Insert '()' under write action in finishing anonymous object template (EA-82700)
(cherry picked from commit 3234d76)
This commit is contained in:
committed by
Nikolay Krasko
parent
3513cef779
commit
67cc6bb004
+5
-1
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.core.overrideImplement.ImplementMembersHandler
|
import org.jetbrains.kotlin.idea.core.overrideImplement.ImplementMembersHandler
|
||||||
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
@@ -58,7 +59,10 @@ internal class AnonymousTemplateEditingListener(private val psiFile: PsiFile, pr
|
|||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
if (classDescriptor!!.kind == ClassKind.CLASS) {
|
if (classDescriptor!!.kind == ClassKind.CLASS) {
|
||||||
val placeToInsert = classRef!!.textRange.endOffset
|
val placeToInsert = classRef!!.textRange.endOffset
|
||||||
PsiDocumentManager.getInstance(psiFile.project).getDocument(psiFile)!!.insertString(placeToInsert, "()")
|
|
||||||
|
runWriteAction {
|
||||||
|
PsiDocumentManager.getInstance(psiFile.project).getDocument(psiFile)!!.insertString(placeToInsert, "()")
|
||||||
|
}
|
||||||
|
|
||||||
var hasConstructorsParameters = false
|
var hasConstructorsParameters = false
|
||||||
for (cd in classDescriptor!!.constructors) {
|
for (cd in classDescriptor!!.constructors) {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// Using class is important
|
||||||
|
// Test for EA-82700
|
||||||
|
|
||||||
|
open class A
|
||||||
|
val test = object : A() {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// Using class is important
|
||||||
|
// Test for EA-82700
|
||||||
|
|
||||||
|
open class A
|
||||||
|
val test = <caret>
|
||||||
+9
-1
@@ -213,6 +213,14 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
checkAfter()
|
checkAfter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testObject_ForClass() {
|
||||||
|
start()
|
||||||
|
|
||||||
|
typeAndNextTab("A")
|
||||||
|
|
||||||
|
checkAfter()
|
||||||
|
}
|
||||||
|
|
||||||
private fun doTestIfnInn() {
|
private fun doTestIfnInn() {
|
||||||
start()
|
start()
|
||||||
|
|
||||||
@@ -272,7 +280,7 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
CommandProcessor.getInstance().executeCommand(
|
CommandProcessor.getInstance().executeCommand(
|
||||||
project,
|
project,
|
||||||
{
|
{
|
||||||
ApplicationManager.getApplication().runWriteAction { templateState!!.nextTab() }
|
templateState!!.nextTab()
|
||||||
},
|
},
|
||||||
"nextTab",
|
"nextTab",
|
||||||
null)
|
null)
|
||||||
|
|||||||
Reference in New Issue
Block a user