diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt index 49668760f8c..566c6fe18ba 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt @@ -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 } diff --git a/idea/testData/multiModuleQuickFix/createActual/annotationWithComment/common/a.kt b/idea/testData/multiModuleQuickFix/createActual/annotationWithComment/common/a.kt new file mode 100644 index 00000000000..aca843a7d3c --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createActual/annotationWithComment/common/a.kt @@ -0,0 +1,6 @@ +// "Create actual annotation class for module testModule_JVM (JVM)" "true" + +@RegAnn // some comment +expect annotation class SomeAnn + +annotation class RegAnn \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/createActual/annotationWithComment/jvm/SomeAnn.kt.after b/idea/testData/multiModuleQuickFix/createActual/annotationWithComment/jvm/SomeAnn.kt.after new file mode 100644 index 00000000000..07d4efadafc --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createActual/annotationWithComment/jvm/SomeAnn.kt.after @@ -0,0 +1,2 @@ +@RegAnn // some comment +actual annotation class SomeAnn \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java index a58a91edded..e158fdb4482 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java @@ -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/");