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:
Valentin Kipyatkov
2015-06-26 20:32:03 +03:00
parent ed267d9949
commit df5f035760
4 changed files with 25 additions and 2 deletions
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.JetExpression
import org.jetbrains.kotlin.psi.JetVisitorVoid
import org.jetbrains.kotlin.psi.psiUtil.siblings
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.scopes.JetScope
@@ -78,9 +79,9 @@ public class NameValidatorImpl(
if (!visitedScopes.add(resolutionScope)) return
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
resolutionScope.getFunctions(name).isNotEmpty() || resolutionScope.getClassifier(name) != null
resolutionScope.getFunctions(name).any { !it.isExtension } || resolutionScope.getClassifier(name) != null
if (conflict) {
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
}
@@ -163,6 +163,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
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")
public void testNoConflictWithInnerVariable() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/noConflictWithInnerVariable.kt");