[groovy] add api for determining whether some expression is not really an expression

This commit is contained in:
Daniil Ovchinnikov
2019-01-24 14:47:33 +03:00
parent a4af51dffa
commit fce5051b76
3 changed files with 32 additions and 0 deletions
@@ -0,0 +1,15 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang
import org.jetbrains.annotations.ApiStatus.Experimental
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
@Experimental
interface GroovyExpressionFilter {
/**
* @return `true` if [expression] is not really an expression,
* meaning it would be transformed into something else
*/
fun isFake(expression: GrExpression): Boolean
}
@@ -0,0 +1,16 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
@file:JvmName("GroovyExpressionUtil")
package org.jetbrains.plugins.groovy.lang.psi.util
import com.intellij.openapi.extensions.ExtensionPointName
import org.jetbrains.plugins.groovy.lang.GroovyExpressionFilter
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
private val EP_NAME = ExtensionPointName.create<GroovyExpressionFilter>("org.intellij.groovy.expressionFilter")
fun GrExpression.isFake(): Boolean {
return EP_NAME.extensions.any {
it.isFake(this)
}
}
+1
View File
@@ -82,6 +82,7 @@
<extensionPoint name="gdslScriptProvider" interface="org.jetbrains.plugins.groovy.dsl.GdslScriptProvider"/>
<extensionPoint name="expectedPackageNameProvider" interface="org.jetbrains.plugins.groovy.lang.resolve.ExpectedPackageNameProvider"/>
<extensionPoint name="delegatesToProvider" interface="org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.GrDelegatesToProvider"/>
<extensionPoint name="expressionFilter" interface="org.jetbrains.plugins.groovy.lang.GroovyExpressionFilter"/>
</extensionPoints>
<extensions defaultExtensionNs="org.intellij.groovy">