Smart completion: fix anonymous object code style (KT-29572)

#KT-29572 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-03-09 03:15:37 +03:00
committed by Nikolay Krasko
parent 6acf3ad629
commit fd262bcd8d
31 changed files with 50 additions and 50 deletions
@@ -185,13 +185,13 @@ class TypeInstantiationItems(
val constructorParenthesis = if (classifier.kind != ClassKind.INTERFACE) "()" else ""
itemText += constructorParenthesis
itemText = "object: $itemText{...}"
itemText = "object : $itemText{...}"
lookupString = "object"
allLookupStrings = setOf(lookupString, lookupElement.lookupString)
insertHandler = InsertHandler<LookupElement> { context, _ ->
val startOffset = context.startOffset
val text1 = "object: $typeText"
val text1 = "object : $typeText"
val text2 = "$constructorParenthesis {}"
val text = if (allTypeArgsKnown)
text1 + IdeDescriptorRenderers.SOURCE_CODE.renderTypeArguments(typeArgsToUse) + text2
@@ -1,5 +1,5 @@
fun<T> f(){
JavaClass<T>(object: Comparator<T> {
JavaClass<T>(object : Comparator<T> {
override fun compare(var1: T, var2: T): Int {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,5 +1,5 @@
interface Foo
var a : Foo = object: Foo {<caret>}
var a : Foo = object : Foo {<caret>}
//ELEMENT: object
@@ -1,5 +1,5 @@
abstract class Foo
var a : Foo = object: Foo() {<caret>}
var a : Foo = object : Foo() {<caret>}
//ELEMENT: object
@@ -1,4 +1,4 @@
var r : Runnable = object: Runnable {
var r : Runnable = object : Runnable {
override fun run() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,3 +1,3 @@
val c: java.io.Closeable = <caret>
//ELEMENT_TEXT: "object: Closeable{...}"
//ELEMENT_TEXT: "object : Closeable{...}"
@@ -1,9 +1,9 @@
import java.io.Closeable
val c: java.io.Closeable = object: Closeable {
val c: java.io.Closeable = object : Closeable {
override fun close() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
//ELEMENT_TEXT: "object: Closeable{...}"
//ELEMENT_TEXT: "object : Closeable{...}"
@@ -3,7 +3,7 @@ interface A<T>
fun <T> foo(a: A<T>){}
fun g() {
foo(object: A<<caret>> {})
foo(object : A<<caret>> {})
}
// ELEMENT: object
@@ -3,7 +3,7 @@ interface Foo
fun foo(f: Foo, i: Int){}
fun bar() {
foo(object: Foo {<caret>}, )
foo(object : Foo {<caret>}, )
}
//ELEMENT: object
@@ -1,7 +1,7 @@
fun registerHandler(handler: Handler<out Message>) {}
fun test() {
registerHandler(object: Handler<Message> {
registerHandler(object : Handler<Message> {
override fun handle(e: Message) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+1 -1
View File
@@ -2,6 +2,6 @@ import java.util.Comparator
var v: Comparator<String> = <caret>
// EXIST: { itemText: "object: Comparator<String>{...}" }
// EXIST: { itemText: "object : Comparator<String>{...}" }
// EXIST: { lookupString: "Comparator", itemText: "Comparator", tailText: "(function: (T!, T!) -> Int) (java.util)", typeText: "Comparator<T>" }
// EXIST: { lookupString: "Comparator", itemText: "Comparator", tailText: " { T, T -> ... } (function: (T!, T!) -> Int) (java.util)", typeText: "Comparator<T>" }
+1 -1
View File
@@ -3,4 +3,4 @@ interface Foo
var a : Foo = <caret>
// ABSENT: Foo
// EXIST: { lookupString:"object", itemText:"object: Foo{...}" }
// EXIST: { lookupString:"object", itemText:"object : Foo{...}" }
+1 -1
View File
@@ -3,4 +3,4 @@ abstract class Foo
var a : Foo = <caret>
// ABSENT: Foo
// EXIST: { lookupString:"object", itemText:"object: Foo(){...}" }
// EXIST: { lookupString:"object", itemText:"object : Foo(){...}" }
@@ -1,4 +1,4 @@
var a : Appendable = <caret>
// ABSENT: Appendable
// EXIST: { lookupString:"object", itemText:"object: Appendable{...}" }
// EXIST: { lookupString:"object", itemText:"object : Appendable{...}" }
@@ -6,4 +6,4 @@ fun g() {
foo(<caret>)
}
// EXIST: { lookupString:"object", itemText:"object: A<...>{...}" }
// EXIST: { lookupString:"object", itemText:"object : A<...>{...}" }
@@ -2,4 +2,4 @@ interface Foo
var a : Foo = o<caret>
// EXIST: { lookupString:"object", itemText:"object: Foo{...}" }
// EXIST: { lookupString:"object", itemText:"object : Foo{...}" }
@@ -3,4 +3,4 @@ abstract class Foo protected()
var a : Foo = <caret>
// ABSENT: Foo
// EXIST: { lookupString:"object", itemText:"object: Foo(){...}" }
// EXIST: { lookupString:"object", itemText:"object : Foo(){...}" }
@@ -12,9 +12,9 @@ fun bar() {
foo(<caret>)
}
// EXIST: { itemText: "object: I<Int>{...}" }
// EXIST: { itemText: "object: C1<Int>(){...}" }
// EXIST: { itemText: "object: C3(){...}" }
// EXIST: { itemText: "object : I<Int>{...}" }
// EXIST: { itemText: "object : C1<Int>(){...}" }
// EXIST: { itemText: "object : C3(){...}" }
// EXIST: { itemText: "C4", tailText: "(t: Int) (<root>)" }
// EXIST: { itemText: "C5", tailText: "(t1: T1, t2: Int) (<root>)" }
// NOTHING_ELSE
@@ -10,10 +10,10 @@ fun bar() {
foo(<caret>)
}
// EXIST: { itemText: "object: I<...>{...}" }
// EXIST: { itemText: "object: C1<...>(){...}" }
// EXIST: { itemText: "object: C2(){...}" }
// EXIST: { itemText: "object: C3(){...}" }
// EXIST: { itemText: "object : I<...>{...}" }
// EXIST: { itemText: "object : C1<...>(){...}" }
// EXIST: { itemText: "object : C2(){...}" }
// EXIST: { itemText: "object : C3(){...}" }
// all these items shouldn't be proposed, see KT-15479
// EXIST: { itemText: "enumValueOf" }
@@ -11,10 +11,10 @@ fun bar() {
foo(<caret>)
}
// EXIST: { itemText: "object: I<...>{...}" }
// EXIST: { itemText: "object: C1<...>(){...}" }
// EXIST: { itemText: "object: C2(){...}" }
// EXIST: { itemText: "object: C4<String>(){...}" }
// EXIST: { itemText: "object : I<...>{...}" }
// EXIST: { itemText: "object : C1<...>(){...}" }
// EXIST: { itemText: "object : C2(){...}" }
// EXIST: { itemText: "object : C4<String>(){...}" }
// all these items shouldn't be proposed, see KT-15479
// EXIST: { itemText: "enumValueOf" }
@@ -8,8 +8,8 @@ fun bar() {
foo(<caret>)
}
// EXIST: { itemText: "object: I<...>{...}" }
// EXIST: { itemText: "object: C<...>(){...}" }
// EXIST: { itemText: "object : I<...>{...}" }
// EXIST: { itemText: "object : C<...>(){...}" }
// all these items shouldn't be proposed, see KT-15479
// EXIST: { itemText: "enumValueOf" }
@@ -8,6 +8,6 @@ fun bar() {
foo(<caret>)
}
// EXIST: { itemText: "object: I<String>{...}" }
// EXIST: { itemText: "object: C<...>(){...}" }
// EXIST: { itemText: "object : I<String>{...}" }
// EXIST: { itemText: "object : C<...>(){...}" }
// NOTHING_ELSE
@@ -14,9 +14,9 @@ fun bar() {
foo(<caret>)
}
// EXIST: { itemText: "object: I<...>{...}" }
// EXIST: { itemText: "object: C1<X>(){...}" }
// EXIST: { itemText: "object: C2(){...}" }
// EXIST: { itemText: "object : I<...>{...}" }
// EXIST: { itemText: "object : C1<X>(){...}" }
// EXIST: { itemText: "object : C2(){...}" }
// all these items shouldn't be proposed, see KT-15479
// EXIST: { itemText: "enumValueOf" }
@@ -2,4 +2,4 @@ fun f(){
JavaClass<String>(<caret>)
}
// EXIST: { itemText: "object: Comparator<String?>{...}" }
// EXIST: { itemText: "object : Comparator<String?>{...}" }
@@ -4,11 +4,11 @@ fun foo(): KotlinTrait<I1, I2> {
return <caret>
}
// EXIST: { lookupString: "object", itemText: "object: KotlinTrait<I1, I2>{...}" }
// EXIST: { lookupString: "object", itemText: "object : KotlinTrait<I1, I2>{...}" }
// EXIST: { lookupString: "KotlinInheritor1", itemText: "KotlinInheritor1", tailText: "() (p)" }
// EXIST: { lookupString: "KotlinInheritor2", itemText: "KotlinInheritor2", tailText: "() (p)" }
// ABSENT: KotlinInheritor3
// EXIST: { lookupString: "object", itemText: "object: KotlinInheritor4<I1, I2>(){...}" }
// EXIST: { lookupString: "object", itemText: "object : KotlinInheritor4<I1, I2>(){...}" }
// ABSENT: KotlinInheritor5
// EXIST: { lookupString: "KotlinInheritor6", itemText: "KotlinInheritor6", tailText: "() (p)" }
// EXIST: { lookupString: "JavaInheritor1", itemText: "JavaInheritor1", tailText: "() (<root>)" }
@@ -4,5 +4,5 @@ fun foo(): KotlinTrait<I1, I1> {
return <caret>
}
// EXIST: { lookupString: "object", itemText: "object: KotlinTrait<I1, I1>{...}" }
// EXIST: { lookupString: "object", itemText: "object : KotlinTrait<I1, I1>{...}" }
// EXIST: { lookupString: "KotlinInheritor", itemText: "KotlinInheritor", tailText: "() (p)" }
@@ -4,5 +4,5 @@ fun foo(): KotlinTrait<I1, I2> {
return <caret>
}
// EXIST: { lookupString: "object", itemText: "object: KotlinTrait<I1, I2>{...}" }
// EXIST: { lookupString: "object", itemText: "object : KotlinTrait<I1, I2>{...}" }
// ABSENT: KotlinInheritor
@@ -4,5 +4,5 @@ fun foo(): KotlinTrait<I1<I2>> {
return <caret>
}
// EXIST: { lookupString: "object", itemText: "object: KotlinTrait<I1<I2>>{...}" }
// EXIST: { lookupString: "object", itemText: "object : KotlinTrait<I1<I2>>{...}" }
// EXIST: { lookupString: "KotlinInheritor", itemText: "KotlinInheritor", tailText: "() (p)" }
@@ -4,12 +4,12 @@ fun foo(): p2.KotlinTrait {
return <caret>
}
// EXIST: { lookupString: "object", itemText: "object: KotlinTrait{...}" }
// EXIST: { lookupString: "object", itemText: "object : KotlinTrait{...}" }
// EXIST: { lookupString: "KotlinInheritor1", itemText: "KotlinInheritor1", tailText: "() (p2)" }
// EXIST: { lookupString: "KotlinInheritor2", itemText: "KotlinInheritor2", tailText: "(s: String) (p2)" }
// EXIST: { lookupString: "object", itemText: "object: KotlinInheritor3(){...}" }
// EXIST: { lookupString: "object", itemText: "object : KotlinInheritor3(){...}" }
// ABSENT: PrivateInheritor
// EXIST: { lookupString: "object", itemText: "object: JavaInheritor1(){...}" }
// EXIST: { lookupString: "object", itemText: "object : JavaInheritor1(){...}" }
// EXIST: { lookupString: "JavaInheritor2", itemText: "JavaInheritor2", tailText: "(...) (<root>)" }
// ABSENT: JavaInheritor3
// EXIST: { lookupString: "ObjectInheritor", itemText: "ObjectInheritor", tailText: " (p2)" }
@@ -2,9 +2,9 @@ fun bar() {
foo(<caret>)
}
// EXIST: { lookupString: "object", itemText: "object: T1{...}" }
// EXIST: { lookupString: "object", itemText: "object: T2<X>{...}" }
// EXIST: { lookupString: "object", itemText: "object: T3<Y>{...}" }
// EXIST: { lookupString: "object", itemText: "object : T1{...}" }
// EXIST: { lookupString: "object", itemText: "object : T2<X>{...}" }
// EXIST: { lookupString: "object", itemText: "object : T3<Y>{...}" }
// EXIST: { lookupString: "C1", itemText: "C1" }
// EXIST: { lookupString: "C2", itemText: "C2" }
// EXIST: { lookupString: "C3", itemText: "C3" }
@@ -1,6 +1,6 @@
fun foo(): T = <caret>
// EXIST: foo
// EXIST: { lookupString: "object", itemText: "object: T{...}" }
// EXIST: { lookupString: "object", itemText: "object : T{...}" }
// EXIST: { lookupString: "OO", itemText: "OO", tailText: " (<root>)" }
// NOTHING_ELSE