TrailingCommaPostFormatProcessor: should reset user data after invocation
#KT-37870 Fixed
This commit is contained in:
@@ -50,7 +50,6 @@ private class TrailingCommaPostFormatVisitor(val settings: CodeStyleSettings) :
|
||||
|
||||
private fun processCommaOwner(parent: KtElement) {
|
||||
if (!postFormatIsEnable(parent)) return
|
||||
parent.putUserData(IS_INSIDE, true)
|
||||
|
||||
val lastElement = trailingCommaOrLastElement(parent) ?: return
|
||||
val elementType = getElementType(lastElement)
|
||||
@@ -76,11 +75,13 @@ private class TrailingCommaPostFormatVisitor(val settings: CodeStyleSettings) :
|
||||
}
|
||||
|
||||
private fun updatePsi(element: KtElement, block: () -> Unit) {
|
||||
element.putUserData(IS_INSIDE, true)
|
||||
val oldLength = element.parent.textLength
|
||||
block()
|
||||
|
||||
val resultElement = CodeStyleManager.getInstance(element.project).reformat(element)
|
||||
myPostProcessor.updateResultRange(oldLength, resultElement.parent.textLength)
|
||||
element.putUserData(IS_INSIDE, false)
|
||||
}
|
||||
|
||||
private fun correctCommaPosition(parent: KtElement) {
|
||||
@@ -109,7 +110,7 @@ private class TrailingCommaPostFormatVisitor(val settings: CodeStyleSettings) :
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(TrailingCommaVisitor::class.java)
|
||||
private val IS_INSIDE = Key.create<Boolean>("TrailingCommaPostFormat")
|
||||
private fun postFormatIsEnable(source: PsiElement): Boolean = source.getUserData(IS_INSIDE)?.not() ?: true
|
||||
private fun postFormatIsEnable(source: PsiElement): Boolean = source.getUserData(IS_INSIDE) != true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user