Replace PsiManager.getInstance(psiElement.getProject()) to psiElement.getManager...
authorSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Sat, 28 Jan 2012 13:23:15 +0000 (17:23 +0400)
committerSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Sat, 28 Jan 2012 13:23:15 +0000 (17:23 +0400)
21 files changed:
java/java-impl/src/com/intellij/psi/impl/search/AnnotatedElementsSearcher.java
java/java-impl/src/com/intellij/psi/impl/search/AnnotatedPackagesSearcher.java
java/java-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearcher.java
java/java-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java
java/java-impl/src/com/intellij/psi/impl/search/MethodUsagesSearcher.java
java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
platform/lang-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java
platform/lang-impl/src/com/intellij/codeInspection/reference/RefFileImpl.java
plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsBetweenInconvertibleTypesInspection.java
plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintInspectionBase.java
plugins/ant/src/com/intellij/lang/ant/dom/AntDomProject.java
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyInArgumentCheckInspection.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/weighers/GrKindWeigher.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GdkMethodDslProvider.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureConflictSearcher.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencySystemPathConverter.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenParentRelativePathConverter.java
plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/support/jaxen/PsiDocumentNavigator.java
xml/impl/src/com/intellij/codeInsight/daemon/impl/tagTreeHighlighting/XmlTagTreeHighlightingPass.java
xml/relaxng/src/org/intellij/plugins/relaxNG/RncFileReferenceManipulator.java

index 4da8609cb45c2ddd782f872e2d87a54995288ead..d5270b733954b2639eb56c4e388643ebaccd656b 100644 (file)
@@ -36,7 +36,7 @@ public class AnnotatedElementsSearcher implements QueryExecutor<PsiModifierListO
     final String annotationFQN = annClass.getQualifiedName();
     assert annotationFQN != null;
 
-    final PsiManagerImpl psiManager = (PsiManagerImpl)PsiManager.getInstance(annClass.getProject());
+    final PsiManagerImpl psiManager = (PsiManagerImpl)annClass.getManager();
 
     final SearchScope useScope = p.getScope();
     Class<? extends PsiModifierListOwner>[] types = p.getTypes();
index bf1eac47d52108a01fa1a9ab091b6f564126053c..397c85cc96428306601f5d40e6375979cf6cdecd 100644 (file)
@@ -47,7 +47,7 @@ public class AnnotatedPackagesSearcher implements QueryExecutor<PsiPackage, Anno
     final String annotationFQN = annClass.getQualifiedName();
     assert annotationFQN != null;
 
-    final PsiManagerImpl psiManager = (PsiManagerImpl)PsiManager.getInstance(annClass.getProject());
+    final PsiManagerImpl psiManager = (PsiManagerImpl)annClass.getManager();
     final SearchScope useScope = p.getScope();
 
     final String annotationShortName = annClass.getName();
index ba972624cb5a69b9946878adbf0950fbe95c8700..daa403fbb5cd349d1a11386e0dbb3f9a9745edb1 100644 (file)
@@ -21,7 +21,7 @@ public class ConstructorReferencesSearcher extends QueryExecutorBase<PsiReferenc
   public void processQuery(@NotNull ReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
     final PsiElement element = p.getElementToSearch();
     if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) {
-      new ConstructorReferencesSearchHelper(PsiManager.getInstance(element.getProject()))
+      new ConstructorReferencesSearchHelper(element.getManager())
         .processConstructorReferences(consumer, (PsiMethod)p.getElementToSearch(), p.getScope(), p.isIgnoreAccessScope(), true, p.getOptimizer());
     }
   }
index 8ae1fbf9b0b43b820ac465edd4c81614c6025705..b495b2bd0d8bb09103017b0bb0aea8dc0adc80d2 100644 (file)
@@ -36,7 +36,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
   @Override
   public boolean execute(@NotNull final DirectClassInheritorsSearch.SearchParameters p, @NotNull final Processor<PsiClass> consumer) {
     final PsiClass aClass = p.getClassToProcess();
-    final PsiManagerImpl psiManager = (PsiManagerImpl)PsiManager.getInstance(aClass.getProject());
+    final PsiManagerImpl psiManager = (PsiManagerImpl)aClass.getManager();
 
     final SearchScope useScope = ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
       @Override
index e71cbe46e1732aac9750ea5db120cec7d89d470d..42ccde45a7850bb7ced41fc727a9dc6a840fab0d 100644 (file)
@@ -25,7 +25,7 @@ public class MethodUsagesSearcher extends QueryExecutorBase<PsiReference, Method
 
     final SearchScope searchScope = p.getScope();
 
-    final PsiManager psiManager = PsiManager.getInstance(method.getProject());
+    final PsiManager psiManager = method.getManager();
 
     final PsiClass aClass = method.getContainingClass();
     if (aClass == null) return;
index d710ee9948d7498326fbf68e11fbefed5e449792..a931ba654458fc5c9573336ce4f4ab0ca0157e20 100644 (file)
@@ -931,7 +931,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
         PsiMethod prototype;
         final PsiMethod method = myChangeInfo.getMethod();
         if (!StdLanguages.JAVA.equals(method.getLanguage())) return;
-        PsiManager manager = PsiManager.getInstance(method.getProject());
+        PsiManager manager = method.getManager();
         PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
         final CanonicalTypes.Type returnType = myChangeInfo.getNewReturnType();
         if (returnType != null) {
index e63943379f8bf9b2d2561158e049eaf638e27a81..30c34b725ca9131b95e6930a4cc9e1d86a4864b4 100644 (file)
@@ -148,7 +148,7 @@ public class JavaResolveCache {
         if (physicalContext != null &&
             (physicalFile = physicalContext.getContainingFile()) != null &&
             physicalFile.getVirtualFile() != null &&
-            !((PsiManagerEx)PsiManager.getInstance(dummyHolder.getProject())).isAssertOnFileLoading(physicalFile.getVirtualFile())) {
+            !((PsiManagerEx)dummyHolder.getManager()).isAssertOnFileLoading(physicalFile.getVirtualFile())) {
           DebugUtil.trackInvalidation(physicalContext, "dummy holder was invalidated", new Processor<PsiElement>() {
             @Override
             public boolean process(PsiElement element) {
index 418cd296aa76285e65fe12aba964ee355d21309c..2a2ed840ab049ea64069927c0096676a1e104c4e 100644 (file)
@@ -31,7 +31,7 @@ public class RefDirectoryImpl extends RefElementImpl implements RefDirectory{
   protected RefDirectoryImpl(PsiDirectory psiElement, RefManager refManager) {
     super(psiElement.getName(), psiElement, refManager);
     final PsiDirectory parentDirectory = psiElement.getParentDirectory();
-    if (parentDirectory != null && PsiManager.getInstance(parentDirectory.getProject()).isInProject(parentDirectory)) {
+    if (parentDirectory != null && parentDirectory.getManager().isInProject(parentDirectory)) {
       final RefElementImpl refElement = (RefElementImpl)refManager.getReference(parentDirectory);
       if (refElement != null) {
         refElement.add(this);
index 2a355cf9065434f0d1318a7bda710e6e6db3588d..2c09c7144f35564770a984cb24b34342a67118a1 100644 (file)
@@ -32,7 +32,7 @@ public class RefFileImpl extends RefElementImpl implements RefFile {
     if (vFile == null) return;
     final VirtualFile parentDirectory = vFile.getParent();
     if (parentDirectory == null) return;
-    final PsiDirectory psiDirectory = PsiManager.getInstance(elem.getProject()).findDirectory(parentDirectory);
+    final PsiDirectory psiDirectory = elem.getManager().findDirectory(parentDirectory);
     if (psiDirectory != null) {
       final RefElement element = getRefManager().getReference(psiDirectory);
       if (element != null) {
index e8b19fecd47cfdedb1c25e85ba9b926eb2dced8e..9375239fe32b4386c7699e5aa7163596efe96943 100644 (file)
@@ -123,8 +123,7 @@ public class AssertEqualsBetweenInconvertibleTypesInspection
       if (!parameterType1.equals(parameterType2)) {
         return;
       }
-      final PsiManager manager =
-        PsiManager.getInstance(expression.getProject());
+      final PsiManager manager = expression.getManager();
       final GlobalSearchScope scope = expression.getResolveScope();
       if (type2 instanceof PsiPrimitiveType &&
           parameterType2.equals(PsiType.getJavaLangObject(manager,
index dfec9b262f16cf84b1749e03cab755016342218e..af7f059585a4e59501ad54bb15bc631ff476bb2d 100644 (file)
@@ -149,7 +149,7 @@ public abstract class AndroidLintInspectionBase extends GlobalInspectionTool {
             final VirtualFile manifestFile = AndroidRootUtil.getManifestFile(module);
 
             if (manifestFile != null) {
-              f = PsiManager.getInstance(f.getProject()).findFile(manifestFile);
+              f = f.getManager().findFile(manifestFile);
             }
           }
         }
index ea74435e308518f4a2d67556eb3d2192f21dc3e9..0685b8de739a5e875a820d3e80ed4c6ffdc1ffdf 100644 (file)
@@ -83,7 +83,7 @@ public abstract class AntDomProject extends AntDomNamedElement implements Proper
     if (parent == null) {
       return null;
     }
-    return PsiManager.getInstance(tag.getProject()).findDirectory(parent);
+    return tag.getManager().findDirectory(parent);
   }
 
   @Nullable
index 3b5e58883af0046db2c3f2f1565db9707545117c..f81fdb554fa5bbd4f7da2348ec300b37148dabfb 100644 (file)
@@ -91,7 +91,7 @@ public class GroovyInArgumentCheckInspection extends BaseInspection {
 
       if (component == null) return;
       
-      if (TypesUtil.isAssignable(ltype, component, PsiManager.getInstance(expression.getProject()), expression.getResolveScope(), false)) return;
+      if (TypesUtil.isAssignable(ltype, component, expression.getManager(), expression.getResolveScope(), false)) return;
 
       registerError(expression, ltype, rtype);
     }
@@ -105,7 +105,7 @@ public class GroovyInArgumentCheckInspection extends BaseInspection {
 
       if (lclass == null || rclass == null) return;
 
-      if (PsiManager.getInstance(expression.getProject()).areElementsEquivalent(lclass, rclass)) return;
+      if (expression.getManager().areElementsEquivalent(lclass, rclass)) return;
 
       if (lclass.isInterface() || rclass.isInterface()) return;
 
index ec55633f787389dd7c0f68cb405ac31e7a9387a9..442255bd8359b6453fe71e7655be14a19f6b67d3 100644 (file)
@@ -142,7 +142,7 @@ public class GrKindWeigher extends CompletionWeigher {
     final PsiClass psiClass = ((PsiClassType)type).resolve();
     if (psiClass == null) return false;
 
-    return PsiManager.getInstance(qualifier.getProject()).areElementsEquivalent(member.getContainingClass(), psiClass);
+    return qualifier.getManager().areElementsEquivalent(member.getContainingClass(), psiClass);
   }
 
   private static enum NotQualifiedKind {
index 767dc1ddb53f61c1f3c3b6813ea947381fe8a668..d9c0a9bb56001b6ae6be9785ef99807729f444da 100644 (file)
@@ -108,7 +108,7 @@ public class GdkMethodDslProvider implements GdslMembersProvider {
       myStatic = isStatic;
       myScope = scope;
       final MultiMap<String, PsiMethod> byName = new MultiMap<String, PsiMethod>();
-      myPsiManager = PsiManager.getInstance(categoryClass.getProject());
+      myPsiManager = categoryClass.getManager();
       for (PsiMethod m : categoryClass.getMethods()) {
         final PsiParameter[] params = m.getParameterList().getParameters();
         if (params.length == 0) continue;
index 6a9e1fb90e7d3f15699a0358522f795d19c8e97e..142c90bb9cd0401eb496d63ea4c118ad01cffa74 100644 (file)
@@ -134,7 +134,7 @@ class GrChangeSignatureConflictSearcher {
       GrMethod prototype;
       final PsiMethod method = myChangeInfo.getMethod();
       if (!(method instanceof GrMethod)) return;
-      PsiManager manager = PsiManager.getInstance(method.getProject());
+      PsiManager manager = method.getManager();
       GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(manager.getProject());
       final CanonicalTypes.Type returnType = myChangeInfo.getNewReturnType();
       String newMethodName = myChangeInfo.getNewName();
index eb72c96beb80e1468229a0e8d95dc53a7a2f67d4..427ad7cc66d968c807e7ad1d4c695335f6702b36 100644 (file)
@@ -41,7 +41,7 @@ public class MavenDependencySystemPathConverter extends ResolvingConverter<PsiFi
     if (s == null) return null;
     VirtualFile f = LocalFileSystem.getInstance().findFileByPath(s);
     if (f == null) return null;
-    return PsiManager.getInstance(context.getXmlElement().getProject()).findFile(f);
+    return context.getXmlElement().getManager().findFile(f);
   }
 
   public String toString(@Nullable PsiFile file, ConvertContext context) {
index 9f50e885873f403cff1575190d4412f1f2c09276..3420614dcae898a16faa3d450d0044bd274294d6 100644 (file)
@@ -55,7 +55,7 @@ public class MavenParentRelativePathConverter extends ResolvingConverter<PsiFile
     if (f.isDirectory()) f = f.findFileByRelativePath(MavenConstants.POM_XML);
     if (f == null) return null;
 
-    return PsiManager.getInstance(context.getXmlElement().getProject()).findFile(f);
+    return context.getXmlElement().getManager().findFile(f);
   }
 
   @Override
index 537b0dce5e2f1d9a0baa05dbd3ab2ae4a7fcf70d..5039707ad4190a123e92574e5413e27d3d9a3d85 100644 (file)
@@ -176,7 +176,7 @@ public class PsiDocumentNavigator extends DefaultNavigator {
         final VirtualFile virtualFile = VfsUtil.findRelativeFile(url, file.getVirtualFile());
         if (virtualFile != null) {
             LOG.debug("document() -> VirtualFile = " + virtualFile.getPath());
-            final PsiFile file = PsiManager.getInstance(this.file.getProject()).findFile(virtualFile);
+            final PsiFile file = this.file.getManager().findFile(virtualFile);
             if (file instanceof XmlFile) {
                 return ((XmlFile)file).getDocument();
             }
index 0fae94e6cf32f191d394f035dab82f66baf8bbbc..34dad92dfc532d70d084e5a48d618fcc9aa3c6af 100644 (file)
@@ -70,7 +70,7 @@ public class XmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
     super(file.getProject(), editor.getDocument(), true);
     myFile = file;
     myEditor = editor;
-    final FileViewProvider viewProvider = PsiManager.getInstance(file.getProject()).findViewProvider(file.getVirtualFile());
+    final FileViewProvider viewProvider = file.getManager().findViewProvider(file.getVirtualFile());
     myInfoProvider = BreadcrumbsXmlWrapper.findInfoProvider(viewProvider);
   }
 
index e9bd6a354e1ef435538628da23d84a9ee1bffe46..bc17a9db2287b001f708c2bfb0470e2f9b926a98 100644 (file)
@@ -21,7 +21,7 @@ public class RncFileReferenceManipulator extends AbstractElementManipulator<RncF
     final ASTNode literal = node.findChildByType(RncTokenTypes.LITERAL);
     if (literal != null) {
       assert range.equals(element.getReferenceRange());
-      final PsiManager manager = PsiManager.getInstance(element.getProject());
+      final PsiManager manager = element.getManager();
       final ASTNode newChild = RenameUtil.createLiteralNode(manager, newContent);
       literal.getTreeParent().replaceChild(literal, newChild);
     }