|
16 | 16 | */
|
17 | 17 | package spp.jetbrains.marker.jvm.service
|
18 | 18 |
|
| 19 | +import com.intellij.lang.Language |
19 | 20 | import com.intellij.openapi.diagnostic.logger
|
20 | 21 | import com.intellij.psi.PsiDeclarationStatement
|
21 | 22 | import com.intellij.psi.PsiElement
|
@@ -116,18 +117,18 @@ class JVMArtifactCreationService : IArtifactCreationService {
|
116 | 117 | autoApply: Boolean
|
117 | 118 | ): Optional<ExpressionInlayMark> {
|
118 | 119 | val element = SourceMarkerUtils.getElementAtLine(fileMarker.psiFile, lineNumber)
|
119 |
| - if (element is LeafPsiElement && element.parent is GrImportStatement) { |
120 |
| - return Optional.empty() |
121 |
| - } else if (element is LeafPsiElement && element.parent is GrPackageDefinition) { |
122 |
| - return Optional.empty() |
| 120 | + if (element is LeafPsiElement && element.language == Language.findLanguageByID("Groovy")) { |
| 121 | + if (element.parent is GrImportStatement) { |
| 122 | + return Optional.empty() |
| 123 | + } else if (element.parent is GrPackageDefinition) { |
| 124 | + return Optional.empty() |
| 125 | + } |
123 | 126 | }
|
124 | 127 |
|
125 |
| - return if (element is PsiStatement) { |
126 |
| - Optional.ofNullable(getOrCreateExpressionInlayMark(fileMarker, element, autoApply)) |
127 |
| - } else if (element is PsiElement) { |
128 |
| - Optional.ofNullable(getOrCreateExpressionInlayMark(fileMarker, element, autoApply)) |
129 |
| - } else { |
130 |
| - Optional.empty() |
| 128 | + return when (element) { |
| 129 | + is PsiStatement -> Optional.ofNullable(getOrCreateExpressionInlayMark(fileMarker, element, autoApply)) |
| 130 | + is PsiElement -> Optional.ofNullable(getOrCreateExpressionInlayMark(fileMarker, element, autoApply)) |
| 131 | + else -> Optional.empty() |
131 | 132 | }
|
132 | 133 | }
|
133 | 134 |
|
|
0 commit comments