mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Kotlin] Fixed for loop declarations leaking to outer scope when using PSI-only based completion
KTIJ-19995 GitOrigin-RevId: e01effa55285da3258b029ce4be963a7a040db2e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8dae39dcf8
commit
ea1ff1d62c
+4
@@ -238,6 +238,10 @@ class PsiTreeCompletion {
|
||||
return super.visitClassBody(classBody, data.registerSubScope(classBody.textRange, scopeType))
|
||||
}
|
||||
|
||||
override fun visitForExpression(expression: KtForExpression, data: LookupScope): Void? {
|
||||
return super.visitForExpression(expression, data.registerSubScope(expression.textRange, ScopeType.LOCAL))
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(function: KtNamedFunction, data: LookupScope): Void? {
|
||||
// We handle this declaration separately because it needs to open a new scope for the
|
||||
// function parameters, so they do not leak to the outside scope.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
for (prefixTest in test) {
|
||||
val a = prefix<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// EXIST: prefixTest
|
||||
// NOTHING_ELSE
|
||||
@@ -0,0 +1,9 @@
|
||||
fun test() {
|
||||
for (prefixTest in test) {
|
||||
|
||||
}
|
||||
val a = prefix<caret>
|
||||
}
|
||||
|
||||
// ABSENT: prefixTest
|
||||
// NOTHING_ELSE
|
||||
+10
@@ -118,6 +118,16 @@ public class DumbCompletionTestGenerated extends AbstractDumbCompletionTest {
|
||||
runTest("../testData/dumb/ExtensionProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForLoopDeclarationInBody.kt")
|
||||
public void testForLoopDeclarationInBody() throws Exception {
|
||||
runTest("../testData/dumb/ForLoopDeclarationInBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForLoopDeclarationShouldNotLeak.kt")
|
||||
public void testForLoopDeclarationShouldNotLeak() throws Exception {
|
||||
runTest("../testData/dumb/ForLoopDeclarationShouldNotLeak.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
runTest("../testData/dumb/Function.kt");
|
||||
|
||||
+10
@@ -118,6 +118,16 @@ public class FirDumbCompletionTestGenerated extends AbstractFirDumbCompletionTes
|
||||
runTest("../../completion/testData/dumb/ExtensionProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForLoopDeclarationInBody.kt")
|
||||
public void testForLoopDeclarationInBody() throws Exception {
|
||||
runTest("../../completion/testData/dumb/ForLoopDeclarationInBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForLoopDeclarationShouldNotLeak.kt")
|
||||
public void testForLoopDeclarationShouldNotLeak() throws Exception {
|
||||
runTest("../../completion/testData/dumb/ForLoopDeclarationShouldNotLeak.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
runTest("../../completion/testData/dumb/Function.kt");
|
||||
|
||||
Reference in New Issue
Block a user