@likec4/language-server 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ast.d.ts +72 -0
- package/dist/ast.js +131 -0
- package/dist/elementRef.d.ts +6 -0
- package/dist/elementRef.js +39 -0
- package/dist/generated/ast.d.ts +346 -0
- package/dist/generated/ast.js +353 -0
- package/dist/generated/grammar.d.ts +6 -0
- package/dist/generated/grammar.js +2259 -0
- package/dist/generated/module.d.ts +9 -0
- package/dist/generated/module.js +26 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.js +20 -0
- package/dist/lsp/CodeLensProvider.d.ts +8 -0
- package/dist/lsp/CodeLensProvider.js +35 -0
- package/dist/lsp/DocumentSymbolProvider.d.ts +21 -0
- package/dist/lsp/DocumentSymbolProvider.js +138 -0
- package/dist/lsp/HoverProvider.d.ts +8 -0
- package/dist/lsp/HoverProvider.js +57 -0
- package/dist/lsp/SemanticTokenProvider.d.ts +6 -0
- package/dist/lsp/SemanticTokenProvider.js +245 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.js +4 -0
- package/dist/model/fqn-index.d.ts +17 -0
- package/dist/model/fqn-index.js +136 -0
- package/dist/model/index.d.ts +3 -0
- package/dist/model/index.js +3 -0
- package/dist/model/model-builder.d.ts +26 -0
- package/dist/model/model-builder.js +325 -0
- package/dist/model/model-locator.d.ts +16 -0
- package/dist/model/model-locator.js +108 -0
- package/dist/module.d.ts +18 -0
- package/dist/module.js +57 -0
- package/dist/protocol.d.ts +35 -0
- package/dist/protocol.js +19 -0
- package/dist/references/index.d.ts +2 -0
- package/dist/references/index.js +2 -0
- package/dist/references/scope-computation.d.ts +10 -0
- package/dist/references/scope-computation.js +76 -0
- package/dist/references/scope-provider.d.ts +15 -0
- package/dist/references/scope-provider.js +110 -0
- package/dist/registerProtocolHandlers.d.ts +2 -0
- package/dist/registerProtocolHandlers.js +49 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.js +1 -0
- package/dist/test/testServices.d.ts +15 -0
- package/dist/test/testServices.js +53 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +7 -0
- package/dist/validation/element.d.ts +5 -0
- package/dist/validation/element.js +20 -0
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.js +20 -0
- package/dist/validation/specification.d.ts +5 -0
- package/dist/validation/specification.js +31 -0
- package/dist/validation/view.d.ts +4 -0
- package/dist/validation/view.js +19 -0
- package/package.json +84 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* This file was generated by langium-cli 1.1.0.
|
|
3
|
+
* DO NOT EDIT MANUALLY!
|
|
4
|
+
******************************************************************************/
|
|
5
|
+
import { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedServices, LangiumServices, LanguageMetaData, Module, IParserConfig } from 'langium';
|
|
6
|
+
export declare const LikeC4LanguageMetaData: LanguageMetaData;
|
|
7
|
+
export declare const parserConfig: IParserConfig;
|
|
8
|
+
export declare const LikeC4GeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices>;
|
|
9
|
+
export declare const LikeC4GeneratedModule: Module<LangiumServices, LangiumGeneratedServices>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* This file was generated by langium-cli 1.1.0.
|
|
3
|
+
* DO NOT EDIT MANUALLY!
|
|
4
|
+
******************************************************************************/
|
|
5
|
+
import 'langium';
|
|
6
|
+
import { LikeC4AstReflection } from './ast';
|
|
7
|
+
import { LikeC4Grammar } from './grammar';
|
|
8
|
+
export const LikeC4LanguageMetaData = {
|
|
9
|
+
languageId: 'likec4',
|
|
10
|
+
fileExtensions: ['.c4', '.likec4', '.like-c4'],
|
|
11
|
+
caseInsensitive: false
|
|
12
|
+
};
|
|
13
|
+
export const parserConfig = {
|
|
14
|
+
recoveryEnabled: true,
|
|
15
|
+
nodeLocationTracking: 'full',
|
|
16
|
+
};
|
|
17
|
+
export const LikeC4GeneratedSharedModule = {
|
|
18
|
+
AstReflection: () => new LikeC4AstReflection()
|
|
19
|
+
};
|
|
20
|
+
export const LikeC4GeneratedModule = {
|
|
21
|
+
Grammar: () => LikeC4Grammar(),
|
|
22
|
+
LanguageMetaData: () => LikeC4LanguageMetaData,
|
|
23
|
+
parser: {
|
|
24
|
+
ParserConfig: () => parserConfig
|
|
25
|
+
}
|
|
26
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// import { type DefaultSharedModuleContext, startLanguageServer as startLangiumLanguageServer } from 'langium'
|
|
2
|
+
export { createLanguageServices } from './module';
|
|
3
|
+
// export type { C4XServices }
|
|
4
|
+
// export type { C4XModel } from './c4x-model'
|
|
5
|
+
// export type { C4XLangiumDocument } from './ast'
|
|
6
|
+
// export {
|
|
7
|
+
// LanguageId
|
|
8
|
+
// } from './const'
|
|
9
|
+
export { LikeC4LanguageMetaData as LanguageMetaData } from './generated/module';
|
|
10
|
+
// export { createC4XServices }
|
|
11
|
+
// export function startLanguageServices(context: DefaultSharedModuleContext) {
|
|
12
|
+
// const { shared, likec4 } = createLikeC4Services(context)
|
|
13
|
+
// startLangiumLanguageServer(shared)
|
|
14
|
+
// return likec4
|
|
15
|
+
// }
|
|
16
|
+
export { Rpc } from './protocol';
|
package/dist/logger.d.ts
ADDED
package/dist/logger.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const logger = {
|
|
2
|
+
debug(message) {
|
|
3
|
+
console.debug(message);
|
|
4
|
+
},
|
|
5
|
+
info(message) {
|
|
6
|
+
console.info(message);
|
|
7
|
+
},
|
|
8
|
+
warn(message) {
|
|
9
|
+
console.warn(message);
|
|
10
|
+
},
|
|
11
|
+
log(message) {
|
|
12
|
+
console.log(message);
|
|
13
|
+
},
|
|
14
|
+
error(message) {
|
|
15
|
+
console.error(message);
|
|
16
|
+
},
|
|
17
|
+
trace(message) {
|
|
18
|
+
console.debug(message);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LangiumDocument, LangiumSharedServices, MaybePromise } from 'langium';
|
|
2
|
+
import type { CodeLensProvider } from 'langium/lib/lsp/code-lens-provider';
|
|
3
|
+
import type { CancellationToken, CodeLens, CodeLensParams } from 'vscode-languageserver-protocol';
|
|
4
|
+
export declare class LikeC4CodeLensProvider implements CodeLensProvider {
|
|
5
|
+
private services;
|
|
6
|
+
constructor(services: LangiumSharedServices);
|
|
7
|
+
provideCodeLens(doc: LangiumDocument, _params: CodeLensParams, _cancelToken?: CancellationToken): MaybePromise<CodeLens[] | undefined>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ElementViewOps, isParsedLikeC4LangiumDocument } from '../ast';
|
|
2
|
+
export class LikeC4CodeLensProvider {
|
|
3
|
+
services;
|
|
4
|
+
constructor(services) {
|
|
5
|
+
this.services = services;
|
|
6
|
+
//
|
|
7
|
+
}
|
|
8
|
+
provideCodeLens(doc, _params, _cancelToken) {
|
|
9
|
+
if (!isParsedLikeC4LangiumDocument(doc)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return doc.parseResult.value.views?.views.flatMap((ast) => {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const viewId = ElementViewOps.readId(ast);
|
|
15
|
+
const range = ast.$cstNode?.range;
|
|
16
|
+
if (!range || !viewId) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
range: {
|
|
21
|
+
start: range.start,
|
|
22
|
+
end: {
|
|
23
|
+
line: range.start.line,
|
|
24
|
+
character: range.start.character + 4
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
command: {
|
|
28
|
+
command: 'likec4.open-preview',
|
|
29
|
+
arguments: [viewId],
|
|
30
|
+
title: 'open preview',
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* Copyright 2021 TypeFox GmbH
|
|
3
|
+
* This program and the accompanying materials are made available under the
|
|
4
|
+
* terms of the MIT License, which is available in the project root.
|
|
5
|
+
******************************************************************************/
|
|
6
|
+
/// <reference types="react" />
|
|
7
|
+
import { type DocumentSymbolProvider, type MaybePromise } from 'langium';
|
|
8
|
+
import { type DocumentSymbol } from 'vscode-languageserver-protocol';
|
|
9
|
+
import { type LikeC4LangiumDocument, ast } from '../ast';
|
|
10
|
+
import type { LikeC4Services } from '../module';
|
|
11
|
+
export declare class LikeC4DocumentSymbolProvider implements DocumentSymbolProvider {
|
|
12
|
+
private services;
|
|
13
|
+
constructor(services: LikeC4Services);
|
|
14
|
+
getSymbols(document: LikeC4LangiumDocument): MaybePromise<DocumentSymbol[]>;
|
|
15
|
+
protected getSpecSymbols: (astSpec: ast.SpecificationRule | undefined) => DocumentSymbol[];
|
|
16
|
+
protected getModelSymbols: (astModel: ast.Model | undefined) => DocumentSymbol[];
|
|
17
|
+
protected getElementsSymbol: (el: ast.Element | ast.Relation | ast.ExtendElement) => DocumentSymbol[];
|
|
18
|
+
protected getExtendElementSymbol: (astElement: ast.ExtendElement) => DocumentSymbol[];
|
|
19
|
+
protected getElementSymbol: (astElement: ast.Element) => DocumentSymbol[];
|
|
20
|
+
protected getModelViewsSymbols: (astViews: ast.ModelViews | undefined) => DocumentSymbol[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* Copyright 2021 TypeFox GmbH
|
|
3
|
+
* This program and the accompanying materials are made available under the
|
|
4
|
+
* terms of the MIT License, which is available in the project root.
|
|
5
|
+
******************************************************************************/
|
|
6
|
+
import invariant from 'tiny-invariant';
|
|
7
|
+
import { findNodeForProperty } from 'langium';
|
|
8
|
+
import { SymbolKind } from 'vscode-languageserver-protocol';
|
|
9
|
+
import { ast } from '../ast';
|
|
10
|
+
export class LikeC4DocumentSymbolProvider {
|
|
11
|
+
services;
|
|
12
|
+
constructor(services) {
|
|
13
|
+
this.services = services;
|
|
14
|
+
}
|
|
15
|
+
getSymbols(document) {
|
|
16
|
+
const { specification, model, views } = document.parseResult.value;
|
|
17
|
+
return [
|
|
18
|
+
...this.getSpecSymbols(specification),
|
|
19
|
+
...this.getModelSymbols(model),
|
|
20
|
+
...this.getModelViewsSymbols(views)
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
getSpecSymbols = (astSpec) => {
|
|
24
|
+
const cstModel = astSpec?.$cstNode;
|
|
25
|
+
if (!cstModel)
|
|
26
|
+
return [];
|
|
27
|
+
const specKeywordNode = findNodeForProperty(cstModel, 'name');
|
|
28
|
+
if (!specKeywordNode)
|
|
29
|
+
return [];
|
|
30
|
+
const specSymbols = [];
|
|
31
|
+
const getElementKindSymbol = (astKind) => {
|
|
32
|
+
invariant(astKind.$cstNode, 'SpecificationElementKind must have a CST node');
|
|
33
|
+
invariant(astKind.kind.$cstNode, 'SpecificationElementKind name must have a CST node');
|
|
34
|
+
return {
|
|
35
|
+
kind: SymbolKind.Class,
|
|
36
|
+
name: astKind.kind.name,
|
|
37
|
+
range: astKind.$cstNode.range,
|
|
38
|
+
selectionRange: astKind.kind.$cstNode.range
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
for (const astKind of astSpec.elementKinds) {
|
|
42
|
+
specSymbols.push(getElementKindSymbol(astKind));
|
|
43
|
+
}
|
|
44
|
+
const getTagSymbol = (astTag) => {
|
|
45
|
+
invariant(astTag.$cstNode, 'TagSpec must have a CST node');
|
|
46
|
+
invariant(astTag.tag.$cstNode, 'Tag name must have a CST node');
|
|
47
|
+
return {
|
|
48
|
+
kind: SymbolKind.EnumMember,
|
|
49
|
+
name: '#' + astTag.tag.name,
|
|
50
|
+
range: astTag.$cstNode.range,
|
|
51
|
+
selectionRange: astTag.tag.$cstNode.range
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
for (const astTag of astSpec.tags) {
|
|
55
|
+
specSymbols.push(getTagSymbol(astTag));
|
|
56
|
+
}
|
|
57
|
+
if (specSymbols.length === 0)
|
|
58
|
+
return [];
|
|
59
|
+
return [{
|
|
60
|
+
kind: SymbolKind.Class,
|
|
61
|
+
name: astSpec.name,
|
|
62
|
+
range: cstModel.range,
|
|
63
|
+
selectionRange: specKeywordNode.range,
|
|
64
|
+
children: specSymbols
|
|
65
|
+
}];
|
|
66
|
+
};
|
|
67
|
+
getModelSymbols = (astModel) => {
|
|
68
|
+
const cstModel = astModel?.$cstNode;
|
|
69
|
+
if (!cstModel)
|
|
70
|
+
return [];
|
|
71
|
+
const nameNode = findNodeForProperty(cstModel, 'name');
|
|
72
|
+
if (!nameNode)
|
|
73
|
+
return [];
|
|
74
|
+
return [{
|
|
75
|
+
kind: SymbolKind.Class,
|
|
76
|
+
name: astModel.name,
|
|
77
|
+
range: cstModel.range,
|
|
78
|
+
selectionRange: nameNode.range,
|
|
79
|
+
children: astModel.elements.flatMap(this.getElementsSymbol)
|
|
80
|
+
}];
|
|
81
|
+
};
|
|
82
|
+
getElementsSymbol = (el) => {
|
|
83
|
+
if (ast.isExtendElement(el)) {
|
|
84
|
+
return this.getExtendElementSymbol(el);
|
|
85
|
+
}
|
|
86
|
+
if (ast.isElement(el)) {
|
|
87
|
+
return this.getElementSymbol(el);
|
|
88
|
+
}
|
|
89
|
+
return [];
|
|
90
|
+
};
|
|
91
|
+
getExtendElementSymbol = (astElement) => {
|
|
92
|
+
const cst = astElement.$cstNode;
|
|
93
|
+
const nameNode = astElement.element.$cstNode;
|
|
94
|
+
if (!cst || !nameNode)
|
|
95
|
+
return [];
|
|
96
|
+
return [{
|
|
97
|
+
kind: SymbolKind.Constructor,
|
|
98
|
+
name: nameNode.text,
|
|
99
|
+
range: cst.range,
|
|
100
|
+
selectionRange: nameNode.range,
|
|
101
|
+
children: astElement.body.elements.flatMap(this.getElementsSymbol)
|
|
102
|
+
}];
|
|
103
|
+
};
|
|
104
|
+
getElementSymbol = (astElement) => {
|
|
105
|
+
const cst = astElement.$cstNode;
|
|
106
|
+
if (!cst)
|
|
107
|
+
return [];
|
|
108
|
+
const nameNode = findNodeForProperty(cst, 'name');
|
|
109
|
+
if (!nameNode)
|
|
110
|
+
return [];
|
|
111
|
+
const name = astElement.name;
|
|
112
|
+
const kind = astElement.kind.$refText;
|
|
113
|
+
const detail = kind + (astElement.title ? ': ' + astElement.title : '').replaceAll('\n', ' ').trim();
|
|
114
|
+
return [{
|
|
115
|
+
kind: SymbolKind.Constructor,
|
|
116
|
+
name: name,
|
|
117
|
+
range: cst.range,
|
|
118
|
+
selectionRange: nameNode.range,
|
|
119
|
+
detail,
|
|
120
|
+
children: astElement.body?.elements.flatMap(this.getElementsSymbol) ?? []
|
|
121
|
+
}];
|
|
122
|
+
};
|
|
123
|
+
getModelViewsSymbols = (astViews) => {
|
|
124
|
+
const cst = astViews?.$cstNode;
|
|
125
|
+
if (!cst)
|
|
126
|
+
return [];
|
|
127
|
+
const nameNode = findNodeForProperty(cst, 'name');
|
|
128
|
+
if (!nameNode)
|
|
129
|
+
return [];
|
|
130
|
+
return [{
|
|
131
|
+
kind: SymbolKind.Class,
|
|
132
|
+
name: astViews.name,
|
|
133
|
+
range: cst.range,
|
|
134
|
+
selectionRange: nameNode.range,
|
|
135
|
+
children: []
|
|
136
|
+
}];
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AstNode, AstNodeHoverProvider, type MaybePromise } from 'langium';
|
|
2
|
+
import type { Hover } from 'vscode-languageserver-protocol';
|
|
3
|
+
import type { LikeC4Services } from '../module';
|
|
4
|
+
export declare class LikeC4HoverProvider extends AstNodeHoverProvider {
|
|
5
|
+
private locator;
|
|
6
|
+
constructor(services: LikeC4Services);
|
|
7
|
+
protected getAstNodeHoverContent(node: AstNode): MaybePromise<Hover | undefined>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AstNodeHoverProvider } from 'langium';
|
|
2
|
+
import stripIndent from 'strip-indent';
|
|
3
|
+
import { ast } from '../ast';
|
|
4
|
+
export class LikeC4HoverProvider extends AstNodeHoverProvider {
|
|
5
|
+
locator;
|
|
6
|
+
constructor(services) {
|
|
7
|
+
super(services);
|
|
8
|
+
this.locator = services.likec4.ModelLocator;
|
|
9
|
+
}
|
|
10
|
+
getAstNodeHoverContent(node) {
|
|
11
|
+
if (ast.isTag(node)) {
|
|
12
|
+
return {
|
|
13
|
+
contents: {
|
|
14
|
+
kind: 'markdown',
|
|
15
|
+
value: stripIndent(`
|
|
16
|
+
tag: \`${node.name}\`
|
|
17
|
+
`)
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
// if (ast.isElementKind(node)) {
|
|
22
|
+
// const spec = this.specIndex.get(node.name as ElementKind)
|
|
23
|
+
// return {
|
|
24
|
+
// contents: {
|
|
25
|
+
// kind: 'markdown',
|
|
26
|
+
// value: stripIndent(`
|
|
27
|
+
// kind: **${spec.id}**
|
|
28
|
+
// shape: ${spec.style.shape}
|
|
29
|
+
// `)
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
if (ast.isElement(node)) {
|
|
34
|
+
const el = this.locator.getParsedElement(node);
|
|
35
|
+
if (!el) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const lines = [
|
|
39
|
+
el.id,
|
|
40
|
+
`${el.kind}: **${el.title}**`
|
|
41
|
+
];
|
|
42
|
+
if (el.tags && el.tags.length > 0) {
|
|
43
|
+
lines.push(' \n', el.tags.map(t => '#' + t).join(', '));
|
|
44
|
+
}
|
|
45
|
+
if (el.description) {
|
|
46
|
+
lines.push(' \n', el.description);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
contents: {
|
|
50
|
+
kind: 'markdown',
|
|
51
|
+
value: lines.join(' \n')
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractSemanticTokenProvider, type AstNode, type SemanticTokenAcceptor } from 'langium';
|
|
2
|
+
export declare class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
3
|
+
protected highlightElement(node: AstNode, acceptor: SemanticTokenAcceptor): void;
|
|
4
|
+
private highlightAstElement;
|
|
5
|
+
private highlightView;
|
|
6
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { AbstractSemanticTokenProvider } from 'langium';
|
|
2
|
+
import { SemanticTokenModifiers, SemanticTokenTypes } from 'vscode-languageserver-protocol';
|
|
3
|
+
import { ast } from '../ast';
|
|
4
|
+
import { isElementRefHead } from '../elementRef';
|
|
5
|
+
export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
6
|
+
highlightElement(node, acceptor) {
|
|
7
|
+
const keyword = (keyword, _index) => acceptor({
|
|
8
|
+
node,
|
|
9
|
+
keyword,
|
|
10
|
+
type: SemanticTokenTypes.keyword,
|
|
11
|
+
});
|
|
12
|
+
if (ast.isElementRef(node) || ast.isStrictElementRef(node)) {
|
|
13
|
+
acceptor({
|
|
14
|
+
node,
|
|
15
|
+
property: 'el',
|
|
16
|
+
type: isElementRefHead(node) ? SemanticTokenTypes.variable : SemanticTokenTypes.property,
|
|
17
|
+
});
|
|
18
|
+
// acceptor({
|
|
19
|
+
// node,
|
|
20
|
+
// property: 'el',
|
|
21
|
+
// type: SemanticTokenTypes.variable,
|
|
22
|
+
// })
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// if (ast.isSpec(node)) {
|
|
26
|
+
// keyword('spec')
|
|
27
|
+
// return
|
|
28
|
+
// }
|
|
29
|
+
if (ast.isWildcardExpression(node)) {
|
|
30
|
+
acceptor({
|
|
31
|
+
node,
|
|
32
|
+
property: 'isWildcard',
|
|
33
|
+
type: SemanticTokenTypes.variable
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (ast.isRelationExpression(node) || ast.isIncomingExpression(node) || ast.isOutgoingExpression(node)) {
|
|
38
|
+
keyword('->');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (ast.isInOutExpression(node)) {
|
|
42
|
+
keyword('->', 0);
|
|
43
|
+
keyword('->', 1);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (ast.isRelation(node)) {
|
|
47
|
+
keyword('->');
|
|
48
|
+
if ('title' in node) {
|
|
49
|
+
acceptor({
|
|
50
|
+
node,
|
|
51
|
+
property: 'title',
|
|
52
|
+
type: SemanticTokenTypes.string
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// if (ast.isDynamicViewStep(node)) {
|
|
58
|
+
// keyword(node.isReverse ? '<-' : '->')
|
|
59
|
+
// if (hasTitle(node)) {
|
|
60
|
+
// acceptor({
|
|
61
|
+
// node,
|
|
62
|
+
// property: 'title',
|
|
63
|
+
// type: SemanticTokenTypes.string
|
|
64
|
+
// })
|
|
65
|
+
// }
|
|
66
|
+
// return
|
|
67
|
+
// }
|
|
68
|
+
// if (ast.isStyleProperties(node)) {
|
|
69
|
+
// keyword('style')
|
|
70
|
+
// return
|
|
71
|
+
// }
|
|
72
|
+
if (ast.isElementKind(node)) {
|
|
73
|
+
acceptor({
|
|
74
|
+
node,
|
|
75
|
+
property: 'name',
|
|
76
|
+
type: SemanticTokenTypes.type,
|
|
77
|
+
modifier: [
|
|
78
|
+
SemanticTokenModifiers.definition,
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// if (ast.isElementKindSpec(node)) {
|
|
84
|
+
// keyword('element')
|
|
85
|
+
// // keyword('nested')
|
|
86
|
+
// // if (node.nested.length > 0) {
|
|
87
|
+
// // acceptor({
|
|
88
|
+
// // node,
|
|
89
|
+
// // property: 'nested',
|
|
90
|
+
// // type: SemanticTokenTypes.type,
|
|
91
|
+
// // })
|
|
92
|
+
// // }
|
|
93
|
+
// // acceptor({
|
|
94
|
+
// // node,
|
|
95
|
+
// // property: 'kind',
|
|
96
|
+
// // type: SemanticTokenTypes.type,
|
|
97
|
+
// // })
|
|
98
|
+
// return
|
|
99
|
+
// }
|
|
100
|
+
// if (ast.isTagSpec(node)) {
|
|
101
|
+
// keyword('tag')
|
|
102
|
+
// acceptor({
|
|
103
|
+
// node,
|
|
104
|
+
// property: 'tag',
|
|
105
|
+
// type: SemanticTokenTypes.enumMember
|
|
106
|
+
// })
|
|
107
|
+
// return
|
|
108
|
+
// }
|
|
109
|
+
if (ast.isTags(node)) {
|
|
110
|
+
acceptor({
|
|
111
|
+
node,
|
|
112
|
+
property: 'value',
|
|
113
|
+
type: SemanticTokenTypes.macro
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (ast.isTag(node)) {
|
|
118
|
+
acceptor({
|
|
119
|
+
node,
|
|
120
|
+
property: 'name',
|
|
121
|
+
type: SemanticTokenTypes.macro
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (ast.isColorProperty(node) || ast.isShapeProperty(node)) {
|
|
126
|
+
acceptor({
|
|
127
|
+
node,
|
|
128
|
+
property: 'key',
|
|
129
|
+
type: SemanticTokenTypes.keyword,
|
|
130
|
+
});
|
|
131
|
+
acceptor({
|
|
132
|
+
node,
|
|
133
|
+
property: 'value',
|
|
134
|
+
type: SemanticTokenTypes.enumMember
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (ast.isElementProperty(node) || ast.isRelationProperty(node) || ast.isViewProperty(node)) {
|
|
139
|
+
acceptor({
|
|
140
|
+
node,
|
|
141
|
+
property: 'key',
|
|
142
|
+
type: SemanticTokenTypes.keyword,
|
|
143
|
+
});
|
|
144
|
+
if ('value' in node) {
|
|
145
|
+
acceptor({
|
|
146
|
+
node,
|
|
147
|
+
property: 'value',
|
|
148
|
+
type: SemanticTokenTypes.string
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (ast.isModel(node)) {
|
|
154
|
+
keyword('model');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (ast.isModelViews(node)) {
|
|
158
|
+
keyword('views');
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (ast.isElement(node)) {
|
|
162
|
+
return this.highlightAstElement(node, acceptor);
|
|
163
|
+
}
|
|
164
|
+
if (ast.isExtendElement(node)) {
|
|
165
|
+
keyword('extend');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// if (ast.isElementProperty(node) || ast.isRelationProperty(node) || ast.isViewProperty(node)) {
|
|
169
|
+
// acceptor({
|
|
170
|
+
// node,
|
|
171
|
+
// property: 'key',
|
|
172
|
+
// type: SemanticTokenTypes.property,
|
|
173
|
+
// modifier: [SemanticTokenModifiers.definition]
|
|
174
|
+
// })
|
|
175
|
+
// if ('value' in node) {
|
|
176
|
+
// acceptor({
|
|
177
|
+
// node,
|
|
178
|
+
// property: 'value',
|
|
179
|
+
// type: SemanticTokenTypes.string
|
|
180
|
+
// })
|
|
181
|
+
// }
|
|
182
|
+
// return
|
|
183
|
+
// }
|
|
184
|
+
if (ast.isView(node)) {
|
|
185
|
+
return this.highlightView(node, acceptor);
|
|
186
|
+
}
|
|
187
|
+
// if (ast.isDynamicViewSteps(node)) {
|
|
188
|
+
// keyword('steps')
|
|
189
|
+
// return
|
|
190
|
+
// }
|
|
191
|
+
if (ast.isViewRuleStyle(node)) {
|
|
192
|
+
keyword('style');
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (ast.isViewRuleExpression(node)) {
|
|
196
|
+
keyword(node.isInclude ? 'include' : 'exclude');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
//
|
|
200
|
+
}
|
|
201
|
+
highlightAstElement(node, acceptor) {
|
|
202
|
+
acceptor({
|
|
203
|
+
node,
|
|
204
|
+
property: 'name',
|
|
205
|
+
type: SemanticTokenTypes.variable,
|
|
206
|
+
modifier: [
|
|
207
|
+
SemanticTokenModifiers.declaration,
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
acceptor({
|
|
211
|
+
node,
|
|
212
|
+
property: 'kind',
|
|
213
|
+
type: SemanticTokenTypes.keyword,
|
|
214
|
+
modifier: []
|
|
215
|
+
});
|
|
216
|
+
if ('title' in node) {
|
|
217
|
+
acceptor({
|
|
218
|
+
node,
|
|
219
|
+
property: 'title',
|
|
220
|
+
type: SemanticTokenTypes.string
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
highlightView(node, acceptor) {
|
|
225
|
+
if (node.name) {
|
|
226
|
+
acceptor({
|
|
227
|
+
node,
|
|
228
|
+
property: 'name',
|
|
229
|
+
type: SemanticTokenTypes.variable,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (node.viewOf) {
|
|
233
|
+
acceptor({
|
|
234
|
+
node,
|
|
235
|
+
keyword: 'of',
|
|
236
|
+
type: SemanticTokenTypes.keyword
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
acceptor({
|
|
240
|
+
node,
|
|
241
|
+
keyword: 'view',
|
|
242
|
+
type: SemanticTokenTypes.keyword
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StreamImpl } from 'langium';
|
|
2
|
+
import type { AstNodeDescription, AstNodeDescriptionProvider } from 'langium';
|
|
3
|
+
import { ast } from '../ast';
|
|
4
|
+
import type { LikeC4Services } from '../module';
|
|
5
|
+
import { Fqn } from '@likec4/core/types';
|
|
6
|
+
export declare class FqnIndex {
|
|
7
|
+
#private;
|
|
8
|
+
private services;
|
|
9
|
+
protected readonly descriptions: AstNodeDescriptionProvider;
|
|
10
|
+
constructor(services: LikeC4Services);
|
|
11
|
+
get(el: ast.Element): Fqn | null;
|
|
12
|
+
byFqn(fqn: Fqn): readonly AstNodeDescription[];
|
|
13
|
+
directChildrenOf(parent: Fqn): import("langium").Stream<AstNodeDescription>;
|
|
14
|
+
uniqueDescedants(parent: Fqn): StreamImpl<IterableIterator<AstNodeDescription> | null, AstNodeDescription>;
|
|
15
|
+
private doIndexElements;
|
|
16
|
+
private cleanIndexedElements;
|
|
17
|
+
}
|