Index for top level objects

This commit is contained in:
Nikolay Krasko
2012-11-08 20:58:03 +04:00
parent 5cf708d056
commit cb602496e3
10 changed files with 87 additions and 12 deletions
+1
View File
@@ -204,6 +204,7 @@
<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" />
<contentBasedClassFileProcessor implementation="org.jetbrains.jet.plugin.libraries.JetContentBasedFileSubstitutor" />
<psi.clsCustomNavigationPolicy implementation="org.jetbrains.jet.plugin.libraries.JetClsNavigationPolicy" />
@@ -17,10 +17,7 @@
package org.jetbrains.jet.plugin.stubindex;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.jet.lang.psi.JetAnnotationEntry;
import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
import org.jetbrains.jet.lang.psi.JetProperty;
import org.jetbrains.jet.lang.psi.*;
/**
* @author Nikolay Krasko
@@ -30,6 +27,9 @@ public interface JetIndexKeys {
StubIndexKey<String, JetClassOrObject> SUPERCLASS_NAME_KEY = StubIndexKey.createIndexKey("jet.class.superClassName");
StubIndexKey<String, JetClassOrObject> FQN_KEY = StubIndexKey.createIndexKey("jet.fqn");
StubIndexKey<String, JetObjectDeclaration> TOP_LEVEL_OBJECT_SHORT_NAME_KEY =
StubIndexKey.createIndexKey("jet.top.level.object.short.name");
StubIndexKey<String, JetNamedFunction> TOP_LEVEL_FUNCTION_SHORT_NAME_KEY =
StubIndexKey.createIndexKey("jet.top.level.function.short.name");
@@ -0,0 +1,45 @@
/*
* 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.openapi.project.Project;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
import java.util.Collection;
public class JetTopLevelShortObjectNameIndex extends StringStubIndexExtension<JetObjectDeclaration> {
private static final JetTopLevelShortObjectNameIndex ourInstance = new JetTopLevelShortObjectNameIndex();
public static JetTopLevelShortObjectNameIndex getInstance() {
return ourInstance;
}
@NotNull
@Override
public StubIndexKey<String, JetObjectDeclaration> getKey() {
return JetIndexKeys.TOP_LEVEL_OBJECT_SHORT_NAME_KEY;
}
@Override
public Collection<JetObjectDeclaration> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
return super.get(s, project, new JetSourceFilterScope(scope));
}
}
@@ -50,6 +50,10 @@ public class StubIndexServiceImpl implements StubIndexService {
sink.occurrence(JetIndexKeys.SHORT_NAME_KEY, name);
if (stub.isTopLevel()) {
sink.occurrence(JetIndexKeys.TOP_LEVEL_OBJECT_SHORT_NAME_KEY, name);
}
FqName fqName = stub.getFQName();
if (fqName != null) {
sink.occurrence(JetIndexKeys.FQN_KEY, fqName.toString());