Smart completion: prefer items matching by name
This commit is contained in:
committed by
valentin
parent
56978c4e16
commit
0462d152eb
@@ -0,0 +1,8 @@
|
|||||||
|
<root>
|
||||||
|
<item name='com.intellij.psi.codeStyle.NameUtil java.lang.String[] nameToWords(java.lang.String)'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
<item name='com.intellij.psi.codeStyle.NameUtil java.util.List<java.lang.String> nameToWordsLowerCase(java.lang.String)'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -65,7 +65,6 @@ import org.jetbrains.jet.editor.quickDoc.AbstractJetQuickDocProviderTest
|
|||||||
import org.jetbrains.jet.safeDelete.AbstractJetSafeDeleteTest
|
import org.jetbrains.jet.safeDelete.AbstractJetSafeDeleteTest
|
||||||
import org.jetbrains.jet.resolve.AbstractReferenceResolveTest
|
import org.jetbrains.jet.resolve.AbstractReferenceResolveTest
|
||||||
import org.jetbrains.jet.resolve.AbstractReferenceResolveWithLibTest
|
import org.jetbrains.jet.resolve.AbstractReferenceResolveWithLibTest
|
||||||
import org.jetbrains.jet.completion.weighers.AbstractCompletionWeigherTest
|
|
||||||
import org.jetbrains.jet.findUsages.AbstractJetFindUsagesTest
|
import org.jetbrains.jet.findUsages.AbstractJetFindUsagesTest
|
||||||
import org.jetbrains.jet.plugin.configuration.AbstractConfigureProjectByChangingFileTest
|
import org.jetbrains.jet.plugin.configuration.AbstractConfigureProjectByChangingFileTest
|
||||||
import org.jetbrains.jet.formatter.AbstractJetFormatterTest
|
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.codegen.AbstractScriptCodegenTest
|
||||||
import org.jetbrains.jet.plugin.parameterInfo.AbstractFunctionParameterInfoTest
|
import org.jetbrains.jet.plugin.parameterInfo.AbstractFunctionParameterInfoTest
|
||||||
import org.jetbrains.jet.psi.patternMatching.AbstractJetPsiUnifierTest
|
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<String>) {
|
fun main(args: Array<String>) {
|
||||||
System.setProperty("java.awt.headless", "true")
|
System.setProperty("java.awt.headless", "true")
|
||||||
@@ -479,8 +480,11 @@ fun main(args: Array<String>) {
|
|||||||
model("refactoring/move", extension = "test", singleClass = true)
|
model("refactoring/move", extension = "test", singleClass = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractCompletionWeigherTest>()) {
|
testClass(javaClass<AbstractBasicCompletionWeigherTest>()) {
|
||||||
model("completion/weighers", pattern = """^([^\.]+)\.kt$""")
|
model("completion/weighers/basic", pattern = """^([^\.]+)\.kt$""")
|
||||||
|
}
|
||||||
|
testClass(javaClass<AbstractSmartCompletionWeigherTest>()) {
|
||||||
|
model("completion/weighers/smart", pattern = """^([^\.]+)\.kt$""")
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractConfigureProjectByChangingFileTest>()) {
|
testClass(javaClass<AbstractConfigureProjectByChangingFileTest>()) {
|
||||||
|
|||||||
@@ -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.name.isValidJavaFqName
|
||||||
import org.jetbrains.jet.lang.resolve.ImportPath
|
import org.jetbrains.jet.lang.resolve.ImportPath
|
||||||
import org.jetbrains.jet.plugin.quickfix.ImportInsertHelper
|
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 {
|
public fun CompletionResultSet.addKotlinSorting(parameters: CompletionParameters): CompletionResultSet {
|
||||||
var sorter = CompletionSorter.defaultSorter(parameters, getPrefixMatcher())!!
|
var sorter = CompletionSorter.defaultSorter(parameters, getPrefixMatcher())!!
|
||||||
|
|
||||||
sorter = sorter.weighBefore("stats", PriorityWeigher, KindWeigher)
|
sorter = sorter.weighBefore("stats", PriorityWeigher, KindWeigher)
|
||||||
|
|
||||||
|
if (parameters.getCompletionType() == CompletionType.SMART) {
|
||||||
|
sorter = sorter.weighBefore("kotlin.kind", NameSimilarityWeigher)
|
||||||
|
}
|
||||||
|
|
||||||
sorter = sorter.weighAfter(
|
sorter = sorter.weighAfter(
|
||||||
"stats",
|
"stats",
|
||||||
JetDeclarationRemotenessWeigher(parameters.getOriginalFile() as JetFile),
|
JetDeclarationRemotenessWeigher(parameters.getOriginalFile() as JetFile)/*TODO: shouldn't it have bigger priority?*/,
|
||||||
DeprecatedWeigher)
|
DeprecatedWeigher)
|
||||||
|
|
||||||
sorter = sorter.weighBefore("middleMatching", PreferMatchingItemWeigher)
|
sorter = sorter.weighBefore("middleMatching", PreferMatchingItemWeigher)
|
||||||
|
|||||||
@@ -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.resolve.calls.util.DelegatingCall
|
||||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteralArgument
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteralArgument
|
||||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
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 {
|
enum class Tail {
|
||||||
COMMA
|
COMMA
|
||||||
@@ -66,7 +68,7 @@ enum class Tail {
|
|||||||
ELSE
|
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) {
|
class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: ModuleDescriptor) {
|
||||||
public fun calculate(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
public fun calculate(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
||||||
@@ -162,7 +164,9 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
|
|||||||
else
|
else
|
||||||
Tail.COMMA
|
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
|
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()
|
val otherOperand = if (expressionWithType == binaryExpression.getRight()) binaryExpression.getLeft() else binaryExpression.getRight()
|
||||||
if (otherOperand != null) {
|
if (otherOperand != null) {
|
||||||
val expressionType = bindingContext[BindingContext.EXPRESSION_TYPE, otherOperand] ?: return 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<ExpectedInfo>? {
|
private fun calculateForIf(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
||||||
val ifExpression = (expressionWithType.getParent() as? JetContainerNode)?.getParent() as? JetIfExpression ?: return null
|
val ifExpression = (expressionWithType.getParent() as? JetContainerNode)?.getParent() as? JetIfExpression ?: return null
|
||||||
return when (expressionWithType) {
|
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() -> {
|
ifExpression.getElse() -> {
|
||||||
val ifExpectedInfo = calculate(ifExpression)
|
val ifExpectedInfo = calculate(ifExpression)
|
||||||
@@ -219,7 +223,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
|
|||||||
expectedInfos
|
expectedInfos
|
||||||
}
|
}
|
||||||
else if (leftTypeNotNullable != null) {
|
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<ExpectedInfo>? {
|
private fun calculateForBlockExpression(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
||||||
val block = expressionWithType.getParent() as? JetBlockExpression ?: return null
|
val block = expressionWithType.getParent() as? JetBlockExpression ?: return null
|
||||||
if (expressionWithType != block.getStatements().last()) 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<ExpectedInfo>? {
|
private fun calculateForWhenEntryValue(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
||||||
@@ -239,21 +243,34 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
|
|||||||
val subject = whenExpression.getSubjectExpression()
|
val subject = whenExpression.getSubjectExpression()
|
||||||
if (subject != null) {
|
if (subject != null) {
|
||||||
val subjectType = bindingContext[BindingContext.EXPRESSION_TYPE, subject] ?: return null
|
val subjectType = bindingContext[BindingContext.EXPRESSION_TYPE, subject] ?: return null
|
||||||
return listOf(ExpectedInfo(subjectType, null))
|
return listOf(ExpectedInfo(subjectType, null, null))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null))
|
return listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null, null))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateForExclOperand(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
private fun calculateForExclOperand(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
||||||
val prefixExpression = expressionWithType.getParent() as? JetPrefixExpression ?: return null
|
val prefixExpression = expressionWithType.getParent() as? JetPrefixExpression ?: return null
|
||||||
if (prefixExpression.getOperationToken() != JetTokens.EXCL) 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<ExpectedInfo>? {
|
private fun getFromBindingContext(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
|
||||||
val expectedType = bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, expressionWithType] ?: return null
|
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
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ object LambdaItems {
|
|||||||
val lookupElement = LookupElementBuilder.create("{...}")
|
val lookupElement = LookupElementBuilder.create("{...}")
|
||||||
.withInsertHandler(ArtificialElementInsertHandler("{ ", " }", false))
|
.withInsertHandler(ArtificialElementInsertHandler("{ ", " }", false))
|
||||||
.suppressAutoInsertion()
|
.suppressAutoInsertion()
|
||||||
.addTail(functionExpectedInfos)
|
.addTailAndNameSimilarity(functionExpectedInfos)
|
||||||
lookupElement.putUserData(JetCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
lookupElement.putUserData(JetCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
||||||
collection.add(lookupElement)
|
collection.add(lookupElement)
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ object LambdaItems {
|
|||||||
insertLambdaTemplate(context, TextRange(offset, offset + placeholder.length), functionType)
|
insertLambdaTemplate(context, TextRange(offset, offset + placeholder.length), functionType)
|
||||||
})
|
})
|
||||||
.suppressAutoInsertion()
|
.suppressAutoInsertion()
|
||||||
.addTail(functionExpectedInfos.filter { it.`type` == functionType })
|
.addTailAndNameSimilarity(functionExpectedInfos.filter { it.`type` == functionType })
|
||||||
lookupElement.putUserData(JetCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
lookupElement.putUserData(JetCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
||||||
collection.add(lookupElement)
|
collection.add(lookupElement)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<Int>("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<ExpectedInfo>): 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
|
||||||
|
}
|
||||||
@@ -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
|
// 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))
|
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
|
else
|
||||||
filteredExpectedInfos
|
filteredExpectedInfos
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
|
|||||||
if (originalDeclaration != null) {
|
if (originalDeclaration != null) {
|
||||||
val originalDescriptor = originalDeclaration.getLazyResolveSession().resolveToDescriptor(originalDeclaration) as? CallableDescriptor
|
val originalDescriptor = originalDeclaration.getLazyResolveSession().resolveToDescriptor(originalDeclaration) as? CallableDescriptor
|
||||||
val returnType = originalDescriptor?.getReturnType()
|
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) {
|
if (descriptor is SimpleFunctionDescriptor) {
|
||||||
@@ -281,7 +281,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
|
|||||||
val items = ArrayList<LookupElement>()
|
val items = ArrayList<LookupElement>()
|
||||||
for ((jetType, infos) in expectedInfosGrouped) {
|
for ((jetType, infos) in expectedInfosGrouped) {
|
||||||
val lookupElement = lookupElementForType(jetType) ?: continue
|
val lookupElement = lookupElementForType(jetType) ?: continue
|
||||||
items.add(lookupElement.addTail(infos))
|
items.add(lookupElement.addTailAndNameSimilarity(infos))
|
||||||
}
|
}
|
||||||
return Result(null, items)
|
return Result(null, items)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import org.jetbrains.jet.lang.psi.JetFile
|
|||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||||
import java.util.HashSet
|
import java.util.HashSet
|
||||||
import com.intellij.codeInsight.lookup.LookupElementDecorator
|
import com.intellij.codeInsight.lookup.LookupElementDecorator
|
||||||
import com.intellij.codeInsight.lookup.AutoCompletionPolicy
|
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.jet.lang.types.JetType
|
import org.jetbrains.jet.lang.types.JetType
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
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 com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import org.jetbrains.jet.plugin.completion.*
|
import org.jetbrains.jet.plugin.completion.*
|
||||||
import com.intellij.openapi.util.Key
|
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.jet.plugin.project.ResolveSessionForBodies
|
import org.jetbrains.jet.plugin.project.ResolveSessionForBodies
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
|
||||||
import org.jetbrains.jet.plugin.completion.handlers.WithTailInsertHandler
|
import org.jetbrains.jet.plugin.completion.handlers.WithTailInsertHandler
|
||||||
|
|
||||||
class ArtificialElementInsertHandler(
|
class ArtificialElementInsertHandler(
|
||||||
@@ -87,8 +84,14 @@ fun LookupElement.addTail(tail: Tail?): LookupElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LookupElement.addTail(matchedExpectedInfos: Collection<ExpectedInfo>): LookupElement
|
fun LookupElement.addTailAndNameSimilarity(matchedExpectedInfos: Collection<ExpectedInfo>): LookupElement {
|
||||||
= addTail(mergeTails(matchedExpectedInfos.map { it.tail }))
|
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 {
|
enum class ExpectedInfoClassification {
|
||||||
MATCHES
|
MATCHES
|
||||||
@@ -111,7 +114,7 @@ fun MutableCollection<LookupElement>.addLookupElements(expectedInfos: Collection
|
|||||||
if (matchedInfos.isNotEmpty()) {
|
if (matchedInfos.isNotEmpty()) {
|
||||||
val lookupElement = lookupElementFactory()
|
val lookupElement = lookupElementFactory()
|
||||||
if (lookupElement != null) {
|
if (lookupElement != null) {
|
||||||
add(lookupElement.addTail(matchedInfos))
|
add(lookupElement.addTailAndNameSimilarity(matchedInfos))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (matchedInfosNotNullable.isNotEmpty()) {
|
else if (matchedInfosNotNullable.isNotEmpty()) {
|
||||||
@@ -132,7 +135,7 @@ fun MutableCollection<LookupElement>.addLookupElementsForNullable(factory: () ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lookupElement = lookupElement!!.suppressAutoInsertion()
|
lookupElement = lookupElement!!.suppressAutoInsertion()
|
||||||
add(lookupElement!!.addTail(matchedInfos))
|
add(lookupElement!!.addTailAndNameSimilarity(matchedInfos))
|
||||||
}
|
}
|
||||||
|
|
||||||
lookupElement = factory()
|
lookupElement = factory()
|
||||||
@@ -147,7 +150,7 @@ fun MutableCollection<LookupElement>.addLookupElementsForNullable(factory: () ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lookupElement = lookupElement!!.suppressAutoInsertion()
|
lookupElement = lookupElement!!.suppressAutoInsertion()
|
||||||
add(lookupElement!!.addTail(matchedInfos))
|
add(lookupElement!!.addTailAndNameSimilarity(matchedInfos))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun f(fooBar: String){}
|
||||||
|
|
||||||
|
fun g(a: String, bar: String, fooBar: String) {
|
||||||
|
f(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: fooBar, bar, a
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun f(fooBar: String){}
|
||||||
|
|
||||||
|
fun g(fooA: String, someBar: String, fooBar: String, fooStuff: String) {
|
||||||
|
f(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: fooBar, someBar, fooA, fooStuff
|
||||||
@@ -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(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: fooBar1, fooBar, fooBar0, fooBar2, someBar1, someBar0, someBar2
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
val id = ""
|
||||||
|
val p = ""
|
||||||
|
val p1 = ""
|
||||||
|
|
||||||
|
fun g(zone: java.util.TimeZone) {
|
||||||
|
val local = ""
|
||||||
|
zone.setID(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: local, id, p, p1
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun f(fooBar: String){}
|
||||||
|
|
||||||
|
fun g(b: Boolean, a: String, foo: String, bar: String) {
|
||||||
|
f(if (b) { <caret> })
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: bar, foo, a
|
||||||
@@ -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 <caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: bar, foo, aaa, aaa1
|
||||||
@@ -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() ?: <caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: bar, foo, aaa
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
var fooBar1 = ""
|
||||||
|
var fooBar2 = ""
|
||||||
|
|
||||||
|
fun f(s: String){
|
||||||
|
if (fooBar1 == <caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: fooBar2, s
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class C {
|
||||||
|
var fooBar = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
var fooBar = ""
|
||||||
|
|
||||||
|
fun f(s: String, c: C){
|
||||||
|
if (c.fooBar == <caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: fooBar, s
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
var fooBar = ""
|
||||||
|
|
||||||
|
object C {
|
||||||
|
fun getFooBar() = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f(s: String){
|
||||||
|
if (C.getFooBar() == <caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: fooBar, s
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
var fooBar = ""
|
||||||
|
|
||||||
|
fun f(s: String, bars: List<String>){
|
||||||
|
if (bars[0] == <caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: fooBar, s
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun f(fooBar: String){}
|
||||||
|
|
||||||
|
fun g(b: Boolean, a: String, foo: String, bar: String) {
|
||||||
|
f(if (b) <caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: bar, foo, a
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
class A(s: String) {
|
||||||
|
val substring = s.<caret>capitalize()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: substring
|
||||||
@@ -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(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ORDER: localBar, globalBar, localX, globalX
|
||||||
@@ -17,10 +17,13 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
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.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.InnerTestClasses;
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
import org.junit.runner.RunWith;
|
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ import org.jetbrains.jet.InTextDirectivesUtils
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
||||||
import org.testng.Assert
|
import org.testng.Assert
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
|
||||||
import org.jetbrains.jet.test.util.configureWithExtraFile
|
import org.jetbrains.jet.test.util.configureWithExtraFile
|
||||||
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase
|
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) {
|
fun doTest(path: String) {
|
||||||
myFixture.configureWithExtraFile(path)
|
myFixture.configureWithExtraFile(path)
|
||||||
|
|
||||||
@@ -34,12 +35,18 @@ public abstract class AbstractCompletionWeigherTest() : JetLightCodeInsightFixtu
|
|||||||
val items = InTextDirectivesUtils.findArrayWithPrefixes(text, "// ORDER:")
|
val items = InTextDirectivesUtils.findArrayWithPrefixes(text, "// ORDER:")
|
||||||
Assert.assertTrue(!items.isEmpty(), """Some items should be defined with "// ORDER:" directive""")
|
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)
|
myFixture.assertPreferredCompletionItems(InTextDirectivesUtils.getPrefixedInt(text, "// SELECTED:") ?: 0, *items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||||
|
return JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
|
}
|
||||||
|
|
||||||
protected override fun getTestDataPath() : String? {
|
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")
|
||||||
|
|||||||
+14
-14
@@ -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 */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("idea/testData/completion/weighers")
|
@TestMetadata("idea/testData/completion/weighers/basic")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class)
|
@RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class)
|
||||||
public class CompletionWeigherTestGenerated extends AbstractCompletionWeigherTest {
|
public class BasicCompletionWeigherTestGenerated extends AbstractBasicCompletionWeigherTest {
|
||||||
public void testAllFilesPresentInWeighers() throws Exception {
|
public void testAllFilesPresentInBasic() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/weighers"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/weighers/basic"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("DeprecatedFun.kt")
|
@TestMetadata("DeprecatedFun.kt")
|
||||||
public void testDeprecatedFun() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("ExactMatchForKeyword.kt")
|
@TestMetadata("ExactMatchForKeyword.kt")
|
||||||
public void testExactMatchForKeyword() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("KeywordsLast.kt")
|
@TestMetadata("KeywordsLast.kt")
|
||||||
public void testKeywordsLast() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("LocalFileBeforeImported.kt")
|
@TestMetadata("LocalFileBeforeImported.kt")
|
||||||
public void testLocalFileBeforeImported() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("LocalValuesAndParams.kt")
|
@TestMetadata("LocalValuesAndParams.kt")
|
||||||
public void testLocalValuesAndParams() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("LocalsBeforeKeywords.kt")
|
@TestMetadata("LocalsBeforeKeywords.kt")
|
||||||
public void testLocalsBeforeKeywords() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("LocalsPropertiesKeywords.kt")
|
@TestMetadata("LocalsPropertiesKeywords.kt")
|
||||||
public void testLocalsPropertiesKeywords() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("NamedParameters.kt")
|
@TestMetadata("NamedParameters.kt")
|
||||||
public void testNamedParameters() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("ParametersBeforeKeywords.kt")
|
@TestMetadata("ParametersBeforeKeywords.kt")
|
||||||
public void testParametersBeforeKeywords() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("PropertiesBeforeKeywords.kt")
|
@TestMetadata("PropertiesBeforeKeywords.kt")
|
||||||
public void testPropertiesBeforeKeywords() throws Exception {
|
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);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
+125
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user