JetPackageDeclarationIndex removed (replaced by JetAllPackagesIndex)
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ import org.jetbrains.jet.plugin.JetLanguage;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class JetFileElementType extends IStubFileElementType<PsiJetFileStub> {
|
public class JetFileElementType extends IStubFileElementType<PsiJetFileStub> {
|
||||||
public static final int STUB_VERSION = 20;
|
public static final int STUB_VERSION = 21;
|
||||||
|
|
||||||
public JetFileElementType() {
|
public JetFileElementType() {
|
||||||
super("jet.FILE", JetLanguage.INSTANCE);
|
super("jet.FILE", JetLanguage.INSTANCE);
|
||||||
|
|||||||
@@ -201,7 +201,6 @@
|
|||||||
<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.JetAllPackagesIndex"/>
|
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetAllPackagesIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetClassByPackageIndex"/>
|
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetClassByPackageIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex"/>
|
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex"/>
|
||||||
|
|||||||
+12
-4
@@ -19,7 +19,9 @@ package org.jetbrains.jet.plugin.caches.resolve;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.openapi.components.ServiceManager;
|
import com.intellij.openapi.components.ServiceManager;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.util.Condition;
|
||||||
import com.intellij.psi.search.GlobalSearchScope;
|
import com.intellij.psi.search.GlobalSearchScope;
|
||||||
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import com.intellij.util.containers.MultiMap;
|
import com.intellij.util.containers.MultiMap;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.asJava.LightClassConstructionContext;
|
import org.jetbrains.jet.asJava.LightClassConstructionContext;
|
||||||
@@ -64,8 +66,14 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<JetFile> findFilesForPackage(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) {
|
public Collection<JetFile> findFilesForPackage(@NotNull final FqName fqName, @NotNull GlobalSearchScope searchScope) {
|
||||||
return JetPackageDeclarationIndex.getInstance().get(fqName.getFqName(), project, kotlinSources(searchScope));
|
Collection<JetFile> files = JetAllPackagesIndex.getInstance().get(fqName.getFqName(), project, kotlinSources(searchScope));
|
||||||
|
return ContainerUtil.filter(files, new Condition<JetFile>() {
|
||||||
|
@Override
|
||||||
|
public boolean value(JetFile file) {
|
||||||
|
return fqName.equals(JetPsiUtil.getFQName(file));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -106,11 +114,11 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public MultiMap<String, FqName> getAllPackageClasses(@NotNull final GlobalSearchScope scope) {
|
public MultiMap<String, FqName> getAllPackageClasses(@NotNull final GlobalSearchScope scope) {
|
||||||
Collection<String> packageFqNames = JetPackageDeclarationIndex.getInstance().getAllKeys(project);
|
Collection<String> packageFqNames = JetAllPackagesIndex.getInstance().getAllKeys(project);
|
||||||
|
|
||||||
MultiMap<String, FqName> result = new MultiMap<String, FqName>();
|
MultiMap<String, FqName> result = new MultiMap<String, FqName>();
|
||||||
for (String packageFqName : packageFqNames) {
|
for (String packageFqName : packageFqNames) {
|
||||||
Collection<JetFile> files = JetPackageDeclarationIndex.getInstance().get(packageFqName, project, kotlinSources(scope));
|
Collection<JetFile> files = findFilesForPackage(new FqName(packageFqName), scope);
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(new FqName(packageFqName));
|
FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(new FqName(packageFqName));
|
||||||
result.putValue(packageClassFqName.shortName().getName(), packageClassFqName);
|
result.putValue(packageClassFqName.shortName().getName(), packageClassFqName);
|
||||||
|
|||||||
@@ -1,55 +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.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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Explicitly declared packages, i.e. if a file declares
|
|
||||||
* package a.b.c
|
|
||||||
*
|
|
||||||
* Only "a.b.c" will be registered, not "a" nor "a.b"
|
|
||||||
*/
|
|
||||||
public class JetPackageDeclarationIndex extends StringStubIndexExtension<JetFile> {
|
|
||||||
private static final StubIndexKey<String, JetFile> KEY = KotlinIndexUtil.createIndexKey(JetPackageDeclarationIndex.class);
|
|
||||||
|
|
||||||
private static final JetPackageDeclarationIndex ourInstance = new JetPackageDeclarationIndex();
|
|
||||||
|
|
||||||
public static JetPackageDeclarationIndex getInstance() {
|
|
||||||
return ourInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JetPackageDeclarationIndex() {}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public StubIndexKey<String, JetFile> getKey() {
|
|
||||||
return KEY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<JetFile> get(final String fqName, final Project project, @NotNull final GlobalSearchScope scope) {
|
|
||||||
return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,8 +30,6 @@ public class StubIndexServiceImpl implements StubIndexService {
|
|||||||
String packageName = stub.getPackageName();
|
String packageName = stub.getPackageName();
|
||||||
FqName fqName = new FqName(packageName == null ? "" : packageName);
|
FqName fqName = new FqName(packageName == null ? "" : packageName);
|
||||||
|
|
||||||
sink.occurrence(JetPackageDeclarationIndex.getInstance().getKey(), fqName.getFqName());
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
sink.occurrence(JetAllPackagesIndex.getInstance().getKey(), fqName.getFqName());
|
sink.occurrence(JetAllPackagesIndex.getInstance().getKey(), fqName.getFqName());
|
||||||
if (fqName.isRoot()) {
|
if (fqName.isRoot()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user