java: disable AddOnDemandStaticImportAction on broken code where it'd break stub-text consistency otherwise

GitOrigin-RevId: 705892a1471eff7797a1fe2abfcbd320849dd76e
This commit is contained in:
Peter Gromov
2020-08-03 14:59:37 +02:00
committed by intellij-monorepo-bot
parent 74fb322770
commit 457c7b42b6
2 changed files with 15 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.util.IncorrectOperationException;
import com.siyeh.ig.psiutils.ClassUtils;
@@ -58,6 +59,10 @@ public class AddOnDemandStaticImportAction extends BaseElementAtCaretIntentionAc
if (!(gParent instanceof PsiJavaCodeReferenceElement) ||
isParameterizedReference((PsiJavaCodeReferenceElement)gParent)) return null;
if (PsiUtilCore.getElementType(PsiTreeUtil.nextCodeLeaf(gParent)) == JavaTokenType.ARROW) {
return null;
}
PsiElement resolved = refExpr.resolve();
if (!(resolved instanceof PsiClass)) {
return null;

View File

@@ -0,0 +1,10 @@
// "Add on-demand static import for 'test.Bar'" "false"
package test;
class Bar {
{
SomeLambda l =
Ba<caret>r.param -> ();
}
}