mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
// "Add constructor parameter" "true"
|
||||
class A {
|
||||
private final int field;
|
||||
private int j;
|
||||
|
||||
A(int field) {
|
||||
this(0, field);
|
||||
}
|
||||
|
||||
A(int j, int field) {
|
||||
this.j = j;
|
||||
this.field = field;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Add constructor parameter" "true"
|
||||
class A {
|
||||
private final int <caret>field;
|
||||
private int j;
|
||||
|
||||
A() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
A(int j) {
|
||||
this.j = j;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Suppress for class" "false"
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
class Test {
|
||||
@javax.annotation.Generated(value = "unknown")
|
||||
public static void main(String[] args) {
|
||||
ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int <caret>i = 0;
|
||||
System.out.println(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if (a) {
|
||||
call();
|
||||
} else if (b) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if (a) {
|
||||
if (b) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if ((a) |<caret>| (b)) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if ((a) &<caret>& (b)) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
void f() {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
int j = 0;
|
||||
if (j == 0 && <selection>j < 0 && j > 0</selection>) {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class Test {
|
||||
void f() {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
int j = 0;
|
||||
if (j == 0 && newMethod(j)) {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private boolean newMethod(int j) {
|
||||
return j < 0 && j > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
public class ExpData {
|
||||
void foo(String s) {
|
||||
s = "";
|
||||
System.out.println(<caret>s.substring(2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class ExpData {
|
||||
void foo(String s) {
|
||||
System.out.println("".substring(2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
public class ExpData {
|
||||
void foo(int i) {
|
||||
i = 0;
|
||||
System.out.println(<caret>i++);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
void bar(int i){
|
||||
method(1);
|
||||
method(i, "a");
|
||||
method(1, "a", "b");
|
||||
}
|
||||
|
||||
void m<caret>(String... args) {
|
||||
method(1, args);
|
||||
}
|
||||
|
||||
void method(int i, String... args) {
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
void bar(int i){
|
||||
m(new String[0]);
|
||||
method(i, "a");
|
||||
m("a", "b");
|
||||
}
|
||||
|
||||
void m(String... args) {
|
||||
method(1, args);
|
||||
}
|
||||
|
||||
void method(int i, String... args) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
void bar(int i){
|
||||
method(i);
|
||||
method(i, "a");
|
||||
method(i, "a", "b");
|
||||
}
|
||||
|
||||
void m<caret>(int i, String... args) {
|
||||
method(i, args);
|
||||
}
|
||||
|
||||
void method(int i, String... args) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
void bar(int i){
|
||||
m(i, new String[0]);
|
||||
m(i, "a");
|
||||
m(i, "a", "b");
|
||||
}
|
||||
|
||||
void m(int i, String... args) {
|
||||
method(i, args);
|
||||
}
|
||||
|
||||
void method(int i, String... args) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
{
|
||||
method(1);
|
||||
method(1, "a");
|
||||
method(1, "a", "b");
|
||||
}
|
||||
|
||||
void m<caret>(String... args) {
|
||||
method(1, args);
|
||||
}
|
||||
|
||||
void method(int i, String... args) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
{
|
||||
m(new String[0]);
|
||||
m("a");
|
||||
m("a", "b");
|
||||
}
|
||||
|
||||
void m(String... args) {
|
||||
method(1, args);
|
||||
}
|
||||
|
||||
void method(int i, String... args) {
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class X {
|
||||
}
|
||||
|
||||
class MyClass1 {}
|
||||
|
||||
/**
|
||||
* {@link #MyClass1Impl()}
|
||||
*/
|
||||
class MyClass1Impl extends MyClass1 {
|
||||
MyClass1Impl() {
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class X {
|
||||
}
|
||||
|
||||
class MyClass {}
|
||||
|
||||
/**
|
||||
* {@link #MyClassImpl()}
|
||||
*/
|
||||
class MyClassImpl extends MyClass {
|
||||
MyClassImpl() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo(Object o) {
|
||||
<selection>((A)o).doSmth();</selection>
|
||||
}
|
||||
}
|
||||
|
||||
class A {void doSmth(){}}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
void foo(Object o) {
|
||||
<selection>
|
||||
if (true) {
|
||||
((A1)o).doSmth();
|
||||
} else {
|
||||
o.toString();
|
||||
}
|
||||
</selection>
|
||||
}
|
||||
}
|
||||
|
||||
class A {void doSmth(){}}
|
||||
class A1 extends A {}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test {
|
||||
void foo(Object o) {
|
||||
<selection>
|
||||
if (true) {
|
||||
((A1)o).doSmth();
|
||||
} else {
|
||||
((A2)o).doSmth();
|
||||
}
|
||||
</selection>
|
||||
}
|
||||
}
|
||||
|
||||
class A {void doSmth(){}}
|
||||
class A1 extends A {}
|
||||
class A2 extends A {}
|
||||
@@ -145,9 +145,7 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testSCR36110() throws Exception {
|
||||
JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
||||
LanguageLevel old = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(old);
|
||||
}
|
||||
|
||||
public void testSCR37331() throws Exception { doTest(); }
|
||||
|
||||
-7
@@ -4,8 +4,6 @@ import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
@SuppressWarnings({"ALL"})
|
||||
public class HeavySmartTypeCompletion15Test extends CompletionTestCase {
|
||||
@@ -79,11 +77,6 @@ public class HeavySmartTypeCompletion15Test extends CompletionTestCase {
|
||||
complete();
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(myProject).hideActiveLookup();
|
||||
super.tearDown();
|
||||
|
||||
+2
-11
@@ -1,8 +1,6 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
|
||||
/**
|
||||
@@ -109,15 +107,8 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testExtends_12() throws Exception {
|
||||
final LanguageLevel level = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
try {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile(BASE_PATH + "/extends-12.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-12-result.java");
|
||||
}
|
||||
finally {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(level);
|
||||
}
|
||||
configureByFile(BASE_PATH + "/extends-12.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-12-result.java");
|
||||
}
|
||||
|
||||
public void testSynchronized_1() throws Exception {
|
||||
|
||||
@@ -6,10 +6,8 @@ import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
@@ -241,39 +239,33 @@ public class NormalCompletionTest extends LightCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testSwitchEnumLabel() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile("/codeInsight/completion/normal/SwitchEnumLabel.java");
|
||||
assertEquals(3, myItems.length);
|
||||
}
|
||||
|
||||
public void testMethodInAnnotation() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile("/codeInsight/completion/normal/Annotation.java");
|
||||
checkResultByFile("/codeInsight/completion/normal/Annotation_after.java");
|
||||
}
|
||||
|
||||
public void testMethodInAnnotation2() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile("/codeInsight/completion/normal/Annotation2.java");
|
||||
checkResultByFile("/codeInsight/completion/normal/Annotation2_after.java");
|
||||
}
|
||||
|
||||
public void testMethodInAnnotation3() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
|
||||
configureByFile("/codeInsight/completion/normal/Annotation3.java");
|
||||
checkResultByFile("/codeInsight/completion/normal/Annotation3_after.java");
|
||||
}
|
||||
|
||||
public void testMethodInAnnotation5() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
|
||||
configureByFile("/codeInsight/completion/normal/Annotation5.java");
|
||||
checkResultByFile("/codeInsight/completion/normal/Annotation5_after.java");
|
||||
}
|
||||
|
||||
public void testMethodInAnnotation7() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
|
||||
configureByFile("/codeInsight/completion/normal/Annotation7.java");
|
||||
selectItem(myItems[0]);
|
||||
@@ -281,19 +273,16 @@ public class NormalCompletionTest extends LightCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testEnumInAnnotation() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile("/codeInsight/completion/normal/Annotation4.java");
|
||||
checkResultByFile("/codeInsight/completion/normal/Annotation4_after.java");
|
||||
}
|
||||
|
||||
public void testSecondAttribute() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile("/codeInsight/completion/normal/Annotation6.java");
|
||||
checkResultByFile("/codeInsight/completion/normal/Annotation6_after.java");
|
||||
}
|
||||
|
||||
public void testIDEADEV6408() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile("/codeInsight/completion/normal/IDEADEV6408.java");
|
||||
assertEquals(2, myItems.length);
|
||||
}
|
||||
@@ -334,22 +323,18 @@ public class NormalCompletionTest extends LightCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testPackageInAnnoParam() throws Throwable {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testClassLiteralInAnnoParam() throws Throwable {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAtUnderClass() throws Throwable {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAtUnderClassNoModifiers() throws Throwable {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
+1
-10
@@ -9,13 +9,9 @@ import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@SuppressWarnings({"ALL"})
|
||||
public class SecondSmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/smartType/second";
|
||||
@@ -160,7 +156,7 @@ public class SecondSmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
|
||||
protected void checkResultByFile(@NonNls final String filePath) throws Exception {
|
||||
if (myItems != null) {
|
||||
System.out.println("items = " + Arrays.asList(myItems));
|
||||
//System.out.println("items = " + Arrays.asList(myItems));
|
||||
}
|
||||
super.checkResultByFile(filePath);
|
||||
}
|
||||
@@ -178,11 +174,6 @@ public class SecondSmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
myItems = lookup == null ? null : lookup.getItems().toArray(LookupElement.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
super.tearDown();
|
||||
|
||||
+1
-11
@@ -15,7 +15,6 @@ import com.intellij.codeInsight.template.impl.TemplateImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateSettings;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -25,7 +24,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class SmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/smartType";
|
||||
private LanguageLevel myPrevLanguageLevel;
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
@@ -764,13 +762,13 @@ public class SmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testAfterNew15() throws Exception {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doActionItemTest();
|
||||
}
|
||||
|
||||
public void testInsertOverride() throws Exception {
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
styleSettings.INSERT_OVERRIDE_ANNOTATION = true;
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_6);
|
||||
doActionItemTest();
|
||||
}
|
||||
|
||||
@@ -1064,17 +1062,9 @@ public class SmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myPrevLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
setType(CompletionType.SMART);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPrevLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk17("java 1.5");
|
||||
|
||||
-14
@@ -2,26 +2,12 @@ package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class AnnotationsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
private LanguageLevel myPrevLanguageLevel;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myPrevLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPrevLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/annotations";
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/genericsHighlighting";
|
||||
private LanguageLevel myOldLanguageLevel;
|
||||
|
||||
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new UncheckedWarningLocalInspection(), new UnusedSymbolLocalInspection(), new UnusedImportLocalInspection()};
|
||||
@@ -32,7 +30,6 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevel level = getTestName(false).contains("Level6") ? LanguageLevel.JDK_1_6 : LanguageLevel.JDK_1_5;
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(level);
|
||||
}
|
||||
@@ -41,10 +38,6 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
return JavaSdkImpl.getMockJdk17("java 1.5");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myOldLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testReferenceTypeParams() throws Exception { doTest(false); }
|
||||
public void testOverridingMethods() throws Exception { doTest(false); }
|
||||
|
||||
+2
-10
@@ -8,7 +8,6 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
|
||||
|
||||
public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@@ -99,15 +98,8 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testMissingReturnDescription() throws Exception {doTest();}
|
||||
|
||||
private void doTestWithLangLevel(final LanguageLevel langLevel) throws Exception {
|
||||
JavaPsiFacade manager = getJavaFacade();
|
||||
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(manager.getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(manager.getProject()).setLanguageLevel(langLevel);
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
LanguageLevelProjectExtension.getInstance(manager.getProject()).setLanguageLevel(effectiveLanguageLevel);
|
||||
}
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(langLevel);
|
||||
doTest();
|
||||
}
|
||||
|
||||
protected void doTest() throws Exception {
|
||||
|
||||
-14
@@ -1,7 +1,5 @@
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
@@ -10,23 +8,11 @@ import org.jetbrains.annotations.NonNls;
|
||||
*/
|
||||
public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting7";
|
||||
private LanguageLevel myOldLanguageLevel;
|
||||
|
||||
private void doTest(boolean checkWarnings, boolean checkInfos) throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myOldLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testSwitchByString() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
+3
-10
@@ -13,7 +13,6 @@ import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspec
|
||||
import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration;
|
||||
import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageAnnotators;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
@@ -35,7 +34,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase.filter;
|
||||
@@ -46,7 +44,6 @@ import static com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase.filter;
|
||||
*/
|
||||
public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting";
|
||||
private LanguageLevel myOldLanguageLevel;
|
||||
private UnusedSymbolLocalInspection myUnusedSymbolLocalInspection;
|
||||
|
||||
private void doTest(boolean checkWarnings, boolean checkInfos) throws Exception {
|
||||
@@ -55,14 +52,9 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_4);
|
||||
setLanguageLevel(LanguageLevel.JDK_1_4);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myOldLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
myUnusedSymbolLocalInspection = new UnusedSymbolLocalInspection();
|
||||
@@ -283,7 +275,6 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
assertFalse(list.toString(), list.contains(annotator));
|
||||
}
|
||||
|
||||
@Bombed(month = Calendar.DECEMBER, day=31, user="cdr")
|
||||
public void testSOEForTypeOfHugeBinaryExpression() throws IOException {
|
||||
configureFromFileText("a.java", "class A { String s = \"\"; }");
|
||||
assertEmpty(filter(doHighlighting(), HighlightSeverity.ERROR));
|
||||
@@ -299,6 +290,8 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
binary.getLOperand().replace(expression);
|
||||
binary.getROperand().replace(literal);
|
||||
|
||||
//UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
expression.replace(binary);
|
||||
PostprocessReformattingAspect.getInstance(getProject()).clear(); // OOM otherwise
|
||||
}
|
||||
|
||||
@@ -8,25 +8,11 @@ import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class SuppressWarningsTest extends LightDaemonAnalyzerTestCase {
|
||||
private LanguageLevel myPrevLanguageLevel;
|
||||
@NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myPrevLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPrevLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private void doTest(boolean checkWarnings) throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
public class UnusedImportsTest extends DaemonAnalyzerTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/unusedImports";
|
||||
@@ -12,11 +10,6 @@ public class UnusedImportsTest extends DaemonAnalyzerTestCase {
|
||||
return new LocalInspectionTool[]{new UnusedImportLocalInspection()};
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
public void test1() throws Exception { doTest(); }
|
||||
public void test2() throws Exception { doTest(); }
|
||||
|
||||
|
||||
+6
-1
@@ -1,11 +1,16 @@
|
||||
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
|
||||
|
||||
public class ChangeParameterClassTest extends LightQuickFix15TestCase {
|
||||
|
||||
public void test() throws Exception {doAllTests();}
|
||||
public void test() throws Exception {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass";
|
||||
|
||||
-15
@@ -2,13 +2,9 @@ package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
|
||||
public class GenerifyFileTest extends LightQuickFixAvailabilityTestCase {
|
||||
private LanguageLevel oldLanguageLevel;
|
||||
|
||||
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[] {new UncheckedWarningLocalInspection()};
|
||||
@@ -16,17 +12,6 @@ public class GenerifyFileTest extends LightQuickFixAvailabilityTestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
oldLanguageLevel = LanguageLevelProjectExtension.getInstance(getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(oldLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/generifyFile";
|
||||
}
|
||||
|
||||
-13
@@ -2,27 +2,14 @@ package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public abstract class LightQuickFix15TestCase extends LightQuickFixTestCase {
|
||||
private LanguageLevel myPrevLanguageLevel;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myPrevLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk17("java 1.5");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPrevLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
-7
@@ -11,17 +11,10 @@ import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
|
||||
public class Suppress15InspectionsTest extends LightQuickFixTestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk17();
|
||||
|
||||
-14
@@ -3,25 +3,11 @@ package com.intellij.codeInsight.intention;
|
||||
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
public class AddOnDemandStaticImportActionTest extends LightIntentionActionTestCase {
|
||||
private LanguageLevel myLanguageLevel;
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myLanguageLevel = LanguageLevelProjectExtension.getInstance(getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(myLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport";
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
|
||||
public class InvertIfConditionTest extends LightIntentionActionTestCase {
|
||||
private LanguageLevel myPrevLanguageLevel;
|
||||
|
||||
protected String getBasePath() {
|
||||
return BASE_PATH;
|
||||
@@ -24,18 +21,6 @@ public class InvertIfConditionTest extends LightIntentionActionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/invertIfCondition/";
|
||||
private boolean myElseOnNewLine;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
myPrevLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPrevLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected boolean shouldBeAvailableAfterExecution() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.codeInsight.intention.impl.SplitIfAction;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
@@ -39,6 +39,20 @@ public class SplitIfActionTest extends LightCodeInsightTestCase {
|
||||
checkResultByFile("/codeInsight/splitIfAction/after5.java");
|
||||
}
|
||||
|
||||
public void test6() throws Exception {
|
||||
configureByFile("/codeInsight/splitIfAction/beforeParenthesis.java");
|
||||
perform();
|
||||
checkResultByFile("/codeInsight/splitIfAction/afterParenthesis.java");
|
||||
}
|
||||
|
||||
public void test7() throws Exception {
|
||||
configureByFile("/codeInsight/splitIfAction/beforeOrParenthesis.java");
|
||||
perform();
|
||||
checkResultByFile("/codeInsight/splitIfAction/afterOrParenthesis.java");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void perform() throws Exception {
|
||||
SplitIfAction action = new SplitIfAction();
|
||||
assertTrue(action.isAvailable(getProject(), getEditor(), getFile()));
|
||||
|
||||
@@ -8,11 +8,9 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowHeadlessManagerImpl;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.slicer.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -26,23 +24,10 @@ import java.util.*;
|
||||
* @author cdr
|
||||
*/
|
||||
public class SliceTreeTest extends LightDaemonAnalyzerTestCase {
|
||||
private LanguageLevel myOldLanguageLevel;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
@Override protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk17("java 1.5");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myOldLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private SliceTreeStructure configureTree(@NonNls final String name) throws Exception {
|
||||
configureByFile("/codeInsight/slice/backward/"+ name +".java");
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
|
||||
+5
-3
@@ -1,8 +1,10 @@
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Pavel.Fatin, 18.02.2010
|
||||
@@ -123,7 +125,7 @@ public class ClassFileStubBuilderTest extends TestCase {
|
||||
|
||||
private static boolean isInner(String name, String... files) {
|
||||
Set<String> all = new HashSet<String>();
|
||||
all.addAll(Arrays.asList(files));
|
||||
ContainerUtil.addAll(all, files);
|
||||
all.add(name);
|
||||
return ClassFileStubBuilder.isInner(name, new DirectoryMock(all));
|
||||
}
|
||||
@@ -140,4 +142,4 @@ public class ClassFileStubBuilderTest extends TestCase {
|
||||
return myFiles.contains(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.refactoring.extractMethod.ExtractMethodProcessor;
|
||||
import com.intellij.refactoring.extractMethod.PrepareFailedException;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import com.intellij.refactoring.util.duplicates.Match;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -448,6 +449,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testParametersFromAnonymous() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doPrepareErrorTest(final String expectedMessage) throws Exception {
|
||||
String expectedError = null;
|
||||
try {
|
||||
@@ -503,6 +508,12 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
else {
|
||||
elements = CodeInsightUtil.findStatementsInRange(file, startOffset, endOffset);
|
||||
}
|
||||
if (elements.length == 0) {
|
||||
final PsiExpression expression = IntroduceVariableBase.getSelectedExpression(project, file, startOffset, endOffset);
|
||||
if (expression != null) {
|
||||
elements = new PsiElement[]{expression};
|
||||
}
|
||||
}
|
||||
assertTrue(elements.length > 0);
|
||||
|
||||
final ExtractMethodProcessor processor =
|
||||
|
||||
@@ -74,5 +74,15 @@ public class FindMethodDuplicatesMiscTest extends FindMethodDuplicatesBaseTest {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVarargsAccess() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncorrectVarargsAccess() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVarVarargsAccess() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@ import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.refactoring.inheritanceToDelegation.InheritanceToDelegationProcessor;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ public class InheritanceToDelegationTest extends MultiFileTestCase {
|
||||
final List<PsiMethod> methodsList = new ArrayList<PsiMethod>();
|
||||
for (String name : methodNames) {
|
||||
final PsiMethod[] methodsByName = baseClass.findMethodsByName(name, false);
|
||||
methodsList.addAll(Arrays.asList(methodsByName));
|
||||
ContainerUtil.addAll(methodsList, methodsByName);
|
||||
}
|
||||
delegatedMethods = methodsList.toArray(new PsiMethod[methodsList.size()]);
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings;
|
||||
@@ -221,17 +219,6 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
|
||||
checkResultByFile(baseName + ".after.java");
|
||||
}
|
||||
|
||||
private LanguageLevel myOldLanguageLevel;
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myOldLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk17();
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.intellij.refactoring;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.listeners.JavaRefactoringListenerManager;
|
||||
@@ -69,6 +70,7 @@ public class PullUpTest extends LightCodeInsightTestCase {
|
||||
|
||||
|
||||
public void testRemoveOverride() throws Exception {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest(new RefactoringTestUtil.MemberDescriptor("get", PsiMethod.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,12 +54,16 @@ public class RenameClassTest extends MultiFileTestCase {
|
||||
}
|
||||
|
||||
public void testAutomaticRenameVars() throws Exception {
|
||||
doRenameClass("XX", "Y");
|
||||
}
|
||||
|
||||
private void doRenameClass(final String className, final String newName) throws Exception {
|
||||
doTest(new PerformAction() {
|
||||
public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
|
||||
PsiClass aClass = myJavaFacade.findClass("XX", GlobalSearchScope.allScope(getProject()));
|
||||
PsiClass aClass = myJavaFacade.findClass(className, GlobalSearchScope.allScope(getProject()));
|
||||
assertNotNull("Class XX not found", aClass);
|
||||
|
||||
final RenameProcessor processor = new RenameProcessor(myProject, aClass, "Y", true, true) {
|
||||
final RenameProcessor processor = new RenameProcessor(myProject, aClass, newName, true, true) {
|
||||
@Override
|
||||
protected boolean showAutomaticRenamingDialog(AutomaticRenamer automaticVariableRenamer) {
|
||||
for (PsiNamedElement element : automaticVariableRenamer.getElements()) {
|
||||
@@ -78,6 +82,10 @@ public class RenameClassTest extends MultiFileTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public void testAutomaticRenameInheritors() throws Exception {
|
||||
doRenameClass("MyClass", "MyClass1");
|
||||
}
|
||||
|
||||
public void testAutomaticRenameVarsCollision() throws Exception {
|
||||
doTest("XX", "Y");
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class SafeDeleteTest extends MultiFileTestCase {
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue(message, message.startsWith("local variable <b><code>varName</code></b> has 1 usage that is not safe to delete.\n" +
|
||||
"Of those 0 usages are in strings, comments, or non-Java files."));
|
||||
"Of those 0 usages are in strings, comments, or non-code files."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,18 @@ public class SuggestedParamTypesTest extends LightCodeInsightTestCase {
|
||||
doTest("String", "Object", "Serializable", "Comparable<String>", "CharSequence");
|
||||
}
|
||||
|
||||
public void testCastInside() throws Exception {
|
||||
doTest("A", "Object");
|
||||
}
|
||||
|
||||
public void testMultipleCasts() throws Exception {
|
||||
doTest("A", "Object");
|
||||
}
|
||||
|
||||
public void testCastNoCast() throws Exception {
|
||||
doTest("Object");
|
||||
}
|
||||
|
||||
private void doTest(String... types) throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
|
||||
|
||||
@@ -246,6 +246,19 @@ public class InlineParameterTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testInlineLocalParamDef() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testParameterDefWithWriteAccess() throws Exception {
|
||||
try {
|
||||
doTest(false);
|
||||
}
|
||||
catch (CommonRefactoringUtil.RefactoringErrorHintException e) {
|
||||
assertEquals("Method has no usages", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void doTest(final boolean createLocal) throws Exception {
|
||||
getProject().putUserData(InlineParameterExpressionProcessor.CREATE_LOCAL_FOR_TESTS,createLocal);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.intellij.openapi.util.EmptyRunnable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -516,9 +517,9 @@ public class DirectoryIndexImplTest extends IdeaTestCase {
|
||||
VirtualFile[] actualDirs = myIndex.getDirectoriesByPackageName(packageName, true).toArray(VirtualFile.EMPTY_ARRAY);
|
||||
assertNotNull(actualDirs);
|
||||
HashSet<VirtualFile> set1 = new HashSet<VirtualFile>();
|
||||
set1.addAll(Arrays.asList(expectedDirs));
|
||||
ContainerUtil.addAll(set1, expectedDirs);
|
||||
HashSet<VirtualFile> set2 = new HashSet<VirtualFile>();
|
||||
set2.addAll(Arrays.asList(actualDirs));
|
||||
ContainerUtil.addAll(set2, actualDirs);
|
||||
assertEquals(set1, set2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user