From 4a6fd1676b375562653df9843709829e41a19184 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 18 Dec 2012 18:26:25 +0400 Subject: [PATCH] Index classes refactored: keys are properly references, ensuring that a keys doesn't get confused across classes --- .../stubs/elements/JetFileElementType.java | 2 +- .../caches/JetGotoSymbolContributor.java | 11 ++-- .../JetAllShortFunctionNameIndex.java | 4 +- .../plugin/stubindex/JetAnnotationsIndex.java | 4 +- .../JetExtensionFunctionNameIndex.java | 4 +- .../stubindex/JetFullClassNameIndex.java | 4 +- .../jet/plugin/stubindex/JetIndexKeys.java | 50 ------------------- .../stubindex/JetPackageDeclarationIndex.java | 4 +- .../stubindex/JetShortClassNameIndex.java | 4 +- .../stubindex/JetShortFunctionNameIndex.java | 4 +- .../JetShortPropertiesNameIndex.java | 4 +- .../plugin/stubindex/JetSuperClassIndex.java | 5 +- .../JetTopLevelFunctionsFqnNameIndex.java | 7 ++- .../JetTopLevelPropertiesFqnNameIndex.java | 4 +- .../JetTopLevelShortObjectNameIndex.java | 4 +- .../jet/plugin/stubindex/KotlinIndexUtil.java | 32 ++++++++++++ .../stubindex/StubIndexServiceImpl.java | 28 +++++------ 17 files changed, 93 insertions(+), 82 deletions(-) delete mode 100644 idea/src/org/jetbrains/jet/plugin/stubindex/JetIndexKeys.java create mode 100644 idea/src/org/jetbrains/jet/plugin/stubindex/KotlinIndexUtil.java diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java index 1ea0a916d18..5615f20cc63 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java @@ -35,7 +35,7 @@ import org.jetbrains.jet.plugin.JetLanguage; import java.io.IOException; public class JetFileElementType extends IStubFileElementType { - public static final int STUB_VERSION = 18; + public static final int STUB_VERSION = 19; public JetFileElementType() { super("jet.FILE", JetLanguage.INSTANCE); diff --git a/idea/src/org/jetbrains/jet/plugin/caches/JetGotoSymbolContributor.java b/idea/src/org/jetbrains/jet/plugin/caches/JetGotoSymbolContributor.java index c43ad4c0a50..78460bdde6f 100644 --- a/idea/src/org/jetbrains/jet/plugin/caches/JetGotoSymbolContributor.java +++ b/idea/src/org/jetbrains/jet/plugin/caches/JetGotoSymbolContributor.java @@ -25,7 +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.JetIndexKeys; +import org.jetbrains.jet.plugin.stubindex.JetAllShortFunctionNameIndex; +import org.jetbrains.jet.plugin.stubindex.JetShortPropertiesNameIndex; import java.util.ArrayList; import java.util.Collection; @@ -35,8 +36,8 @@ public class JetGotoSymbolContributor implements ChooseByNameContributor { @NotNull @Override public String[] getNames(Project project, boolean includeNonProjectItems) { - Collection items = StubIndex.getInstance().getAllKeys(JetIndexKeys.FUNCTIONS_SHORT_NAME_KEY, project); - items.addAll(StubIndex.getInstance().getAllKeys(JetIndexKeys.PROPERTIES_SHORT_NAME_KEY, project)); + Collection items = StubIndex.getInstance().getAllKeys(JetAllShortFunctionNameIndex.getInstance().getKey(), project); + items.addAll(StubIndex.getInstance().getAllKeys(JetShortPropertiesNameIndex.getInstance().getKey(), project)); return ArrayUtil.toStringArray(items); } @@ -47,10 +48,10 @@ public class JetGotoSymbolContributor implements ChooseByNameContributor { GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); Collection functions = StubIndex.getInstance().get( - JetIndexKeys.FUNCTIONS_SHORT_NAME_KEY, name, project, scope); + JetAllShortFunctionNameIndex.getInstance().getKey(), name, project, scope); Collection properties = StubIndex.getInstance().get( - JetIndexKeys.PROPERTIES_SHORT_NAME_KEY, name, project, scope); + JetShortPropertiesNameIndex.getInstance().getKey(), name, project, scope); final List items = new ArrayList(Collections2.filter(functions, Predicates.notNull())); items.addAll(properties); diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllShortFunctionNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllShortFunctionNameIndex.java index 56fa299f7c6..ebb21749584 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllShortFunctionNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllShortFunctionNameIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction; import java.util.Collection; public class JetAllShortFunctionNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetAllShortFunctionNameIndex.class); + private static final JetShortClassNameIndex ourInstance = new JetShortClassNameIndex(); public static JetShortClassNameIndex getInstance() { @@ -35,7 +37,7 @@ public class JetAllShortFunctionNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.FUNCTIONS_SHORT_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java index c4f0b168312..6cb18b78fbe 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetAnnotationEntry; import java.util.Collection; public class JetAnnotationsIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetAnnotationsIndex.class); + private static final JetAnnotationsIndex ourInstance = new JetAnnotationsIndex(); public static JetAnnotationsIndex getInstance() { @@ -35,7 +37,7 @@ public class JetAnnotationsIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.ANNOTATIONS_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetExtensionFunctionNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetExtensionFunctionNameIndex.java index 3a7efed0da6..082df10c2f6 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetExtensionFunctionNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetExtensionFunctionNameIndex.java @@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.JetNamedFunction; public class JetExtensionFunctionNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetExtensionFunctionNameIndex.class); + private static final JetExtensionFunctionNameIndex instance = new JetExtensionFunctionNameIndex(); public static JetExtensionFunctionNameIndex getInstance() { @@ -31,6 +33,6 @@ public class JetExtensionFunctionNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.TOP_LEVEL_EXTENSION_FUNCTION_SHORT_NAME_KEY; + return KEY; } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java index 93b1f929a03..770c20920f1 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject; import java.util.Collection; public class JetFullClassNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetFullClassNameIndex.class); + private static final JetFullClassNameIndex ourInstance = new JetFullClassNameIndex(); public static JetFullClassNameIndex getInstance() { @@ -35,7 +37,7 @@ public class JetFullClassNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.CLASS_OR_OBJECT_FQN_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetIndexKeys.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetIndexKeys.java deleted file mode 100644 index bf36e529108..00000000000 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetIndexKeys.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2010-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 org.jetbrains.jet.plugin.stubindex; - -import com.intellij.psi.stubs.StubIndexKey; -import org.jetbrains.jet.lang.psi.*; - -public interface JetIndexKeys { - StubIndexKey PACKAGE_DECLARATION_KEY = StubIndexKey.createIndexKey("jet.file.package.declaration"); - - StubIndexKey SHORT_NAME_KEY = StubIndexKey.createIndexKey("jet.class.shortName"); - StubIndexKey SUPERCLASS_NAME_KEY = StubIndexKey.createIndexKey("jet.class.superClassName"); - StubIndexKey CLASS_OR_OBJECT_FQN_KEY = StubIndexKey.createIndexKey("jet.fqn"); - - StubIndexKey TOP_LEVEL_OBJECT_SHORT_NAME_KEY = - StubIndexKey.createIndexKey("jet.top.level.object.short.name"); - - StubIndexKey TOP_LEVEL_FUNCTION_SHORT_NAME_KEY = - StubIndexKey.createIndexKey("jet.top.level.function.short.name"); - - StubIndexKey TOP_LEVEL_EXTENSION_FUNCTION_SHORT_NAME_KEY = - StubIndexKey.createIndexKey("jet.top.level.extension.function.short.name"); - - /** Stores package top level function (both extension and non-extension) full qualified names. */ - StubIndexKey TOP_LEVEL_FUNCTIONS_FQN_NAME_KEY = - StubIndexKey.createIndexKey("jet.top.level.functions.fqn.name"); - - StubIndexKey TOP_LEVEL_PROPERTY_FQN_NAME_KEY = - StubIndexKey.createIndexKey("jet.top.level.property.fqn.name"); - - StubIndexKey FUNCTIONS_SHORT_NAME_KEY = StubIndexKey.createIndexKey("jet.functions.short.name"); - StubIndexKey PROPERTIES_SHORT_NAME_KEY = StubIndexKey.createIndexKey("jet.properties.short.name"); - - StubIndexKey ANNOTATIONS_KEY = StubIndexKey.createIndexKey("jet.annotations"); -} - diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetPackageDeclarationIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetPackageDeclarationIndex.java index 2175e9d3b87..d219fcba0b6 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetPackageDeclarationIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetPackageDeclarationIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetFile; import java.util.Collection; public class JetPackageDeclarationIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetPackageDeclarationIndex.class); + private static final JetPackageDeclarationIndex ourInstance = new JetPackageDeclarationIndex(); public static JetPackageDeclarationIndex getInstance() { @@ -35,7 +37,7 @@ public class JetPackageDeclarationIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.PACKAGE_DECLARATION_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortClassNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortClassNameIndex.java index 25a9e0ace65..6af4928459f 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortClassNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortClassNameIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject; import java.util.Collection; public class JetShortClassNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetShortClassNameIndex.class); + private static final JetShortClassNameIndex ourInstance = new JetShortClassNameIndex(); public static JetShortClassNameIndex getInstance() { @@ -35,7 +37,7 @@ public class JetShortClassNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.SHORT_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortFunctionNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortFunctionNameIndex.java index 8c217c9e7e6..da87ef68754 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortFunctionNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortFunctionNameIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction; import java.util.Collection; public class JetShortFunctionNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetShortFunctionNameIndex.class); + private static final JetShortFunctionNameIndex ourInstance = new JetShortFunctionNameIndex(); public static JetShortFunctionNameIndex getInstance() { @@ -35,7 +37,7 @@ public class JetShortFunctionNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.TOP_LEVEL_FUNCTION_SHORT_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortPropertiesNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortPropertiesNameIndex.java index 625a521b376..011e218e765 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortPropertiesNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetShortPropertiesNameIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetProperty; import java.util.Collection; public class JetShortPropertiesNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetShortPropertiesNameIndex.class); + private static final JetShortPropertiesNameIndex ourInstance = new JetShortPropertiesNameIndex(); public static JetShortPropertiesNameIndex getInstance() { @@ -35,7 +37,7 @@ public class JetShortPropertiesNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.PROPERTIES_SHORT_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java index 8d3e313d165..fc49f7d8a5d 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java @@ -26,7 +26,10 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject; import java.util.Collection; public class JetSuperClassIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetSuperClassIndex.class); + private static final JetSuperClassIndex ourInstance = new JetSuperClassIndex(); + public static JetSuperClassIndex getInstance() { return ourInstance; } @@ -34,7 +37,7 @@ public class JetSuperClassIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.SUPERCLASS_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java index 789a22db9b9..a7ee07d988c 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java @@ -25,7 +25,12 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction; import java.util.Collection; +/** + * Stores package top level function (both extension and non-extension) full qualified names. + */ public class JetTopLevelFunctionsFqnNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetTopLevelFunctionsFqnNameIndex.class); + private static final JetTopLevelFunctionsFqnNameIndex INSTANCE = new JetTopLevelFunctionsFqnNameIndex(); public static JetTopLevelFunctionsFqnNameIndex getInstance() { @@ -35,7 +40,7 @@ public class JetTopLevelFunctionsFqnNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.TOP_LEVEL_FUNCTIONS_FQN_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java index c5fea897e4f..f2fc5f04c89 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetProperty; import java.util.Collection; public class JetTopLevelPropertiesFqnNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetTopLevelPropertiesFqnNameIndex.class); + private static final JetTopLevelPropertiesFqnNameIndex INSTANCE = new JetTopLevelPropertiesFqnNameIndex(); public static JetTopLevelPropertiesFqnNameIndex getInstance() { @@ -35,7 +37,7 @@ public class JetTopLevelPropertiesFqnNameIndex extends StringStubIndexExtension< @NotNull @Override public StubIndexKey getKey() { - return JetIndexKeys.TOP_LEVEL_PROPERTY_FQN_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelShortObjectNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelShortObjectNameIndex.java index 91fb8f5a3d8..1760a5ced5b 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelShortObjectNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelShortObjectNameIndex.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.psi.JetObjectDeclaration; import java.util.Collection; public class JetTopLevelShortObjectNameIndex extends StringStubIndexExtension { + private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetTopLevelShortObjectNameIndex.class); + private static final JetTopLevelShortObjectNameIndex ourInstance = new JetTopLevelShortObjectNameIndex(); public static JetTopLevelShortObjectNameIndex getInstance() { @@ -35,7 +37,7 @@ public class JetTopLevelShortObjectNameIndex extends StringStubIndexExtension getKey() { - return JetIndexKeys.TOP_LEVEL_OBJECT_SHORT_NAME_KEY; + return KEY; } @Override diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/KotlinIndexUtil.java b/idea/src/org/jetbrains/jet/plugin/stubindex/KotlinIndexUtil.java new file mode 100644 index 00000000000..5f0f70a2ce6 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/KotlinIndexUtil.java @@ -0,0 +1,32 @@ +/* + * Copyright 2010-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 org.jetbrains.jet.plugin.stubindex; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.stubs.StubIndexExtension; +import com.intellij.psi.stubs.StubIndexKey; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +public class KotlinIndexUtil { + @NonNls + public static StubIndexKey createIndexKey(@NotNull Class> indexClass) { + return StubIndexKey.createIndexKey(indexClass.getCanonicalName()); + } + + private KotlinIndexUtil() {} +} diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java b/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java index 3739ea744c1..2f5022aff20 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java @@ -26,23 +26,23 @@ public class StubIndexServiceImpl implements StubIndexService { @Override public void indexFile(PsiJetFileStub stub, IndexSink sink) { String packageName = stub.getPackageName(); - sink.occurrence(JetIndexKeys.PACKAGE_DECLARATION_KEY, packageName == null ? "" : packageName); + sink.occurrence(JetPackageDeclarationIndex.getInstance().getKey(), packageName == null ? "" : packageName); } @Override public void indexClass(PsiJetClassStub stub, IndexSink sink) { String name = stub.getName(); if (name != null) { - sink.occurrence(JetIndexKeys.SHORT_NAME_KEY, name); + sink.occurrence(JetShortClassNameIndex.getInstance().getKey(), name); } String fqn = stub.getQualifiedName(); if (fqn != null) { - sink.occurrence(JetIndexKeys.CLASS_OR_OBJECT_FQN_KEY, fqn); + sink.occurrence(JetFullClassNameIndex.getInstance().getKey(), fqn); } for (String superName : stub.getSuperNames()) { - sink.occurrence(JetIndexKeys.SUPERCLASS_NAME_KEY, superName); + sink.occurrence(JetSuperClassIndex.getInstance().getKey(), superName); } } @@ -51,15 +51,15 @@ public class StubIndexServiceImpl implements StubIndexService { String name = stub.getName(); assert name != null; - sink.occurrence(JetIndexKeys.SHORT_NAME_KEY, name); + sink.occurrence(JetShortClassNameIndex.getInstance().getKey(), name); if (stub.isTopLevel()) { - sink.occurrence(JetIndexKeys.TOP_LEVEL_OBJECT_SHORT_NAME_KEY, name); + sink.occurrence(JetTopLevelShortObjectNameIndex.getInstance().getKey(), name); } FqName fqName = stub.getFQName(); if (fqName != null) { - sink.occurrence(JetIndexKeys.CLASS_OR_OBJECT_FQN_KEY, fqName.toString()); + sink.occurrence(JetFullClassNameIndex.getInstance().getKey(), fqName.toString()); } } @@ -70,19 +70,19 @@ 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(JetIndexKeys.TOP_LEVEL_FUNCTION_SHORT_NAME_KEY, name); + sink.occurrence(JetShortFunctionNameIndex.getInstance().getKey(), name); } else { - sink.occurrence(JetIndexKeys.TOP_LEVEL_EXTENSION_FUNCTION_SHORT_NAME_KEY, name); + sink.occurrence(JetExtensionFunctionNameIndex.getInstance().getKey(), name); } FqName topFQName = stub.getTopFQName(); if (topFQName != null) { - sink.occurrence(JetIndexKeys.TOP_LEVEL_FUNCTIONS_FQN_NAME_KEY, topFQName.toString()); + sink.occurrence(JetTopLevelFunctionsFqnNameIndex.getInstance().getKey(), topFQName.toString()); } } - sink.occurrence(JetIndexKeys.FUNCTIONS_SHORT_NAME_KEY, name); + sink.occurrence(JetAllShortFunctionNameIndex.getInstance().getKey(), name); } } @@ -93,16 +93,16 @@ public class StubIndexServiceImpl implements StubIndexService { if (stub.isTopLevel()) { FqName topFQName = stub.getTopFQName(); if (topFQName != null) { - sink.occurrence(JetIndexKeys.TOP_LEVEL_PROPERTY_FQN_NAME_KEY, topFQName.toString()); + sink.occurrence(JetTopLevelPropertiesFqnNameIndex.getInstance().getKey(), topFQName.toString()); } } - sink.occurrence(JetIndexKeys.PROPERTIES_SHORT_NAME_KEY, propertyName); + sink.occurrence(JetShortPropertiesNameIndex.getInstance().getKey(), propertyName); } } @Override public void indexAnnotation(PsiJetAnnotationStub stub, IndexSink sink) { - sink.occurrence(JetIndexKeys.ANNOTATIONS_KEY, stub.getShortName()); + sink.occurrence(JetAnnotationsIndex.getInstance().getKey(), stub.getShortName()); } }