mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] IJ-CR-167924 IDEA-371865 Inspection to convert 'System.out'<->'IO'
- extract "java.lang.IO" - tests for allowUnresolved - more reliable works with varargs GitOrigin-RevId: 8376baaa86afa3806cb096cffd42e9ed0db0d451
This commit is contained in:
committed by
intellij-monorepo-bot
parent
de315fe676
commit
7369bd9f90
+4
-2
@@ -11,14 +11,16 @@ import com.siyeh.ig.callMatcher.CallMatcher;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.psi.CommonClassNames.JAVA_LANG_IO;
|
||||
|
||||
public final class MigrateFromJavaLangIoInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
|
||||
private static final CallMatcher IO_PRINT =
|
||||
CallMatcher.anyOf(
|
||||
CallMatcher.staticCall("java.lang.IO", "println")
|
||||
CallMatcher.staticCall(JAVA_LANG_IO, "println")
|
||||
.parameterCount(0)
|
||||
.allowUnresolved(),
|
||||
CallMatcher.staticCall("java.lang.IO", "println", "print")
|
||||
CallMatcher.staticCall(JAVA_LANG_IO, "println", "print")
|
||||
.parameterCount(1)
|
||||
.allowUnresolved()
|
||||
);
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ public final class MigrateToJavaLangIoInspection extends AbstractBaseJavaLocalIn
|
||||
PsiReferenceExpression methodExpr = methodCall.getMethodExpression();
|
||||
String methodName = methodExpr.getReferenceName();
|
||||
if (methodName == null) return;
|
||||
PsiElement replaced = new CommentTracker().replaceAndRestoreComments(methodExpr, "java.lang.IO." + methodName);
|
||||
PsiElement replaced = new CommentTracker().replaceAndRestoreComments(methodExpr, JAVA_LANG_IO + "." + methodName);
|
||||
if (replaced instanceof PsiReferenceExpression replacedReferenceExpression) {
|
||||
JavaCodeStyleManager.getInstance(replacedReferenceExpression.getProject()).shortenClassReferences(replacedReferenceExpression);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user