Merge pull request #906 from cypressious/make_val_private
Quickfix "Make primary constructor parameter a val" makes the val private now #KT-13187 Fixed
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.Errors
|
||||
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.KtNameReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
@@ -45,6 +46,7 @@ class MakeConstructorParameterPropertyFix(
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
element.addBefore(kotlinValVar.createKeyword(KtPsiFactory(project))!!, element.firstChild)
|
||||
element.addModifier(KtTokens.PRIVATE_KEYWORD)
|
||||
}
|
||||
|
||||
companion object Factory : KotlinIntentionActionsFactory() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "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 {
|
||||
fun foo() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Make primary constructor parameter 'foo' a property" "true"
|
||||
|
||||
class A(val foo: String) {
|
||||
class A(private val foo: String) {
|
||||
fun bar() {
|
||||
val a = foo<caret>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Make primary constructor parameter 'foo' a property" "true"
|
||||
|
||||
class A(var foo: String) {
|
||||
class A(private var foo: String) {
|
||||
fun bar() {
|
||||
foo<caret> = ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user