diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinModifierListStubImpl.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinModifierListStubImpl.java index 043d2af8dc8..f8f90c840d7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinModifierListStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinModifierListStubImpl.java @@ -18,12 +18,12 @@ package org.jetbrains.kotlin.psi.stubs.impl; import com.intellij.psi.stubs.StubElement; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.psi.KtModifierList; +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken; +import org.jetbrains.kotlin.psi.KtDeclarationModifierList; import org.jetbrains.kotlin.psi.stubs.KotlinModifierListStub; import org.jetbrains.kotlin.psi.stubs.elements.KtModifierListElementType; -import org.jetbrains.kotlin.lexer.KtModifierKeywordToken; -public class KotlinModifierListStubImpl extends KotlinStubBaseImpl implements KotlinModifierListStub { +public class KotlinModifierListStubImpl extends KotlinStubBaseImpl implements KotlinModifierListStub { private final int mask; diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IdeStubIndexService.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IdeStubIndexService.java index 31244ebe50e..15e47eb47b8 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IdeStubIndexService.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IdeStubIndexService.java @@ -168,6 +168,8 @@ public class IdeStubIndexService extends StubIndexService { IndexUtilsKt.indexTopLevelExtension(stub, sink); } } + + IndexUtilsKt.indexInternals(stub, sink); } @Override @@ -208,6 +210,8 @@ public class IdeStubIndexService extends StubIndexService { IndexUtilsKt.indexTopLevelExtension(stub, sink); } } + + IndexUtilsKt.indexInternals(stub, sink); } @Override diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt index a97cb6cda4c..c5c45aaae50 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/IndexUtils.kt @@ -19,8 +19,8 @@ package org.jetbrains.kotlin.idea.stubindex import com.intellij.psi.stubs.IndexSink import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.stubs.KotlinCallableStubBase -import org.jetbrains.kotlin.psi.stubs.KotlinTypeAliasStub +import org.jetbrains.kotlin.psi.stubs.* +import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes import org.jetbrains.kotlin.util.aliasImportMap fun indexTopLevelExtension(stub: KotlinCallableStubBase, sink: IndexSink) { @@ -87,3 +87,21 @@ private fun KtTypeElement.index( else -> error("Unsupported type: $this") } } + +fun indexInternals(stub: KotlinCallableStubBase<*>, sink: IndexSink) { + val name = stub.name ?: return + + val modifierListStub = stub.modifierList ?: return + + if (!modifierListStub.hasModifier(KtTokens.INTERNAL_KEYWORD)) return + + if (stub.isTopLevel()) return + + if (modifierListStub.hasModifier(KtTokens.OPEN_KEYWORD) + || modifierListStub.hasModifier(KtTokens.ABSTRACT_KEYWORD)) { + sink.occurrence(KotlinOverridableInternalMembersShortNameIndex.Instance.key, name) + } +} + +private val KotlinStubWithFqName<*>.modifierList: KotlinModifierListStub? + get() = findChildStubByType(KtStubElementTypes.MODIFIER_LIST) as? KotlinModifierListStub diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinOverridableInternalMembersShortNameIndex.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinOverridableInternalMembersShortNameIndex.kt new file mode 100644 index 00000000000..e0b8d5245d8 --- /dev/null +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinOverridableInternalMembersShortNameIndex.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2017 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.stubindex + +import com.intellij.openapi.project.Project +import com.intellij.psi.search.GlobalSearchScope +import com.intellij.psi.stubs.StringStubIndexExtension +import com.intellij.psi.stubs.StubIndex +import org.jetbrains.kotlin.psi.KtCallableDeclaration + +class KotlinOverridableInternalMembersShortNameIndex private constructor() : StringStubIndexExtension() { + override fun getKey() = KEY + + override fun get(name: String, project: Project, scope: GlobalSearchScope): Collection { + return StubIndex.getElements(KEY, name, project, scope, KtCallableDeclaration::class.java) + } + + companion object { + + @JvmField + val Instance = KotlinOverridableInternalMembersShortNameIndex() + + private val KEY = KotlinIndexUtil.createIndexKey(KotlinOverridableInternalMembersShortNameIndex::class.java) + } +} \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 4c3896c6beb..5a2e5562969 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -663,6 +663,7 @@ +