@@ -10,8 +10,12 @@ import {
10
10
Scope ,
11
11
} from 'langium' ;
12
12
import {
13
+ isSdsAbstractCall ,
14
+ isSdsAnnotationCall ,
15
+ isSdsArgument ,
13
16
isSdsAssignment ,
14
17
isSdsBlock ,
18
+ isSdsCall ,
15
19
isSdsCallable ,
16
20
isSdsClass ,
17
21
isSdsEnum ,
@@ -31,6 +35,7 @@ import {
31
35
isSdsTypeArgument ,
32
36
isSdsWildcardImport ,
33
37
isSdsYield ,
38
+ SdsArgument ,
34
39
SdsDeclaration ,
35
40
SdsExpression ,
36
41
SdsImportedDeclaration ,
@@ -61,6 +66,7 @@ import { isStatic } from '../helpers/checks.js';
61
66
import { SafeDsServices } from '../safe-ds-module.js' ;
62
67
import { SafeDsTypeComputer } from '../typing/safe-ds-type-computer.js' ;
63
68
import { SafeDsPackageManager } from '../workspace/safe-ds-package-manager.js' ;
69
+ import { CallableType , StaticType } from '../typing/model.js' ;
64
70
65
71
export class SafeDsScopeProvider extends DefaultScopeProvider {
66
72
private readonly astReflection : AstReflection ;
@@ -78,7 +84,9 @@ export class SafeDsScopeProvider extends DefaultScopeProvider {
78
84
override getScope ( context : ReferenceInfo ) : Scope {
79
85
const node = context . container ;
80
86
81
- if ( isSdsImportedDeclaration ( node ) && context . property === 'declaration' ) {
87
+ if ( isSdsArgument ( node ) && context . property === 'parameter' ) {
88
+ return this . getScopeForArgumentParameter ( node ) ;
89
+ } else if ( isSdsImportedDeclaration ( node ) && context . property === 'declaration' ) {
82
90
return this . getScopeForImportedDeclarationDeclaration ( node ) ;
83
91
} else if ( isSdsNamedType ( node ) && context . property === 'declaration' ) {
84
92
if ( isSdsMemberType ( node . $container ) && node . $containerProperty === 'member' ) {
@@ -101,6 +109,35 @@ export class SafeDsScopeProvider extends DefaultScopeProvider {
101
109
}
102
110
}
103
111
112
+ private getScopeForArgumentParameter ( node : SdsArgument ) : Scope {
113
+ const containingAbstractCall = getContainerOfType ( node , isSdsAbstractCall ) ;
114
+ if ( isSdsAnnotationCall ( containingAbstractCall ) ) {
115
+ const annotation = containingAbstractCall . annotation ?. ref ;
116
+ if ( ! annotation ) {
117
+ return EMPTY_SCOPE ;
118
+ }
119
+
120
+ const parameters = parametersOrEmpty ( annotation . parameterList ) ;
121
+ return this . createScopeForNodes ( parameters ) ;
122
+ } else if ( isSdsCall ( containingAbstractCall ) ) {
123
+ const receiverType = this . typeComputer . computeType ( containingAbstractCall . receiver ) ;
124
+ if ( receiverType instanceof CallableType ) {
125
+ const parameters = parametersOrEmpty ( receiverType . sdsCallable . parameterList ) ;
126
+ return this . createScopeForNodes ( parameters ) ;
127
+ } else if ( receiverType instanceof StaticType ) {
128
+ const declaration = receiverType . instanceType . sdsDeclaration ;
129
+ if ( isSdsCallable ( declaration ) ) {
130
+ const parameters = parametersOrEmpty ( declaration . parameterList ) ;
131
+ return this . createScopeForNodes ( parameters ) ;
132
+ }
133
+ }
134
+
135
+ return EMPTY_SCOPE ;
136
+ } /* c8 ignore start */ else {
137
+ return EMPTY_SCOPE ;
138
+ } /* c8 ignore stop */
139
+ }
140
+
104
141
private getScopeForImportedDeclarationDeclaration ( node : SdsImportedDeclaration ) : Scope {
105
142
const ownPackageName = packageNameOrNull ( node ) ;
106
143
0 commit comments