@@ -65,11 +65,11 @@ class ColorLineMarkerProvider : LineMarkerProvider {
65
65
ColorIcon (12 , color),
66
66
FunctionUtil .nullConstant<Any , String >(),
67
67
GutterIconNavigationHandler handler@{ _, psiElement ->
68
- if (! psiElement.isWritable || ! element .isValid) {
68
+ if (psiElement == null || ! psiElement.isWritable || ! psiElement .isValid || ! workElement.isPsiValid ) {
69
69
return @handler
70
70
}
71
71
72
- val editor = PsiEditorUtil .findEditor(element ) ? : return @handler
72
+ val editor = PsiEditorUtil .findEditor(psiElement ) ? : return @handler
73
73
74
74
val picker = ColorPicker (map, editor.component)
75
75
val newColor = picker.showDialog()
@@ -117,18 +117,20 @@ class ColorLineMarkerProvider : LineMarkerProvider {
117
117
) : ColorLineMarkerProvider.ColorInfo(
118
118
element,
119
119
color,
120
- GutterIconNavigationHandler handler@{ _, _ ->
121
- if (!element.isWritable || !element.isValid) {
120
+ GutterIconNavigationHandler handler@{ _, psiElement ->
121
+ if (psiElement == null || !psiElement.isValid ||
122
+ !workElement.isPsiValid || workElement.sourcePsi?.isWritable != true
123
+ ) {
122
124
return @handler
123
125
}
124
126
125
- val editor = PsiEditorUtil .findEditor(element ) ? : return @handler
126
- if (JVMElementFactories .getFactory(element .language, element .project) == null) {
127
+ val editor = PsiEditorUtil .findEditor(psiElement ) ? : return @handler
128
+ if (JVMElementFactories .getFactory(psiElement .language, psiElement .project) == null) {
127
129
// The setColor methods used here require a JVMElementFactory. Unfortunately the Kotlin plugin does not
128
130
// implement it yet. It is better to not display the color chooser at all than deceiving users after
129
131
// after they chose a color
130
132
HintManager .getInstance()
131
- .showErrorHint(editor, "Can 't change colors in " + element .language.displayName)
133
+ .showErrorHint(editor, "Can 't change colors in " + psiElement .language.displayName)
132
134
return @handler
133
135
}
134
136
0 commit comments