Skip to content

Commit 8209f3d

Browse files
committed
chore: check if groovy lang before type check
1 parent d6138de commit 8209f3d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/service/JVMArtifactCreationService.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package spp.jetbrains.marker.jvm.service
1818

19+
import com.intellij.lang.Language
1920
import com.intellij.openapi.diagnostic.logger
2021
import com.intellij.psi.PsiDeclarationStatement
2122
import com.intellij.psi.PsiElement
@@ -116,18 +117,18 @@ class JVMArtifactCreationService : IArtifactCreationService {
116117
autoApply: Boolean
117118
): Optional<ExpressionInlayMark> {
118119
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+
}
123126
}
124127

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()
131132
}
132133
}
133134

0 commit comments

Comments
 (0)