Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/language/context-mapper-dsl.langium
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ grammar ContextMapperDsl

terminal ID: /[_a-zA-Z][\w_]*/;
terminal STRING: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/;
terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
terminal SL_COMMENT: /\/\/[^\n\r]*/;

terminal OPEN: '{';
terminal CLOSE: '}';

hidden terminal WS: /\s+/;
hidden terminal HIDDEN_ML_COMMENT: ML_COMMENT;
hidden terminal HIDDEN_SL_COMMENT: SL_COMMENT;
hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;

entry ContextMappingModel:
(
Expand Down Expand Up @@ -169,7 +167,7 @@ CustomerSupplierRelationship:
(OPEN
(
('implementationTechnology' ('=')? implementationTechnology=STRING) &
(('exposedAggregates' ('=')? upstreamExposedAggregates+=[Aggregate]) ("," upstreamExposedAggregates+=[Aggregate])* (exposedAggregatesComment=SL_COMMENT)?) &
(('exposedAggregates' ('=')? upstreamExposedAggregates+=[Aggregate]) ("," upstreamExposedAggregates+=[Aggregate])*) &
('downstreamRights' ('=')? downstreamGovernanceRights=DownstreamGovernanceRights)
)
CLOSE)?
Expand All @@ -182,8 +180,8 @@ Aggregate:
(
(('responsibilities' ('=')? responsibilities+=STRING) ("," responsibilities+=STRING)*) &
(
(('useCases' ('=')? userRequirements+=[UseCase]) ("," userRequirements+=[UseCase])*) |
(('userStories' ('=')? userRequirements+=[UserStory]) ("," userRequirements+=[UserStory])*) |
(('useCases' ('=')? useCases+=[UseCase]) ("," useCases+=[UseCase])*) |
(('userStories' ('=')? userStories+=[UserStory]) ("," userStories+=[UserStory])*) |
((('features' | 'userRequirements') ('=')? userRequirements+=[UserRequirement]) ("," userRequirements+=[UserRequirement])*)
) &
('owner' ('=')? owner=[BoundedContext]) &
Expand Down
8 changes: 8 additions & 0 deletions src/language/semantictokens/HighlightingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export function highlightKeyword (node: AstNode, acceptor: SemanticTokenAcceptor
})
}

export function highlightOperator (node: AstNode, acceptor: SemanticTokenAcceptor, operator: string) {
acceptor({
node,
type: SemanticTokenTypes.operator,
keyword: operator
})
}

export function highlightType (node: AstNode, acceptor: SemanticTokenAcceptor, property: string, modifiers: string[] = []) {
acceptor({
node,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Aggregate, isAggregate, isUseCase, isUserRequirement, isUserStory } from '../../generated/ast.js'
import { Aggregate, isAggregate } from '../../generated/ast.js'
import { SemanticTokenAcceptor } from 'langium/lsp'
import { SemanticTokenTypes } from 'vscode-languageserver-types'
import { highlightField, highlightString, highlightTypeDeclaration } from '../HighlightingHelper.js'
Expand All @@ -22,7 +22,15 @@ export class AggregateSemanticTokenProvider implements ContextMapperSemanticToke
}

if (node.userRequirements.length > 0) {
this.highlightUserRequirements(node, acceptor)
highlightField(node, acceptor, ['userRequirements', 'features'], 'userRequirements', SemanticTokenTypes.type)
}

if (node.useCases.length > 0) {
highlightField(node, acceptor, ['useCases'], 'useCases', SemanticTokenTypes.type)
}

if (node.userStories.length > 0) {
highlightField(node, acceptor, ['userStories'], 'userStories', SemanticTokenTypes.type)
}

if (node.owner) {
Expand Down Expand Up @@ -53,10 +61,6 @@ export class AggregateSemanticTokenProvider implements ContextMapperSemanticToke
highlightField(node, acceptor, ['storageSimilarity'], 'storageSimilarity')
}

if (node.storageSimilarity) {
highlightField(node, acceptor, ['storageSimilarity'], 'storageSimilarity')
}

if (node.securityCriticality) {
highlightField(node, acceptor, ['securityCriticality'], 'securityCriticality')
}
Expand All @@ -69,18 +73,4 @@ export class AggregateSemanticTokenProvider implements ContextMapperSemanticToke
highlightField(node, acceptor, ['securityAccessGroup'], 'securityAccessGroup', SemanticTokenTypes.string)
}
}

private highlightUserRequirements (node: Aggregate, acceptor: SemanticTokenAcceptor) {
const keywords = []
if (isUseCase(node.userRequirements[0])) {
keywords.push('useCases')
} else if (isUserRequirement(node.userRequirements[0])) {
keywords.push('userRequirements')
keywords.push('features')
} else if (isUserStory(node.userRequirements[0])) {
keywords.push('userStories')
}

highlightField(node, acceptor, keywords, 'userRequirements', SemanticTokenTypes.type)
}
}
Loading
Loading