[jvm-lang] update Java-to-Java Create Method from usage tests

This commit is contained in:
Daniil Ovchinnikov
2017-09-06 21:11:36 +03:00
parent 6d4b68c6df
commit e08521fb91
6 changed files with 26 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
// "Create method 'f'" "true"
// "Create method 'f' in 'Nested in aMethod() in CreateMethodTest'" "true"
public class CreateMethodTest {
public <T> void aMethod(final T t) {
class Nested {

View File

@@ -1,4 +1,4 @@
// "Create method 'f'" "true"
// "Create method 'f' in 'Nested in aMethod() in CreateMethodTest'" "true"
public class CreateMethodTest {
public <T> void aMethod(final T t) {
class Nested {

View File

@@ -27,7 +27,7 @@ public class CreateMethodFromUsagePerformanceTest extends LightQuickFixTestCase
PlatformTestUtil.startPerformanceTest("5000 args for a new method", 400_000, () -> {
String text = "class Foo {{ f<caret>oo(" + StringUtil.repeat("\"a\", ", 5000) + " \"a\");}}";
configureFromFileText("Foo.java", text);
doAction("Create method 'foo'");
doAction("Create method 'foo' in 'Foo'");
})
.assertTiming();
}

View File

@@ -48,7 +48,7 @@ class SomeOuterClassWithLongName {
}
"""
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
doAction("Create method 'addSubGroup'")
doAction("Create method 'addSubGroup' in 'Group in PropertyDescriptorWithVeryLongName in SomeOuterClassWithLongName'")
def state = TemplateManagerImpl.getTemplateState(getEditor())
//skip void return type
state.nextTab()
@@ -98,7 +98,7 @@ class Usage {
}
"""
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
doAction("Create method 'getInstance'")
doAction("Create method 'getInstance' in 'Singleton'")
def state = TemplateManagerImpl.getTemplateState(getEditor())
// parameter type
assert LookupManager.getActiveLookup(editor)?.currentItem?.lookupString == 'Singleton'
@@ -118,7 +118,7 @@ class Usage {
}
"""
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
doAction("Create method 'getInstance'")
doAction("Create method 'getInstance' in 'Singleton'")
def state = TemplateManagerImpl.getTemplateState(getEditor())
def document = getEditor().getDocument()
@@ -144,19 +144,8 @@ class A {
}
"""
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
doAction("Create method 'foo'")
def state = TemplateManagerImpl.getTemplateState(getEditor())
def document = getEditor().getDocument()
def offset = getEditor().getCaretModel().getOffset()
ApplicationManager.application.runWriteAction {
def method = PsiTreeUtil.getParentOfType(getFile().findElementAt(offset), PsiMethod.class)
method.getModifierList().setModifierProperty(PsiModifier.STATIC, false)
PsiDocumentManager.getInstance(getFile().project).commitDocument(document)
}
state.gotoEnd(false)
doAction("Create method 'foo' in 'A'")
TemplateManagerImpl.getTemplateState(getEditor()).gotoEnd(false)
checkResultByText """
class A {
@@ -166,7 +155,7 @@ class A {
B(int x) { super(foo(x)); }
}
private int foo(int x) {
private static int foo(int x) {
return 0;
}
}
@@ -188,7 +177,7 @@ class A {
}
"""
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
doAction("Create method 'foo'")
doAction("Create method 'foo' in 'A'")
def state = TemplateManagerImpl.getTemplateState(getEditor())
def document = getEditor().getDocument()

View File

@@ -15,7 +15,10 @@
*/
package com.intellij.java.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.daemon.quickFix.ActionHint;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class CreateMethodFromUsageTest extends LightQuickFixParameterizedTestCase {
@@ -25,4 +28,9 @@ public class CreateMethodFromUsageTest extends LightQuickFixParameterizedTestCas
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromUsage";
}
@Override
protected ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
return ActionHint.parse(file, contents, false);
}
}

View File

@@ -15,8 +15,11 @@
*/
package com.intellij.java.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.daemon.quickFix.ActionHint;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -34,4 +37,9 @@ public class GenericCreateFromUsageTest extends LightQuickFixParameterizedTestCa
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.JDK_1_5;
}
@Override
protected ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
return ActionHint.parse(file, contents, false);
}
}