Clean PSI elements in KotlinExpressionMover
Fix report about leaked projects on build server:
via 'com.intellij.psi.impl.PsiManagerImpl.myProject'; Value: 'Project (name=light_temp, containerState=DISPOSE_COMPLETED, componentStore=/mnt/agent/temp/buildTmp/ideaProject_test_1285163057398451250/testRootGW1/unitTest_addPrimaryConstructorParameter/light_temp....' of class com.intellij.openapi.project.impl.ProjectImpl
via 'com.intellij.psi.impl.source.PsiFileImpl.myManager'; Value: 'com.intellij.psi.impl.PsiManagerImpl@4ecdfe8' of class com.intellij.psi.impl.PsiManagerImpl
via 'com.intellij.psi.impl.source.tree.CompositeElement.myWrapper'; Value: 'DummyHolder' of class com.intellij.psi.impl.source.JavaDummyHolder
via 'com.intellij.psi.impl.source.tree.TreeElement.myParent'; Value: 'Element(DUMMY_HOLDER)' of class com.intellij.psi.impl.source.tree.FileElement
via 'com.intellij.psi.impl.source.SubstrateRef$2.val$node'; Value: 'Element(VALUE_PARAMETER)' of class com.intellij.psi.impl.source.tree.CompositeElement
via 'com.intellij.extapi.psi.StubBasedPsiElementBase.mySubstrateRef'; Value: 'com.intellij.psi.impl.source.SubstrateRef$2@5d02fa19' of class com.intellij.psi.impl.source.SubstrateRef$2
via 'kotlin.Pair.first'; Value: 'VALUE_PARAMETER' of class org.jetbrains.kotlin.psi.KtParameter
via 'org.jetbrains.kotlin.idea.codeInsight.upDownMover.KotlinExpressionMover.parametersOrArgsToMove'; Value: '(VALUE_PARAMETER, VALUE_PARAMETER)' of class kotlin.Pair
via '?'; Value: 'org.jetbrains.kotlin.idea.codeInsight.upDownMover.KotlinExpressionMover@7a6f128e' of class org.jetbrains.kotlin.idea.codeInsight.upDownMover.KotlinExpressionMover
via 'com.intellij.openapi.extensions.impl.ExtensionPointImpl.myExtensionsCacheAsArray'; Value: '[Lcom.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover;@276493b6' of class [Lcom.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover;
via 'java.util.concurrent.ConcurrentHashMap$Node.val'; Value: 'com.intellij.statementUpDownMover' of class com.intellij.openapi.extensions.impl.InterfaceExtensionPoint
via '?'; Value: 'com.intellij.statementUpDownMover=com.intellij.statementUpDownMover' of class java.util.concurrent.ConcurrentHashMap$Node
via 'java.util.concurrent.ConcurrentHashMap.table'; Value: '[Ljava.util.concurrent.ConcurrentHashMap$Node;@724e0cae' of class [Ljava.util.concurrent.ConcurrentHashMap$Node;
via 'com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.extensionPoints'; Value: '{com.intellij.embeddedTokenHighlighter=com.intellij.embeddedTokenHighlighter, org.intellij.groovy.expectedTypesContributor=org.intellij.groovy.expectedTypesContributor, org.jetbrains.kotlin.resolveSco...' of class java.util.concurrent.ConcurrentHashMap
via 'com.intellij.serviceContainer.ComponentManagerImpl.extensionArea'; Value: 'Application (containerState=ACTIVE) (Unit test) (Internal) (Headless) (Command line)' of class com.intellij.openapi.extensions.impl.ExtensionsAreaImpl
via '?'; Value: 'Application (containerState=ACTIVE) (Unit test) (Internal) (Headless) (Command line)' of class com.intellij.openapi.application.impl.ApplicationImpl
(from ApplicationManager.getApplication())
This commit is contained in:
@@ -11,7 +11,6 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.idea.core.util.getLineCount
|
||||
import org.jetbrains.kotlin.idea.core.util.isMultiLine
|
||||
import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaHelper
|
||||
import org.jetbrains.kotlin.idea.util.isComma
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -120,6 +119,7 @@ class KotlinExpressionMover : AbstractKotlinUpDownMover() {
|
||||
}
|
||||
|
||||
private var parametersOrArgsToMove: Pair<PsiElement, PsiElement>? = null
|
||||
|
||||
override fun beforeMove(
|
||||
editor: Editor,
|
||||
info: MoveInfo,
|
||||
@@ -127,6 +127,8 @@ class KotlinExpressionMover : AbstractKotlinUpDownMover() {
|
||||
) {
|
||||
if (parametersOrArgsToMove != null) {
|
||||
val (first, second) = parametersOrArgsToMove ?: return
|
||||
parametersOrArgsToMove = null
|
||||
|
||||
val lastElementOnFirstLine = getLastSiblingOfSameTypeInLine(first, editor)
|
||||
val lastElementOnSecondLine = getLastSiblingOfSameTypeInLine(second, editor)
|
||||
val withTrailingComma = lastElementOnFirstLine.parent
|
||||
|
||||
Reference in New Issue
Block a user