Minor code corrections on code review
This commit is contained in:
Generated
+1
@@ -11,6 +11,7 @@
|
|||||||
<w>rbracket</w>
|
<w>rbracket</w>
|
||||||
<w>rparenth</w>
|
<w>rparenth</w>
|
||||||
<w>selectioner</w>
|
<w>selectioner</w>
|
||||||
|
<w>unpluralize</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
</component>
|
</component>
|
||||||
@@ -33,7 +33,7 @@ public fun JetScope.getImplicitReceiversWithInstance(): List<ReceiverParameterDe
|
|||||||
var current: DeclarationDescriptor? = getContainingDeclaration()
|
var current: DeclarationDescriptor? = getContainingDeclaration()
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
if (current is PropertyAccessorDescriptor) {
|
if (current is PropertyAccessorDescriptor) {
|
||||||
current = (current as PropertyAccessorDescriptor).getCorrespondingProperty()
|
current = current.getCorrespondingProperty()
|
||||||
}
|
}
|
||||||
withInstance.add(current)
|
withInstance.add(current)
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.completion
|
package org.jetbrains.kotlin.idea.completion
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.text.StringUtil
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.di.InjectorForMacros
|
import org.jetbrains.kotlin.di.InjectorForMacros
|
||||||
@@ -185,7 +186,7 @@ class ExpectedInfos(
|
|||||||
if (isFunctionLiteralArgument) continue
|
if (isFunctionLiteralArgument) continue
|
||||||
|
|
||||||
if (argumentName == null) {
|
if (argumentName == null) {
|
||||||
expectedInfos.add(ArgumentExpectedInfo(varargElementType, expectedName?.fromPlural(), null, descriptor, argumentPosition))
|
expectedInfos.add(ArgumentExpectedInfo(varargElementType, expectedName?.unpluralize(), null, descriptor, argumentPosition))
|
||||||
|
|
||||||
if (argumentIndex == parameters.indexOf(parameter)) {
|
if (argumentIndex == parameters.indexOf(parameter)) {
|
||||||
val tail = if (parameter == parameters.last()) Tail.RPARENTH else null
|
val tail = if (parameter == parameters.last()) Tail.RPARENTH else null
|
||||||
@@ -194,7 +195,7 @@ class ExpectedInfos(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val tail = namedArgumentTail(argumentToParameter, argumentName, descriptor)
|
val tail = namedArgumentTail(argumentToParameter, argumentName, descriptor)
|
||||||
expectedInfos.add(ArgumentExpectedInfo(varargElementType, expectedName?.fromPlural(), tail, descriptor, argumentPosition))
|
expectedInfos.add(ArgumentExpectedInfo(varargElementType, expectedName?.unpluralize(), tail, descriptor, argumentPosition))
|
||||||
expectedInfos.add(ArgumentExpectedInfo(parameter.getType(), expectedName, tail, descriptor, argumentPosition, ItemOptions.STAR_PREFIX))
|
expectedInfos.add(ArgumentExpectedInfo(parameter.getType(), expectedName, tail, descriptor, argumentPosition, ItemOptions.STAR_PREFIX))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,11 +380,11 @@ class ExpectedInfos(
|
|||||||
is JetSimpleNameExpression -> expression.getReferencedName()
|
is JetSimpleNameExpression -> expression.getReferencedName()
|
||||||
is JetQualifiedExpression -> expectedNameFromExpression(expression.getSelectorExpression())
|
is JetQualifiedExpression -> expectedNameFromExpression(expression.getSelectorExpression())
|
||||||
is JetCallExpression -> expectedNameFromExpression(expression.getCalleeExpression())
|
is JetCallExpression -> expectedNameFromExpression(expression.getCalleeExpression())
|
||||||
is JetArrayAccessExpression -> expectedNameFromExpression(expression.getArrayExpression())?.fromPlural()
|
is JetArrayAccessExpression -> expectedNameFromExpression(expression.getArrayExpression())?.unpluralize()
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.fromPlural()
|
private fun String.unpluralize()
|
||||||
= if (endsWith("s")) substring(0, length() - 1) else this
|
= StringUtil.unpluralize(this)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user