[java-tests] Convert Groovy to Java

GitOrigin-RevId: 9a4ce6f95a759c52b961452c75109882a9c4bb94
This commit is contained in:
Tagir Valeev
2024-02-21 13:44:08 +01:00
committed by intellij-monorepo-bot
parent abf5b7c3f2
commit f5d7968fa7
3 changed files with 277 additions and 280 deletions

View File

@@ -1,46 +1,44 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.java.codeInsight.navigation
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.codeInsight.navigation;
import com.intellij.codeInsight.navigation.MethodUpDownUtil
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import groovy.transform.CompileStatic
import com.intellij.codeInsight.navigation.MethodUpDownUtil;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
import com.intellij.util.ArrayUtil;
@CompileStatic
class JavaMemberNavigationTest extends LightJavaCodeInsightFixtureTestCase {
void "test include anonymous and local classes"() {
def file = myFixture.configureByText('a.java', '''
class Foo {
void bar() {
new Runnable() {
void run() {}
};
class Local {
void localMethod() {}
}
public class JavaMemberNavigationTest extends LightJavaCodeInsightFixtureTestCase {
public void test_include_anonymous_and_local_classes() {
//noinspection ResultOfObjectAllocationIgnored,override
PsiFile file = myFixture.configureByText("a.java", """
class Foo {
void bar() {
new Runnable() {
void run() {}
};
class Local {
void localMethod() {}
}
}
}
""");
int[] offsets = MethodUpDownUtil.getNavigationOffsets(file, 0);
assertTrue(ArrayUtil.indexOf(offsets, file.getText().indexOf("run")) >= 0);
assertTrue(ArrayUtil.indexOf(offsets, file.getText().indexOf("Local")) >= 0);
assertTrue(ArrayUtil.indexOf(offsets, file.getText().indexOf("localMethod")) >= 0);
}
}
''')
def offsets = MethodUpDownUtil.getNavigationOffsets(file, 0)
assert file.text.indexOf('run') in offsets
assert file.text.indexOf('Local') in offsets
assert file.text.indexOf('localMethod') in offsets
}
void "test type parameters are not included"() {
def file = myFixture.configureByText('a.java', '''
class Foo {
<T> void m1(T t) {}
}
''')
def offsets = MethodUpDownUtil.getNavigationOffsets(file, 0)
String typeParameterText = "<T>"
def start = file.text.indexOf(typeParameterText)
def end = start + typeParameterText.length()
public void test_type_parameters_are_not_included() {
PsiFile file = myFixture.configureByText("a.java", """
class Foo {
<T> void m1(T t) {}
}
""");
int[] offsets = MethodUpDownUtil.getNavigationOffsets(file, 0);
String typeParameterText = "<T>";
int start = file.getText().indexOf(typeParameterText);
int end = start + typeParameterText.length();
for (int offset : offsets) {
assert offset < start || offset > end
assertTrue(offset < start || offset > end);
}
}
}

View File

@@ -1,145 +1,153 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.codeInsight.psi
package com.intellij.java.codeInsight.psi;
import com.intellij.codeInsight.AnnotationUtil
import com.intellij.pom.java.LanguageLevel
import com.intellij.psi.*
import com.intellij.psi.impl.source.PsiImmediateClassType
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiImmediateClassType;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
import com.intellij.util.containers.ContainerUtil;
import static com.intellij.codeInsight.AnnotationUtil.CHECK_TYPE
import java.util.Arrays;
class AnnotatedTypeTest extends LightJavaCodeInsightFixtureTestCase {
private PsiElementFactory factory
private PsiElement context
import static com.intellij.codeInsight.AnnotationUtil.CHECK_TYPE;
public class AnnotatedTypeTest extends LightJavaCodeInsightFixtureTestCase {
private PsiElementFactory factory;
private PsiElement context;
@Override
void setUp() {
super.setUp()
public void setUp() throws Exception {
super.setUp();
factory = myFixture.javaFacade.elementFactory
context = myFixture.addClass("""\
package pkg;
factory = myFixture.getJavaFacade().getElementFactory();
context = myFixture.addClass("""
package pkg;
import java.lang.annotation.*;
import java.lang.annotation.*;
@interface A { }
@Target(ElementType.TYPE_USE) @interface TA { int value() default 42; }
@interface A { }
@Target(ElementType.TYPE_USE) @interface TA { int value() default 42; }
class O { class I { } }
class O { class I { } }
@SuppressWarnings("ExceptionClassNameDoesntEndWithException") class E1 extends Exception { }
@SuppressWarnings("ExceptionClassNameDoesntEndWithException") class E2 extends Exception { }""".stripIndent())
@SuppressWarnings("ExceptionClassNameDoesntEndWithException") class E1 extends Exception { }
@SuppressWarnings("ExceptionClassNameDoesntEndWithException") class E2 extends Exception { }""".stripIndent());
}
@Override
void tearDown() {
factory = null
context = null
super.tearDown()
public void tearDown() throws Exception {
factory = null;
context = null;
super.tearDown();
}
void testPrimitiveArrayType() {
doTest("@A @TA(1) int @TA(2) [] a", "int[]", "@pkg.TA(1) int @pkg.TA(2) []", "int[]", "@TA int @TA []")
public void testPrimitiveArrayType() {
doTest("@A @TA(1) int @TA(2) [] a", "int[]", "@pkg.TA(1) int @pkg.TA(2) []", "int[]", "@TA int @TA []");
}
void testEllipsisType() {
doTest("@TA int @TA ... p", "int...", "@pkg.TA int @pkg.TA ...", "int...", "@TA int @TA ...")
public void testEllipsisType() {
doTest("@TA int @TA ... p", "int...", "@pkg.TA int @pkg.TA ...", "int...", "@TA int @TA ...");
}
void testClassReferenceType() {
doTest("@A @TA(1) String s", "java.lang.String", "java.lang.@pkg.TA(1) String", "String", "@TA String")
public void testClassReferenceType() {
doTest("@A @TA(1) String s", "java.lang.String", "java.lang.@pkg.TA(1) String", "String", "@TA String");
}
void testQualifiedClassReferenceType() {
doTest("@A java.lang.@TA(1) String s", "java.lang.String", "java.lang.@pkg.TA(1) String", "String", "@TA String")
public void testQualifiedClassReferenceType() {
doTest("@A java.lang.@TA(1) String s", "java.lang.String", "java.lang.@pkg.TA(1) String", "String", "@TA String");
}
void testQualifiedPackageClassReferenceType() {
doTest("@A @TA java.lang.String s", "java.lang.String", "java.lang.String", "String", "String" ) // packages can't have type annotations
public void testQualifiedPackageClassReferenceType() {
doTest("@A @TA java.lang.String s", "java.lang.String", "java.lang.String", "String", "String");// packages can't have type annotations
}
void testPartiallyQualifiedClassReferenceType() {
doTest("@TA(1) O.@TA(2) I i", "pkg.O.I", "pkg.@pkg.TA(1) O.@pkg.TA(2) I", "I", "@TA O.@TA I")
public void testPartiallyQualifiedClassReferenceType() {
doTest("@TA(1) O.@TA(2) I i", "pkg.O.I", "pkg.@pkg.TA(1) O.@pkg.TA(2) I", "I", "@TA O.@TA I");
}
void testCStyleArrayType() {
doTest("@A @TA(1) String @TA(2) [] f @TA(3) []",
"java.lang.String[][]", "java.lang.@pkg.TA(1) String @pkg.TA(3) [] @pkg.TA(2) []",
"String[][]", "@TA String @TA [] @TA []")
public void testCStyleArrayType() {
doTest("@A @TA(1) String @TA(2) [] f @TA(3) []", "java.lang.String[][]", "java.lang.@pkg.TA(1) String @pkg.TA(3) [] @pkg.TA(2) []",
"String[][]", "@TA String @TA [] @TA []");
}
void testCStyleMultiArrayType() {
doTest("@A @TA(1) String @TA(2) [] @TA(3) [] f @TA(4) [] @TA(5) []",
"java.lang.String[][][][]", "java.lang.@pkg.TA(1) String @pkg.TA(4) [] @pkg.TA(5) [] @pkg.TA(2) [] @pkg.TA(3) []",
"String[][][][]", "@TA String @TA [] @TA [] @TA [] @TA []")
public void testCStyleMultiArrayType() {
doTest("@A @TA(1) String @TA(2) [] @TA(3) [] f @TA(4) [] @TA(5) []", "java.lang.String[][][][]",
"java.lang.@pkg.TA(1) String @pkg.TA(4) [] @pkg.TA(5) [] @pkg.TA(2) [] @pkg.TA(3) []", "String[][][][]",
"@TA String @TA [] @TA [] @TA [] @TA []");
}
void testWildcardType() {
doTest("Class<@TA(1) ?> c", "java.lang.Class<?>", "java.lang.Class<@pkg.TA(1) ?>", "Class<?>", "Class<@TA ?>")
public void testWildcardType() {
doTest("Class<@TA(1) ?> c", "java.lang.Class<?>", "java.lang.Class<@pkg.TA(1) ?>", "Class<?>", "Class<@TA ?>");
}
void testWildcardBoundType() {
doTest("Class<@TA(1) ? extends @TA(2) Object> c",
"java.lang.Class<? extends java.lang.Object>", "java.lang.Class<@pkg.TA(1) ? extends java.lang.@pkg.TA(2) Object>",
"Class<? extends Object>", "Class<@TA ? extends @TA Object>")
public void testWildcardBoundType() {
doTest("Class<@TA(1) ? extends @TA(2) Object> c", "java.lang.Class<? extends java.lang.Object>",
"java.lang.Class<@pkg.TA(1) ? extends java.lang.@pkg.TA(2) Object>", "Class<? extends Object>",
"Class<@TA ? extends @TA Object>");
}
void testDisjunctionType() {
def psi = factory.createStatementFromText("try { } catch (@A @TA(1) E1 | @TA(2) E2 e) { }", context) as PsiTryStatement
assertTypeText psi.catchBlockParameters[0].type, "pkg.E1 | pkg.E2", "pkg.@pkg.TA(1) E1 | pkg.@pkg.TA(2) E2", "E1 | E2", "@TA E1 | @TA E2"
public void testDisjunctionType() {
PsiTryStatement psi =
(PsiTryStatement)factory.createStatementFromText("try { } catch (@A @TA(1) E1 | @TA(2) E2 e) { }", context);
assertTypeText(psi.getCatchBlockParameters()[0].getType(), "pkg.E1 | pkg.E2", "pkg.@pkg.TA(1) E1 | pkg.@pkg.TA(2) E2", "E1 | E2",
"@TA E1 | @TA E2");
}
void testDiamondType() {
def psi = factory.createStatementFromText("Class<@TA String> cs = new Class<>()", context) as PsiDeclarationStatement
def var = psi.declaredElements[0] as PsiVariable
assertTypeText var.initializer.type,
"java.lang.Class<java.lang.String>", "java.lang.Class<java.lang.@pkg.TA String>",
"Class<String>", "Class<@TA String>"
public void testDiamondType() {
PsiDeclarationStatement psi =
(PsiDeclarationStatement)factory.createStatementFromText("Class<@TA String> cs = new Class<>()", context);
PsiVariable var = (PsiVariable)psi.getDeclaredElements()[0];
assertTypeText(var.getInitializer().getType(), "java.lang.Class<java.lang.String>", "java.lang.Class<java.lang.@pkg.TA String>",
"Class<String>", "Class<@TA String>");
}
void testImmediateClassType() {
def aClass = myFixture.javaFacade.findClass(CommonClassNames.JAVA_LANG_OBJECT)
def annotations = factory.createParameterFromText("@TA int x", context).modifierList.annotations
def type = new PsiImmediateClassType(aClass, PsiSubstitutor.EMPTY, LanguageLevel.JDK_1_8, annotations)
assertTypeText type, CommonClassNames.JAVA_LANG_OBJECT, "java.lang.@pkg.TA Object", "Object", "@TA Object"
public void testImmediateClassType() {
PsiClass aClass = myFixture.getJavaFacade().findClass(CommonClassNames.JAVA_LANG_OBJECT);
PsiAnnotation[] annotations = factory.createParameterFromText("@TA int x", context).getModifierList().getAnnotations();
PsiImmediateClassType type = new PsiImmediateClassType(aClass, PsiSubstitutor.EMPTY, LanguageLevel.JDK_1_8, annotations);
assertTypeText(type, CommonClassNames.JAVA_LANG_OBJECT, "java.lang.@pkg.TA Object", "Object", "@TA Object");
}
void testFieldType() {
def psi = factory.createFieldFromText("@A @TA(1) String f;", context)
assertTypeText psi.type, "java.lang.String", "java.lang.@pkg.TA(1) String", "String", "@TA String"
assertAnnotations psi.type, "@TA(1)"
public void testFieldType() {
PsiField psi = factory.createFieldFromText("@A @TA(1) String f;", context);
assertTypeText(psi.getType(), "java.lang.String", "java.lang.@pkg.TA(1) String", "String", "@TA String");
assertAnnotations(psi.getType(), "@TA(1)");
}
void testMethodReturnType() {
def psi = factory.createMethodFromText("@A @TA(1) <T> @TA(2) String m() { return null; }", context)
assertTypeText psi.returnType, "java.lang.String", "java.lang.@pkg.TA(1) @pkg.TA(2) String", "String", "@TA @TA String"
assertAnnotations psi.returnType, "@TA(1)", "@TA(2)"
public void testMethodReturnType() {
PsiMethod psi = factory.createMethodFromText("@A @TA(1) <T> @TA(2) String m() { return null; }", context);
assertTypeText(psi.getReturnType(), "java.lang.String", "java.lang.@pkg.TA(1) @pkg.TA(2) String", "String", "@TA @TA String");
assertAnnotations(psi.getReturnType(), "@TA(1)", "@TA(2)");
}
void testIsAnnotated() {
def unqualified = factory.createParameterFromText("@A @TA(1) String p", context)
assert AnnotationUtil.isAnnotated(unqualified, "pkg.A", CHECK_TYPE)
assert AnnotationUtil.isAnnotated(unqualified, "pkg.TA", CHECK_TYPE)
public void testIsAnnotated() {
PsiParameter unqualified = factory.createParameterFromText("@A @TA(1) String p", context);
assertTrue(AnnotationUtil.isAnnotated(unqualified, "pkg.A", CHECK_TYPE));
assertTrue(AnnotationUtil.isAnnotated(unqualified, "pkg.TA", CHECK_TYPE));
def qualified = factory.createParameterFromText("@A java.lang.@TA(1) String p", context)
assert AnnotationUtil.isAnnotated(qualified, "pkg.A", CHECK_TYPE)
assert AnnotationUtil.isAnnotated(qualified, "pkg.TA", CHECK_TYPE)
PsiParameter qualified = factory.createParameterFromText("@A java.lang.@TA(1) String p", context);
assertTrue(AnnotationUtil.isAnnotated(qualified, "pkg.A", CHECK_TYPE));
assertTrue(AnnotationUtil.isAnnotated(qualified, "pkg.TA", CHECK_TYPE));
}
private void doTest(String text, String canonical, String canonicalAnnotated, String presentable, String presentableAnnotated) {
assertTypeText factory.createParameterFromText(text, context).type, canonical, canonicalAnnotated, presentable, presentableAnnotated
assertTypeText(factory.createParameterFromText(text, context).getType(), canonical, canonicalAnnotated, presentable,
presentableAnnotated);
}
private static void assertTypeText(PsiType type, String canonical, String canonicalAnnotated, String presentable, String presentableAnnotated) {
assert type.getCanonicalText(false) == canonical
assert type.getCanonicalText(true) == canonicalAnnotated
assert type.getPresentableText(false) == presentable
assert type.getPresentableText(true) == presentableAnnotated
private static void assertTypeText(PsiType type,
String canonical,
String canonicalAnnotated,
String presentable,
String presentableAnnotated) {
assertEquals(canonical, type.getCanonicalText(false));
assertEquals(canonicalAnnotated, type.getCanonicalText(true));
assertEquals(presentable, type.getPresentableText(false));
assertEquals(presentableAnnotated, type.getPresentableText(true));
}
private static void assertAnnotations(PsiType type, String... annotations) {
assert type.annotations.collect { it.text } == annotations.toList()
assertEquals(Arrays.asList(annotations), ContainerUtil.map(type.getAnnotations(), PsiAnnotation::getText));
}
}
}

View File

@@ -1,180 +1,171 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.refactoring
package com.intellij.java.refactoring;
import com.intellij.codeInsight.TargetElementUtil
import com.intellij.codeInsight.lookup.LookupEx
import com.intellij.codeInsight.lookup.LookupManager
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
import com.intellij.codeInsight.template.impl.TemplateState
import com.intellij.psi.PsiElement
import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler
import com.intellij.testFramework.LightJavaCodeInsightTestCase
import groovy.transform.CompileStatic
import com.intellij.codeInsight.TargetElementUtil;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupEx;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateState;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler;
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
import com.intellij.util.containers.ContainerUtil;
import junit.framework.TestCase;
@CompileStatic
class RenameSuggestionsTest extends LightJavaCodeInsightTestCase {
void "test by parameter name"() {
def text = """\
class Test {
void foo(int foo) {}
{
int bar = 0;
foo(b<caret>ar);
import java.util.Arrays;
import java.util.List;
public class RenameSuggestionsTest extends LightJavaCodeInsightTestCase {
public void test_by_parameter_name() {
String text = """
class Test {
void foo(int foo) {}
{
int bar = 0;
foo(b<caret>ar);
}
}""";
doTestSuggestionAvailable(text, "foo");
}
public void test_lambda_parameter_name() {
String text = """
import java.util.Map;
class LambdaRename {
void q(Map<String, LambdaRename> map) {
map.forEach((k, <caret>v) -> {
System.out.println(k + v);
});
}
}""";
doTestSuggestionAvailable(text, "lambdaRename", "rename", "v");
}
public void test_foreach_scope() {
String text = """
class Foo {
{
for (Foo <caret>f : new Foo[] {});
for (Foo foo : new Foo[] {});
}
}""";
doTestSuggestionAvailable(text, "foo");
}
public void test_by_super_parameter_name() {
String text = """
class Test {
void foo(int foo) {}
}
}
}
"""
doTestSuggestionAvailable(text, "foo")
}
void "test lambda parameter name"() {
def text = """\
import java.util.Map;
class TestImpl extends Test {
void foo(int foo<caret>1) {}
}""";
class LambdaRename {
void q(Map<String, LambdaRename> map) {
map.forEach((k, <caret>v) -> {
System.out.println(k + v);
});
}
}
}
"""
doTestSuggestionAvailable(text, "lambdaRename", "rename", "v")
doTestSuggestionAvailable(text, "foo");
}
void "test foreach scope"() {
def text = """\
class Foo {
{
for (Foo <caret>f : new Foo[] {});
for (Foo foo : new Foo[] {});
public void test_by_Optional_of_initializer() {
List<String> suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Foo typeValue = null;
Optional<Foo> <caret>o = Optional.of(typeValue);
}}
""");
assertEquals(Arrays.asList("typeValue1", "value", "foo", "optionalFoo", "fooOptional", "optional", "o"), suggestions);
}
public void test_by_Optional_ofNullable_initializer() {
List<String> suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Foo typeValue = this;
Optional<Foo> <caret>o = Optional.ofNullable(typeValue);
}}""");
assertEquals(Arrays.asList("typeValue1", "value", "foo", "optionalFoo", "fooOptional", "optional", "o"), suggestions);
}
public void test_by_Optional_of_initializer_with_constructor() {
List<String> suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Optional<Foo> <caret>o = Optional.ofNullable(new Foo());
}}""");
assertEquals(Arrays.asList("foo", "optionalFoo", "fooOptional", "optional", "o"), suggestions);
}
public void test_by_Optional_flatMap() {
List<String> suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Optional<Car> <caret>o = Optional.of(new Person()).flatMap(Person::getCar);
}}
class Person {
Optional<Car> getCar() {}
}
}
"""
doTestSuggestionAvailable(text, "foo")
class Car {}
""");
assertEquals(Arrays.asList("car", "optionalCar", "carOptional", "optional", "o"), suggestions);
}
void "test by super parameter name"() {
def text = """\
class Test {
void foo(int foo) {}
}
class TestImpl extends Test {
void foo(int foo<caret>1) {}
}
}
"""
public void test_long_qualified_name() {
List<String> suggestions = getNameSuggestions("""
class Foo {
Inner inner;
class Inner {
String getCat() {}
}
doTestSuggestionAvailable(text, "foo")
void m(Foo f){
String <caret>s = f.inner.getCat();\s
}
}
""");
assertEquals(Arrays.asList("cat", "innerCat", "string", "s"), suggestions);
}
void "test by Optional_of initializer"() {
def suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Foo typeValue = null;
Optional<Foo> <caret>o = Optional.of(typeValue);
}}
""")
assert suggestions == ["typeValue1", "value", "foo", "optionalFoo", "fooOptional", "optional", "o"]
}
void "test by Optional_ofNullable initializer"() {
def suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Foo typeValue = this;
Optional<Foo> <caret>o = Optional.ofNullable(typeValue);
}}
""")
assert suggestions == ["typeValue1", "value", "foo", "optionalFoo", "fooOptional", "optional", "o"]
}
void "test by Optional_of initializer with constructor"() {
def suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Optional<Foo> <caret>o = Optional.ofNullable(new Foo());
}}
""")
assert suggestions == ["foo", "optionalFoo", "fooOptional", "optional", "o"]
}
void "test by Optional_flatMap"() {
def suggestions = getNameSuggestions("""
import java.util.*;
class Foo {{
Optional<Car> <caret>o = Optional.of(new Person()).flatMap(Person::getCar);
}}
class Person {
Optional<Car> getCar() {}
}
class Car {}
""")
assert suggestions == ["car", "optionalCar", "carOptional", "optional", "o"]
}
void "test long qualified name"() {
def suggestions = getNameSuggestions("""
class Foo {
Inner inner;
class Inner {
String getCat() {}
}
void m(Foo f){
String <caret>s = f.inner.getCat();
}
}
""")
assert suggestions == ["cat", "innerCat", 'string', "s"]
}
private doTestSuggestionAvailable(String text, String... expectedSuggestions) {
def suggestions = getNameSuggestions(text)
print(suggestions)
private void doTestSuggestionAvailable(String text, String... expectedSuggestions) {
List<String> suggestions = getNameSuggestions(text);
for (String suggestion : expectedSuggestions) {
assert suggestion in suggestions
assertTrue(suggestions.contains(suggestion));
}
}
private List<String> getNameSuggestions(String text) {
configure text
def oldPreselectSetting = editor.settings.preselectRename
configure(text);
boolean oldPreselectSetting = getEditor().getSettings().isPreselectRename();
try {
TemplateManagerImpl.setTemplateTesting(getTestRootDisposable())
final PsiElement element = TargetElementUtil.findTargetElement(editor, TargetElementUtil.getInstance().getAllAccepted())
TemplateManagerImpl.setTemplateTesting(getTestRootDisposable());
final PsiElement element = TargetElementUtil.findTargetElement(getEditor(), TargetElementUtil.getInstance().getAllAccepted());
assertNotNull(element)
TestCase.assertNotNull(element);
VariableInplaceRenameHandler handler = new VariableInplaceRenameHandler()
VariableInplaceRenameHandler handler = new VariableInplaceRenameHandler();
handler.doRename(element, editor, null)
LookupEx lookup = LookupManager.getActiveLookup(editor)
assertNotNull(lookup)
return lookup.items.collect { it.lookupString }
handler.doRename(element, getEditor(), null);
LookupEx lookup = LookupManager.getActiveLookup(getEditor());
TestCase.assertNotNull(lookup);
return ContainerUtil.map(lookup.getItems(), LookupElement::getLookupString);
}
finally {
editor.settings.preselectRename = oldPreselectSetting
TemplateState state = TemplateManagerImpl.getTemplateState(editor)
assertNotNull(state)
state.gotoEnd(false)
getEditor().getSettings().setPreselectRename(oldPreselectSetting);
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
TestCase.assertNotNull(state);
state.gotoEnd(false);
}
}
private def configure(String text) {
configureFromFileText("a.java", text)
private void configure(String text) {
configureFromFileText("a.java", text);
}
}
}