mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: better types for script variables
This commit is contained in:
+8
-2
@@ -170,9 +170,15 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getPresentableElement(PsiElement element) {
|
||||
if (element instanceof PsiJavaCodeReferenceElement) {
|
||||
if (element instanceof PsiReferenceExpression) {
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiTypeElement) {
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
else if (element instanceof PsiJavaCodeReferenceElement) {
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiTypeElement || parent instanceof PsiNewExpression || parent instanceof PsiAnnotation) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class StructuralSearchUtil {
|
||||
if (profile == null) {
|
||||
return element;
|
||||
}
|
||||
return getParentIfIdentifier(profile.getPresentableElement(element));
|
||||
return profile.getPresentableElement(getParentIfIdentifier(element));
|
||||
}
|
||||
|
||||
private static StructuralSearchProfile[] getNewStyleProfiles() {
|
||||
|
||||
+9
-4
@@ -1177,10 +1177,12 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
|
||||
final String source2 = "class A {" +
|
||||
" String s = new String();" +
|
||||
" int m() {" +
|
||||
" @SuppressWarnings(\"\") int m() {" +
|
||||
" n();" +
|
||||
" int i = 2+1;" +
|
||||
" return i;" +
|
||||
" }" +
|
||||
" void n() {}" +
|
||||
"}";
|
||||
assertEquals("type of variables in script are as expected", 1,
|
||||
findMatchesCount(source2,
|
||||
@@ -1196,11 +1198,14 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
"g instanceof PsiTypeElement &&" +
|
||||
"h instanceof PsiLocalVariable &&" +
|
||||
"i instanceof PsiPolyadicExpression &&" +
|
||||
"j instanceof PsiReferenceExpression\n" +
|
||||
"j instanceof PsiReferenceExpression &&" +
|
||||
"k instanceof PsiMethodCallExpression &&" +
|
||||
"l instanceof PsiAnnotation\n" +
|
||||
"\")]" +
|
||||
"class '_a {" +
|
||||
" '_b '_c = '_d;" +
|
||||
" '_e '_f() {" +
|
||||
" '_b '_c = new '_d();" +
|
||||
" @'_l '_e '_f() {" +
|
||||
" '_k();" +
|
||||
" '_g '_h = '_i;" +
|
||||
" return '_j;" +
|
||||
" }" +
|
||||
|
||||
Reference in New Issue
Block a user