diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsProjectDetector.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsProjectDetector.kt deleted file mode 100644 index cfe9795dedc..00000000000 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JsProjectDetector.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2015 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.kotlin.idea.caches.resolve - -import com.intellij.openapi.module.ModuleManager -import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.ProjectRootModificationTracker -import com.intellij.psi.util.CachedValueProvider -import com.intellij.psi.util.CachedValuesManager -import org.jetbrains.kotlin.idea.project.TargetPlatformDetector -import org.jetbrains.kotlin.js.resolve.JsPlatform - -//TODO: this should go away to support cross-platform projects -object JsProjectDetector { - @JvmStatic - fun isJsProject(project: Project): Boolean { - return CachedValuesManager.getManager(project).getCachedValue(project) { - val result = ModuleManager.getInstance(project).modules.any { TargetPlatformDetector.getPlatform(it) == JsPlatform } - CachedValueProvider.Result(result, ProjectRootModificationTracker.getInstance(project)) - } - } -} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinSourceFilterScope.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinSourceFilterScope.kt index 28e155c6e22..d69d5d8a6ff 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinSourceFilterScope.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinSourceFilterScope.kt @@ -35,16 +35,13 @@ class KotlinSourceFilterScope private constructor( private val index = ProjectRootManager.getInstance(project).fileIndex - //NOTE: avoid recomputing in potentially bottleneck 'contains' method - private val isJsProjectRef = Ref(null) - override fun getProject() = project override fun contains(file: VirtualFile): Boolean { if (!super.contains(file)) return false return ProjectRootsUtil.isInContent( - project, file, includeProjectSourceFiles, includeLibrarySourceFiles, includeClassFiles, includeScriptDependencies, index, isJsProjectRef + project, file, includeProjectSourceFiles, includeLibrarySourceFiles, includeClassFiles, includeScriptDependencies, index ) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt index a8796046950..c54aa55ffdd 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt @@ -28,15 +28,14 @@ import com.intellij.openapi.roots.FileIndex import com.intellij.openapi.roots.ModuleRootManager import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.roots.ProjectRootManager -import com.intellij.openapi.util.Ref import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiDirectory import com.intellij.psi.PsiElement import com.intellij.psi.PsiFileSystemItem import org.jetbrains.kotlin.idea.KotlinModuleFileType -import org.jetbrains.kotlin.idea.caches.resolve.JsProjectDetector import org.jetbrains.kotlin.idea.core.script.ScriptDependenciesManager import org.jetbrains.kotlin.idea.decompiler.builtIns.KotlinBuiltInFileType +import org.jetbrains.kotlin.idea.decompiler.js.KotlinJavaScriptMetaFileType import org.jetbrains.kotlin.idea.util.application.runReadAction abstract class KotlinBinaryExtension(val fileType: FileType) { @@ -53,6 +52,7 @@ abstract class KotlinBinaryExtension(val fileType: FileType) { class JavaClassBinary: KotlinBinaryExtension(JavaClassFileType.INSTANCE) class KotlinBuiltInBinary: KotlinBinaryExtension(KotlinBuiltInFileType) class KotlinModuleBinary: KotlinBinaryExtension(KotlinModuleFileType.INSTANCE) +class KotlinJsMetaBinary: KotlinBinaryExtension(KotlinJavaScriptMetaFileType) fun FileType.isKotlinBinary(): Boolean = this in KotlinBinaryExtension.kotlinBinaries @@ -69,8 +69,7 @@ object ProjectRootsUtil { @JvmStatic fun isInContent(project: Project, file: VirtualFile, includeProjectSource: Boolean, includeLibrarySource: Boolean, includeLibraryClasses: Boolean, includeScriptDependencies: Boolean, - fileIndex: ProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(project), - isJsProjectRef: Ref? = null): Boolean { + fileIndex: ProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(project)): Boolean { if (includeProjectSource && fileIndex.isInSourceContentWithoutInjected(file)) return true @@ -92,15 +91,6 @@ object ProjectRootsUtil { if (scriptConfigurationManager?.getAllLibrarySourcesScope()?.contains(file) == true) return true } - if ((includeLibraryClasses && fileIndex.isInLibraryClasses(file)) || - (includeLibrarySource && fileIndex.isInLibrarySource(file))) { - - //NOTE: avoid computing isJsProject if redundant - val isJsProject = isJsProjectRef?.get() ?: JsProjectDetector.isJsProject(project) - isJsProjectRef?.set(isJsProject) - return isJsProject - } - return false } diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 780d440cd4e..81ac1aa421d 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -2726,6 +2726,7 @@ +