FIR IDE: render short names as for completion lookup element types
This commit is contained in:
committed by
TeamCityServer
parent
a718a2c2d8
commit
f7cf80b8e9
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import a.O.uniqueName
|
import a.O.uniqueName
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
class Test : java.lang.A<caret>
|
class Test : java.lang.A<caret>
|
||||||
|
|
||||||
// ABSENT: Annotation
|
// ABSENT: Annotation
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
@kotlin.concurrent.<caret>
|
@kotlin.concurrent.<caret>
|
||||||
|
|
||||||
// INVOCATION_COUNT: 2
|
// INVOCATION_COUNT: 2
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
annotation class Anno
|
annotation class Anno
|
||||||
typealias TypedAnno = Anno
|
typealias TypedAnno = Anno
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
class C
|
class C
|
||||||
|
|
||||||
fun C.test(foo: C.() -> Unit) {
|
fun C.test(foo: C.() -> Unit) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
fun foo(xxx: String) {
|
fun foo(xxx: String) {
|
||||||
var xxx: Int = xx<caret>
|
var xxx: Int = xx<caret>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
fun foo(xxx: Int) {
|
fun foo(xxx: Int) {
|
||||||
val xxx: Any = run {
|
val xxx: Any = run {
|
||||||
xx<caret>
|
xx<caret>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
class C {
|
class C {
|
||||||
val xxx = 1
|
val xxx = 1
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
class C {
|
class C {
|
||||||
val xxx = 1
|
val xxx = 1
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
class C {
|
class C {
|
||||||
inner class Inner {
|
inner class Inner {
|
||||||
fun foo() {
|
fun foo() {
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
interface I<T> {
|
interface I<T> {
|
||||||
fun xxx(): T
|
fun xxx(): T
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
open class C<T> {
|
open class C<T> {
|
||||||
fun foo(t: T): T = t
|
fun foo(t: T): T = t
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
open class Base {
|
open class Base {
|
||||||
open fun foo(p: Int){}
|
open fun foo(p: Int){}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
open class Base {
|
open class Base {
|
||||||
open fun foo(p: Int){}
|
open fun foo(p: Int){}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.idea.completion.handlers.isTextAt
|
|||||||
import org.jetbrains.kotlin.idea.core.asFqNameWithRootPrefixIfNeeded
|
import org.jetbrains.kotlin.idea.core.asFqNameWithRootPrefixIfNeeded
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession
|
import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.analyse
|
import org.jetbrains.kotlin.idea.frontend.api.analyse
|
||||||
|
import org.jetbrains.kotlin.idea.frontend.api.components.KtTypeRendererOptions
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.fir.utils.addImportToFile
|
import org.jetbrains.kotlin.idea.frontend.api.fir.utils.addImportToFile
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.*
|
import org.jetbrains.kotlin.idea.frontend.api.symbols.*
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtNamedSymbol
|
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtNamedSymbol
|
||||||
@@ -119,7 +120,7 @@ private class VariableLookupElementFactory {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return LookupElementBuilder.create(lookupObject, symbol.name.asString())
|
return LookupElementBuilder.create(lookupObject, symbol.name.asString())
|
||||||
.withTypeText(symbol.annotatedType.type.render())
|
.withTypeText(symbol.annotatedType.type.render(WITH_TYPE_RENDERING_OPTIONS))
|
||||||
.markIfSyntheticJavaProperty(symbol)
|
.markIfSyntheticJavaProperty(symbol)
|
||||||
.withInsertHandler(VariableInsertionHandler)
|
.withInsertHandler(VariableInsertionHandler)
|
||||||
}
|
}
|
||||||
@@ -163,7 +164,7 @@ private class FunctionLookupElementFactory {
|
|||||||
return try {
|
return try {
|
||||||
LookupElementBuilder.create(lookupObject, symbol.name.asString())
|
LookupElementBuilder.create(lookupObject, symbol.name.asString())
|
||||||
.withTailText(getTailText(symbol), true)
|
.withTailText(getTailText(symbol), true)
|
||||||
.withTypeText(symbol.annotatedType.type.render())
|
.withTypeText(symbol.annotatedType.type.render(WITH_TYPE_RENDERING_OPTIONS))
|
||||||
.withInsertHandler(FunctionInsertionHandler)
|
.withInsertHandler(FunctionInsertionHandler)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
if (e is ControlFlowException) throw e
|
if (e is ControlFlowException) throw e
|
||||||
@@ -198,6 +199,8 @@ private class FunctionLookupElementFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val WITH_TYPE_RENDERING_OPTIONS = KtTypeRendererOptions.SHORT_NAMES
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The simplest implementation of the insertion handler for a classifiers.
|
* The simplest implementation of the insertion handler for a classifiers.
|
||||||
*/
|
*/
|
||||||
@@ -399,7 +402,7 @@ private object ShortNamesRenderer {
|
|||||||
function.valueParameters.joinToString(", ", "(", ")") { renderFunctionParameter(it) }
|
function.valueParameters.joinToString(", ", "(", ")") { renderFunctionParameter(it) }
|
||||||
|
|
||||||
private fun KtAnalysisSession.renderFunctionParameter(param: KtValueParameterSymbol): String =
|
private fun KtAnalysisSession.renderFunctionParameter(param: KtValueParameterSymbol): String =
|
||||||
"${if (param.isVararg) "vararg " else ""}${param.name.asString()}: ${param.annotatedType.type.render()}"
|
"${if (param.isVararg) "vararg " else ""}${param.name.asString()}: ${param.annotatedType.type.render(WITH_TYPE_RENDERING_OPTIONS)}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user