mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Formerly deprecated method leaved for test use only
This commit is contained in:
@@ -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<JavaPsiFacade, Project> 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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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<PsiTypeParameter> typeParams = superSubstitutor.getSubstitutionMap().keySet();
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(superClass.getProject());
|
||||
superSubstitutor = factory.createRawSubstitutor(derivedSubstitutor, typeParams.toArray(new PsiTypeParameter[typeParams.size()]));
|
||||
}
|
||||
Map<PsiTypeParameter, PsiType> map = null;
|
||||
for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(superClass)) {
|
||||
|
||||
@@ -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<String> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+31
-21
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<PsiElement> source, final boolean expected) throws Exception {
|
||||
String testName = getTestName(true);
|
||||
String root = getTestDataPath() + getTestRoot() + testName;
|
||||
|
||||
@@ -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();
|
||||
|
||||
+4
-4
@@ -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() {
|
||||
|
||||
+3
-5
@@ -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);
|
||||
|
||||
|
||||
+4
-3
@@ -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
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<orderEntry type="module" module-name="lang-api" exported="" />
|
||||
<orderEntry type="module" module-name="lang-impl" exported="" />
|
||||
<orderEntry type="module" module-name="compiler-impl" />
|
||||
<orderEntry type="module" module-name="java-impl" />
|
||||
<orderEntry type="module" module-name="java-impl" exported="" />
|
||||
<orderEntry type="module" module-name="execution-impl" exported="" scope="RUNTIME" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="testFramework" exported="" />
|
||||
|
||||
+1
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user