This commit is contained in:
3
node_modules/yaml-language-server/lib/esm/commands.d.ts
generated
vendored
Normal file
3
node_modules/yaml-language-server/lib/esm/commands.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare enum YamlCommands {
|
||||
JUMP_TO_SCHEMA = "jumpToSchema"
|
||||
}
|
||||
9
node_modules/yaml-language-server/lib/esm/commands.js
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/esm/commands.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export var YamlCommands;
|
||||
(function (YamlCommands) {
|
||||
YamlCommands["JUMP_TO_SCHEMA"] = "jumpToSchema";
|
||||
})(YamlCommands || (YamlCommands = {}));
|
||||
//# sourceMappingURL=commands.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/commands.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/commands.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,MAAM,CAAN,IAAY,YAEX;AAFD,WAAY,YAAY;IACtB,+CAA+B,CAAA;AACjC,CAAC,EAFW,YAAY,KAAZ,YAAY,QAEvB"}
|
||||
3
node_modules/yaml-language-server/lib/esm/index.d.ts
generated
vendored
Normal file
3
node_modules/yaml-language-server/lib/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './languageservice/yamlLanguageService';
|
||||
export { getLanguageService as getJSONLanguageService } from 'vscode-json-languageservice';
|
||||
export * from 'vscode-languageserver-types';
|
||||
4
node_modules/yaml-language-server/lib/esm/index.js
generated
vendored
Normal file
4
node_modules/yaml-language-server/lib/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './languageservice/yamlLanguageService';
|
||||
export { getLanguageService as getJSONLanguageService } from 'vscode-json-languageservice';
|
||||
export * from 'vscode-languageserver-types';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/index.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC3F,cAAc,6BAA6B,CAAC"}
|
||||
10
node_modules/yaml-language-server/lib/esm/languageserver/commandExecutor.d.ts
generated
vendored
Normal file
10
node_modules/yaml-language-server/lib/esm/languageserver/commandExecutor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ExecuteCommandParams } from 'vscode-languageserver-protocol';
|
||||
export interface CommandHandler {
|
||||
(...args: unknown[]): void;
|
||||
}
|
||||
export declare class CommandExecutor {
|
||||
private commands;
|
||||
executeCommand(params: ExecuteCommandParams): void;
|
||||
registerCommand(commandId: string, handler: CommandHandler): void;
|
||||
}
|
||||
export declare const commandExecutor: CommandExecutor;
|
||||
21
node_modules/yaml-language-server/lib/esm/languageserver/commandExecutor.js
generated
vendored
Normal file
21
node_modules/yaml-language-server/lib/esm/languageserver/commandExecutor.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export class CommandExecutor {
|
||||
constructor() {
|
||||
this.commands = new Map();
|
||||
}
|
||||
executeCommand(params) {
|
||||
if (this.commands.has(params.command)) {
|
||||
const handler = this.commands.get(params.command);
|
||||
return handler(...params.arguments);
|
||||
}
|
||||
throw new Error(`Command '${params.command}' not found`);
|
||||
}
|
||||
registerCommand(commandId, handler) {
|
||||
this.commands.set(commandId, handler);
|
||||
}
|
||||
}
|
||||
export const commandExecutor = new CommandExecutor();
|
||||
//# sourceMappingURL=commandExecutor.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/commandExecutor.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/commandExecutor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"commandExecutor.js","sourceRoot":"","sources":["../../../src/languageserver/commandExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAQhG,MAAM,OAAO,eAAe;IAA5B;QACU,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAYvD,CAAC;IAXC,cAAc,CAAC,MAA4B;QACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClD,OAAO,OAAO,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;SACrC;QACD,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;IAC3D,CAAC;IAED,eAAe,CAAC,SAAiB,EAAE,OAAuB;QACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
||||
58
node_modules/yaml-language-server/lib/esm/languageserver/handlers/languageHandlers.d.ts
generated
vendored
Normal file
58
node_modules/yaml-language-server/lib/esm/languageserver/handlers/languageHandlers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/// <reference types="node" />
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { CodeActionParams, DidChangeWatchedFilesParams, DocumentFormattingParams, DocumentLinkParams, DocumentOnTypeFormattingParams, DocumentSymbolParams, FoldingRangeParams, SelectionRangeParams, TextDocumentPositionParams, CodeLensParams, DefinitionParams } from 'vscode-languageserver-protocol';
|
||||
import { CodeAction, CodeLens, CompletionList, DefinitionLink, DocumentLink, DocumentSymbol, Hover, FoldingRange, SelectionRange, SymbolInformation, TextEdit } from 'vscode-languageserver-types';
|
||||
import { LanguageService } from '../../languageservice/yamlLanguageService';
|
||||
import { SettingsState } from '../../yamlSettings';
|
||||
import { ValidationHandler } from './validationHandlers';
|
||||
export declare class LanguageHandlers {
|
||||
private readonly connection;
|
||||
private languageService;
|
||||
private yamlSettings;
|
||||
private validationHandler;
|
||||
pendingLimitExceededWarnings: {
|
||||
[uri: string]: {
|
||||
features: {
|
||||
[name: string]: string;
|
||||
};
|
||||
timeout?: NodeJS.Timeout;
|
||||
};
|
||||
};
|
||||
constructor(connection: Connection, languageService: LanguageService, yamlSettings: SettingsState, validationHandler: ValidationHandler);
|
||||
registerHandlers(): void;
|
||||
documentLinkHandler(params: DocumentLinkParams): Promise<DocumentLink[]>;
|
||||
/**
|
||||
* Called when the code outline in an editor needs to be populated
|
||||
* Returns a list of symbols that is then shown in the code outline
|
||||
*/
|
||||
documentSymbolHandler(documentSymbolParams: DocumentSymbolParams): DocumentSymbol[] | SymbolInformation[];
|
||||
/**
|
||||
* Called when the formatter is invoked
|
||||
* Returns the formatted document content using prettier
|
||||
*/
|
||||
formatterHandler(formatParams: DocumentFormattingParams): TextEdit[];
|
||||
formatOnTypeHandler(params: DocumentOnTypeFormattingParams): Promise<TextEdit[] | undefined> | TextEdit[] | undefined;
|
||||
/**
|
||||
* Called when the user hovers with their mouse over a keyword
|
||||
* Returns an informational tooltip
|
||||
*/
|
||||
hoverHandler(textDocumentPositionParams: TextDocumentPositionParams): Promise<Hover>;
|
||||
/**
|
||||
* Called when auto-complete is triggered in an editor
|
||||
* Returns a list of valid completion items
|
||||
*/
|
||||
completionHandler(textDocumentPosition: TextDocumentPositionParams): Promise<CompletionList>;
|
||||
/**
|
||||
* Called when a monitored file is changed in an editor
|
||||
* Re-validates the entire document
|
||||
*/
|
||||
watchedFilesHandler(change: DidChangeWatchedFilesParams): void;
|
||||
foldingRangeHandler(params: FoldingRangeParams): Promise<FoldingRange[] | undefined> | FoldingRange[] | undefined;
|
||||
selectionRangeHandler(params: SelectionRangeParams): SelectionRange[] | undefined;
|
||||
codeActionHandler(params: CodeActionParams): CodeAction[] | undefined;
|
||||
codeLensHandler(params: CodeLensParams): PromiseLike<CodeLens[] | undefined> | CodeLens[] | undefined;
|
||||
codeLensResolveHandler(param: CodeLens): PromiseLike<CodeLens> | CodeLens;
|
||||
definitionHandler(params: DefinitionParams): DefinitionLink[];
|
||||
private cancelLimitExceededWarnings;
|
||||
private onResultLimitExceeded;
|
||||
}
|
||||
198
node_modules/yaml-language-server/lib/esm/languageserver/handlers/languageHandlers.js
generated
vendored
Normal file
198
node_modules/yaml-language-server/lib/esm/languageserver/handlers/languageHandlers.js
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
|
||||
import { ResultLimitReachedNotification } from '../../requestTypes';
|
||||
import * as path from 'path';
|
||||
export class LanguageHandlers {
|
||||
constructor(connection, languageService, yamlSettings, validationHandler) {
|
||||
this.connection = connection;
|
||||
this.languageService = languageService;
|
||||
this.yamlSettings = yamlSettings;
|
||||
this.validationHandler = validationHandler;
|
||||
this.pendingLimitExceededWarnings = {};
|
||||
}
|
||||
registerHandlers() {
|
||||
this.connection.onDocumentLinks((params) => this.documentLinkHandler(params));
|
||||
this.connection.onDocumentSymbol((documentSymbolParams) => this.documentSymbolHandler(documentSymbolParams));
|
||||
this.connection.onDocumentFormatting((formatParams) => this.formatterHandler(formatParams));
|
||||
this.connection.onHover((textDocumentPositionParams) => this.hoverHandler(textDocumentPositionParams));
|
||||
this.connection.onCompletion((textDocumentPosition) => this.completionHandler(textDocumentPosition));
|
||||
this.connection.onDidChangeWatchedFiles((change) => this.watchedFilesHandler(change));
|
||||
this.connection.onFoldingRanges((params) => this.foldingRangeHandler(params));
|
||||
this.connection.onSelectionRanges((params) => this.selectionRangeHandler(params));
|
||||
this.connection.onCodeAction((params) => this.codeActionHandler(params));
|
||||
this.connection.onDocumentOnTypeFormatting((params) => this.formatOnTypeHandler(params));
|
||||
this.connection.onCodeLens((params) => this.codeLensHandler(params));
|
||||
this.connection.onCodeLensResolve((params) => this.codeLensResolveHandler(params));
|
||||
this.connection.onDefinition((params) => this.definitionHandler(params));
|
||||
this.yamlSettings.documents.onDidChangeContent((change) => this.cancelLimitExceededWarnings(change.document.uri));
|
||||
this.yamlSettings.documents.onDidClose((event) => this.cancelLimitExceededWarnings(event.document.uri));
|
||||
}
|
||||
documentLinkHandler(params) {
|
||||
const document = this.yamlSettings.documents.get(params.textDocument.uri);
|
||||
if (!document) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return this.languageService.findLinks(document);
|
||||
}
|
||||
/**
|
||||
* Called when the code outline in an editor needs to be populated
|
||||
* Returns a list of symbols that is then shown in the code outline
|
||||
*/
|
||||
documentSymbolHandler(documentSymbolParams) {
|
||||
const document = this.yamlSettings.documents.get(documentSymbolParams.textDocument.uri);
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
const onResultLimitExceeded = this.onResultLimitExceeded(document.uri, this.yamlSettings.maxItemsComputed, 'document symbols');
|
||||
const context = { resultLimit: this.yamlSettings.maxItemsComputed, onResultLimitExceeded };
|
||||
if (this.yamlSettings.hierarchicalDocumentSymbolSupport) {
|
||||
return this.languageService.findDocumentSymbols2(document, context);
|
||||
}
|
||||
else {
|
||||
return this.languageService.findDocumentSymbols(document, context);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called when the formatter is invoked
|
||||
* Returns the formatted document content using prettier
|
||||
*/
|
||||
formatterHandler(formatParams) {
|
||||
const document = this.yamlSettings.documents.get(formatParams.textDocument.uri);
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
const customFormatterSettings = {
|
||||
tabWidth: formatParams.options.tabSize,
|
||||
...this.yamlSettings.yamlFormatterSettings,
|
||||
};
|
||||
return this.languageService.doFormat(document, customFormatterSettings);
|
||||
}
|
||||
formatOnTypeHandler(params) {
|
||||
const document = this.yamlSettings.documents.get(params.textDocument.uri);
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
return this.languageService.doDocumentOnTypeFormatting(document, params);
|
||||
}
|
||||
/**
|
||||
* Called when the user hovers with their mouse over a keyword
|
||||
* Returns an informational tooltip
|
||||
*/
|
||||
hoverHandler(textDocumentPositionParams) {
|
||||
const document = this.yamlSettings.documents.get(textDocumentPositionParams.textDocument.uri);
|
||||
if (!document) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
return this.languageService.doHover(document, textDocumentPositionParams.position);
|
||||
}
|
||||
/**
|
||||
* Called when auto-complete is triggered in an editor
|
||||
* Returns a list of valid completion items
|
||||
*/
|
||||
completionHandler(textDocumentPosition) {
|
||||
const textDocument = this.yamlSettings.documents.get(textDocumentPosition.textDocument.uri);
|
||||
const result = {
|
||||
items: [],
|
||||
isIncomplete: false,
|
||||
};
|
||||
if (!textDocument) {
|
||||
return Promise.resolve(result);
|
||||
}
|
||||
return this.languageService.doComplete(textDocument, textDocumentPosition.position, isKubernetesAssociatedDocument(textDocument, this.yamlSettings.specificValidatorPaths));
|
||||
}
|
||||
/**
|
||||
* Called when a monitored file is changed in an editor
|
||||
* Re-validates the entire document
|
||||
*/
|
||||
watchedFilesHandler(change) {
|
||||
let hasChanges = false;
|
||||
change.changes.forEach((c) => {
|
||||
if (this.languageService.resetSchema(c.uri)) {
|
||||
hasChanges = true;
|
||||
}
|
||||
});
|
||||
if (hasChanges) {
|
||||
this.yamlSettings.documents.all().forEach((document) => this.validationHandler.validate(document));
|
||||
}
|
||||
}
|
||||
foldingRangeHandler(params) {
|
||||
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
|
||||
if (!textDocument) {
|
||||
return;
|
||||
}
|
||||
const capabilities = this.yamlSettings.capabilities.textDocument.foldingRange;
|
||||
const rangeLimit = this.yamlSettings.maxItemsComputed || capabilities.rangeLimit;
|
||||
const onRangeLimitExceeded = this.onResultLimitExceeded(textDocument.uri, rangeLimit, 'folding ranges');
|
||||
const context = {
|
||||
rangeLimit,
|
||||
onRangeLimitExceeded,
|
||||
lineFoldingOnly: capabilities.lineFoldingOnly,
|
||||
};
|
||||
return this.languageService.getFoldingRanges(textDocument, context);
|
||||
}
|
||||
selectionRangeHandler(params) {
|
||||
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
|
||||
if (!textDocument) {
|
||||
return;
|
||||
}
|
||||
return this.languageService.getSelectionRanges(textDocument, params.positions);
|
||||
}
|
||||
codeActionHandler(params) {
|
||||
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
|
||||
if (!textDocument) {
|
||||
return;
|
||||
}
|
||||
return this.languageService.getCodeAction(textDocument, params);
|
||||
}
|
||||
codeLensHandler(params) {
|
||||
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
|
||||
if (!textDocument) {
|
||||
return;
|
||||
}
|
||||
return this.languageService.getCodeLens(textDocument);
|
||||
}
|
||||
codeLensResolveHandler(param) {
|
||||
return this.languageService.resolveCodeLens(param);
|
||||
}
|
||||
definitionHandler(params) {
|
||||
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
|
||||
if (!textDocument) {
|
||||
return;
|
||||
}
|
||||
return this.languageService.doDefinition(textDocument, params);
|
||||
}
|
||||
// Adapted from:
|
||||
// https://github.com/microsoft/vscode/blob/94c9ea46838a9a619aeafb7e8afd1170c967bb55/extensions/json-language-features/server/src/jsonServer.ts#L172
|
||||
cancelLimitExceededWarnings(uri) {
|
||||
const warning = this.pendingLimitExceededWarnings[uri];
|
||||
if (warning && warning.timeout) {
|
||||
clearTimeout(warning.timeout);
|
||||
delete this.pendingLimitExceededWarnings[uri];
|
||||
}
|
||||
}
|
||||
onResultLimitExceeded(uri, resultLimit, name) {
|
||||
return () => {
|
||||
let warning = this.pendingLimitExceededWarnings[uri];
|
||||
if (warning) {
|
||||
if (!warning.timeout) {
|
||||
// already shown
|
||||
return;
|
||||
}
|
||||
warning.features[name] = name;
|
||||
warning.timeout.refresh();
|
||||
}
|
||||
else {
|
||||
warning = { features: { [name]: name } };
|
||||
warning.timeout = setTimeout(() => {
|
||||
this.connection.sendNotification(ResultLimitReachedNotification.type, `${path.basename(uri)}: For performance reasons, ${Object.keys(warning.features).join(' and ')} have been limited to ${resultLimit} items.`);
|
||||
warning.timeout = undefined;
|
||||
}, 2000);
|
||||
this.pendingLimitExceededWarnings[uri] = warning;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=languageHandlers.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/languageHandlers.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/languageHandlers.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/yaml-language-server/lib/esm/languageserver/handlers/notificationHandlers.d.ts
generated
vendored
Normal file
29
node_modules/yaml-language-server/lib/esm/languageserver/handlers/notificationHandlers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { LanguageService } from '../../languageservice/yamlLanguageService';
|
||||
import { SettingsState } from '../../yamlSettings';
|
||||
import { SettingsHandler } from './settingsHandlers';
|
||||
export declare class NotificationHandlers {
|
||||
private readonly connection;
|
||||
private languageService;
|
||||
private yamlSettings;
|
||||
private settingsHandler;
|
||||
constructor(connection: Connection, languageService: LanguageService, yamlSettings: SettingsState, settingsHandler: SettingsHandler);
|
||||
registerHandlers(): void;
|
||||
/**
|
||||
* Received a notification from the client with schema associations from other extensions
|
||||
* Update the associations in the server
|
||||
*/
|
||||
private schemaAssociationNotificationHandler;
|
||||
/**
|
||||
* Received a notification from the client that it can accept custom schema requests
|
||||
* Register the custom schema provider and use it for requests of unknown scheme
|
||||
*/
|
||||
private dynamicSchemaRequestHandler;
|
||||
/**
|
||||
* Received a notification from the client that it can accept content requests
|
||||
* This means that the server sends schemas back to the client side to get resolved rather
|
||||
* than resolving them on the extension side
|
||||
*/
|
||||
private vscodeContentRequestHandler;
|
||||
private schemaSelectionRequestHandler;
|
||||
}
|
||||
46
node_modules/yaml-language-server/lib/esm/languageserver/handlers/notificationHandlers.js
generated
vendored
Normal file
46
node_modules/yaml-language-server/lib/esm/languageserver/handlers/notificationHandlers.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { CustomSchemaRequest, DynamicCustomSchemaRequestRegistration, SchemaAssociationNotification, SchemaSelectionRequests, VSCodeContentRequestRegistration, } from '../../requestTypes';
|
||||
export class NotificationHandlers {
|
||||
constructor(connection, languageService, yamlSettings, settingsHandler) {
|
||||
this.connection = connection;
|
||||
this.languageService = languageService;
|
||||
this.yamlSettings = yamlSettings;
|
||||
this.settingsHandler = settingsHandler;
|
||||
}
|
||||
registerHandlers() {
|
||||
this.connection.onNotification(SchemaAssociationNotification.type, (associations) => this.schemaAssociationNotificationHandler(associations));
|
||||
this.connection.onNotification(DynamicCustomSchemaRequestRegistration.type, () => this.dynamicSchemaRequestHandler());
|
||||
this.connection.onNotification(VSCodeContentRequestRegistration.type, () => this.vscodeContentRequestHandler());
|
||||
this.connection.onNotification(SchemaSelectionRequests.type, () => this.schemaSelectionRequestHandler());
|
||||
}
|
||||
/**
|
||||
* Received a notification from the client with schema associations from other extensions
|
||||
* Update the associations in the server
|
||||
*/
|
||||
schemaAssociationNotificationHandler(associations) {
|
||||
this.yamlSettings.schemaAssociations = associations;
|
||||
this.yamlSettings.specificValidatorPaths = [];
|
||||
this.settingsHandler.pullConfiguration().catch((error) => console.log(error));
|
||||
}
|
||||
/**
|
||||
* Received a notification from the client that it can accept custom schema requests
|
||||
* Register the custom schema provider and use it for requests of unknown scheme
|
||||
*/
|
||||
dynamicSchemaRequestHandler() {
|
||||
const schemaProvider = ((resource) => {
|
||||
return this.connection.sendRequest(CustomSchemaRequest.type, resource);
|
||||
});
|
||||
this.languageService.registerCustomSchemaProvider(schemaProvider);
|
||||
}
|
||||
/**
|
||||
* Received a notification from the client that it can accept content requests
|
||||
* This means that the server sends schemas back to the client side to get resolved rather
|
||||
* than resolving them on the extension side
|
||||
*/
|
||||
vscodeContentRequestHandler() {
|
||||
this.yamlSettings.useVSCodeContentRequest = true;
|
||||
}
|
||||
schemaSelectionRequestHandler() {
|
||||
this.yamlSettings.useSchemaSelectionRequests = true;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=notificationHandlers.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/notificationHandlers.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/notificationHandlers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"notificationHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/notificationHandlers.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACtC,6BAA6B,EAC7B,uBAAuB,EACvB,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAI5B,MAAM,OAAO,oBAAoB;IAK/B,YACmB,UAAsB,EACvC,eAAgC,EAChC,YAA2B,EAC3B,eAAgC;QAHf,eAAU,GAAV,UAAU,CAAY;QAKvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IA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O,6BAA6B;QACnC,IAAI,CAAC,YAAY,CAAC,0BAA0B,GAAG,IAAI,CAAC;IACtD,CAAC;CACF"}
|
||||
9
node_modules/yaml-language-server/lib/esm/languageserver/handlers/requestHandlers.d.ts
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/esm/languageserver/handlers/requestHandlers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { LanguageService } from '../../languageservice/yamlLanguageService';
|
||||
export declare class RequestHandlers {
|
||||
private readonly connection;
|
||||
private languageService;
|
||||
constructor(connection: Connection, languageService: LanguageService);
|
||||
registerHandlers(): void;
|
||||
private registerSchemaModificationNotificationHandler;
|
||||
}
|
||||
23
node_modules/yaml-language-server/lib/esm/languageserver/handlers/requestHandlers.js
generated
vendored
Normal file
23
node_modules/yaml-language-server/lib/esm/languageserver/handlers/requestHandlers.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { MODIFICATION_ACTIONS, } from '../../languageservice/services/yamlSchemaService';
|
||||
import { SchemaModificationNotification } from '../../requestTypes';
|
||||
export class RequestHandlers {
|
||||
constructor(connection, languageService) {
|
||||
this.connection = connection;
|
||||
this.languageService = languageService;
|
||||
}
|
||||
registerHandlers() {
|
||||
this.connection.onRequest(SchemaModificationNotification.type, (modifications) => this.registerSchemaModificationNotificationHandler(modifications));
|
||||
}
|
||||
registerSchemaModificationNotificationHandler(modifications) {
|
||||
if (modifications.action === MODIFICATION_ACTIONS.add) {
|
||||
this.languageService.modifySchemaContent(modifications);
|
||||
}
|
||||
else if (modifications.action === MODIFICATION_ACTIONS.delete) {
|
||||
this.languageService.deleteSchemaContent(modifications);
|
||||
}
|
||||
else if (modifications.action === MODIFICATION_ACTIONS.deleteAll) {
|
||||
this.languageService.deleteSchemasWhole(modifications);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=requestHandlers.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/requestHandlers.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/requestHandlers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/requestHandlers.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,oBAAoB,GAIrB,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,OAAO,eAAe;IAE1B,YAA6B,UAAsB,EAAE,eAAgC;QAAxD,eAAU,GAAV,UAAU,CAAY;QACjD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAEM,gBAAgB;QACrB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,8BAA8B,CAAC,IAAI,EAAE,CAAC,aAAa,EAAE,EAAE,CAC/E,IAAI,CAAC,6CAA6C,CAAC,aAAa,CAAC,CAClE,CAAC;IACJ,CAAC;IAEO,6CAA6C,CACnD,aAAqE;QAErE,IAAI,aAAa,CAAC,MAAM,KAAK,oBAAoB,CAAC,GAAG,EAAE;YACrD,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;SACzD;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,oBAAoB,CAAC,MAAM,EAAE;YAC/D,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;SACzD;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,oBAAoB,CAAC,SAAS,EAAE;YAClE,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;SACxD;IACH,CAAC;CACF"}
|
||||
13
node_modules/yaml-language-server/lib/esm/languageserver/handlers/schemaSelectionHandlers.d.ts
generated
vendored
Normal file
13
node_modules/yaml-language-server/lib/esm/languageserver/handlers/schemaSelectionHandlers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Connection } from 'vscode-languageserver/node';
|
||||
import { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService';
|
||||
import { SettingsState } from '../../yamlSettings';
|
||||
import { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes';
|
||||
export declare class JSONSchemaSelection {
|
||||
private readonly schemaService;
|
||||
private readonly yamlSettings?;
|
||||
private readonly connection?;
|
||||
constructor(schemaService: YAMLSchemaService, yamlSettings?: SettingsState, connection?: Connection);
|
||||
getSchemas(docUri: string): Promise<JSONSchemaDescription[]>;
|
||||
private getSchemasForFile;
|
||||
getAllSchemas(docUri: string): Promise<JSONSchemaDescriptionExt[]>;
|
||||
}
|
||||
72
node_modules/yaml-language-server/lib/esm/languageserver/handlers/schemaSelectionHandlers.js
generated
vendored
Normal file
72
node_modules/yaml-language-server/lib/esm/languageserver/handlers/schemaSelectionHandlers.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents';
|
||||
import { getSchemaUrls } from '../../languageservice/utils/schemaUrls';
|
||||
import { SchemaSelectionRequests } from '../../requestTypes';
|
||||
export class JSONSchemaSelection {
|
||||
constructor(schemaService, yamlSettings, connection) {
|
||||
this.schemaService = schemaService;
|
||||
this.yamlSettings = yamlSettings;
|
||||
this.connection = connection;
|
||||
this.connection?.onRequest(SchemaSelectionRequests.getSchema, (fileUri) => {
|
||||
return this.getSchemas(fileUri);
|
||||
});
|
||||
this.connection?.onRequest(SchemaSelectionRequests.getAllSchemas, (fileUri) => {
|
||||
return this.getAllSchemas(fileUri);
|
||||
});
|
||||
}
|
||||
async getSchemas(docUri) {
|
||||
const schemas = await this.getSchemasForFile(docUri);
|
||||
return Array.from(schemas).map((val) => {
|
||||
return {
|
||||
name: val[1].title,
|
||||
uri: val[0],
|
||||
description: val[1].description,
|
||||
versions: val[1].versions,
|
||||
};
|
||||
});
|
||||
}
|
||||
async getSchemasForFile(docUri) {
|
||||
const document = this.yamlSettings?.documents.get(docUri);
|
||||
const schemas = new Map();
|
||||
if (!document) {
|
||||
return schemas;
|
||||
}
|
||||
const yamlDoc = yamlDocumentsCache.getYamlDocument(document);
|
||||
for (const currentYAMLDoc of yamlDoc.documents) {
|
||||
const schema = await this.schemaService.getSchemaForResource(document.uri, currentYAMLDoc);
|
||||
if (schema?.schema) {
|
||||
const schemaUrls = getSchemaUrls(schema?.schema);
|
||||
if (schemaUrls.size === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const urlToSchema of schemaUrls) {
|
||||
schemas.set(urlToSchema[0], urlToSchema[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return schemas;
|
||||
}
|
||||
async getAllSchemas(docUri) {
|
||||
const fileSchemas = await this.getSchemasForFile(docUri);
|
||||
const fileSchemasHandle = Array.from(fileSchemas.entries()).map((val) => {
|
||||
return {
|
||||
uri: val[0],
|
||||
fromStore: false,
|
||||
usedForCurrentFile: true,
|
||||
name: val[1].title,
|
||||
description: val[1].description,
|
||||
versions: val[1].versions,
|
||||
};
|
||||
});
|
||||
const result = [];
|
||||
let allSchemas = this.schemaService.getAllSchemas();
|
||||
allSchemas = allSchemas.filter((val) => !fileSchemas.has(val.uri));
|
||||
result.push(...fileSchemasHandle);
|
||||
result.push(...allSchemas);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=schemaSelectionHandlers.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/schemaSelectionHandlers.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/schemaSelectionHandlers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schemaSelectionHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/schemaSelect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AG,CAAC,CAAC,CAAC,CAAC,WAAW;gBAC/B,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;aAC1B,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;QACpD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAE3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
||||
42
node_modules/yaml-language-server/lib/esm/languageserver/handlers/settingsHandlers.d.ts
generated
vendored
Normal file
42
node_modules/yaml-language-server/lib/esm/languageserver/handlers/settingsHandlers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { LanguageService } from '../../languageservice/yamlLanguageService';
|
||||
import { SettingsState } from '../../yamlSettings';
|
||||
import { Telemetry } from '../../languageservice/telemetry';
|
||||
import { ValidationHandler } from './validationHandlers';
|
||||
export declare class SettingsHandler {
|
||||
private readonly connection;
|
||||
private readonly languageService;
|
||||
private readonly yamlSettings;
|
||||
private readonly validationHandler;
|
||||
private readonly telemetry;
|
||||
constructor(connection: Connection, languageService: LanguageService, yamlSettings: SettingsState, validationHandler: ValidationHandler, telemetry: Telemetry);
|
||||
registerHandlers(): Promise<void>;
|
||||
/**
|
||||
* The server pull the 'yaml', 'http.proxy', 'http.proxyStrictSSL', '[yaml]' settings sections
|
||||
*/
|
||||
pullConfiguration(): Promise<void>;
|
||||
private setConfiguration;
|
||||
/**
|
||||
* This function helps set the schema store if it hasn't already been set
|
||||
* AND the schema store setting is enabled. If the schema store setting
|
||||
* is not enabled we need to clear the schemas.
|
||||
*/
|
||||
private setSchemaStoreSettingsIfNotSet;
|
||||
/**
|
||||
* When the schema store is enabled, download and store YAML schema associations
|
||||
*/
|
||||
private getSchemaStoreMatchingSchemas;
|
||||
/**
|
||||
* Called when server settings or schema associations are changed
|
||||
* Re-creates schema associations and re-validates any open YAML files
|
||||
*/
|
||||
private updateConfiguration;
|
||||
/**
|
||||
* Stores schema associations in server settings, handling kubernetes
|
||||
* @param uri string path to schema (whether local or online)
|
||||
* @param fileMatch file pattern to apply the schema to
|
||||
* @param schema schema id
|
||||
* @param languageSettings current server settings
|
||||
*/
|
||||
private configureSchemas;
|
||||
}
|
||||
299
node_modules/yaml-language-server/lib/esm/languageserver/handlers/settingsHandlers.js
generated
vendored
Normal file
299
node_modules/yaml-language-server/lib/esm/languageserver/handlers/settingsHandlers.js
generated
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { configure as configureHttpRequests, xhr } from 'request-light';
|
||||
import { DidChangeConfigurationNotification, DocumentFormattingRequest } from 'vscode-languageserver';
|
||||
import { convertErrorToTelemetryMsg } from '../../languageservice/utils/objects';
|
||||
import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths';
|
||||
import { checkSchemaURI, JSON_SCHEMASTORE_URL, KUBERNETES_SCHEMA_URL } from '../../languageservice/utils/schemaUrls';
|
||||
import { SchemaPriority } from '../../languageservice/yamlLanguageService';
|
||||
import { SchemaSelectionRequests } from '../../requestTypes';
|
||||
export class SettingsHandler {
|
||||
constructor(connection, languageService, yamlSettings, validationHandler, telemetry) {
|
||||
this.connection = connection;
|
||||
this.languageService = languageService;
|
||||
this.yamlSettings = yamlSettings;
|
||||
this.validationHandler = validationHandler;
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
async registerHandlers() {
|
||||
if (this.yamlSettings.hasConfigurationCapability && this.yamlSettings.clientDynamicRegisterSupport) {
|
||||
try {
|
||||
// Register for all configuration changes.
|
||||
await this.connection.client.register(DidChangeConfigurationNotification.type);
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry.sendError('yaml.settings.error', { error: convertErrorToTelemetryMsg(err) });
|
||||
}
|
||||
}
|
||||
this.connection.onDidChangeConfiguration(() => this.pullConfiguration());
|
||||
}
|
||||
/**
|
||||
* The server pull the 'yaml', 'http.proxy', 'http.proxyStrictSSL', '[yaml]' settings sections
|
||||
*/
|
||||
async pullConfiguration() {
|
||||
const config = await this.connection.workspace.getConfiguration([
|
||||
{ section: 'yaml' },
|
||||
{ section: 'http' },
|
||||
{ section: '[yaml]' },
|
||||
{ section: 'editor' },
|
||||
{ section: 'files' },
|
||||
]);
|
||||
const settings = {
|
||||
yaml: config[0],
|
||||
http: {
|
||||
proxy: config[1]?.proxy ?? '',
|
||||
proxyStrictSSL: config[1]?.proxyStrictSSL ?? false,
|
||||
},
|
||||
yamlEditor: config[2],
|
||||
vscodeEditor: config[3],
|
||||
files: config[4],
|
||||
};
|
||||
await this.setConfiguration(settings);
|
||||
}
|
||||
async setConfiguration(settings) {
|
||||
configureHttpRequests(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
||||
this.yamlSettings.specificValidatorPaths = [];
|
||||
if (settings.yaml) {
|
||||
if (Object.prototype.hasOwnProperty.call(settings.yaml, 'schemas')) {
|
||||
this.yamlSettings.yamlConfigurationSettings = settings.yaml.schemas;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(settings.yaml, 'validate')) {
|
||||
this.yamlSettings.yamlShouldValidate = settings.yaml.validate;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(settings.yaml, 'hover')) {
|
||||
this.yamlSettings.yamlShouldHover = settings.yaml.hover;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(settings.yaml, 'completion')) {
|
||||
this.yamlSettings.yamlShouldCompletion = settings.yaml.completion;
|
||||
}
|
||||
this.yamlSettings.customTags = settings.yaml.customTags ? settings.yaml.customTags : [];
|
||||
this.yamlSettings.maxItemsComputed = Math.trunc(Math.max(0, Number(settings.yaml.maxItemsComputed))) || 5000;
|
||||
if (settings.yaml.schemaStore) {
|
||||
this.yamlSettings.schemaStoreEnabled = settings.yaml.schemaStore.enable;
|
||||
if (settings.yaml.schemaStore.url?.length !== 0) {
|
||||
this.yamlSettings.schemaStoreUrl = settings.yaml.schemaStore.url;
|
||||
}
|
||||
}
|
||||
if (settings.files?.associations) {
|
||||
for (const [ext, languageId] of Object.entries(settings.files.associations)) {
|
||||
if (languageId === 'yaml') {
|
||||
this.yamlSettings.fileExtensions.push(ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.yamlSettings.yamlVersion = settings.yaml.yamlVersion ?? '1.2';
|
||||
if (settings.yaml.format) {
|
||||
this.yamlSettings.yamlFormatterSettings = {
|
||||
proseWrap: settings.yaml.format.proseWrap || 'preserve',
|
||||
printWidth: settings.yaml.format.printWidth || 80,
|
||||
};
|
||||
if (settings.yaml.format.singleQuote !== undefined) {
|
||||
this.yamlSettings.yamlFormatterSettings.singleQuote = settings.yaml.format.singleQuote;
|
||||
}
|
||||
if (settings.yaml.format.bracketSpacing !== undefined) {
|
||||
this.yamlSettings.yamlFormatterSettings.bracketSpacing = settings.yaml.format.bracketSpacing;
|
||||
}
|
||||
if (settings.yaml.format.enable !== undefined) {
|
||||
this.yamlSettings.yamlFormatterSettings.enable = settings.yaml.format.enable;
|
||||
}
|
||||
}
|
||||
this.yamlSettings.disableAdditionalProperties = settings.yaml.disableAdditionalProperties;
|
||||
this.yamlSettings.disableDefaultProperties = settings.yaml.disableDefaultProperties;
|
||||
if (settings.yaml.suggest) {
|
||||
this.yamlSettings.suggest.parentSkeletonSelectedFirst = settings.yaml.suggest.parentSkeletonSelectedFirst;
|
||||
}
|
||||
this.yamlSettings.style = {
|
||||
flowMapping: settings.yaml.style?.flowMapping ?? 'allow',
|
||||
flowSequence: settings.yaml.style?.flowSequence ?? 'allow',
|
||||
};
|
||||
this.yamlSettings.keyOrdering = settings.yaml.keyOrdering ?? false;
|
||||
}
|
||||
this.yamlSettings.schemaConfigurationSettings = [];
|
||||
let tabSize = 2;
|
||||
if (settings.vscodeEditor) {
|
||||
tabSize =
|
||||
!settings.vscodeEditor['detectIndentation'] && settings.yamlEditor ? settings.yamlEditor['editor.tabSize'] : tabSize;
|
||||
}
|
||||
if (settings.yamlEditor && settings.yamlEditor['editor.tabSize']) {
|
||||
this.yamlSettings.indentation = ' '.repeat(tabSize);
|
||||
}
|
||||
for (const uri in this.yamlSettings.yamlConfigurationSettings) {
|
||||
const globPattern = this.yamlSettings.yamlConfigurationSettings[uri];
|
||||
const schemaObj = {
|
||||
fileMatch: Array.isArray(globPattern) ? globPattern : [globPattern],
|
||||
uri: checkSchemaURI(this.yamlSettings.workspaceFolders, this.yamlSettings.workspaceRoot, uri, this.telemetry),
|
||||
};
|
||||
this.yamlSettings.schemaConfigurationSettings.push(schemaObj);
|
||||
}
|
||||
await this.setSchemaStoreSettingsIfNotSet();
|
||||
this.updateConfiguration();
|
||||
if (this.yamlSettings.useSchemaSelectionRequests) {
|
||||
this.connection.sendNotification(SchemaSelectionRequests.schemaStoreInitialized, {});
|
||||
}
|
||||
// dynamically enable & disable the formatter
|
||||
if (this.yamlSettings.clientDynamicRegisterSupport) {
|
||||
const enableFormatter = settings && settings.yaml && settings.yaml.format && settings.yaml.format.enable;
|
||||
if (enableFormatter) {
|
||||
if (!this.yamlSettings.formatterRegistration) {
|
||||
this.yamlSettings.formatterRegistration = this.connection.client.register(DocumentFormattingRequest.type, {
|
||||
documentSelector: [{ language: 'yaml' }],
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (this.yamlSettings.formatterRegistration) {
|
||||
this.yamlSettings.formatterRegistration.then((r) => {
|
||||
return r.dispose();
|
||||
});
|
||||
this.yamlSettings.formatterRegistration = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This function helps set the schema store if it hasn't already been set
|
||||
* AND the schema store setting is enabled. If the schema store setting
|
||||
* is not enabled we need to clear the schemas.
|
||||
*/
|
||||
async setSchemaStoreSettingsIfNotSet() {
|
||||
const schemaStoreIsSet = this.yamlSettings.schemaStoreSettings.length !== 0;
|
||||
let schemaStoreUrl = '';
|
||||
if (this.yamlSettings.schemaStoreUrl?.length !== 0) {
|
||||
schemaStoreUrl = this.yamlSettings.schemaStoreUrl;
|
||||
}
|
||||
else {
|
||||
schemaStoreUrl = JSON_SCHEMASTORE_URL;
|
||||
}
|
||||
if (this.yamlSettings.schemaStoreEnabled && !schemaStoreIsSet) {
|
||||
try {
|
||||
const schemaStore = await this.getSchemaStoreMatchingSchemas(schemaStoreUrl);
|
||||
this.yamlSettings.schemaStoreSettings = schemaStore.schemas;
|
||||
}
|
||||
catch (err) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
else if (!this.yamlSettings.schemaStoreEnabled) {
|
||||
this.yamlSettings.schemaStoreSettings = [];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* When the schema store is enabled, download and store YAML schema associations
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async getSchemaStoreMatchingSchemas(schemaStoreUrl) {
|
||||
const response = await xhr({ url: schemaStoreUrl });
|
||||
const languageSettings = {
|
||||
schemas: [],
|
||||
};
|
||||
// Parse the schema store catalog as JSON
|
||||
const schemas = JSON.parse(response.responseText);
|
||||
for (const schemaIndex in schemas.schemas) {
|
||||
const schema = schemas.schemas[schemaIndex];
|
||||
if (schema && schema.fileMatch) {
|
||||
for (const fileMatch in schema.fileMatch) {
|
||||
const currFileMatch = schema.fileMatch[fileMatch];
|
||||
// If the schema is for files with a YAML extension, save the schema association
|
||||
if (this.yamlSettings.fileExtensions.findIndex((value) => {
|
||||
return currFileMatch.indexOf(value) > -1;
|
||||
}) > -1) {
|
||||
languageSettings.schemas.push({
|
||||
uri: schema.url,
|
||||
fileMatch: [currFileMatch],
|
||||
priority: SchemaPriority.SchemaStore,
|
||||
name: schema.name,
|
||||
description: schema.description,
|
||||
versions: schema.versions,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return languageSettings;
|
||||
}
|
||||
/**
|
||||
* Called when server settings or schema associations are changed
|
||||
* Re-creates schema associations and re-validates any open YAML files
|
||||
*/
|
||||
updateConfiguration() {
|
||||
let languageSettings = {
|
||||
validate: this.yamlSettings.yamlShouldValidate,
|
||||
hover: this.yamlSettings.yamlShouldHover,
|
||||
completion: this.yamlSettings.yamlShouldCompletion,
|
||||
schemas: [],
|
||||
customTags: this.yamlSettings.customTags,
|
||||
format: this.yamlSettings.yamlFormatterSettings.enable,
|
||||
indentation: this.yamlSettings.indentation,
|
||||
disableAdditionalProperties: this.yamlSettings.disableAdditionalProperties,
|
||||
disableDefaultProperties: this.yamlSettings.disableDefaultProperties,
|
||||
parentSkeletonSelectedFirst: this.yamlSettings.suggest.parentSkeletonSelectedFirst,
|
||||
flowMapping: this.yamlSettings.style?.flowMapping,
|
||||
flowSequence: this.yamlSettings.style?.flowSequence,
|
||||
yamlVersion: this.yamlSettings.yamlVersion,
|
||||
keyOrdering: this.yamlSettings.keyOrdering,
|
||||
};
|
||||
if (this.yamlSettings.schemaAssociations) {
|
||||
if (Array.isArray(this.yamlSettings.schemaAssociations)) {
|
||||
this.yamlSettings.schemaAssociations.forEach((association) => {
|
||||
languageSettings = this.configureSchemas(association.uri, association.fileMatch, association.schema, languageSettings, SchemaPriority.SchemaAssociation);
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (const uri in this.yamlSettings.schemaAssociations) {
|
||||
const fileMatch = this.yamlSettings.schemaAssociations[uri];
|
||||
languageSettings = this.configureSchemas(uri, fileMatch, null, languageSettings, SchemaPriority.SchemaAssociation);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.yamlSettings.schemaConfigurationSettings) {
|
||||
this.yamlSettings.schemaConfigurationSettings.forEach((schema) => {
|
||||
let uri = schema.uri;
|
||||
if (!uri && schema.schema) {
|
||||
uri = schema.schema.id;
|
||||
}
|
||||
if (!uri && schema.fileMatch) {
|
||||
uri = 'vscode://schemas/custom/' + encodeURIComponent(schema.fileMatch.join('&'));
|
||||
}
|
||||
if (uri) {
|
||||
if (isRelativePath(uri)) {
|
||||
uri = relativeToAbsolutePath(this.yamlSettings.workspaceFolders, this.yamlSettings.workspaceRoot, uri);
|
||||
}
|
||||
languageSettings = this.configureSchemas(uri, schema.fileMatch, schema.schema, languageSettings, SchemaPriority.Settings);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.yamlSettings.schemaStoreSettings) {
|
||||
languageSettings.schemas = languageSettings.schemas.concat(this.yamlSettings.schemaStoreSettings);
|
||||
}
|
||||
this.languageService.configure(languageSettings);
|
||||
// Revalidate any open text documents
|
||||
this.yamlSettings.documents.all().forEach((document) => this.validationHandler.validate(document));
|
||||
}
|
||||
/**
|
||||
* Stores schema associations in server settings, handling kubernetes
|
||||
* @param uri string path to schema (whether local or online)
|
||||
* @param fileMatch file pattern to apply the schema to
|
||||
* @param schema schema id
|
||||
* @param languageSettings current server settings
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
configureSchemas(uri, fileMatch, schema, languageSettings, priorityLevel) {
|
||||
uri = checkSchemaURI(this.yamlSettings.workspaceFolders, this.yamlSettings.workspaceRoot, uri, this.telemetry);
|
||||
if (schema === null) {
|
||||
languageSettings.schemas.push({ uri, fileMatch: fileMatch, priority: priorityLevel });
|
||||
}
|
||||
else {
|
||||
languageSettings.schemas.push({ uri, fileMatch: fileMatch, schema: schema, priority: priorityLevel });
|
||||
}
|
||||
if (fileMatch.constructor === Array && uri === KUBERNETES_SCHEMA_URL) {
|
||||
fileMatch.forEach((url) => {
|
||||
this.yamlSettings.specificValidatorPaths.push(url);
|
||||
});
|
||||
}
|
||||
else if (uri === KUBERNETES_SCHEMA_URL) {
|
||||
this.yamlSettings.specificValidatorPaths.push(fileMatch);
|
||||
}
|
||||
return languageSettings;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=settingsHandlers.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/settingsHandlers.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/settingsHandlers.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
node_modules/yaml-language-server/lib/esm/languageserver/handlers/validationHandlers.d.ts
generated
vendored
Normal file
14
node_modules/yaml-language-server/lib/esm/languageserver/handlers/validationHandlers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { LanguageService } from '../../languageservice/yamlLanguageService';
|
||||
import { SettingsState } from '../../yamlSettings';
|
||||
export declare class ValidationHandler {
|
||||
private readonly connection;
|
||||
private languageService;
|
||||
private yamlSettings;
|
||||
constructor(connection: Connection, languageService: LanguageService, yamlSettings: SettingsState);
|
||||
validate(textDocument: TextDocument): void;
|
||||
private cleanPendingValidation;
|
||||
validateTextDocument(textDocument: TextDocument): Promise<Diagnostic[]>;
|
||||
}
|
||||
54
node_modules/yaml-language-server/lib/esm/languageserver/handlers/validationHandlers.js
generated
vendored
Normal file
54
node_modules/yaml-language-server/lib/esm/languageserver/handlers/validationHandlers.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
|
||||
import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils';
|
||||
export class ValidationHandler {
|
||||
constructor(connection, languageService, yamlSettings) {
|
||||
this.connection = connection;
|
||||
this.languageService = languageService;
|
||||
this.yamlSettings = yamlSettings;
|
||||
this.yamlSettings.documents.onDidChangeContent((change) => {
|
||||
this.validate(change.document);
|
||||
});
|
||||
this.yamlSettings.documents.onDidClose((event) => {
|
||||
this.cleanPendingValidation(event.document);
|
||||
this.connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
|
||||
});
|
||||
}
|
||||
validate(textDocument) {
|
||||
this.cleanPendingValidation(textDocument);
|
||||
this.yamlSettings.pendingValidationRequests[textDocument.uri] = setTimeout(() => {
|
||||
delete this.yamlSettings.pendingValidationRequests[textDocument.uri];
|
||||
this.validateTextDocument(textDocument);
|
||||
}, this.yamlSettings.validationDelayMs);
|
||||
}
|
||||
cleanPendingValidation(textDocument) {
|
||||
const request = this.yamlSettings.pendingValidationRequests[textDocument.uri];
|
||||
if (request) {
|
||||
clearTimeout(request);
|
||||
delete this.yamlSettings.pendingValidationRequests[textDocument.uri];
|
||||
}
|
||||
}
|
||||
validateTextDocument(textDocument) {
|
||||
if (!textDocument) {
|
||||
return;
|
||||
}
|
||||
return this.languageService
|
||||
.doValidation(textDocument, isKubernetesAssociatedDocument(textDocument, this.yamlSettings.specificValidatorPaths))
|
||||
.then((diagnosticResults) => {
|
||||
const diagnostics = [];
|
||||
for (const diagnosticItem of diagnosticResults) {
|
||||
// Convert all warnings to errors
|
||||
if (diagnosticItem.severity === 2) {
|
||||
diagnosticItem.severity = 1;
|
||||
}
|
||||
diagnostics.push(diagnosticItem);
|
||||
}
|
||||
const removeDuplicatesDiagnostics = removeDuplicatesObj(diagnostics);
|
||||
this.connection.sendDiagnostics({
|
||||
uri: textDocument.uri,
|
||||
diagnostics: removeDuplicatesDiagnostics,
|
||||
});
|
||||
return removeDuplicatesDiagnostics;
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=validationHandlers.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/validationHandlers.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/validationHandlers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"validationHandlers.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BAAsB,CAAC,YAA0B;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAE9E,IAAI,OAAO,EAAE;YACX,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;SACtE;IACH,CAAC;IAED,oBAAoB,CAAC,YAA0B;QAC7C,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QAED,OAAO,IAAI,CAAC,eAAe;aACxB,YAAY,CAAC,YAAY,EAAE,8BAA8B,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;aAClH,IAAI,CAAC,CAAC,iBAAiB,EAAE,EAAE;YAC1B,MAAM,WAAW,GAAiB,EAAE,CAAC;YACrC,KAAK,MAAM,cAAc,IAAI,iBAAiB,EAAE;gBAC9C,iCAAiC;gBACjC,IAAI,cAAc,CAAC,QAAQ,KAAK,CAAC,EAAE;oBACjC,cAAc,CAAC,QAAQ,GAAG,CAAC,CAAC;iBAC7B;gBACD,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aAClC;YAED,MAAM,2BAA2B,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;YACrE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;gBAC9B,GAAG,EAAE,YAAY,CAAC,GAAG;gBACrB,WAAW,EAAE,2BAA2B;aACzC,CAAC,CAAC;YACH,OAAO,2BAA2B,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC;CACF"}
|
||||
9
node_modules/yaml-language-server/lib/esm/languageserver/handlers/workspaceHandlers.d.ts
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/esm/languageserver/handlers/workspaceHandlers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { CommandExecutor } from '../commandExecutor';
|
||||
export declare class WorkspaceHandlers {
|
||||
private readonly connection;
|
||||
private readonly commandExecutor;
|
||||
constructor(connection: Connection, commandExecutor: CommandExecutor);
|
||||
registerHandlers(): void;
|
||||
private executeCommand;
|
||||
}
|
||||
17
node_modules/yaml-language-server/lib/esm/languageserver/handlers/workspaceHandlers.js
generated
vendored
Normal file
17
node_modules/yaml-language-server/lib/esm/languageserver/handlers/workspaceHandlers.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export class WorkspaceHandlers {
|
||||
constructor(connection, commandExecutor) {
|
||||
this.connection = connection;
|
||||
this.commandExecutor = commandExecutor;
|
||||
}
|
||||
registerHandlers() {
|
||||
this.connection.onExecuteCommand((params) => this.executeCommand(params));
|
||||
}
|
||||
executeCommand(params) {
|
||||
return this.commandExecutor.executeCommand(params);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=workspaceHandlers.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/workspaceHandlers.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/handlers/workspaceHandlers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"workspaceHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/workspaceHandlers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAKhG,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,UAAsB,EAAmB,eAAgC;QAAzE,eAAU,GAAV,UAAU,CAAY;QAAmB,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAE1G,gBAAgB;QACd,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,cAAc,CAAC,MAA4B;QACjD,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;CACF"}
|
||||
9
node_modules/yaml-language-server/lib/esm/languageserver/telemetry.d.ts
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/esm/languageserver/telemetry.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { TelemetryEvent, Telemetry } from '../languageservice/telemetry';
|
||||
export declare class TelemetryImpl implements Telemetry {
|
||||
private readonly connection;
|
||||
constructor(connection: Connection);
|
||||
send(event: TelemetryEvent): void;
|
||||
sendError(name: string, properties: unknown): void;
|
||||
sendTrack(name: string, properties: unknown): void;
|
||||
}
|
||||
19
node_modules/yaml-language-server/lib/esm/languageserver/telemetry.js
generated
vendored
Normal file
19
node_modules/yaml-language-server/lib/esm/languageserver/telemetry.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export class TelemetryImpl {
|
||||
constructor(connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
send(event) {
|
||||
this.connection.telemetry.logEvent(event);
|
||||
}
|
||||
sendError(name, properties) {
|
||||
this.send({ name, type: 'track', properties: properties });
|
||||
}
|
||||
sendTrack(name, properties) {
|
||||
this.send({ name, type: 'track', properties: properties });
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=telemetry.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageserver/telemetry.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageserver/telemetry.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../src/languageserver/telemetry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAKhG,MAAM,OAAO,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,IAAI,CAAC,KAAqB;QACxB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,UAAmB;QACzC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,UAAmB;QACzC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
||||
48
node_modules/yaml-language-server/lib/esm/languageservice/jsonASTTypes.d.ts
generated
vendored
Normal file
48
node_modules/yaml-language-server/lib/esm/languageservice/jsonASTTypes.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Node, Pair } from 'yaml';
|
||||
export declare type YamlNode = Node | Pair;
|
||||
export declare type ASTNode = ObjectASTNode | PropertyASTNode | ArrayASTNode | StringASTNode | NumberASTNode | BooleanASTNode | NullASTNode;
|
||||
export interface BaseASTNode {
|
||||
readonly type: 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null';
|
||||
readonly parent?: ASTNode;
|
||||
readonly offset: number;
|
||||
readonly length: number;
|
||||
readonly children?: ASTNode[];
|
||||
readonly value?: string | boolean | number | null;
|
||||
readonly internalNode: YamlNode;
|
||||
location: string;
|
||||
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
|
||||
}
|
||||
export interface ObjectASTNode extends BaseASTNode {
|
||||
readonly type: 'object';
|
||||
readonly properties: PropertyASTNode[];
|
||||
readonly children: ASTNode[];
|
||||
}
|
||||
export interface PropertyASTNode extends BaseASTNode {
|
||||
readonly type: 'property';
|
||||
readonly keyNode: StringASTNode;
|
||||
readonly valueNode?: ASTNode;
|
||||
readonly colonOffset?: number;
|
||||
readonly children: ASTNode[];
|
||||
}
|
||||
export interface ArrayASTNode extends BaseASTNode {
|
||||
readonly type: 'array';
|
||||
readonly items: ASTNode[];
|
||||
readonly children: ASTNode[];
|
||||
}
|
||||
export interface StringASTNode extends BaseASTNode {
|
||||
readonly type: 'string';
|
||||
readonly value: string;
|
||||
}
|
||||
export interface NumberASTNode extends BaseASTNode {
|
||||
readonly type: 'number';
|
||||
readonly value: number;
|
||||
readonly isInteger: boolean;
|
||||
}
|
||||
export interface BooleanASTNode extends BaseASTNode {
|
||||
readonly type: 'boolean';
|
||||
readonly value: boolean;
|
||||
}
|
||||
export interface NullASTNode extends BaseASTNode {
|
||||
readonly type: 'null';
|
||||
readonly value: null;
|
||||
}
|
||||
6
node_modules/yaml-language-server/lib/esm/languageservice/jsonASTTypes.js
generated
vendored
Normal file
6
node_modules/yaml-language-server/lib/esm/languageservice/jsonASTTypes.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export {};
|
||||
//# sourceMappingURL=jsonASTTypes.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/jsonASTTypes.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/jsonASTTypes.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jsonASTTypes.js","sourceRoot":"","sources":["../../../src/languageservice/jsonASTTypes.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}
|
||||
79
node_modules/yaml-language-server/lib/esm/languageservice/jsonSchema.d.ts
generated
vendored
Normal file
79
node_modules/yaml-language-server/lib/esm/languageservice/jsonSchema.d.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import { CompletionItemKind } from 'vscode-json-languageservice';
|
||||
import { SchemaVersions } from './yamlTypes';
|
||||
export declare type JSONSchemaRef = JSONSchema | boolean;
|
||||
export interface JSONSchema {
|
||||
id?: string;
|
||||
$id?: string;
|
||||
$schema?: string;
|
||||
url?: string;
|
||||
type?: string | string[];
|
||||
title?: string;
|
||||
closestTitle?: string;
|
||||
versions?: SchemaVersions;
|
||||
default?: any;
|
||||
definitions?: {
|
||||
[name: string]: JSONSchema;
|
||||
};
|
||||
description?: string;
|
||||
properties?: JSONSchemaMap;
|
||||
patternProperties?: JSONSchemaMap;
|
||||
additionalProperties?: boolean | JSONSchemaRef;
|
||||
minProperties?: number;
|
||||
maxProperties?: number;
|
||||
dependencies?: JSONSchemaMap | {
|
||||
[prop: string]: string[];
|
||||
};
|
||||
items?: JSONSchemaRef | JSONSchemaRef[];
|
||||
minItems?: number;
|
||||
maxItems?: number;
|
||||
uniqueItems?: boolean;
|
||||
additionalItems?: boolean | JSONSchemaRef;
|
||||
pattern?: string;
|
||||
minLength?: number;
|
||||
maxLength?: number;
|
||||
minimum?: number;
|
||||
maximum?: number;
|
||||
exclusiveMinimum?: boolean | number;
|
||||
exclusiveMaximum?: boolean | number;
|
||||
multipleOf?: number;
|
||||
required?: string[];
|
||||
$ref?: string;
|
||||
_$ref?: string;
|
||||
anyOf?: JSONSchemaRef[];
|
||||
allOf?: JSONSchemaRef[];
|
||||
oneOf?: JSONSchemaRef[];
|
||||
not?: JSONSchemaRef;
|
||||
enum?: any[];
|
||||
format?: string;
|
||||
const?: any;
|
||||
contains?: JSONSchemaRef;
|
||||
propertyNames?: JSONSchemaRef;
|
||||
examples?: any[];
|
||||
$comment?: string;
|
||||
if?: JSONSchemaRef;
|
||||
then?: JSONSchemaRef;
|
||||
else?: JSONSchemaRef;
|
||||
defaultSnippets?: {
|
||||
label?: string;
|
||||
description?: string;
|
||||
markdownDescription?: string;
|
||||
type?: string;
|
||||
suggestionKind?: CompletionItemKind;
|
||||
sortText?: string;
|
||||
body?: any;
|
||||
bodyText?: string;
|
||||
}[];
|
||||
errorMessage?: string;
|
||||
patternErrorMessage?: string;
|
||||
deprecationMessage?: string;
|
||||
enumDescriptions?: string[];
|
||||
markdownEnumDescriptions?: string[];
|
||||
markdownDescription?: string;
|
||||
doNotSuggest?: boolean;
|
||||
allowComments?: boolean;
|
||||
schemaSequence?: JSONSchema[];
|
||||
filePatternAssociation?: string;
|
||||
}
|
||||
export interface JSONSchemaMap {
|
||||
[name: string]: JSONSchemaRef;
|
||||
}
|
||||
6
node_modules/yaml-language-server/lib/esm/languageservice/jsonSchema.js
generated
vendored
Normal file
6
node_modules/yaml-language-server/lib/esm/languageservice/jsonSchema.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export {};
|
||||
//# sourceMappingURL=jsonSchema.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/jsonSchema.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/jsonSchema.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jsonSchema.js","sourceRoot":"","sources":["../../../src/languageservice/jsonSchema.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}
|
||||
6
node_modules/yaml-language-server/lib/esm/languageservice/parser/ast-converter.d.ts
generated
vendored
Normal file
6
node_modules/yaml-language-server/lib/esm/languageservice/parser/ast-converter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Document, LineCounter } from 'yaml';
|
||||
import { ASTNode, YamlNode } from '../jsonASTTypes';
|
||||
declare type NodeRange = [number, number, number];
|
||||
export declare function convertAST(parent: ASTNode, node: YamlNode, doc: Document, lineCounter: LineCounter): ASTNode | undefined;
|
||||
export declare function toOffsetLength(range: NodeRange): [number, number];
|
||||
export {};
|
||||
168
node_modules/yaml-language-server/lib/esm/languageservice/parser/ast-converter.js
generated
vendored
Normal file
168
node_modules/yaml-language-server/lib/esm/languageservice/parser/ast-converter.js
generated
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { isScalar, isMap, isPair, isSeq, isNode, isAlias, } from 'yaml';
|
||||
import { NullASTNodeImpl, PropertyASTNodeImpl, StringASTNodeImpl, ObjectASTNodeImpl, NumberASTNodeImpl, ArrayASTNodeImpl, BooleanASTNodeImpl, } from './jsonParser07';
|
||||
const maxRefCount = 1000;
|
||||
let refDepth = 0;
|
||||
const seenAlias = new Set();
|
||||
export function convertAST(parent, node, doc, lineCounter) {
|
||||
if (!parent) {
|
||||
// first invocation
|
||||
refDepth = 0;
|
||||
}
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
if (isMap(node)) {
|
||||
return convertMap(node, parent, doc, lineCounter);
|
||||
}
|
||||
if (isPair(node)) {
|
||||
return convertPair(node, parent, doc, lineCounter);
|
||||
}
|
||||
if (isSeq(node)) {
|
||||
return convertSeq(node, parent, doc, lineCounter);
|
||||
}
|
||||
if (isScalar(node)) {
|
||||
return convertScalar(node, parent);
|
||||
}
|
||||
if (isAlias(node) && !seenAlias.has(node) && refDepth < maxRefCount) {
|
||||
seenAlias.add(node);
|
||||
const converted = convertAlias(node, parent, doc, lineCounter);
|
||||
seenAlias.delete(node);
|
||||
return converted;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
function convertMap(node, parent, doc, lineCounter) {
|
||||
let range;
|
||||
if (node.flow && !node.range) {
|
||||
range = collectFlowMapRange(node);
|
||||
}
|
||||
else {
|
||||
range = node.range;
|
||||
}
|
||||
const result = new ObjectASTNodeImpl(parent, node, ...toFixedOffsetLength(range, lineCounter));
|
||||
for (const it of node.items) {
|
||||
if (isPair(it)) {
|
||||
result.properties.push(convertAST(result, it, doc, lineCounter));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function convertPair(node, parent, doc, lineCounter) {
|
||||
const keyNode = node.key;
|
||||
const valueNode = node.value;
|
||||
const rangeStart = keyNode.range[0];
|
||||
let rangeEnd = keyNode.range[1];
|
||||
let nodeEnd = keyNode.range[2];
|
||||
if (valueNode) {
|
||||
rangeEnd = valueNode.range[1];
|
||||
nodeEnd = valueNode.range[2];
|
||||
}
|
||||
// Pair does not return a range using the key/value ranges to fake one.
|
||||
const result = new PropertyASTNodeImpl(parent, node, ...toFixedOffsetLength([rangeStart, rangeEnd, nodeEnd], lineCounter));
|
||||
if (isAlias(keyNode)) {
|
||||
const keyAlias = new StringASTNodeImpl(parent, keyNode, ...toOffsetLength(keyNode.range));
|
||||
keyAlias.value = keyNode.source;
|
||||
result.keyNode = keyAlias;
|
||||
}
|
||||
else {
|
||||
result.keyNode = convertAST(result, keyNode, doc, lineCounter);
|
||||
}
|
||||
result.valueNode = convertAST(result, valueNode, doc, lineCounter);
|
||||
return result;
|
||||
}
|
||||
function convertSeq(node, parent, doc, lineCounter) {
|
||||
const result = new ArrayASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
for (const it of node.items) {
|
||||
if (isNode(it)) {
|
||||
const convertedNode = convertAST(result, it, doc, lineCounter);
|
||||
// due to recursion protection, convertAST may return undefined
|
||||
if (convertedNode) {
|
||||
result.children.push(convertedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function convertScalar(node, parent) {
|
||||
if (node.value === null) {
|
||||
return new NullASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
}
|
||||
switch (typeof node.value) {
|
||||
case 'string': {
|
||||
const result = new StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
result.value = node.value;
|
||||
return result;
|
||||
}
|
||||
case 'boolean':
|
||||
return new BooleanASTNodeImpl(parent, node, node.value, ...toOffsetLength(node.range));
|
||||
case 'number': {
|
||||
const result = new NumberASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
result.value = node.value;
|
||||
result.isInteger = Number.isInteger(result.value);
|
||||
return result;
|
||||
}
|
||||
default: {
|
||||
// fail safe converting, we need to return some node anyway
|
||||
const result = new StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
result.value = node.source;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
function convertAlias(node, parent, doc, lineCounter) {
|
||||
refDepth++;
|
||||
const resolvedNode = node.resolve(doc);
|
||||
if (resolvedNode) {
|
||||
return convertAST(parent, resolvedNode, doc, lineCounter);
|
||||
}
|
||||
else {
|
||||
const resultNode = new StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
resultNode.value = node.source;
|
||||
return resultNode;
|
||||
}
|
||||
}
|
||||
export function toOffsetLength(range) {
|
||||
return [range[0], range[1] - range[0]];
|
||||
}
|
||||
/**
|
||||
* Convert offsets to offset+length with fix length to not include '\n' character in some cases
|
||||
* @param range the yaml ast range
|
||||
* @param lineCounter the line counter
|
||||
* @returns the offset and length
|
||||
*/
|
||||
function toFixedOffsetLength(range, lineCounter) {
|
||||
const start = lineCounter.linePos(range[0]);
|
||||
const end = lineCounter.linePos(range[1]);
|
||||
const result = [range[0], range[1] - range[0]];
|
||||
// -1 as range may include '\n'
|
||||
if (start.line !== end.line && (lineCounter.lineStarts.length !== end.line || end.col === 1)) {
|
||||
result[1]--;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function collectFlowMapRange(node) {
|
||||
let start = Number.MAX_SAFE_INTEGER;
|
||||
let end = 0;
|
||||
for (const it of node.items) {
|
||||
if (isPair(it)) {
|
||||
if (isNode(it.key)) {
|
||||
if (it.key.range && it.key.range[0] <= start) {
|
||||
start = it.key.range[0];
|
||||
}
|
||||
}
|
||||
if (isNode(it.value)) {
|
||||
if (it.value.range && it.value.range[2] >= end) {
|
||||
end = it.value.range[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [start, end, end];
|
||||
}
|
||||
//# sourceMappingURL=ast-converter.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/ast-converter.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/ast-converter.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
node_modules/yaml-language-server/lib/esm/languageservice/parser/custom-tag-provider.d.ts
generated
vendored
Normal file
7
node_modules/yaml-language-server/lib/esm/languageservice/parser/custom-tag-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Tags } from 'yaml';
|
||||
/**
|
||||
* Converts the tags from settings and adds known tags such as !include
|
||||
* and returns Tags that can be used by the parser.
|
||||
* @param customTags Tags for parser
|
||||
*/
|
||||
export declare function getCustomTags(customTags: string[]): Tags;
|
||||
58
node_modules/yaml-language-server/lib/esm/languageservice/parser/custom-tag-provider.js
generated
vendored
Normal file
58
node_modules/yaml-language-server/lib/esm/languageservice/parser/custom-tag-provider.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import { isSeq, isMap } from 'yaml';
|
||||
import { filterInvalidCustomTags } from '../utils/arrUtils';
|
||||
class CommonTagImpl {
|
||||
constructor(tag, type) {
|
||||
this.tag = tag;
|
||||
this.type = type;
|
||||
}
|
||||
get collection() {
|
||||
if (this.type === 'mapping') {
|
||||
return 'map';
|
||||
}
|
||||
if (this.type === 'sequence') {
|
||||
return 'seq';
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
resolve(value) {
|
||||
if (isMap(value) && this.type === 'mapping') {
|
||||
return value;
|
||||
}
|
||||
if (isSeq(value) && this.type === 'sequence') {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === 'string' && this.type === 'scalar') {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
class IncludeTag {
|
||||
constructor() {
|
||||
this.tag = '!include';
|
||||
this.type = 'scalar';
|
||||
}
|
||||
resolve(value, onError) {
|
||||
if (value && value.length > 0 && value.trim()) {
|
||||
return value;
|
||||
}
|
||||
onError('!include without value');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the tags from settings and adds known tags such as !include
|
||||
* and returns Tags that can be used by the parser.
|
||||
* @param customTags Tags for parser
|
||||
*/
|
||||
export function getCustomTags(customTags) {
|
||||
const tags = [];
|
||||
const filteredTags = filterInvalidCustomTags(customTags);
|
||||
for (const tag of filteredTags) {
|
||||
const typeInfo = tag.split(' ');
|
||||
const tagName = typeInfo[0];
|
||||
const tagType = (typeInfo[1] && typeInfo[1].toLowerCase()) || 'scalar';
|
||||
tags.push(new CommonTagImpl(tagName, tagType));
|
||||
}
|
||||
tags.push(new IncludeTag());
|
||||
return tags;
|
||||
}
|
||||
//# sourceMappingURL=custom-tag-provider.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/custom-tag-provider.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/custom-tag-provider.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"custom-tag-provider.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/custom-tag-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,EAAE,KAAK,EAAoB,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,aAAa;IAIjB,YAAY,GAAW,EAAE,IAAY;QACnC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,UAAU;QACZ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;YAC3B,OAAO,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Q,CAAC;QACvE,IAAI,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;KAChD;IACD,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
||||
4
node_modules/yaml-language-server/lib/esm/languageservice/parser/isKubernetes.d.ts
generated
vendored
Normal file
4
node_modules/yaml-language-server/lib/esm/languageservice/parser/isKubernetes.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import * as Parser from './jsonParser07';
|
||||
export declare function setKubernetesParserOption(jsonDocuments: Parser.JSONDocument[], option: boolean): void;
|
||||
export declare function isKubernetesAssociatedDocument(textDocument: TextDocument, paths: string[]): boolean;
|
||||
17
node_modules/yaml-language-server/lib/esm/languageservice/parser/isKubernetes.js
generated
vendored
Normal file
17
node_modules/yaml-language-server/lib/esm/languageservice/parser/isKubernetes.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { FilePatternAssociation } from '../services/yamlSchemaService';
|
||||
export function setKubernetesParserOption(jsonDocuments, option) {
|
||||
for (const jsonDoc of jsonDocuments) {
|
||||
jsonDoc.isKubernetes = option;
|
||||
}
|
||||
}
|
||||
export function isKubernetesAssociatedDocument(textDocument, paths) {
|
||||
for (const path in paths) {
|
||||
const globPath = paths[path];
|
||||
const fpa = new FilePatternAssociation(globPath);
|
||||
if (fpa.matchesPattern(textDocument.uri)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//# sourceMappingURL=isKubernetes.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/isKubernetes.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/isKubernetes.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isKubernetes.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/isKubernetes.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,MAAM,UAAU,yBAAyB,CAAC,aAAoC,EAAE,MAAe;IAC7F,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;QACnC,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC;KAC/B;AACH,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,YAA0B,EAAE,KAAe;IACxF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QAEjD,IAAI,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;YACxC,OAAO,IAAI,CAAC;SACb;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
||||
185
node_modules/yaml-language-server/lib/esm/languageservice/parser/jsonParser07.d.ts
generated
vendored
Normal file
185
node_modules/yaml-language-server/lib/esm/languageservice/parser/jsonParser07.d.ts
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
import { JSONSchema, JSONSchemaRef } from '../jsonSchema';
|
||||
import { ASTNode, ObjectASTNode, ArrayASTNode, BooleanASTNode, NumberASTNode, StringASTNode, NullASTNode, PropertyASTNode, YamlNode } from '../jsonASTTypes';
|
||||
import { ErrorCode } from 'vscode-json-languageservice';
|
||||
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Node, Pair } from 'yaml';
|
||||
export interface IRange {
|
||||
offset: number;
|
||||
length: number;
|
||||
}
|
||||
export declare const formats: {
|
||||
'color-hex': {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
};
|
||||
'date-time': {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
};
|
||||
date: {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
};
|
||||
time: {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
};
|
||||
email: {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
};
|
||||
ipv4: {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
};
|
||||
ipv6: {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
};
|
||||
};
|
||||
export declare const YAML_SOURCE = "YAML";
|
||||
export declare enum ProblemType {
|
||||
missingRequiredPropWarning = "missingRequiredPropWarning",
|
||||
typeMismatchWarning = "typeMismatchWarning",
|
||||
constWarning = "constWarning"
|
||||
}
|
||||
export declare const ProblemTypeMessages: Record<ProblemType, string>;
|
||||
export interface IProblem {
|
||||
location: IRange;
|
||||
severity: DiagnosticSeverity;
|
||||
code?: ErrorCode;
|
||||
message: string;
|
||||
source?: string;
|
||||
problemType?: ProblemType;
|
||||
problemArgs?: string[];
|
||||
schemaUri?: string[];
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
export declare abstract class ASTNodeImpl {
|
||||
abstract readonly type: 'object' | 'property' | 'array' | 'number' | 'boolean' | 'null' | 'string';
|
||||
offset: number;
|
||||
length: number;
|
||||
readonly parent: ASTNode;
|
||||
location: string;
|
||||
readonly internalNode: YamlNode;
|
||||
constructor(parent: ASTNode, internalNode: YamlNode, offset: number, length?: number);
|
||||
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
|
||||
get children(): ASTNode[];
|
||||
toString(): string;
|
||||
}
|
||||
export declare class NullASTNodeImpl extends ASTNodeImpl implements NullASTNode {
|
||||
type: 'null';
|
||||
value: any;
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
}
|
||||
export declare class BooleanASTNodeImpl extends ASTNodeImpl implements BooleanASTNode {
|
||||
type: 'boolean';
|
||||
value: boolean;
|
||||
constructor(parent: ASTNode, internalNode: Node, boolValue: boolean, offset: number, length?: number);
|
||||
}
|
||||
export declare class ArrayASTNodeImpl extends ASTNodeImpl implements ArrayASTNode {
|
||||
type: 'array';
|
||||
items: ASTNode[];
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
get children(): ASTNode[];
|
||||
}
|
||||
export declare class NumberASTNodeImpl extends ASTNodeImpl implements NumberASTNode {
|
||||
type: 'number';
|
||||
isInteger: boolean;
|
||||
value: number;
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
}
|
||||
export declare class StringASTNodeImpl extends ASTNodeImpl implements StringASTNode {
|
||||
type: 'string';
|
||||
value: string;
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
}
|
||||
export declare class PropertyASTNodeImpl extends ASTNodeImpl implements PropertyASTNode {
|
||||
type: 'property';
|
||||
keyNode: StringASTNode;
|
||||
valueNode: ASTNode;
|
||||
colonOffset: number;
|
||||
constructor(parent: ObjectASTNode, internalNode: Pair, offset: number, length?: number);
|
||||
get children(): ASTNode[];
|
||||
}
|
||||
export declare class ObjectASTNodeImpl extends ASTNodeImpl implements ObjectASTNode {
|
||||
type: 'object';
|
||||
properties: PropertyASTNode[];
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
get children(): ASTNode[];
|
||||
}
|
||||
export declare function asSchema(schema: JSONSchemaRef): JSONSchema | undefined;
|
||||
export interface JSONDocumentConfig {
|
||||
collectComments?: boolean;
|
||||
}
|
||||
export interface IApplicableSchema {
|
||||
node: ASTNode;
|
||||
inverted?: boolean;
|
||||
schema: JSONSchema;
|
||||
}
|
||||
export declare enum EnumMatch {
|
||||
Key = 0,
|
||||
Enum = 1
|
||||
}
|
||||
export interface ISchemaCollector {
|
||||
schemas: IApplicableSchema[];
|
||||
add(schema: IApplicableSchema): void;
|
||||
merge(other: ISchemaCollector): void;
|
||||
include(node: ASTNode): boolean;
|
||||
newSub(): ISchemaCollector;
|
||||
}
|
||||
export declare class ValidationResult {
|
||||
problems: IProblem[];
|
||||
propertiesMatches: number;
|
||||
propertiesValueMatches: number;
|
||||
primaryValueMatches: number;
|
||||
enumValueMatch: boolean;
|
||||
enumValues: any[];
|
||||
constructor(isKubernetes: boolean);
|
||||
hasProblems(): boolean;
|
||||
mergeAll(validationResults: ValidationResult[]): void;
|
||||
merge(validationResult: ValidationResult): void;
|
||||
mergeEnumValues(validationResult: ValidationResult): void;
|
||||
/**
|
||||
* Merge multiple warnings with same problemType together
|
||||
* @param subValidationResult another possible result
|
||||
*/
|
||||
mergeWarningGeneric(subValidationResult: ValidationResult, problemTypesToMerge: ProblemType[]): void;
|
||||
mergePropertyMatch(propertyValidationResult: ValidationResult): void;
|
||||
private mergeSources;
|
||||
compareGeneric(other: ValidationResult): number;
|
||||
compareKubernetes(other: ValidationResult): number;
|
||||
}
|
||||
export declare function newJSONDocument(root: ASTNode, diagnostics?: Diagnostic[]): JSONDocument;
|
||||
export declare function getNodeValue(node: ASTNode): any;
|
||||
export declare function contains(node: ASTNode, offset: number, includeRightBound?: boolean): boolean;
|
||||
export declare function findNodeAtOffset(node: ASTNode, offset: number, includeRightBound: boolean): ASTNode;
|
||||
export declare class JSONDocument {
|
||||
readonly root: ASTNode;
|
||||
readonly syntaxErrors: Diagnostic[];
|
||||
readonly comments: Range[];
|
||||
isKubernetes: boolean;
|
||||
disableAdditionalProperties: boolean;
|
||||
uri: string;
|
||||
constructor(root: ASTNode, syntaxErrors?: Diagnostic[], comments?: Range[]);
|
||||
getNodeFromOffset(offset: number, includeRightBound?: boolean): ASTNode | undefined;
|
||||
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
|
||||
visit(visitor: (node: ASTNode) => boolean): void;
|
||||
validate(textDocument: TextDocument, schema: JSONSchema): Diagnostic[];
|
||||
/**
|
||||
* This method returns the list of applicable schemas
|
||||
*
|
||||
* currently used @param didCallFromAutoComplete flag to differentiate the method call, when it is from auto complete
|
||||
* then user still types something and skip the validation for timebeing untill completed.
|
||||
* On https://github.com/redhat-developer/yaml-language-server/pull/719 the auto completes need to populate the list of enum string which matches to the enum
|
||||
* and on https://github.com/redhat-developer/vscode-yaml/issues/803 the validation should throw the error based on the enum string.
|
||||
*
|
||||
* @param schema schema
|
||||
* @param focusOffset offsetValue
|
||||
* @param exclude excluded Node
|
||||
* @param didCallFromAutoComplete true if method called from AutoComplete
|
||||
* @returns array of applicable schemas
|
||||
*/
|
||||
getMatchingSchemas(schema: JSONSchema, focusOffset?: number, exclude?: ASTNode, didCallFromAutoComplete?: boolean): IApplicableSchema[];
|
||||
}
|
||||
1332
node_modules/yaml-language-server/lib/esm/languageservice/parser/jsonParser07.js
generated
vendored
Normal file
1332
node_modules/yaml-language-server/lib/esm/languageservice/parser/jsonParser07.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/jsonParser07.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/jsonParser07.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/yaml-language-server/lib/esm/languageservice/parser/scalar-type.d.ts
generated
vendored
Normal file
8
node_modules/yaml-language-server/lib/esm/languageservice/parser/scalar-type.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Parse a boolean according to the specification
|
||||
*
|
||||
* Return:
|
||||
* true if its a true value
|
||||
* false if its a false value
|
||||
*/
|
||||
export declare function parseYamlBoolean(input: string): boolean;
|
||||
17
node_modules/yaml-language-server/lib/esm/languageservice/parser/scalar-type.js
generated
vendored
Normal file
17
node_modules/yaml-language-server/lib/esm/languageservice/parser/scalar-type.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Parse a boolean according to the specification
|
||||
*
|
||||
* Return:
|
||||
* true if its a true value
|
||||
* false if its a false value
|
||||
*/
|
||||
export function parseYamlBoolean(input) {
|
||||
if (['true', 'True', 'TRUE', 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON'].lastIndexOf(input) >= 0) {
|
||||
return true;
|
||||
}
|
||||
else if (['false', 'False', 'FALSE', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'].lastIndexOf(input) >= 0) {
|
||||
return false;
|
||||
}
|
||||
throw `Invalid boolean "${input}"`;
|
||||
}
|
||||
//# sourceMappingURL=scalar-type.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/scalar-type.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/scalar-type.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scalar-type.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/scalar-type.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QACrG,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QAC/G,OAAO,KAAK,CAAC;KACd;IACD,MAAM,oBAAoB,KAAK,GAAG,CAAC;AACrC,CAAC"}
|
||||
71
node_modules/yaml-language-server/lib/esm/languageservice/parser/yaml-documents.d.ts
generated
vendored
Normal file
71
node_modules/yaml-language-server/lib/esm/languageservice/parser/yaml-documents.d.ts
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { JSONDocument } from './jsonParser07';
|
||||
import { Document, LineCounter } from 'yaml';
|
||||
import { ASTNode, YamlNode } from '../jsonASTTypes';
|
||||
import { ParserOptions } from './yamlParser07';
|
||||
import { YAMLDocDiagnostic } from '../utils/parseUtils';
|
||||
import { TextBuffer } from '../utils/textBuffer';
|
||||
import { Token } from 'yaml/dist/parse/cst';
|
||||
/**
|
||||
* These documents are collected into a final YAMLDocument
|
||||
* and passed to the `parseYAML` caller.
|
||||
*/
|
||||
export declare class SingleYAMLDocument extends JSONDocument {
|
||||
private lineCounter;
|
||||
private _internalDocument;
|
||||
root: ASTNode;
|
||||
currentDocIndex: number;
|
||||
private _lineComments;
|
||||
constructor(lineCounter?: LineCounter);
|
||||
/**
|
||||
* Create a deep copy of this document
|
||||
*/
|
||||
clone(): SingleYAMLDocument;
|
||||
private collectLineComments;
|
||||
/**
|
||||
* Updates the internal AST tree of the object
|
||||
* from the internal node. This is call whenever the
|
||||
* internalDocument is set but also can be called to
|
||||
* reflect any changes on the underlying document
|
||||
* without setting the internalDocument explicitly.
|
||||
*/
|
||||
updateFromInternalDocument(): void;
|
||||
set internalDocument(document: Document);
|
||||
get internalDocument(): Document;
|
||||
get lineComments(): string[];
|
||||
set lineComments(val: string[]);
|
||||
get errors(): YAMLDocDiagnostic[];
|
||||
get warnings(): YAMLDocDiagnostic[];
|
||||
getNodeFromPosition(positionOffset: number, textBuffer: TextBuffer, configuredIndentation?: number): [YamlNode | undefined, boolean];
|
||||
findClosestNode(offset: number, textBuffer: TextBuffer, configuredIndentation?: number): YamlNode;
|
||||
private getProperParentByIndentation;
|
||||
getParent(node: YamlNode): YamlNode | undefined;
|
||||
}
|
||||
/**
|
||||
* Contains the SingleYAMLDocuments, to be passed
|
||||
* to the `parseYAML` caller.
|
||||
*/
|
||||
export declare class YAMLDocument {
|
||||
documents: SingleYAMLDocument[];
|
||||
tokens: Token[];
|
||||
private errors;
|
||||
private warnings;
|
||||
constructor(documents: SingleYAMLDocument[], tokens: Token[]);
|
||||
}
|
||||
export declare class YamlDocuments {
|
||||
private cache;
|
||||
/**
|
||||
* Get cached YAMLDocument
|
||||
* @param document TextDocument to parse
|
||||
* @param parserOptions YAML parserOptions
|
||||
* @param addRootObject if true and document is empty add empty object {} to force schema usage
|
||||
* @returns the YAMLDocument
|
||||
*/
|
||||
getYamlDocument(document: TextDocument, parserOptions?: ParserOptions, addRootObject?: boolean): YAMLDocument;
|
||||
/**
|
||||
* For test purpose only!
|
||||
*/
|
||||
clear(): void;
|
||||
private ensureCache;
|
||||
}
|
||||
export declare const yamlDocumentsCache: YamlDocuments;
|
||||
258
node_modules/yaml-language-server/lib/esm/languageservice/parser/yaml-documents.js
generated
vendored
Normal file
258
node_modules/yaml-language-server/lib/esm/languageservice/parser/yaml-documents.js
generated
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { JSONDocument } from './jsonParser07';
|
||||
import { isNode, isPair, isScalar, visit } from 'yaml';
|
||||
import { defaultOptions, parse as parseYAML } from './yamlParser07';
|
||||
import { ErrorCode } from 'vscode-json-languageservice';
|
||||
import { convertAST } from './ast-converter';
|
||||
import { isArrayEqual } from '../utils/arrUtils';
|
||||
import { getParent } from '../utils/astUtils';
|
||||
import { getIndentation } from '../utils/strings';
|
||||
/**
|
||||
* These documents are collected into a final YAMLDocument
|
||||
* and passed to the `parseYAML` caller.
|
||||
*/
|
||||
export class SingleYAMLDocument extends JSONDocument {
|
||||
constructor(lineCounter) {
|
||||
super(null, []);
|
||||
this.lineCounter = lineCounter;
|
||||
}
|
||||
/**
|
||||
* Create a deep copy of this document
|
||||
*/
|
||||
clone() {
|
||||
const copy = new SingleYAMLDocument(this.lineCounter);
|
||||
copy.isKubernetes = this.isKubernetes;
|
||||
copy.disableAdditionalProperties = this.disableAdditionalProperties;
|
||||
copy.uri = this.uri;
|
||||
copy.currentDocIndex = this.currentDocIndex;
|
||||
copy._lineComments = this.lineComments.slice();
|
||||
// this will re-create root node
|
||||
copy.internalDocument = this._internalDocument.clone();
|
||||
return copy;
|
||||
}
|
||||
collectLineComments() {
|
||||
this._lineComments = [];
|
||||
if (this._internalDocument.commentBefore) {
|
||||
const comments = this._internalDocument.commentBefore.split('\n');
|
||||
comments.forEach((comment) => this._lineComments.push(`#${comment}`));
|
||||
}
|
||||
visit(this.internalDocument, (_key, node) => {
|
||||
if (node?.commentBefore) {
|
||||
const comments = node?.commentBefore.split('\n');
|
||||
comments.forEach((comment) => this._lineComments.push(`#${comment}`));
|
||||
}
|
||||
if (node?.comment) {
|
||||
this._lineComments.push(`#${node.comment}`);
|
||||
}
|
||||
});
|
||||
if (this._internalDocument.comment) {
|
||||
this._lineComments.push(`#${this._internalDocument.comment}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Updates the internal AST tree of the object
|
||||
* from the internal node. This is call whenever the
|
||||
* internalDocument is set but also can be called to
|
||||
* reflect any changes on the underlying document
|
||||
* without setting the internalDocument explicitly.
|
||||
*/
|
||||
updateFromInternalDocument() {
|
||||
this.root = convertAST(null, this._internalDocument.contents, this._internalDocument, this.lineCounter);
|
||||
}
|
||||
set internalDocument(document) {
|
||||
this._internalDocument = document;
|
||||
this.updateFromInternalDocument();
|
||||
}
|
||||
get internalDocument() {
|
||||
return this._internalDocument;
|
||||
}
|
||||
get lineComments() {
|
||||
if (!this._lineComments) {
|
||||
this.collectLineComments();
|
||||
}
|
||||
return this._lineComments;
|
||||
}
|
||||
set lineComments(val) {
|
||||
this._lineComments = val;
|
||||
}
|
||||
get errors() {
|
||||
return this.internalDocument.errors.map(YAMLErrorToYamlDocDiagnostics);
|
||||
}
|
||||
get warnings() {
|
||||
return this.internalDocument.warnings.map(YAMLErrorToYamlDocDiagnostics);
|
||||
}
|
||||
getNodeFromPosition(positionOffset, textBuffer, configuredIndentation) {
|
||||
const position = textBuffer.getPosition(positionOffset);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
if (lineContent.trim().length === 0) {
|
||||
return [this.findClosestNode(positionOffset, textBuffer, configuredIndentation), true];
|
||||
}
|
||||
const textAfterPosition = lineContent.substring(position.character);
|
||||
const spacesAfterPositionMatch = textAfterPosition.match(/^([ ]+)\n?$/);
|
||||
const areOnlySpacesAfterPosition = !!spacesAfterPositionMatch;
|
||||
const countOfSpacesAfterPosition = spacesAfterPositionMatch?.[1].length;
|
||||
let closestNode;
|
||||
visit(this.internalDocument, (key, node) => {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
const range = node.range;
|
||||
if (!range) {
|
||||
return;
|
||||
}
|
||||
const isNullNodeOnTheLine = () => areOnlySpacesAfterPosition &&
|
||||
positionOffset + countOfSpacesAfterPosition === range[2] &&
|
||||
isScalar(node) &&
|
||||
node.value === null;
|
||||
if ((range[0] <= positionOffset && range[1] >= positionOffset) || isNullNodeOnTheLine()) {
|
||||
closestNode = node;
|
||||
}
|
||||
else {
|
||||
return visit.SKIP;
|
||||
}
|
||||
});
|
||||
return [closestNode, false];
|
||||
}
|
||||
findClosestNode(offset, textBuffer, configuredIndentation) {
|
||||
let offsetDiff = this.internalDocument.range[2];
|
||||
let maxOffset = this.internalDocument.range[0];
|
||||
let closestNode;
|
||||
visit(this.internalDocument, (key, node) => {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
const range = node.range;
|
||||
if (!range) {
|
||||
return;
|
||||
}
|
||||
const diff = range[1] - offset;
|
||||
if (maxOffset <= range[0] && diff <= 0 && Math.abs(diff) <= offsetDiff) {
|
||||
offsetDiff = Math.abs(diff);
|
||||
maxOffset = range[0];
|
||||
closestNode = node;
|
||||
}
|
||||
});
|
||||
const position = textBuffer.getPosition(offset);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
const indentation = getIndentation(lineContent, position.character);
|
||||
if (isScalar(closestNode) && closestNode.value === null) {
|
||||
return closestNode;
|
||||
}
|
||||
if (indentation === position.character) {
|
||||
closestNode = this.getProperParentByIndentation(indentation, closestNode, textBuffer, '', configuredIndentation);
|
||||
}
|
||||
return closestNode;
|
||||
}
|
||||
getProperParentByIndentation(indentation, node, textBuffer, currentLine, configuredIndentation, rootParent) {
|
||||
if (!node) {
|
||||
return this.internalDocument.contents;
|
||||
}
|
||||
configuredIndentation = !configuredIndentation ? 2 : configuredIndentation;
|
||||
if (isNode(node) && node.range) {
|
||||
const position = textBuffer.getPosition(node.range[0]);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
currentLine = currentLine === '' ? lineContent.trim() : currentLine;
|
||||
if (currentLine.startsWith('-') && indentation === configuredIndentation && currentLine === lineContent.trim()) {
|
||||
position.character += indentation;
|
||||
}
|
||||
if (position.character > indentation && position.character > 0) {
|
||||
const parent = this.getParent(node);
|
||||
if (parent) {
|
||||
return this.getProperParentByIndentation(indentation, parent, textBuffer, currentLine, configuredIndentation, rootParent);
|
||||
}
|
||||
}
|
||||
else if (position.character < indentation) {
|
||||
const parent = this.getParent(node);
|
||||
if (isPair(parent) && isNode(parent.value)) {
|
||||
return parent.value;
|
||||
}
|
||||
else if (isPair(rootParent) && isNode(rootParent.value)) {
|
||||
return rootParent.value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
else if (isPair(node)) {
|
||||
rootParent = node;
|
||||
const parent = this.getParent(node);
|
||||
return this.getProperParentByIndentation(indentation, parent, textBuffer, currentLine, configuredIndentation, rootParent);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
getParent(node) {
|
||||
return getParent(this.internalDocument, node);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Contains the SingleYAMLDocuments, to be passed
|
||||
* to the `parseYAML` caller.
|
||||
*/
|
||||
export class YAMLDocument {
|
||||
constructor(documents, tokens) {
|
||||
this.documents = documents;
|
||||
this.tokens = tokens;
|
||||
this.errors = [];
|
||||
this.warnings = [];
|
||||
}
|
||||
}
|
||||
export class YamlDocuments {
|
||||
constructor() {
|
||||
// a mapping of URIs to cached documents
|
||||
this.cache = new Map();
|
||||
}
|
||||
/**
|
||||
* Get cached YAMLDocument
|
||||
* @param document TextDocument to parse
|
||||
* @param parserOptions YAML parserOptions
|
||||
* @param addRootObject if true and document is empty add empty object {} to force schema usage
|
||||
* @returns the YAMLDocument
|
||||
*/
|
||||
getYamlDocument(document, parserOptions, addRootObject = false) {
|
||||
this.ensureCache(document, parserOptions ?? defaultOptions, addRootObject);
|
||||
return this.cache.get(document.uri).document;
|
||||
}
|
||||
/**
|
||||
* For test purpose only!
|
||||
*/
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
}
|
||||
ensureCache(document, parserOptions, addRootObject) {
|
||||
const key = document.uri;
|
||||
if (!this.cache.has(key)) {
|
||||
this.cache.set(key, { version: -1, document: new YAMLDocument([], []), parserOptions: defaultOptions });
|
||||
}
|
||||
const cacheEntry = this.cache.get(key);
|
||||
if (cacheEntry.version !== document.version ||
|
||||
(parserOptions.customTags && !isArrayEqual(cacheEntry.parserOptions.customTags, parserOptions.customTags))) {
|
||||
let text = document.getText();
|
||||
// if text is contains only whitespace wrap all text in object to force schema selection
|
||||
if (addRootObject && !/\S/.test(text)) {
|
||||
text = `{${text}}`;
|
||||
}
|
||||
const doc = parseYAML(text, parserOptions, document);
|
||||
cacheEntry.document = doc;
|
||||
cacheEntry.version = document.version;
|
||||
cacheEntry.parserOptions = parserOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
export const yamlDocumentsCache = new YamlDocuments();
|
||||
function YAMLErrorToYamlDocDiagnostics(error) {
|
||||
return {
|
||||
message: error.message,
|
||||
location: {
|
||||
start: error.pos[0],
|
||||
end: error.pos[1],
|
||||
toLineEnd: true,
|
||||
},
|
||||
severity: 1,
|
||||
code: ErrorCode.Undefined,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=yaml-documents.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/yaml-documents.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/yaml-documents.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
node_modules/yaml-language-server/lib/esm/languageservice/parser/yamlParser07.d.ts
generated
vendored
Normal file
15
node_modules/yaml-language-server/lib/esm/languageservice/parser/yamlParser07.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { YAMLDocument, SingleYAMLDocument } from './yaml-documents';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export { YAMLDocument, SingleYAMLDocument };
|
||||
export declare type YamlVersion = '1.1' | '1.2';
|
||||
export interface ParserOptions {
|
||||
customTags: string[];
|
||||
yamlVersion: YamlVersion;
|
||||
}
|
||||
export declare const defaultOptions: ParserOptions;
|
||||
/**
|
||||
* `yaml-ast-parser-custom-tags` parses the AST and
|
||||
* returns YAML AST nodes, which are then formatted
|
||||
* for consumption via the language server.
|
||||
*/
|
||||
export declare function parse(text: string, parserOptions?: ParserOptions, document?: TextDocument): YAMLDocument;
|
||||
50
node_modules/yaml-language-server/lib/esm/languageservice/parser/yamlParser07.js
generated
vendored
Normal file
50
node_modules/yaml-language-server/lib/esm/languageservice/parser/yamlParser07.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Parser, Composer, LineCounter } from 'yaml';
|
||||
import { YAMLDocument, SingleYAMLDocument } from './yaml-documents';
|
||||
import { getCustomTags } from './custom-tag-provider';
|
||||
import { TextBuffer } from '../utils/textBuffer';
|
||||
export { YAMLDocument, SingleYAMLDocument };
|
||||
export const defaultOptions = {
|
||||
customTags: [],
|
||||
yamlVersion: '1.2',
|
||||
};
|
||||
/**
|
||||
* `yaml-ast-parser-custom-tags` parses the AST and
|
||||
* returns YAML AST nodes, which are then formatted
|
||||
* for consumption via the language server.
|
||||
*/
|
||||
export function parse(text, parserOptions = defaultOptions, document) {
|
||||
const options = {
|
||||
strict: false,
|
||||
customTags: getCustomTags(parserOptions.customTags),
|
||||
version: parserOptions.yamlVersion ?? defaultOptions.yamlVersion,
|
||||
keepSourceTokens: true,
|
||||
};
|
||||
const composer = new Composer(options);
|
||||
const lineCounter = new LineCounter();
|
||||
let isLastLineEmpty = false;
|
||||
if (document) {
|
||||
const textBuffer = new TextBuffer(document);
|
||||
const position = textBuffer.getPosition(text.length);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
isLastLineEmpty = lineContent.trim().length === 0;
|
||||
}
|
||||
const parser = isLastLineEmpty ? new Parser() : new Parser(lineCounter.addNewLine);
|
||||
const tokens = parser.parse(text);
|
||||
const tokensArr = Array.from(tokens);
|
||||
const docs = composer.compose(tokensArr, true, text.length);
|
||||
// Generate the SingleYAMLDocs from the AST nodes
|
||||
const yamlDocs = Array.from(docs, (doc) => parsedDocToSingleYAMLDocument(doc, lineCounter));
|
||||
// Consolidate the SingleYAMLDocs
|
||||
return new YAMLDocument(yamlDocs, tokensArr);
|
||||
}
|
||||
function parsedDocToSingleYAMLDocument(parsedDoc, lineCounter) {
|
||||
const syd = new SingleYAMLDocument(lineCounter);
|
||||
syd.internalDocument = parsedDoc;
|
||||
return syd;
|
||||
}
|
||||
//# sourceMappingURL=yamlParser07.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/yamlParser07.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/parser/yamlParser07.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlParser07.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/yamlParser07.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;AAEhG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAY,W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CAAC;IACnF,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5D,iDAAiD;IACjD,MAAM,QAAQ,GAAyB,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,6BAA6B,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;IAElH,iCAAiC;IACjC,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,6BAA6B,CAAC,SAAmB,EAAE,WAAwB;IAClF,MAAM,GAAG,GAAG,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAChD,GAAG,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
||||
12
node_modules/yaml-language-server/lib/esm/languageservice/services/documentSymbols.d.ts
generated
vendored
Normal file
12
node_modules/yaml-language-server/lib/esm/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[];
|
||||
}
|
||||
68
node_modules/yaml-language-server/lib/esm/languageservice/services/documentSymbols.js
generated
vendored
Normal file
68
node_modules/yaml-language-server/lib/esm/languageservice/services/documentSymbols.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { JSONDocumentSymbols } from 'vscode-json-languageservice/lib/umd/services/jsonDocumentSymbols';
|
||||
import { yamlDocumentsCache } from '../parser/yaml-documents';
|
||||
import { isMap, isSeq } from 'yaml';
|
||||
import { convertErrorToTelemetryMsg } from '../utils/objects';
|
||||
export class YAMLDocumentSymbols {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
this.jsonDocumentSymbols = new 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 (isMap(keyNode)) {
|
||||
name = '{}';
|
||||
}
|
||||
else if (isSeq(keyNode)) {
|
||||
name = '[]';
|
||||
}
|
||||
else {
|
||||
name = keyNode.source;
|
||||
}
|
||||
return name;
|
||||
};
|
||||
}
|
||||
findDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
|
||||
let results = [];
|
||||
try {
|
||||
const doc = 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: convertErrorToTelemetryMsg(err) });
|
||||
}
|
||||
return results;
|
||||
}
|
||||
findHierarchicalDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
|
||||
let results = [];
|
||||
try {
|
||||
const doc = 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: convertErrorToTelemetryMsg(err) });
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=documentSymbols.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/documentSymbols.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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;AAIhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AAGvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAQ,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,OAAO,mBAAmB;IAG9B,YAAY,aAAgC,EAAmB,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QAClF,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAElE,m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UAAkC,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE;QAEnE,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI;YACF,MAAM,GAAG,GAAG,kBAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACzD,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;gBACzC,OAAO,IAAI,CAAC;aACb;YAED,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,EAAE;gBACtC,IAAI,OAAO,CAAC,IAAI,EAAE;oBAChB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;iBACrG;aACF;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,wCAAwC,EAAE,EAAE,KAAK,EAAE,0BAA0B,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SACjH;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
||||
9
node_modules/yaml-language-server/lib/esm/languageservice/services/modelineUtil.d.ts
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/esm/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;
|
||||
32
node_modules/yaml-language-server/lib/esm/languageservice/services/modelineUtil.js
generated
vendored
Normal file
32
node_modules/yaml-language-server/lib/esm/languageservice/services/modelineUtil.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { SingleYAMLDocument } from '../parser/yamlParser07';
|
||||
/**
|
||||
* Retrieve schema if declared as modeline.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
*/
|
||||
export function getSchemaFromModeline(doc) {
|
||||
if (doc instanceof 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;
|
||||
}
|
||||
export function isModeline(lineText) {
|
||||
const matchModeline = lineText.match(/^#\s+yaml-language-server\s*:/g);
|
||||
return matchModeline !== null && matchModeline.length === 1;
|
||||
}
|
||||
//# sourceMappingURL=modelineUtil.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/modelineUtil.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAsC;IAC1E,IAAI,GAAG,YAAY,kBAAkB,EAAE;QACrC,MAAM,0BAA0B,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;YACvE,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,IAAI,0BAA0B,IAAI,SAAS,EAAE;YAC3C,MAAM,YAAY,GAAG,0BAA0B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACvE,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;gBACrD,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;oBAC5B,OAAO,CAAC,GAAG,CACT,gHAAgH,CACjH,CAAC;iBACH;gBACD,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aACrD;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACvE,OAAO,aAAa,KAAK,IAAI,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;AAC9D,CAAC"}
|
||||
12
node_modules/yaml-language-server/lib/esm/languageservice/services/schemaRequestHandler.d.ts
generated
vendored
Normal file
12
node_modules/yaml-language-server/lib/esm/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;
|
||||
62
node_modules/yaml-language-server/lib/esm/languageservice/services/schemaRequestHandler.js
generated
vendored
Normal file
62
node_modules/yaml-language-server/lib/esm/languageservice/services/schemaRequestHandler.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import { URI } from 'vscode-uri';
|
||||
import { xhr, getErrorStatusDescription } from 'request-light';
|
||||
import * as URL from 'url';
|
||||
import { CustomSchemaContentRequest, VSCodeContentRequest } from '../../requestTypes';
|
||||
import { isRelativePath, relativeToAbsolutePath } from '../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
|
||||
*/
|
||||
export 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 (isRelativePath(uri)) {
|
||||
uri = relativeToAbsolutePath(workspaceFolders, workspaceRoot, uri);
|
||||
}
|
||||
let scheme = URI.parse(uri).scheme.toLowerCase();
|
||||
// test if uri is windows path, ie starts with 'c:\'
|
||||
if (/^[a-z]:[\\/]/i.test(uri)) {
|
||||
const winUri = 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 = 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(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 xhr({ url: uri, followRedirects: 5, headers }).then((response) => {
|
||||
return response.responseText;
|
||||
}, (error) => {
|
||||
return Promise.reject(error.responseText || 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(CustomSchemaContentRequest.type, uri);
|
||||
};
|
||||
export const workspaceContext = {
|
||||
resolveRelativePath: (relativePath, resource) => {
|
||||
return URL.resolve(resource, relativePath);
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=schemaRequestHandler.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/schemaRequestHandler.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,GAAG,EAAe,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAOxE;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,UAAsB,E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AAO,YAAY,CAAC;YACtB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;gBACR,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvC,CAAC,CACiB,CAAC;SACtB;QAED,gEAAgE;QAChE,MAAM,OAAO,GAAG,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;QACvD,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CACxD,CAAC,QAAQ,EAAE,EAAE;YACX,OAAO,QAAQ,CAAC,YAAY,CAAC;QAC/B,CAAC,EACD,CAAC,KAAkB,EAAE,EAAE;YACrB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,yBAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3G,CAAC,CACF,CAAC;KACH;IAED,gGAAgG;IAChG,OAAO,UAAU,CAAC,WAAW,CAAC,0BAA0B,CAAC,IAAI,EAAE,GAAG,CAAoB,CAAC;AACzF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA4B;IACvD,mBAAmB,EAAE,CAAC,YAAoB,EAAE,QAAgB,EAAE,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
|
||||
7
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/map-key-order.d.ts
generated
vendored
Normal file
7
node_modules/yaml-language-server/lib/esm/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[];
|
||||
}
|
||||
36
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/map-key-order.js
generated
vendored
Normal file
36
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/map-key-order.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
|
||||
import { isMap, visit } from 'yaml';
|
||||
export class MapKeyOrderValidator {
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
visit(yamlDoc.internalDocument, (key, node) => {
|
||||
if (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(Diagnostic.create(range, `Wrong ordering of key "${node.items[i - 1].key}" in mapping`, DiagnosticSeverity.Error, 'mapKeyOrder'));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
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 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/esm/languageservice/services/validation/map-key-order.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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;AAGhG,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAGpF,OAAO,EAAE,KAAK,EAAQ,KAAK,EAAE,MAAM,MAAM,CAAC;AAE1C,MAAM,OAAO,oBAAoB;IAC/B,QAAQ,CAAC,QAAsB,EAAE,OAA2B;QAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;QAElB,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YAC5C,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE;gBACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;wBACjD,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;wBACvD,MAAM,CAAC,IAAI,CACT,UAAU,CAAC,MAAM,CACf,KAAK,EACL,0BAA0B,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,cAAc,EAC7D,kBAAkB,CAAC,KAAK,EACxB,aAAa,CACd,CACF,CAAC;qBACH;iBACF;aACF;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,WAAW,CAAC,QAAsB,EAAE,IAAU;IACrD,MAAM,KAAK,GAAG,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAC9G,MAAM,GAAG,GACP,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM;QAC5B,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM;QAC9B,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM;QAC1B,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,OAAO,CAAC,IAAU,EAAE,IAAU;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
||||
6
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/types.d.ts
generated
vendored
Normal file
6
node_modules/yaml-language-server/lib/esm/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[];
|
||||
}
|
||||
6
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/types.js
generated
vendored
Normal file
6
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/types.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/types.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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/esm/languageservice/services/validation/unused-anchors.d.ts
generated
vendored
Normal file
8
node_modules/yaml-language-server/lib/esm/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;
|
||||
}
|
||||
73
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/unused-anchors.js
generated
vendored
Normal file
73
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/unused-anchors.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Diagnostic, DiagnosticSeverity, DiagnosticTag, Range } from 'vscode-languageserver-types';
|
||||
import { isAlias, isCollection, isNode, isScalar, visit, CST } from 'yaml';
|
||||
import { isCollectionItem } from '../../../languageservice/utils/astUtils';
|
||||
export class UnusedAnchorsValidator {
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
const anchors = new Set();
|
||||
const usedAnchors = new Set();
|
||||
const anchorParent = new Map();
|
||||
visit(yamlDoc.internalDocument, (key, node, path) => {
|
||||
if (!isNode(node)) {
|
||||
return;
|
||||
}
|
||||
if ((isCollection(node) || isScalar(node)) && node.anchor) {
|
||||
anchors.add(node);
|
||||
anchorParent.set(node, path[path.length - 1]);
|
||||
}
|
||||
if (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 = Range.create(document.positionAt(aToken.offset), document.positionAt(aToken.offset + aToken.source.length));
|
||||
const warningDiagnostic = Diagnostic.create(range, `Unused anchor "${aToken.source}"`, DiagnosticSeverity.Hint, 0);
|
||||
warningDiagnostic.tags = [DiagnosticTag.Unnecessary];
|
||||
result.push(warningDiagnostic);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getAnchorNode(parentNode, node) {
|
||||
if (parentNode && parentNode.srcToken) {
|
||||
const token = parentNode.srcToken;
|
||||
if (isCollectionItem(token)) {
|
||||
return getAnchorFromCollectionItem(token);
|
||||
}
|
||||
else if (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;
|
||||
}
|
||||
}
|
||||
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/esm/languageservice/services/validation/unused-anchors.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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;AAGhG,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAgB,KAAK,EAAoB,GAAG,EAAQ,MAAM,MAAM,CAAC;AAIjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,MAAM,OAAO,sBAAsB;IACjC,QAAQ,CAAC,QAAsB,EAAE,OAA2B;QAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;QACtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAQ,CAAC;QACpC,MAAM,YAAY,GAAG,IAAI,GAAG,EAA2C,CAAC;QAExE,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YAClD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACjB,OAAO;aAC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pD,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,EAAE;YACrC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC;YAClC,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;gBAC3B,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;aAC3C;iBAAM,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;gBAClC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;oBAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC,KAAK;wBAAE,SAAS;oBACxC,MAAM,MAAM,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAC;oBAC9C,IAAI,MAAM,EAAE;wBACV,OAAO,MAAM,CAAC;qBACf;iBACF;aACF;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AACD,SAAS,2BAA2B,CAAC,KAAyB;IAC5D,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;QAC3B,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;YACvB,OAAO,CAAC,CAAC;SACV;KACF;IACD,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACzC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE;YACzB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvB,OAAO,CAAC,CAAC;aACV;SACF;KACF;AACH,CAAC"}
|
||||
12
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/yaml-style.d.ts
generated
vendored
Normal file
12
node_modules/yaml-language-server/lib/esm/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;
|
||||
}
|
||||
24
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/yaml-style.js
generated
vendored
Normal file
24
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/yaml-style.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
|
||||
import { isMap, isSeq, visit } from 'yaml';
|
||||
export class YAMLStyleValidator {
|
||||
constructor(settings) {
|
||||
this.forbidMapping = settings.flowMapping === 'forbid';
|
||||
this.forbidSequence = settings.flowSequence === 'forbid';
|
||||
}
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
visit(yamlDoc.internalDocument, (key, node) => {
|
||||
if (this.forbidMapping && isMap(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style mapping is forbidden', DiagnosticSeverity.Error, 'flowMap'));
|
||||
}
|
||||
if (this.forbidSequence && isSeq(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style sequence is forbidden', DiagnosticSeverity.Error, 'flowSeq'));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
getRangeOf(document, node) {
|
||||
return Range.create(document.positionAt(node.start.offset), document.positionAt(node.end.pop().offset));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=yaml-style.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/validation/yaml-style.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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":"AACA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAM3C,MAAM,OAAO,kBAAkB;IAI7B,YAAY,QAA0B;QACpC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC;QACvD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,YAAY,KAAK,QAAQ,CAAC;IAC3D,CAAC;IACD,QAAQ,CAAC,QAAsB,EAAE,OAA2B;QAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YAC5C,IAAI,IAAI,CAAC,aAAa,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;gBAClF,MAAM,CAAC,IAAI,CACT,UAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,iCAAiC,EACjC,kBAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;aACH;YACD,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;gBACnF,MAAM,CAAC,IAAI,CACT,UAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,kCAAkC,EAClC,kBAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;aACH;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,UAAU,CAAC,QAAsB,EAAE,IAAoB;QAC7D,OAAO,KAAK,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;IAC1G,CAAC;CACF"}
|
||||
17
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCodeActions.d.ts
generated
vendored
Normal file
17
node_modules/yaml-language-server/lib/esm/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;
|
||||
}
|
||||
253
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCodeActions.js
generated
vendored
Normal file
253
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCodeActions.js
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { CodeAction, CodeActionKind, Command, Position, Range, TextEdit, } from 'vscode-languageserver-types';
|
||||
import { YamlCommands } from '../../commands';
|
||||
import * as path from 'path';
|
||||
import { TextBuffer } from '../utils/textBuffer';
|
||||
import { YAML_SOURCE } from '../parser/jsonParser07';
|
||||
import { getFirstNonWhitespaceCharacterAfterOffset } from '../utils/strings';
|
||||
import { matchOffsetToDocument } from '../utils/arrUtils';
|
||||
import { CST, isMap, isSeq } from 'yaml';
|
||||
import { yamlDocumentsCache } from '../parser/yaml-documents';
|
||||
import { FlowStyleRewriter } from '../utils/flow-style-rewriter';
|
||||
import * as _ from 'lodash';
|
||||
export 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 = CodeAction.create(`Jump to schema location (${path.basename(schemaUri)})`, Command.create('JumpToSchema', YamlCommands.JUMP_TO_SCHEMA, schemaUri));
|
||||
action.diagnostics = schemaUriToDiagnostic.get(schemaUri);
|
||||
result.push(action);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getTabToSpaceConverting(diagnostics, document) {
|
||||
const result = [];
|
||||
const textBuff = new 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 = Range.create(diag.range.start, Position.create(diag.range.end.line, diag.range.start.character + replacedTabs));
|
||||
}
|
||||
result.push(CodeAction.create('Convert Tab to Spaces', createWorkspaceEdit(document.uri, [TextEdit.replace(resultRange, newText)]), 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(TextEdit.replace(Range.create(i, j - replacedTabs, i, j), newText));
|
||||
replacedTabs = 0;
|
||||
newText = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (char === ' ' && replacedTabs !== 0) {
|
||||
replaceEdits.push(TextEdit.replace(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(TextEdit.replace(Range.create(i, 0, i, textBuff.getLineLength(i)), newText));
|
||||
}
|
||||
}
|
||||
if (replaceEdits.length > 0) {
|
||||
result.push(CodeAction.create('Convert all Tabs to Spaces', createWorkspaceEdit(document.uri, replaceEdits), CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getUnusedAnchorsDelete(diagnostics, document) {
|
||||
const result = [];
|
||||
const buffer = new TextBuffer(document);
|
||||
for (const diag of diagnostics) {
|
||||
if (diag.message.startsWith('Unused anchor') && diag.source === YAML_SOURCE) {
|
||||
const range = Range.create(diag.range.start, diag.range.end);
|
||||
const actual = buffer.getText(range);
|
||||
const lineContent = buffer.getLineContent(range.end.line);
|
||||
const lastWhitespaceChar = getFirstNonWhitespaceCharacterAfterOffset(lineContent, range.end.character);
|
||||
range.end.character = lastWhitespaceChar;
|
||||
const action = CodeAction.create(`Delete unused anchor: ${actual}`, createWorkspaceEdit(document.uri, [TextEdit.del(range)]), 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(CodeAction.create('Convert to boolean', createWorkspaceEdit(document.uri, [TextEdit.replace(diagnostic.range, newValue)]), 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 (isMap(node.internalNode) || isSeq(node.internalNode)) {
|
||||
const blockTypeDescription = isMap(node.internalNode) ? 'map' : 'sequence';
|
||||
const rewriter = new FlowStyleRewriter(this.indentation);
|
||||
results.push(CodeAction.create(`Convert to block style ${blockTypeDescription}`, createWorkspaceEdit(document.uri, [TextEdit.replace(diagnostic.range, rewriter.write(node))]), 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 && 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 && CST.isScalar(a.key) && 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 (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 = Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
||||
results.push(CodeAction.create('Fix key order for this map', createWorkspaceEdit(document.uri, [TextEdit.replace(replaceRange, CST.stringify(sorted.srcToken))]), CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
function getNodeforDiagnostic(document, diagnostic) {
|
||||
const yamlDocuments = yamlDocumentsCache.getYamlDocument(document);
|
||||
const startOffset = document.offsetAt(diagnostic.range.start);
|
||||
const yamlDoc = 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/esm/languageservice/services/yamlCodeActions.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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/esm/languageservice/services/yamlCodeLens.d.ts
generated
vendored
Normal file
11
node_modules/yaml-language-server/lib/esm/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;
|
||||
}
|
||||
47
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCodeLens.js
generated
vendored
Normal file
47
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCodeLens.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.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { CodeLens, Range } from 'vscode-languageserver-types';
|
||||
import { YamlCommands } from '../../commands';
|
||||
import { yamlDocumentsCache } from '../parser/yaml-documents';
|
||||
import { getSchemaUrls } from '../utils/schemaUrls';
|
||||
import { convertErrorToTelemetryMsg } from '../utils/objects';
|
||||
import { getSchemaTitle } from '../utils/schemaUtils';
|
||||
export class YamlCodeLens {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.schemaService = schemaService;
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
async getCodeLens(document) {
|
||||
const result = [];
|
||||
try {
|
||||
const yamlDocument = 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([...getSchemaUrls(schema?.schema), ...schemaUrls]);
|
||||
}
|
||||
}
|
||||
for (const urlToSchema of schemaUrls) {
|
||||
const lens = CodeLens.create(Range.create(0, 0, 0, 0));
|
||||
lens.command = {
|
||||
title: getSchemaTitle(urlToSchema[1], urlToSchema[0]),
|
||||
command: YamlCommands.JUMP_TO_SCHEMA,
|
||||
arguments: [urlToSchema[0]],
|
||||
};
|
||||
result.push(lens);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.codeLens.error', { error: convertErrorToTelemetryMsg(err) });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
resolveCodeLens(param) {
|
||||
return param;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=yamlCodeLens.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCodeLens.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCodeLens.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlCodeLens.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlCodeLens.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C;gBACvD,IAAI,CAAC,OAAO,GAAG;oBACb,KAAK,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;oBACrD,OAAO,EAAE,YAAY,CAAC,cAAc;oBACpC,SAAS,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;iBAC5B,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACnB;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,0BAA0B,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SAC9F;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,eAAe,CAAC,KAAe;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
||||
3
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCommands.d.ts
generated
vendored
Normal file
3
node_modules/yaml-language-server/lib/esm/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;
|
||||
34
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCommands.js
generated
vendored
Normal file
34
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCommands.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { YamlCommands } from '../../commands';
|
||||
import { URI } from 'vscode-uri';
|
||||
export function registerCommands(commandExecutor, connection) {
|
||||
commandExecutor.registerCommand(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 = URI.parse(uri);
|
||||
const customUri = 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 = 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}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=yamlCommands.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCommands.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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;AAGhG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,UAAU,gBAAgB,CAAC,eAAgC,EAAE,UAAsB;IACvF,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,cAAc,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE;QACjF,IAAI,CAAC,GAAG,EAAE;YACR,OAAO;SACR;QACD,oDAAoD;QACpD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACzD,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC;gBACzB,MAAM,EAAE,aAAa;gBACrB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,OAAO;gBAC5E,QAAQ,EAAE,GAAG;aACd,CAAC,CAAC;YACH,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;SAC5B;QAED,uEAAuE;QACvE,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7B,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,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;QACpG,IAAI,CAAC,MAAM,EAAE;YACX,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
68
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCompletion.d.ts
generated
vendored
Normal file
68
node_modules/yaml-language-server/lib/esm/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 {};
|
||||
1459
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlCompletion.js
generated
vendored
Normal file
1459
node_modules/yaml-language-server/lib/esm/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/esm/languageservice/services/yamlCompletion.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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/esm/languageservice/services/yamlDefinition.d.ts
generated
vendored
Normal file
9
node_modules/yaml-language-server/lib/esm/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;
|
||||
}
|
||||
38
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlDefinition.js
generated
vendored
Normal file
38
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlDefinition.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { LocationLink, Range } from 'vscode-languageserver-types';
|
||||
import { isAlias } from 'yaml';
|
||||
import { yamlDocumentsCache } from '../parser/yaml-documents';
|
||||
import { matchOffsetToDocument } from '../utils/arrUtils';
|
||||
import { convertErrorToTelemetryMsg } from '../utils/objects';
|
||||
import { TextBuffer } from '../utils/textBuffer';
|
||||
export class YamlDefinition {
|
||||
constructor(telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
getDefinition(document, params) {
|
||||
try {
|
||||
const yamlDocument = yamlDocumentsCache.getYamlDocument(document);
|
||||
const offset = document.offsetAt(params.position);
|
||||
const currentDoc = matchOffsetToDocument(offset, yamlDocument);
|
||||
if (currentDoc) {
|
||||
const [node] = currentDoc.getNodeFromPosition(offset, new TextBuffer(document));
|
||||
if (node && isAlias(node)) {
|
||||
const defNode = node.resolve(currentDoc.internalDocument);
|
||||
if (defNode && defNode.range) {
|
||||
const targetRange = Range.create(document.positionAt(defNode.range[0]), document.positionAt(defNode.range[2]));
|
||||
const selectionRange = Range.create(document.positionAt(defNode.range[0]), document.positionAt(defNode.range[1]));
|
||||
return [LocationLink.create(document.uri, targetRange, selectionRange)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.definition.error', { error: convertErrorToTelemetryMsg(err) });
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=yamlDefinition.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlDefinition.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/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;AAIhG,OAAO,EAAkB,YAAY,EAAE,KAA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AC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAClH,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;qBACzE;iBACF;aACF;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,0BAA0B,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SAChG;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
||||
4
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlFolding.d.ts
generated
vendored
Normal file
4
node_modules/yaml-language-server/lib/esm/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;
|
||||
62
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlFolding.js
generated
vendored
Normal file
62
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlFolding.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { FoldingRange, Range } from 'vscode-languageserver-types';
|
||||
import { yamlDocumentsCache } from '../parser/yaml-documents';
|
||||
export function getFoldingRanges(document, context) {
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
const result = [];
|
||||
const doc = 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);
|
||||
}
|
||||
function createNormalizedFolding(document, node) {
|
||||
const startPos = document.positionAt(node.offset);
|
||||
let endPos = document.positionAt(node.offset + node.length);
|
||||
const textFragment = document.getText(Range.create(startPos, endPos));
|
||||
const newLength = textFragment.length - textFragment.trimRight().length;
|
||||
if (newLength > 0) {
|
||||
endPos = document.positionAt(node.offset + node.length - newLength);
|
||||
}
|
||||
return FoldingRange.create(startPos.line, endPos.line, startPos.character, endPos.character);
|
||||
}
|
||||
//# sourceMappingURL=yamlFolding.js.map
|
||||
1
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlFolding.js.map
generated
vendored
Normal file
1
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlFolding.js.map
generated
vend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Y,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;IACxE,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;KACrE;IACD,OAAO,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;AAC/F,CAAC"}
|
||||
8
node_modules/yaml-language-server/lib/esm/languageservice/services/yamlFormatter.d.ts
generated
vendored
Normal file
8
node_modules/yaml-language-server/lib/esm/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[];
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user