From 1368596c1f56b8f866529067141c1ed96de18b74 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Sep 2012 20:36:14 +0200 Subject: [PATCH] Formerly deprecated method leaved for test use only --- .../src/com/intellij/psi/JavaPsiFacade.java | 26 +++------- .../intellij/psi/impl/JavaPsiFacadeEx.java | 14 ++++- .../intellij/psi/impl/JavaPsiFacadeImpl.java | 10 +--- .../psi/impl/PsiSuperMethodImplUtil.java | 6 ++- .../psi/impl/file/PsiPackageImpl.java | 9 ++-- .../com/intellij/psi/LibraryOrderTest.java | 20 +++++-- .../testSrc/com/intellij/psi/TypesTest.java | 47 +++++++++++------ .../tree/java/ExtendsBoundListTest.java | 52 +++++++++++-------- .../psi/resolve/ResolveMethodTest.java | 17 +++++- .../intellij/psi/search/UpdateCacheTest.java | 4 +- .../com/intellij/refactoring/DndMoveTest.java | 24 +++++++-- .../IntroduceParameterObjectTest.java | 18 ++++++- .../inline/InlineLibraryMethodTest.java | 8 +-- .../fixtures/JavaCodeInsightTestFixture.java | 8 ++- .../impl/JavaCodeInsightTestFixtureImpl.java | 7 +-- java/testFramework/testFramework-java.iml | 2 +- .../compiler/GroovyCompilerTestCase.java | 3 +- 17 files changed, 174 insertions(+), 101 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/psi/JavaPsiFacade.java b/java/java-psi-api/src/com/intellij/psi/JavaPsiFacade.java index 3819fe5290b5..3b4f9a214703 100644 --- a/java/java-psi-api/src/com/intellij/psi/JavaPsiFacade.java +++ b/java/java-psi-api/src/com/intellij/psi/JavaPsiFacade.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,10 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi; import com.intellij.openapi.components.ServiceManager; @@ -27,6 +23,9 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +/** + * @author max + */ public abstract class JavaPsiFacade { private static final NotNullLazyKey INSTANCE_KEY = ServiceManager.createLazyKey(JavaPsiFacade.class); @@ -38,18 +37,6 @@ public abstract class JavaPsiFacade { return getInstance(project).getElementFactory(); } - /** - * Searches the project and all its libraries for a class with the specified full-qualified - * name and returns one if it is found. - * - * @param qualifiedName the full-qualified name of the class to find. - * @return the PSI class, or null if no class with such name is found. - * @deprecated use {@link #findClass(String, com.intellij.psi.search.GlobalSearchScope)} - */ - @Nullable - public abstract PsiClass findClass(@NotNull @NonNls String qualifiedName); - - /** * Searches the specified scope within the project for a class with the specified full-qualified * name and returns one if it is found. @@ -61,7 +48,6 @@ public abstract class JavaPsiFacade { @Nullable public abstract PsiClass findClass(@NonNls @NotNull String qualifiedName, @NotNull GlobalSearchScope scope); - /** * Searches the specified scope within the project for classes with the specified full-qualified * name and returns all found classes. @@ -94,8 +80,8 @@ public abstract class JavaPsiFacade { /** * Returns the factory for the project, which can be used to create instances of certain java constructs from their textual - * presentation. Elements created shall not be used to later interfer (like insert into) a PSI parsed from the user codebase - * since no formatting to the user codestyle will be performed in this case. Please use {@link #getElementFactory()} instead, which + * representation. Elements created shall not be used to later intermix (like insert into) a PSI parsed from the user codebase + * since no formatting to the user code style will be performed in this case. Please use {@link #getElementFactory()} instead, which * provides exactly same methods but ensures created instances will get properly formatted. * @return the parser facade. */ diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeEx.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeEx.java index 64d52091062b..365581938b98 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeEx.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,14 +22,24 @@ package com.intellij.psi.impl; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFileFilter; import com.intellij.psi.JavaPsiFacade; +import com.intellij.psi.PsiClass; +import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; public abstract class JavaPsiFacadeEx extends JavaPsiFacade { - public static JavaPsiFacadeEx getInstanceEx(Project project) { + @TestOnly + public static JavaPsiFacadeEx getInstanceEx(@NotNull Project project) { return (JavaPsiFacadeEx)getInstance(project); } + @TestOnly + @Nullable + public PsiClass findClass(@NotNull String qualifiedName) { + return findClass(qualifiedName, GlobalSearchScope.allScope(getProject())); + } + @TestOnly public abstract void setAssertOnFileLoadingFilter(@NotNull VirtualFileFilter filter); } \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java index 16cecad25dec..17e4eecd4d22 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,14 +90,6 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx { JavaElementType.ANNOTATION.getIndex(); // Initialize stubs. } - /** - * @deprecated - */ - @Override - public PsiClass findClass(@NotNull String qualifiedName) { - return findClass(qualifiedName, GlobalSearchScope.allScope(myProject)); - } - @Override public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) { ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java index 485fa9289950..b84f064216b3 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -303,7 +303,9 @@ public class PsiSuperMethodImplUtil { PsiSubstitutor superSubstitutor, PsiSubstitutor derivedSubstitutor, boolean inRawContext) { if (inRawContext) { - superSubstitutor = JavaPsiFacadeEx.getElementFactory(superClass.getProject()).createRawSubstitutor(derivedSubstitutor, superSubstitutor.getSubstitutionMap().keySet().toArray(PsiTypeParameter.EMPTY_ARRAY)); + Set typeParams = superSubstitutor.getSubstitutionMap().keySet(); + PsiElementFactory factory = JavaPsiFacade.getElementFactory(superClass.getProject()); + superSubstitutor = factory.createRawSubstitutor(derivedSubstitutor, typeParams.toArray(new PsiTypeParameter[typeParams.size()])); } Map map = null; for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(superClass)) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java index b04b592b48af..a8bcac5e5fcd 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -203,7 +203,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); - final JavaPsiFacadeImpl facade = getFacade(); + final JavaPsiFacade facade = getFacade(); final Condition prefixMatcher = processor.getHint(JavaCompletionHints.NAME_FILTER); if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { @@ -295,8 +295,9 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya } } - final JavaPsiFacadeImpl facade = getFacade(); - for (PsiClass aClass : facade.findClasses(getQualifiedName() + ".package-info", allScope())) { + final JavaPsiFacade facade = getFacade(); + final GlobalSearchScope scope = allScope(); + for (PsiClass aClass : facade.findClasses(getQualifiedName() + ".package-info", scope)) { ContainerUtil.addIfNotNull(aClass.getModifierList(), list); } diff --git a/java/java-tests/testSrc/com/intellij/psi/LibraryOrderTest.java b/java/java-tests/testSrc/com/intellij/psi/LibraryOrderTest.java index f1c7f06fd2c8..6a5218b6519d 100644 --- a/java/java-tests/testSrc/com/intellij/psi/LibraryOrderTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/LibraryOrderTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi; import com.intellij.JavaTestUtil; @@ -48,8 +63,7 @@ public class LibraryOrderTest extends PsiTestCase { public void testNavigation() throws Exception { setupPaths(); - final JavaPsiFacade psiManager = getJavaFacade(); - final PsiClass classA = psiManager.findClass("test.A"); + final PsiClass classA = getJavaFacade().findClass("test.A"); final PsiElement navigationElement = classA.getNavigationElement(); assertNotNull(navigationElement); assertTrue(navigationElement != classA); @@ -57,7 +71,7 @@ public class LibraryOrderTest extends PsiTestCase { } private void checkClassFromLib(String qualifiedName, String index) { - final PsiClass classA = (PsiClass)JavaPsiFacade.getInstance(myProject).findClass(qualifiedName).getNavigationElement(); + final PsiClass classA = (PsiClass)getJavaFacade().findClass(qualifiedName).getNavigationElement(); assertNotNull(classA); final PsiMethod[] methodsA = classA.getMethods(); assertEquals(1, methodsA.length); diff --git a/java/java-tests/testSrc/com/intellij/psi/TypesTest.java b/java/java-tests/testSrc/com/intellij/psi/TypesTest.java index 54b9c8cb6ecb..1ae10fadaeb1 100644 --- a/java/java-tests/testSrc/com/intellij/psi/TypesTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/TypesTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi; import com.intellij.openapi.application.ApplicationManager; @@ -5,6 +20,7 @@ import com.intellij.openapi.application.ex.PathManagerEx; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.impl.JavaPsiFacadeEx; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PsiUtil; import com.intellij.testFramework.PsiTestUtil; @@ -34,7 +50,7 @@ public class TypesTest extends GenericsTestCase { } public void testSimpleStuff() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -67,7 +83,7 @@ public class TypesTest extends GenericsTestCase { } public void testRawTypes() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -93,7 +109,7 @@ public class TypesTest extends GenericsTestCase { } public void testSubstWithInheritor() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -123,7 +139,7 @@ public class TypesTest extends GenericsTestCase { } public void testSimpleRawTypeInMethodArg() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -156,8 +172,7 @@ public class TypesTest extends GenericsTestCase { public void testRawTypeInMethodArg() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); - final PsiClass classA = psiManager.findClass("A"); + final PsiClass classA = getJavaFacade().findClass("A"); assertNotNull(classA); final PsiMethod method = classA.getMethods()[0]; @@ -172,7 +187,7 @@ public class TypesTest extends GenericsTestCase { } public void testBoundedParams() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -191,7 +206,7 @@ public class TypesTest extends GenericsTestCase { } public void testRawTypeExtension() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -210,7 +225,7 @@ public class TypesTest extends GenericsTestCase { } public void testTypesInGenericClass() { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -226,8 +241,8 @@ public class TypesTest extends GenericsTestCase { assertEquals(typeT, type); } - public void testAssignableSubinheritor() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + public void testAssignableSubInheritor() throws Exception { + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classCollection = psiManager.findClass("test.Collection"); final PsiClass classList = psiManager.findClass("test.List"); @@ -242,7 +257,7 @@ public class TypesTest extends GenericsTestCase { } public void testComplexInheritance() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -259,7 +274,7 @@ public class TypesTest extends GenericsTestCase { } public void testListListInheritance() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -280,7 +295,7 @@ public class TypesTest extends GenericsTestCase { } public void testSpaceInTypeParameterList() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -294,7 +309,7 @@ public class TypesTest extends GenericsTestCase { } public void testMethodTypeParameter() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); @@ -325,7 +340,7 @@ public class TypesTest extends GenericsTestCase { } public void testRawArrayTypes() throws Exception { - final JavaPsiFacade psiManager = getJavaFacade(); + final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/source/tree/java/ExtendsBoundListTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/source/tree/java/ExtendsBoundListTest.java index ec7481a19a35..f8fdc1789a6d 100644 --- a/java/java-tests/testSrc/com/intellij/psi/impl/source/tree/java/ExtendsBoundListTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/impl/source/tree/java/ExtendsBoundListTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi.impl.source.tree.java; import com.intellij.openapi.application.ApplicationManager; @@ -19,6 +34,7 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase { check(); } + public void testRemoveBoundFromEnd() throws Exception { final PsiTypeParameter typeParameter = getTypeParameter(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @@ -30,6 +46,7 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase { check(); } + public void testRemoveBoundFromMiddle() throws Exception { final PsiTypeParameter typeParameter = getTypeParameter(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @@ -45,20 +62,19 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase { public void testAddBoundInTheMiddle() throws Exception { final PsiTypeParameter typeParameter = getTypeParameter(); final PsiReferenceList extendsList = typeParameter.getExtendsList(); - final JavaPsiFacade manager = getJavaFacade(); - final PsiClass clonableClass = manager.findClass("java.lang.Cloneable"); - assertNotNull(clonableClass); - final PsiJavaCodeReferenceElement reference = manager.getElementFactory().createClassReferenceElement(clonableClass); + final PsiClass cloneableClass = getJavaFacade().findClass("java.lang.Cloneable"); + assertNotNull(cloneableClass); + final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass); extendsList.addAfter(reference, extendsList.getReferenceElements()[0]); check(); } + public void testAddBoundInFront() throws Exception { final PsiTypeParameter typeParameter = getTypeParameter(); final PsiReferenceList extendsList = typeParameter.getExtendsList(); - final JavaPsiFacade manager = getJavaFacade(); - final PsiClass clonableClass = manager.findClass("java.lang.Cloneable"); - assertNotNull(clonableClass); - final PsiJavaCodeReferenceElement reference = manager.getElementFactory().createClassReferenceElement(clonableClass); + final PsiClass cloneableClass = getJavaFacade().findClass("java.lang.Cloneable"); + assertNotNull(cloneableClass); + final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass); extendsList.addBefore(reference, extendsList.getReferenceElements()[0]); check(); } @@ -66,28 +82,23 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase { public void testAddBoundInEnd() throws Exception { final PsiTypeParameter typeParameter = getTypeParameter(); final PsiReferenceList extendsList = typeParameter.getExtendsList(); - final JavaPsiFacade manager = getJavaFacade(); - final PsiClass clonableClass = manager.findClass("java.lang.Cloneable"); - assertNotNull(clonableClass); - final PsiJavaCodeReferenceElement reference = manager.getElementFactory().createClassReferenceElement(clonableClass); + final PsiClass cloneableClass = getJavaFacade().findClass("java.lang.Cloneable"); + assertNotNull(cloneableClass); + final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass); extendsList.addBefore(reference, null); check(); } - public void testAddBound() throws Exception { final PsiTypeParameter typeParameter = getTypeParameter(); final PsiReferenceList extendsList = typeParameter.getExtendsList(); - final JavaPsiFacade manager = getJavaFacade(); - final PsiClass clonableClass = manager.findClass(CommonClassNames.JAVA_LANG_RUNNABLE); - assertNotNull(clonableClass); - final PsiJavaCodeReferenceElement reference = manager.getElementFactory().createClassReferenceElement(clonableClass); + final PsiClass cloneableClass = getJavaFacade().findClass(CommonClassNames.JAVA_LANG_RUNNABLE); + assertNotNull(cloneableClass); + final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass); extendsList.add(reference); check(); } - - private void check() throws Exception { outputFile(getTestName(true) + "_after.java"); } @@ -95,8 +106,7 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase { private PsiTypeParameter getTypeParameter() throws Exception { inputFile(getTestName(true) + ".java"); final PsiClass aClass = ((PsiJavaFile)getFile()).getClasses()[0]; - final PsiTypeParameter typeParameter = aClass.getTypeParameters()[0]; - return typeParameter; + return aClass.getTypeParameters()[0]; } private void outputFile(String filename) throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java index 0a601aa3d5dd..b91df431fe78 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi.resolve; import com.intellij.openapi.projectRoots.Sdk; @@ -267,7 +282,7 @@ public class ResolveMethodTest extends ResolveTestCase { PsiReference ref = configureByFile("method/" + getTestName(false) + ".java"); // just assume this is called by some highlighting inspection/intention/pass before the resolve - JavaPsiFacade.getInstance(getProject()).findClass("NN").getAllMethods(); + getJavaFacade().findClass("NN").getAllMethods(); PsiElement target = ref.resolve(); assertInstanceOf(target, PsiMethod.class); diff --git a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java index e081da9e9f8d..0aa3369511d0 100644 --- a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java @@ -31,7 +31,7 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; -import com.intellij.psi.impl.JavaPsiFacadeImpl; +import com.intellij.psi.impl.JavaPsiFacadeEx; import com.intellij.psi.impl.PsiManagerImpl; import com.intellij.psi.impl.cache.impl.id.IdIndex; import com.intellij.psi.impl.cache.impl.todo.TodoIndex; @@ -181,7 +181,7 @@ public class UpdateCacheTest extends PsiTestCase{ assertNotNull(myProject); myPsiManager = (PsiManagerImpl) PsiManager.getInstance(myProject); - myJavaFacade = (JavaPsiFacadeImpl) JavaPsiFacade.getInstance(myProject); + myJavaFacade = JavaPsiFacadeEx.getInstanceEx(myProject); objectClass = myJavaFacade.findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(getProject())); assertNotNull(objectClass); diff --git a/java/java-tests/testSrc/com/intellij/refactoring/DndMoveTest.java b/java/java-tests/testSrc/com/intellij/refactoring/DndMoveTest.java index 8f7af90edbce..51a5acfbfa63 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/DndMoveTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/DndMoveTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.refactoring; import com.intellij.codeInsight.CodeInsightTestCase; @@ -9,8 +24,8 @@ import com.intellij.testFramework.PsiTestUtil; import org.jetbrains.annotations.Nullable; /** - * User: anna - * Date: Aug 31, 2010 + * @author anna + * @since Aug 31, 2010 */ public class DndMoveTest extends CodeInsightTestCase { @Override @@ -23,7 +38,7 @@ public class DndMoveTest extends CodeInsightTestCase { @Nullable @Override public PsiElement compute() { - return JavaPsiFacade.getInstance(getProject()).findClass("d.MyClass"); + return getJavaFacade().findClass("d.MyClass"); } }, true); } @@ -33,12 +48,11 @@ public class DndMoveTest extends CodeInsightTestCase { @Nullable @Override public PsiElement compute() { - return JavaPsiFacade.getInstance(getProject()).findClass("d.Second"); + return getJavaFacade().findClass("d.Second"); } }, false); } - private void doTest(final String targetDirName, final Computable source, final boolean expected) throws Exception { String testName = getTestName(true); String root = getTestDataPath() + getTestRoot() + testName; diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterObjectTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterObjectTest.java index 66942460a50a..bd70e5dafa98 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterObjectTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterObjectTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * User: anna * Date: 20-Aug-2008 @@ -138,7 +154,7 @@ public class IntroduceParameterObjectTest extends MultiFileTestCase{ @Override public ParameterTablePanel.VariableData[] fun(PsiMethod psiMethod) { final PsiParameter parameter = psiMethod.getParameterList().getParameters()[0]; - final PsiClass collectionClass = JavaPsiFacade.getInstance(getProject()).findClass(CommonClassNames.JAVA_UTIL_COLLECTION); + final PsiClass collectionClass = getJavaFacade().findClass(CommonClassNames.JAVA_UTIL_COLLECTION); final ParameterTablePanel.VariableData variableData = new ParameterTablePanel.VariableData(parameter, JavaPsiFacade.getElementFactory(getProject()).createType(collectionClass)); variableData.name = parameter.getName(); diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLibraryMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLibraryMethodTest.java index e3af5151d751..2bbee1af264e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLibraryMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLibraryMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,8 @@ import org.jetbrains.annotations.NonNls; import java.io.IOException; /** - * User: anna - * Date: 11/4/11 + * @author anna + * @since 11/4/11 */ public class InlineLibraryMethodTest extends RefactoringTestCase { @Override @@ -45,7 +45,7 @@ public class InlineLibraryMethodTest extends RefactoringTestCase { @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java"; configureByFile(fileName); - PsiClass fileClass = JavaPsiFacade.getInstance(getProject()).findClass("mycompany.File"); + PsiClass fileClass = getJavaFacade().findClass("mycompany.File"); assertNotNull(fileClass); final PsiFile file = fileClass.getContainingFile(); ApplicationManager.getApplication().runWriteAction(new Runnable() { diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightTestFixture.java b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightTestFixture.java index d168a632b97c..e5d8c43a8c0a 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightTestFixture.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightTestFixture.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,19 +15,17 @@ */ package com.intellij.testFramework.fixtures; -import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiPackage; +import com.intellij.psi.impl.JavaPsiFacadeEx; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import java.io.IOException; - /** * @author yole */ public interface JavaCodeInsightTestFixture extends CodeInsightTestFixture { - JavaPsiFacade getJavaFacade(); + JavaPsiFacadeEx getJavaFacade(); PsiClass addClass(@NotNull @NonNls final String classText); diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java b/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java index eb2b6548fa86..7ebb31b1b1b2 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import com.intellij.psi.impl.JavaPsiFacadeEx; import com.intellij.psi.impl.PsiModificationTrackerImpl; import com.intellij.psi.search.ProjectScope; import com.intellij.testFramework.fixtures.IdeaProjectTestFixture; @@ -36,9 +37,9 @@ public class JavaCodeInsightTestFixtureImpl extends CodeInsightTestFixtureImpl i } @Override - public JavaPsiFacade getJavaFacade() { + public JavaPsiFacadeEx getJavaFacade() { assertInitialized(); - return JavaPsiFacade.getInstance(getProject()); + return JavaPsiFacadeEx.getInstanceEx(getProject()); } @Override diff --git a/java/testFramework/testFramework-java.iml b/java/testFramework/testFramework-java.iml index bcd446ef0028..d37693273732 100644 --- a/java/testFramework/testFramework-java.iml +++ b/java/testFramework/testFramework-java.iml @@ -15,7 +15,7 @@ - + diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java index 78ec639c9814..81ce946a69e8 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java @@ -48,7 +48,6 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiFile; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PsiTestUtil; @@ -184,7 +183,7 @@ public abstract class GroovyCompilerTestCase extends JavaCodeInsightFixtureTestC try { if (useJps()) { //noinspection ConstantConditions - touch(JavaPsiFacade.getInstance(getProject()).findClass(className).getContainingFile().getVirtualFile()); + touch(myFixture.getJavaFacade().findClass(className).getContainingFile().getVirtualFile()); } else { //noinspection ConstantConditions