Use of substringBefore/After

This commit is contained in:
Valentin Kipyatkov
2015-03-04 18:49:42 +03:00
parent 2ef80d1b34
commit efa83000a2
3 changed files with 4 additions and 12 deletions
@@ -286,8 +286,7 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
addReferenceVariants(kindFilter, runtimeReceiverType = false)
}
val ampIndex = prefix.indexOf("@")
val keywordsPrefix = if (ampIndex < 0) prefix else prefix.substring(0, ampIndex) // if there is '@' in the prefix - use shorter prefix to not loose 'this' etc
val keywordsPrefix = prefix.substringBefore('@') // if there is '@' in the prefix - use shorter prefix to not loose 'this' etc
KeywordCompletion.complete(expression ?: parameters.getPosition(), keywordsPrefix) { lookupElement ->
val keyword = lookupElement.getLookupString()
when (keyword) {
@@ -110,8 +110,7 @@ public class LookupElementFactory(
}
val qualifiedName = psiClass.getQualifiedName()!!
val dotIndex = qualifiedName.lastIndexOf('.')
val packageName = if (dotIndex <= 0) "<root>" else qualifiedName.substring(0, dotIndex)
val packageName = qualifiedName.substringBeforeLast('.', "<root>")
element = element.appendTailText(" ($packageName)", true)
if (psiClass.isDeprecated()) {