KT-61890 [AA] Add test for ContextCollector at loop variable position
This turns out to be important for conflict resolution in postfix completion in K2 IDE (see `KotlinDeclarationNameValidator`)
This commit is contained in:
+6
@@ -100,6 +100,12 @@ public class FirIdeDependentAnalysisSourceModuleScopeContextForPositionTestGener
|
|||||||
runTest("analysis/analysis-api/testData/components/scopeProvider/scopeContextForPosition/errorType.kt");
|
runTest("analysis/analysis-api/testData/components/scopeProvider/scopeContextForPosition/errorType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("forLoopVariable.kt")
|
||||||
|
public void testForLoopVariable() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/scopeProvider/scopeContextForPosition/forLoopVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kDocOnClass.kt")
|
@TestMetadata("kDocOnClass.kt")
|
||||||
public void testKDocOnClass() throws Exception {
|
public void testKDocOnClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -100,6 +100,12 @@ public class FirIdeNormalAnalysisSourceModuleScopeContextForPositionTestGenerate
|
|||||||
runTest("analysis/analysis-api/testData/components/scopeProvider/scopeContextForPosition/errorType.kt");
|
runTest("analysis/analysis-api/testData/components/scopeProvider/scopeContextForPosition/errorType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("forLoopVariable.kt")
|
||||||
|
public void testForLoopVariable() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/scopeProvider/scopeContextForPosition/forLoopVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kDocOnClass.kt")
|
@TestMetadata("kDocOnClass.kt")
|
||||||
public void testKDocOnClass() throws Exception {
|
public void testKDocOnClass() throws Exception {
|
||||||
|
|||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun usage(list: List<Int>) {
|
||||||
|
for (<expr>loopVar</expr> in list) {}
|
||||||
|
}
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
element: loopVar
|
||||||
|
implicit receivers:
|
||||||
|
scopes:
|
||||||
|
LocalScope, index = 0
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
LocalScope, index = 1
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 1
|
||||||
|
val `<iterator>`: kotlin.collections.Iterator<kotlin.Int>
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
LocalScope, index = 2
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
LocalScope, index = 3
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 1
|
||||||
|
list: kotlin.collections.List<kotlin.Int>
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
ExplicitSimpleImportingScope, index = 4
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
PackageMemberScope, index = 5
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 1
|
||||||
|
fun usage(list: kotlin.collections.List<kotlin.Int>)
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
DefaultSimpleImportingScope, index = 6
|
||||||
|
|
||||||
|
DefaultSimpleImportingScope, index = 7
|
||||||
|
|
||||||
|
ExplicitStarImportingScope, index = 8
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
DefaultSimpleImportingScope, index = 9
|
||||||
|
|
||||||
|
DefaultStarImportingScope, index = 10
|
||||||
Vendored
+152
@@ -0,0 +1,152 @@
|
|||||||
|
element: loopVar
|
||||||
|
implicit receivers:
|
||||||
|
scopes:
|
||||||
|
LocalScope, index = 0
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
LocalScope, index = 1
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 1
|
||||||
|
KtLocalVariableSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
isExtension: false
|
||||||
|
isVal: true
|
||||||
|
name: <iterator>
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: KtUsualClassType:
|
||||||
|
annotationsList: []
|
||||||
|
ownTypeArguments: [
|
||||||
|
KtUsualClassType:
|
||||||
|
annotationsList: []
|
||||||
|
ownTypeArguments: []
|
||||||
|
type: kotlin/Int
|
||||||
|
]
|
||||||
|
type: kotlin/collections/Iterator<kotlin/Int>
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
LocalScope, index = 2
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
LocalScope, index = 3
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 1
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: list
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: KtUsualClassType:
|
||||||
|
annotationsList: []
|
||||||
|
ownTypeArguments: [
|
||||||
|
KtUsualClassType:
|
||||||
|
annotationsList: []
|
||||||
|
ownTypeArguments: []
|
||||||
|
type: kotlin/Int
|
||||||
|
]
|
||||||
|
type: kotlin/collections/List<kotlin/Int>
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
ExplicitSimpleImportingScope, index = 4
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
PackageMemberScope, index = 5
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 1
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: test/usage
|
||||||
|
contextReceivers: []
|
||||||
|
contractEffects: []
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isActual: false
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExpect: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: usage
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: KtUsualClassType:
|
||||||
|
annotationsList: []
|
||||||
|
ownTypeArguments: []
|
||||||
|
type: kotlin/Unit
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: [
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: list
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: KtUsualClassType:
|
||||||
|
annotationsList: []
|
||||||
|
ownTypeArguments: [
|
||||||
|
KtUsualClassType:
|
||||||
|
annotationsList: []
|
||||||
|
ownTypeArguments: []
|
||||||
|
type: kotlin/Int
|
||||||
|
]
|
||||||
|
type: kotlin/collections/List<kotlin/Int>
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
]
|
||||||
|
visibility: Public
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
DefaultSimpleImportingScope, index = 6
|
||||||
|
|
||||||
|
DefaultSimpleImportingScope, index = 7
|
||||||
|
|
||||||
|
ExplicitStarImportingScope, index = 8
|
||||||
|
packages: 0
|
||||||
|
classifiers: 0
|
||||||
|
callables: 0
|
||||||
|
constructors: 0
|
||||||
|
|
||||||
|
DefaultSimpleImportingScope, index = 9
|
||||||
|
|
||||||
|
DefaultStarImportingScope, index = 10
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun usage(list: List<Int>) {
|
||||||
|
for (<expr>loopVar</expr> in list) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 6
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 7
|
||||||
|
Scope: FirLocalScope
|
||||||
|
Properties:
|
||||||
|
FirValueParameterSymbol list: R|kotlin/collections/List<kotlin/Int>|
|
||||||
|
Element 8
|
||||||
|
Scope: FirLocalScope
|
||||||
|
Element 9
|
||||||
|
Scope: FirLocalScope
|
||||||
|
Properties:
|
||||||
|
FirPropertySymbol lval <iterator>: R|kotlin/collections/Iterator<kotlin/Int>|
|
||||||
|
Element 10
|
||||||
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] forLoopVariable.kt
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun usage([ResolvedTo(BODY_RESOLVE)] list: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/Unit| {
|
||||||
|
{
|
||||||
|
[ResolvedTo(BODY_RESOLVE)] lval <iterator>: R|kotlin/collections/Iterator<kotlin/Int>| = R|<local>/list|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<kotlin/Int>|>|()
|
||||||
|
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
|
||||||
|
[ResolvedTo(BODY_RESOLVE)] lval loopVar: R|kotlin/Int| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Int|>|()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+6
@@ -60,6 +60,12 @@ public class ContextCollectorSourceTestGenerated extends AbstractContextCollecto
|
|||||||
runTest("analysis/low-level-api-fir/testData/contextCollector/file.kt");
|
runTest("analysis/low-level-api-fir/testData/contextCollector/file.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("forLoopVariable.kt")
|
||||||
|
public void testForLoopVariable() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/contextCollector/forLoopVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClasses.kt")
|
@TestMetadata("innerClasses.kt")
|
||||||
public void testInnerClasses() throws Exception {
|
public void testInnerClasses() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user