mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] tuple expressions cannot have types, as well as they cannot
be a subject for introducing variable or parameter.
This commit is contained in:
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnState
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrTupleExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
@@ -143,6 +144,7 @@ public class GroovyUncheckedAssignmentOfMemberOfRawTypeInspection extends BaseIn
|
||||
super.visitAssignmentExpression(assignment);
|
||||
|
||||
GrExpression lValue = assignment.getLValue();
|
||||
if (lValue instanceof GrTupleExpression) return;
|
||||
if (!PsiUtil.mightBeLValue(lValue)) return;
|
||||
|
||||
IElementType opToken = assignment.getOperationTokenType();
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,8 +65,6 @@ public class GroovyGStringKeyInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
public void visitExpression(@NotNull GrExpression grExpression) {
|
||||
if (!isGStringType(grExpression)) return;
|
||||
|
||||
final PsiElement gstringParent = grExpression.getParent();
|
||||
if (gstringParent == null || !(gstringParent instanceof GrArgumentList)) return;
|
||||
|
||||
@@ -78,6 +76,7 @@ public class GroovyGStringKeyInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isGStringType(grExpression)) return;
|
||||
if (!isMapPutMethod((GrMethodCall)grandparent)) return;
|
||||
|
||||
registerError(grExpression);
|
||||
|
||||
+10
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
@@ -31,18 +30,16 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrTupleE
|
||||
*/
|
||||
public class GrTupleExpressionImpl extends GrExpressionImpl implements GrTupleExpression {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Tuple Assignment Expression";
|
||||
}
|
||||
|
||||
public GrTupleExpressionImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getType() {
|
||||
return getTypeByFQName(CommonClassNames.JAVA_UTIL_LIST);
|
||||
// The reason this method exists is that tuple expression can appear in the left side of an assignment.
|
||||
// LHS should probably have its own interface with implementations: GrReferenceExpression, GrIndexProperty, GrTupleExpression,
|
||||
// while GrTupleExpression will just implement it, but not an GrExpression.
|
||||
throw new UnsupportedOperationException("Tuple expressions cannot have type");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,4 +58,9 @@ public class GrTupleExpressionImpl extends GrExpressionImpl implements GrTupleEx
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitTupleExpression(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Tuple Assignment Expression";
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -218,6 +218,7 @@ public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSetting
|
||||
}
|
||||
|
||||
public static boolean expressionIsIncorrect(@Nullable GrExpression expression, boolean acceptVoidCalls) {
|
||||
if (expression instanceof GrTupleExpression) return true;
|
||||
if (expression instanceof GrParenthesizedExpression) return true;
|
||||
if (PsiUtil.isSuperReference(expression)) return true;
|
||||
if (expression instanceof GrAssignmentExpression) return true;
|
||||
|
||||
Reference in New Issue
Block a user