Index package FqNames for files
This commit is contained in:
+1
-1
@@ -82,6 +82,6 @@ public class JetFileElementType extends IStubFileElementType<PsiJetFileStub> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void indexStub(final PsiJetFileStub stub, final IndexSink sink) {
|
public void indexStub(final PsiJetFileStub stub, final IndexSink sink) {
|
||||||
// Don't index file
|
StubIndexServiceFactory.getInstance().indexFile(stub, sink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ public interface StubIndexService {
|
|||||||
* Default implementation with no indexing.
|
* Default implementation with no indexing.
|
||||||
*/
|
*/
|
||||||
StubIndexService NO_INDEX_SERVICE = new StubIndexService() {
|
StubIndexService NO_INDEX_SERVICE = new StubIndexService() {
|
||||||
|
@Override
|
||||||
|
public void indexFile(PsiJetFileStub stub, IndexSink sink) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void indexClass(PsiJetClassStub stub, IndexSink sink) {
|
public void indexClass(PsiJetClassStub stub, IndexSink sink) {
|
||||||
}
|
}
|
||||||
@@ -46,6 +50,7 @@ public interface StubIndexService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void indexFile(PsiJetFileStub stub, IndexSink sink);
|
||||||
void indexClass(PsiJetClassStub stub, IndexSink sink);
|
void indexClass(PsiJetClassStub stub, IndexSink sink);
|
||||||
void indexFunction(PsiJetFunctionStub stub, IndexSink sink);
|
void indexFunction(PsiJetFunctionStub stub, IndexSink sink);
|
||||||
void indexObject(PsiJetObjectStub stub, IndexSink sink);
|
void indexObject(PsiJetObjectStub stub, IndexSink sink);
|
||||||
|
|||||||
@@ -203,6 +203,7 @@
|
|||||||
<java.shortNamesCache implementation="org.jetbrains.jet.plugin.caches.JetShortNamesCache"/>
|
<java.shortNamesCache implementation="org.jetbrains.jet.plugin.caches.JetShortNamesCache"/>
|
||||||
|
|
||||||
<stubElementTypeHolder class="org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes"/>
|
<stubElementTypeHolder class="org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes"/>
|
||||||
|
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetPackageDeclarationIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex"/>
|
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetFullClassNameIndex"/>
|
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetFullClassNameIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortFunctionNameIndex"/>
|
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortFunctionNameIndex"/>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import com.intellij.psi.stubs.StubIndexKey;
|
|||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
|
||||||
public interface JetIndexKeys {
|
public interface JetIndexKeys {
|
||||||
|
StubIndexKey<String, JetFile> PACKAGE_DECLARATION_KEY = StubIndexKey.createIndexKey("jet.file.package.declaration");
|
||||||
|
|
||||||
StubIndexKey<String, JetClassOrObject> SHORT_NAME_KEY = StubIndexKey.createIndexKey("jet.class.shortName");
|
StubIndexKey<String, JetClassOrObject> SHORT_NAME_KEY = StubIndexKey.createIndexKey("jet.class.shortName");
|
||||||
StubIndexKey<String, JetClassOrObject> SUPERCLASS_NAME_KEY = StubIndexKey.createIndexKey("jet.class.superClassName");
|
StubIndexKey<String, JetClassOrObject> SUPERCLASS_NAME_KEY = StubIndexKey.createIndexKey("jet.class.superClassName");
|
||||||
StubIndexKey<String, JetClassOrObject> FQN_KEY = StubIndexKey.createIndexKey("jet.fqn");
|
StubIndexKey<String, JetClassOrObject> FQN_KEY = StubIndexKey.createIndexKey("jet.fqn");
|
||||||
|
|||||||
@@ -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.JetFile;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class JetPackageDeclarationIndex extends StringStubIndexExtension<JetFile> {
|
||||||
|
private static final JetPackageDeclarationIndex ourInstance = new JetPackageDeclarationIndex();
|
||||||
|
|
||||||
|
public static JetPackageDeclarationIndex getInstance() {
|
||||||
|
return ourInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public StubIndexKey<String, JetFile> getKey() {
|
||||||
|
return JetIndexKeys.PACKAGE_DECLARATION_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<JetFile> get(final String fqName, final Project project, @NotNull final GlobalSearchScope scope) {
|
||||||
|
return super.get(fqName, project, new JetSourceFilterScope(scope));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,12 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
|
|||||||
|
|
||||||
public class StubIndexServiceImpl implements StubIndexService {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void indexClass(PsiJetClassStub stub, IndexSink sink) {
|
public void indexClass(PsiJetClassStub stub, IndexSink sink) {
|
||||||
String name = stub.getName();
|
String name = stub.getName();
|
||||||
|
|||||||
Reference in New Issue
Block a user