mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
code processor: added tests on single file reformat and import optimization
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
int a = 3;
|
||||
|
||||
int b = 3;
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import java.lang.String;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
<selection>List<String> list = new ArrayList<String>();
|
||||
int a = 3;</selection>
|
||||
|
||||
int b = 3;
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
int a = 3;
|
||||
|
||||
int b = 3;
|
||||
}
|
||||
|
||||
|
||||
public void test() {
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
<selection> List<String> list = new ArrayList<String>();
|
||||
int a = 3;<caret></selection>
|
||||
|
||||
int b = 3;
|
||||
}
|
||||
|
||||
|
||||
<selection><caret>
|
||||
public void test() {
|
||||
}</selection>
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.String;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
}
|
||||
|
||||
}
|
||||
+16
-4
@@ -25,6 +25,8 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.codeInsight.actions.TextRangeType.*;
|
||||
|
||||
public class MultiActionCodeProcessorTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
|
||||
@Override
|
||||
@@ -47,7 +49,7 @@ public class MultiActionCodeProcessorTest extends LightPlatformCodeInsightFixtur
|
||||
myFixture.configureByFile(getTestDataPath() + getTestName(true) + "_before.java");
|
||||
CodeProcessor processor = new CodeProcessor(myFixture.getFile(), myFixture.getEditor(), options);
|
||||
|
||||
if (options.getTextRangeType() == TextRangeType.VCS_CHANGED_TEXT) {
|
||||
if (options.getTextRangeType() == VCS_CHANGED_TEXT) {
|
||||
CaretModel model = myFixture.getEditor().getCaretModel();
|
||||
List<TextRange> ranges = ContainerUtil.mapNotNull(model.getAllCarets(), new Function<Caret, TextRange>() {
|
||||
@Override
|
||||
@@ -66,16 +68,26 @@ public class MultiActionCodeProcessorTest extends LightPlatformCodeInsightFixtur
|
||||
}
|
||||
|
||||
public void testSelectionReformat() {
|
||||
doTest(new ReformatCodeRunOptions(TextRangeType.SELECTED_TEXT));
|
||||
doTest(new ReformatCodeRunOptions(SELECTED_TEXT));
|
||||
}
|
||||
|
||||
public void testWholeFileReformat() {
|
||||
doTest(new ReformatCodeRunOptions(TextRangeType.WHOLE_FILE));
|
||||
doTest(new ReformatCodeRunOptions(WHOLE_FILE));
|
||||
}
|
||||
|
||||
public void testVcsChangedTextReformat() {
|
||||
doTest(new ReformatCodeRunOptions(TextRangeType.VCS_CHANGED_TEXT));
|
||||
doTest(new ReformatCodeRunOptions(VCS_CHANGED_TEXT));
|
||||
}
|
||||
|
||||
public void testWholeFileReformatAndOptimize() {
|
||||
doTest(new ReformatCodeRunOptions(WHOLE_FILE).setOptimizeImports(true));
|
||||
}
|
||||
|
||||
public void testSelectedTextAndOptimizeImports() {
|
||||
doTest(new ReformatCodeRunOptions(SELECTED_TEXT).setOptimizeImports(true));
|
||||
}
|
||||
|
||||
//public void testVcsChangedTextReformatAndOptimize() {
|
||||
// doTest(new ReformatCodeRunOptions(VCS_CHANGED_TEXT).setOptimizeImports(true));
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -39,12 +39,14 @@ public class ReformatCodeRunOptions implements LayoutCodeOptions {
|
||||
return myRearrangeCode;
|
||||
}
|
||||
|
||||
public void setRearrangeCode(boolean rearrangeCode) {
|
||||
public ReformatCodeRunOptions setRearrangeCode(boolean rearrangeCode) {
|
||||
myRearrangeCode = rearrangeCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setOptimizeImports(boolean optimizeImports) {
|
||||
public ReformatCodeRunOptions setOptimizeImports(boolean optimizeImports) {
|
||||
myOptimizeImports = optimizeImports;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user