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.idea.caches.resolve.analyze
|
||||
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.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -97,10 +99,9 @@ public class NewDeclarationNameValidator(
|
||||
|
||||
return when(target) {
|
||||
Target.VARIABLES ->
|
||||
getProperties(name, NoLookupLocation.FROM_IDE).any { !it.isExtension && it.isVisible() } ||
|
||||
getLocalVariable(name) != null
|
||||
getAllAccessibleVariables(name).any { !it.isExtension && it.isVisible() }
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -9,7 +9,7 @@ class A {
|
||||
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 {
|
||||
val b = 1
|
||||
|
||||
+2
-2
@@ -11,6 +11,6 @@ class Y(val y: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun __dummyTestFun__(x: X, y1: Y) {
|
||||
x.`x`plus y1.y
|
||||
private fun __dummyTestFun__(x1: X, y1: Y) {
|
||||
x1.`x`plus y1.y
|
||||
}
|
||||
+2
-2
@@ -14,7 +14,7 @@ class A(val a: Int) {
|
||||
|
||||
fun test() {
|
||||
val t = with(A(1)) {
|
||||
val a = A(2)
|
||||
foo(this.a + a.a)
|
||||
val a1 = A(2)
|
||||
foo(a + a1.a)
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -8,13 +8,13 @@ class A(val a: Int) {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val a2 = A(1)
|
||||
val a = A(1)
|
||||
val a3 = A(2)
|
||||
a2.foo(a2.a + a3.a)
|
||||
a.foo(a.a + a3.a)
|
||||
with(A(1)) {
|
||||
val a2 = A(2)
|
||||
foo(this.a + a2.a)
|
||||
val a1 = A(2)
|
||||
foo(a + a1.a)
|
||||
val a = A(2)
|
||||
this.foo(this.a + a.a)
|
||||
this.foo(this.a + a1.a)
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -8,13 +8,13 @@ class A(val a: Int) {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val a2 = A(1)
|
||||
val a = A(1)
|
||||
val a3 = A(2)
|
||||
a2.foo(a2.a + a3.a)
|
||||
a.foo(a.a + a3.a)
|
||||
with(A(1)) {
|
||||
val a2 = A(2)
|
||||
foo(this.a + a2.a)
|
||||
val a1 = A(2)
|
||||
foo(a + a1.a)
|
||||
val a = A(2)
|
||||
this.foo(this.a + a.a)
|
||||
this.foo(this.a + a1.a)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
with(A()) {
|
||||
val prop = prop
|
||||
println(prop)
|
||||
println(prop)
|
||||
val prop1 = prop
|
||||
println(prop1)
|
||||
println(prop1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -6,9 +6,9 @@ fun foo(body: A.() -> Unit) {}
|
||||
|
||||
fun bar() {
|
||||
foo {
|
||||
val value = value
|
||||
print(value)
|
||||
print(value)
|
||||
val value1 = value
|
||||
print(value1)
|
||||
print(value1)
|
||||
}
|
||||
|
||||
foo {
|
||||
|
||||
Reference in New Issue
Block a user