@@ -8,33 +8,82 @@ import {
8
8
} from 'langium' ;
9
9
import {
10
10
isSdsClass ,
11
+ isSdsDeclaration ,
12
+ isSdsEnum ,
11
13
isSdsEnumVariant ,
12
14
isSdsFunction ,
15
+ isSdsModule ,
13
16
isSdsTypeParameter ,
14
17
isSdsTypeParameterList ,
18
+ SdsClass ,
19
+ SdsEnum ,
15
20
SdsTypeParameter ,
16
21
} from '../generated/ast.js' ;
17
22
18
23
export class SafeDsScopeComputation extends DefaultScopeComputation {
19
24
override processNode ( node : AstNode , document : LangiumDocument , scopes : PrecomputedScopes ) : void {
20
- if ( isSdsTypeParameter ( node ) ) {
25
+ if ( isSdsClass ( node ) ) {
26
+ this . processSdsClass ( node , document , scopes ) ;
27
+ } else if ( isSdsEnum ( node ) ) {
28
+ this . processSdsEnum ( node , document , scopes ) ;
29
+ } else if ( isSdsTypeParameter ( node ) ) {
21
30
this . processSdsTypeParameter ( node , document , scopes ) ;
22
31
} else {
23
32
super . processNode ( node , document , scopes ) ;
24
33
}
25
34
}
26
35
36
+ private processSdsClass ( node : SdsClass , document : LangiumDocument , scopes : PrecomputedScopes ) : void {
37
+ const name = this . nameProvider . getName ( node ) ;
38
+ if ( ! name ) {
39
+ return ;
40
+ }
41
+
42
+ const description = this . descriptions . createDescription ( node , name , document ) ;
43
+
44
+ this . addToScopesIfKeyIsDefined ( scopes , node . parameterList , description ) ;
45
+ this . addToScopesIfKeyIsDefined ( scopes , node . constraintList , description ) ;
46
+ this . addToScopesIfKeyIsDefined ( scopes , node . body , description ) ;
47
+
48
+ const containingDeclaration = getContainerOfType ( node . $container , isSdsDeclaration ) ;
49
+ if ( isSdsModule ( containingDeclaration ) ) {
50
+ this . addToScopesIfKeyIsDefined ( scopes , containingDeclaration , description ) ;
51
+ }
52
+ }
53
+
54
+ private processSdsEnum ( node : SdsEnum , document : LangiumDocument , scopes : PrecomputedScopes ) : void {
55
+ const name = this . nameProvider . getName ( node ) ;
56
+ if ( ! name ) {
57
+ return ;
58
+ }
59
+
60
+ const description = this . descriptions . createDescription ( node , name , document ) ;
61
+
62
+ this . addToScopesIfKeyIsDefined ( scopes , node . body , description ) ;
63
+
64
+ const containingDeclaration = getContainerOfType ( node . $container , isSdsDeclaration ) ;
65
+ if ( isSdsModule ( containingDeclaration ) ) {
66
+ this . addToScopesIfKeyIsDefined ( scopes , containingDeclaration , description ) ;
67
+ }
68
+ }
69
+
27
70
private processSdsTypeParameter (
28
71
node : SdsTypeParameter ,
29
72
document : LangiumDocument ,
30
73
scopes : PrecomputedScopes ,
31
74
) : void {
32
75
const containingDeclaration = getContainerOfType ( node , isSdsTypeParameterList ) ?. $container ;
33
76
if ( ! containingDeclaration ) {
77
+ /* c8 ignore next 2 */
34
78
return ;
35
79
}
36
80
37
81
const name = this . nameProvider . getName ( node ) ;
82
+ if ( ! name ) {
83
+ /* c8 ignore next 2 */
84
+ return ;
85
+ }
86
+
38
87
const description = this . descriptions . createDescription ( node , name , document ) ;
39
88
40
89
if ( isSdsClass ( containingDeclaration ) ) {
0 commit comments