From 0462d152eb73f5846901d8c1ca7159c900d5e7eb Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 23 Sep 2014 23:01:57 +0400 Subject: [PATCH] Smart completion: prefer items matching by name --- .../intellij/psi/codeStyle/annotations.xml | 8 ++ .../jet/generators/tests/GenerateTests.kt | 10 +- .../plugin/completion/CompletionSorting.kt | 8 +- .../jet/plugin/completion/ExpectedInfos.kt | 39 ++++-- .../plugin/completion/smart/LambdaItems.kt | 4 +- .../plugin/completion/smart/NameSimilarity.kt | 59 +++++++++ .../completion/smart/SmartCompletion.kt | 8 +- .../jet/plugin/completion/smart/Utils.kt | 19 +-- .../weighers/{ => basic}/DeprecatedFun.kt | 0 .../{ => basic}/ExactMatchForKeyword.kt | 0 .../weighers/{ => basic}/KeywordsLast.kt | 0 .../LocalFileBeforeImported.Data.kt | 0 .../{ => basic}/LocalFileBeforeImported.kt | 0 .../{ => basic}/LocalValuesAndParams.kt | 0 .../{ => basic}/LocalsBeforeKeywords.kt | 0 .../{ => basic}/LocalsPropertiesKeywords.kt | 0 .../{ => basic}/NamedParameters.Data.kt | 0 .../weighers/{ => basic}/NamedParameters.kt | 0 .../{ => basic}/ParametersBeforeKeywords.kt | 0 .../{ => basic}/PropertiesBeforeKeywords.kt | 0 .../weighers/smart/NameSimilarity1.kt | 7 + .../weighers/smart/NameSimilarity2.kt | 7 + .../weighers/smart/NameSimilarity3.kt | 23 ++++ .../NameSimilarityAndCompiledParameters.kt | 10 ++ .../weighers/smart/NameSimilarityForBlock.kt | 7 + .../weighers/smart/NameSimilarityForElse.kt | 7 + .../weighers/smart/NameSimilarityForElvis.kt | 11 ++ .../weighers/smart/NameSimilarityForEq1.kt | 8 ++ .../weighers/smart/NameSimilarityForEq2.kt | 11 ++ .../weighers/smart/NameSimilarityForEq3.kt | 11 ++ .../weighers/smart/NameSimilarityForEq4.kt | 7 + .../weighers/smart/NameSimilarityForThen.kt | 7 + ...milarityInImplicitlyTypedVarInitializer.kt | 5 + .../smart/NameSimilaritySorterPlacement.kt | 13 ++ .../JvmBasicCompletionTestGenerated.java | 5 +- .../weighers/AbstractCompletionWeigherTest.kt | 15 ++- ... BasicCompletionWeigherTestGenerated.java} | 28 ++-- .../SmartCompletionWeigherTestGenerated.java | 125 ++++++++++++++++++ 38 files changed, 414 insertions(+), 48 deletions(-) create mode 100644 annotations/com/intellij/psi/codeStyle/annotations.xml create mode 100644 idea/src/org/jetbrains/jet/plugin/completion/smart/NameSimilarity.kt rename idea/testData/completion/weighers/{ => basic}/DeprecatedFun.kt (100%) rename idea/testData/completion/weighers/{ => basic}/ExactMatchForKeyword.kt (100%) rename idea/testData/completion/weighers/{ => basic}/KeywordsLast.kt (100%) rename idea/testData/completion/weighers/{ => basic}/LocalFileBeforeImported.Data.kt (100%) rename idea/testData/completion/weighers/{ => basic}/LocalFileBeforeImported.kt (100%) rename idea/testData/completion/weighers/{ => basic}/LocalValuesAndParams.kt (100%) rename idea/testData/completion/weighers/{ => basic}/LocalsBeforeKeywords.kt (100%) rename idea/testData/completion/weighers/{ => basic}/LocalsPropertiesKeywords.kt (100%) rename idea/testData/completion/weighers/{ => basic}/NamedParameters.Data.kt (100%) rename idea/testData/completion/weighers/{ => basic}/NamedParameters.kt (100%) rename idea/testData/completion/weighers/{ => basic}/ParametersBeforeKeywords.kt (100%) rename idea/testData/completion/weighers/{ => basic}/PropertiesBeforeKeywords.kt (100%) create mode 100644 idea/testData/completion/weighers/smart/NameSimilarity1.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarity2.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarity3.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityAndCompiledParameters.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForBlock.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForElse.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForElvis.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForEq1.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForEq2.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForEq3.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForEq4.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityForThen.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilarityInImplicitlyTypedVarInitializer.kt create mode 100644 idea/testData/completion/weighers/smart/NameSimilaritySorterPlacement.kt rename idea/tests/org/jetbrains/jet/completion/weighers/{CompletionWeigherTestGenerated.java => BasicCompletionWeigherTestGenerated.java} (78%) create mode 100644 idea/tests/org/jetbrains/jet/completion/weighers/SmartCompletionWeigherTestGenerated.java diff --git a/annotations/com/intellij/psi/codeStyle/annotations.xml b/annotations/com/intellij/psi/codeStyle/annotations.xml new file mode 100644 index 00000000000..dc64de8827c --- /dev/null +++ b/annotations/com/intellij/psi/codeStyle/annotations.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 69443282590..ad19fe6859e 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -65,7 +65,6 @@ import org.jetbrains.jet.editor.quickDoc.AbstractJetQuickDocProviderTest import org.jetbrains.jet.safeDelete.AbstractJetSafeDeleteTest import org.jetbrains.jet.resolve.AbstractReferenceResolveTest import org.jetbrains.jet.resolve.AbstractReferenceResolveWithLibTest -import org.jetbrains.jet.completion.weighers.AbstractCompletionWeigherTest import org.jetbrains.jet.findUsages.AbstractJetFindUsagesTest import org.jetbrains.jet.plugin.configuration.AbstractConfigureProjectByChangingFileTest import org.jetbrains.jet.formatter.AbstractJetFormatterTest @@ -119,6 +118,8 @@ import org.jetbrains.jet.plugin.intentions.declarations.AbstractJoinLinesTest import org.jetbrains.jet.codegen.AbstractScriptCodegenTest import org.jetbrains.jet.plugin.parameterInfo.AbstractFunctionParameterInfoTest import org.jetbrains.jet.psi.patternMatching.AbstractJetPsiUnifierTest +import org.jetbrains.jet.completion.weighers.AbstractBasicCompletionWeigherTest +import org.jetbrains.jet.completion.weighers.AbstractSmartCompletionWeigherTest fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -479,8 +480,11 @@ fun main(args: Array) { model("refactoring/move", extension = "test", singleClass = true) } - testClass(javaClass()) { - model("completion/weighers", pattern = """^([^\.]+)\.kt$""") + testClass(javaClass()) { + model("completion/weighers/basic", pattern = """^([^\.]+)\.kt$""") + } + testClass(javaClass()) { + model("completion/weighers/smart", pattern = """^([^\.]+)\.kt$""") } testClass(javaClass()) { diff --git a/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt b/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt index 703cef62fb8..23316d6c5db 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/CompletionSorting.kt @@ -33,15 +33,21 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils import org.jetbrains.jet.lang.resolve.name.isValidJavaFqName import org.jetbrains.jet.lang.resolve.ImportPath import org.jetbrains.jet.plugin.quickfix.ImportInsertHelper +import com.intellij.codeInsight.completion.CompletionType +import org.jetbrains.jet.plugin.completion.smart.NameSimilarityWeigher public fun CompletionResultSet.addKotlinSorting(parameters: CompletionParameters): CompletionResultSet { var sorter = CompletionSorter.defaultSorter(parameters, getPrefixMatcher())!! sorter = sorter.weighBefore("stats", PriorityWeigher, KindWeigher) + if (parameters.getCompletionType() == CompletionType.SMART) { + sorter = sorter.weighBefore("kotlin.kind", NameSimilarityWeigher) + } + sorter = sorter.weighAfter( "stats", - JetDeclarationRemotenessWeigher(parameters.getOriginalFile() as JetFile), + JetDeclarationRemotenessWeigher(parameters.getOriginalFile() as JetFile)/*TODO: shouldn't it have bigger priority?*/, DeprecatedWeigher) sorter = sorter.weighBefore("middleMatching", PreferMatchingItemWeigher) diff --git a/idea/src/org/jetbrains/jet/plugin/completion/ExpectedInfos.kt b/idea/src/org/jetbrains/jet/plugin/completion/ExpectedInfos.kt index 3401099d388..af0679326eb 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/ExpectedInfos.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/ExpectedInfos.kt @@ -59,6 +59,8 @@ import org.jetbrains.jet.lang.psi.JetPrefixExpression import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall import org.jetbrains.jet.lang.psi.JetFunctionLiteralArgument import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression +import org.jetbrains.jet.lang.psi.JetArrayAccessExpression enum class Tail { COMMA @@ -66,7 +68,7 @@ enum class Tail { ELSE } -data class ExpectedInfo(val `type`: JetType, val tail: Tail?) +data class ExpectedInfo(val `type`: JetType, val name: String?, val tail: Tail?) class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: ModuleDescriptor) { public fun calculate(expressionWithType: JetExpression): Collection? { @@ -162,7 +164,9 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo else Tail.COMMA - expectedInfos.add(ExpectedInfo(parameters[argumentIndex].getType(), tail)) + val parameter = parameters[argumentIndex] + val expectedName = if (descriptor.hasSynthesizedParameterNames()) null else parameter.getName().asString() + expectedInfos.add(ExpectedInfo(parameter.getType(), expectedName, tail)) } } return expectedInfos @@ -176,7 +180,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo val otherOperand = if (expressionWithType == binaryExpression.getRight()) binaryExpression.getLeft() else binaryExpression.getRight() if (otherOperand != null) { val expressionType = bindingContext[BindingContext.EXPRESSION_TYPE, otherOperand] ?: return null - return listOf(ExpectedInfo(expressionType, null)) + return listOf(ExpectedInfo(expressionType, expectedNameFromExpression(otherOperand), null)) } } } @@ -186,9 +190,9 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo private fun calculateForIf(expressionWithType: JetExpression): Collection? { val ifExpression = (expressionWithType.getParent() as? JetContainerNode)?.getParent() as? JetIfExpression ?: return null return when (expressionWithType) { - ifExpression.getCondition() -> listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), Tail.RPARENTH)) + ifExpression.getCondition() -> listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null, Tail.RPARENTH)) - ifExpression.getThen() -> calculate(ifExpression)?.map { ExpectedInfo(it.`type`, Tail.ELSE) } + ifExpression.getThen() -> calculate(ifExpression)?.map { ExpectedInfo(it.`type`, it.name, Tail.ELSE) } ifExpression.getElse() -> { val ifExpectedInfo = calculate(ifExpression) @@ -219,7 +223,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo expectedInfos } else if (leftTypeNotNullable != null) { - return listOf(ExpectedInfo(leftTypeNotNullable, null)) + return listOf(ExpectedInfo(leftTypeNotNullable, null, null)) } } } @@ -229,7 +233,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo private fun calculateForBlockExpression(expressionWithType: JetExpression): Collection? { val block = expressionWithType.getParent() as? JetBlockExpression ?: return null if (expressionWithType != block.getStatements().last()) return null - return calculate(block)?.map { ExpectedInfo(it.`type`, null) } + return calculate(block)?.map { ExpectedInfo(it.`type`, it.name, null) } } private fun calculateForWhenEntryValue(expressionWithType: JetExpression): Collection? { @@ -239,21 +243,34 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo val subject = whenExpression.getSubjectExpression() if (subject != null) { val subjectType = bindingContext[BindingContext.EXPRESSION_TYPE, subject] ?: return null - return listOf(ExpectedInfo(subjectType, null)) + return listOf(ExpectedInfo(subjectType, null, null)) } else { - return listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null)) + return listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null, null)) } } private fun calculateForExclOperand(expressionWithType: JetExpression): Collection? { val prefixExpression = expressionWithType.getParent() as? JetPrefixExpression ?: return null if (prefixExpression.getOperationToken() != JetTokens.EXCL) return null - return listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null)) + return listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null, null)) } private fun getFromBindingContext(expressionWithType: JetExpression): Collection? { val expectedType = bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, expressionWithType] ?: return null - return listOf(ExpectedInfo(expectedType, null)) + return listOf(ExpectedInfo(expectedType, null, null)) } + + private fun expectedNameFromExpression(expression: JetExpression?): String? { + return when (expression) { + is JetSimpleNameExpression -> expression.getReferencedName() + is JetQualifiedExpression -> expectedNameFromExpression(expression.getSelectorExpression()) + is JetCallExpression -> expectedNameFromExpression(expression.getCalleeExpression()) + is JetArrayAccessExpression -> expectedNameFromExpression(expression.getArrayExpression())?.fromPlural() + else -> null + } + } + + private fun String.fromPlural() + = if (endsWith("s")) substring(0, length - 1) else this } \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/plugin/completion/smart/LambdaItems.kt b/idea/src/org/jetbrains/jet/plugin/completion/smart/LambdaItems.kt index 94cd6768db5..a4f22b10d8e 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/smart/LambdaItems.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/smart/LambdaItems.kt @@ -37,7 +37,7 @@ object LambdaItems { val lookupElement = LookupElementBuilder.create("{...}") .withInsertHandler(ArtificialElementInsertHandler("{ ", " }", false)) .suppressAutoInsertion() - .addTail(functionExpectedInfos) + .addTailAndNameSimilarity(functionExpectedInfos) lookupElement.putUserData(JetCompletionCharFilter.ACCEPT_OPENING_BRACE, true) collection.add(lookupElement) } @@ -53,7 +53,7 @@ object LambdaItems { insertLambdaTemplate(context, TextRange(offset, offset + placeholder.length), functionType) }) .suppressAutoInsertion() - .addTail(functionExpectedInfos.filter { it.`type` == functionType }) + .addTailAndNameSimilarity(functionExpectedInfos.filter { it.`type` == functionType }) lookupElement.putUserData(JetCompletionCharFilter.ACCEPT_OPENING_BRACE, true) collection.add(lookupElement) } diff --git a/idea/src/org/jetbrains/jet/plugin/completion/smart/NameSimilarity.kt b/idea/src/org/jetbrains/jet/plugin/completion/smart/NameSimilarity.kt new file mode 100644 index 00000000000..287944223e1 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/completion/smart/NameSimilarity.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2014 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.completion.smart + +import com.intellij.openapi.util.Key +import com.intellij.codeInsight.lookup.LookupElementWeigher +import com.intellij.codeInsight.lookup.LookupElement +import com.intellij.codeInsight.lookup.WeighingContext +import org.jetbrains.jet.plugin.completion.ExpectedInfo +import com.intellij.psi.codeStyle.NameUtil + +val NAME_SIMILARITY_KEY = Key("NAME_SIMILARITY_KEY") + +object NameSimilarityWeigher : LookupElementWeigher("kotlin.nameSimilarity") { + override fun weigh(element: LookupElement, context: WeighingContext) + = -(element.getUserData(NAME_SIMILARITY_KEY) ?: 0) +} + +fun calcNameSimilarity(name: String, expectedInfos: Collection): Int { + return expectedInfos + .map { it.name } + .filterNotNull() + .map { calcNameSimilarity(name, it) } + .max() ?: 0 +} + +private fun calcNameSimilarity(name: String, expectedName: String): Int { + val words1 = NameUtil.nameToWordsLowerCase(name) + val words2 = NameUtil.nameToWordsLowerCase(expectedName) + + val matchedWords = words1.toSet().intersect(words2) + if (matchedWords.isEmpty()) return 0 + + fun isNonNumber(word: String) = !word[0].isDigit() + val nonNumberWords1 = words1.filter(::isNonNumber) + val nonNumberWords2 = words2.filter(::isNonNumber) + + // count number of words matched at the end (but ignore number words - they are less important) + val minWords = Math.min(nonNumberWords1.size, nonNumberWords2.size) + val matchedTailLength = (0..minWords-1).firstOrNull { + i -> nonNumberWords1[nonNumberWords1.size - i - 1] != nonNumberWords2[nonNumberWords2.size - i - 1] + } ?: minWords + + return matchedWords.size * 1000 + matchedTailLength +} diff --git a/idea/src/org/jetbrains/jet/plugin/completion/smart/SmartCompletion.kt b/idea/src/org/jetbrains/jet/plugin/completion/smart/SmartCompletion.kt index 7b40ca46199..4c16ca84bba 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/smart/SmartCompletion.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/smart/SmartCompletion.kt @@ -94,7 +94,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression, // if we complete argument of == or !=, make types in expected info's nullable to allow nullable items too val expectedInfos = if ((expressionWithType.getParent() as? JetBinaryExpression)?.getOperationToken() in setOf(JetTokens.EQEQ, JetTokens.EXCLEQ)) - filteredExpectedInfos.map { ExpectedInfo(it.`type`.makeNullable(), it.tail) } + filteredExpectedInfos.map { ExpectedInfo(it.`type`.makeNullable(), it.name, it.tail) } else filteredExpectedInfos @@ -150,7 +150,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression, if (originalDeclaration != null) { val originalDescriptor = originalDeclaration.getLazyResolveSession().resolveToDescriptor(originalDeclaration) as? CallableDescriptor val returnType = originalDescriptor?.getReturnType() - return if (returnType != null) listOf(ExpectedInfo(returnType, null)) else null + return if (returnType != null) listOf(ExpectedInfo(returnType, declaration.getName(), null)) else null } } @@ -250,7 +250,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression, } } - return lookupElement.addTail(matchedExpectedInfos) + return lookupElement.addTailAndNameSimilarity(matchedExpectedInfos) } if (descriptor is SimpleFunctionDescriptor) { @@ -281,7 +281,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression, val items = ArrayList() for ((jetType, infos) in expectedInfosGrouped) { val lookupElement = lookupElementForType(jetType) ?: continue - items.add(lookupElement.addTail(infos)) + items.add(lookupElement.addTailAndNameSimilarity(infos)) } return Result(null, items) } diff --git a/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt b/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt index d3ff189b1de..147fec6d83a 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/smart/Utils.kt @@ -24,7 +24,6 @@ import org.jetbrains.jet.lang.psi.JetFile import org.jetbrains.jet.plugin.codeInsight.ShortenReferences import java.util.HashSet import com.intellij.codeInsight.lookup.LookupElementDecorator -import com.intellij.codeInsight.lookup.AutoCompletionPolicy import org.jetbrains.jet.lang.descriptors.FunctionDescriptor import org.jetbrains.jet.lang.types.JetType import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns @@ -32,10 +31,8 @@ import org.jetbrains.jet.lang.types.checker.JetTypeChecker import com.intellij.codeInsight.lookup.LookupElementPresentation import java.util.ArrayList import org.jetbrains.jet.plugin.completion.* -import com.intellij.openapi.util.Key import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor import org.jetbrains.jet.plugin.project.ResolveSessionForBodies -import org.jetbrains.jet.lang.resolve.BindingContext import org.jetbrains.jet.plugin.completion.handlers.WithTailInsertHandler class ArtificialElementInsertHandler( @@ -87,8 +84,14 @@ fun LookupElement.addTail(tail: Tail?): LookupElement { } } -fun LookupElement.addTail(matchedExpectedInfos: Collection): LookupElement - = addTail(mergeTails(matchedExpectedInfos.map { it.tail })) +fun LookupElement.addTailAndNameSimilarity(matchedExpectedInfos: Collection): LookupElement { + val lookupElement = addTail(mergeTails(matchedExpectedInfos.map { it.tail })) + val similarity = calcNameSimilarity(lookupElement.getLookupString(), matchedExpectedInfos) + if (similarity != 0) { + lookupElement.putUserData(NAME_SIMILARITY_KEY, similarity) + } + return lookupElement +} enum class ExpectedInfoClassification { MATCHES @@ -111,7 +114,7 @@ fun MutableCollection.addLookupElements(expectedInfos: Collection if (matchedInfos.isNotEmpty()) { val lookupElement = lookupElementFactory() if (lookupElement != null) { - add(lookupElement.addTail(matchedInfos)) + add(lookupElement.addTailAndNameSimilarity(matchedInfos)) } } else if (matchedInfosNotNullable.isNotEmpty()) { @@ -132,7 +135,7 @@ fun MutableCollection.addLookupElementsForNullable(factory: () -> } } lookupElement = lookupElement!!.suppressAutoInsertion() - add(lookupElement!!.addTail(matchedInfos)) + add(lookupElement!!.addTailAndNameSimilarity(matchedInfos)) } lookupElement = factory() @@ -147,7 +150,7 @@ fun MutableCollection.addLookupElementsForNullable(factory: () -> } } lookupElement = lookupElement!!.suppressAutoInsertion() - add(lookupElement!!.addTail(matchedInfos)) + add(lookupElement!!.addTailAndNameSimilarity(matchedInfos)) } } diff --git a/idea/testData/completion/weighers/DeprecatedFun.kt b/idea/testData/completion/weighers/basic/DeprecatedFun.kt similarity index 100% rename from idea/testData/completion/weighers/DeprecatedFun.kt rename to idea/testData/completion/weighers/basic/DeprecatedFun.kt diff --git a/idea/testData/completion/weighers/ExactMatchForKeyword.kt b/idea/testData/completion/weighers/basic/ExactMatchForKeyword.kt similarity index 100% rename from idea/testData/completion/weighers/ExactMatchForKeyword.kt rename to idea/testData/completion/weighers/basic/ExactMatchForKeyword.kt diff --git a/idea/testData/completion/weighers/KeywordsLast.kt b/idea/testData/completion/weighers/basic/KeywordsLast.kt similarity index 100% rename from idea/testData/completion/weighers/KeywordsLast.kt rename to idea/testData/completion/weighers/basic/KeywordsLast.kt diff --git a/idea/testData/completion/weighers/LocalFileBeforeImported.Data.kt b/idea/testData/completion/weighers/basic/LocalFileBeforeImported.Data.kt similarity index 100% rename from idea/testData/completion/weighers/LocalFileBeforeImported.Data.kt rename to idea/testData/completion/weighers/basic/LocalFileBeforeImported.Data.kt diff --git a/idea/testData/completion/weighers/LocalFileBeforeImported.kt b/idea/testData/completion/weighers/basic/LocalFileBeforeImported.kt similarity index 100% rename from idea/testData/completion/weighers/LocalFileBeforeImported.kt rename to idea/testData/completion/weighers/basic/LocalFileBeforeImported.kt diff --git a/idea/testData/completion/weighers/LocalValuesAndParams.kt b/idea/testData/completion/weighers/basic/LocalValuesAndParams.kt similarity index 100% rename from idea/testData/completion/weighers/LocalValuesAndParams.kt rename to idea/testData/completion/weighers/basic/LocalValuesAndParams.kt diff --git a/idea/testData/completion/weighers/LocalsBeforeKeywords.kt b/idea/testData/completion/weighers/basic/LocalsBeforeKeywords.kt similarity index 100% rename from idea/testData/completion/weighers/LocalsBeforeKeywords.kt rename to idea/testData/completion/weighers/basic/LocalsBeforeKeywords.kt diff --git a/idea/testData/completion/weighers/LocalsPropertiesKeywords.kt b/idea/testData/completion/weighers/basic/LocalsPropertiesKeywords.kt similarity index 100% rename from idea/testData/completion/weighers/LocalsPropertiesKeywords.kt rename to idea/testData/completion/weighers/basic/LocalsPropertiesKeywords.kt diff --git a/idea/testData/completion/weighers/NamedParameters.Data.kt b/idea/testData/completion/weighers/basic/NamedParameters.Data.kt similarity index 100% rename from idea/testData/completion/weighers/NamedParameters.Data.kt rename to idea/testData/completion/weighers/basic/NamedParameters.Data.kt diff --git a/idea/testData/completion/weighers/NamedParameters.kt b/idea/testData/completion/weighers/basic/NamedParameters.kt similarity index 100% rename from idea/testData/completion/weighers/NamedParameters.kt rename to idea/testData/completion/weighers/basic/NamedParameters.kt diff --git a/idea/testData/completion/weighers/ParametersBeforeKeywords.kt b/idea/testData/completion/weighers/basic/ParametersBeforeKeywords.kt similarity index 100% rename from idea/testData/completion/weighers/ParametersBeforeKeywords.kt rename to idea/testData/completion/weighers/basic/ParametersBeforeKeywords.kt diff --git a/idea/testData/completion/weighers/PropertiesBeforeKeywords.kt b/idea/testData/completion/weighers/basic/PropertiesBeforeKeywords.kt similarity index 100% rename from idea/testData/completion/weighers/PropertiesBeforeKeywords.kt rename to idea/testData/completion/weighers/basic/PropertiesBeforeKeywords.kt diff --git a/idea/testData/completion/weighers/smart/NameSimilarity1.kt b/idea/testData/completion/weighers/smart/NameSimilarity1.kt new file mode 100644 index 00000000000..75dda71ef9c --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarity1.kt @@ -0,0 +1,7 @@ +fun f(fooBar: String){} + +fun g(a: String, bar: String, fooBar: String) { + f() +} + +// ORDER: fooBar, bar, a diff --git a/idea/testData/completion/weighers/smart/NameSimilarity2.kt b/idea/testData/completion/weighers/smart/NameSimilarity2.kt new file mode 100644 index 00000000000..4b1bac846b9 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarity2.kt @@ -0,0 +1,7 @@ +fun f(fooBar: String){} + +fun g(fooA: String, someBar: String, fooBar: String, fooStuff: String) { + f() +} + +// ORDER: fooBar, someBar, fooA, fooStuff diff --git a/idea/testData/completion/weighers/smart/NameSimilarity3.kt b/idea/testData/completion/weighers/smart/NameSimilarity3.kt new file mode 100644 index 00000000000..640ea7ed81e --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarity3.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2014 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. + */ + +fun f(fooBar1: String, fooBar2: String){} + +fun g(someBar0: String, someBar1: String, someBar2: String, fooBar: String, fooBar0: String, fooBar1: String, fooBar2: String) { + f() +} + +// ORDER: fooBar1, fooBar, fooBar0, fooBar2, someBar1, someBar0, someBar2 diff --git a/idea/testData/completion/weighers/smart/NameSimilarityAndCompiledParameters.kt b/idea/testData/completion/weighers/smart/NameSimilarityAndCompiledParameters.kt new file mode 100644 index 00000000000..5520add1c71 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityAndCompiledParameters.kt @@ -0,0 +1,10 @@ +val id = "" +val p = "" +val p1 = "" + +fun g(zone: java.util.TimeZone) { + val local = "" + zone.setID() +} + +// ORDER: local, id, p, p1 diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForBlock.kt b/idea/testData/completion/weighers/smart/NameSimilarityForBlock.kt new file mode 100644 index 00000000000..2545b01d622 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForBlock.kt @@ -0,0 +1,7 @@ +fun f(fooBar: String){} + +fun g(b: Boolean, a: String, foo: String, bar: String) { + f(if (b) { }) +} + +// ORDER: bar, foo, a diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForElse.kt b/idea/testData/completion/weighers/smart/NameSimilarityForElse.kt new file mode 100644 index 00000000000..ec9d1822cf3 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForElse.kt @@ -0,0 +1,7 @@ +fun f(fooBar: String){} + +fun g(b: Boolean, aaa: String, aaa1:String, foo: String, bar: String) { + f(if (b) aaa else ) +} + +// ORDER: bar, foo, aaa, aaa1 diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForElvis.kt b/idea/testData/completion/weighers/smart/NameSimilarityForElvis.kt new file mode 100644 index 00000000000..47c949c7ad8 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForElvis.kt @@ -0,0 +1,11 @@ +fun f(fooBar: String){} + +object C { + fun aaa(): String = "" +} + +fun g(b: Boolean, aaa: String, foo: String, bar: String) { + f(C.aaa() ?: ) +} + +// ORDER: bar, foo, aaa diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForEq1.kt b/idea/testData/completion/weighers/smart/NameSimilarityForEq1.kt new file mode 100644 index 00000000000..8e1fd8baeca --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForEq1.kt @@ -0,0 +1,8 @@ +var fooBar1 = "" +var fooBar2 = "" + +fun f(s: String){ + if (fooBar1 == ) +} + +// ORDER: fooBar2, s diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForEq2.kt b/idea/testData/completion/weighers/smart/NameSimilarityForEq2.kt new file mode 100644 index 00000000000..b7865f9ad5a --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForEq2.kt @@ -0,0 +1,11 @@ +class C { + var fooBar = "" +} + +var fooBar = "" + +fun f(s: String, c: C){ + if (c.fooBar == ) +} + +// ORDER: fooBar, s diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForEq3.kt b/idea/testData/completion/weighers/smart/NameSimilarityForEq3.kt new file mode 100644 index 00000000000..3e4a244513c --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForEq3.kt @@ -0,0 +1,11 @@ +var fooBar = "" + +object C { + fun getFooBar() = "" +} + +fun f(s: String){ + if (C.getFooBar() == ) +} + +// ORDER: fooBar, s diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForEq4.kt b/idea/testData/completion/weighers/smart/NameSimilarityForEq4.kt new file mode 100644 index 00000000000..d4550138034 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForEq4.kt @@ -0,0 +1,7 @@ +var fooBar = "" + +fun f(s: String, bars: List){ + if (bars[0] == ) +} + +// ORDER: fooBar, s diff --git a/idea/testData/completion/weighers/smart/NameSimilarityForThen.kt b/idea/testData/completion/weighers/smart/NameSimilarityForThen.kt new file mode 100644 index 00000000000..d3cfcf3c755 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityForThen.kt @@ -0,0 +1,7 @@ +fun f(fooBar: String){} + +fun g(b: Boolean, a: String, foo: String, bar: String) { + f(if (b) ) +} + +// ORDER: bar, foo, a diff --git a/idea/testData/completion/weighers/smart/NameSimilarityInImplicitlyTypedVarInitializer.kt b/idea/testData/completion/weighers/smart/NameSimilarityInImplicitlyTypedVarInitializer.kt new file mode 100644 index 00000000000..8051dd07ff6 --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilarityInImplicitlyTypedVarInitializer.kt @@ -0,0 +1,5 @@ +class A(s: String) { + val substring = s.capitalize() +} + +// ORDER: substring \ No newline at end of file diff --git a/idea/testData/completion/weighers/smart/NameSimilaritySorterPlacement.kt b/idea/testData/completion/weighers/smart/NameSimilaritySorterPlacement.kt new file mode 100644 index 00000000000..33c4dd992dd --- /dev/null +++ b/idea/testData/completion/weighers/smart/NameSimilaritySorterPlacement.kt @@ -0,0 +1,13 @@ +// test that name similarity sorting takes over declaration kind sorting +val globalBar = "" +val globalX = "" + +fun f(fooBar: String){} + +fun g() { + val localBar = "" + val localX = "" + f() +} + +// ORDER: localBar, globalBar, localX, globalX diff --git a/idea/tests/org/jetbrains/jet/completion/JvmBasicCompletionTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/JvmBasicCompletionTestGenerated.java index a2314bbeb96..68870a3e989 100644 --- a/idea/tests/org/jetbrains/jet/completion/JvmBasicCompletionTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/completion/JvmBasicCompletionTestGenerated.java @@ -17,10 +17,13 @@ package org.jetbrains.jet.completion; import com.intellij.testFramework.TestDataPath; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.junit.runner.RunWith; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.test.InnerTestClasses; import org.jetbrains.jet.test.TestMetadata; -import org.junit.runner.RunWith; +import org.jetbrains.jet.JUnit3RunnerWithInners; import java.io.File; import java.util.regex.Pattern; diff --git a/idea/tests/org/jetbrains/jet/completion/weighers/AbstractCompletionWeigherTest.kt b/idea/tests/org/jetbrains/jet/completion/weighers/AbstractCompletionWeigherTest.kt index b134059d984..8f88d1e5b05 100644 --- a/idea/tests/org/jetbrains/jet/completion/weighers/AbstractCompletionWeigherTest.kt +++ b/idea/tests/org/jetbrains/jet/completion/weighers/AbstractCompletionWeigherTest.kt @@ -21,11 +21,12 @@ import org.jetbrains.jet.InTextDirectivesUtils import java.io.File import org.jetbrains.jet.plugin.PluginTestCaseBase import org.testng.Assert -import com.intellij.openapi.util.io.FileUtil import org.jetbrains.jet.test.util.configureWithExtraFile import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase +import com.intellij.testFramework.LightProjectDescriptor +import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor -public abstract class AbstractCompletionWeigherTest() : JetLightCodeInsightFixtureTestCase() { +public abstract class AbstractCompletionWeigherTest(val completionType: CompletionType, val relativeTestDataPath: String) : JetLightCodeInsightFixtureTestCase() { fun doTest(path: String) { myFixture.configureWithExtraFile(path) @@ -34,12 +35,18 @@ public abstract class AbstractCompletionWeigherTest() : JetLightCodeInsightFixtu val items = InTextDirectivesUtils.findArrayWithPrefixes(text, "// ORDER:") Assert.assertTrue(!items.isEmpty(), """Some items should be defined with "// ORDER:" directive""") - myFixture.complete(CompletionType.BASIC, InTextDirectivesUtils.getPrefixedInt(text, "// INVOCATION_COUNT:") ?: 1) + myFixture.complete(completionType, InTextDirectivesUtils.getPrefixedInt(text, "// INVOCATION_COUNT:") ?: 1) myFixture.assertPreferredCompletionItems(InTextDirectivesUtils.getPrefixedInt(text, "// SELECTED:") ?: 0, *items) } + override fun getProjectDescriptor(): LightProjectDescriptor { + return JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE + } + protected override fun getTestDataPath() : String? { - return File(PluginTestCaseBase.getTestDataPathBase(), "/completion/weighers").getPath() + File.separator + return File(PluginTestCaseBase.getTestDataPathBase(), relativeTestDataPath).getPath() + File.separator } } +public abstract class AbstractBasicCompletionWeigherTest() : AbstractCompletionWeigherTest(CompletionType.BASIC, "/completion/weighers/basic") +public abstract class AbstractSmartCompletionWeigherTest() : AbstractCompletionWeigherTest(CompletionType.SMART, "/completion/weighers/smart") diff --git a/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/weighers/BasicCompletionWeigherTestGenerated.java similarity index 78% rename from idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTestGenerated.java rename to idea/tests/org/jetbrains/jet/completion/weighers/BasicCompletionWeigherTestGenerated.java index 078f2487528..53227964669 100644 --- a/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/completion/weighers/BasicCompletionWeigherTestGenerated.java @@ -30,71 +30,71 @@ import java.util.regex.Pattern; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@TestMetadata("idea/testData/completion/weighers") +@TestMetadata("idea/testData/completion/weighers/basic") @TestDataPath("$PROJECT_ROOT") @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) -public class CompletionWeigherTestGenerated extends AbstractCompletionWeigherTest { - public void testAllFilesPresentInWeighers() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/weighers"), Pattern.compile("^([^\\.]+)\\.kt$"), true); +public class BasicCompletionWeigherTestGenerated extends AbstractBasicCompletionWeigherTest { + public void testAllFilesPresentInBasic() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/weighers/basic"), Pattern.compile("^([^\\.]+)\\.kt$"), true); } @TestMetadata("DeprecatedFun.kt") public void testDeprecatedFun() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/DeprecatedFun.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/DeprecatedFun.kt"); doTest(fileName); } @TestMetadata("ExactMatchForKeyword.kt") public void testExactMatchForKeyword() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/ExactMatchForKeyword.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/ExactMatchForKeyword.kt"); doTest(fileName); } @TestMetadata("KeywordsLast.kt") public void testKeywordsLast() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/KeywordsLast.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/KeywordsLast.kt"); doTest(fileName); } @TestMetadata("LocalFileBeforeImported.kt") public void testLocalFileBeforeImported() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/LocalFileBeforeImported.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/LocalFileBeforeImported.kt"); doTest(fileName); } @TestMetadata("LocalValuesAndParams.kt") public void testLocalValuesAndParams() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/LocalValuesAndParams.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/LocalValuesAndParams.kt"); doTest(fileName); } @TestMetadata("LocalsBeforeKeywords.kt") public void testLocalsBeforeKeywords() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/LocalsBeforeKeywords.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/LocalsBeforeKeywords.kt"); doTest(fileName); } @TestMetadata("LocalsPropertiesKeywords.kt") public void testLocalsPropertiesKeywords() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/LocalsPropertiesKeywords.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/LocalsPropertiesKeywords.kt"); doTest(fileName); } @TestMetadata("NamedParameters.kt") public void testNamedParameters() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/NamedParameters.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/NamedParameters.kt"); doTest(fileName); } @TestMetadata("ParametersBeforeKeywords.kt") public void testParametersBeforeKeywords() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/ParametersBeforeKeywords.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/ParametersBeforeKeywords.kt"); doTest(fileName); } @TestMetadata("PropertiesBeforeKeywords.kt") public void testPropertiesBeforeKeywords() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/PropertiesBeforeKeywords.kt"); + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/basic/PropertiesBeforeKeywords.kt"); doTest(fileName); } diff --git a/idea/tests/org/jetbrains/jet/completion/weighers/SmartCompletionWeigherTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/weighers/SmartCompletionWeigherTestGenerated.java new file mode 100644 index 00000000000..3356b04c4c5 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/weighers/SmartCompletionWeigherTestGenerated.java @@ -0,0 +1,125 @@ +/* + * Copyright 2010-2014 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.completion.weighers; + +import com.intellij.testFramework.TestDataPath; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; +import org.jetbrains.jet.JUnit3RunnerWithInners; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/completion/weighers/smart") +@TestDataPath("$PROJECT_ROOT") +@RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) +public class SmartCompletionWeigherTestGenerated extends AbstractSmartCompletionWeigherTest { + public void testAllFilesPresentInSmart() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/weighers/smart"), Pattern.compile("^([^\\.]+)\\.kt$"), true); + } + + @TestMetadata("NameSimilarity1.kt") + public void testNameSimilarity1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarity1.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarity2.kt") + public void testNameSimilarity2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarity2.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarity3.kt") + public void testNameSimilarity3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarity3.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityAndCompiledParameters.kt") + public void testNameSimilarityAndCompiledParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityAndCompiledParameters.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForBlock.kt") + public void testNameSimilarityForBlock() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForBlock.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForElse.kt") + public void testNameSimilarityForElse() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForElse.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForElvis.kt") + public void testNameSimilarityForElvis() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForElvis.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForEq1.kt") + public void testNameSimilarityForEq1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForEq1.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForEq2.kt") + public void testNameSimilarityForEq2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForEq2.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForEq3.kt") + public void testNameSimilarityForEq3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForEq3.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForEq4.kt") + public void testNameSimilarityForEq4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForEq4.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityForThen.kt") + public void testNameSimilarityForThen() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityForThen.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilarityInImplicitlyTypedVarInitializer.kt") + public void testNameSimilarityInImplicitlyTypedVarInitializer() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilarityInImplicitlyTypedVarInitializer.kt"); + doTest(fileName); + } + + @TestMetadata("NameSimilaritySorterPlacement.kt") + public void testNameSimilaritySorterPlacement() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/weighers/smart/NameSimilaritySorterPlacement.kt"); + doTest(fileName); + } + +}