mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] WIP IDEA-374760 Move implicit classes inspections to Java 25 migration aids category
- move to java 25 folder - update tests and fix error with incorrect resolve with new language levels - IO.println will be updated later GitOrigin-RevId: 93985096433766e33178da6048ce4554063841a2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
128454480a
commit
26814db524
+8
-1
@@ -281,6 +281,14 @@ public final class ExplicitToImplicitClassMigrationInspection extends AbstractBa
|
||||
CommentTracker tracker = new CommentTracker();
|
||||
String body = tracker.rangeText(lBrace.getNextSibling(), rBrace.getPrevSibling());
|
||||
PsiImplicitClass newClass = PsiElementFactory.getInstance(project).createImplicitClassFromText(body, psiClass);
|
||||
if(!(newClass.getContainingFile() instanceof PsiJavaFile dummyFile) ||
|
||||
dummyFile.getImportList() == null ||
|
||||
javaFile.getImportList() == null) {
|
||||
return;
|
||||
}
|
||||
//it is necessary to resolve accurately inside a new implicit class
|
||||
//collisions will be resolved after it
|
||||
dummyFile.getImportList().replace(javaFile.getImportList());
|
||||
PsiElement replaced = tracker.replace(psiClass, newClass);
|
||||
if (!(replaced instanceof PsiImplicitClass implicitClass)) {
|
||||
return;
|
||||
@@ -290,7 +298,6 @@ public final class ExplicitToImplicitClassMigrationInspection extends AbstractBa
|
||||
|
||||
cleanMainMethod(implicitClass);
|
||||
|
||||
|
||||
PsiFile replacedContainingFile = replaced.getContainingFile();
|
||||
if (replacedContainingFile != null) {
|
||||
JavaCodeStyleManager.getInstance(project).optimizeImports(replacedContainingFile);
|
||||
|
||||
@@ -1690,13 +1690,13 @@
|
||||
key="inspection.string.template.reverse.migration.name"/>
|
||||
<localInspection groupPathKey="group.path.names.java.language.level.specific.issues.and.migration.aids" language="JAVA"
|
||||
groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.language.level.specific.issues.and.migration.aids21" enabledByDefault="true" level="INFORMATION"
|
||||
groupKey="group.names.language.level.specific.issues.and.migration.aids25" enabledByDefault="true" level="INFORMATION"
|
||||
implementationClass="com.intellij.codeInspection.ImplicitToExplicitClassBackwardMigrationInspection"
|
||||
bundle="messages.JavaBundle"
|
||||
key="inspection.implicit.to.explicit.class.backward.migration.name"/>
|
||||
<localInspection groupPathKey="group.path.names.java.language.level.specific.issues.and.migration.aids" language="JAVA"
|
||||
groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.language.level.specific.issues.and.migration.aids21" enabledByDefault="true" level="WARNING"
|
||||
groupKey="group.names.language.level.specific.issues.and.migration.aids25" enabledByDefault="true" level="WARNING"
|
||||
implementationClass="com.intellij.codeInspection.ExplicitToImplicitClassMigrationInspection"
|
||||
bundle="messages.JavaBundle"
|
||||
editorAttributes="NOT_USED_ELEMENT_ATTRIBUTES"
|
||||
|
||||
+4
-4
@@ -1,18 +1,18 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports ordinary classes, which can be converted into implicitly declared classes
|
||||
Reports ordinary classes, which can be converted into compact source files
|
||||
<p><b>Example:</b></p>
|
||||
<pre><code>
|
||||
public class Sample {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, world!");
|
||||
String a = "Hello, world!";
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<p>After the quick-fix is applied:</p>
|
||||
<pre><code>
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, world!");
|
||||
void main() {
|
||||
String a = "Hello, world!";
|
||||
}
|
||||
</code></pre>
|
||||
<!-- tooltip end -->
|
||||
|
||||
+5
-5
@@ -1,17 +1,17 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports implicitly declared classes and suggests replacing them with regular classes.
|
||||
Reports compact source files and suggests replacing them with regular classes.
|
||||
<p><b>Example (in file Sample.java):</b></p>
|
||||
<pre><code>
|
||||
public static void main() {
|
||||
System.out.println("Hello, world!");
|
||||
void main() {
|
||||
String a = "Hello, world!";
|
||||
}
|
||||
</code></pre>
|
||||
<p>After the quick-fix is applied:</p>
|
||||
<pre><code>
|
||||
public class Sample {
|
||||
public static void main() {
|
||||
System.out.println("Hello, world!");
|
||||
void main() {
|
||||
String a = "Hello, world!";
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class ExplicitToImplicitClassMigrationInspectionInspectionTest extends Li
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_23;
|
||||
return JAVA_LATEST_WITH_LATEST_JDK;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class ImplicitToExplicitClassBackwardMigrationInspectionTest extends Ligh
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_23;
|
||||
return JAVA_LATEST_WITH_LATEST_JDK;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -211,6 +211,7 @@ group.names.language.level.specific.issues.and.migration.aids15=Java 15
|
||||
group.names.language.level.specific.issues.and.migration.aids16=Java 16
|
||||
group.names.language.level.specific.issues.and.migration.aids21=Java 21
|
||||
group.names.language.level.specific.issues.and.migration.aids23=Java 23
|
||||
group.names.language.level.specific.issues.and.migration.aids25=Java 25
|
||||
group.names.javabeans.issues=JavaBeans issues
|
||||
group.names.inheritance.issues=Inheritance issues
|
||||
group.names.data.flow.issues=Data flow
|
||||
|
||||
Reference in New Issue
Block a user