mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-92963 Groovy: Good code is red (Invalid value to assign to)
This commit is contained in:
@@ -69,6 +69,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClaus
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrPropertySelection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
@@ -653,8 +654,12 @@ public class PsiUtil {
|
||||
public static boolean mightBeLValue(@Nullable GrExpression expr) {
|
||||
if (expr instanceof GrParenthesizedExpression) return mightBeLValue(((GrParenthesizedExpression)expr).getOperand());
|
||||
|
||||
if (expr instanceof GrTupleExpression) return true;
|
||||
if (expr instanceof GrReferenceExpression || expr instanceof GrIndexProperty) return true;
|
||||
if (expr instanceof GrTupleExpression ||
|
||||
expr instanceof GrReferenceExpression ||
|
||||
expr instanceof GrIndexProperty ||
|
||||
expr instanceof GrPropertySelection) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((expr instanceof GrThisReferenceExpression || expr instanceof GrSuperReferenceExpression) &&
|
||||
GroovyConfigUtils.getInstance().isVersionAtLeast(expr, GroovyConfigUtils.GROOVY1_8)) {
|
||||
|
||||
+12
@@ -884,6 +884,18 @@ class X {
|
||||
}
|
||||
}
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
void testPropertySelectionMayBeLValue() {
|
||||
testHighlighting('''\
|
||||
def methodMissing(String methodName, args) {
|
||||
def closure = {
|
||||
callSomeOtherMethodInstead()
|
||||
}
|
||||
this.metaClass."$methodName" = closure
|
||||
<error descr="Invalid value to assign to">closure()</error> = 2
|
||||
}
|
||||
''')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user