@aws/lsp-yaml 0.1.27 → 0.1.28
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
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.28](https://github.com/Amazon-Q-Developer/language-servers/compare/lsp-yaml/v0.1.27...lsp-yaml/v0.1.28) (2026-11-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **lsp-yaml:** load the schema once instead of on every request ([#3017](https://github.com/Amazon-Q-Developer/language-servers/issues/3017)) ([86a471c](https://github.com/Amazon-Q-Developer/language-servers/commit/86a471c9c156a18222c0b6cba1e8ceb08ca4718a))
|
|
9
|
+
|
|
3
10
|
## [0.1.27](https://github.com/Amazon-Q-Developer/language-servers/compare/lsp-yaml/v0.1.26...lsp-yaml/v0.1.27) (2026-08-18)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -14,12 +14,16 @@ export type YamlLanguageServiceProps = {
|
|
|
14
14
|
export declare class YamlLanguageService implements AwsLanguageService {
|
|
15
15
|
private readonly props;
|
|
16
16
|
private yamlService;
|
|
17
|
+
private readonly settings;
|
|
18
|
+
private schemaLoadFailed;
|
|
17
19
|
constructor(props: YamlLanguageServiceProps);
|
|
18
20
|
isSupported(document: TextDocument): boolean;
|
|
19
21
|
doValidation(document: TextDocument): Promise<Diagnostic[]>;
|
|
20
22
|
doComplete(document: TextDocument, position: Position): Promise<CompletionList>;
|
|
21
23
|
doHover(document: TextDocument, position: Position): Promise<Hover | null>;
|
|
22
24
|
format(document: TextDocument, range: Range, options: YamlFormattingOptions): TextEdit[];
|
|
23
|
-
private
|
|
25
|
+
private requestSchema;
|
|
26
|
+
private fetchSchema;
|
|
27
|
+
private retryFailedSchemaLoad;
|
|
24
28
|
}
|
|
25
29
|
export declare function create(props: YamlLanguageServiceProps): AwsLanguageService;
|
|
@@ -11,6 +11,8 @@ const yaml_language_server_1 = require("yaml-language-server");
|
|
|
11
11
|
class YamlLanguageService {
|
|
12
12
|
props;
|
|
13
13
|
yamlService;
|
|
14
|
+
settings;
|
|
15
|
+
schemaLoadFailed = false;
|
|
14
16
|
constructor(props) {
|
|
15
17
|
this.props = props;
|
|
16
18
|
let resolveUri;
|
|
@@ -18,7 +20,7 @@ class YamlLanguageService {
|
|
|
18
20
|
resolveUri = props.uriResolver;
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
|
-
resolveUri =
|
|
23
|
+
resolveUri = url => this.fetchSchema(url);
|
|
22
24
|
}
|
|
23
25
|
const workspaceContext = {
|
|
24
26
|
resolveRelativePath(relativePath, resource) {
|
|
@@ -26,54 +28,87 @@ class YamlLanguageService {
|
|
|
26
28
|
},
|
|
27
29
|
};
|
|
28
30
|
this.yamlService = (0, yaml_language_server_1.getLanguageService)({
|
|
29
|
-
schemaRequestService: resolveUri,
|
|
31
|
+
schemaRequestService: uri => this.requestSchema(resolveUri, uri),
|
|
30
32
|
workspaceContext,
|
|
31
33
|
});
|
|
32
|
-
this.
|
|
34
|
+
this.settings = {
|
|
35
|
+
hover: true,
|
|
36
|
+
hoverSettings: { showSource: false, showTitle: false },
|
|
37
|
+
completion: true,
|
|
38
|
+
format: true,
|
|
39
|
+
validate: true,
|
|
40
|
+
customTags: [],
|
|
41
|
+
schemas: [
|
|
42
|
+
{
|
|
43
|
+
fileMatch: ['*'],
|
|
44
|
+
uri: this.props.defaultSchemaUri,
|
|
45
|
+
name: this.props.displayName,
|
|
46
|
+
description: 'some description,',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
// Configure once: every configure() call clears the schema cache, so the
|
|
51
|
+
// schema would otherwise be downloaded and parsed again for each request.
|
|
52
|
+
this.yamlService.configure(this.settings);
|
|
33
53
|
}
|
|
34
54
|
isSupported(document) {
|
|
35
55
|
return document.languageId === 'yaml';
|
|
36
56
|
}
|
|
37
57
|
doValidation(document) {
|
|
38
|
-
this.
|
|
58
|
+
this.retryFailedSchemaLoad();
|
|
39
59
|
return this.yamlService.doValidation(document, false);
|
|
40
60
|
}
|
|
41
61
|
doComplete(document, position) {
|
|
42
|
-
this.
|
|
62
|
+
this.retryFailedSchemaLoad();
|
|
43
63
|
return this.yamlService.doComplete(document, position, false);
|
|
44
64
|
}
|
|
45
65
|
doHover(document, position) {
|
|
46
|
-
this.
|
|
66
|
+
this.retryFailedSchemaLoad();
|
|
47
67
|
return this.yamlService.doHover(document, position);
|
|
48
68
|
}
|
|
49
69
|
format(document, range, options) {
|
|
50
|
-
this.
|
|
70
|
+
this.retryFailedSchemaLoad();
|
|
51
71
|
return this.yamlService.doFormat(document, options);
|
|
52
72
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
async requestSchema(resolveUri, uri) {
|
|
74
|
+
try {
|
|
75
|
+
const content = await resolveUri(uri);
|
|
76
|
+
if (!isJson(content)) {
|
|
77
|
+
this.schemaLoadFailed = true;
|
|
78
|
+
}
|
|
79
|
+
return content;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
this.schemaLoadFailed = true;
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async fetchSchema(url) {
|
|
87
|
+
const response = await fetch(url);
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
this.schemaLoadFailed = true;
|
|
90
|
+
}
|
|
91
|
+
const schema = await (await response.blob()).text();
|
|
92
|
+
return schema;
|
|
93
|
+
}
|
|
94
|
+
// A failed load stays cached, so clear it the way the per-request configure() used
|
|
95
|
+
// to, letting the next request fetch the schema again.
|
|
96
|
+
retryFailedSchemaLoad() {
|
|
97
|
+
if (this.schemaLoadFailed) {
|
|
98
|
+
this.schemaLoadFailed = false;
|
|
99
|
+
this.yamlService.configure(this.settings);
|
|
100
|
+
}
|
|
70
101
|
}
|
|
71
102
|
}
|
|
72
103
|
exports.YamlLanguageService = YamlLanguageService;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
104
|
+
function isJson(content) {
|
|
105
|
+
try {
|
|
106
|
+
JSON.parse(content);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
77
112
|
}
|
|
78
113
|
function create(props) {
|
|
79
114
|
const jsonService = new YamlLanguageService(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yamlLanguageService.js","sourceRoot":"","sources":["../../src/language-service/yamlLanguageService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"yamlLanguageService.js","sourceRoot":"","sources":["../../src/language-service/yamlLanguageService.ts"],"names":[],"mappings":";;;AAgIA,wBAIC;AApID,iDAA0G;AAG1G,+DAA4F;AAS5F;;;GAGG;AACH,MAAa,mBAAmB;IAKC;IAJrB,WAAW,CAAiB;IACnB,QAAQ,CAAkB;IACnC,gBAAgB,GAAG,KAAK,CAAA;IAEhC,YAA6B,KAA+B;QAA/B,UAAK,GAAL,KAAK,CAA0B;QACxD,IAAI,UAA4C,CAAA;QAChD,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACpB,UAAU,GAAG,KAAK,CAAC,WAAW,CAAA;QAClC,CAAC;aAAM,CAAC;YACJ,UAAU,GAAG,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAC7C,CAAC;QAED,MAAM,gBAAgB,GAAG;YACrB,mBAAmB,CAAC,YAAoB,EAAE,QAAgB;gBACtD,OAAO,IAAI,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CA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