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
|
||||
|
||||
import a.O.uniqueName
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
class Test : java.lang.A<caret>
|
||||
|
||||
// ABSENT: Annotation
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
@kotlin.concurrent.<caret>
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
annotation class Anno
|
||||
typealias TypedAnno = Anno
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
class C
|
||||
|
||||
fun C.test(foo: C.() -> Unit) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun foo(xxx: String) {
|
||||
var xxx: Int = xx<caret>
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun foo(xxx: Int) {
|
||||
val xxx: Any = run {
|
||||
xx<caret>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
class C {
|
||||
val xxx = 1
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
class C {
|
||||
val xxx = 1
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
class C {
|
||||
inner class Inner {
|
||||
fun foo() {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
interface I<T> {
|
||||
fun xxx(): T
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
open class C<T> {
|
||||
fun foo(t: T): T = t
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
open class Base {
|
||||
open fun foo(p: Int){}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
open class Base {
|
||||
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.frontend.api.KtAnalysisSession
|
||||
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.symbols.*
|
||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtNamedSymbol
|
||||
@@ -119,7 +120,7 @@ private class VariableLookupElementFactory {
|
||||
)
|
||||
|
||||
return LookupElementBuilder.create(lookupObject, symbol.name.asString())
|
||||
.withTypeText(symbol.annotatedType.type.render())
|
||||
.withTypeText(symbol.annotatedType.type.render(WITH_TYPE_RENDERING_OPTIONS))
|
||||
.markIfSyntheticJavaProperty(symbol)
|
||||
.withInsertHandler(VariableInsertionHandler)
|
||||
}
|
||||
@@ -163,7 +164,7 @@ private class FunctionLookupElementFactory {
|
||||
return try {
|
||||
LookupElementBuilder.create(lookupObject, symbol.name.asString())
|
||||
.withTailText(getTailText(symbol), true)
|
||||
.withTypeText(symbol.annotatedType.type.render())
|
||||
.withTypeText(symbol.annotatedType.type.render(WITH_TYPE_RENDERING_OPTIONS))
|
||||
.withInsertHandler(FunctionInsertionHandler)
|
||||
} catch (e: Throwable) {
|
||||
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.
|
||||
*/
|
||||
@@ -399,7 +402,7 @@ private object ShortNamesRenderer {
|
||||
function.valueParameters.joinToString(", ", "(", ")") { renderFunctionParameter(it) }
|
||||
|
||||
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