addRemoveModifier: shouldn't add extra new line
#KT-26635 Fixed
This commit is contained in:
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.psi.addRemoveModifier
|
||||
@@ -22,7 +11,6 @@ import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespace
|
||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||
|
||||
private fun KtModifierListOwner.addModifierList(newModifierList: KtModifierList): KtModifierList {
|
||||
@@ -98,7 +86,7 @@ internal fun addModifier(modifierList: KtModifierList, modifier: KtModifierKeywo
|
||||
val lastChild = modifierList.lastChild
|
||||
val anchor = lastChild?.siblings(forward = false)?.firstOrNull(::placeAfter).let {
|
||||
when {
|
||||
it?.nextSibling is PsiWhiteSpace && (it is KtAnnotation || it is KtAnnotationEntry) -> it.nextSibling
|
||||
it?.nextSibling is PsiWhiteSpace && (it is KtAnnotation || it is KtAnnotationEntry || it is PsiComment) -> it.nextSibling
|
||||
it == null && modifierList.firstChild is PsiWhiteSpace -> modifierList.firstChild
|
||||
else -> it
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Create actual annotation class for module testModule_JVM (JVM)" "true"
|
||||
|
||||
@RegAnn // some comment
|
||||
expect annotation class SomeAnn<caret>
|
||||
|
||||
annotation class RegAnn
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
@RegAnn // some comment
|
||||
actual annotation class SomeAnn
|
||||
+5
@@ -159,6 +159,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
||||
runTest("idea/testData/multiModuleQuickFix/createActual/annotationOptionalExpectationNoDir/");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationWithComment")
|
||||
public void testAnnotationWithComment() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/createActual/annotationWithComment/");
|
||||
}
|
||||
|
||||
@TestMetadata("class")
|
||||
public void testClass() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/createActual/class/");
|
||||
|
||||
Reference in New Issue
Block a user