zenstack 0.4.2 → 0.5.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/bin/post-install.js +0 -24
- package/bundle/cli/index.js +159 -159
- package/bundle/language-server/main.js +60 -60
- package/package.json +2 -2
- package/src/language-server/zmodel-linker.ts +0 -4
- package/src/language-server/zmodel-module.ts +0 -5
- package/src/language-server/lsp/zmodel-definition-provider.ts +0 -87
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publisher": "zenstack",
|
|
4
4
|
"displayName": "ZenStack Language Tools",
|
|
5
5
|
"description": "A toolkit for building secure CRUD apps with Next.js + Typescript",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.5.0",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "ZenStack Team"
|
|
9
9
|
},
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"vscode-languageserver": "^8.0.2",
|
|
88
88
|
"vscode-languageserver-textdocument": "^1.0.7",
|
|
89
89
|
"vscode-uri": "^3.0.6",
|
|
90
|
-
"@zenstackhq/runtime": "0.
|
|
90
|
+
"@zenstackhq/runtime": "0.5.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@prisma/internals": "~4.7.0",
|
|
@@ -129,10 +129,6 @@ export class ZModelLinker extends DefaultLinker {
|
|
|
129
129
|
document: LangiumDocument,
|
|
130
130
|
extraScopes: ScopeProvider[] = []
|
|
131
131
|
) {
|
|
132
|
-
if (node.$resolvedType) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
132
|
switch (node.$type) {
|
|
137
133
|
case LiteralExpr:
|
|
138
134
|
this.resolveLiteral(node as LiteralExpr);
|
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
import { TextDocuments } from 'vscode-languageserver';
|
|
31
31
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
32
32
|
import ZModelWorkspaceManager from './zmodel-workspace-manager';
|
|
33
|
-
import ZModelDefinitionProvider from './lsp/zmodel-definition-provider';
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* Declaration of custom services - add your own service classes here.
|
|
@@ -65,10 +64,6 @@ export const ZModelModule: Module<
|
|
|
65
64
|
new ZModelValidationRegistry(services),
|
|
66
65
|
ZModelValidator: () => new ZModelValidator(),
|
|
67
66
|
},
|
|
68
|
-
lsp: {
|
|
69
|
-
DefinitionProvider: (services) =>
|
|
70
|
-
new ZModelDefinitionProvider(services),
|
|
71
|
-
},
|
|
72
67
|
};
|
|
73
68
|
|
|
74
69
|
// this duplicates createDefaultSharedModule except that a custom WorkspaceManager is used
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CstNode,
|
|
3
|
-
DefinitionProvider,
|
|
4
|
-
findDeclarationNodeAtOffset,
|
|
5
|
-
getDocument,
|
|
6
|
-
GoToLink,
|
|
7
|
-
LangiumDocument,
|
|
8
|
-
LangiumServices,
|
|
9
|
-
MaybePromise,
|
|
10
|
-
NameProvider,
|
|
11
|
-
} from 'langium';
|
|
12
|
-
import { GrammarConfig } from 'langium/lib/grammar/grammar-config';
|
|
13
|
-
import { References } from 'langium/lib/references/references';
|
|
14
|
-
import { DefinitionParams, LocationLink } from 'vscode-languageserver';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Custom Langium DefinitionProvider implementation
|
|
18
|
-
*/
|
|
19
|
-
export default class ZModelDefinitionProvider implements DefinitionProvider {
|
|
20
|
-
protected readonly nameProvider: NameProvider;
|
|
21
|
-
protected readonly references: References;
|
|
22
|
-
protected readonly grammarConfig: GrammarConfig;
|
|
23
|
-
|
|
24
|
-
constructor(services: LangiumServices) {
|
|
25
|
-
this.nameProvider = services.references.NameProvider;
|
|
26
|
-
this.references = services.references.References;
|
|
27
|
-
this.grammarConfig = services.parser.GrammarConfig;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getDefinition(
|
|
31
|
-
document: LangiumDocument,
|
|
32
|
-
params: DefinitionParams
|
|
33
|
-
): MaybePromise<LocationLink[] | undefined> {
|
|
34
|
-
const rootNode = document.parseResult.value;
|
|
35
|
-
if (rootNode.$cstNode) {
|
|
36
|
-
const cst = rootNode.$cstNode;
|
|
37
|
-
const sourceCstNode = findDeclarationNodeAtOffset(
|
|
38
|
-
cst,
|
|
39
|
-
document.textDocument.offsetAt(params.position),
|
|
40
|
-
this.grammarConfig.nameRegexp
|
|
41
|
-
);
|
|
42
|
-
if (sourceCstNode) {
|
|
43
|
-
return this.collectLocationLinks(sourceCstNode, params);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
protected collectLocationLinks(
|
|
50
|
-
sourceCstNode: CstNode,
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
-
_params: DefinitionParams
|
|
53
|
-
): MaybePromise<LocationLink[] | undefined> {
|
|
54
|
-
const goToLink = this.findLink(sourceCstNode);
|
|
55
|
-
if (goToLink) {
|
|
56
|
-
if (
|
|
57
|
-
// this condition is for working around a potential Langium bug
|
|
58
|
-
// https://github.com/langium/langium/discussions/732
|
|
59
|
-
!goToLink.targetDocument.textDocument.uri.endsWith(
|
|
60
|
-
'stdlib.zmodel'
|
|
61
|
-
)
|
|
62
|
-
) {
|
|
63
|
-
return [
|
|
64
|
-
LocationLink.create(
|
|
65
|
-
goToLink.targetDocument.textDocument.uri,
|
|
66
|
-
(goToLink.target.element.$cstNode ?? goToLink.target)
|
|
67
|
-
.range,
|
|
68
|
-
goToLink.target.range,
|
|
69
|
-
goToLink.source.range
|
|
70
|
-
),
|
|
71
|
-
];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
protected findLink(source: CstNode): GoToLink | undefined {
|
|
78
|
-
const target = this.references.findDeclarationNode(source);
|
|
79
|
-
if (target?.element) {
|
|
80
|
-
const targetDocument = getDocument(target.element);
|
|
81
|
-
if (target && targetDocument) {
|
|
82
|
-
return { source, target, targetDocument };
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
}
|