This commit is contained in:
12
node_modules/yaml-language-server/lib/umd/languageservice/services/documentSymbols.d.ts
generated
vendored
Normal file
12
node_modules/yaml-language-server/lib/umd/languageservice/services/documentSymbols.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { SymbolInformation, DocumentSymbol } from 'vscode-languageserver-types';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { DocumentSymbolsContext } from 'vscode-json-languageservice/lib/umd/jsonLanguageTypes';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YAMLDocumentSymbols {
|
||||
private readonly telemetry?;
|
||||
private jsonDocumentSymbols;
|
||||
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
|
||||
findDocumentSymbols(document: TextDocument, context?: DocumentSymbolsContext): SymbolInformation[];
|
||||
findHierarchicalDocumentSymbols(document: TextDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
|
||||
}
|
||||
82
node_modules/yaml-language-server/lib/umd/languageservice/services/documentSymbols.js
generated
vendored
Normal file
82
node_modules/yaml-language-server/lib/umd/languageservice/services/documentSymbols.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-json-languageservice/lib/umd/services/jsonDocumentSymbols", "../parser/yaml-documents", "yaml", "../utils/objects"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLDocumentSymbols = void 0;
|
||||
const jsonDocumentSymbols_1 = require("vscode-json-languageservice/lib/umd/services/jsonDocumentSymbols");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const yaml_1 = require("yaml");
|
||||
const objects_1 = require("../utils/objects");
|
||||
class YAMLDocumentSymbols {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
this.jsonDocumentSymbols = new jsonDocumentSymbols_1.JSONDocumentSymbols(schemaService);
|
||||
// override 'getKeyLabel' to handle complex mapping
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this.jsonDocumentSymbols.getKeyLabel = (property) => {
|
||||
const keyNode = property.keyNode.internalNode;
|
||||
let name = '';
|
||||
if ((0, yaml_1.isMap)(keyNode)) {
|
||||
name = '{}';
|
||||
}
|
||||
else if ((0, yaml_1.isSeq)(keyNode)) {
|
||||
name = '[]';
|
||||
}
|
||||
else {
|
||||
name = keyNode.source;
|
||||
}
|
||||
return name;
|
||||
};
|
||||
}
|
||||
findDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
|
||||
let results = [];
|
||||
try {
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
if (!doc || doc['documents'].length === 0) {
|
||||
return null;
|
||||
}
|
||||
for (const yamlDoc of doc['documents']) {
|
||||
if (yamlDoc.root) {
|
||||
results = results.concat(this.jsonDocumentSymbols.findDocumentSymbols(document, yamlDoc, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.documentSymbols.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(err) });
|
||||
}
|
||||
return results;
|
||||
}
|
||||
findHierarchicalDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
|
||||
let results = [];
|
||||
try {
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
if (!doc || doc['documents'].length === 0) {
|
||||
return null;
|
||||
}
|
||||
for (const yamlDoc of doc['documents']) {
|
||||
if (yamlDoc.root) {
|
||||
results = results.concat(this.jsonDocumentSymbols.findDocumentSymbols2(document, yamlDoc, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.hierarchicalDocumentSymbols.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(err) });
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
exports.YAMLDocumentSymbols = YAMLDocumentSymbols;
|
||||
});
|
||||
//# sourceMappingURL=documentSymbols.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/documentSymbols.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/documentSymbols.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"documentSymbols.js","sourceRoot":"","sources":["../../../../src/languageservice/services/documentSymbols.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;;;;;;;;;;;;;IAIhG,0GAAuG;IAGvG,6DAA8D;IAE9D,+BAA0C;IAC1C,8CAA8D;IAE9D,MAAa,mBAAmB;QAG9B,YAAY,aAAgC,EAAmB,SAAqB;YAArB,cAAS,GAAT,SAAS,CAAY;YAClF,IAAI,CAAC,mBAAmB,GAAG,IAAI,yCAAmB,CAAC,aAAa,CAAC,CAAC;YAElE,mDAAmD;YACnD,8DAA8D;YAC9D,IAAI,CAAC,mBAAmB,CAAC,WAAW,GAAG,CAAC,QAAa,EAAE,EAAE;gBACvD,MAAM,OAAO,GAAS,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;gBACpD,IAAI,IAAI,GAAG,EAAE,CAAC;gBACd,IAAI,IAAA,YAAK,EAAC,OAAO,CAAC,EAAE;oBAClB,IAAI,GAAG,IAAI,CAAC;iBACb;qBAAM,IAAI,IAAA,YAAK,EAAC,OAAO,CAAC,EAAE;oBACzB,IAAI,GAAG,IAAI,CAAC;iBACb;qBAAM;oBACL,IAA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BACtC,IAAI,OAAO,CAAC,IAAI,EAAE;wBAChB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;qBACrG;iBACF;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,wCAAwC,EAAE,EAAE,KAAK,EAAE,IAAA,oCAA0B,EAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aACjH;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;KACF;IAlED,kDAkEC"}
|
||||
9
node_modules/yaml-language-server/lib/umd/languageservice/services/modelineUtil.d.ts
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/umd/languageservice/services/modelineUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { SingleYAMLDocument } from '../parser/yamlParser07';
|
||||
import { JSONDocument } from '../parser/jsonParser07';
|
||||
/**
|
||||
* Retrieve schema if declared as modeline.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
*/
|
||||
export declare function getSchemaFromModeline(doc: SingleYAMLDocument | JSONDocument): string;
|
||||
export declare function isModeline(lineText: string): boolean;
|
||||
47
node_modules/yaml-language-server/lib/umd/languageservice/services/modelineUtil.js
generated
vendored
Normal file
47
node_modules/yaml-language-server/lib/umd/languageservice/services/modelineUtil.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../parser/yamlParser07"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isModeline = exports.getSchemaFromModeline = void 0;
|
||||
const yamlParser07_1 = require("../parser/yamlParser07");
|
||||
/**
|
||||
* Retrieve schema if declared as modeline.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
*/
|
||||
function getSchemaFromModeline(doc) {
|
||||
if (doc instanceof yamlParser07_1.SingleYAMLDocument) {
|
||||
const yamlLanguageServerModeline = doc.lineComments.find((lineComment) => {
|
||||
return isModeline(lineComment);
|
||||
});
|
||||
if (yamlLanguageServerModeline != undefined) {
|
||||
const schemaMatchs = yamlLanguageServerModeline.match(/\$schema=\S+/g);
|
||||
if (schemaMatchs !== null && schemaMatchs.length >= 1) {
|
||||
if (schemaMatchs.length >= 2) {
|
||||
console.log('Several $schema attributes have been found on the yaml-language-server modeline. The first one will be picked.');
|
||||
}
|
||||
return schemaMatchs[0].substring('$schema='.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
exports.getSchemaFromModeline = getSchemaFromModeline;
|
||||
function isModeline(lineText) {
|
||||
const matchModeline = lineText.match(/^#\s+yaml-language-server\s*:/g);
|
||||
return matchModeline !== null && matchModeline.length === 1;
|
||||
}
|
||||
exports.isModeline = isModeline;
|
||||
});
|
||||
//# sourceMappingURL=modelineUtil.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/modelineUtil.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/modelineUtil.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"modelineUtil.js","sourceRoot":"","sources":["../../../../src/languageservice/services/modelineUtil.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAEhG,yDAA4D;IAG5D;;;;OAIG;IACH,SAAgB,qBAAqB,CAAC,GAAsC;QAC1E,IAAI,GAAG,YAAY,iCAAkB,EAAE;YACrC,MAAM,0BAA0B,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;gBACvE,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,IAAI,0BAA0B,IAAI,SAAS,EAAE;gBAC3C,MAAM,YAAY,GAAG,0BAA0B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBACvE,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;oBACrD,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;wBAC5B,OAAO,CAAC,GAAG,CACT,gHAAgH,CACjH,CAAC;qBACH;oBACD,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;iBACrD;aACF;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAlBD,sDAkBC;IAED,SAAgB,UAAU,CAAC,QAAgB;QACzC,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACvE,OAAO,aAAa,KAAK,IAAI,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;IAC9D,CAAC;IAHD,gCAGC"}
|
||||
12
node_modules/yaml-language-server/lib/umd/languageservice/services/schemaRequestHandler.d.ts
generated
vendored
Normal file
12
node_modules/yaml-language-server/lib/umd/languageservice/services/schemaRequestHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { URI } from 'vscode-uri';
|
||||
import { Connection, WorkspaceFolder } from 'vscode-languageserver';
|
||||
import { WorkspaceContextService } from '../yamlLanguageService';
|
||||
export interface FileSystem {
|
||||
readFile(fsPath: string, encoding?: string): Promise<string>;
|
||||
}
|
||||
/**
|
||||
* Handles schema content requests given the schema URI
|
||||
* @param uri can be a local file, vscode request, http(s) request or a custom request
|
||||
*/
|
||||
export declare const schemaRequestHandler: (connection: Connection, uri: string, workspaceFolders: WorkspaceFolder[], workspaceRoot: URI, useVSCodeContentRequest: boolean, fs: FileSystem) => Promise<string>;
|
||||
export declare const workspaceContext: WorkspaceContextService;
|
||||
76
node_modules/yaml-language-server/lib/umd/languageservice/services/schemaRequestHandler.js
generated
vendored
Normal file
76
node_modules/yaml-language-server/lib/umd/languageservice/services/schemaRequestHandler.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-uri", "request-light", "url", "../../requestTypes", "../utils/paths"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.workspaceContext = exports.schemaRequestHandler = void 0;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const request_light_1 = require("request-light");
|
||||
const URL = require("url");
|
||||
const requestTypes_1 = require("../../requestTypes");
|
||||
const paths_1 = require("../utils/paths");
|
||||
/**
|
||||
* Handles schema content requests given the schema URI
|
||||
* @param uri can be a local file, vscode request, http(s) request or a custom request
|
||||
*/
|
||||
const schemaRequestHandler = (connection, uri, workspaceFolders, workspaceRoot, useVSCodeContentRequest, fs) => {
|
||||
if (!uri) {
|
||||
return Promise.reject('No schema specified');
|
||||
}
|
||||
// If the requested schema URI is a relative file path
|
||||
// Convert it into a proper absolute path URI
|
||||
if ((0, paths_1.isRelativePath)(uri)) {
|
||||
uri = (0, paths_1.relativeToAbsolutePath)(workspaceFolders, workspaceRoot, uri);
|
||||
}
|
||||
let scheme = vscode_uri_1.URI.parse(uri).scheme.toLowerCase();
|
||||
// test if uri is windows path, ie starts with 'c:\'
|
||||
if (/^[a-z]:[\\/]/i.test(uri)) {
|
||||
const winUri = vscode_uri_1.URI.file(uri);
|
||||
scheme = winUri.scheme.toLowerCase();
|
||||
uri = winUri.toString();
|
||||
}
|
||||
// If the requested schema is a local file, read and return the file contents
|
||||
if (scheme === 'file') {
|
||||
const fsPath = vscode_uri_1.URI.parse(uri).fsPath;
|
||||
return fs.readFile(fsPath, 'UTF-8').catch(() => {
|
||||
// If there was an error reading the file, return empty error message
|
||||
// Otherwise return the file contents as a string
|
||||
return '';
|
||||
});
|
||||
}
|
||||
// HTTP(S) requests are sent and the response result is either the schema content or an error
|
||||
if (scheme === 'http' || scheme === 'https') {
|
||||
// If we are running inside of VSCode we need to make a content request. This content request
|
||||
// will make it so that schemas behind VPN's will resolve correctly
|
||||
if (useVSCodeContentRequest) {
|
||||
return connection.sendRequest(requestTypes_1.VSCodeContentRequest.type, uri).then((responseText) => {
|
||||
return responseText;
|
||||
}, (error) => {
|
||||
return Promise.reject(error.message);
|
||||
});
|
||||
}
|
||||
// Send the HTTP(S) schema content request and return the result
|
||||
const headers = { 'Accept-Encoding': 'gzip, deflate' };
|
||||
return (0, request_light_1.xhr)({ url: uri, followRedirects: 5, headers }).then((response) => {
|
||||
return response.responseText;
|
||||
}, (error) => {
|
||||
return Promise.reject(error.responseText || (0, request_light_1.getErrorStatusDescription)(error.status) || error.toString());
|
||||
});
|
||||
}
|
||||
// Neither local file nor vscode, nor HTTP(S) schema request, so send it off as a custom request
|
||||
return connection.sendRequest(requestTypes_1.CustomSchemaContentRequest.type, uri);
|
||||
};
|
||||
exports.schemaRequestHandler = schemaRequestHandler;
|
||||
exports.workspaceContext = {
|
||||
resolveRelativePath: (relativePath, resource) => {
|
||||
return URL.resolve(resource, relativePath);
|
||||
},
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=schemaRequestHandler.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/schemaRequestHandler.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/schemaRequestHandler.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schemaRequestHandler.js","sourceRoot":"","sources":["../../../../src/languageservice/services/schemaRequestHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,2CAAiC;IAEjC,iDAA4E;IAC5E,2BAA2B;IAC3B,qDAAsF;IACtF,0CAAwE;IAOxE;;;OAGG;IACI,MAAM,oBAAoB,GAAG,CAClC,UAAsB,EACtB,GAAW,EACX,gBAAmC,EACnC,aAAkB,EAClB,uBAAgC,EAChC,EAAc,EACG,EAAE;QACnB,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;SAC9C;QAED,sDAAsD;QACtD,6CAA6C;QAC7C,IAAI,IAAA,sBAAc,EAAC,GAAG,CAAC,EAAE;YACvB,GAAG,GAAG,IAAA,8BAAsB,EAAC,gBAAgB,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;SACpE;QAED,IAAI,MAAM,GAAG,gBAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAEjD,oDAAoD;QACpD,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,MAAM,GAAG,gBAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACrC,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,6EAA6E;QAC7E,IAAI,MAAM,KAAK,MAAM,EAAE;YACrB,MAAM,MAAM,GAAG,gBAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;YAErC,OAAO,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC7C,qEAAqE;gBACrE,iDAAiD;gBACjD,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;SACJ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
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/map-key-order.d.ts
generated
vendored
Normal file
7
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/map-key-order.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
import { AdditionalValidator } from './types';
|
||||
export declare class MapKeyOrderValidator implements AdditionalValidator {
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
}
|
||||
50
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/map-key-order.js
generated
vendored
Normal file
50
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/map-key-order.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MapKeyOrderValidator = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
class MapKeyOrderValidator {
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
(0, yaml_1.visit)(yamlDoc.internalDocument, (key, node) => {
|
||||
if ((0, yaml_1.isMap)(node)) {
|
||||
for (let i = 1; i < node.items.length; i++) {
|
||||
if (compare(node.items[i - 1], node.items[i]) > 0) {
|
||||
const range = createRange(document, node.items[i - 1]);
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(range, `Wrong ordering of key "${node.items[i - 1].key}" in mapping`, vscode_languageserver_types_1.DiagnosticSeverity.Error, 'mapKeyOrder'));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.MapKeyOrderValidator = MapKeyOrderValidator;
|
||||
function createRange(document, node) {
|
||||
const start = node?.srcToken.start[0]?.offset ?? node?.srcToken?.key.offset ?? node?.srcToken?.sep[0]?.offset;
|
||||
const end = node?.srcToken?.value.offset ||
|
||||
node?.srcToken?.sep[0]?.offset ||
|
||||
node?.srcToken?.key.offset ||
|
||||
node?.srcToken.start[node.srcToken.start.length - 1]?.offset;
|
||||
return vscode_languageserver_types_1.Range.create(document.positionAt(start), document.positionAt(end));
|
||||
}
|
||||
function compare(thiz, that) {
|
||||
const thatKey = String(that.key);
|
||||
const thisKey = String(thiz.key);
|
||||
return thisKey.localeCompare(thatKey);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=map-key-order.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/map-key-order.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/map-key-order.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"map-key-order.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/map-key-order.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6EAAoF;IAGpF,+BAA0C;IAE1C,MAAa,oBAAoB;QAC/B,QAAQ,CAAC,QAAsB,EAAE,OAA2B;YAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;YAElB,IAAA,YAAK,EAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC5C,IAAI,IAAA,YAAK,EAAC,IAAI,CAAC,EAAE;oBACf,KAAK,IAAI,CAAC,GAAG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AC,UAAU,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,SAAS,OAAO,CAAC,IAAU,EAAE,IAAU;QACrC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC"}
|
||||
6
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/types.d.ts
generated
vendored
Normal file
6
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
export interface AdditionalValidator {
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
}
|
||||
17
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/types.js
generated
vendored
Normal file
17
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/types.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
});
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/types.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/types.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}
|
||||
8
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/unused-anchors.d.ts
generated
vendored
Normal file
8
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/unused-anchors.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
import { AdditionalValidator } from './types';
|
||||
export declare class UnusedAnchorsValidator implements AdditionalValidator {
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
private getAnchorNode;
|
||||
}
|
||||
87
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/unused-anchors.js
generated
vendored
Normal file
87
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/unused-anchors.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml", "../../../languageservice/utils/astUtils"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UnusedAnchorsValidator = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
const astUtils_1 = require("../../../languageservice/utils/astUtils");
|
||||
class UnusedAnchorsValidator {
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
const anchors = new Set();
|
||||
const usedAnchors = new Set();
|
||||
const anchorParent = new Map();
|
||||
(0, yaml_1.visit)(yamlDoc.internalDocument, (key, node, path) => {
|
||||
if (!(0, yaml_1.isNode)(node)) {
|
||||
return;
|
||||
}
|
||||
if (((0, yaml_1.isCollection)(node) || (0, yaml_1.isScalar)(node)) && node.anchor) {
|
||||
anchors.add(node);
|
||||
anchorParent.set(node, path[path.length - 1]);
|
||||
}
|
||||
if ((0, yaml_1.isAlias)(node)) {
|
||||
usedAnchors.add(node.resolve(yamlDoc.internalDocument));
|
||||
}
|
||||
});
|
||||
for (const anchor of anchors) {
|
||||
if (!usedAnchors.has(anchor)) {
|
||||
const aToken = this.getAnchorNode(anchorParent.get(anchor), anchor);
|
||||
if (aToken) {
|
||||
const range = vscode_languageserver_types_1.Range.create(document.positionAt(aToken.offset), document.positionAt(aToken.offset + aToken.source.length));
|
||||
const warningDiagnostic = vscode_languageserver_types_1.Diagnostic.create(range, `Unused anchor "${aToken.source}"`, vscode_languageserver_types_1.DiagnosticSeverity.Hint, 0);
|
||||
warningDiagnostic.tags = [vscode_languageserver_types_1.DiagnosticTag.Unnecessary];
|
||||
result.push(warningDiagnostic);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getAnchorNode(parentNode, node) {
|
||||
if (parentNode && parentNode.srcToken) {
|
||||
const token = parentNode.srcToken;
|
||||
if ((0, astUtils_1.isCollectionItem)(token)) {
|
||||
return getAnchorFromCollectionItem(token);
|
||||
}
|
||||
else if (yaml_1.CST.isCollection(token)) {
|
||||
for (const t of token.items) {
|
||||
if (node.srcToken !== t.value)
|
||||
continue;
|
||||
const anchor = getAnchorFromCollectionItem(t);
|
||||
if (anchor) {
|
||||
return anchor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.UnusedAnchorsValidator = UnusedAnchorsValidator;
|
||||
function getAnchorFromCollectionItem(token) {
|
||||
for (const t of token.start) {
|
||||
if (t.type === 'anchor') {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
if (token.sep && Array.isArray(token.sep)) {
|
||||
for (const t of token.sep) {
|
||||
if (t.type === 'anchor') {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=unused-anchors.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/unused-anchors.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/unused-anchors.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unused-anchors.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/unused-anchors.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6EAAmG;IACnG,+BAAiH;IAIjH,sEAA2E;IAE3E,MAAa,sBAAsB;QACjC,QAAQ,CAAC,QAAsB,EAAE,OAA2B;YAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;YACtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAQ,CAAC;YACpC,MAAM,YAAY,GAAG,IAAI,GAAG,EAA2C,CAAC;YAExE,IAAA,YAAK,EAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;gBAClD,IAAI,CAAC,IAAA,aAAM,EAAC,IAAI,CAAC,EAAE;oBACjB,OAAO;iBACR;gBACD,IAAI,CAAC,IAAA,mBAAY,EAAC,IAAI,CAAC,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EA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CAAC;gBAClC,IAAI,IAAA,2BAAgB,EAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;iBAC3C;qBAAM,IAAI,UAAG,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;oBAClC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;wBAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC,KAAK;4BAAE,SAAS;wBACxC,MAAM,MAAM,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAC;wBAC9C,IAAI,MAAM,EAAE;4BACV,OAAO,MAAM,CAAC;yBACf;qBACF;iBACF;aACF;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF;IAtDD,wDAsDC;IACD,SAAS,2BAA2B,CAAC,KAAyB;QAC5D,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;YAC3B,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvB,OAAO,CAAC,CAAC;aACV;SACF;QACD,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACzC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE;gBACzB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACvB,OAAO,CAAC,CAAC;iBACV;aACF;SACF;IACH,CAAC"}
|
||||
12
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/yaml-style.d.ts
generated
vendored
Normal file
12
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/yaml-style.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
import { LanguageSettings } from '../../yamlLanguageService';
|
||||
import { AdditionalValidator } from './types';
|
||||
export declare class YAMLStyleValidator implements AdditionalValidator {
|
||||
private forbidSequence;
|
||||
private forbidMapping;
|
||||
constructor(settings: LanguageSettings);
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
private getRangeOf;
|
||||
}
|
||||
38
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/yaml-style.js
generated
vendored
Normal file
38
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/yaml-style.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLStyleValidator = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
class YAMLStyleValidator {
|
||||
constructor(settings) {
|
||||
this.forbidMapping = settings.flowMapping === 'forbid';
|
||||
this.forbidSequence = settings.flowSequence === 'forbid';
|
||||
}
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
(0, yaml_1.visit)(yamlDoc.internalDocument, (key, node) => {
|
||||
if (this.forbidMapping && (0, yaml_1.isMap)(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style mapping is forbidden', vscode_languageserver_types_1.DiagnosticSeverity.Error, 'flowMap'));
|
||||
}
|
||||
if (this.forbidSequence && (0, yaml_1.isSeq)(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style sequence is forbidden', vscode_languageserver_types_1.DiagnosticSeverity.Error, 'flowSeq'));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
getRangeOf(document, node) {
|
||||
return vscode_languageserver_types_1.Range.create(document.positionAt(node.start.offset), document.positionAt(node.end.pop().offset));
|
||||
}
|
||||
}
|
||||
exports.YAMLStyleValidator = YAMLStyleValidator;
|
||||
});
|
||||
//# sourceMappingURL=yaml-style.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/yaml-style.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/validation/yaml-style.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yaml-style.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/yaml-style.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA,6EAAoF;IACpF,+BAA2C;IAM3C,MAAa,kBAAkB;QAI7B,YAAY,QAA0B;YACpC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC;YACvD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,YAAY,KAAK,QAAQ,CAAC;QAC3D,CAAC;QACD,QAAQ,CAAC,QAAsB,EAAE,OAA2B;YAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;YAClB,IAAA,YAAK,EAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC5C,IAAI,IAAI,CAAC,aAAa,IAAI,IAAA,YAAK,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;oBAClF,MAAM,CAAC,IAAI,CACT,wCAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,iCAAiC,EACjC,gDAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;iBACH;gBACD,IAAI,IAAI,CAAC,cAAc,IAAI,IAAA,YAAK,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;oBACnF,MAAM,CAAC,IAAI,CACT,wCAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,kCAAkC,EAClC,gDAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;iBACH;YACH,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QAEO,UAAU,CAAC,QAAsB,EAAE,IAAoB;YAC7D,OAAO,mCAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1G,CAAC;KACF;IAtCD,gDAsCC"}
|
||||
17
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeActions.d.ts
generated
vendored
Normal file
17
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeActions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { CodeAction } from 'vscode-languageserver-types';
|
||||
import { ClientCapabilities, CodeActionParams } from 'vscode-languageserver-protocol';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
export declare class YamlCodeActions {
|
||||
private readonly clientCapabilities;
|
||||
private indentation;
|
||||
constructor(clientCapabilities: ClientCapabilities);
|
||||
configure(settings: LanguageSettings): void;
|
||||
getCodeAction(document: TextDocument, params: CodeActionParams): CodeAction[] | undefined;
|
||||
private getJumpToSchemaActions;
|
||||
private getTabToSpaceConverting;
|
||||
private getUnusedAnchorsDelete;
|
||||
private getConvertToBooleanActions;
|
||||
private getConvertToBlockStyleActions;
|
||||
private getKeyOrderActions;
|
||||
}
|
||||
267
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeActions.js
generated
vendored
Normal file
267
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeActions.js
generated
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../../commands", "path", "../utils/textBuffer", "../parser/jsonParser07", "../utils/strings", "../utils/arrUtils", "yaml", "../parser/yaml-documents", "../utils/flow-style-rewriter", "lodash"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlCodeActions = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const commands_1 = require("../../commands");
|
||||
const path = require("path");
|
||||
const textBuffer_1 = require("../utils/textBuffer");
|
||||
const jsonParser07_1 = require("../parser/jsonParser07");
|
||||
const strings_1 = require("../utils/strings");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
const yaml_1 = require("yaml");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const flow_style_rewriter_1 = require("../utils/flow-style-rewriter");
|
||||
const _ = require("lodash");
|
||||
class YamlCodeActions {
|
||||
constructor(clientCapabilities) {
|
||||
this.clientCapabilities = clientCapabilities;
|
||||
this.indentation = ' ';
|
||||
}
|
||||
configure(settings) {
|
||||
this.indentation = settings.indentation;
|
||||
}
|
||||
getCodeAction(document, params) {
|
||||
if (!params.context.diagnostics) {
|
||||
return;
|
||||
}
|
||||
const result = [];
|
||||
result.push(...this.getConvertToBooleanActions(params.context.diagnostics, document));
|
||||
result.push(...this.getJumpToSchemaActions(params.context.diagnostics));
|
||||
result.push(...this.getTabToSpaceConverting(params.context.diagnostics, document));
|
||||
result.push(...this.getUnusedAnchorsDelete(params.context.diagnostics, document));
|
||||
result.push(...this.getConvertToBlockStyleActions(params.context.diagnostics, document));
|
||||
result.push(...this.getKeyOrderActions(params.context.diagnostics, document));
|
||||
return result;
|
||||
}
|
||||
getJumpToSchemaActions(diagnostics) {
|
||||
const isOpenTextDocumentEnabled = this.clientCapabilities?.window?.showDocument?.support ?? false;
|
||||
if (!isOpenTextDocumentEnabled) {
|
||||
return [];
|
||||
}
|
||||
const schemaUriToDiagnostic = new Map();
|
||||
for (const diagnostic of diagnostics) {
|
||||
const schemaUri = diagnostic.data?.schemaUri || [];
|
||||
for (const schemaUriStr of schemaUri) {
|
||||
if (schemaUriStr) {
|
||||
if (!schemaUriToDiagnostic.has(schemaUriStr)) {
|
||||
schemaUriToDiagnostic.set(schemaUriStr, []);
|
||||
}
|
||||
schemaUriToDiagnostic.get(schemaUriStr).push(diagnostic);
|
||||
}
|
||||
}
|
||||
}
|
||||
const result = [];
|
||||
for (const schemaUri of schemaUriToDiagnostic.keys()) {
|
||||
const action = vscode_languageserver_types_1.CodeAction.create(`Jump to schema location (${path.basename(schemaUri)})`, vscode_languageserver_types_1.Command.create('JumpToSchema', commands_1.YamlCommands.JUMP_TO_SCHEMA, schemaUri));
|
||||
action.diagnostics = schemaUriToDiagnostic.get(schemaUri);
|
||||
result.push(action);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getTabToSpaceConverting(diagnostics, document) {
|
||||
const result = [];
|
||||
const textBuff = new textBuffer_1.TextBuffer(document);
|
||||
const processedLine = [];
|
||||
for (const diag of diagnostics) {
|
||||
if (diag.message === 'Using tabs can lead to unpredictable results') {
|
||||
if (processedLine.includes(diag.range.start.line)) {
|
||||
continue;
|
||||
}
|
||||
const lineContent = textBuff.getLineContent(diag.range.start.line);
|
||||
let replacedTabs = 0;
|
||||
let newText = '';
|
||||
for (let i = diag.range.start.character; i <= diag.range.end.character; i++) {
|
||||
const char = lineContent.charAt(i);
|
||||
if (char !== '\t') {
|
||||
break;
|
||||
}
|
||||
replacedTabs++;
|
||||
newText += this.indentation;
|
||||
}
|
||||
processedLine.push(diag.range.start.line);
|
||||
let resultRange = diag.range;
|
||||
if (replacedTabs !== diag.range.end.character - diag.range.start.character) {
|
||||
resultRange = vscode_languageserver_types_1.Range.create(diag.range.start, vscode_languageserver_types_1.Position.create(diag.range.end.line, diag.range.start.character + replacedTabs));
|
||||
}
|
||||
result.push(vscode_languageserver_types_1.CodeAction.create('Convert Tab to Spaces', createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(resultRange, newText)]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
if (result.length !== 0) {
|
||||
const replaceEdits = [];
|
||||
for (let i = 0; i <= textBuff.getLineCount(); i++) {
|
||||
const lineContent = textBuff.getLineContent(i);
|
||||
let replacedTabs = 0;
|
||||
let newText = '';
|
||||
for (let j = 0; j < lineContent.length; j++) {
|
||||
const char = lineContent.charAt(j);
|
||||
if (char !== ' ' && char !== '\t') {
|
||||
if (replacedTabs !== 0) {
|
||||
replaceEdits.push(vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(i, j - replacedTabs, i, j), newText));
|
||||
replacedTabs = 0;
|
||||
newText = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (char === ' ' && replacedTabs !== 0) {
|
||||
replaceEdits.push(vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(i, j - replacedTabs, i, j), newText));
|
||||
replacedTabs = 0;
|
||||
newText = '';
|
||||
continue;
|
||||
}
|
||||
if (char === '\t') {
|
||||
newText += this.indentation;
|
||||
replacedTabs++;
|
||||
}
|
||||
}
|
||||
// line contains only tabs
|
||||
if (replacedTabs !== 0) {
|
||||
replaceEdits.push(vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(i, 0, i, textBuff.getLineLength(i)), newText));
|
||||
}
|
||||
}
|
||||
if (replaceEdits.length > 0) {
|
||||
result.push(vscode_languageserver_types_1.CodeAction.create('Convert all Tabs to Spaces', createWorkspaceEdit(document.uri, replaceEdits), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getUnusedAnchorsDelete(diagnostics, document) {
|
||||
const result = [];
|
||||
const buffer = new textBuffer_1.TextBuffer(document);
|
||||
for (const diag of diagnostics) {
|
||||
if (diag.message.startsWith('Unused anchor') && diag.source === jsonParser07_1.YAML_SOURCE) {
|
||||
const range = vscode_languageserver_types_1.Range.create(diag.range.start, diag.range.end);
|
||||
const actual = buffer.getText(range);
|
||||
const lineContent = buffer.getLineContent(range.end.line);
|
||||
const lastWhitespaceChar = (0, strings_1.getFirstNonWhitespaceCharacterAfterOffset)(lineContent, range.end.character);
|
||||
range.end.character = lastWhitespaceChar;
|
||||
const action = vscode_languageserver_types_1.CodeAction.create(`Delete unused anchor: ${actual}`, createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.del(range)]), vscode_languageserver_types_1.CodeActionKind.QuickFix);
|
||||
action.diagnostics = [diag];
|
||||
result.push(action);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getConvertToBooleanActions(diagnostics, document) {
|
||||
const results = [];
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic.message === 'Incorrect type. Expected "boolean".') {
|
||||
const value = document.getText(diagnostic.range).toLocaleLowerCase();
|
||||
if (value === '"true"' || value === '"false"' || value === "'true'" || value === "'false'") {
|
||||
const newValue = value.includes('true') ? 'true' : 'false';
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create('Convert to boolean', createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(diagnostic.range, newValue)]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
getConvertToBlockStyleActions(diagnostics, document) {
|
||||
const results = [];
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic.code === 'flowMap' || diagnostic.code === 'flowSeq') {
|
||||
const node = getNodeforDiagnostic(document, diagnostic);
|
||||
if ((0, yaml_1.isMap)(node.internalNode) || (0, yaml_1.isSeq)(node.internalNode)) {
|
||||
const blockTypeDescription = (0, yaml_1.isMap)(node.internalNode) ? 'map' : 'sequence';
|
||||
const rewriter = new flow_style_rewriter_1.FlowStyleRewriter(this.indentation);
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create(`Convert to block style ${blockTypeDescription}`, createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(diagnostic.range, rewriter.write(node))]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
getKeyOrderActions(diagnostics, document) {
|
||||
const results = [];
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic?.code === 'mapKeyOrder') {
|
||||
let node = getNodeforDiagnostic(document, diagnostic);
|
||||
while (node && node.type !== 'object') {
|
||||
node = node.parent;
|
||||
}
|
||||
if (node && (0, yaml_1.isMap)(node.internalNode)) {
|
||||
const sorted = _.cloneDeep(node.internalNode);
|
||||
if ((sorted.srcToken.type === 'block-map' || sorted.srcToken.type === 'flow-collection') &&
|
||||
(node.internalNode.srcToken.type === 'block-map' || node.internalNode.srcToken.type === 'flow-collection')) {
|
||||
sorted.srcToken.items.sort((a, b) => {
|
||||
if (a.key && b.key && yaml_1.CST.isScalar(a.key) && yaml_1.CST.isScalar(b.key)) {
|
||||
return a.key.source.localeCompare(b.key.source);
|
||||
}
|
||||
if (!a.key && b.key) {
|
||||
return -1;
|
||||
}
|
||||
if (a.key && !b.key) {
|
||||
return 1;
|
||||
}
|
||||
if (!a.key && !b.key) {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
for (let i = 0; i < sorted.srcToken.items.length; i++) {
|
||||
const item = sorted.srcToken.items[i];
|
||||
const uItem = node.internalNode.srcToken.items[i];
|
||||
item.start = uItem.start;
|
||||
if (item.value?.type === 'alias' ||
|
||||
item.value?.type === 'scalar' ||
|
||||
item.value?.type === 'single-quoted-scalar' ||
|
||||
item.value?.type === 'double-quoted-scalar') {
|
||||
const newLineIndex = item.value?.end?.findIndex((p) => p.type === 'newline') ?? -1;
|
||||
let newLineToken = null;
|
||||
if (uItem.value?.type === 'block-scalar') {
|
||||
newLineToken = uItem.value?.props?.find((p) => p.type === 'newline');
|
||||
}
|
||||
else if (yaml_1.CST.isScalar(uItem.value)) {
|
||||
newLineToken = uItem.value?.end?.find((p) => p.type === 'newline');
|
||||
}
|
||||
if (newLineToken && newLineIndex < 0) {
|
||||
item.value.end = item.value.end ?? [];
|
||||
item.value.end.push(newLineToken);
|
||||
}
|
||||
if (!newLineToken && newLineIndex > -1) {
|
||||
item.value.end.splice(newLineIndex, 1);
|
||||
}
|
||||
}
|
||||
else if (item.value?.type === 'block-scalar') {
|
||||
const nwline = item.value.props.find((p) => p.type === 'newline');
|
||||
if (!nwline) {
|
||||
item.value.props.push({ type: 'newline', indent: 0, offset: item.value.offset, source: '\n' });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const replaceRange = vscode_languageserver_types_1.Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create('Fix key order for this map', createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(replaceRange, yaml_1.CST.stringify(sorted.srcToken))]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
exports.YamlCodeActions = YamlCodeActions;
|
||||
function getNodeforDiagnostic(document, diagnostic) {
|
||||
const yamlDocuments = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
const startOffset = document.offsetAt(diagnostic.range.start);
|
||||
const yamlDoc = (0, arrUtils_1.matchOffsetToDocument)(startOffset, yamlDocuments);
|
||||
const node = yamlDoc.getNodeFromOffset(startOffset);
|
||||
return node;
|
||||
}
|
||||
function createWorkspaceEdit(uri, edits) {
|
||||
const changes = {};
|
||||
changes[uri] = edits;
|
||||
const edit = {
|
||||
changes,
|
||||
};
|
||||
return edit;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlCodeActions.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeActions.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeActions.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
11
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeLens.d.ts
generated
vendored
Normal file
11
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeLens.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { CodeLens } from 'vscode-languageserver-types';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YamlCodeLens {
|
||||
private schemaService;
|
||||
private readonly telemetry?;
|
||||
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
|
||||
getCodeLens(document: TextDocument): Promise<CodeLens[]>;
|
||||
resolveCodeLens(param: CodeLens): PromiseLike<CodeLens> | CodeLens;
|
||||
}
|
||||
61
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeLens.js
generated
vendored
Normal file
61
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeLens.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../../commands", "../parser/yaml-documents", "../utils/schemaUrls", "../utils/objects", "../utils/schemaUtils"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlCodeLens = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const commands_1 = require("../../commands");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const schemaUrls_1 = require("../utils/schemaUrls");
|
||||
const objects_1 = require("../utils/objects");
|
||||
const schemaUtils_1 = require("../utils/schemaUtils");
|
||||
class YamlCodeLens {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.schemaService = schemaService;
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
async getCodeLens(document) {
|
||||
const result = [];
|
||||
try {
|
||||
const yamlDocument = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
let schemaUrls = new Map();
|
||||
for (const currentYAMLDoc of yamlDocument.documents) {
|
||||
const schema = await this.schemaService.getSchemaForResource(document.uri, currentYAMLDoc);
|
||||
if (schema?.schema) {
|
||||
// merge schemas from all docs to avoid duplicates
|
||||
schemaUrls = new Map([...(0, schemaUrls_1.getSchemaUrls)(schema?.schema), ...schemaUrls]);
|
||||
}
|
||||
}
|
||||
for (const urlToSchema of schemaUrls) {
|
||||
const lens = vscode_languageserver_types_1.CodeLens.create(vscode_languageserver_types_1.Range.create(0, 0, 0, 0));
|
||||
lens.command = {
|
||||
title: (0, schemaUtils_1.getSchemaTitle)(urlToSchema[1], urlToSchema[0]),
|
||||
command: commands_1.YamlCommands.JUMP_TO_SCHEMA,
|
||||
arguments: [urlToSchema[0]],
|
||||
};
|
||||
result.push(lens);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.codeLens.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(err) });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
resolveCodeLens(param) {
|
||||
return param;
|
||||
}
|
||||
}
|
||||
exports.YamlCodeLens = YamlCodeLens;
|
||||
});
|
||||
//# sourceMappingURL=yamlCodeLens.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeLens.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCodeLens.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlCodeLens.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlCodeLens.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6EAA8D;IAC9D,6CAA8C;IAC9C,6DAA8D;IAI9D,oDAAoD;IACpD,8CAA8D;IAC9D,sDAAsD;IAEtD,MAAa,YAAY;QACvB,YAAoB,aAAgC,EAAmB,SAAqB;YAAxE,kBAAa,GAAb,aAAa,CAAmB;YAAmB,cAAS,GAAT,SAAS,CAAY;QAAG,CAAC;QAEhG,KAAK,CAAC,WAAW,CAAC,QAAsB;YACtC,MAAM,MAAM,GAAG,EAAE,CAAC;YAClB,IAAI;gBACF,MAAM,YAAY,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,UAAU,GAAG,IAAI,GAAG,EAAsB,CAAC;gBAC/C,KAAK,MAAM,cAAc,IAAI,YAAY,CAAC,SAAS,EAAE;oBACnD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;oBAC3F,IAAI,MAAM,EAAE,MAAM,EAAE;wBAClB,kDAAkD;wBAClD,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAA,0BAAa,EAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC;qBACzE;iBACF;gBACD,KAAK,MAAM,WAAW,IAAI,UAAU,EAAE;oBACpC,MAAM,IAAI,GAAG,sCAAQ,CAAC,MAAM,CAAC,mCAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;oBACvD,IAAI,CAAC,OAAO,GAAG;wBACb,KAAK,EAAE,IAAA,4BAAc,EAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;wBACrD,OAAO,EAAE,uBAAY,CAAC,cAAc;wBACpC,SAAS,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;qBAC5B,CAAC;oBACF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACnB;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,IAAA,oCAA0B,EAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aAC9F;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,eAAe,CAAC,KAAe;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;KACF;IAjCD,oCAiCC"}
|
||||
3
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCommands.d.ts
generated
vendored
Normal file
3
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCommands.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { CommandExecutor } from '../../languageserver/commandExecutor';
|
||||
export declare function registerCommands(commandExecutor: CommandExecutor, connection: Connection): void;
|
||||
48
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCommands.js
generated
vendored
Normal file
48
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCommands.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../../commands", "vscode-uri"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registerCommands = void 0;
|
||||
const commands_1 = require("../../commands");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
function registerCommands(commandExecutor, connection) {
|
||||
commandExecutor.registerCommand(commands_1.YamlCommands.JUMP_TO_SCHEMA, async (uri) => {
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
// if uri points to local file of its a windows path
|
||||
if (!uri.startsWith('file') && !/^[a-z]:[\\/]/i.test(uri)) {
|
||||
const origUri = vscode_uri_1.URI.parse(uri);
|
||||
const customUri = vscode_uri_1.URI.from({
|
||||
scheme: 'json-schema',
|
||||
authority: origUri.authority,
|
||||
path: origUri.path.endsWith('.json') ? origUri.path : origUri.path + '.json',
|
||||
fragment: uri,
|
||||
});
|
||||
uri = customUri.toString();
|
||||
}
|
||||
// test if uri is windows path, ie starts with 'c:\' and convert to URI
|
||||
if (/^[a-z]:[\\/]/i.test(uri)) {
|
||||
const winUri = vscode_uri_1.URI.file(uri);
|
||||
uri = winUri.toString();
|
||||
}
|
||||
const result = await connection.window.showDocument({ uri: uri, external: false, takeFocus: true });
|
||||
if (!result) {
|
||||
connection.window.showErrorMessage(`Cannot open ${uri}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.registerCommands = registerCommands;
|
||||
});
|
||||
//# sourceMappingURL=yamlCommands.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCommands.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCommands.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlCommands.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlCommands.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6CAA8C;IAE9C,2CAAiC;IAEjC,SAAgB,gBAAgB,CAAC,eAAgC,EAAE,UAAsB;QACvF,eAAe,CAAC,eAAe,CAAC,uBAAY,CAAC,cAAc,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE;YACjF,IAAI,CAAC,GAAG,EAAE;gBACR,OAAO;aACR;YACD,oDAAoD;YACpD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;gBACzD,MAAM,OAAO,GAAG,gBAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC/B,MAAM,SAAS,GAAG,gBAAG,CAAC,IAAI,CAAC;oBACzB,MAAM,EAAE,aAAa;oBACrB,SAAS,EAAE,OAAO,CAAC,SAAS;oBAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,OAAO;oBAC5E,QAAQ,EAAE,GAAG;iBACd,CAAC,CAAC;gBACH,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;aAC5B;YAED,uEAAuE;YACvE,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;gBAC7B,MAAM,MAAM,GAAG,gBAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC7B,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;aACzB;YAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACpG,IAAI,CAAC,MAAM,EAAE;gBACX,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC;aAC1D;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IA5BD,4CA4BC"}
|
||||
68
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCompletion.d.ts
generated
vendored
Normal file
68
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCompletion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { ClientCapabilities } from 'vscode-languageserver';
|
||||
import { CompletionItem as CompletionItemBase, CompletionList, Position } from 'vscode-languageserver-types';
|
||||
import { Telemetry } from '../telemetry';
|
||||
import { YamlDocuments } from '../parser/yaml-documents';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { JSONSchema } from '../jsonSchema';
|
||||
interface ParentCompletionItemOptions {
|
||||
schema: JSONSchema;
|
||||
indent?: string;
|
||||
insertTexts?: string[];
|
||||
}
|
||||
interface CompletionItem extends CompletionItemBase {
|
||||
parent?: ParentCompletionItemOptions;
|
||||
}
|
||||
export declare class YamlCompletion {
|
||||
private schemaService;
|
||||
private clientCapabilities;
|
||||
private yamlDocument;
|
||||
private readonly telemetry?;
|
||||
private customTags;
|
||||
private completionEnabled;
|
||||
private configuredIndentation;
|
||||
private yamlVersion;
|
||||
private indentation;
|
||||
private arrayPrefixIndentation;
|
||||
private supportsMarkdown;
|
||||
private disableDefaultProperties;
|
||||
private parentSkeletonSelectedFirst;
|
||||
constructor(schemaService: YAMLSchemaService, clientCapabilities: ClientCapabilities, yamlDocument: YamlDocuments, telemetry?: Telemetry);
|
||||
configure(languageSettings: LanguageSettings): void;
|
||||
doComplete(document: TextDocument, position: Position, isKubernetes?: boolean, doComplete?: boolean): Promise<CompletionList>;
|
||||
updateCompletionText(completionItem: CompletionItem, text: string): void;
|
||||
mergeSimpleInsertTexts(label: string, existingText: string, addingText: string, oneOfSchema: boolean): string | undefined;
|
||||
getValuesFromInsertText(insertText: string): string[];
|
||||
private finalizeParentCompletion;
|
||||
private createTempObjNode;
|
||||
private addPropertyCompletions;
|
||||
private getValueCompletions;
|
||||
private addArrayItemValueCompletion;
|
||||
private getInsertTextForProperty;
|
||||
private getInsertTextForObject;
|
||||
private getInsertTextForArray;
|
||||
private getInsertTextForGuessedValue;
|
||||
private getInsertTextForPlainText;
|
||||
private getInsertTextForValue;
|
||||
private getInsertTemplateForValue;
|
||||
private addSchemaValueCompletions;
|
||||
private collectTypes;
|
||||
private addDefaultValueCompletions;
|
||||
private addEnumValueCompletions;
|
||||
private getLabelForValue;
|
||||
private collectDefaultSnippets;
|
||||
private getInsertTextForSnippetValue;
|
||||
private addBooleanValueCompletion;
|
||||
private addNullValueCompletion;
|
||||
private getLabelForSnippetValue;
|
||||
private getCustomTagValueCompletions;
|
||||
private addCustomTagValueCompletion;
|
||||
private getDocumentationWithMarkdownText;
|
||||
private getSuggestionKind;
|
||||
private getCurrentWord;
|
||||
private fromMarkup;
|
||||
private doesSupportMarkdown;
|
||||
private findItemAtOffset;
|
||||
}
|
||||
export {};
|
||||
1473
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCompletion.js
generated
vendored
Normal file
1473
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCompletion.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCompletion.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlCompletion.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlDefinition.d.ts
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlDefinition.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { DefinitionParams } from 'vscode-languageserver-protocol';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { DefinitionLink } from 'vscode-languageserver-types';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YamlDefinition {
|
||||
private readonly telemetry?;
|
||||
constructor(telemetry?: Telemetry);
|
||||
getDefinition(document: TextDocument, params: DefinitionParams): DefinitionLink[] | undefined;
|
||||
}
|
||||
52
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlDefinition.js
generated
vendored
Normal file
52
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlDefinition.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml", "../parser/yaml-documents", "../utils/arrUtils", "../utils/objects", "../utils/textBuffer"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlDefinition = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
const objects_1 = require("../utils/objects");
|
||||
const textBuffer_1 = require("../utils/textBuffer");
|
||||
class YamlDefinition {
|
||||
constructor(telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
getDefinition(document, params) {
|
||||
try {
|
||||
const yamlDocument = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
const offset = document.offsetAt(params.position);
|
||||
const currentDoc = (0, arrUtils_1.matchOffsetToDocument)(offset, yamlDocument);
|
||||
if (currentDoc) {
|
||||
const [node] = currentDoc.getNodeFromPosition(offset, new textBuffer_1.TextBuffer(document));
|
||||
if (node && (0, yaml_1.isAlias)(node)) {
|
||||
const defNode = node.resolve(currentDoc.internalDocument);
|
||||
if (defNode && defNode.range) {
|
||||
const targetRange = vscode_languageserver_types_1.Range.create(document.positionAt(defNode.range[0]), document.positionAt(defNode.range[2]));
|
||||
const selectionRange = vscode_languageserver_types_1.Range.create(document.positionAt(defNode.range[0]), document.positionAt(defNode.range[1]));
|
||||
return [vscode_languageserver_types_1.LocationLink.create(document.uri, targetRange, selectionRange)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.definition.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(err) });
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.YamlDefinition = YamlDefinition;
|
||||
});
|
||||
//# sourceMappingURL=yamlDefinition.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlDefinition.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlDefinition.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlDefinition.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAIhG,6EAAkF;IAClF,+BAA+B;IAE/B,6DAA8D;IAC9D,gDAA0D;IAC1D,8CAA8D;IAC9D,oDAAiD;IAEjD,MAAa,cAAc;QACzB,YAA6B,SAAqB;YAArB,cAAS,GAAT,SAAS,CAAY;QAAG,CAAC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AuB,EAAE,EAAE,KAAK,EAAE,IAAA,oCAA0B,EAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aAChG;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;KACF;IAzBD,wCAyBC"}
|
||||
4
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFolding.d.ts
generated
vendored
Normal file
4
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFolding.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { FoldingRange } from 'vscode-languageserver-types';
|
||||
import { FoldingRangesContext } from '../yamlTypes';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare function getFoldingRanges(document: TextDocument, context: FoldingRangesContext): FoldingRange[] | undefined;
|
||||
76
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFolding.js
generated
vendored
Normal file
76
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFolding.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../parser/yaml-documents"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getFoldingRanges = void 0;
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
function getFoldingRanges(document, context) {
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
const result = [];
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
for (const ymlDoc of doc.documents) {
|
||||
if (doc.documents.length > 1) {
|
||||
result.push(createNormalizedFolding(document, ymlDoc.root));
|
||||
}
|
||||
ymlDoc.visit((node) => {
|
||||
if (node.type === 'object' && node.parent?.type === 'array') {
|
||||
result.push(createNormalizedFolding(document, node));
|
||||
}
|
||||
if (node.type === 'property' && node.valueNode) {
|
||||
switch (node.valueNode.type) {
|
||||
case 'array':
|
||||
case 'object':
|
||||
result.push(createNormalizedFolding(document, node));
|
||||
break;
|
||||
case 'string': {
|
||||
// check if it is a multi-line string
|
||||
const nodePosn = document.positionAt(node.offset);
|
||||
const valuePosn = document.positionAt(node.valueNode.offset + node.valueNode.length);
|
||||
if (nodePosn.line !== valuePosn.line) {
|
||||
result.push(createNormalizedFolding(document, node));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
const rangeLimit = context && context.rangeLimit;
|
||||
if (typeof rangeLimit !== 'number' || result.length <= rangeLimit) {
|
||||
return result;
|
||||
}
|
||||
if (context && context.onRangeLimitExceeded) {
|
||||
context.onRangeLimitExceeded(document.uri);
|
||||
}
|
||||
return result.slice(0, context.rangeLimit);
|
||||
}
|
||||
exports.getFoldingRanges = getFoldingRanges;
|
||||
function createNormalizedFolding(document, node) {
|
||||
const startPos = document.positionAt(node.offset);
|
||||
let endPos = document.positionAt(node.offset + node.length);
|
||||
const textFragment = document.getText(vscode_languageserver_types_1.Range.create(startPos, endPos));
|
||||
const newLength = textFragment.length - textFragment.trimRight().length;
|
||||
if (newLength > 0) {
|
||||
endPos = document.positionAt(node.offset + node.length - newLength);
|
||||
}
|
||||
return vscode_languageserver_types_1.FoldingRange.create(startPos.line, endPos.line, startPos.character, endPos.character);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlFolding.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFolding.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFolding.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlFolding.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlFolding.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA;;;oGAGgG;IAChG,6EAAkE;IAGlE,6DAA8D;IAG9D,SAAgB,gBAAgB,CAAC,QAAsB,EAAE,OAA6B;QACpF,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;SACR;QACD,MAAM,MAAM,GAAmB,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACzD,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE;YAClC,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;aAC7D;YACD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;gBACpB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,OAAO,EAAE;oBAC3D,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;iBACtD;gBACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE;oBAC9C,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;wBAC3B,KAAK,OAAO,CAAC;wBACb,KAAK,QAAQ;4BACX,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;4BACrD,MAAM;wBACR,KAAK,QAAQ,CAAC,CAAC;4BACb,qCAAqC;4BACrC,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,CA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AAE,CAAC,MAAM,CAAC;QACxE,IAAI,SAAS,GAAG,CAAC,EAAE;YACjB,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;SACrE;QACD,OAAO,0CAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/F,CAAC"}
|
||||
8
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFormatter.d.ts
generated
vendored
Normal file
8
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFormatter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { TextEdit, FormattingOptions } from 'vscode-languageserver-types';
|
||||
import { CustomFormatterOptions, LanguageSettings } from '../yamlLanguageService';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare class YAMLFormatter {
|
||||
private formatterEnabled;
|
||||
configure(shouldFormat: LanguageSettings): void;
|
||||
format(document: TextDocument, options?: Partial<FormattingOptions> & CustomFormatterOptions): TextEdit[];
|
||||
}
|
||||
58
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFormatter.js
generated
vendored
Normal file
58
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFormatter.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) Adam Voss. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "prettier", "prettier/parser-yaml"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLFormatter = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const prettier = require("prettier");
|
||||
const parser = require("prettier/parser-yaml");
|
||||
class YAMLFormatter {
|
||||
constructor() {
|
||||
this.formatterEnabled = true;
|
||||
}
|
||||
configure(shouldFormat) {
|
||||
if (shouldFormat) {
|
||||
this.formatterEnabled = shouldFormat.format;
|
||||
}
|
||||
}
|
||||
format(document, options = {}) {
|
||||
if (!this.formatterEnabled) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const text = document.getText();
|
||||
const prettierOptions = {
|
||||
parser: 'yaml',
|
||||
plugins: [parser],
|
||||
// --- FormattingOptions ---
|
||||
tabWidth: options.tabWidth || options.tabSize,
|
||||
// --- CustomFormatterOptions ---
|
||||
singleQuote: options.singleQuote,
|
||||
bracketSpacing: options.bracketSpacing,
|
||||
// 'preserve' is the default for Options.proseWrap. See also server.ts
|
||||
proseWrap: 'always' === options.proseWrap ? 'always' : 'never' === options.proseWrap ? 'never' : 'preserve',
|
||||
printWidth: options.printWidth,
|
||||
};
|
||||
const formatted = prettier.format(text, prettierOptions);
|
||||
return [vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(vscode_languageserver_types_1.Position.create(0, 0), document.positionAt(text.length)), formatted)];
|
||||
}
|
||||
catch (error) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.YAMLFormatter = YAMLFormatter;
|
||||
});
|
||||
//# sourceMappingURL=yamlFormatter.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFormatter.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlFormatter.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlFormatter.js","sourceRoot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,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;aAC7G;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,EAAE,CAAC;aACX;QACH,CAAC;KACF;IAvCD,sCAuCC"}
|
||||
16
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.d.ts
generated
vendored
Normal file
16
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Hover, Position } from 'vscode-languageserver-types';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YAMLHover {
|
||||
private readonly telemetry?;
|
||||
private shouldHover;
|
||||
private indentation;
|
||||
private schemaService;
|
||||
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
|
||||
configure(languageSettings: LanguageSettings): void;
|
||||
doHover(document: TextDocument, position: Position, isKubernetes?: boolean): Promise<Hover | null>;
|
||||
private getHover;
|
||||
private toMarkdown;
|
||||
}
|
||||
251
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.js
generated
vendored
Normal file
251
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.js
generated
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../utils/arrUtils", "../parser/isKubernetes", "../parser/yaml-documents", "vscode-uri", "path", "../utils/objects", "yaml"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLHover = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
const isKubernetes_1 = require("../parser/isKubernetes");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const path = require("path");
|
||||
const objects_1 = require("../utils/objects");
|
||||
const yaml_1 = require("yaml");
|
||||
class YAMLHover {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
this.shouldHover = true;
|
||||
this.schemaService = schemaService;
|
||||
}
|
||||
configure(languageSettings) {
|
||||
if (languageSettings) {
|
||||
this.shouldHover = languageSettings.hover;
|
||||
this.indentation = languageSettings.indentation;
|
||||
}
|
||||
}
|
||||
doHover(document, position, isKubernetes = false) {
|
||||
try {
|
||||
if (!this.shouldHover || !document) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
const offset = document.offsetAt(position);
|
||||
const currentDoc = (0, arrUtils_1.matchOffsetToDocument)(offset, doc);
|
||||
if (currentDoc === null) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
(0, isKubernetes_1.setKubernetesParserOption)(doc.documents, isKubernetes);
|
||||
const currentDocIndex = doc.documents.indexOf(currentDoc);
|
||||
currentDoc.currentDocIndex = currentDocIndex;
|
||||
return this.getHover(document, position, currentDoc);
|
||||
}
|
||||
catch (error) {
|
||||
this.telemetry?.sendError('yaml.hover.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(error) });
|
||||
}
|
||||
}
|
||||
// method copied from https://github.com/microsoft/vscode-json-languageservice/blob/2ea5ad3d2ffbbe40dea11cfe764a502becf113ce/src/services/jsonHover.ts#L23
|
||||
getHover(document, position, doc) {
|
||||
const offset = document.offsetAt(position);
|
||||
let node = doc.getNodeFromOffset(offset);
|
||||
if (!node ||
|
||||
((node.type === 'object' || node.type === 'array') && offset > node.offset + 1 && offset < node.offset + node.length - 1)) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
const hoverRangeNode = node;
|
||||
// use the property description when hovering over an object key
|
||||
if (node.type === 'string') {
|
||||
const parent = node.parent;
|
||||
if (parent && parent.type === 'property' && parent.keyNode === node) {
|
||||
node = parent.valueNode;
|
||||
if (!node) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
const hoverRange = vscode_languageserver_types_1.Range.create(document.positionAt(hoverRangeNode.offset), document.positionAt(hoverRangeNode.offset + hoverRangeNode.length));
|
||||
const createHover = (contents) => {
|
||||
const markupContent = {
|
||||
kind: vscode_languageserver_types_1.MarkupKind.Markdown,
|
||||
value: contents,
|
||||
};
|
||||
const result = {
|
||||
contents: markupContent,
|
||||
range: hoverRange,
|
||||
};
|
||||
return result;
|
||||
};
|
||||
const removePipe = (value) => {
|
||||
return value.replace(/\|\|\s*$/, '');
|
||||
};
|
||||
return this.schemaService.getSchemaForResource(document.uri, doc).then((schema) => {
|
||||
if (schema && node && !schema.errors.length) {
|
||||
const matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
|
||||
let title = undefined;
|
||||
let markdownDescription = undefined;
|
||||
let markdownEnumDescriptions = [];
|
||||
const markdownExamples = [];
|
||||
const markdownEnums = [];
|
||||
matchingSchemas.every((s) => {
|
||||
if ((s.node === node || (node.type === 'property' && node.valueNode === s.node)) && !s.inverted && s.schema) {
|
||||
title = title || s.schema.title || s.schema.closestTitle;
|
||||
markdownDescription = markdownDescription || s.schema.markdownDescription || this.toMarkdown(s.schema.description);
|
||||
if (s.schema.enum) {
|
||||
if (s.schema.markdownEnumDescriptions) {
|
||||
markdownEnumDescriptions = s.schema.markdownEnumDescriptions;
|
||||
}
|
||||
else if (s.schema.enumDescriptions) {
|
||||
markdownEnumDescriptions = s.schema.enumDescriptions.map(this.toMarkdown, this);
|
||||
}
|
||||
else {
|
||||
markdownEnumDescriptions = [];
|
||||
}
|
||||
s.schema.enum.forEach((enumValue, idx) => {
|
||||
if (typeof enumValue !== 'string') {
|
||||
enumValue = JSON.stringify(enumValue);
|
||||
}
|
||||
markdownEnums.push({
|
||||
value: enumValue,
|
||||
description: markdownEnumDescriptions[idx],
|
||||
});
|
||||
});
|
||||
}
|
||||
if (s.schema.anyOf && isAllSchemasMatched(node, matchingSchemas, s.schema)) {
|
||||
//if append title and description of all matched schemas on hover
|
||||
title = '';
|
||||
markdownDescription = '';
|
||||
s.schema.anyOf.forEach((childSchema, index) => {
|
||||
title += childSchema.title || s.schema.closestTitle || '';
|
||||
markdownDescription += childSchema.markdownDescription || this.toMarkdown(childSchema.description) || '';
|
||||
if (index !== s.schema.anyOf.length - 1) {
|
||||
title += ' || ';
|
||||
markdownDescription += ' || ';
|
||||
}
|
||||
});
|
||||
title = removePipe(title);
|
||||
markdownDescription = removePipe(markdownDescription);
|
||||
}
|
||||
if (s.schema.examples) {
|
||||
s.schema.examples.forEach((example) => {
|
||||
markdownExamples.push((0, yaml_1.stringify)(example, null, 2));
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
let result = '';
|
||||
if (title) {
|
||||
result = '#### ' + this.toMarkdown(title);
|
||||
}
|
||||
if (markdownDescription) {
|
||||
result = ensureLineBreak(result);
|
||||
result += markdownDescription;
|
||||
}
|
||||
if (markdownEnums.length !== 0) {
|
||||
result = ensureLineBreak(result);
|
||||
result += 'Allowed Values:\n\n';
|
||||
markdownEnums.forEach((me) => {
|
||||
if (me.description) {
|
||||
result += `* \`${toMarkdownCodeBlock(me.value)}\`: ${me.description}\n`;
|
||||
}
|
||||
else {
|
||||
result += `* \`${toMarkdownCodeBlock(me.value)}\`\n`;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (markdownExamples.length !== 0) {
|
||||
markdownExamples.forEach((example) => {
|
||||
result = ensureLineBreak(result);
|
||||
result += 'Example:\n\n';
|
||||
result += `\`\`\`yaml\n${example}\`\`\`\n`;
|
||||
});
|
||||
}
|
||||
if (result.length > 0 && schema.schema.url) {
|
||||
result = ensureLineBreak(result);
|
||||
result += `Source: [${getSchemaName(schema.schema)}](${schema.schema.url})`;
|
||||
}
|
||||
return createHover(result);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
// copied from https://github.com/microsoft/vscode-json-languageservice/blob/2ea5ad3d2ffbbe40dea11cfe764a502becf113ce/src/services/jsonHover.ts#L112
|
||||
toMarkdown(plain) {
|
||||
if (plain) {
|
||||
let escaped = plain.replace(/([^\n\r])(\r?\n)([^\n\r])/gm, '$1\n\n$3'); // single new lines to \n\n (Markdown paragraph)
|
||||
escaped = escaped.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
||||
if (this.indentation !== undefined) {
|
||||
// escape indentation whitespace to prevent it from being converted to markdown code blocks.
|
||||
const indentationMatchRegex = new RegExp(` {${this.indentation.length}}`, 'g');
|
||||
escaped = escaped.replace(indentationMatchRegex, ' ');
|
||||
}
|
||||
return escaped;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.YAMLHover = YAMLHover;
|
||||
function ensureLineBreak(content) {
|
||||
if (content.length === 0) {
|
||||
return content;
|
||||
}
|
||||
if (!content.endsWith('\n')) {
|
||||
content += '\n';
|
||||
}
|
||||
return content + '\n';
|
||||
}
|
||||
function getSchemaName(schema) {
|
||||
let result = 'JSON Schema';
|
||||
const urlString = schema.url;
|
||||
if (urlString) {
|
||||
const url = vscode_uri_1.URI.parse(urlString);
|
||||
result = path.basename(url.fsPath);
|
||||
}
|
||||
else if (schema.title) {
|
||||
result = schema.title;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// copied from https://github.com/microsoft/vscode-json-languageservice/blob/2ea5ad3d2ffbbe40dea11cfe764a502becf113ce/src/services/jsonHover.ts#L122
|
||||
function toMarkdownCodeBlock(content) {
|
||||
// see https://daringfireball.net/projects/markdown/syntax#precode
|
||||
if (content.indexOf('`') !== -1) {
|
||||
return '`` ' + content + ' ``';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
/**
|
||||
* check all the schemas which is inside anyOf presented or not in matching schema.
|
||||
* @param node node
|
||||
* @param matchingSchemas all matching schema
|
||||
* @param schema scheam which is having anyOf
|
||||
* @returns true if all the schemas which inside anyOf presents in matching schema
|
||||
*/
|
||||
function isAllSchemasMatched(node, matchingSchemas, schema) {
|
||||
let count = 0;
|
||||
for (const matchSchema of matchingSchemas) {
|
||||
if (node === matchSchema.node && matchSchema.schema !== schema) {
|
||||
schema.anyOf.forEach((childSchema) => {
|
||||
if (matchSchema.schema.title === childSchema.title &&
|
||||
matchSchema.schema.description === childSchema.description &&
|
||||
matchSchema.schema.properties === childSchema.properties) {
|
||||
count++;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return count === schema.anyOf.length;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlHover.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlHover.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlLinks.d.ts
generated
vendored
Normal file
8
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlLinks.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DocumentLink } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YamlLinks {
|
||||
private readonly telemetry?;
|
||||
constructor(telemetry?: Telemetry);
|
||||
findLinks(document: TextDocument): Promise<DocumentLink[]>;
|
||||
}
|
||||
42
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlLinks.js
generated
vendored
Normal file
42
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlLinks.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-json-languageservice/lib/umd/services/jsonLinks", "../parser/yaml-documents", "../utils/objects"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlLinks = void 0;
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
const jsonLinks_1 = require("vscode-json-languageservice/lib/umd/services/jsonLinks");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const objects_1 = require("../utils/objects");
|
||||
class YamlLinks {
|
||||
constructor(telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
findLinks(document) {
|
||||
try {
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
// Find links across all YAML Documents then report them back once finished
|
||||
const linkPromises = [];
|
||||
for (const yamlDoc of doc.documents) {
|
||||
linkPromises.push((0, jsonLinks_1.findLinks)(document, yamlDoc));
|
||||
}
|
||||
// Wait for all the promises to return and then flatten them into one DocumentLink array
|
||||
return Promise.all(linkPromises).then((yamlLinkArray) => [].concat(...yamlLinkArray));
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.documentLink.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(err) });
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.YamlLinks = YamlLinks;
|
||||
});
|
||||
//# sourceMappingURL=yamlLinks.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlLinks.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlLinks.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlLinks.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlLinks.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA;;;oGAGgG;IAChG,sFAAoG;IAIpG,6DAA8D;IAC9D,8CAA8D;IAE9D,MAAa,SAAS;QACpB,YAA6B,SAAqB;YAArB,cAAS,GAAT,SAAS,CAAY;QAAG,CAAC;QAEtD,SAAS,CAAC,QAAsB;YAC9B,IAAI;gBACF,MAAM,GAAG,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBACzD,2EAA2E;gBAC3E,MAAM,YAAY,GAAG,EAAE,CAAC;gBACxB,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,SAAS,EAAE;oBACnC,YAAY,CAAC,IAAI,CAAC,IAAA,qBAAa,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;iBACrD;gBACD,wFAAwF;gBACxF,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;aACvF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,IAAA,oCAA0B,EAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aAClG;QACH,CAAC;KACF;IAjBD,8BAiBC"}
|
||||
4
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlOnTypeFormatting.d.ts
generated
vendored
Normal file
4
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlOnTypeFormatting.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { DocumentOnTypeFormattingParams } from 'vscode-languageserver';
|
||||
import { TextEdit } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare function doDocumentOnTypeFormatting(document: TextDocument, params: DocumentOnTypeFormattingParams): TextEdit[] | undefined;
|
||||
57
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlOnTypeFormatting.js
generated
vendored
Normal file
57
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlOnTypeFormatting.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../utils/textBuffer"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.doDocumentOnTypeFormatting = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const textBuffer_1 = require("../utils/textBuffer");
|
||||
function doDocumentOnTypeFormatting(document, params) {
|
||||
const { position } = params;
|
||||
const tb = new textBuffer_1.TextBuffer(document);
|
||||
if (params.ch === '\n') {
|
||||
const previousLine = tb.getLineContent(position.line - 1);
|
||||
if (previousLine.trimRight().endsWith(':')) {
|
||||
const currentLine = tb.getLineContent(position.line);
|
||||
const subLine = currentLine.substring(position.character, currentLine.length);
|
||||
const isInArray = previousLine.indexOf(' - ') !== -1;
|
||||
if (subLine.trimRight().length === 0) {
|
||||
const indentationFix = position.character - (previousLine.length - previousLine.trimLeft().length);
|
||||
if (indentationFix === params.options.tabSize && !isInArray) {
|
||||
return; // skip if line already has proper formatting
|
||||
}
|
||||
const result = [];
|
||||
if (currentLine.length > 0) {
|
||||
result.push(vscode_languageserver_types_1.TextEdit.del(vscode_languageserver_types_1.Range.create(position, vscode_languageserver_types_1.Position.create(position.line, currentLine.length - 1))));
|
||||
}
|
||||
result.push(vscode_languageserver_types_1.TextEdit.insert(position, ' '.repeat(params.options.tabSize + (isInArray ? 2 - indentationFix : 0))));
|
||||
return result;
|
||||
}
|
||||
if (isInArray) {
|
||||
return [vscode_languageserver_types_1.TextEdit.insert(position, ' '.repeat(params.options.tabSize))];
|
||||
}
|
||||
}
|
||||
if (previousLine.trimRight().endsWith('|')) {
|
||||
return [vscode_languageserver_types_1.TextEdit.insert(position, ' '.repeat(params.options.tabSize))];
|
||||
}
|
||||
if (previousLine.includes(' - ') && !previousLine.includes(': ')) {
|
||||
return [vscode_languageserver_types_1.TextEdit.insert(position, '- ')];
|
||||
}
|
||||
if (previousLine.includes(' - ') && previousLine.includes(': ')) {
|
||||
return [vscode_languageserver_types_1.TextEdit.insert(position, ' ')];
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.doDocumentOnTypeFormatting = doDocumentOnTypeFormatting;
|
||||
});
|
||||
//# sourceMappingURL=yamlOnTypeFormatting.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlOnTypeFormatting.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlOnTypeFormatting.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlOnTypeFormatting.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlOnTypeFormatting.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6EAAwE;IAExE,oDAAiD;IAEjD,SAAgB,0BAA0B,CACxC,QAAsB,EACtB,MAAsC;QAEtC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAA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,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAElH,OAAO,MAAM,CAAC;iBACf;gBACD,IAAI,SAAS,EAAE;oBACb,OAAO,CAAC,sCAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACxE;aACF;YAED,IAAI,YAAY,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC1C,OAAO,CAAC,sCAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;aACxE;YAED,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAChE,OAAO,CAAC,sCAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;aAC1C;YAED,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC/D,OAAO,CAAC,sCAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;aAC1C;SACF;IACH,CAAC;IA1CD,gEA0CC"}
|
||||
102
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.d.ts
generated
vendored
Normal file
102
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.d.ts
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import { JSONSchema } from '../jsonSchema';
|
||||
import { SchemaPriority, SchemaRequestService, WorkspaceContextService } from '../yamlLanguageService';
|
||||
import { UnresolvedSchema, ResolvedSchema, JSONSchemaService, SchemaDependencies, ISchemaContributions, SchemaHandle } from 'vscode-json-languageservice/lib/umd/services/jsonSchemaService';
|
||||
import { JSONDocument } from '../parser/jsonParser07';
|
||||
import { JSONSchemaDescriptionExt } from '../../requestTypes';
|
||||
import { SchemaVersions } from '../yamlTypes';
|
||||
export declare type CustomSchemaProvider = (uri: string) => Promise<string | string[]>;
|
||||
export declare enum MODIFICATION_ACTIONS {
|
||||
'delete' = 0,
|
||||
'add' = 1,
|
||||
'deleteAll' = 2
|
||||
}
|
||||
export interface SchemaAdditions {
|
||||
schema: string;
|
||||
action: MODIFICATION_ACTIONS.add;
|
||||
path: string;
|
||||
key: string;
|
||||
content: any;
|
||||
}
|
||||
export interface SchemaDeletions {
|
||||
schema: string;
|
||||
action: MODIFICATION_ACTIONS.delete;
|
||||
path: string;
|
||||
key: string;
|
||||
}
|
||||
export interface SchemaDeletionsAll {
|
||||
schemas: string[];
|
||||
action: MODIFICATION_ACTIONS.deleteAll;
|
||||
}
|
||||
export declare class FilePatternAssociation {
|
||||
private schemas;
|
||||
private patternRegExp;
|
||||
constructor(pattern: string);
|
||||
addSchema(id: string): void;
|
||||
matchesPattern(fileName: string): boolean;
|
||||
getSchemas(): string[];
|
||||
}
|
||||
export declare class YAMLSchemaService extends JSONSchemaService {
|
||||
[x: string]: any;
|
||||
private customSchemaProvider;
|
||||
private filePatternAssociations;
|
||||
private contextService;
|
||||
private requestService;
|
||||
schemaPriorityMapping: Map<string, Set<SchemaPriority>>;
|
||||
private schemaUriToNameAndDescription;
|
||||
constructor(requestService: SchemaRequestService, contextService?: WorkspaceContextService, promiseConstructor?: PromiseConstructor);
|
||||
registerCustomSchemaProvider(customSchemaProvider: CustomSchemaProvider): void;
|
||||
getAllSchemas(): JSONSchemaDescriptionExt[];
|
||||
resolveSchemaContent(schemaToResolve: UnresolvedSchema, schemaURL: string, dependencies: SchemaDependencies): Promise<ResolvedSchema>;
|
||||
getSchemaForResource(resource: string, doc: JSONDocument): Promise<ResolvedSchema>;
|
||||
addSchemaPriority(uri: string, priority: number): void;
|
||||
/**
|
||||
* Search through all the schemas and find the ones with the highest priority
|
||||
*/
|
||||
private highestPrioritySchemas;
|
||||
private resolveCustomSchema;
|
||||
/**
|
||||
* Save a schema with schema ID and schema content.
|
||||
* Overrides previous schemas set for that schema ID.
|
||||
*/
|
||||
saveSchema(schemaId: string, schemaContent: JSONSchema): Promise<void>;
|
||||
/**
|
||||
* Delete schemas on specific path
|
||||
*/
|
||||
deleteSchemas(deletions: SchemaDeletionsAll): Promise<void>;
|
||||
/**
|
||||
* Delete a schema with schema ID.
|
||||
*/
|
||||
deleteSchema(schemaId: string): Promise<void>;
|
||||
/**
|
||||
* Add content to a specified schema at a specified path
|
||||
*/
|
||||
addContent(additions: SchemaAdditions): Promise<void>;
|
||||
/**
|
||||
* Delete content in a specified schema at a specified path
|
||||
*/
|
||||
deleteContent(deletions: SchemaDeletions): Promise<void>;
|
||||
/**
|
||||
* Take a JSON Schema and the path that you would like to get to
|
||||
* @returns the JSON Schema resolved at that specific path
|
||||
*/
|
||||
private resolveJSONSchemaToSection;
|
||||
/**
|
||||
* Resolve the next Object if they have compatible types
|
||||
* @param object a location in the JSON Schema
|
||||
* @param token the next token that you want to search for
|
||||
*/
|
||||
private resolveNext;
|
||||
/**
|
||||
* Everything below here is needed because we're importing from vscode-json-languageservice umd and we need
|
||||
* to provide a wrapper around the javascript methods we are calling since they have no type
|
||||
*/
|
||||
normalizeId(id: string): string;
|
||||
getOrAddSchemaHandle(id: string, unresolvedSchemaContent?: JSONSchema): SchemaHandle;
|
||||
loadSchema(schemaUri: string): Promise<UnresolvedSchema>;
|
||||
registerExternalSchema(uri: string, filePatterns?: string[], unresolvedSchema?: JSONSchema, name?: string, description?: string, versions?: SchemaVersions): SchemaHandle;
|
||||
clearExternalSchemas(): void;
|
||||
setSchemaContributions(schemaContributions: ISchemaContributions): void;
|
||||
getRegisteredSchemaIds(filter?: (scheme: any) => boolean): string[];
|
||||
getResolvedSchema(schemaId: string): Promise<ResolvedSchema>;
|
||||
onResourceChange(uri: string): boolean;
|
||||
}
|
||||
585
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.js
generated
vendored
Normal file
585
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.js
generated
vendored
Normal file
@@ -0,0 +1,585 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../yamlLanguageService", "vscode-json-languageservice/lib/umd/services/jsonSchemaService", "vscode-uri", "vscode-nls", "../utils/strings", "yaml", "path", "./modelineUtil", "ajv", "../utils/schemaUtils"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLSchemaService = exports.FilePatternAssociation = exports.MODIFICATION_ACTIONS = void 0;
|
||||
const yamlLanguageService_1 = require("../yamlLanguageService");
|
||||
const jsonSchemaService_1 = require("vscode-json-languageservice/lib/umd/services/jsonSchemaService");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const nls = require("vscode-nls");
|
||||
const strings_1 = require("../utils/strings");
|
||||
const yaml_1 = require("yaml");
|
||||
const path = require("path");
|
||||
const modelineUtil_1 = require("./modelineUtil");
|
||||
const ajv_1 = require("ajv");
|
||||
const schemaUtils_1 = require("../utils/schemaUtils");
|
||||
const localize = nls.loadMessageBundle();
|
||||
const ajv = new ajv_1.default();
|
||||
// load JSON Schema 07 def to validate loaded schemas
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const jsonSchema07 = require('ajv/dist/refs/json-schema-draft-07.json');
|
||||
const schema07Validator = ajv.compile(jsonSchema07);
|
||||
var MODIFICATION_ACTIONS;
|
||||
(function (MODIFICATION_ACTIONS) {
|
||||
MODIFICATION_ACTIONS[MODIFICATION_ACTIONS["delete"] = 0] = "delete";
|
||||
MODIFICATION_ACTIONS[MODIFICATION_ACTIONS["add"] = 1] = "add";
|
||||
MODIFICATION_ACTIONS[MODIFICATION_ACTIONS["deleteAll"] = 2] = "deleteAll";
|
||||
})(MODIFICATION_ACTIONS = exports.MODIFICATION_ACTIONS || (exports.MODIFICATION_ACTIONS = {}));
|
||||
class FilePatternAssociation {
|
||||
constructor(pattern) {
|
||||
try {
|
||||
this.patternRegExp = new RegExp((0, strings_1.convertSimple2RegExpPattern)(pattern) + '$');
|
||||
}
|
||||
catch (e) {
|
||||
// invalid pattern
|
||||
this.patternRegExp = null;
|
||||
}
|
||||
this.schemas = [];
|
||||
}
|
||||
addSchema(id) {
|
||||
this.schemas.push(id);
|
||||
}
|
||||
matchesPattern(fileName) {
|
||||
return this.patternRegExp && this.patternRegExp.test(fileName);
|
||||
}
|
||||
getSchemas() {
|
||||
return this.schemas;
|
||||
}
|
||||
}
|
||||
exports.FilePatternAssociation = FilePatternAssociation;
|
||||
class YAMLSchemaService extends jsonSchemaService_1.JSONSchemaService {
|
||||
constructor(requestService, contextService, promiseConstructor) {
|
||||
super(requestService, contextService, promiseConstructor);
|
||||
this.schemaUriToNameAndDescription = new Map();
|
||||
this.customSchemaProvider = undefined;
|
||||
this.requestService = requestService;
|
||||
this.schemaPriorityMapping = new Map();
|
||||
}
|
||||
registerCustomSchemaProvider(customSchemaProvider) {
|
||||
this.customSchemaProvider = customSchemaProvider;
|
||||
}
|
||||
getAllSchemas() {
|
||||
const result = [];
|
||||
const schemaUris = new Set();
|
||||
for (const filePattern of this.filePatternAssociations) {
|
||||
const schemaUri = filePattern.uris[0];
|
||||
if (schemaUris.has(schemaUri)) {
|
||||
continue;
|
||||
}
|
||||
schemaUris.add(schemaUri);
|
||||
const schemaHandle = {
|
||||
uri: schemaUri,
|
||||
fromStore: false,
|
||||
usedForCurrentFile: false,
|
||||
};
|
||||
if (this.schemaUriToNameAndDescription.has(schemaUri)) {
|
||||
const { name, description, versions } = this.schemaUriToNameAndDescription.get(schemaUri);
|
||||
schemaHandle.name = name;
|
||||
schemaHandle.description = description;
|
||||
schemaHandle.fromStore = true;
|
||||
schemaHandle.versions = versions;
|
||||
}
|
||||
result.push(schemaHandle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async resolveSchemaContent(schemaToResolve, schemaURL, dependencies) {
|
||||
const resolveErrors = schemaToResolve.errors.slice(0);
|
||||
let schema = schemaToResolve.schema;
|
||||
const contextService = this.contextService;
|
||||
if (!schema07Validator(schema)) {
|
||||
const errs = [];
|
||||
for (const err of schema07Validator.errors) {
|
||||
errs.push(`${err.instancePath} : ${err.message}`);
|
||||
}
|
||||
resolveErrors.push(`Schema '${(0, schemaUtils_1.getSchemaTitle)(schemaToResolve.schema, schemaURL)}' is not valid:\n${errs.join('\n')}`);
|
||||
}
|
||||
const findSection = (schema, path) => {
|
||||
if (!path) {
|
||||
return schema;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let current = schema;
|
||||
if (path[0] === '/') {
|
||||
path = path.substr(1);
|
||||
}
|
||||
path.split('/').some((part) => {
|
||||
current = current[part];
|
||||
return !current;
|
||||
});
|
||||
return current;
|
||||
};
|
||||
const merge = (target, sourceRoot, sourceURI, path) => {
|
||||
const section = findSection(sourceRoot, path);
|
||||
if (section) {
|
||||
for (const key in section) {
|
||||
if (Object.prototype.hasOwnProperty.call(section, key) && !Object.prototype.hasOwnProperty.call(target, key)) {
|
||||
target[key] = section[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
resolveErrors.push(localize('json.schema.invalidref', "$ref '{0}' in '{1}' can not be resolved.", path, sourceURI));
|
||||
}
|
||||
};
|
||||
const resolveExternalLink = (node, uri, linkPath, parentSchemaURL, parentSchemaDependencies
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
) => {
|
||||
if (contextService && !/^\w+:\/\/.*/.test(uri)) {
|
||||
uri = contextService.resolveRelativePath(uri, parentSchemaURL);
|
||||
}
|
||||
uri = this.normalizeId(uri);
|
||||
const referencedHandle = this.getOrAddSchemaHandle(uri);
|
||||
return referencedHandle.getUnresolvedSchema().then((unresolvedSchema) => {
|
||||
parentSchemaDependencies[uri] = true;
|
||||
if (unresolvedSchema.errors.length) {
|
||||
const loc = linkPath ? uri + '#' + linkPath : uri;
|
||||
resolveErrors.push(localize('json.schema.problemloadingref', "Problems loading reference '{0}': {1}", loc, unresolvedSchema.errors[0]));
|
||||
}
|
||||
merge(node, unresolvedSchema.schema, uri, linkPath);
|
||||
node.url = uri;
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
return resolveRefs(node, unresolvedSchema.schema, uri, referencedHandle.dependencies);
|
||||
});
|
||||
};
|
||||
const resolveRefs = async (node, parentSchema, parentSchemaURL, parentSchemaDependencies
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
) => {
|
||||
if (!node || typeof node !== 'object') {
|
||||
return null;
|
||||
}
|
||||
const toWalk = [node];
|
||||
const seen = new Set();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const openPromises = [];
|
||||
const collectEntries = (...entries) => {
|
||||
for (const entry of entries) {
|
||||
if (typeof entry === 'object') {
|
||||
toWalk.push(entry);
|
||||
}
|
||||
}
|
||||
};
|
||||
const collectMapEntries = (...maps) => {
|
||||
for (const map of maps) {
|
||||
if (typeof map === 'object') {
|
||||
for (const key in map) {
|
||||
const entry = map[key];
|
||||
if (typeof entry === 'object') {
|
||||
toWalk.push(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const collectArrayEntries = (...arrays) => {
|
||||
for (const array of arrays) {
|
||||
if (Array.isArray(array)) {
|
||||
for (const entry of array) {
|
||||
if (typeof entry === 'object') {
|
||||
toWalk.push(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const handleRef = (next) => {
|
||||
const seenRefs = new Set();
|
||||
while (next.$ref) {
|
||||
const ref = next.$ref;
|
||||
const segments = ref.split('#', 2);
|
||||
//return back removed $ref. We lost info about referenced type without it.
|
||||
next._$ref = next.$ref;
|
||||
delete next.$ref;
|
||||
if (segments[0].length > 0) {
|
||||
openPromises.push(resolveExternalLink(next, segments[0], segments[1], parentSchemaURL, parentSchemaDependencies));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (!seenRefs.has(ref)) {
|
||||
merge(next, parentSchema, parentSchemaURL, segments[1]); // can set next.$ref again, use seenRefs to avoid circle
|
||||
seenRefs.add(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
collectEntries(next.items, next.additionalItems, next.additionalProperties, next.not, next.contains, next.propertyNames, next.if, next.then, next.else);
|
||||
collectMapEntries(next.definitions, next.properties, next.patternProperties, next.dependencies);
|
||||
collectArrayEntries(next.anyOf, next.allOf, next.oneOf, next.items, next.schemaSequence);
|
||||
};
|
||||
if (parentSchemaURL.indexOf('#') > 0) {
|
||||
const segments = parentSchemaURL.split('#', 2);
|
||||
if (segments[0].length > 0 && segments[1].length > 0) {
|
||||
const newSchema = {};
|
||||
await resolveExternalLink(newSchema, segments[0], segments[1], parentSchemaURL, parentSchemaDependencies);
|
||||
for (const key in schema) {
|
||||
if (key === 'required') {
|
||||
continue;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(schema, key) && !Object.prototype.hasOwnProperty.call(newSchema, key)) {
|
||||
newSchema[key] = schema[key];
|
||||
}
|
||||
}
|
||||
schema = newSchema;
|
||||
}
|
||||
}
|
||||
while (toWalk.length) {
|
||||
const next = toWalk.pop();
|
||||
if (seen.has(next)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(next);
|
||||
handleRef(next);
|
||||
}
|
||||
return Promise.all(openPromises);
|
||||
};
|
||||
await resolveRefs(schema, schema, schemaURL, dependencies);
|
||||
return new jsonSchemaService_1.ResolvedSchema(schema, resolveErrors);
|
||||
}
|
||||
getSchemaForResource(resource, doc) {
|
||||
const resolveModelineSchema = () => {
|
||||
let schemaFromModeline = (0, modelineUtil_1.getSchemaFromModeline)(doc);
|
||||
if (schemaFromModeline !== undefined) {
|
||||
if (!schemaFromModeline.startsWith('file:') && !schemaFromModeline.startsWith('http')) {
|
||||
// If path contains a fragment and it is left intact, "#" will be
|
||||
// considered part of the filename and converted to "%23" by
|
||||
// path.resolve() -> take it out and add back after path.resolve
|
||||
let appendix = '';
|
||||
if (schemaFromModeline.indexOf('#') > 0) {
|
||||
const segments = schemaFromModeline.split('#', 2);
|
||||
schemaFromModeline = segments[0];
|
||||
appendix = segments[1];
|
||||
}
|
||||
if (!path.isAbsolute(schemaFromModeline)) {
|
||||
const resUri = vscode_uri_1.URI.parse(resource);
|
||||
schemaFromModeline = vscode_uri_1.URI.file(path.resolve(path.parse(resUri.fsPath).dir, schemaFromModeline)).toString();
|
||||
}
|
||||
else {
|
||||
schemaFromModeline = vscode_uri_1.URI.file(schemaFromModeline).toString();
|
||||
}
|
||||
if (appendix.length > 0) {
|
||||
schemaFromModeline += '#' + appendix;
|
||||
}
|
||||
}
|
||||
return schemaFromModeline;
|
||||
}
|
||||
};
|
||||
const resolveSchemaForResource = (schemas) => {
|
||||
const schemaHandle = super.createCombinedSchema(resource, schemas);
|
||||
return schemaHandle.getResolvedSchema().then((schema) => {
|
||||
if (schema.schema && typeof schema.schema === 'object') {
|
||||
schema.schema.url = schemaHandle.url;
|
||||
}
|
||||
if (schema.schema &&
|
||||
schema.schema.schemaSequence &&
|
||||
schema.schema.schemaSequence[doc.currentDocIndex]) {
|
||||
return new jsonSchemaService_1.ResolvedSchema(schema.schema.schemaSequence[doc.currentDocIndex]);
|
||||
}
|
||||
return schema;
|
||||
});
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const resolveSchema = () => {
|
||||
const seen = Object.create(null);
|
||||
const schemas = [];
|
||||
for (const entry of this.filePatternAssociations) {
|
||||
if (entry.matchesPattern(resource)) {
|
||||
for (const schemaId of entry.getURIs()) {
|
||||
if (!seen[schemaId]) {
|
||||
schemas.push(schemaId);
|
||||
seen[schemaId] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (schemas.length > 0) {
|
||||
// Join all schemas with the highest priority.
|
||||
const highestPrioSchemas = this.highestPrioritySchemas(schemas);
|
||||
return resolveSchemaForResource(highestPrioSchemas);
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
};
|
||||
const modelineSchema = resolveModelineSchema();
|
||||
if (modelineSchema) {
|
||||
return resolveSchemaForResource([modelineSchema]);
|
||||
}
|
||||
if (this.customSchemaProvider) {
|
||||
return this.customSchemaProvider(resource)
|
||||
.then((schemaUri) => {
|
||||
if (Array.isArray(schemaUri)) {
|
||||
if (schemaUri.length === 0) {
|
||||
return resolveSchema();
|
||||
}
|
||||
return Promise.all(schemaUri.map((schemaUri) => {
|
||||
return this.resolveCustomSchema(schemaUri, doc);
|
||||
})).then((schemas) => {
|
||||
return {
|
||||
errors: [],
|
||||
schema: {
|
||||
allOf: schemas.map((schemaObj) => {
|
||||
return schemaObj.schema;
|
||||
}),
|
||||
},
|
||||
};
|
||||
}, () => {
|
||||
return resolveSchema();
|
||||
});
|
||||
}
|
||||
if (!schemaUri) {
|
||||
return resolveSchema();
|
||||
}
|
||||
return this.resolveCustomSchema(schemaUri, doc);
|
||||
})
|
||||
.then((schema) => {
|
||||
return schema;
|
||||
}, () => {
|
||||
return resolveSchema();
|
||||
});
|
||||
}
|
||||
else {
|
||||
return resolveSchema();
|
||||
}
|
||||
}
|
||||
// Set the priority of a schema in the schema service
|
||||
addSchemaPriority(uri, priority) {
|
||||
let currSchemaArray = this.schemaPriorityMapping.get(uri);
|
||||
if (currSchemaArray) {
|
||||
currSchemaArray = currSchemaArray.add(priority);
|
||||
this.schemaPriorityMapping.set(uri, currSchemaArray);
|
||||
}
|
||||
else {
|
||||
this.schemaPriorityMapping.set(uri, new Set().add(priority));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Search through all the schemas and find the ones with the highest priority
|
||||
*/
|
||||
highestPrioritySchemas(schemas) {
|
||||
let highestPrio = 0;
|
||||
const priorityMapping = new Map();
|
||||
schemas.forEach((schema) => {
|
||||
// If the schema does not have a priority then give it a default one of [0]
|
||||
const priority = this.schemaPriorityMapping.get(schema) || [0];
|
||||
priority.forEach((prio) => {
|
||||
if (prio > highestPrio) {
|
||||
highestPrio = prio;
|
||||
}
|
||||
// Build up a mapping of priority to schemas so that we can easily get the highest priority schemas easier
|
||||
let currPriorityArray = priorityMapping.get(prio);
|
||||
if (currPriorityArray) {
|
||||
currPriorityArray = currPriorityArray.concat(schema);
|
||||
priorityMapping.set(prio, currPriorityArray);
|
||||
}
|
||||
else {
|
||||
priorityMapping.set(prio, [schema]);
|
||||
}
|
||||
});
|
||||
});
|
||||
return priorityMapping.get(highestPrio) || [];
|
||||
}
|
||||
async resolveCustomSchema(schemaUri, doc) {
|
||||
const unresolvedSchema = await this.loadSchema(schemaUri);
|
||||
const schema = await this.resolveSchemaContent(unresolvedSchema, schemaUri, []);
|
||||
if (schema.schema && typeof schema.schema === 'object') {
|
||||
schema.schema.url = schemaUri;
|
||||
}
|
||||
if (schema.schema && schema.schema.schemaSequence && schema.schema.schemaSequence[doc.currentDocIndex]) {
|
||||
return new jsonSchemaService_1.ResolvedSchema(schema.schema.schemaSequence[doc.currentDocIndex], schema.errors);
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
/**
|
||||
* Save a schema with schema ID and schema content.
|
||||
* Overrides previous schemas set for that schema ID.
|
||||
*/
|
||||
async saveSchema(schemaId, schemaContent) {
|
||||
const id = this.normalizeId(schemaId);
|
||||
this.getOrAddSchemaHandle(id, schemaContent);
|
||||
this.schemaPriorityMapping.set(id, new Set().add(yamlLanguageService_1.SchemaPriority.Settings));
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
/**
|
||||
* Delete schemas on specific path
|
||||
*/
|
||||
async deleteSchemas(deletions) {
|
||||
deletions.schemas.forEach((s) => {
|
||||
this.deleteSchema(s);
|
||||
});
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
/**
|
||||
* Delete a schema with schema ID.
|
||||
*/
|
||||
async deleteSchema(schemaId) {
|
||||
const id = this.normalizeId(schemaId);
|
||||
if (this.schemasById[id]) {
|
||||
delete this.schemasById[id];
|
||||
}
|
||||
this.schemaPriorityMapping.delete(id);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
/**
|
||||
* Add content to a specified schema at a specified path
|
||||
*/
|
||||
async addContent(additions) {
|
||||
const schema = await this.getResolvedSchema(additions.schema);
|
||||
if (schema) {
|
||||
const resolvedSchemaLocation = this.resolveJSONSchemaToSection(schema.schema, additions.path);
|
||||
if (typeof resolvedSchemaLocation === 'object') {
|
||||
resolvedSchemaLocation[additions.key] = additions.content;
|
||||
}
|
||||
await this.saveSchema(additions.schema, schema.schema);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Delete content in a specified schema at a specified path
|
||||
*/
|
||||
async deleteContent(deletions) {
|
||||
const schema = await this.getResolvedSchema(deletions.schema);
|
||||
if (schema) {
|
||||
const resolvedSchemaLocation = this.resolveJSONSchemaToSection(schema.schema, deletions.path);
|
||||
if (typeof resolvedSchemaLocation === 'object') {
|
||||
delete resolvedSchemaLocation[deletions.key];
|
||||
}
|
||||
await this.saveSchema(deletions.schema, schema.schema);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Take a JSON Schema and the path that you would like to get to
|
||||
* @returns the JSON Schema resolved at that specific path
|
||||
*/
|
||||
resolveJSONSchemaToSection(schema, paths) {
|
||||
const splitPathway = paths.split('/');
|
||||
let resolvedSchemaLocation = schema;
|
||||
for (const path of splitPathway) {
|
||||
if (path === '') {
|
||||
continue;
|
||||
}
|
||||
this.resolveNext(resolvedSchemaLocation, path);
|
||||
resolvedSchemaLocation = resolvedSchemaLocation[path];
|
||||
}
|
||||
return resolvedSchemaLocation;
|
||||
}
|
||||
/**
|
||||
* Resolve the next Object if they have compatible types
|
||||
* @param object a location in the JSON Schema
|
||||
* @param token the next token that you want to search for
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
resolveNext(object, token) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
if (Array.isArray(object) && isNaN(token)) {
|
||||
throw new Error('Expected a number after the array object');
|
||||
}
|
||||
else if (typeof object === 'object' && typeof token !== 'string') {
|
||||
throw new Error('Expected a string after the object');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Everything below here is needed because we're importing from vscode-json-languageservice umd and we need
|
||||
* to provide a wrapper around the javascript methods we are calling since they have no type
|
||||
*/
|
||||
normalizeId(id) {
|
||||
// The parent's `super.normalizeId(id)` isn't visible, so duplicated the code here
|
||||
try {
|
||||
return vscode_uri_1.URI.parse(id).toString();
|
||||
}
|
||||
catch (e) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Everything below here is needed because we're importing from vscode-json-languageservice umd and we need
|
||||
* to provide a wrapper around the javascript methods we are calling since they have no type
|
||||
*/
|
||||
getOrAddSchemaHandle(id, unresolvedSchemaContent) {
|
||||
return super.getOrAddSchemaHandle(id, unresolvedSchemaContent);
|
||||
}
|
||||
loadSchema(schemaUri) {
|
||||
const requestService = this.requestService;
|
||||
return super.loadSchema(schemaUri).then((unresolvedJsonSchema) => {
|
||||
// If json-language-server failed to parse the schema, attempt to parse it as YAML instead.
|
||||
if (unresolvedJsonSchema.errors && unresolvedJsonSchema.schema === undefined) {
|
||||
return requestService(schemaUri).then((content) => {
|
||||
if (!content) {
|
||||
const errorMessage = localize('json.schema.nocontent', "Unable to load schema from '{0}': No content. {1}", toDisplayString(schemaUri), unresolvedJsonSchema.errors);
|
||||
return new jsonSchemaService_1.UnresolvedSchema({}, [errorMessage]);
|
||||
}
|
||||
try {
|
||||
const schemaContent = (0, yaml_1.parse)(content);
|
||||
return new jsonSchemaService_1.UnresolvedSchema(schemaContent, []);
|
||||
}
|
||||
catch (yamlError) {
|
||||
const errorMessage = localize('json.schema.invalidFormat', "Unable to parse content from '{0}': {1}.", toDisplayString(schemaUri), yamlError);
|
||||
return new jsonSchemaService_1.UnresolvedSchema({}, [errorMessage]);
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(error) => {
|
||||
let errorMessage = error.toString();
|
||||
const errorSplit = error.toString().split('Error: ');
|
||||
if (errorSplit.length > 1) {
|
||||
// more concise error message, URL and context are attached by caller anyways
|
||||
errorMessage = errorSplit[1];
|
||||
}
|
||||
return new jsonSchemaService_1.UnresolvedSchema({}, [errorMessage]);
|
||||
});
|
||||
}
|
||||
unresolvedJsonSchema.uri = schemaUri;
|
||||
if (this.schemaUriToNameAndDescription.has(schemaUri)) {
|
||||
const { name, description, versions } = this.schemaUriToNameAndDescription.get(schemaUri);
|
||||
unresolvedJsonSchema.schema.title = name ?? unresolvedJsonSchema.schema.title;
|
||||
unresolvedJsonSchema.schema.description = description ?? unresolvedJsonSchema.schema.description;
|
||||
unresolvedJsonSchema.schema.versions = versions ?? unresolvedJsonSchema.schema.versions;
|
||||
}
|
||||
return unresolvedJsonSchema;
|
||||
});
|
||||
}
|
||||
registerExternalSchema(uri, filePatterns, unresolvedSchema, name, description, versions) {
|
||||
if (name || description) {
|
||||
this.schemaUriToNameAndDescription.set(uri, { name, description, versions });
|
||||
}
|
||||
return super.registerExternalSchema(uri, filePatterns, unresolvedSchema);
|
||||
}
|
||||
clearExternalSchemas() {
|
||||
super.clearExternalSchemas();
|
||||
}
|
||||
setSchemaContributions(schemaContributions) {
|
||||
super.setSchemaContributions(schemaContributions);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
getRegisteredSchemaIds(filter) {
|
||||
return super.getRegisteredSchemaIds(filter);
|
||||
}
|
||||
getResolvedSchema(schemaId) {
|
||||
return super.getResolvedSchema(schemaId);
|
||||
}
|
||||
onResourceChange(uri) {
|
||||
return super.onResourceChange(uri);
|
||||
}
|
||||
}
|
||||
exports.YAMLSchemaService = YAMLSchemaService;
|
||||
function toDisplayString(url) {
|
||||
try {
|
||||
const uri = vscode_uri_1.URI.parse(url);
|
||||
if (uri.scheme === 'file') {
|
||||
return uri.fsPath;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// ignore
|
||||
}
|
||||
return url;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlSchemaService.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSchemaService.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSelectionRanges.d.ts
generated
vendored
Normal file
3
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSelectionRanges.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Position, SelectionRange } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare function getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[];
|
||||
144
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSelectionRanges.js
generated
vendored
Normal file
144
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSelectionRanges.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../parser/yaml-documents"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getSelectionRanges = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
function getSelectionRanges(document, positions) {
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
return positions.map((position) => {
|
||||
const ranges = getRanges(position);
|
||||
let current;
|
||||
for (const range of ranges) {
|
||||
current = vscode_languageserver_types_1.SelectionRange.create(range, current);
|
||||
}
|
||||
return current ?? vscode_languageserver_types_1.SelectionRange.create({ start: position, end: position });
|
||||
});
|
||||
function getRanges(position) {
|
||||
const offset = document.offsetAt(position);
|
||||
const result = [];
|
||||
for (const ymlDoc of doc.documents) {
|
||||
let currentNode;
|
||||
let overrideStartOffset;
|
||||
ymlDoc.visit((node) => {
|
||||
const endOffset = node.offset + node.length;
|
||||
// Skip if end offset doesn't even reach cursor position
|
||||
if (endOffset < offset) {
|
||||
return true;
|
||||
}
|
||||
// Skip if we're ending at new line
|
||||
// times:
|
||||
// - second: 1
|
||||
// millisecond: 10
|
||||
// | - second: 2
|
||||
// ↑ millisecond: 0
|
||||
// (| is actually part of { second: 1, millisecond: 10 })
|
||||
// \r\n doesn't matter here
|
||||
if (getTextFromOffsets(endOffset - 1, endOffset) === '\n') {
|
||||
if (endOffset - 1 < offset) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
let startOffset = node.offset;
|
||||
if (startOffset > offset) {
|
||||
// Recheck start offset for some special cases
|
||||
const newOffset = getStartOffsetForSpecialCases(node, position);
|
||||
if (!newOffset || newOffset > offset) {
|
||||
return true;
|
||||
}
|
||||
startOffset = newOffset;
|
||||
}
|
||||
// Allow equal for children to override
|
||||
if (!currentNode || startOffset >= currentNode.offset) {
|
||||
currentNode = node;
|
||||
overrideStartOffset = startOffset;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
while (currentNode) {
|
||||
const startOffset = overrideStartOffset ?? currentNode.offset;
|
||||
const endOffset = currentNode.offset + currentNode.length;
|
||||
const range = {
|
||||
start: document.positionAt(startOffset),
|
||||
end: document.positionAt(endOffset),
|
||||
};
|
||||
const text = document.getText(range);
|
||||
const trimmedText = trimEndNewLine(text);
|
||||
const trimmedEndOffset = startOffset + trimmedText.length;
|
||||
if (trimmedEndOffset >= offset) {
|
||||
range.end = document.positionAt(trimmedEndOffset);
|
||||
}
|
||||
// Add a jump between '' "" {} []
|
||||
const isSurroundedBy = (startCharacter, endCharacter) => {
|
||||
return trimmedText.startsWith(startCharacter) && trimmedText.endsWith(endCharacter || startCharacter);
|
||||
};
|
||||
if ((currentNode.type === 'string' && (isSurroundedBy("'") || isSurroundedBy('"'))) ||
|
||||
(currentNode.type === 'object' && isSurroundedBy('{', '}')) ||
|
||||
(currentNode.type === 'array' && isSurroundedBy('[', ']'))) {
|
||||
result.push({
|
||||
start: document.positionAt(startOffset + 1),
|
||||
end: document.positionAt(endOffset - 1),
|
||||
});
|
||||
}
|
||||
result.push(range);
|
||||
currentNode = currentNode.parent;
|
||||
overrideStartOffset = undefined;
|
||||
}
|
||||
// A position can't be in multiple documents
|
||||
if (result.length > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.reverse();
|
||||
}
|
||||
function getStartOffsetForSpecialCases(node, position) {
|
||||
const nodeStartPosition = document.positionAt(node.offset);
|
||||
if (nodeStartPosition.line !== position.line) {
|
||||
return;
|
||||
}
|
||||
if (node.parent?.type === 'array') {
|
||||
// array:
|
||||
// - value
|
||||
// ↑
|
||||
if (getTextFromOffsets(node.offset - 2, node.offset) === '- ') {
|
||||
return node.offset - 2;
|
||||
}
|
||||
}
|
||||
if (node.type === 'array' || node.type === 'object') {
|
||||
// array:
|
||||
// - value
|
||||
// ↑
|
||||
const lineBeginning = { line: nodeStartPosition.line, character: 0 };
|
||||
const text = document.getText({ start: lineBeginning, end: nodeStartPosition });
|
||||
if (text.trim().length === 0) {
|
||||
return document.offsetAt(lineBeginning);
|
||||
}
|
||||
}
|
||||
}
|
||||
function getTextFromOffsets(startOffset, endOffset) {
|
||||
return document.getText({
|
||||
start: document.positionAt(startOffset),
|
||||
end: document.positionAt(endOffset),
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.getSelectionRanges = getSelectionRanges;
|
||||
function trimEndNewLine(str) {
|
||||
if (str.endsWith('\r\n')) {
|
||||
return str.substring(0, str.length - 2);
|
||||
}
|
||||
if (str.endsWith('\n')) {
|
||||
return str.substring(0, str.length - 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlSelectionRanges.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSelectionRanges.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlSelectionRanges.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlSelectionRanges.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlSelectionRanges.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,6EAA8E;IAC9E,6DAA8D;IAI9D,SAAgB,kBAAkB,CAAC,QAAsB,EAAE,SAAqB;QAC9E,MAAM,GAAG,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACzD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;YACnC,IAAI,OAAmC,CAAC;YACxC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,OAAO,GAAG,4CAAc,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;aACjD;YACD,OAAO,OAAO,IAAI,4CAAc,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9E,CAAC,CAAC,CAA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AC;gBAChF,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC5B,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;iBACzC;aACF;QACH,CAAC;QAED,SAAS,kBAAkB,CAAC,WAAmB,EAAE,SAAiB;YAChE,OAAO,QAAQ,CAAC,OAAO,CAAC;gBACtB,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC;gBACvC,GAAG,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;aACpC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IA9HD,gDA8HC;IAED,SAAS,cAAc,CAAC,GAAW;QACjC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACxB,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACzC;QACD,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACtB,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,CAAC;IACb,CAAC"}
|
||||
26
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlValidation.d.ts
generated
vendored
Normal file
26
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlValidation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { YAMLDocDiagnostic } from '../utils/parseUtils';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Telemetry } from '../telemetry';
|
||||
/**
|
||||
* Convert a YAMLDocDiagnostic to a language server Diagnostic
|
||||
* @param yamlDiag A YAMLDocDiagnostic from the parser
|
||||
* @param textDocument TextDocument from the language server client
|
||||
*/
|
||||
export declare const yamlDiagToLSDiag: (yamlDiag: YAMLDocDiagnostic, textDocument: TextDocument) => Diagnostic;
|
||||
export declare class YAMLValidation {
|
||||
private readonly telemetry?;
|
||||
private validationEnabled;
|
||||
private customTags;
|
||||
private jsonValidation;
|
||||
private disableAdditionalProperties;
|
||||
private yamlVersion;
|
||||
private validators;
|
||||
private MATCHES_MULTIPLE;
|
||||
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
|
||||
configure(settings: LanguageSettings): void;
|
||||
doValidation(textDocument: TextDocument, isKubernetes?: boolean): Promise<Diagnostic[]>;
|
||||
private runAdditionalValidators;
|
||||
}
|
||||
144
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlValidation.js
generated
vendored
Normal file
144
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlValidation.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "vscode-json-languageservice/lib/umd/services/jsonValidation", "../parser/jsonParser07", "../utils/textBuffer", "../parser/yaml-documents", "../utils/objects", "./validation/unused-anchors", "./validation/yaml-style", "./validation/map-key-order"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLValidation = exports.yamlDiagToLSDiag = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const jsonValidation_1 = require("vscode-json-languageservice/lib/umd/services/jsonValidation");
|
||||
const jsonParser07_1 = require("../parser/jsonParser07");
|
||||
const textBuffer_1 = require("../utils/textBuffer");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const objects_1 = require("../utils/objects");
|
||||
const unused_anchors_1 = require("./validation/unused-anchors");
|
||||
const yaml_style_1 = require("./validation/yaml-style");
|
||||
const map_key_order_1 = require("./validation/map-key-order");
|
||||
/**
|
||||
* Convert a YAMLDocDiagnostic to a language server Diagnostic
|
||||
* @param yamlDiag A YAMLDocDiagnostic from the parser
|
||||
* @param textDocument TextDocument from the language server client
|
||||
*/
|
||||
const yamlDiagToLSDiag = (yamlDiag, textDocument) => {
|
||||
const start = textDocument.positionAt(yamlDiag.location.start);
|
||||
const range = {
|
||||
start,
|
||||
end: yamlDiag.location.toLineEnd
|
||||
? vscode_languageserver_types_1.Position.create(start.line, new textBuffer_1.TextBuffer(textDocument).getLineLength(start.line))
|
||||
: textDocument.positionAt(yamlDiag.location.end),
|
||||
};
|
||||
return vscode_languageserver_types_1.Diagnostic.create(range, yamlDiag.message, yamlDiag.severity, yamlDiag.code, jsonParser07_1.YAML_SOURCE);
|
||||
};
|
||||
exports.yamlDiagToLSDiag = yamlDiagToLSDiag;
|
||||
class YAMLValidation {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
this.validators = [];
|
||||
this.MATCHES_MULTIPLE = 'Matches multiple schemas when only one must validate.';
|
||||
this.validationEnabled = true;
|
||||
this.jsonValidation = new jsonValidation_1.JSONValidation(schemaService, Promise);
|
||||
}
|
||||
configure(settings) {
|
||||
this.validators = [];
|
||||
if (settings) {
|
||||
this.validationEnabled = settings.validate;
|
||||
this.customTags = settings.customTags;
|
||||
this.disableAdditionalProperties = settings.disableAdditionalProperties;
|
||||
this.yamlVersion = settings.yamlVersion;
|
||||
// Add style validator if flow style is set to forbid only.
|
||||
if (settings.flowMapping === 'forbid' || settings.flowSequence === 'forbid') {
|
||||
this.validators.push(new yaml_style_1.YAMLStyleValidator(settings));
|
||||
}
|
||||
if (settings.keyOrdering) {
|
||||
this.validators.push(new map_key_order_1.MapKeyOrderValidator());
|
||||
}
|
||||
}
|
||||
this.validators.push(new unused_anchors_1.UnusedAnchorsValidator());
|
||||
}
|
||||
async doValidation(textDocument, isKubernetes = false) {
|
||||
if (!this.validationEnabled) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
const validationResult = [];
|
||||
try {
|
||||
const yamlDocument = yaml_documents_1.yamlDocumentsCache.getYamlDocument(textDocument, { customTags: this.customTags, yamlVersion: this.yamlVersion }, true);
|
||||
let index = 0;
|
||||
for (const currentYAMLDoc of yamlDocument.documents) {
|
||||
currentYAMLDoc.isKubernetes = isKubernetes;
|
||||
currentYAMLDoc.currentDocIndex = index;
|
||||
currentYAMLDoc.disableAdditionalProperties = this.disableAdditionalProperties;
|
||||
currentYAMLDoc.uri = textDocument.uri;
|
||||
const validation = await this.jsonValidation.doValidation(textDocument, currentYAMLDoc);
|
||||
const syd = currentYAMLDoc;
|
||||
if (syd.errors.length > 0) {
|
||||
// TODO: Get rid of these type assertions (shouldn't need them)
|
||||
validationResult.push(...syd.errors);
|
||||
}
|
||||
if (syd.warnings.length > 0) {
|
||||
validationResult.push(...syd.warnings);
|
||||
}
|
||||
validationResult.push(...validation);
|
||||
validationResult.push(...this.runAdditionalValidators(textDocument, currentYAMLDoc));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.validation.error', { error: (0, objects_1.convertErrorToTelemetryMsg)(err) });
|
||||
}
|
||||
let previousErr;
|
||||
const foundSignatures = new Set();
|
||||
const duplicateMessagesRemoved = [];
|
||||
for (let err of validationResult) {
|
||||
/**
|
||||
* A patch ontop of the validation that removes the
|
||||
* 'Matches many schemas' error for kubernetes
|
||||
* for a better user experience.
|
||||
*/
|
||||
if (isKubernetes && err.message === this.MATCHES_MULTIPLE) {
|
||||
continue;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(err, 'location')) {
|
||||
err = (0, exports.yamlDiagToLSDiag)(err, textDocument);
|
||||
}
|
||||
if (!err.source) {
|
||||
err.source = jsonParser07_1.YAML_SOURCE;
|
||||
}
|
||||
if (previousErr &&
|
||||
previousErr.message === err.message &&
|
||||
previousErr.range.end.line === err.range.start.line &&
|
||||
Math.abs(previousErr.range.end.character - err.range.end.character) >= 1) {
|
||||
previousErr.range.end = err.range.end;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
previousErr = err;
|
||||
}
|
||||
const errSig = err.range.start.line + ' ' + err.range.start.character + ' ' + err.message;
|
||||
if (!foundSignatures.has(errSig)) {
|
||||
duplicateMessagesRemoved.push(err);
|
||||
foundSignatures.add(errSig);
|
||||
}
|
||||
}
|
||||
return duplicateMessagesRemoved;
|
||||
}
|
||||
runAdditionalValidators(document, yarnDoc) {
|
||||
const result = [];
|
||||
for (const validator of this.validators) {
|
||||
result.push(...validator.validate(document, yarnDoc));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.YAMLValidation = YAMLValidation;
|
||||
});
|
||||
//# sourceMappingURL=yamlValidation.js.map
|
||||
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlValidation.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/umd/languageservice/services/yamlValidation.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlValidation.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlValidation.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;;;;;;;;;;;;;IAEhG,6EAAmE;IAMnE,gGAA6F;IAC7F,yDAAqD;IACrD,oDAAiD;IACjD,6DAA8D;IAC9D,8CAA8D;IAG9D,gEAAqE;IACrE,wDAA6D;IAC7D,8DAAkE;IAElE;;;;OAIG;IACI,MAAM,gBAAgB,GAAG,CAAC,QAA2B,EAAE,YAA0B,EAAc,EAAE;QACtG,MAAM,KAAK,GAAG,YAAY,CAAC,UAAU,CA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