Can be constructor property: comment saver introduced to retain comments; unbound comments now added before, not after
(cherry picked from commit 886cf21)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4145e3438f
commit
4abcc278fd
+3
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiElementVisitor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||
import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -73,6 +74,7 @@ class CanBePrimaryConstructorPropertyInspection : AbstractKotlinInspection() {
|
||||
override fun getFamilyName() = "Move to constructor"
|
||||
|
||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||
val commentSaver = CommentSaver(original)
|
||||
val isVar = original.isVar
|
||||
val modifiers = original.modifierList?.text
|
||||
val factory = KtPsiFactory(project)
|
||||
@@ -83,6 +85,7 @@ class CanBePrimaryConstructorPropertyInspection : AbstractKotlinInspection() {
|
||||
parameter.addBefore(newModifiers, parameter.valOrVarKeyword)
|
||||
}
|
||||
original.delete()
|
||||
commentSaver.restore(parameter)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user