use PsiShortNamesCache as independent service

This commit is contained in:
Dmitry Jemerov
2011-09-22 19:31:25 +02:00
parent db3ba747b7
commit 44663f0c05
25 changed files with 69 additions and 109 deletions
@@ -23,7 +23,6 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NotNullLazyKey;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -112,24 +111,6 @@ public abstract class JavaPsiFacade {
@NotNull
public abstract PsiResolveHelper getResolveHelper();
/**
* Returns the short name cache for the project, which can be used to locate files, classes,
* methods and fields by non-qualified names.
*
* @return the short name cache instance.
*/
@NotNull
public abstract PsiShortNamesCache getShortNamesCache();
/**
* Registers a custom short name cache implementation for the project, which is used
* in addition to the standard IDEA implementation. Should not be used by most plugins.
*
* @param cache the short name cache instance.
* @deprecated register cache via extension
*/
public abstract void registerShortNamesCache(@NotNull PsiShortNamesCache cache);
/**
* Initiates a migrate refactoring. The refactoring is finished when
* {@link com.intellij.psi.PsiMigration#finish()} is called.
@@ -15,7 +15,9 @@
*/
package com.intellij.psi.search;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.HashSet;
@@ -29,13 +31,18 @@ import org.jetbrains.annotations.NotNull;
* @see JavaPsiFacade#getShortNamesCache()
*/
public abstract class PsiShortNamesCache {
public static final ExtensionPointName<PsiShortNamesCache> EP_NAME = ExtensionPointName.create("com.intellij.java.shortNamesCache");
/**
* Initializes the cache. To be used by custom PsiShortNameCache implementations
* Return the composite short names cache, uniting all short name cache instances registered via extensions.
*
* @param project the project to return the cache for.
* @return the cache instance.
*/
public void runStartupActivity() {
public static PsiShortNamesCache getInstance(Project project) {
return ServiceManager.getService(project, PsiShortNamesCache.class);
}
public static final ExtensionPointName<PsiShortNamesCache> EP_NAME = ExtensionPointName.create("com.intellij.java.shortNamesCache");
/**
* Returns the list of files with the specified name.