Refactor: rename short name indices

This commit is contained in:
Pavel V. Talanov
2013-08-07 21:27:28 +04:00
parent 1859ce6124
commit 22b714cef8
12 changed files with 63 additions and 63 deletions
+6 -6
View File
@@ -330,17 +330,17 @@
<stubElementTypeHolder class="org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetAllPackagesIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetClassByPackageIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetClassShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetFullClassNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortFunctionNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortPropertiesNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetExtensionFunctionNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetAllShortFunctionNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelNonExtensionFunctionShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetPropertyShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelExtensionFunctionShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetFunctionShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetSuperClassIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelFunctionsFqnNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelPropertiesFqnNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetAnnotationsIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelShortObjectNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelObjectShortNameIndex"/>
<psi.classFileDecompiler implementation="org.jetbrains.jet.plugin.libraries.JetClassFileDecompiler"/>
<psi.classFileDecompiler implementation="org.jetbrains.jet.plugin.libraries.JetDecompilerForWrongAbiVersion"/>
@@ -24,7 +24,7 @@ import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex;
import org.jetbrains.jet.plugin.stubindex.JetClassShortNameIndex;
import java.util.ArrayList;
import java.util.Collection;
@@ -52,14 +52,14 @@ public class JetGotoClassContributor implements GotoClassContributor {
@NotNull
@Override
public String[] getNames(Project project, boolean includeNonProjectItems) {
return ArrayUtil.toObjectArray(JetShortClassNameIndex.getInstance().getAllKeys(project), String.class);
return ArrayUtil.toObjectArray(JetClassShortNameIndex.getInstance().getAllKeys(project), String.class);
}
@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
Collection<JetClassOrObject> classesOrObjects = JetShortClassNameIndex.getInstance().get(name, project, scope);
Collection<JetClassOrObject> classesOrObjects = JetClassShortNameIndex.getInstance().get(name, project, scope);
if (classesOrObjects.isEmpty()) {
return NavigationItem.EMPTY_NAVIGATION_ITEM_ARRAY;
@@ -25,8 +25,8 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StubIndex;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.plugin.stubindex.JetAllShortFunctionNameIndex;
import org.jetbrains.jet.plugin.stubindex.JetShortPropertiesNameIndex;
import org.jetbrains.jet.plugin.stubindex.JetFunctionShortNameIndex;
import org.jetbrains.jet.plugin.stubindex.JetPropertyShortNameIndex;
import java.util.ArrayList;
import java.util.Collection;
@@ -36,8 +36,8 @@ public class JetGotoSymbolContributor implements ChooseByNameContributor {
@NotNull
@Override
public String[] getNames(Project project, boolean includeNonProjectItems) {
Collection<String> items = StubIndex.getInstance().getAllKeys(JetAllShortFunctionNameIndex.getInstance().getKey(), project);
items.addAll(StubIndex.getInstance().getAllKeys(JetShortPropertiesNameIndex.getInstance().getKey(), project));
Collection<String> items = StubIndex.getInstance().getAllKeys(JetFunctionShortNameIndex.getInstance().getKey(), project);
items.addAll(StubIndex.getInstance().getAllKeys(JetPropertyShortNameIndex.getInstance().getKey(), project));
return ArrayUtil.toStringArray(items);
}
@@ -48,10 +48,10 @@ public class JetGotoSymbolContributor implements ChooseByNameContributor {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
Collection<? extends NavigationItem> functions = StubIndex.getInstance().get(
JetAllShortFunctionNameIndex.getInstance().getKey(), name, project, scope);
JetFunctionShortNameIndex.getInstance().getKey(), name, project, scope);
Collection<? extends NavigationItem> properties = StubIndex.getInstance().get(
JetShortPropertiesNameIndex.getInstance().getKey(), name, project, scope);
JetPropertyShortNameIndex.getInstance().getKey(), name, project, scope);
List<NavigationItem> items = new ArrayList<NavigationItem>(Collections2.filter(functions, Predicates.notNull()));
items.addAll(properties);
@@ -85,7 +85,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
@NotNull
@Override
public String[] getAllClassNames() {
Collection<String> classNames = JetShortClassNameIndex.getInstance().getAllKeys(project);
Collection<String> classNames = JetClassShortNameIndex.getInstance().getAllKeys(project);
// package classes can not be indexed, since they have no explicit declarations
IDELightClassGenerationSupport lightClassGenerationSupport = IDELightClassGenerationSupport.getInstanceForIDE(project);
@@ -119,7 +119,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
}
// Quick check for classes from getAllClassNames()
Collection<JetClassOrObject> classOrObjects = JetShortClassNameIndex.getInstance().get(name, project, scope);
Collection<JetClassOrObject> classOrObjects = JetClassShortNameIndex.getInstance().get(name, project, scope);
if (classOrObjects.isEmpty()) {
return result.toArray(new PsiClass[result.size()]);
}
@@ -154,7 +154,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
@NotNull
public Collection<String> getAllTopLevelFunctionNames() {
Set<String> functionNames = new HashSet<String>();
functionNames.addAll(JetShortFunctionNameIndex.getInstance().getAllKeys(project));
functionNames.addAll(JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().getAllKeys(project));
functionNames.addAll(JetFromJavaDescriptorHelper.getPossiblePackageDeclarationsNames(project, GlobalSearchScope.allScope(project)));
return functionNames;
}
@@ -162,7 +162,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
@NotNull
public Collection<String> getAllTopLevelObjectNames() {
Set<String> topObjectNames = new HashSet<String>();
topObjectNames.addAll(JetTopLevelShortObjectNameIndex.getInstance().getAllKeys(project));
topObjectNames.addAll(JetTopLevelObjectShortNameIndex.getInstance().getAllKeys(project));
Collection<PsiClass> classObjects =
JetFromJavaDescriptorHelper.getCompiledClassesForTopLevelObjects(project, GlobalSearchScope.allScope(project));
@@ -193,7 +193,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
Set<ClassDescriptor> result = Sets.newHashSet();
Collection<JetObjectDeclaration> topObjects = JetTopLevelShortObjectNameIndex.getInstance().get(name, project, scope);
Collection<JetObjectDeclaration> topObjects = JetTopLevelObjectShortNameIndex.getInstance().get(name, project, scope);
for (JetObjectDeclaration objectDeclaration : topObjects) {
FqName fqName = JetPsiUtil.getFQName(objectDeclaration);
assert fqName != null : "Local object declaration in JetTopLevelShortObjectNameIndex:" + objectDeclaration.getText();
@@ -254,7 +254,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
Set<FqName> affectedPackages = Sets.newHashSet();
Collection<JetNamedFunction> jetNamedFunctions =
JetShortFunctionNameIndex.getInstance().get(referenceName.asString(), project, scope);
JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().get(referenceName.asString(), project, scope);
for (JetNamedFunction jetNamedFunction : jetNamedFunctions) {
PsiFile containingFile = jetNamedFunction.getContainingFile();
if (containingFile instanceof JetFile) {
@@ -278,7 +278,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
private Collection<PsiElement> getJetExtensionFunctionsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
HashSet<PsiElement> functions = new HashSet<PsiElement>();
functions.addAll(JetExtensionFunctionNameIndex.getInstance().get(name, project, scope));
functions.addAll(JetTopLevelExtensionFunctionShortNameIndex.getInstance().get(name, project, scope));
return functions;
}
@@ -329,7 +329,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
@NotNull Condition<String> acceptedNameCondition,
@NotNull GlobalSearchScope searchScope
) {
Set<String> extensionFunctionNames = new HashSet<String>(JetExtensionFunctionNameIndex.getInstance().getAllKeys(project));
Set<String> extensionFunctionNames = new HashSet<String>(JetTopLevelExtensionFunctionShortNameIndex.getInstance().getAllKeys(project));
Set<FqName> functionFQNs = new java.util.HashSet<FqName>();
@@ -421,7 +421,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
@Override
public void getAllMethodNames(@NotNull HashSet<String> set) {
set.addAll(JetShortFunctionNameIndex.getInstance().getAllKeys(project));
set.addAll(JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().getAllKeys(project));
}
@NotNull
@@ -38,7 +38,7 @@ import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.plugin.JetPluginUtil;
import org.jetbrains.jet.plugin.caches.resolve.KotlinCacheManagerUtil;
import org.jetbrains.jet.plugin.libraries.JetSourceNavigationHelper;
import org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex;
import org.jetbrains.jet.plugin.stubindex.JetClassShortNameIndex;
import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.util.Collection;
@@ -78,7 +78,7 @@ public class KotlinTypeHierarchyProvider extends JavaTypeHierarchyProvider {
String returnTypeText = DescriptorRenderer.TEXT.renderType(type);
if (returnTypeText.equals(functionName)) {
Collection<JetClassOrObject> classOrObjects =
JetShortClassNameIndex.getInstance().get(functionName, project, GlobalSearchScope.allScope(project));
JetClassShortNameIndex.getInstance().get(functionName, project, GlobalSearchScope.allScope(project));
if (classOrObjects.size() == 1) {
JetClassOrObject classOrObject = classOrObjects.iterator().next();
return JetSourceNavigationHelper.getOriginalPsiClassOrCreateLightClass(classOrObject);
@@ -25,16 +25,16 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject;
import java.util.Collection;
public class JetShortClassNameIndex extends StringStubIndexExtension<JetClassOrObject> {
private static final StubIndexKey<String, JetClassOrObject> KEY = KotlinIndexUtil.createIndexKey(JetShortClassNameIndex.class);
public class JetClassShortNameIndex extends StringStubIndexExtension<JetClassOrObject> {
private static final StubIndexKey<String, JetClassOrObject> KEY = KotlinIndexUtil.createIndexKey(JetClassShortNameIndex.class);
private static final JetShortClassNameIndex ourInstance = new JetShortClassNameIndex();
private static final JetClassShortNameIndex ourInstance = new JetClassShortNameIndex();
public static JetShortClassNameIndex getInstance() {
public static JetClassShortNameIndex getInstance() {
return ourInstance;
}
private JetShortClassNameIndex() {}
private JetClassShortNameIndex() {}
@NotNull
@Override
@@ -25,16 +25,16 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction;
import java.util.Collection;
public class JetShortFunctionNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetShortFunctionNameIndex.class);
public class JetFunctionShortNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetFunctionShortNameIndex.class);
private static final JetShortFunctionNameIndex ourInstance = new JetShortFunctionNameIndex();
private static final JetFunctionShortNameIndex ourInstance = new JetFunctionShortNameIndex();
public static JetShortFunctionNameIndex getInstance() {
public static JetFunctionShortNameIndex getInstance() {
return ourInstance;
}
private JetShortFunctionNameIndex() {}
private JetFunctionShortNameIndex() {}
@NotNull
@Override
@@ -25,16 +25,16 @@ import org.jetbrains.jet.lang.psi.JetProperty;
import java.util.Collection;
public class JetShortPropertiesNameIndex extends StringStubIndexExtension<JetProperty> {
private static final StubIndexKey<String, JetProperty> KEY = KotlinIndexUtil.createIndexKey(JetShortPropertiesNameIndex.class);
public class JetPropertyShortNameIndex extends StringStubIndexExtension<JetProperty> {
private static final StubIndexKey<String, JetProperty> KEY = KotlinIndexUtil.createIndexKey(JetPropertyShortNameIndex.class);
private static final JetShortPropertiesNameIndex ourInstance = new JetShortPropertiesNameIndex();
private static final JetPropertyShortNameIndex ourInstance = new JetPropertyShortNameIndex();
public static JetShortPropertiesNameIndex getInstance() {
public static JetPropertyShortNameIndex getInstance() {
return ourInstance;
}
private JetShortPropertiesNameIndex() {}
private JetPropertyShortNameIndex() {}
@NotNull
@Override
@@ -21,16 +21,16 @@ import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
public class JetExtensionFunctionNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetExtensionFunctionNameIndex.class);
public class JetTopLevelExtensionFunctionShortNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetTopLevelExtensionFunctionShortNameIndex.class);
private static final JetExtensionFunctionNameIndex instance = new JetExtensionFunctionNameIndex();
private static final JetTopLevelExtensionFunctionShortNameIndex instance = new JetTopLevelExtensionFunctionShortNameIndex();
public static JetExtensionFunctionNameIndex getInstance() {
public static JetTopLevelExtensionFunctionShortNameIndex getInstance() {
return instance;
}
private JetExtensionFunctionNameIndex() {}
private JetTopLevelExtensionFunctionShortNameIndex() {}
@NotNull
@Override
@@ -25,16 +25,16 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction;
import java.util.Collection;
public class JetAllShortFunctionNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetAllShortFunctionNameIndex.class);
public class JetTopLevelNonExtensionFunctionShortNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetTopLevelNonExtensionFunctionShortNameIndex.class);
private static final JetAllShortFunctionNameIndex ourInstance = new JetAllShortFunctionNameIndex();
private static final JetTopLevelNonExtensionFunctionShortNameIndex ourInstance = new JetTopLevelNonExtensionFunctionShortNameIndex();
public static JetAllShortFunctionNameIndex getInstance() {
public static JetTopLevelNonExtensionFunctionShortNameIndex getInstance() {
return ourInstance;
}
private JetAllShortFunctionNameIndex() {}
private JetTopLevelNonExtensionFunctionShortNameIndex() {}
@NotNull
@Override
@@ -25,16 +25,16 @@ import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
import java.util.Collection;
public class JetTopLevelShortObjectNameIndex extends StringStubIndexExtension<JetObjectDeclaration> {
private static final StubIndexKey<String, JetObjectDeclaration> KEY = KotlinIndexUtil.createIndexKey(JetTopLevelShortObjectNameIndex.class);
public class JetTopLevelObjectShortNameIndex extends StringStubIndexExtension<JetObjectDeclaration> {
private static final StubIndexKey<String, JetObjectDeclaration> KEY = KotlinIndexUtil.createIndexKey(JetTopLevelObjectShortNameIndex.class);
private static final JetTopLevelShortObjectNameIndex ourInstance = new JetTopLevelShortObjectNameIndex();
private static final JetTopLevelObjectShortNameIndex ourInstance = new JetTopLevelObjectShortNameIndex();
public static JetTopLevelShortObjectNameIndex getInstance() {
public static JetTopLevelObjectShortNameIndex getInstance() {
return ourInstance;
}
private JetTopLevelShortObjectNameIndex() {}
private JetTopLevelObjectShortNameIndex() {}
@NotNull
@Override
@@ -45,7 +45,7 @@ public class StubIndexServiceImpl implements StubIndexService {
public void indexClass(PsiJetClassStub stub, IndexSink sink) {
String name = stub.getName();
if (name != null) {
sink.occurrence(JetShortClassNameIndex.getInstance().getKey(), name);
sink.occurrence(JetClassShortNameIndex.getInstance().getKey(), name);
}
FqName fqn = stub.getFqName();
@@ -75,10 +75,10 @@ public class StubIndexServiceImpl implements StubIndexService {
}
if (name != null) {
sink.occurrence(JetShortClassNameIndex.getInstance().getKey(), name);
sink.occurrence(JetClassShortNameIndex.getInstance().getKey(), name);
if (stub.isTopLevel()) {
sink.occurrence(JetTopLevelShortObjectNameIndex.getInstance().getKey(), name);
sink.occurrence(JetTopLevelObjectShortNameIndex.getInstance().getKey(), name);
}
}
@@ -114,10 +114,10 @@ public class StubIndexServiceImpl implements StubIndexService {
if (stub.isTopLevel()) {
// Collection only top level functions as only they are expected in completion without explicit import
if (!stub.isExtension()) {
sink.occurrence(JetShortFunctionNameIndex.getInstance().getKey(), name);
sink.occurrence(JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().getKey(), name);
}
else {
sink.occurrence(JetExtensionFunctionNameIndex.getInstance().getKey(), name);
sink.occurrence(JetTopLevelExtensionFunctionShortNameIndex.getInstance().getKey(), name);
}
FqName topFQName = stub.getTopFQName();
@@ -126,7 +126,7 @@ public class StubIndexServiceImpl implements StubIndexService {
}
}
sink.occurrence(JetAllShortFunctionNameIndex.getInstance().getKey(), name);
sink.occurrence(JetFunctionShortNameIndex.getInstance().getKey(), name);
}
}
@@ -141,7 +141,7 @@ public class StubIndexServiceImpl implements StubIndexService {
}
}
sink.occurrence(JetShortPropertiesNameIndex.getInstance().getKey(), propertyName);
sink.occurrence(JetPropertyShortNameIndex.getInstance().getKey(), propertyName);
}
}