diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionStatistician.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionStatistician.kt new file mode 100644 index 00000000000..cb4438c92e8 --- /dev/null +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionStatistician.kt @@ -0,0 +1,50 @@ +/* + * 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.completion + +import com.intellij.codeInsight.completion.CompletionLocation +import com.intellij.codeInsight.completion.CompletionStatistician +import com.intellij.codeInsight.lookup.LookupElement +import com.intellij.psi.statistics.StatisticsInfo +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor +import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject +import org.jetbrains.kotlin.idea.imports.importableFqName +import org.jetbrains.kotlin.renderer.DescriptorRenderer + +public class KotlinCompletionStatistician : CompletionStatistician() { + override fun serialize(element: LookupElement, location: CompletionLocation): StatisticsInfo? { + val o = (element.`object` as? DeclarationLookupObject) ?: return null + + if (o.descriptor != null) { + val container = o.descriptor!!.containingDeclaration + val containerFqName = when (container) { + is ClassDescriptor -> container.importableFqName?.asString() + is PackageFragmentDescriptor -> container.fqName.asString() + is ModuleDescriptor -> "" + else -> null + } ?: return StatisticsInfo.EMPTY + val signature = DescriptorRenderer.COMPACT.render(o.descriptor!!) //TODO: more compact presentation + return StatisticsInfo(containerFqName, signature) + } + else { + val fqName = o.importableFqName ?: return StatisticsInfo.EMPTY + return StatisticsInfo(fqName.parent().asString(), fqName.shortName().identifier) + } + } +} \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/EnumEntry/EnumEntry.dependency.kt b/idea/idea-completion/testData/basic/multifile/EnumEntry/EnumEntry.dependency.kt index e46aec2c520..3a83097033b 100644 --- a/idea/idea-completion/testData/basic/multifile/EnumEntry/EnumEntry.dependency.kt +++ b/idea/idea-completion/testData/basic/multifile/EnumEntry/EnumEntry.dependency.kt @@ -5,4 +5,6 @@ enum class EnumTest(val i: Int = 0) { ENTRY2(1) } -class EAnotherClass \ No newline at end of file +class EAnotherClass + +// ALLOW_AST_ACCESS \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index c5f61b84b3d..8a9a1426bf8 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -320,6 +320,8 @@ + +