mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] skip parenthesis (EA-58298)
This commit is contained in:
+4
-2
@@ -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();
|
||||
|
||||
+4
-4
@@ -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) {
|
||||
|
||||
+15
@@ -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"
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user