Code Insight: Format generated declarations
#KT-11176 Fixed (cherry picked from commit 3641ad6)
This commit is contained in:
@@ -123,6 +123,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
|
|
||||||
###### Issues fixed
|
###### Issues fixed
|
||||||
|
|
||||||
|
- [`KT-11176`](https://youtrack.jetbrains.com/issue/KT-11176) Add a space before '{' in functions generated "Generate hashCode/equals/toString"
|
||||||
- [`KT-12294`](https://youtrack.jetbrains.com/issue/KT-12294) Introduce Property: Fix extraction of expressions referring to primary constructor parameters
|
- [`KT-12294`](https://youtrack.jetbrains.com/issue/KT-12294) Introduce Property: Fix extraction of expressions referring to primary constructor parameters
|
||||||
- [`KT-12413`](https://youtrack.jetbrains.com/issue/KT-12413) Change Signature: Fix bogus warning about unresolved type parameters/invalid functional type replacement
|
- [`KT-12413`](https://youtrack.jetbrains.com/issue/KT-12413) Change Signature: Fix bogus warning about unresolved type parameters/invalid functional type replacement
|
||||||
- [`KT-12084`](https://youtrack.jetbrains.com/issue/KT-12084) Introduce Property: Do not skip outer classes if extractable expression is contained in object literal
|
- [`KT-12084`](https://youtrack.jetbrains.com/issue/KT-12084) Introduce Property: Do not skip outer classes if extractable expression is contained in object literal
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import com.intellij.psi.PsiDocumentManager
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiWhiteSpace
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import com.intellij.psi.SmartPointerManager
|
import com.intellij.psi.SmartPointerManager
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import com.intellij.util.SmartList
|
import com.intellij.util.SmartList
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
|
||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
@@ -174,7 +174,7 @@ fun <T : KtDeclaration> insertMembersAfter(
|
|||||||
if (otherMembers.isNotEmpty()) {
|
if (otherMembers.isNotEmpty()) {
|
||||||
val body = classOrObject.getOrCreateBody()
|
val body = classOrObject.getOrCreateBody()
|
||||||
|
|
||||||
var afterAnchor = anchor ?: findInsertAfterAnchor(editor, body) ?: return@runWriteAction emptyList()
|
var afterAnchor = anchor ?: findInsertAfterAnchor(editor, body) ?: return@runWriteAction emptyList<T>()
|
||||||
otherMembers.mapNotNullTo(insertedMembers) {
|
otherMembers.mapNotNullTo(insertedMembers) {
|
||||||
if (classOrObject is KtClass && classOrObject.isEnum()) {
|
if (classOrObject is KtClass && classOrObject.isEnum()) {
|
||||||
val enumEntries = classOrObject.declarations.filterIsInstance<KtEnumEntry>()
|
val enumEntries = classOrObject.declarations.filterIsInstance<KtEnumEntry>()
|
||||||
@@ -204,6 +204,9 @@ fun <T : KtDeclaration> insertMembersAfter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
insertedMembers
|
insertedMembers
|
||||||
|
}.apply {
|
||||||
|
val codeStyleManager = CodeStyleManager.getInstance(classOrObject.project)
|
||||||
|
forEach { codeStyleManager.reformat(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ private class Visitor(var range: TextRange) : KtTreeVisitorVoid() {
|
|||||||
|
|
||||||
val nextEntry = declaration.nextSiblingOfSameType()
|
val nextEntry = declaration.nextSiblingOfSameType()
|
||||||
if (nextEntry != null && !declaration.containsToken(KtTokens.COMMA)) {
|
if (nextEntry != null && !declaration.containsToken(KtTokens.COMMA)) {
|
||||||
classBody.addAfter(comma, declaration)
|
declaration.add(comma)
|
||||||
delta += comma.textLength
|
delta += comma.textLength
|
||||||
}
|
}
|
||||||
|
|
||||||
val prevEntry = declaration.prevSiblingOfSameType()
|
val prevEntry = declaration.prevSiblingOfSameType()
|
||||||
if (prevEntry != null && !prevEntry.containsToken(KtTokens.COMMA)) {
|
if (prevEntry != null && !prevEntry.containsToken(KtTokens.COMMA)) {
|
||||||
classBody.addAfter(comma, prevEntry)
|
prevEntry.add(comma)
|
||||||
delta += comma.textLength
|
delta += comma.textLength
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
class A<T>(val n: T) {
|
class A<T>(val n: T) {
|
||||||
operator fun unaryPlus(): A<T> = throw Exception()
|
operator fun unaryPlus(): A<T> = throw Exception()
|
||||||
|
|
||||||
infix operator fun plus(t: T): A<T> {
|
infix operator fun plus(t: T): A<T> {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
class A<T>(val n: T) {
|
class A<T>(val n: T) {
|
||||||
fun plus(i: Int, s: String): A<T> = throw Exception()
|
fun plus(i: Int, s: String): A<T> = throw Exception()
|
||||||
|
|
||||||
infix operator fun plus(t: T): A<T> {
|
infix operator fun plus(t: T): A<T> {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
class A<T>(val n: T) {
|
class A<T>(val n: T) {
|
||||||
fun foo(a: Int): A<T> = throw Exception()
|
fun foo(a: Int): A<T> = throw Exception()
|
||||||
|
|
||||||
fun foo(a: T, s: String): A<T> {
|
fun foo(a: T, s: String): A<T> {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
class A<T>(val n: T) {
|
class A<T>(val n: T) {
|
||||||
fun foo(i: Int, s: String): A<T> = throw Exception()
|
fun foo(i: Int, s: String): A<T> = throw Exception()
|
||||||
|
|
||||||
fun foo(i: T): A<T> {
|
fun foo(i: T): A<T> {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -2,7 +2,6 @@
|
|||||||
class Foo<T> {
|
class Foo<T> {
|
||||||
operator fun component1(): Int { return 0 }
|
operator fun component1(): Int { return 0 }
|
||||||
operator fun component2(): Int { return 0 }
|
operator fun component2(): Int { return 0 }
|
||||||
|
|
||||||
operator fun component3(): Any {
|
operator fun component3(): Any {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -2,7 +2,6 @@
|
|||||||
class Foo<T> {
|
class Foo<T> {
|
||||||
operator fun component1(): Int { return 0 }
|
operator fun component1(): Int { return 0 }
|
||||||
operator fun component2(): Int { return 0 }
|
operator fun component2(): Int { return 0 }
|
||||||
|
|
||||||
operator fun component3(): String {
|
operator fun component3(): String {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -3,7 +3,6 @@ import kotlin.reflect.KProperty
|
|||||||
|
|
||||||
class F {
|
class F {
|
||||||
operator fun setValue(x: X, property: KProperty<*>, i: Int) { }
|
operator fun setValue(x: X, property: KProperty<*>, i: Int) { }
|
||||||
|
|
||||||
operator fun getValue(x: X, property: KProperty<*>): Int {
|
operator fun getValue(x: X, property: KProperty<*>): Int {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -3,7 +3,6 @@ import kotlin.reflect.KProperty
|
|||||||
|
|
||||||
class F {
|
class F {
|
||||||
operator fun getValue(x: X, property: KProperty<*>): Int = 1
|
operator fun getValue(x: X, property: KProperty<*>): Int = 1
|
||||||
|
|
||||||
operator fun setValue(x: X, property: KProperty<*>, i: Int) {
|
operator fun setValue(x: X, property: KProperty<*>, i: Int) {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -1,7 +1,6 @@
|
|||||||
// "Create member function 'next'" "true"
|
// "Create member function 'next'" "true"
|
||||||
class FooIterator<T> {
|
class FooIterator<T> {
|
||||||
operator fun hasNext(): Boolean { return false }
|
operator fun hasNext(): Boolean { return false }
|
||||||
|
|
||||||
operator fun next(): Any {
|
operator fun next(): Any {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -1,7 +1,6 @@
|
|||||||
// "Create member function 'next'" "true"
|
// "Create member function 'next'" "true"
|
||||||
class FooIterator<T> {
|
class FooIterator<T> {
|
||||||
operator fun hasNext(): Boolean { return false }
|
operator fun hasNext(): Boolean { return false }
|
||||||
|
|
||||||
operator fun next(): Int {
|
operator fun next(): Int {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -1,7 +1,6 @@
|
|||||||
// "Create member function 'next'" "true"
|
// "Create member function 'next'" "true"
|
||||||
class FooIterator<T> {
|
class FooIterator<T> {
|
||||||
operator fun hasNext(): Boolean { return false }
|
operator fun hasNext(): Boolean { return false }
|
||||||
|
|
||||||
operator fun next(): T {
|
operator fun next(): T {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -1,7 +1,6 @@
|
|||||||
// "Create member function 'set'" "true"
|
// "Create member function 'set'" "true"
|
||||||
class A {
|
class A {
|
||||||
operator fun get(s: String): Int = 1
|
operator fun get(s: String): Int = 1
|
||||||
|
|
||||||
operator fun set(s: String, value: Int) {
|
operator fun set(s: String, value: Int) {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
class A<T>(val n: T) {
|
class A<T>(val n: T) {
|
||||||
operator fun minus(n: Int): A<T> = throw Exception()
|
operator fun minus(n: Int): A<T> = throw Exception()
|
||||||
|
|
||||||
operator fun unaryMinus(): A<T> {
|
operator fun unaryMinus(): A<T> {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -3,7 +3,6 @@ open class Base()
|
|||||||
|
|
||||||
class Creation {
|
class Creation {
|
||||||
constructor(f: Int)
|
constructor(f: Int)
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
}
|
}
|
||||||
val v = Creation()
|
val v = Creation()
|
||||||
Vendored
-1
@@ -5,7 +5,6 @@ open class Base(val f: Int)
|
|||||||
|
|
||||||
class Creation: Base {
|
class Creation: Base {
|
||||||
constructor(f: Int): super(f)
|
constructor(f: Int): super(f)
|
||||||
|
|
||||||
constructor() : super(<caret>)
|
constructor() : super(<caret>)
|
||||||
}
|
}
|
||||||
val v = Creation()
|
val v = Creation()
|
||||||
-1
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
class CtorSecondary() {
|
class CtorSecondary() {
|
||||||
constructor(p: Int) : this()
|
constructor(p: Int) : this()
|
||||||
|
|
||||||
constructor<caret>(i: Int, i1: Int)
|
constructor<caret>(i: Int, i1: Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user