Improved logic of finding conflicts for refactoring actions
This commit is contained in:
@@ -21,6 +21,8 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
|
import org.jetbrains.kotlin.idea.util.getAllAccessibleFunctions
|
||||||
|
import org.jetbrains.kotlin.idea.util.getAllAccessibleVariables
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
@@ -97,10 +99,9 @@ public class NewDeclarationNameValidator(
|
|||||||
|
|
||||||
return when(target) {
|
return when(target) {
|
||||||
Target.VARIABLES ->
|
Target.VARIABLES ->
|
||||||
getProperties(name, NoLookupLocation.FROM_IDE).any { !it.isExtension && it.isVisible() } ||
|
getAllAccessibleVariables(name).any { !it.isExtension && it.isVisible() }
|
||||||
getLocalVariable(name) != null
|
|
||||||
Target.FUNCTIONS_AND_CLASSES ->
|
Target.FUNCTIONS_AND_CLASSES ->
|
||||||
getFunctions(name, NoLookupLocation.FROM_IDE).any { !it.isExtension && it.isVisible() } ||
|
getAllAccessibleFunctions(name).any { !it.isExtension && it.isVisible() } ||
|
||||||
getClassifier(name, NoLookupLocation.FROM_IDE)?.let { it.isVisible() } ?: false
|
getClassifier(name, NoLookupLocation.FROM_IDE)?.let { it.isVisible() } ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -9,7 +9,7 @@ class A {
|
|||||||
fun B.foo() = i(this@A, this)
|
fun B.foo() = i(this@A, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun i(a1: A, b: B) = a1.a + b.b
|
private fun i(a1: A, b1: B) = a1.a + b1.b
|
||||||
|
|
||||||
class B {
|
class B {
|
||||||
val b = 1
|
val b = 1
|
||||||
|
|||||||
+2
-2
@@ -11,6 +11,6 @@ class Y(val y: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun __dummyTestFun__(x: X, y1: Y) {
|
private fun __dummyTestFun__(x1: X, y1: Y) {
|
||||||
x.`x`plus y1.y
|
x1.`x`plus y1.y
|
||||||
}
|
}
|
||||||
+2
-2
@@ -14,7 +14,7 @@ class A(val a: Int) {
|
|||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val t = with(A(1)) {
|
val t = with(A(1)) {
|
||||||
val a = A(2)
|
val a1 = A(2)
|
||||||
foo(this.a + a.a)
|
foo(a + a1.a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-5
@@ -8,13 +8,13 @@ class A(val a: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val a2 = A(1)
|
val a = A(1)
|
||||||
val a3 = A(2)
|
val a3 = A(2)
|
||||||
a2.foo(a2.a + a3.a)
|
a.foo(a.a + a3.a)
|
||||||
with(A(1)) {
|
with(A(1)) {
|
||||||
|
val a2 = A(2)
|
||||||
|
foo(this.a + a2.a)
|
||||||
val a1 = A(2)
|
val a1 = A(2)
|
||||||
foo(a + a1.a)
|
this.foo(this.a + a1.a)
|
||||||
val a = A(2)
|
|
||||||
this.foo(this.a + a.a)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-5
@@ -8,13 +8,13 @@ class A(val a: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val a2 = A(1)
|
val a = A(1)
|
||||||
val a3 = A(2)
|
val a3 = A(2)
|
||||||
a2.foo(a2.a + a3.a)
|
a.foo(a.a + a3.a)
|
||||||
with(A(1)) {
|
with(A(1)) {
|
||||||
|
val a2 = A(2)
|
||||||
|
foo(this.a + a2.a)
|
||||||
val a1 = A(2)
|
val a1 = A(2)
|
||||||
foo(a + a1.a)
|
this.foo(this.a + a1.a)
|
||||||
val a = A(2)
|
|
||||||
this.foo(this.a + a.a)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
with(A()) {
|
with(A()) {
|
||||||
val prop = prop
|
val prop1 = prop
|
||||||
println(prop)
|
println(prop1)
|
||||||
println(prop)
|
println(prop1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -6,9 +6,9 @@ fun foo(body: A.() -> Unit) {}
|
|||||||
|
|
||||||
fun bar() {
|
fun bar() {
|
||||||
foo {
|
foo {
|
||||||
val value = value
|
val value1 = value
|
||||||
print(value)
|
print(value1)
|
||||||
print(value)
|
print(value1)
|
||||||
}
|
}
|
||||||
|
|
||||||
foo {
|
foo {
|
||||||
|
|||||||
Reference in New Issue
Block a user