mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
JavaIntentionPolicy: do not parenthesize unresolved qualifiers that could resolve to packages
GitOrigin-RevId: 11f55edaedc828c861c28e479d17e3efd651db9f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
93b455aaab
commit
d84fd8b7dd
@@ -211,6 +211,14 @@ class JavaParenthesesPolicy extends JavaIntentionPolicy {
|
||||
if (target instanceof PsiPackage || target instanceof PsiClass) {
|
||||
return true;
|
||||
}
|
||||
if (target == null) {
|
||||
// unresolved qualifier: if it's just reference chain like a.b.c it could be inaccessible package, so let's avoid parenthesizing it
|
||||
PsiExpression qualifier = expression;
|
||||
while (qualifier instanceof PsiReferenceExpression) {
|
||||
qualifier = ((PsiReferenceExpression)qualifier).getQualifierExpression();
|
||||
}
|
||||
return qualifier == null;
|
||||
}
|
||||
}
|
||||
if (expression instanceof PsiArrayInitializerExpression && parent instanceof PsiArrayInitializerExpression) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user