From 9c58cb9f3160cdc1fee261acb56fdc7aac3c6b3b Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 23 Jul 2014 17:12:23 +0400 Subject: [PATCH] Pass project explicitly to JetSourceFilterScope --- .../IDELightClassGenerationSupport.java | 10 +++++----- .../caches/resolve/KotlinCacheService.kt | 2 +- .../project/PluginJetFilesProvider.java | 2 +- .../plugin/stubindex/JetAllPackagesIndex.java | 2 +- .../plugin/stubindex/JetAnnotationsIndex.java | 2 +- .../stubindex/JetClassByPackageIndex.java | 2 +- .../stubindex/JetClassShortNameIndex.java | 2 +- .../stubindex/JetFullClassNameIndex.java | 2 +- .../stubindex/JetFunctionShortNameIndex.java | 2 +- .../stubindex/JetPropertyShortNameIndex.java | 2 +- .../stubindex/JetSourceFilterScope.java | 19 +++++++++++-------- .../plugin/stubindex/JetSuperClassIndex.java | 2 +- .../JetTopLevelFunctionsFqnNameIndex.java | 2 +- ...velNonExtensionFunctionShortNameIndex.java | 2 +- .../JetTopLevelObjectShortNameIndex.java | 2 +- .../JetTopLevelPropertiesFqnNameIndex.java | 2 +- ...PluginDeclarationProviderFactoryService.kt | 3 ++- 17 files changed, 32 insertions(+), 28 deletions(-) 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 8ffc163cb19..82a57126c76 100644 --- a/idea/src/org/jetbrains/jet/plugin/caches/resolve/IDELightClassGenerationSupport.java +++ b/idea/src/org/jetbrains/jet/plugin/caches/resolve/IDELightClassGenerationSupport.java @@ -160,13 +160,13 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport @NotNull @Override public Collection findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) { - return JetFullClassNameIndex.getInstance().get(fqName.asString(), project, kotlinSources(searchScope)); + return JetFullClassNameIndex.getInstance().get(fqName.asString(), project, kotlinSources(searchScope, project)); } @NotNull @Override public Collection findFilesForPackage(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) { - return PackageIndexUtil.findFilesWithExactPackage(fqName, kotlinSources(searchScope), project); + return PackageIndexUtil.findFilesWithExactPackage(fqName, kotlinSources(searchScope, project), project); } @NotNull @@ -174,18 +174,18 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport public Collection findClassOrObjectDeclarationsInPackage( @NotNull FqName packageFqName, @NotNull GlobalSearchScope searchScope ) { - return JetClassByPackageIndex.getInstance().get(packageFqName.asString(), project, kotlinSources(searchScope)); + return JetClassByPackageIndex.getInstance().get(packageFqName.asString(), project, kotlinSources(searchScope, project)); } @Override public boolean packageExists(@NotNull FqName fqName, @NotNull GlobalSearchScope scope) { - return !JetAllPackagesIndex.getInstance().get(fqName.asString(), project, kotlinSources(scope)).isEmpty(); + return !JetAllPackagesIndex.getInstance().get(fqName.asString(), project, kotlinSources(scope, project)).isEmpty(); } @NotNull @Override public Collection getSubPackages(@NotNull FqName fqn, @NotNull GlobalSearchScope scope) { - return PackageIndexUtil.getSubPackageFqNames(fqn, kotlinSources(scope), project); + return PackageIndexUtil.getSubPackageFqNames(fqn, kotlinSources(scope, project), project); } @Nullable diff --git a/idea/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt b/idea/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt index 1aaee879bbc..3bef76967ff 100644 --- a/idea/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt +++ b/idea/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt @@ -136,7 +136,7 @@ class KotlinCacheService(val project: Project) { } private fun kotlinSourcesInProjectScope(): GlobalSearchScope { - return JetSourceFilterScope.kotlinSources(GlobalSearchScope.allScope(project)) + return JetSourceFilterScope.kotlinSources(GlobalSearchScope.allScope(project), project) } public fun get(extension: CacheExtension): T { diff --git a/idea/src/org/jetbrains/jet/plugin/project/PluginJetFilesProvider.java b/idea/src/org/jetbrains/jet/plugin/project/PluginJetFilesProvider.java index 02033af0be1..5f5b2a1e7b2 100644 --- a/idea/src/org/jetbrains/jet/plugin/project/PluginJetFilesProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/project/PluginJetFilesProvider.java @@ -31,7 +31,7 @@ public class PluginJetFilesProvider { @NotNull public static Collection allFilesInProject(@NotNull Project project) { return JetAllPackagesIndex.getInstance().get(FqName.ROOT.asString(), project, - JetSourceFilterScope.kotlinSources(GlobalSearchScope.allScope(project))); + JetSourceFilterScope.kotlinSources(GlobalSearchScope.allScope(project), project)); } private PluginJetFilesProvider() { diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllPackagesIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllPackagesIndex.java index ae59465ee03..2da344fa3d1 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllPackagesIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAllPackagesIndex.java @@ -52,6 +52,6 @@ public class JetAllPackagesIndex extends StringStubIndexExtension { @NotNull @Override public Collection get(String fqName, Project project, @NotNull GlobalSearchScope scope) { - return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java index 0d3a73faf93..0479bb37b0f 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetAnnotationsIndex.java @@ -44,6 +44,6 @@ public class JetAnnotationsIndex extends StringStubIndexExtension get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassByPackageIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassByPackageIndex.java index 7c7bf75c4d6..a39a73a2de6 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassByPackageIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassByPackageIndex.java @@ -44,6 +44,6 @@ public class JetClassByPackageIndex extends StringStubIndexExtension get(String fqName, Project project, @NotNull GlobalSearchScope scope) { - return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassShortNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassShortNameIndex.java index ea2d4449a63..084f9de9c89 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassShortNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetClassShortNameIndex.java @@ -44,6 +44,6 @@ public class JetClassShortNameIndex extends StringStubIndexExtension get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java index f7b037e476e..0e1784800db 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetFullClassNameIndex.java @@ -46,6 +46,6 @@ public class JetFullClassNameIndex extends StringStubIndexExtension get(String fqName, Project project, @NotNull GlobalSearchScope scope) { - return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(fqName, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetFunctionShortNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetFunctionShortNameIndex.java index 97d30a191be..531d7db8f08 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetFunctionShortNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetFunctionShortNameIndex.java @@ -44,6 +44,6 @@ public class JetFunctionShortNameIndex extends StringStubIndexExtension get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetPropertyShortNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetPropertyShortNameIndex.java index 66437c0b188..8473f508055 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetPropertyShortNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetPropertyShortNameIndex.java @@ -44,6 +44,6 @@ public class JetPropertyShortNameIndex extends StringStubIndexExtension get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetSourceFilterScope.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetSourceFilterScope.java index 500e0c50732..aeb5f9f78a8 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetSourceFilterScope.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetSourceFilterScope.java @@ -17,6 +17,7 @@ package org.jetbrains.jet.plugin.stubindex; import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.vfs.VirtualFile; @@ -28,26 +29,28 @@ import org.jetbrains.jet.plugin.JetPluginUtil; public class JetSourceFilterScope extends DelegatingGlobalSearchScope { @NotNull - public static GlobalSearchScope kotlinSourcesAndLibraries(@NotNull GlobalSearchScope delegate) { - return new JetSourceFilterScope(delegate, true); + public static GlobalSearchScope kotlinSourcesAndLibraries(@NotNull GlobalSearchScope delegate, @NotNull Project project) { + return new JetSourceFilterScope(delegate, true, project); } @NotNull - public static GlobalSearchScope kotlinSources(@NotNull GlobalSearchScope delegate) { - return new JetSourceFilterScope(delegate, false); + public static GlobalSearchScope kotlinSources(@NotNull GlobalSearchScope delegate, @NotNull Project project) { + return new JetSourceFilterScope(delegate, false, project); } private final ProjectFileIndex index; + private final Project project; private final boolean includeLibraries; - private JetSourceFilterScope(@NotNull GlobalSearchScope delegate, boolean includeLibraries) { + private JetSourceFilterScope(@NotNull GlobalSearchScope delegate, boolean includeLibraries, @NotNull Project project) { super(delegate); this.includeLibraries = includeLibraries; - index = ProjectRootManager.getInstance(getProject()).getFileIndex(); + this.index = ProjectRootManager.getInstance(project).getFileIndex(); + this.project = project; } @Override - public boolean contains(VirtualFile file) { + public boolean contains(@NotNull VirtualFile file) { if (!super.contains(file)) { return false; } @@ -56,7 +59,7 @@ public class JetSourceFilterScope extends DelegatingGlobalSearchScope { return index.isInLibraryClasses(file); } - if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file, getProject())) { + if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file, project)) { return false; } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java index c8cffd78120..2bbdf945a6e 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetSuperClassIndex.java @@ -46,6 +46,6 @@ public class JetSuperClassIndex extends StringStubIndexExtension get(String s, Project project, GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java index fa5d8def349..1a0dbdde179 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelFunctionsFqnNameIndex.java @@ -49,6 +49,6 @@ public class JetTopLevelFunctionsFqnNameIndex extends StringStubIndexExtension get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelNonExtensionFunctionShortNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelNonExtensionFunctionShortNameIndex.java index 215179da551..95039d8d826 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelNonExtensionFunctionShortNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelNonExtensionFunctionShortNameIndex.java @@ -44,6 +44,6 @@ public class JetTopLevelNonExtensionFunctionShortNameIndex extends StringStubInd @Override public Collection get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelObjectShortNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelObjectShortNameIndex.java index c39a83b2963..23e0e5c4ce2 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelObjectShortNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelObjectShortNameIndex.java @@ -44,6 +44,6 @@ public class JetTopLevelObjectShortNameIndex extends StringStubIndexExtension get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java index 8c61d52bc09..686bab3bb2c 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/JetTopLevelPropertiesFqnNameIndex.java @@ -46,6 +46,6 @@ public class JetTopLevelPropertiesFqnNameIndex extends StringStubIndexExtension< @NotNull @Override public Collection get(String s, Project project, @NotNull GlobalSearchScope scope) { - return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope)); + return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); } } diff --git a/idea/src/org/jetbrains/jet/plugin/stubindex/resolve/PluginDeclarationProviderFactoryService.kt b/idea/src/org/jetbrains/jet/plugin/stubindex/resolve/PluginDeclarationProviderFactoryService.kt index 453054dd191..4d01e26c632 100644 --- a/idea/src/org/jetbrains/jet/plugin/stubindex/resolve/PluginDeclarationProviderFactoryService.kt +++ b/idea/src/org/jetbrains/jet/plugin/stubindex/resolve/PluginDeclarationProviderFactoryService.kt @@ -32,6 +32,7 @@ public class PluginDeclarationProviderFactoryService : DeclarationProviderFactor syntheticFiles: Collection, filesScope: GlobalSearchScope ): DeclarationProviderFactory { - return PluginDeclarationProviderFactory(project, JetSourceFilterScope.kotlinSources(filesScope), storageManager, syntheticFiles) + return PluginDeclarationProviderFactory(project, JetSourceFilterScope.kotlinSources(filesScope, project), + storageManager, syntheticFiles) } } \ No newline at end of file