mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[Groovy] Convert Groovy files to Java. Refactor and remove groovy runtime.
- GrAnnotationReferencingUnknownIdentifiersTest - GrDependencyVisitorTest - GrNamedVariantLabelsInspectionTest - GroovyRunLineMarkerTest - GrSpreadArgumentTest - ImmutableTransformationSupportTest IDEA-327339 GitOrigin-RevId: 29f75855ec6bbbdf66dd16c7fb3e8c7ec4719e77
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c9d89414d0
commit
2d44f6bf42
@@ -2,7 +2,6 @@
|
||||
package org.jetbrains.plugins.groovy.codeInspection.bugs;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import groovy.lang.Reference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package org.jetbrains.plugins.groovy.codeInspection.bugs;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import groovy.lang.Reference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
|
||||
@@ -14,10 +13,6 @@ public class GrNamedVariantLabelsInspectionTest extends LightGroovyTestCase {
|
||||
return GroovyProjectDescriptors.GROOVY_2_5;
|
||||
}
|
||||
|
||||
public static GrNamedVariantLabelsInspection getInspection() {
|
||||
return new GrNamedVariantLabelsInspection();
|
||||
}
|
||||
|
||||
public void testBasic() {
|
||||
doTest("""
|
||||
|
||||
@@ -93,14 +88,12 @@ public class GrNamedVariantLabelsInspectionTest extends LightGroovyTestCase {
|
||||
}
|
||||
|
||||
private void doTest(String before) {
|
||||
final Reference<String> s = new Reference<>(before);
|
||||
|
||||
myFixture.enableInspections(getInspection());
|
||||
if (s.get().contains("NamedVariant")) s.set("import groovy.transform.NamedVariant\n" + s.get());
|
||||
if (s.get().contains("NamedParam")) s.set("import groovy.transform.NamedParam\n" + s.get());
|
||||
if (s.get().contains("NamedDelegate")) s.set("import groovy.transform.NamedDelegate\n" + s.get());
|
||||
if (s.get().contains("CompileStatic")) s.set("import groovy.transform.CompileStatic\n" + s.get());
|
||||
myFixture.configureByText("_.groovy", s.get());
|
||||
myFixture.enableInspections(new GrNamedVariantLabelsInspection());
|
||||
if (before.contains("NamedVariant")) before = "import groovy.transform.NamedVariant\n" + before;
|
||||
if (before.contains("NamedParam")) before = "import groovy.transform.NamedParam\n" + before;
|
||||
if (before.contains("NamedDelegate")) before = "import groovy.transform.NamedDelegate\n" + before;
|
||||
if (before.contains("CompileStatic")) before = "import groovy.transform.CompileStatic\n" + before;
|
||||
myFixture.configureByText("_.groovy", before);
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.packageDependencies.DependenciesBuilder;
|
||||
import com.intellij.packageDependencies.DependencyVisitorFactory;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -31,11 +32,11 @@ public class GrDependencyVisitorTest extends LightGroovyTestCase {
|
||||
DependenciesBuilder.analyzeFileDependencies(file, (place, dependency) -> {
|
||||
deps.add(dependency);
|
||||
}, DependencyVisitorFactory.VisitorOptions.SKIP_IMPORTS);
|
||||
assert deps.isEmpty();
|
||||
Assert.assertTrue(deps.isEmpty());
|
||||
|
||||
DependenciesBuilder.analyzeFileDependencies(file, (place, dependency) -> {
|
||||
deps.add(dependency);
|
||||
}, DependencyVisitorFactory.VisitorOptions.INCLUDE_IMPORTS);
|
||||
assert deps.size() == 3;
|
||||
Assert.assertEquals(3, deps.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package org.jetbrains.plugins.groovy.fixes;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
import org.jetbrains.plugins.groovy.lang.highlighting.GrHighlightingTestBase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -113,8 +114,8 @@ public class GrSpreadArgumentTest extends GrHighlightingTestBase {
|
||||
myFixture.configureByText("_.groovy", before);
|
||||
myFixture.enableInspections(getCustomInspections());
|
||||
List<IntentionAction> fixes = myFixture.getAllQuickFixes("_.groovy");
|
||||
assert fixes.size() == 1 : before;
|
||||
myFixture.launchAction(DefaultGroovyMethods.first(fixes));
|
||||
Assert.assertEquals(before, 1, fixes.size());
|
||||
myFixture.launchAction(ContainerUtil.getFirstItem(fixes));
|
||||
myFixture.checkResult(after);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class GroovyRunLineMarkerTest extends LightGroovyTestCase {
|
||||
@Override
|
||||
@@ -27,8 +28,8 @@ public class GroovyRunLineMarkerTest extends LightGroovyTestCase {
|
||||
static void main(String[] args) {}
|
||||
}
|
||||
""");
|
||||
assert getFixture().findGuttersAtCaret().isEmpty();
|
||||
assert getFixture().findAllGutters().size() == 2;
|
||||
Assert.assertTrue(getFixture().findGuttersAtCaret().isEmpty());
|
||||
Assert.assertEquals(2, getFixture().findAllGutters().size());
|
||||
}
|
||||
|
||||
public void testImplicitStringArray() {
|
||||
@@ -49,7 +50,7 @@ public class GroovyRunLineMarkerTest extends LightGroovyTestCase {
|
||||
getFixture().configureByText("_.groovy", """
|
||||
class MainTest extends Main {}
|
||||
""");
|
||||
assert getFixture().findAllGutters().size() == 1;
|
||||
Assert.assertEquals(1, getFixture().findAllGutters().size());
|
||||
}
|
||||
|
||||
public void testDefaultParameters() {
|
||||
@@ -58,6 +59,6 @@ public class GroovyRunLineMarkerTest extends LightGroovyTestCase {
|
||||
static void main(String[] args, b = 2) {}
|
||||
}
|
||||
""");
|
||||
assert getFixture().findAllGutters().size() == 2;
|
||||
Assert.assertEquals(2, getFixture().findAllGutters().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
|
||||
@@ -15,6 +14,7 @@ import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilit
|
||||
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.members.GrMethodImpl;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -56,8 +56,8 @@ public class ImmutableTransformationSupportTest extends LightGroovyTestCase {
|
||||
""");
|
||||
PsiClass clazz = myFixture.findClass("CopyWithExistingMethod");
|
||||
PsiMethod[] methods = clazz.findMethodsByName("copyWith", false);
|
||||
assert DefaultGroovyMethods.size(methods) == 1;
|
||||
assert DefaultGroovyMethods.first(methods) instanceof GrMethodImpl;
|
||||
Assert.assertEquals(1, methods.length);
|
||||
Assert.assertTrue(methods[0] instanceof GrMethodImpl);
|
||||
}
|
||||
|
||||
public void testCopyWithResolveArguments() {
|
||||
@@ -67,9 +67,9 @@ public class ImmutableTransformationSupportTest extends LightGroovyTestCase {
|
||||
}
|
||||
""");
|
||||
PsiReference ref = myFixture.getFile().findReferenceAt(getEditor().getCaretModel().getOffset());
|
||||
assert ref != null;
|
||||
Assert.assertNotNull(ref);
|
||||
PsiElement resolved = ref.resolve();
|
||||
assert resolved instanceof GrField;
|
||||
Assert.assertTrue(resolved instanceof GrField);
|
||||
}
|
||||
|
||||
public void testCopyWithCheckArgumentTypes() {
|
||||
@@ -92,6 +92,6 @@ public class ImmutableTransformationSupportTest extends LightGroovyTestCase {
|
||||
}
|
||||
""");
|
||||
myFixture.complete(CompletionType.BASIC);
|
||||
assert myFixture.getLookupElementStrings().containsAll(Arrays.asList("stringProp", "integerProp"));
|
||||
Assert.assertTrue(myFixture.getLookupElementStrings().containsAll(Arrays.asList("stringProp", "integerProp")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user