[groovy] skip parenthesis (EA-58298)

This commit is contained in:
Daniil Ovchinnikov
2016-03-10 21:00:25 +03:00
parent f337674170
commit a86989f51b
3 changed files with 23 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -52,6 +52,8 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUt
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.skipParentheses;
/**
* @author ven
*/
@@ -169,7 +171,7 @@ public class TypeInferenceHelper {
@Nullable
public static PsiType getInitializerTypeFor(PsiElement element) {
final PsiElement parent = element.getParent();
final PsiElement parent = skipParentheses(element.getParent(), true);
if (parent instanceof GrAssignmentExpression) {
if (element instanceof GrIndexProperty) {
final GrExpression rvalue = ((GrAssignmentExpression)parent).getRValue();
@@ -96,12 +96,12 @@ public class SubstitutorComputer {
}
}
else if (parent instanceof GrAssignmentExpression && myPlaceToInferContext.equals(((GrAssignmentExpression)parent).getRValue())) {
GrExpression lValue = ((GrAssignmentExpression)parent).getLValue();
if (lValue instanceof GrIndexProperty) {
return null;
PsiElement lValue = PsiUtil.skipParentheses(((GrAssignmentExpression)parent).getLValue(), false);
if ((lValue instanceof GrExpression) && !(lValue instanceof GrIndexProperty)) {
return ((GrExpression)lValue).getType();
}
else {
return lValue.getType();
return null;
}
}
else if (parent instanceof GrVariable) {
@@ -1987,6 +1987,21 @@ class Main {
println "Works: $x = $t"
}
}
'''
testHighlighting '''
class Main {
static <T> T foo() {}
static void main(String[] args) {
def main = new Main()
(main[Main]) = foo()
}
def putAt(x, String t) {
println "Works: $x = $t"
}
}
'''
}
}