Use of substringBefore/After
This commit is contained in:
@@ -286,8 +286,7 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
addReferenceVariants(kindFilter, runtimeReceiverType = false)
|
addReferenceVariants(kindFilter, runtimeReceiverType = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val ampIndex = prefix.indexOf("@")
|
val keywordsPrefix = prefix.substringBefore('@') // if there is '@' in the prefix - use shorter prefix to not loose 'this' etc
|
||||||
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
|
|
||||||
KeywordCompletion.complete(expression ?: parameters.getPosition(), keywordsPrefix) { lookupElement ->
|
KeywordCompletion.complete(expression ?: parameters.getPosition(), keywordsPrefix) { lookupElement ->
|
||||||
val keyword = lookupElement.getLookupString()
|
val keyword = lookupElement.getLookupString()
|
||||||
when (keyword) {
|
when (keyword) {
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ public class LookupElementFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val qualifiedName = psiClass.getQualifiedName()!!
|
val qualifiedName = psiClass.getQualifiedName()!!
|
||||||
val dotIndex = qualifiedName.lastIndexOf('.')
|
val packageName = qualifiedName.substringBeforeLast('.', "<root>")
|
||||||
val packageName = if (dotIndex <= 0) "<root>" else qualifiedName.substring(0, dotIndex)
|
|
||||||
element = element.appendTailText(" ($packageName)", true)
|
element = element.appendTailText(" ($packageName)", true)
|
||||||
|
|
||||||
if (psiClass.isDeprecated()) {
|
if (psiClass.isDeprecated()) {
|
||||||
|
|||||||
@@ -136,15 +136,9 @@ public abstract class AbstractJavaToKotlinConverterSingleFileTest : AbstractJava
|
|||||||
override fun getProjectDescriptor()
|
override fun getProjectDescriptor()
|
||||||
= JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
= JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
|
|
||||||
private fun String.removeFirstLine(): String {
|
private fun String.removeFirstLine() = substringAfter('\n', "")
|
||||||
val lastNewLine = indexOf('\n')
|
|
||||||
return if (lastNewLine == -1) "" else substring(lastNewLine)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun String.removeLastLine(): String {
|
private fun String.removeLastLine() = substringBeforeLast('\n', "")
|
||||||
val lastNewLine = lastIndexOf('\n')
|
|
||||||
return if (lastNewLine == -1) "" else substring(0, lastNewLine)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createJavaFile(text: String): PsiJavaFile {
|
private fun createJavaFile(text: String): PsiJavaFile {
|
||||||
return myFixture.configureByText("converterTestFile.java", text) as PsiJavaFile
|
return myFixture.configureByText("converterTestFile.java", text) as PsiJavaFile
|
||||||
|
|||||||
Reference in New Issue
Block a user