KT-7716 Introduce Variable's name suggestions often have "1" at the end for no real reason
#KT-7716 Fixed
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.JetExpression
|
|||||||
import org.jetbrains.kotlin.psi.JetVisitorVoid
|
import org.jetbrains.kotlin.psi.JetVisitorVoid
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
|
|
||||||
@@ -78,9 +79,9 @@ public class NameValidatorImpl(
|
|||||||
if (!visitedScopes.add(resolutionScope)) return
|
if (!visitedScopes.add(resolutionScope)) return
|
||||||
|
|
||||||
val conflict = if (target === Target.PROPERTIES)
|
val conflict = if (target === Target.PROPERTIES)
|
||||||
resolutionScope.getProperties(name).isNotEmpty() || resolutionScope.getLocalVariable(name) != null
|
resolutionScope.getProperties(name).any { !it.isExtension } || resolutionScope.getLocalVariable(name) != null
|
||||||
else
|
else
|
||||||
resolutionScope.getFunctions(name).isNotEmpty() || resolutionScope.getClassifier(name) != null
|
resolutionScope.getFunctions(name).any { !it.isExtension } || resolutionScope.getClassifier(name) != null
|
||||||
|
|
||||||
if (conflict) {
|
if (conflict) {
|
||||||
conflictFound = true
|
conflictFound = true
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class For
|
||||||
|
|
||||||
|
val For.parent: For
|
||||||
|
get() = For()
|
||||||
|
|
||||||
|
fun foo(f: For) {
|
||||||
|
<selection>f.parent</selection>
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class For
|
||||||
|
|
||||||
|
val For.parent: For
|
||||||
|
get() = For()
|
||||||
|
|
||||||
|
fun foo(f: For) {
|
||||||
|
val parent = f.parent
|
||||||
|
}
|
||||||
+6
@@ -163,6 +163,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
|
|||||||
doIntroduceVariableTest(fileName);
|
doIntroduceVariableTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NameSuggestionBug.kt")
|
||||||
|
public void testNameSuggestionBug() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/NameSuggestionBug.kt");
|
||||||
|
doIntroduceVariableTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noConflictWithInnerVariable.kt")
|
@TestMetadata("noConflictWithInnerVariable.kt")
|
||||||
public void testNoConflictWithInnerVariable() throws Exception {
|
public void testNoConflictWithInnerVariable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/noConflictWithInnerVariable.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/noConflictWithInnerVariable.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user