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 91e0cf0aea3..a8316851860 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 = 20; + public static final int STUB_VERSION = 21; public JetFileElementType() { super("jet.FILE", JetLanguage.INSTANCE); diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index d14504c5ed0..af1b038ae84 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -201,7 +201,6 @@ - diff --git a/idea/src/org/jetbrains/jet/plugin/caches/resolve/IDELightClassGenerationSupport.java b/idea/src/org/jetbrains/jet/plugin/caches/resolve/IDELightClassGenerationSupport.java index 10361ca66e6..9d8e149f82f 100644 --- a/idea/src/org/jetbrains/jet/plugin/caches/resolve/IDELightClassGenerationSupport.java +++ b/idea/src/org/jetbrains/jet/plugin/caches/resolve/IDELightClassGenerationSupport.java @@ -19,7 +19,9 @@ package org.jetbrains.jet.plugin.caches.resolve; import com.google.common.collect.Sets; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Condition; import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.asJava.LightClassConstructionContext; @@ -64,8 +66,14 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport @NotNull @Override - public Collection findFilesForPackage(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) { - return JetPackageDeclarationIndex.getInstance().get(fqName.getFqName(), project, kotlinSources(searchScope)); + public Collection findFilesForPackage(@NotNull final FqName fqName, @NotNull GlobalSearchScope searchScope) { + Collection files = JetAllPackagesIndex.getInstance().get(fqName.getFqName(), project, kotlinSources(searchScope)); + return ContainerUtil.filter(files, new Condition() { + @Override + public boolean value(JetFile file) { + return fqName.equals(JetPsiUtil.getFQName(file)); + } + }); } @NotNull @@ -106,11 +114,11 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport @NotNull public MultiMap getAllPackageClasses(@NotNull final GlobalSearchScope scope) { - Collection packageFqNames = JetPackageDeclarationIndex.getInstance().getAllKeys(project); + Collection packageFqNames = JetAllPackagesIndex.getInstance().getAllKeys(project); MultiMap result = new MultiMap(); for (String packageFqName : packageFqNames) { - Collection files = JetPackageDeclarationIndex.getInstance().get(packageFqName, project, kotlinSources(scope)); + Collection files = findFilesForPackage(new FqName(packageFqName), scope); if (!files.isEmpty()) { FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(new FqName(packageFqName)); result.putValue(packageClassFqName.shortName().getName(), packageClassFqName); diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetPackageDeclarationIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetPackageDeclarationIndex.java deleted file mode 100644 index 43b1c3d6abb..00000000000 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetPackageDeclarationIndex.java +++ /dev/null @@ -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 { - private static final StubIndexKey KEY = KotlinIndexUtil.createIndexKey(JetPackageDeclarationIndex.class); - - private static final JetPackageDeclarationIndex ourInstance = new JetPackageDeclarationIndex(); - - public static JetPackageDeclarationIndex getInstance() { - return ourInstance; - } - - private JetPackageDeclarationIndex() {} - - @NotNull - @Override - public StubIndexKey getKey() { - return KEY; - } - - @Override - public Collection get(final String fqName, final Project project, @NotNull final GlobalSearchScope scope) { - return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); - } -} diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java b/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java index ac1480d20ca..95c2a9352c8 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/StubIndexServiceImpl.java @@ -30,8 +30,6 @@ public class StubIndexServiceImpl implements StubIndexService { String packageName = stub.getPackageName(); FqName fqName = new FqName(packageName == null ? "" : packageName); - sink.occurrence(JetPackageDeclarationIndex.getInstance().getKey(), fqName.getFqName()); - while (true) { sink.occurrence(JetAllPackagesIndex.getInstance().getKey(), fqName.getFqName()); if (fqName.isRoot()) {