@aws/lsp-yaml 0.0.1
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/CHANGELOG.md +3 -0
- package/LICENSE +175 -0
- package/NOTICE +1 -0
- package/README.md +17 -0
- package/SECURITY.md +3 -0
- package/out/index.d.ts +2 -0
- package/out/index.js +8 -0
- package/out/index.js.map +1 -0
- package/out/language-server/yamlServer.d.ts +11 -0
- package/out/language-server/yamlServer.js +109 -0
- package/out/language-server/yamlServer.js.map +1 -0
- package/out/language-service/formattingOptions.d.ts +4 -0
- package/out/language-service/formattingOptions.js +3 -0
- package/out/language-service/formattingOptions.js.map +1 -0
- package/out/language-service/yamlLanguageService.d.ts +25 -0
- package/out/language-service/yamlLanguageService.js +68 -0
- package/out/language-service/yamlLanguageService.js.map +1 -0
- package/package.json +45 -0
- package/patchYamlPackage.js +60 -0
- package/patches/markdown/yamlHover.esm.patch +47 -0
- package/patches/markdown/yamlHover.src.patch +47 -0
- package/patches/markdown/yamlHover.umd.patch +47 -0
- package/patches/markdown/yamlLanguageService.esm.patch +10 -0
- package/patches/markdown/yamlLanguageService.src.patch +10 -0
- package/patches/markdown/yamlLanguageService.umd.patch +10 -0
- package/patches/unsafe-eval/yamlSchemaService.esm.patch +34 -0
- package/patches/unsafe-eval/yamlSchemaService.src.patch +33 -0
- package/patches/unsafe-eval/yamlSchemaService.umd.patch +33 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
package/NOTICE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## Exports
|
|
2
|
+
── index
|
|
3
|
+
└── CreateYamlLanguageServer - a function that creates and returns a new instance of DEXP Language Server
|
|
4
|
+
└── YamlLanguageService - YAML language service. Provides language features like hover, completion, diagnostics and formatting
|
|
5
|
+
|
|
6
|
+
## Temporary Patch for yaml-language-server Dependency
|
|
7
|
+
|
|
8
|
+
In the current state of this package, we need to apply a temporary patch to the yaml-language-server dependency.
|
|
9
|
+
|
|
10
|
+
The script applies 2 patches:
|
|
11
|
+
- `patches/markdown`: adds hover setting to enable/disable Title and Source from hover tooltip. [PR](https://github.com/redhat-developer/yaml-language-server/pull/892)
|
|
12
|
+
- `patches/unsafe-eval`: adds skipSchemaValidation settings to enable/disable json schema validation. [PR draft](https://github.com/redhat-developer/yaml-language-server/pull/965).
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
The patch file is applied during the installation process using the `postinstall` script in the `package.json` file. This script runs the `patchYamlPackage.js` script, which searches path to the `yaml-language-server` package and applies the patches once.
|
|
16
|
+
|
|
17
|
+
### Note: This is a temporary solution, and we plan to remove the custom patching once the yaml-language-server package is updated. The features from PRs above should be merged to yaml-language-server package. After features are merged we need to update the version and enable skipSchemaValidation setting.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
## Security issue notifications
|
|
2
|
+
|
|
3
|
+
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
|
package/out/index.d.ts
ADDED
package/out/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YamlLanguageService = exports.CreateYamlLanguageServer = void 0;
|
|
4
|
+
var yamlServer_1 = require("./language-server/yamlServer");
|
|
5
|
+
Object.defineProperty(exports, "CreateYamlLanguageServer", { enumerable: true, get: function () { return yamlServer_1.CreateYamlLanguageServer; } });
|
|
6
|
+
var yamlLanguageService_1 = require("./language-service/yamlLanguageService");
|
|
7
|
+
Object.defineProperty(exports, "YamlLanguageService", { enumerable: true, get: function () { return yamlLanguageService_1.YamlLanguageService; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAA9D,sHAAA,wBAAwB,OAAA;AACjC,8EAA4E;AAAnE,0HAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Server } from '@aws/language-server-runtimes/server-interface';
|
|
2
|
+
import { AwsLanguageService } from '@aws/lsp-core/out/base';
|
|
3
|
+
/**
|
|
4
|
+
* This is a demonstration language server that handles both JSON and YAML files according to the
|
|
5
|
+
* CloudFormation or SAM JSON-Schema.
|
|
6
|
+
*
|
|
7
|
+
* This illustrates how we can wrap LSP Connection calls around a provided language service.
|
|
8
|
+
* In this case, the service is a composition of a JSON processor and a YAML processor.
|
|
9
|
+
*/
|
|
10
|
+
export declare const YamlServerFactory: (service: AwsLanguageService) => Server;
|
|
11
|
+
export declare const CreateYamlLanguageServer: (displayName: string, defaultSchemaUri: string, uriResolver?: (url: string) => Promise<string>) => Server;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateYamlLanguageServer = exports.YamlServerFactory = void 0;
|
|
4
|
+
const base_1 = require("@aws/lsp-core/out/base");
|
|
5
|
+
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
6
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
7
|
+
const server_interface_1 = require("@aws/language-server-runtimes/server-interface");
|
|
8
|
+
const yamlLanguageService_1 = require("../language-service/yamlLanguageService");
|
|
9
|
+
/**
|
|
10
|
+
* This is a demonstration language server that handles both JSON and YAML files according to the
|
|
11
|
+
* CloudFormation or SAM JSON-Schema.
|
|
12
|
+
*
|
|
13
|
+
* This illustrates how we can wrap LSP Connection calls around a provided language service.
|
|
14
|
+
* In this case, the service is a composition of a JSON processor and a YAML processor.
|
|
15
|
+
*/
|
|
16
|
+
const YamlServerFactory = (service) => ({ credentialsProvider, lsp, workspace, telemetry, logging }) => {
|
|
17
|
+
const onInitializeHandler = () => {
|
|
18
|
+
return {
|
|
19
|
+
capabilities: {
|
|
20
|
+
completionProvider: { resolveProvider: true },
|
|
21
|
+
hoverProvider: true,
|
|
22
|
+
documentFormattingProvider: true,
|
|
23
|
+
textDocumentSync: {
|
|
24
|
+
openClose: true,
|
|
25
|
+
change: vscode_languageserver_1.TextDocumentSyncKind.Incremental,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const onInitializedHandler = async () => { };
|
|
31
|
+
const onCompletionHandler = async (params, _token) => {
|
|
32
|
+
const emptyCompletionList = server_interface_1.CompletionList.create([]);
|
|
33
|
+
const textDocument = await workspace.getTextDocument(params.textDocument.uri);
|
|
34
|
+
if (!textDocument) {
|
|
35
|
+
logging.log(`textDocument [${params.textDocument.uri}] not found`);
|
|
36
|
+
return emptyCompletionList;
|
|
37
|
+
}
|
|
38
|
+
const completions = await service.doComplete(textDocument, params.position);
|
|
39
|
+
return completions ?? emptyCompletionList;
|
|
40
|
+
};
|
|
41
|
+
const onHoverHandler = async (params, _token) => {
|
|
42
|
+
const textDocument = await workspace.getTextDocument(params.textDocument.uri);
|
|
43
|
+
if (!textDocument) {
|
|
44
|
+
logging.log(`textDocument [${params.textDocument.uri}] not found`);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const hover = await service.doHover(textDocument, params.position);
|
|
48
|
+
return hover;
|
|
49
|
+
};
|
|
50
|
+
const onDidChangeTextDocumentHandler = async (params) => {
|
|
51
|
+
const textDocument = await workspace.getTextDocument(params.textDocument.uri);
|
|
52
|
+
if (!textDocument) {
|
|
53
|
+
logging.log(`textDocument [${params.textDocument.uri}] not found`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const diagnostics = await service.doValidation(textDocument);
|
|
57
|
+
await lsp.publishDiagnostics({
|
|
58
|
+
uri: params.textDocument.uri,
|
|
59
|
+
diagnostics: diagnostics,
|
|
60
|
+
version: textDocument.version,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const onDidOpenTextDocumentHandler = async (params) => {
|
|
64
|
+
let textDocument = await workspace.getTextDocument(params.textDocument.uri);
|
|
65
|
+
if (!textDocument) {
|
|
66
|
+
textDocument = vscode_languageserver_textdocument_1.TextDocument.create(params.textDocument.uri, params.textDocument.languageId, params.textDocument.version, params.textDocument.text);
|
|
67
|
+
}
|
|
68
|
+
const diagnostics = await service.doValidation(textDocument);
|
|
69
|
+
await lsp.publishDiagnostics({
|
|
70
|
+
uri: params.textDocument.uri,
|
|
71
|
+
diagnostics: diagnostics,
|
|
72
|
+
version: textDocument.version,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const onFormatHandler = async (params) => {
|
|
76
|
+
const textDocument = await workspace.getTextDocument(params.textDocument.uri);
|
|
77
|
+
if (!textDocument) {
|
|
78
|
+
logging.log(`textDocument [${params.textDocument.uri}] not found`);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const format = service.format(textDocument, base_1.textDocumentUtils.getFullRange(textDocument), params.options);
|
|
82
|
+
return format;
|
|
83
|
+
};
|
|
84
|
+
lsp.onInitialized(onInitializedHandler);
|
|
85
|
+
lsp.onCompletion(onCompletionHandler);
|
|
86
|
+
lsp.onDidChangeTextDocument(onDidChangeTextDocumentHandler);
|
|
87
|
+
lsp.onDidOpenTextDocument(onDidOpenTextDocumentHandler);
|
|
88
|
+
lsp.onHover(onHoverHandler);
|
|
89
|
+
lsp.onDidFormatDocument(onFormatHandler);
|
|
90
|
+
lsp.addInitializer(onInitializeHandler);
|
|
91
|
+
logging.log('The YAML LSP Language Server has been initialised');
|
|
92
|
+
// disposable
|
|
93
|
+
return () => {
|
|
94
|
+
// Do nothing
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.YamlServerFactory = YamlServerFactory;
|
|
98
|
+
async function getSchema(url) {
|
|
99
|
+
const response = await fetch(url);
|
|
100
|
+
const schema = await (await response.blob()).text();
|
|
101
|
+
return schema;
|
|
102
|
+
}
|
|
103
|
+
const CreateYamlLanguageServer = (displayName, defaultSchemaUri, uriResolver = getSchema) => (0, exports.YamlServerFactory)((0, yamlLanguageService_1.create)({
|
|
104
|
+
displayName: displayName,
|
|
105
|
+
defaultSchemaUri: defaultSchemaUri,
|
|
106
|
+
uriResolver: uriResolver,
|
|
107
|
+
}));
|
|
108
|
+
exports.CreateYamlLanguageServer = CreateYamlLanguageServer;
|
|
109
|
+
//# sourceMappingURL=yamlServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yamlServer.js","sourceRoot":"","sources":["../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mBAAmB,CAAC,CAAA;IAEvC,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAA;IAEhE,aAAa;IACb,OAAO,GAAG,EAAE;QACR,aAAa;IACjB,CAAC,CAAA;AACL,CAAC,CAAA;AA1GQ,QAAA,iBAAiB,qBA0GzB;AAEL,KAAK,UAAU,SAAS,CAAC,GAAW;IAChC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAEnD,OAAO,MAAM,CAAA;AACjB,CAAC;AAEM,MAAM,wBAAwB,GAAG,CACpC,WAAmB,EACnB,gBAAwB,EACxB,cAAgD,SAAS,EAC3D,EAAE,CACA,IAAA,yBAAiB,EACb,IAAA,4BAAM,EAAC;IACH,WAAW,EAAE,WAAW;IACxB,gBAAgB,EAAE,gBAAgB;IAClC,WAAW,EAAE,WAAW;CAC3B,CAAC,CACL,CAAA;AAXQ,QAAA,wBAAwB,4BAWhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formattingOptions.js","sourceRoot":"","sources":["../../src/language-service/formattingOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AwsLanguageService, UriResolver } from '@aws/lsp-core/out/base';
|
|
2
|
+
import { CompletionList, Diagnostic, Hover, Position, Range, TextEdit } from 'vscode-languageserver';
|
|
3
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
import { YamlFormattingOptions } from './formattingOptions';
|
|
5
|
+
export type YamlLanguageServiceProps = {
|
|
6
|
+
displayName: string;
|
|
7
|
+
defaultSchemaUri: string;
|
|
8
|
+
uriResolver: UriResolver;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* This is a thin wrapper around the Redhat Yaml Language Service
|
|
12
|
+
* https://github.com/redhat-developer/yaml-language-server/
|
|
13
|
+
*/
|
|
14
|
+
export declare class YamlLanguageService implements AwsLanguageService {
|
|
15
|
+
private readonly props;
|
|
16
|
+
private yamlService;
|
|
17
|
+
constructor(props: YamlLanguageServiceProps);
|
|
18
|
+
isSupported(document: TextDocument): boolean;
|
|
19
|
+
doValidation(document: TextDocument): Promise<Diagnostic[]>;
|
|
20
|
+
doComplete(document: TextDocument, position: Position): Promise<CompletionList>;
|
|
21
|
+
doHover(document: TextDocument, position: Position): Promise<Hover | null>;
|
|
22
|
+
format(document: TextDocument, range: Range, options: YamlFormattingOptions): TextEdit[];
|
|
23
|
+
private updateSchemaMapping;
|
|
24
|
+
}
|
|
25
|
+
export declare function create(props: YamlLanguageServiceProps): AwsLanguageService;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = exports.YamlLanguageService = void 0;
|
|
4
|
+
const base_1 = require("@aws/lsp-core/out/base");
|
|
5
|
+
const yaml_language_server_1 = require("yaml-language-server");
|
|
6
|
+
/**
|
|
7
|
+
* This is a thin wrapper around the Redhat Yaml Language Service
|
|
8
|
+
* https://github.com/redhat-developer/yaml-language-server/
|
|
9
|
+
*/
|
|
10
|
+
class YamlLanguageService {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
this.props = props;
|
|
13
|
+
const workspaceContext = {
|
|
14
|
+
resolveRelativePath(relativePath, resource) {
|
|
15
|
+
return new URL(relativePath, resource).href;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
this.yamlService = (0, yaml_language_server_1.getLanguageService)({
|
|
19
|
+
schemaRequestService: this.props.uriResolver,
|
|
20
|
+
workspaceContext,
|
|
21
|
+
});
|
|
22
|
+
this.yamlService.configure({ schemas: [{ fileMatch: ['*'], uri: this.props.defaultSchemaUri }] });
|
|
23
|
+
}
|
|
24
|
+
isSupported(document) {
|
|
25
|
+
return document.languageId === 'yaml';
|
|
26
|
+
}
|
|
27
|
+
doValidation(document) {
|
|
28
|
+
this.updateSchemaMapping(document.uri);
|
|
29
|
+
return this.yamlService.doValidation(document, false);
|
|
30
|
+
}
|
|
31
|
+
doComplete(document, position) {
|
|
32
|
+
this.updateSchemaMapping(document.uri);
|
|
33
|
+
return this.yamlService.doComplete(document, position, false);
|
|
34
|
+
}
|
|
35
|
+
doHover(document, position) {
|
|
36
|
+
this.updateSchemaMapping(document.uri);
|
|
37
|
+
return this.yamlService.doHover(document, position);
|
|
38
|
+
}
|
|
39
|
+
format(document, range, options) {
|
|
40
|
+
this.updateSchemaMapping(document.uri);
|
|
41
|
+
return this.yamlService.doFormat(document, options);
|
|
42
|
+
}
|
|
43
|
+
updateSchemaMapping(documentUri) {
|
|
44
|
+
this.yamlService.configure({
|
|
45
|
+
hover: true,
|
|
46
|
+
hoverSettings: { showSource: false, showTitle: false },
|
|
47
|
+
completion: true,
|
|
48
|
+
format: true,
|
|
49
|
+
validate: true,
|
|
50
|
+
customTags: [],
|
|
51
|
+
schemas: [
|
|
52
|
+
{
|
|
53
|
+
fileMatch: [documentUri],
|
|
54
|
+
uri: this.props.defaultSchemaUri,
|
|
55
|
+
name: this.props.displayName,
|
|
56
|
+
description: 'some description,',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.YamlLanguageService = YamlLanguageService;
|
|
63
|
+
function create(props) {
|
|
64
|
+
const jsonService = new YamlLanguageService(props);
|
|
65
|
+
return new base_1.MutuallyExclusiveLanguageService([jsonService]);
|
|
66
|
+
}
|
|
67
|
+
exports.create = create;
|
|
68
|
+
//# sourceMappingURL=yamlLanguageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yamlLanguageService.js","sourceRoot":"","sources":["../../src/language-service/yamlLanguageService.ts"],"names":[],"mappings":";;;AAAA,iDAA0G;AAG1G,+DAA0E;AAS1E;;;GAGG;AACH,MAAa,mB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AAM,CAAC,QAAsB,EAAE,KAAY,EAAE,OAA8B;QAC9E,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACtC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;IAEO,mBAAmB,CAAC,WAAmB;QAC3C,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YACvB,KAAK,EAAE,IAAI;YACX,aAAa,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE;YACtD,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE;gBACL;oBACI,SAAS,EAAE,CAAC,WAAW,CAAC;oBACxB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB;oBAChC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;oBAC5B,WAAW,EAAE,mBAAmB;iBACnC;aACJ;SACJ,CAAC,CAAA;IACN,CAAC;CACJ;AA5DD,kDA4DC;AAED,SAAgB,MAAM,CAAC,KAA+B;IAClD,MAAM,WAAW,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAElD,OAAO,IAAI,uCAAgC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AAC9D,CAAC;AAJD,wBAIC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aws/lsp-yaml",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "YAML Language Server",
|
|
5
|
+
"main": "out/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/aws/language-servers"
|
|
9
|
+
},
|
|
10
|
+
"author": "Amazon Web Services",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.0.0"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"out/**/*",
|
|
17
|
+
"patches/**/*",
|
|
18
|
+
"patchYamlPackage.js",
|
|
19
|
+
"CHANGELOG.md",
|
|
20
|
+
"SECURITY.md",
|
|
21
|
+
"NOTICE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"compile": "tsc --build",
|
|
25
|
+
"postinstall": "node patchYamlPackage.js",
|
|
26
|
+
"prepack": "cp ../../LICENSE ../../NOTICE ../../SECURITY.md ."
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@aws/language-server-runtimes": "^0.2.5",
|
|
30
|
+
"@aws/lsp-core": "^0.0.1",
|
|
31
|
+
"vscode-languageserver": "^9.0.1",
|
|
32
|
+
"vscode-languageserver-textdocument": "^1.0.8",
|
|
33
|
+
"yaml-language-server": "1.13.0"
|
|
34
|
+
},
|
|
35
|
+
"prettier": {
|
|
36
|
+
"printWidth": 120,
|
|
37
|
+
"trailingComma": "es5",
|
|
38
|
+
"tabWidth": 4,
|
|
39
|
+
"singleQuote": true,
|
|
40
|
+
"semi": false,
|
|
41
|
+
"bracketSpacing": true,
|
|
42
|
+
"arrowParens": "avoid",
|
|
43
|
+
"endOfLine": "lf"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const execFileSync = require('child_process').execFileSync
|
|
2
|
+
const fs = require('node:fs')
|
|
3
|
+
|
|
4
|
+
const pathToYamlPackage = require.resolve('yaml-language-server')
|
|
5
|
+
const rootPackage = pathToYamlPackage.substring(
|
|
6
|
+
0,
|
|
7
|
+
pathToYamlPackage.indexOf('node_modules/yaml-language-server/out/server/src/index.js')
|
|
8
|
+
)
|
|
9
|
+
const pathToFileHover = rootPackage + 'node_modules/yaml-language-server/lib/esm/languageservice/services/yamlHover.js'
|
|
10
|
+
|
|
11
|
+
const filePathToPatchPathMarkdown = {
|
|
12
|
+
'node_modules/yaml-language-server/lib/esm/languageservice/services/yamlHover.js':
|
|
13
|
+
'patches/markdown/yamlHover.esm.patch',
|
|
14
|
+
'node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.js':
|
|
15
|
+
'patches/markdown/yamlHover.umd.patch',
|
|
16
|
+
'node_modules/yaml-language-server/out/server/src/languageservice/services/yamlHover.js':
|
|
17
|
+
'patches/markdown/yamlHover.src.patch',
|
|
18
|
+
'node_modules/yaml-language-server/lib/esm/languageservice/yamlLanguageService.d.ts':
|
|
19
|
+
'patches/markdown/yamlLanguageService.esm.patch',
|
|
20
|
+
'node_modules/yaml-language-server/lib/umd/languageservice/yamlLanguageService.d.ts':
|
|
21
|
+
'patches/markdown/yamlLanguageService.umd.patch',
|
|
22
|
+
'node_modules/yaml-language-server/out/server/src/languageservice/yamlLanguageService.d.ts':
|
|
23
|
+
'patches/markdown/yamlLanguageService.src.patch',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const filePathToPatchPathUnsafeEval = {
|
|
27
|
+
'node_modules/yaml-language-server/lib/esm/languageservice/services/yamlSchemaService.js':
|
|
28
|
+
'patches/unsafe-eval/yamlSchemaService.esm.patch',
|
|
29
|
+
'node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.js':
|
|
30
|
+
'patches/unsafe-eval/yamlSchemaService.umd.patch',
|
|
31
|
+
'node_modules/yaml-language-server/out/server/src/languageservice/services/yamlSchemaService.js':
|
|
32
|
+
'patches/unsafe-eval/yamlSchemaService.src.patch',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function applyPatch(filePathToPatchPath) {
|
|
36
|
+
for (var filePath in filePathToPatchPath) {
|
|
37
|
+
const pathToPatch = `${__dirname}/${filePathToPatchPath[filePath]}`
|
|
38
|
+
const patchProc = execFileSync('patch', [filePath, pathToPatch], {
|
|
39
|
+
cwd: rootPackage,
|
|
40
|
+
encoding: 'utf-8',
|
|
41
|
+
timeout: 2000,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
console.log({
|
|
45
|
+
cmd: patchProc.spawnfile,
|
|
46
|
+
args: patchProc.spawnargs,
|
|
47
|
+
cwd: rootPackage,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fs.readFile(pathToFileHover, function (err, data) {
|
|
53
|
+
if (err) throw err
|
|
54
|
+
if (data.indexOf('this.hoverSettings = {showSource: true, showTitle: true};') >= 0) {
|
|
55
|
+
console.log('Patch is already applied')
|
|
56
|
+
} else {
|
|
57
|
+
applyPatch(filePathToPatchPathMarkdown)
|
|
58
|
+
applyPatch(filePathToPatchPathUnsafeEval)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/lib/esm/languageservice/services/yamlHover.js 2024-04-28 20:38:52
|
|
2
|
+
+++ b/node_modules/yaml-language-server/lib/esm/languageservice/services/yamlHover.js 2024-04-28 20:55:28
|
|
3
|
+
@@ -16,11 +16,13 @@
|
|
4
|
+
constructor(schemaService, telemetry) {
|
|
5
|
+
this.telemetry = telemetry;
|
|
6
|
+
this.shouldHover = true;
|
|
7
|
+
+ this.hoverSettings = {showSource: true, showTitle: true};
|
|
8
|
+
this.schemaService = schemaService;
|
|
9
|
+
}
|
|
10
|
+
configure(languageSettings) {
|
|
11
|
+
if (languageSettings) {
|
|
12
|
+
this.shouldHover = languageSettings.hover;
|
|
13
|
+
+ this.hoverSettings = languageSettings.hoverSettings;
|
|
14
|
+
this.indentation = languageSettings.indentation;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@@ -82,6 +84,8 @@
|
|
19
|
+
const removePipe = (value) => {
|
|
20
|
+
return value.replace(/\|\|\s*$/, '');
|
|
21
|
+
};
|
|
22
|
+
+ const showSource = this.hoverSettings?.showSource ?? true;
|
|
23
|
+
+ const showTitle = this.hoverSettings?.showTitle ?? true;
|
|
24
|
+
return this.schemaService.getSchemaForResource(document.uri, doc).then((schema) => {
|
|
25
|
+
if (schema && node && !schema.errors.length) {
|
|
26
|
+
const matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
|
|
27
|
+
|
|
28
|
+
@@ -133,7 +137,7 @@
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
let result = '';
|
|
32
|
+
- if (title) {
|
|
33
|
+
+ if (showTitle && title) {
|
|
34
|
+
result = '#### ' + toMarkdown(title);
|
|
35
|
+
}
|
|
36
|
+
if (markdownDescription) {
|
|
37
|
+
|
|
38
|
+
@@ -157,7 +161,7 @@
|
|
39
|
+
result += `\n\n\`\`\`${example}\`\`\``;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
- if (result.length > 0 && schema.schema.url) {
|
|
43
|
+
+ if (showSource && result.length > 0 && schema.schema.url) {
|
|
44
|
+
result += `\n\nSource: [${getSchemaName(schema.schema)}](${schema.schema.url})`;
|
|
45
|
+
}
|
|
46
|
+
return createHover(result);
|
|
47
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/out/server/src/languageservice/services/yamlHover.js 2024-05-02 15:13:13
|
|
2
|
+
+++ b/node_modules/yaml-language-server/out/server/src/languageservice/services/yamlHover.js 2024-05-02 15:28:53
|
|
3
|
+
@@ -18,11 +18,13 @@
|
|
4
|
+
constructor(schemaService, telemetry) {
|
|
5
|
+
this.telemetry = telemetry;
|
|
6
|
+
this.shouldHover = true;
|
|
7
|
+
+ this.hoverSettings = {showSource: true, showTitle: true};
|
|
8
|
+
this.schemaService = schemaService;
|
|
9
|
+
}
|
|
10
|
+
configure(languageSettings) {
|
|
11
|
+
if (languageSettings) {
|
|
12
|
+
this.shouldHover = languageSettings.hover;
|
|
13
|
+
+ this.hoverSettings = languageSettings.hoverSettings;
|
|
14
|
+
this.indentation = languageSettings.indentation;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@@ -84,6 +86,8 @@
|
|
19
|
+
const removePipe = (value) => {
|
|
20
|
+
return value.replace(/\|\|\s*$/, '');
|
|
21
|
+
};
|
|
22
|
+
+ const showSource = this.hoverSettings?.showSource ?? true;
|
|
23
|
+
+ const showTitle = this.hoverSettings?.showTitle ?? true;
|
|
24
|
+
return this.schemaService.getSchemaForResource(document.uri, doc).then((schema) => {
|
|
25
|
+
if (schema && node && !schema.errors.length) {
|
|
26
|
+
const matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
|
|
27
|
+
|
|
28
|
+
@@ -135,7 +139,7 @@
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
let result = '';
|
|
32
|
+
- if (title) {
|
|
33
|
+
+ if (showTitle && title) {
|
|
34
|
+
result = '#### ' + toMarkdown(title);
|
|
35
|
+
}
|
|
36
|
+
if (markdownDescription) {
|
|
37
|
+
|
|
38
|
+
@@ -159,7 +163,7 @@
|
|
39
|
+
result += `\n\n\`\`\`${example}\`\`\``;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
- if (result.length > 0 && schema.schema.url) {
|
|
43
|
+
+ if (showSource && result.length > 0 && schema.schema.url) {
|
|
44
|
+
result += `\n\nSource: [${getSchemaName(schema.schema)}](${schema.schema.url})`;
|
|
45
|
+
}
|
|
46
|
+
return createHover(result);
|
|
47
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.js 2024-05-02 15:13:13
|
|
2
|
+
+++ b/node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.js 2024-05-02 15:20:47
|
|
3
|
+
@@ -27,11 +27,13 @@
|
|
4
|
+
constructor(schemaService, telemetry) {
|
|
5
|
+
this.telemetry = telemetry;
|
|
6
|
+
this.shouldHover = true;
|
|
7
|
+
+ this.hoverSettings = {showSource: true, showTitle: true};
|
|
8
|
+
this.schemaService = schemaService;
|
|
9
|
+
}
|
|
10
|
+
configure(languageSettings) {
|
|
11
|
+
if (languageSettings) {
|
|
12
|
+
this.shouldHover = languageSettings.hover;
|
|
13
|
+
+ this.hoverSettings = languageSettings.hoverSettings;
|
|
14
|
+
this.indentation = languageSettings.indentation;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@@ -93,6 +95,8 @@
|
|
19
|
+
const removePipe = (value) => {
|
|
20
|
+
return value.replace(/\|\|\s*$/, '');
|
|
21
|
+
};
|
|
22
|
+
+ const showSource = this.hoverSettings?.showSource ?? true;
|
|
23
|
+
+ const showTitle = this.hoverSettings?.showTitle ?? true;
|
|
24
|
+
return this.schemaService.getSchemaForResource(document.uri, doc).then((schema) => {
|
|
25
|
+
if (schema && node && !schema.errors.length) {
|
|
26
|
+
const matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
|
|
27
|
+
|
|
28
|
+
@@ -144,7 +148,7 @@
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
let result = '';
|
|
32
|
+
- if (title) {
|
|
33
|
+
+ if (showTitle && title) {
|
|
34
|
+
result = '#### ' + toMarkdown(title);
|
|
35
|
+
}
|
|
36
|
+
if (markdownDescription) {
|
|
37
|
+
|
|
38
|
+
@@ -168,7 +172,7 @@
|
|
39
|
+
result += `\n\n\`\`\`${example}\`\`\``;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
- if (result.length > 0 && schema.schema.url) {
|
|
43
|
+
+ if (showSource && result.length > 0 && schema.schema.url) {
|
|
44
|
+
result += `\n\nSource: [${getSchemaName(schema.schema)}](${schema.schema.url})`;
|
|
45
|
+
}
|
|
46
|
+
return createHover(result);
|
|
47
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/lib/esm/languageservice/yamlLanguageService.d.ts 2024-05-02 15:36:28
|
|
2
|
+
+++ b/node_modules/yaml-language-server/lib/esm/languageservice/yamlLanguageService.d.ts 2024-05-02 15:36:32
|
|
3
|
+
@@ -25,6 +25,7 @@
|
|
4
|
+
export interface LanguageSettings {
|
|
5
|
+
validate?: boolean;
|
|
6
|
+
hover?: boolean;
|
|
7
|
+
+ hoverSettings?: {showSource?: boolean; showTitle?: boolean;};
|
|
8
|
+
completion?: boolean;
|
|
9
|
+
format?: boolean;
|
|
10
|
+
isKubernetes?: boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/out/server/src/languageservice/yamlLanguageService.d.ts 2024-05-02 15:33:31
|
|
2
|
+
+++ b/node_modules/yaml-language-server/out/server/src/languageservice/yamlLanguageService.d.ts 2024-05-02 15:34:03
|
|
3
|
+
@@ -25,6 +25,7 @@
|
|
4
|
+
export interface LanguageSettings {
|
|
5
|
+
validate?: boolean;
|
|
6
|
+
hover?: boolean;
|
|
7
|
+
+ hoverSettings?: {showSource?: boolean; showTitle?: boolean;};
|
|
8
|
+
completion?: boolean;
|
|
9
|
+
format?: boolean;
|
|
10
|
+
isKubernetes?: boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/lib/umd/languageservice/yamlLanguageService.d.ts 2024-05-02 15:13:12
|
|
2
|
+
+++ b/node_modules/yaml-language-server/lib/umd/languageservice/yamlLanguageService.d.ts 2024-05-02 15:38:22
|
|
3
|
+
@@ -25,6 +25,7 @@
|
|
4
|
+
export interface LanguageSettings {
|
|
5
|
+
validate?: boolean;
|
|
6
|
+
hover?: boolean;
|
|
7
|
+
+ hoverSettings?: {showSource?: boolean; showTitle?: boolean;};
|
|
8
|
+
completion?: boolean;
|
|
9
|
+
format?: boolean;
|
|
10
|
+
isKubernetes?: boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/lib/esm/languageservice/services/yamlSchemaService.js 2024-05-02 15:43:07
|
|
2
|
+
+++ b/node_modules/yaml-language-server/lib/esm/languageservice/services/yamlSchemaService.js 2024-05-02 15:42:46
|
|
3
|
+
@@ -12,14 +12,8 @@
|
|
4
|
+
import { parse } from 'yaml';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { getSchemaFromModeline } from './modelineUtil';
|
|
7
|
+
-import Ajv from 'ajv';
|
|
8
|
+
import { getSchemaTitle } from '../utils/schemaUtils';
|
|
9
|
+
const localize = nls.loadMessageBundle();
|
|
10
|
+
-const ajv = new Ajv();
|
|
11
|
+
-// load JSON Schema 07 def to validate loaded schemas
|
|
12
|
+
-// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
+
-const jsonSchema07 = require('ajv/dist/refs/json-schema-draft-07.json');
|
|
14
|
+
-const schema07Validator = ajv.compile(jsonSchema07);
|
|
15
|
+
export var MODIFICATION_ACTIONS;
|
|
16
|
+
(function (MODIFICATION_ACTIONS) {
|
|
17
|
+
MODIFICATION_ACTIONS[MODIFICATION_ACTIONS["delete"] = 0] = "delete";
|
|
18
|
+
|
|
19
|
+
@@ -87,13 +81,7 @@
|
|
20
|
+
const resolveErrors = schemaToResolve.errors.slice(0);
|
|
21
|
+
let schema = schemaToResolve.schema;
|
|
22
|
+
const contextService = this.contextService;
|
|
23
|
+
- if (!schema07Validator(schema)) {
|
|
24
|
+
- const errs = [];
|
|
25
|
+
- for (const err of schema07Validator.errors) {
|
|
26
|
+
- errs.push(`${err.instancePath} : ${err.message}`);
|
|
27
|
+
- }
|
|
28
|
+
- resolveErrors.push(`Schema '${getSchemaTitle(schemaToResolve.schema, schemaURL)}' is not valid:\n${errs.join('\n')}`);
|
|
29
|
+
- }
|
|
30
|
+
+
|
|
31
|
+
const findSection = (schema, path) => {
|
|
32
|
+
if (!path) {
|
|
33
|
+
return schema;
|
|
34
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
--- ./node_modules/yaml-language-server/out/server/src/languageservice/services/yamlSchemaService.js 2024-05-02 15:47:54
|
|
2
|
+
+++ ./node_modules/yaml-language-server/out/server/src/languageservice/services/yamlSchemaService.js 2024-05-02 15:47:40
|
|
3
|
+
@@ -14,14 +14,8 @@
|
|
4
|
+
const yaml_1 = require("yaml");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const modelineUtil_1 = require("./modelineUtil");
|
|
7
|
+
-const ajv_1 = require("ajv");
|
|
8
|
+
const schemaUtils_1 = require("../utils/schemaUtils");
|
|
9
|
+
const localize = nls.loadMessageBundle();
|
|
10
|
+
-const ajv = new ajv_1.default();
|
|
11
|
+
-// load JSON Schema 07 def to validate loaded schemas
|
|
12
|
+
-// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
+
-const jsonSchema07 = require('ajv/dist/refs/json-schema-draft-07.json');
|
|
14
|
+
-const schema07Validator = ajv.compile(jsonSchema07);
|
|
15
|
+
var MODIFICATION_ACTIONS;
|
|
16
|
+
(function (MODIFICATION_ACTIONS) {
|
|
17
|
+
MODIFICATION_ACTIONS[MODIFICATION_ACTIONS["delete"] = 0] = "delete";
|
|
18
|
+
|
|
19
|
+
@@ -90,13 +84,6 @@
|
|
20
|
+
const resolveErrors = schemaToResolve.errors.slice(0);
|
|
21
|
+
let schema = schemaToResolve.schema;
|
|
22
|
+
const contextService = this.contextService;
|
|
23
|
+
- if (!schema07Validator(schema)) {
|
|
24
|
+
- const errs = [];
|
|
25
|
+
- for (const err of schema07Validator.errors) {
|
|
26
|
+
- errs.push(`${err.instancePath} : ${err.message}`);
|
|
27
|
+
- }
|
|
28
|
+
- resolveErrors.push(`Schema '${(0, schemaUtils_1.getSchemaTitle)(schemaToResolve.schema, schemaURL)}' is not valid:\n${errs.join('\n')}`);
|
|
29
|
+
- }
|
|
30
|
+
const findSection = (schema, path) => {
|
|
31
|
+
if (!path) {
|
|
32
|
+
return schema;
|
|
33
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
--- a/node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.js 2024-05-02 15:45:09
|
|
2
|
+
+++ b/node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.js 2024-05-02 15:44:54
|
|
3
|
+
@@ -23,14 +23,8 @@
|
|
4
|
+
const yaml_1 = require("yaml");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const modelineUtil_1 = require("./modelineUtil");
|
|
7
|
+
- const ajv_1 = require("ajv");
|
|
8
|
+
const schemaUtils_1 = require("../utils/schemaUtils");
|
|
9
|
+
const localize = nls.loadMessageBundle();
|
|
10
|
+
- const ajv = new ajv_1.default();
|
|
11
|
+
- // load JSON Schema 07 def to validate loaded schemas
|
|
12
|
+
- // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
+
- const jsonSchema07 = require('ajv/dist/refs/json-schema-draft-07.json');
|
|
14
|
+
- const schema07Validator = ajv.compile(jsonSchema07);
|
|
15
|
+
var MODIFICATION_ACTIONS;
|
|
16
|
+
(function (MODIFICATION_ACTIONS) {
|
|
17
|
+
MODIFICATION_ACTIONS[MODIFICATION_ACTIONS["delete"] = 0] = "delete";
|
|
18
|
+
|
|
19
|
+
@@ -99,13 +93,6 @@
|
|
20
|
+
const resolveErrors = schemaToResolve.errors.slice(0);
|
|
21
|
+
let schema = schemaToResolve.schema;
|
|
22
|
+
const contextService = this.contextService;
|
|
23
|
+
- if (!schema07Validator(schema)) {
|
|
24
|
+
- const errs = [];
|
|
25
|
+
- for (const err of schema07Validator.errors) {
|
|
26
|
+
- errs.push(`${err.instancePath} : ${err.message}`);
|
|
27
|
+
- }
|
|
28
|
+
- resolveErrors.push(`Schema '${(0, schemaUtils_1.getSchemaTitle)(schemaToResolve.schema, schemaURL)}' is not valid:\n${errs.join('\n')}`);
|
|
29
|
+
- }
|
|
30
|
+
const findSection = (schema, path) => {
|
|
31
|
+
if (!path) {
|
|
32
|
+
return schema;
|
|
33
|
+
|