lighten up, remove redundant language level setting
authorDmitry Jemerov <yole@intellij.com>
Thu, 10 Sep 2009 17:47:55 +0000 (21:47 +0400)
committerDmitry Jemerov <yole@intellij.com>
Thu, 10 Sep 2009 17:47:55 +0000 (21:47 +0400)
java/java-tests/testSrc/com/intellij/refactoring/AnonymousToInnerTest.java
java/java-tests/testSrc/com/intellij/refactoring/ChangeSignaturePropagationTest.java
java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java
java/java-tests/testSrc/com/intellij/refactoring/ExtractMethod15Test.java
java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java
java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectWithMultipleExitPointsTest.java
java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java
java/java-tests/testSrc/com/intellij/refactoring/InheritanceToDelegationTest.java
java/java-tests/testSrc/com/intellij/refactoring/IntroduceConstantTest.java

index 56d224e294effdab7493ca48d228d7b7a6a19fb0..6782516c8291f308d8fa6069fd7cc18af2e7d56c 100644 (file)
@@ -1,15 +1,15 @@
 package com.intellij.refactoring;
 
 import com.intellij.JavaTestUtil;
-import com.intellij.codeInsight.CodeInsightTestCase;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
 import com.intellij.refactoring.anonymousToInner.AnonymousToInnerHandler;
+import com.intellij.testFramework.LightCodeInsightTestCase;
 
 /**
  * @author yole
  */
-public class AnonymousToInnerTest extends CodeInsightTestCase {
+public class AnonymousToInnerTest extends LightCodeInsightTestCase {
   private static final String TEST_ROOT = "/refactoring/anonymousToInner/";
 
   @Override
@@ -18,7 +18,7 @@ public class AnonymousToInnerTest extends CodeInsightTestCase {
   }
 
   @Override
-  protected Sdk getTestProjectJdk() {
+  protected Sdk getProjectJDK() {
     return JavaSdkImpl.getMockJdk15("java 1.5");
   }
 
@@ -38,7 +38,7 @@ public class AnonymousToInnerTest extends CodeInsightTestCase {
     };
 
 
-    handler.invoke(myProject, myEditor, myFile, null);
+    handler.invoke(getProject(), myEditor, myFile, null);
     checkResultByFile(TEST_ROOT + getTestName(true) + "_after.java");
   }
 }
index 31fed2dca19c601a01ae41a48987755954226371..571adeab21a6828fb45510293c7787f3f97a4695 100644 (file)
@@ -1,6 +1,6 @@
 package com.intellij.refactoring;
 
-import com.intellij.codeInsight.CodeInsightTestCase;
+import com.intellij.JavaTestUtil;
 import com.intellij.codeInsight.TargetElementUtilBase;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
@@ -8,8 +8,8 @@ import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
 import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
 import com.intellij.refactoring.changeSignature.ThrownExceptionInfo;
 import com.intellij.refactoring.util.CanonicalTypes;
+import com.intellij.testFramework.LightCodeInsightTestCase;
 import com.intellij.util.containers.HashSet;
-import com.intellij.JavaTestUtil;
 
 import java.util.Arrays;
 import java.util.Set;
@@ -17,7 +17,7 @@ import java.util.Set;
 /**
  * @author ven
  */
-public class ChangeSignaturePropagationTest extends CodeInsightTestCase {
+public class ChangeSignaturePropagationTest extends LightCodeInsightTestCase {
   public void testParamSimple() throws Exception {
     parameterPropagationTest();
   }
@@ -37,7 +37,7 @@ public class ChangeSignaturePropagationTest extends CodeInsightTestCase {
   private void parameterPropagationTest() throws Exception {
     PsiMethod method = getPrimaryMethod();
     PsiClass aClass = method.getContainingClass();
-    PsiType newParamType = myJavaFacade.getElementFactory().createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(myProject));
+    PsiType newParamType = JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(getProject()));
     final ParameterInfoImpl[] newParameters = new ParameterInfoImpl[]{new ParameterInfoImpl(-1, "clazz", newParamType, "null")};
     final Set<PsiMethod> methodsToPropagateParameters = new HashSet<PsiMethod>(Arrays.asList(aClass.getMethods()));
     doTest(newParameters, new ThrownExceptionInfo[0], methodsToPropagateParameters, null, method);
@@ -46,7 +46,7 @@ public class ChangeSignaturePropagationTest extends CodeInsightTestCase {
   private void exceptionPropagationTest() throws Exception {
     PsiMethod method = getPrimaryMethod();
     PsiClass aClass = method.getContainingClass();
-    PsiClassType newExceptionType = myJavaFacade.getElementFactory().createTypeByFQClassName("java.lang.Exception", GlobalSearchScope.allScope(myProject));
+    PsiClassType newExceptionType = JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
     final ThrownExceptionInfo[] newExceptions = new ThrownExceptionInfo[]{new ThrownExceptionInfo(-1, newExceptionType)};
     final Set<PsiMethod> methodsToPropagateExceptions = new HashSet<PsiMethod>(Arrays.asList(aClass.getMethods()));
     doTest(new ParameterInfoImpl[0], newExceptions, null, methodsToPropagateExceptions, method);
@@ -60,7 +60,7 @@ public class ChangeSignaturePropagationTest extends CodeInsightTestCase {
     final String filePath = getBasePath() + getTestName(false) + ".java";
     final PsiType returnType = primaryMethod.getReturnType();
     final CanonicalTypes.Type type = returnType == null ? null : CanonicalTypes.createTypeWrapper(returnType);
-    new ChangeSignatureProcessor(myProject, primaryMethod, false, null,
+    new ChangeSignatureProcessor(getProject(), primaryMethod, false, null,
                                  primaryMethod.getName(),
                                  type,
                                  generateParameterInfos(primaryMethod, newParameters),
@@ -78,7 +78,7 @@ public class ChangeSignaturePropagationTest extends CodeInsightTestCase {
     return (PsiMethod) targetElement;
   }
 
-  private String getBasePath() {
+  private static String getBasePath() {
     return "/refactoring/changeSignaturePropagation/";
   }
 
index 4b96785ca73887392e045dcd3ed941431bab9369..98394457514bccb24b341a9a1669bd42e8583a5f 100644 (file)
@@ -1,21 +1,19 @@
 package com.intellij.refactoring;
 
 import com.intellij.JavaTestUtil;
-import com.intellij.codeInsight.CodeInsightTestCase;
 import com.intellij.codeInsight.TargetElementUtilBase;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
 import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
 import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
 import com.intellij.refactoring.changeSignature.ThrownExceptionInfo;
+import com.intellij.testFramework.LightCodeInsightTestCase;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NonNls;
 
 /**
  * @author dsl
  */
-public class ChangeSignatureTest extends CodeInsightTestCase {
+public class ChangeSignatureTest extends LightCodeInsightTestCase {
   public void testSimple() throws Exception {
     doTest(null, null, null, new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
   }
@@ -202,11 +200,6 @@ public class ChangeSignatureTest extends CodeInsightTestCase {
     doTest(null, new ParameterInfoImpl[]{new ParameterInfoImpl(-1, "i", PsiType.INT, "0")}, false);
   }
 
-  protected void setUpJdk() {
-    super.setUpJdk();
-    LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(LanguageLevel.JDK_1_5);
-  }
-
   private void doTest(String newReturnType, ParameterInfoImpl[] parameterInfos, final boolean generateDelegate) throws Exception {
     doTest(null, null, newReturnType, parameterInfos, new ThrownExceptionInfo[0], generateDelegate);
   }
index e380b8c1213015a9ec20f9aac4e479ad5457abf6..5a700c773650551ad6e1ce89838bcd8c64adec64 100644 (file)
@@ -4,15 +4,12 @@
  */
 package com.intellij.refactoring;
 
+import com.intellij.JavaTestUtil;
 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.LightCodeInsightTestCase;
-import com.intellij.JavaTestUtil;
 
 public class ExtractMethod15Test extends LightCodeInsightTestCase {
-  private LanguageLevel myPreviousLanguageLevel;
   private static final String BASE_PATH = "/refactoring/extractMethod15/";
 
   @Override
@@ -20,17 +17,6 @@ public class ExtractMethod15Test extends LightCodeInsightTestCase {
     return JavaTestUtil.getJavaTestDataPath();
   }
 
-  protected void setUp() throws Exception {
-    super.setUp();
-    myPreviousLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
-    LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
-  }
-
-  protected void tearDown() throws Exception {
-    LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPreviousLanguageLevel);
-    super.tearDown();
-  }
-
   public void testCodeDuplicatesWithMultOccurences() throws Exception {
     configureByFile(BASE_PATH + getTestName(false) + ".java");
     boolean success = ExtractMethodTest.performExtractMethod(true, true, getEditor(), getFile(), getProject());
index cb3c1230c0218b0a6556f1ffa0c2ce6e00113f29..ad24d9ecd936360b5c4c0326b5c2399e62e9bb85 100644 (file)
@@ -4,15 +4,15 @@
  */
 package com.intellij.refactoring;
 
-import com.intellij.codeInsight.CodeInsightTestCase;
+import com.intellij.JavaTestUtil;
 import com.intellij.codeInsight.TargetElementUtilBase;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
 import com.intellij.refactoring.util.duplicates.DuplicatesImpl;
-import com.intellij.JavaTestUtil;
+import com.intellij.testFramework.LightCodeInsightTestCase;
 
-public class ExtractMethodObjectTest extends CodeInsightTestCase {
+public class ExtractMethodObjectTest extends LightCodeInsightTestCase {
   @Override
   protected String getTestDataPath() {
     return JavaTestUtil.getJavaTestDataPath();
index db68bebf6b27764fdfcea3d5795ac2e1090a9a1b..56ca2fc844721f29a88a268e3c0dab4cdd50b04d 100644 (file)
@@ -4,15 +4,15 @@
  */
 package com.intellij.refactoring;
 
-import com.intellij.codeInsight.CodeInsightTestCase;
+import com.intellij.JavaTestUtil;
 import com.intellij.codeInsight.CodeInsightUtil;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiExpression;
 import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
 import com.intellij.refactoring.util.duplicates.DuplicatesImpl;
-import com.intellij.JavaTestUtil;
+import com.intellij.testFramework.LightCodeInsightTestCase;
 
-public class ExtractMethodObjectWithMultipleExitPointsTest extends CodeInsightTestCase {
+public class ExtractMethodObjectWithMultipleExitPointsTest extends LightCodeInsightTestCase {
   @Override
   protected String getTestDataPath() {
     return JavaTestUtil.getJavaTestDataPath();
index 728a87c9023ad9d3c47f68c427f051850ff76ad0..0cd1c520e604d8cfe7d308485849d3191957a976 100644 (file)
@@ -4,37 +4,21 @@
  */
 package com.intellij.refactoring;
 
+import com.intellij.JavaTestUtil;
 import com.intellij.analysis.AnalysisScope;
 import com.intellij.codeInsight.TargetElementUtilBase;
 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.psi.PsiMethod;
 import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler;
 import com.intellij.testFramework.LightCodeInsightTestCase;
-import com.intellij.JavaTestUtil;
 
 public abstract class FindMethodDuplicatesBaseTest extends LightCodeInsightTestCase {
-  private LanguageLevel myPreviousLanguageLevel;
-
   @Override
   protected String getTestDataPath() {
     return JavaTestUtil.getJavaTestDataPath();
   }
-  
-
-  protected void setUp() throws Exception {
-    super.setUp();
-    myPreviousLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
-    LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
-  }
-
-  protected void tearDown() throws Exception {
-    LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPreviousLanguageLevel);
-    super.tearDown();
-  }
 
   protected Sdk getProjectJDK() {
     return JavaSdkImpl.getMockJdk15("java 1.5");
index 7c000a820945fa0ee0c358fd8dbe88daad1929f8..25663b98e9615802a9f1095a6c2d4c8f49e60fab 100644 (file)
@@ -1,44 +1,28 @@
 package com.intellij.refactoring;
 
+import com.intellij.JavaTestUtil;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.PsiClass;
 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.JavaTestUtil;
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * @author dsl
  */
 public class InheritanceToDelegationTest extends MultiFileTestCase {
-  private LanguageLevel myPreviousLanguageLevel;
-
   @Override
   protected String getTestDataPath() {
     return JavaTestUtil.getJavaTestDataPath();
   }
 
-
-  protected void setUp() throws Exception {
-    super.setUp();
-    myPreviousLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
-    LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
-  }
-
-  protected void tearDown() throws Exception {
-    LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPreviousLanguageLevel);
-    super.tearDown();
-  }
-
   protected Sdk getTestProjectJdk() {
     return JavaSdkImpl.getMockJdk15("java 1.5");
   }
index 90b93a7ecb6c488ffd166ae19720460d3029a0f6..7b4690103a4bacaaaba804500bae08d6f34992c2 100644 (file)
@@ -1,20 +1,20 @@
 package com.intellij.refactoring;
 
 import com.intellij.JavaTestUtil;
-import com.intellij.codeInsight.CodeInsightTestCase;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiJavaFile;
 import com.intellij.psi.PsiLocalVariable;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.testFramework.LightCodeInsightTestCase;
 import junit.framework.Assert;
 import org.jetbrains.annotations.NonNls;
 
 /**
  * @author ven
  */
-public class IntroduceConstantTest extends CodeInsightTestCase {
+public class IntroduceConstantTest extends LightCodeInsightTestCase {
   @NonNls private static final String BASE_PATH = "/refactoring/introduceConstant/";
 
   @Override
@@ -36,7 +36,7 @@ public class IntroduceConstantTest extends CodeInsightTestCase {
     doTest(true);    
   }
 
-  private void convertLocal(final boolean makeEnumConstant) {
+  private static void convertLocal(final boolean makeEnumConstant) {
     PsiLocalVariable local = PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiLocalVariable.class);
     new MockLocalToFieldHandler(getProject(), true, makeEnumConstant).convertLocalToField(local, getEditor());
   }
@@ -57,7 +57,7 @@ public class IntroduceConstantTest extends CodeInsightTestCase {
     checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
   }
 
-  protected Sdk getTestProjectJdk() {
+  protected Sdk getProjectJDK() {
     return JavaSdkImpl.getMockJdk15("java 1.5");
   }
 }
\ No newline at end of file