Quickfix "Make primary constructor parameter a val" makes the val private now
Fixes #KT-13187
This commit is contained in:
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiFile
|
|||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinValVar
|
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinValVar
|
||||||
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
import org.jetbrains.kotlin.psi.KtParameter
|
||||||
@@ -45,6 +46,7 @@ class MakeConstructorParameterPropertyFix(
|
|||||||
|
|
||||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||||
element.addBefore(kotlinValVar.createKeyword(KtPsiFactory(project))!!, element.firstChild)
|
element.addBefore(kotlinValVar.createKeyword(KtPsiFactory(project))!!, element.firstChild)
|
||||||
|
element.addModifier(KtTokens.PRIVATE_KEYWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object Factory : KotlinIntentionActionsFactory() {
|
companion object Factory : KotlinIntentionActionsFactory() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// "Make primary constructor parameter 'bar' a property in class 'B'" "true"
|
// "Make primary constructor parameter 'bar' a property in class 'B'" "true"
|
||||||
|
|
||||||
class B(val bar: String) {
|
class B(private val bar: String) {
|
||||||
|
|
||||||
inner class A {
|
inner class A {
|
||||||
fun foo() {
|
fun foo() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// "Make primary constructor parameter 'foo' a property" "true"
|
// "Make primary constructor parameter 'foo' a property" "true"
|
||||||
|
|
||||||
class A(val foo: String) {
|
class A(private val foo: String) {
|
||||||
fun bar() {
|
fun bar() {
|
||||||
val a = foo<caret>
|
val a = foo<caret>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// "Make primary constructor parameter 'foo' a property" "true"
|
// "Make primary constructor parameter 'foo' a property" "true"
|
||||||
|
|
||||||
class A(var foo: String) {
|
class A(private var foo: String) {
|
||||||
fun bar() {
|
fun bar() {
|
||||||
foo<caret> = ""
|
foo<caret> = ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user