mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
expand static import: available on the onDemand import (IDEA-175102)
This commit is contained in:
+6
-6
@@ -17,7 +17,6 @@ package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -40,7 +39,7 @@ public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return "Expand Static Import";
|
||||
return "Expand static import";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,15 +54,16 @@ public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
|
||||
if (resolveScope instanceof PsiImportStaticStatement) {
|
||||
final PsiClass targetClass = ((PsiImportStaticStatement)resolveScope).resolveTargetClass();
|
||||
if (targetClass == null) return false;
|
||||
setText("Expand static import to " + targetClass.getName() + "." + referenceElement.getReferenceName());
|
||||
setText("Replace static import with qualified access to " + targetClass.getName());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static PsiElement getImportStaticStatement(PsiJavaCodeReferenceElement referenceElement) {
|
||||
return referenceElement instanceof PsiImportStaticReferenceElement ? referenceElement.getParent()
|
||||
: referenceElement.advancedResolve(true).getCurrentFileResolveScope();
|
||||
PsiElement parent = referenceElement.getParent();
|
||||
return parent instanceof PsiImportStaticStatement ? parent
|
||||
: referenceElement.advancedResolve(true).getCurrentFileResolveScope();
|
||||
}
|
||||
|
||||
public void invoke(final Project project, final PsiFile file, final Editor editor, PsiElement element) {
|
||||
@@ -76,7 +76,7 @@ public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
|
||||
staticImport.delete();
|
||||
}
|
||||
else {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || refExpr instanceof PsiImportStaticReferenceElement) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || refExpr.getParent() instanceof PsiImportStaticStatement) {
|
||||
replaceAllAndDeleteImport(expressionToExpand, refExpr, staticImport);
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
public void sendMessage(String... destinationAddressNames) {
|
||||
Arrays.sort(destinationAddressNames);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
class Test {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import static java.util.Array<caret>s.*;
|
||||
|
||||
class Test {
|
||||
public void sendMessage(String... destinationAddressNames) {
|
||||
sort(destinationAddressNames);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import static java.util.Arrays.so<caret>rt;
|
||||
|
||||
class Test {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import static java.util.Arrays.sort;
|
||||
|
||||
class Test {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Expand static import to Arrays.sort" "true"
|
||||
// "Replace static import with qualified access to Arrays" "true"
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
class Test {
|
||||
|
||||
Reference in New Issue
Block a user