mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-64741 Elvis inspection bug
This commit is contained in:
+2
-1
@@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ConditionalExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeSpec;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
@@ -41,7 +42,7 @@ public class UnaryExpressionNotPlusMinus implements GroovyElementTypes {
|
||||
if (builder.getTokenType() == mLPAREN) {
|
||||
final ReferenceElement.ReferenceElementResult result = parseTypeCast(builder);
|
||||
if (result != fail) {
|
||||
if (UnaryExpression.parse(builder, parser) || result == ReferenceElement.ReferenceElementResult.mustBeType) {
|
||||
if (ConditionalExpression.parse(builder, parser) || result == ReferenceElement.ReferenceElementResult.mustBeType) {
|
||||
marker.done(CAST_EXPRESSION);
|
||||
return true;
|
||||
} else {
|
||||
|
||||
+2
@@ -187,6 +187,8 @@ public class ExpressionsParsingTest extends GroovyParsingTestCase {
|
||||
public void testtypecast$una4() throws Throwable { doTest(); }
|
||||
public void testtypecast$una5() throws Throwable { doTest(); }
|
||||
public void testtypecast$una6() throws Throwable { doTest(); }
|
||||
public void testtypecast$elvis() throws Throwable { doTest(); }
|
||||
public void testtypecast$conditional() throws Throwable { doTest(); }
|
||||
|
||||
public void testAtHang() throws Throwable { doTest(); }
|
||||
public void testDollar() throws Throwable { doTest(); }
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
def list = (List<String>) foo?bar: bar
|
||||
-----
|
||||
Groovy script
|
||||
Variable definitions
|
||||
Modifiers
|
||||
PsiElement(def)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
Variable
|
||||
PsiElement(identifier)('list')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(=)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
Typecast expression
|
||||
PsiElement(()('(')
|
||||
Type element
|
||||
Reference element
|
||||
PsiElement(identifier)('List')
|
||||
Type arguments
|
||||
PsiElement(<)('<')
|
||||
Type element
|
||||
Reference element
|
||||
PsiElement(identifier)('String')
|
||||
PsiElement(>)('>')
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Conditional expression
|
||||
Reference expression
|
||||
PsiElement(identifier)('foo')
|
||||
PsiElement(?)('?')
|
||||
Reference expression
|
||||
PsiElement(identifier)('bar')
|
||||
PsiElement(:)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
Reference expression
|
||||
PsiElement(identifier)('bar')
|
||||
@@ -0,0 +1,32 @@
|
||||
def list = (List<String>) foo?: bar
|
||||
-----
|
||||
Groovy script
|
||||
Variable definitions
|
||||
Modifiers
|
||||
PsiElement(def)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
Variable
|
||||
PsiElement(identifier)('list')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(=)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
Typecast expression
|
||||
PsiElement(()('(')
|
||||
Type element
|
||||
Reference element
|
||||
PsiElement(identifier)('List')
|
||||
Type arguments
|
||||
PsiElement(<)('<')
|
||||
Type element
|
||||
Reference element
|
||||
PsiElement(identifier)('String')
|
||||
PsiElement(>)('>')
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Elvis expression
|
||||
Reference expression
|
||||
PsiElement(identifier)('foo')
|
||||
PsiElement(?:)('?:')
|
||||
PsiWhiteSpace(' ')
|
||||
Reference expression
|
||||
PsiElement(identifier)('bar')
|
||||
Reference in New Issue
Block a user