@likec4/language-server 0.37.1 → 0.40.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/Rpc.d.ts +6 -0
- package/dist/Rpc.js +130 -0
- package/dist/ast.d.ts +0 -97
- package/dist/ast.js +127 -143
- package/dist/elementRef.d.ts +1 -2
- package/dist/elementRef.js +31 -44
- package/dist/generated/ast.d.ts +4 -5
- package/dist/generated/ast.js +310 -315
- package/dist/generated/grammar.d.ts +0 -2
- package/dist/generated/grammar.js +2 -3177
- package/dist/generated/module.d.ts +1 -6
- package/dist/generated/module.js +13 -18
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -3
- package/dist/logger.d.ts +0 -1
- package/dist/logger.js +39 -42
- package/dist/lsp/CodeLensProvider.d.ts +0 -1
- package/dist/lsp/CodeLensProvider.js +28 -32
- package/dist/lsp/DocumentLinkProvider.d.ts +0 -1
- package/dist/lsp/DocumentLinkProvider.js +26 -33
- package/dist/lsp/DocumentSymbolProvider.d.ts +0 -1
- package/dist/lsp/DocumentSymbolProvider.js +165 -167
- package/dist/lsp/HoverProvider.d.ts +0 -1
- package/dist/lsp/HoverProvider.js +35 -48
- package/dist/lsp/SemanticTokenProvider.d.ts +0 -1
- package/dist/lsp/SemanticTokenProvider.js +153 -201
- package/dist/lsp/index.d.ts +0 -1
- package/dist/lsp/index.js +5 -6
- package/dist/model/fqn-computation.d.ts +0 -1
- package/dist/model/fqn-computation.js +39 -40
- package/dist/model/fqn-index.d.ts +0 -1
- package/dist/model/fqn-index.js +112 -142
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.js +5 -6
- package/dist/model/model-builder.d.ts +10 -6
- package/dist/model/model-builder.js +242 -177
- package/dist/model/model-locator.d.ts +1 -2
- package/dist/model/model-locator.js +102 -100
- package/dist/model/model-parser.d.ts +2 -7
- package/dist/model/model-parser.js +296 -287
- package/dist/module.d.ts +4 -2
- package/dist/module.js +69 -60
- package/dist/protocol.d.ts +16 -20
- package/dist/protocol.js +14 -22
- package/dist/references/index.d.ts +0 -1
- package/dist/references/index.js +2 -3
- package/dist/references/scope-computation.d.ts +2 -3
- package/dist/references/scope-computation.js +68 -70
- package/dist/references/scope-provider.d.ts +1 -2
- package/dist/references/scope-provider.js +126 -116
- package/dist/shared/WorkspaceManager.d.ts +2 -4
- package/dist/shared/WorkspaceManager.js +13 -16
- package/dist/shared/index.d.ts +0 -1
- package/dist/shared/index.js +1 -2
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.js +1 -2
- package/dist/test/testServices.d.ts +6 -7
- package/dist/test/testServices.js +64 -61
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +4 -3
- package/dist/validation/element.d.ts +0 -2
- package/dist/validation/element.js +28 -39
- package/dist/validation/index.d.ts +0 -1
- package/dist/validation/index.js +36 -46
- package/dist/validation/relation.d.ts +0 -2
- package/dist/validation/relation.js +43 -47
- package/dist/validation/specification.d.ts +0 -2
- package/dist/validation/specification.js +21 -30
- package/dist/validation/view.d.ts +0 -2
- package/dist/validation/view.js +16 -22
- package/package.json +20 -13
- package/contrib/likec4.monarch.ts +0 -48
- package/contrib/likec4.tmLanguage.json +0 -73
- package/dist/registerProtocolHandlers.d.ts +0 -3
- package/dist/registerProtocolHandlers.js +0 -112
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
* DO NOT EDIT MANUALLY!
|
|
4
4
|
******************************************************************************/
|
|
5
5
|
import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedServices, LangiumServices, Module, IParserConfig } from 'langium';
|
|
6
|
-
export declare const LikeC4LanguageMetaData:
|
|
7
|
-
readonly languageId: "likec4";
|
|
8
|
-
readonly fileExtensions: readonly [".c4", ".likec4", ".like-c4"];
|
|
9
|
-
readonly caseInsensitive: false;
|
|
10
|
-
};
|
|
6
|
+
export declare const LikeC4LanguageMetaData: LanguageMetaData;
|
|
11
7
|
export declare const parserConfig: IParserConfig;
|
|
12
8
|
export declare const LikeC4GeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices>;
|
|
13
9
|
export declare const LikeC4GeneratedModule: Module<LangiumServices, LangiumGeneratedServices>;
|
|
14
|
-
//# sourceMappingURL=module.d.ts.map
|
package/dist/generated/module.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* DO NOT EDIT MANUALLY!
|
|
4
|
-
******************************************************************************/
|
|
5
|
-
import { LikeC4AstReflection } from './ast.js';
|
|
6
|
-
import { LikeC4Grammar } from './grammar.js';
|
|
1
|
+
import { LikeC4AstReflection } from "./ast.js";
|
|
2
|
+
import { LikeC4Grammar } from "./grammar.js";
|
|
7
3
|
export const LikeC4LanguageMetaData = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
languageId: "likec4",
|
|
5
|
+
fileExtensions: [".c4", ".likec4", ".like-c4"],
|
|
6
|
+
caseInsensitive: false
|
|
11
7
|
};
|
|
12
8
|
export const parserConfig = {
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
recoveryEnabled: true,
|
|
10
|
+
nodeLocationTracking: "full"
|
|
15
11
|
};
|
|
16
12
|
export const LikeC4GeneratedSharedModule = {
|
|
17
|
-
|
|
13
|
+
AstReflection: () => new LikeC4AstReflection()
|
|
18
14
|
};
|
|
19
15
|
export const LikeC4GeneratedModule = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
Grammar: () => LikeC4Grammar(),
|
|
17
|
+
LanguageMetaData: () => LikeC4LanguageMetaData,
|
|
18
|
+
parser: {
|
|
19
|
+
ParserConfig: () => parserConfig
|
|
20
|
+
}
|
|
25
21
|
};
|
|
26
|
-
//# sourceMappingURL=module.js.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { logger } from
|
|
2
|
-
export { createLanguageServices } from
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { logger } from "./logger.js";
|
|
2
|
+
export { createLanguageServices } from "./module.js";
|
package/dist/logger.d.ts
CHANGED
package/dist/logger.js
CHANGED
|
@@ -1,50 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
import { normalizeError } from '@likec4/core';
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
1
|
+
import { normalizeError } from "@likec4/core";
|
|
4
2
|
let isSilent = false;
|
|
5
3
|
export const logger = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
console.error(normalizeError(message));
|
|
34
|
-
},
|
|
35
|
-
silent(silent = true) {
|
|
36
|
-
isSilent = silent;
|
|
4
|
+
trace(message) {
|
|
5
|
+
if (isSilent)
|
|
6
|
+
return;
|
|
7
|
+
console.trace(message);
|
|
8
|
+
},
|
|
9
|
+
debug(message) {
|
|
10
|
+
if (isSilent)
|
|
11
|
+
return;
|
|
12
|
+
console.debug(message);
|
|
13
|
+
},
|
|
14
|
+
info(message) {
|
|
15
|
+
if (isSilent)
|
|
16
|
+
return;
|
|
17
|
+
console.info(message);
|
|
18
|
+
},
|
|
19
|
+
warn(message) {
|
|
20
|
+
if (isSilent)
|
|
21
|
+
return;
|
|
22
|
+
console.warn(message);
|
|
23
|
+
},
|
|
24
|
+
error(message) {
|
|
25
|
+
if (isSilent)
|
|
26
|
+
return;
|
|
27
|
+
if (typeof message === "string") {
|
|
28
|
+
console.error(message);
|
|
29
|
+
return;
|
|
37
30
|
}
|
|
31
|
+
console.error(normalizeError(message));
|
|
32
|
+
},
|
|
33
|
+
silent(silent = true) {
|
|
34
|
+
isSilent = silent;
|
|
35
|
+
}
|
|
38
36
|
};
|
|
39
37
|
export function logError(error) {
|
|
40
|
-
|
|
38
|
+
logger.error(error);
|
|
41
39
|
}
|
|
42
40
|
export function logWarnError(err) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
if (typeof err === "string") {
|
|
42
|
+
logger.warn(err);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const error = normalizeError(err);
|
|
46
|
+
logger.warn(`${error.name}: ${error.message}`);
|
|
49
47
|
}
|
|
50
|
-
//# sourceMappingURL=logger.js.map
|
|
@@ -6,4 +6,3 @@ export declare class LikeC4CodeLensProvider implements CodeLensProvider {
|
|
|
6
6
|
constructor(services: LikeC4Services);
|
|
7
7
|
provideCodeLens(doc: LangiumDocument, _params: CodeLensParams, _cancelToken?: CancellationToken): MaybePromise<CodeLens[] | undefined>;
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=CodeLensProvider.d.ts.map
|
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
import { ElementViewOps, isParsedLikeC4LangiumDocument } from
|
|
1
|
+
import { ElementViewOps, isParsedLikeC4LangiumDocument } from "../ast.js";
|
|
2
2
|
export class LikeC4CodeLensProvider {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
constructor(services) {
|
|
4
|
+
this.services = services;
|
|
5
|
+
}
|
|
6
|
+
provideCodeLens(doc, _params, _cancelToken) {
|
|
7
|
+
if (!isParsedLikeC4LangiumDocument(doc)) {
|
|
8
|
+
return;
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
return doc.parseResult.value.views?.views.flatMap((ast) => {
|
|
11
|
+
const viewId = ElementViewOps.readId(ast);
|
|
12
|
+
const range = ast.$cstNode?.range;
|
|
13
|
+
if (!range || !viewId) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
range: {
|
|
18
|
+
start: range.start,
|
|
19
|
+
end: {
|
|
20
|
+
line: range.start.line,
|
|
21
|
+
character: range.start.character + 4
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
command: {
|
|
25
|
+
command: "likec4.open-preview",
|
|
26
|
+
arguments: [viewId],
|
|
27
|
+
title: "open preview"
|
|
11
28
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
}
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
35
32
|
}
|
|
36
|
-
//# sourceMappingURL=CodeLensProvider.js.map
|
|
@@ -6,4 +6,3 @@ export declare class LikeC4DocumentLinkProvider implements DocumentLinkProvider
|
|
|
6
6
|
constructor(services: LikeC4Services);
|
|
7
7
|
getDocumentLinks(doc: LangiumDocument, _params: DocumentLinkParams): MaybePromise<DocumentLink[]>;
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=DocumentLinkProvider.d.ts.map
|
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
import { findNodeForProperty, streamAllContents } from
|
|
2
|
-
import { ast, isParsedLikeC4LangiumDocument } from
|
|
3
|
-
import { logError } from
|
|
1
|
+
import { findNodeForProperty, streamAllContents } from "langium";
|
|
2
|
+
import { ast, isParsedLikeC4LangiumDocument } from "../ast.js";
|
|
3
|
+
import { logError } from "../logger.js";
|
|
4
4
|
export class LikeC4DocumentLinkProvider {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
constructor(services) {
|
|
6
|
+
this.services = services;
|
|
7
|
+
}
|
|
8
|
+
getDocumentLinks(doc, _params) {
|
|
9
|
+
if (!isParsedLikeC4LangiumDocument(doc)) {
|
|
10
|
+
return [];
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const base = new URL(doc.uri.toString());
|
|
13
|
+
return streamAllContents(doc.parseResult.value).filter(ast.isLinkProperty).flatMap((n) => {
|
|
14
|
+
try {
|
|
15
|
+
const u = new URL(n.value, base);
|
|
16
|
+
const valueCst = findNodeForProperty(n.$cstNode, "value");
|
|
17
|
+
if (!valueCst) {
|
|
18
|
+
return [];
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
range: valueCst.range,
|
|
26
|
-
target: u.toString()
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
logError(e);
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
.toArray();
|
|
35
|
-
}
|
|
20
|
+
return {
|
|
21
|
+
range: valueCst.range,
|
|
22
|
+
target: u.toString()
|
|
23
|
+
};
|
|
24
|
+
} catch (e) {
|
|
25
|
+
logError(e);
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}).toArray();
|
|
29
|
+
}
|
|
36
30
|
}
|
|
37
|
-
//# sourceMappingURL=DocumentLinkProvider.js.map
|
|
@@ -13,4 +13,3 @@ export declare class LikeC4DocumentSymbolProvider implements DocumentSymbolProvi
|
|
|
13
13
|
protected getElementSymbol(astElement: ast.Element): DocumentSymbol[];
|
|
14
14
|
protected getModelViewsSymbol(astViews: ast.ModelViews): DocumentSymbol[];
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=DocumentSymbolProvider.d.ts.map
|
|
@@ -1,178 +1,176 @@
|
|
|
1
|
-
import { findNodeForProperty } from
|
|
2
|
-
import { compact, concat, isEmpty, map, pipe } from
|
|
3
|
-
import { SymbolKind } from
|
|
4
|
-
import { ast } from
|
|
5
|
-
import { logError } from
|
|
1
|
+
import { findNodeForProperty } from "langium";
|
|
2
|
+
import { compact, concat, isEmpty, map, pipe } from "remeda";
|
|
3
|
+
import { SymbolKind } from "vscode-languageserver-protocol";
|
|
4
|
+
import { ast } from "../ast.js";
|
|
5
|
+
import { logError } from "../logger.js";
|
|
6
6
|
function getElementKindSymbol(astKind) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
if (!astKind.$cstNode || !astKind.kind.$cstNode || isEmpty(astKind.kind.name))
|
|
8
|
+
return null;
|
|
9
|
+
return {
|
|
10
|
+
kind: SymbolKind.Class,
|
|
11
|
+
name: astKind.kind.name,
|
|
12
|
+
range: astKind.$cstNode.range,
|
|
13
|
+
selectionRange: astKind.kind.$cstNode.range
|
|
14
|
+
};
|
|
15
15
|
}
|
|
16
16
|
function getTagSymbol(astTag) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
if (!astTag.$cstNode || !astTag.tag.$cstNode || isEmpty(astTag.tag.name))
|
|
18
|
+
return null;
|
|
19
|
+
return {
|
|
20
|
+
kind: SymbolKind.Interface,
|
|
21
|
+
name: "#" + astTag.tag.name,
|
|
22
|
+
range: astTag.$cstNode.range,
|
|
23
|
+
selectionRange: astTag.tag.$cstNode.range
|
|
24
|
+
};
|
|
25
25
|
}
|
|
26
26
|
function getElementViewSymbol(astView) {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const cst = astView?.$cstNode;
|
|
28
|
+
if (!cst)
|
|
29
|
+
return [];
|
|
30
|
+
const nameNode = astView.name ? findNodeForProperty(cst, "name") : null;
|
|
31
|
+
if (!nameNode)
|
|
32
|
+
return [];
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
kind: SymbolKind.Class,
|
|
36
|
+
name: nameNode.text,
|
|
37
|
+
range: cst.range,
|
|
38
|
+
selectionRange: nameNode.range,
|
|
39
|
+
children: []
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
export class LikeC4DocumentSymbolProvider {
|
|
44
|
+
constructor(services) {
|
|
45
|
+
this.services = services;
|
|
46
|
+
}
|
|
47
|
+
getSymbols(document) {
|
|
48
|
+
const { specification, model, views } = document.parseResult.value;
|
|
49
|
+
return [
|
|
50
|
+
() => specification && this.getSpecSymbol(specification),
|
|
51
|
+
() => model && this.getModelSymbol(model),
|
|
52
|
+
() => views && this.getModelViewsSymbol(views)
|
|
53
|
+
].flatMap((fn) => {
|
|
54
|
+
try {
|
|
55
|
+
return fn() ?? [];
|
|
56
|
+
} catch (e) {
|
|
57
|
+
logError(e);
|
|
29
58
|
return [];
|
|
30
|
-
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
getSpecSymbol(astSpec) {
|
|
63
|
+
const cstModel = astSpec?.$cstNode;
|
|
64
|
+
if (!cstModel)
|
|
65
|
+
return [];
|
|
66
|
+
const specKeywordNode = findNodeForProperty(cstModel, "name");
|
|
67
|
+
if (!specKeywordNode)
|
|
68
|
+
return [];
|
|
69
|
+
const specSymbols = pipe(
|
|
70
|
+
concat(astSpec.elements, astSpec.tags),
|
|
71
|
+
map((nd) => {
|
|
72
|
+
if (ast.isSpecificationElementKind(nd)) {
|
|
73
|
+
return getElementKindSymbol(nd);
|
|
74
|
+
} else {
|
|
75
|
+
return getTagSymbol(nd);
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
compact
|
|
79
|
+
);
|
|
80
|
+
if (specSymbols.length === 0)
|
|
81
|
+
return [];
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
kind: SymbolKind.Namespace,
|
|
85
|
+
name: astSpec.name,
|
|
86
|
+
range: cstModel.range,
|
|
87
|
+
selectionRange: specKeywordNode.range,
|
|
88
|
+
children: specSymbols
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
getModelSymbol(astModel) {
|
|
93
|
+
const cstModel = astModel.$cstNode;
|
|
94
|
+
if (!cstModel)
|
|
95
|
+
return [];
|
|
96
|
+
const nameNode = findNodeForProperty(cstModel, "name");
|
|
31
97
|
if (!nameNode)
|
|
32
|
-
|
|
98
|
+
return [];
|
|
33
99
|
return [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
100
|
+
{
|
|
101
|
+
kind: SymbolKind.Namespace,
|
|
102
|
+
name: astModel.name,
|
|
103
|
+
range: cstModel.range,
|
|
104
|
+
selectionRange: nameNode.range,
|
|
105
|
+
children: astModel.elements.flatMap((e) => this.getElementsSymbol(e))
|
|
106
|
+
}
|
|
41
107
|
];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
() => views && this.getModelViewsSymbol(views)
|
|
54
|
-
].flatMap(fn => {
|
|
55
|
-
try {
|
|
56
|
-
return fn() ?? [];
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
logError(e);
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
getSpecSymbol(astSpec) {
|
|
65
|
-
const cstModel = astSpec?.$cstNode;
|
|
66
|
-
if (!cstModel)
|
|
67
|
-
return [];
|
|
68
|
-
const specKeywordNode = findNodeForProperty(cstModel, 'name');
|
|
69
|
-
if (!specKeywordNode)
|
|
70
|
-
return [];
|
|
71
|
-
const specSymbols = pipe(concat(astSpec.elements, astSpec.tags), map(nd => {
|
|
72
|
-
if (ast.isSpecificationElementKind(nd)) {
|
|
73
|
-
return getElementKindSymbol(nd);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return getTagSymbol(nd);
|
|
77
|
-
}
|
|
78
|
-
}), compact);
|
|
79
|
-
if (specSymbols.length === 0)
|
|
80
|
-
return [];
|
|
81
|
-
return [
|
|
82
|
-
{
|
|
83
|
-
kind: SymbolKind.Namespace,
|
|
84
|
-
name: astSpec.name,
|
|
85
|
-
range: cstModel.range,
|
|
86
|
-
selectionRange: specKeywordNode.range,
|
|
87
|
-
children: specSymbols
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
getModelSymbol(astModel) {
|
|
92
|
-
const cstModel = astModel.$cstNode;
|
|
93
|
-
if (!cstModel)
|
|
94
|
-
return [];
|
|
95
|
-
const nameNode = findNodeForProperty(cstModel, 'name');
|
|
96
|
-
if (!nameNode)
|
|
97
|
-
return [];
|
|
98
|
-
return [
|
|
99
|
-
{
|
|
100
|
-
kind: SymbolKind.Namespace,
|
|
101
|
-
name: astModel.name,
|
|
102
|
-
range: cstModel.range,
|
|
103
|
-
selectionRange: nameNode.range,
|
|
104
|
-
children: astModel.elements.flatMap(e => this.getElementsSymbol(e))
|
|
105
|
-
}
|
|
106
|
-
];
|
|
107
|
-
}
|
|
108
|
-
getElementsSymbol(el) {
|
|
109
|
-
try {
|
|
110
|
-
if (ast.isExtendElement(el)) {
|
|
111
|
-
return this.getExtendElementSymbol(el);
|
|
112
|
-
}
|
|
113
|
-
if (ast.isElement(el)) {
|
|
114
|
-
return this.getElementSymbol(el);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
logError(e);
|
|
119
|
-
}
|
|
120
|
-
return [];
|
|
121
|
-
}
|
|
122
|
-
getExtendElementSymbol(astElement) {
|
|
123
|
-
const cst = astElement.$cstNode;
|
|
124
|
-
const nameNode = astElement.element.$cstNode;
|
|
125
|
-
const body = astElement.body;
|
|
126
|
-
if (!cst || !nameNode || !body)
|
|
127
|
-
return [];
|
|
128
|
-
return [
|
|
129
|
-
{
|
|
130
|
-
kind: SymbolKind.Constructor,
|
|
131
|
-
name: nameNode.text,
|
|
132
|
-
range: cst.range,
|
|
133
|
-
selectionRange: nameNode.range,
|
|
134
|
-
children: body.elements.flatMap(e => this.getElementsSymbol(e))
|
|
135
|
-
}
|
|
136
|
-
];
|
|
137
|
-
}
|
|
138
|
-
getElementSymbol(astElement) {
|
|
139
|
-
const cst = astElement.$cstNode;
|
|
140
|
-
if (!cst)
|
|
141
|
-
return [];
|
|
142
|
-
const nameNode = findNodeForProperty(cst, 'name');
|
|
143
|
-
if (!nameNode)
|
|
144
|
-
return [];
|
|
145
|
-
const name = astElement.name;
|
|
146
|
-
const kind = astElement.kind.$refText;
|
|
147
|
-
// TODO: return the title as well
|
|
148
|
-
const detail = kind; // + (astElement.title ? ': ' + astElement.title : '').replaceAll('\n', ' ').trim()
|
|
149
|
-
return [
|
|
150
|
-
{
|
|
151
|
-
kind: SymbolKind.Constructor,
|
|
152
|
-
name: name,
|
|
153
|
-
range: cst.range,
|
|
154
|
-
selectionRange: nameNode.range,
|
|
155
|
-
detail,
|
|
156
|
-
children: astElement.body?.elements.flatMap(e => this.getElementsSymbol(e)) ?? []
|
|
157
|
-
}
|
|
158
|
-
];
|
|
159
|
-
}
|
|
160
|
-
getModelViewsSymbol(astViews) {
|
|
161
|
-
const cst = astViews.$cstNode;
|
|
162
|
-
if (!cst)
|
|
163
|
-
return [];
|
|
164
|
-
const nameNode = findNodeForProperty(cst, 'name');
|
|
165
|
-
if (!nameNode)
|
|
166
|
-
return [];
|
|
167
|
-
return [
|
|
168
|
-
{
|
|
169
|
-
kind: SymbolKind.Namespace,
|
|
170
|
-
name: astViews.name,
|
|
171
|
-
range: cst.range,
|
|
172
|
-
selectionRange: nameNode.range,
|
|
173
|
-
children: astViews.views.flatMap(e => getElementViewSymbol(e))
|
|
174
|
-
}
|
|
175
|
-
];
|
|
108
|
+
}
|
|
109
|
+
getElementsSymbol(el) {
|
|
110
|
+
try {
|
|
111
|
+
if (ast.isExtendElement(el)) {
|
|
112
|
+
return this.getExtendElementSymbol(el);
|
|
113
|
+
}
|
|
114
|
+
if (ast.isElement(el)) {
|
|
115
|
+
return this.getElementSymbol(el);
|
|
116
|
+
}
|
|
117
|
+
} catch (e) {
|
|
118
|
+
logError(e);
|
|
176
119
|
}
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
getExtendElementSymbol(astElement) {
|
|
123
|
+
const cst = astElement.$cstNode;
|
|
124
|
+
const nameNode = astElement.element.$cstNode;
|
|
125
|
+
const body = astElement.body;
|
|
126
|
+
if (!cst || !nameNode || !body)
|
|
127
|
+
return [];
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
kind: SymbolKind.Constructor,
|
|
131
|
+
name: nameNode.text,
|
|
132
|
+
range: cst.range,
|
|
133
|
+
selectionRange: nameNode.range,
|
|
134
|
+
children: body.elements.flatMap((e) => this.getElementsSymbol(e))
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
getElementSymbol(astElement) {
|
|
139
|
+
const cst = astElement.$cstNode;
|
|
140
|
+
if (!cst)
|
|
141
|
+
return [];
|
|
142
|
+
const nameNode = findNodeForProperty(cst, "name");
|
|
143
|
+
if (!nameNode)
|
|
144
|
+
return [];
|
|
145
|
+
const name = astElement.name;
|
|
146
|
+
const kind = astElement.kind.$refText;
|
|
147
|
+
const detail = kind;
|
|
148
|
+
return [
|
|
149
|
+
{
|
|
150
|
+
kind: SymbolKind.Constructor,
|
|
151
|
+
name,
|
|
152
|
+
range: cst.range,
|
|
153
|
+
selectionRange: nameNode.range,
|
|
154
|
+
detail,
|
|
155
|
+
children: astElement.body?.elements.flatMap((e) => this.getElementsSymbol(e)) ?? []
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
getModelViewsSymbol(astViews) {
|
|
160
|
+
const cst = astViews.$cstNode;
|
|
161
|
+
if (!cst)
|
|
162
|
+
return [];
|
|
163
|
+
const nameNode = findNodeForProperty(cst, "name");
|
|
164
|
+
if (!nameNode)
|
|
165
|
+
return [];
|
|
166
|
+
return [
|
|
167
|
+
{
|
|
168
|
+
kind: SymbolKind.Namespace,
|
|
169
|
+
name: astViews.name,
|
|
170
|
+
range: cst.range,
|
|
171
|
+
selectionRange: nameNode.range,
|
|
172
|
+
children: astViews.views.flatMap((e) => getElementViewSymbol(e))
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
}
|
|
177
176
|
}
|
|
178
|
-
//# sourceMappingURL=DocumentSymbolProvider.js.map
|