Skip to content

Commit 29e7fc1

Browse files
committed
fix bugs & adjust to modified grammar structure
1 parent e63b252 commit 29e7fc1

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

src/language/semantictokens/boundedContext/AggregateSemanticTokenProvider.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Aggregate, isAggregate, isUseCase, isUserRequirement, isUserStory } from '../../generated/ast.js'
1+
import { Aggregate, isAggregate } from '../../generated/ast.js'
22
import { SemanticTokenAcceptor } from 'langium/lsp'
33
import { SemanticTokenTypes } from 'vscode-languageserver-types'
44
import { highlightField, highlightString, highlightTypeDeclaration } from '../HighlightingHelper.js'
@@ -22,7 +22,15 @@ export class AggregateSemanticTokenProvider implements ContextMapperSemanticToke
2222
}
2323

2424
if (node.userRequirements.length > 0) {
25-
this.highlightUserRequirements(node, acceptor)
25+
highlightField(node, acceptor, ['userRequirements', 'features'], 'userRequirements', SemanticTokenTypes.type)
26+
}
27+
28+
if (node.useCases.length > 0) {
29+
highlightField(node, acceptor, ['useCases'], 'useCases', SemanticTokenTypes.type)
30+
}
31+
32+
if (node.userStories.length > 0) {
33+
highlightField(node, acceptor, ['userStories'], 'userStories', SemanticTokenTypes.type)
2634
}
2735

2836
if (node.owner) {
@@ -65,19 +73,4 @@ export class AggregateSemanticTokenProvider implements ContextMapperSemanticToke
6573
highlightField(node, acceptor, ['securityAccessGroup'], 'securityAccessGroup', SemanticTokenTypes.string)
6674
}
6775
}
68-
69-
private highlightUserRequirements (node: Aggregate, acceptor: SemanticTokenAcceptor) {
70-
const keywords = []
71-
const requirement = node.userRequirements[0].ref
72-
if (isUseCase(requirement)) {
73-
keywords.push('useCases')
74-
} else if (isUserRequirement(requirement)) {
75-
keywords.push('userRequirements')
76-
keywords.push('features')
77-
} else if (isUserStory(requirement)) {
78-
keywords.push('userStories')
79-
}
80-
81-
highlightField(node, acceptor, keywords, 'userRequirements', SemanticTokenTypes.type)
82-
}
8376
}

src/language/semantictokens/vdad/ActionSemanticTokenProvider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Action, isAction } from '../../generated/ast.js'
33
import { AstNode } from 'langium'
44
import { SemanticTokenAcceptor } from 'langium/lsp'
55
import { highlightKeyword, highlightString } from '../HighlightingHelper.js'
6+
import { SemanticTokenTypes } from 'vscode-languageserver-types'
67

78
export class ActionSemanticTokenProvider implements ContextMapperSemanticTokenProvider<Action> {
89
supports (node: AstNode): node is Action {
@@ -15,7 +16,11 @@ export class ActionSemanticTokenProvider implements ContextMapperSemanticTokenPr
1516

1617
const typeKeywords = ['ACT', 'MONITOR']
1718
if (typeKeywords.includes(node.type)) {
18-
highlightKeyword(node, acceptor, node.type)
19+
acceptor({
20+
node,
21+
type: SemanticTokenTypes.keyword,
22+
property: 'type'
23+
})
1924
} else {
2025
highlightString(node, acceptor, 'type')
2126
}

src/language/semantictokens/vdad/ValueClusterSemanticTokenProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class ValueClusterSemanticTokenProvider implements ContextMapperSemanticT
1414
highlightTypeDeclaration(node, acceptor, 'ValueCluster')
1515

1616
if (node.coreValue) {
17-
highlightField(node, acceptor, ['core'], 'coreValue')
17+
highlightField(node, acceptor, ['core'], 'coreValue', SemanticTokenTypes.string)
1818
}
1919
if (node.coreValue7000) {
2020
highlightField(node, acceptor, ['core'], 'coreValue7000')

src/language/semantictokens/vdad/ValueRegisterSemanticTokenProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import { ContextMapperSemanticTokenProvider } from '../ContextMapperSemanticToke
22
import { isValueRegister, ValueRegister } from '../../generated/ast.js'
33
import { AstNode } from 'langium'
44
import { SemanticTokenAcceptor } from 'langium/lsp'
5-
import { highlightAttribute, highlightKeyword } from '../HighlightingHelper.js'
5+
import { highlightAttribute, highlightTypeDeclaration } from '../HighlightingHelper.js'
66

77
export class ValueRegisterSemanticTokenProvider implements ContextMapperSemanticTokenProvider<ValueRegister> {
88
supports (node: AstNode): node is ValueRegister {
99
return isValueRegister(node)
1010
}
1111

1212
highlight (node: ValueRegister, acceptor: SemanticTokenAcceptor) {
13-
highlightKeyword(node, acceptor, 'ValueRegister')
13+
highlightTypeDeclaration(node, acceptor, 'ValueRegister')
1414

1515
if (node.context) {
16-
highlightAttribute(node, acceptor, ['of'], 'context')
16+
highlightAttribute(node, acceptor, ['for'], 'context')
1717
}
1818
}
1919
}

0 commit comments

Comments
 (0)