Updates dockerfile
All checks were successful
Build and Push / build (push) Successful in 55s

This commit is contained in:
2026-02-16 15:09:37 -05:00
parent 8346776f2a
commit d181f77fb2
14943 changed files with 2078509 additions and 16 deletions

View 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;

View File

@@ -0,0 +1,35 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.commandExecutor = exports.CommandExecutor = void 0;
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);
}
}
exports.CommandExecutor = CommandExecutor;
exports.commandExecutor = new CommandExecutor();
});
//# sourceMappingURL=commandExecutor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"commandExecutor.js","sourceRoot":"","sources":["../../../src/languageserver/commandExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAQhG,MAAa,eAAe;QAA5B;YACU,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;QAYvD,CAAC;QAXC,cAAc,CAAC,MAA4B;YACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;gBACrC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAClD,OAAO,OAAO,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;aACrC;YACD,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;QAC3D,CAAC;QAED,eAAe,CAAC,SAAiB,EAAE,OAAuB;YACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;KACF;IAbD,0CAaC;IAEY,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}

View 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;
}

View File

@@ -0,0 +1,212 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../languageservice/parser/isKubernetes", "../../requestTypes", "path"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LanguageHandlers = void 0;
const isKubernetes_1 = require("../../languageservice/parser/isKubernetes");
const requestTypes_1 = require("../../requestTypes");
const path = require("path");
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, (0, isKubernetes_1.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(requestTypes_1.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;
}
};
}
}
exports.LanguageHandlers = LanguageHandlers;
});
//# sourceMappingURL=languageHandlers.js.map

File diff suppressed because one or more lines are too long

View 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;
}

View File

@@ -0,0 +1,60 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../requestTypes"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationHandlers = void 0;
const requestTypes_1 = require("../../requestTypes");
class NotificationHandlers {
constructor(connection, languageService, yamlSettings, settingsHandler) {
this.connection = connection;
this.languageService = languageService;
this.yamlSettings = yamlSettings;
this.settingsHandler = settingsHandler;
}
registerHandlers() {
this.connection.onNotification(requestTypes_1.SchemaAssociationNotification.type, (associations) => this.schemaAssociationNotificationHandler(associations));
this.connection.onNotification(requestTypes_1.DynamicCustomSchemaRequestRegistration.type, () => this.dynamicSchemaRequestHandler());
this.connection.onNotification(requestTypes_1.VSCodeContentRequestRegistration.type, () => this.vscodeContentRequestHandler());
this.connection.onNotification(requestTypes_1.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(requestTypes_1.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;
}
}
exports.NotificationHandlers = NotificationHandlers;
});
//# sourceMappingURL=notificationHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"notificationHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/notificationHandlers.ts"],"names":[],"mappings":";;;;;;;;;;;;IAOA,qDAM4B;IAI5B,MAAa,oBAAoB;QAK/B,YACmB,UAAsB,EACvC,eAAgC,EAChC,YAA2B,EAC3B,eAAgC;YAHf,eAAU,GAAV,UAAU,CAAY;YAKvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;YACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;YACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACzC,CAAC;QAEM,gBAAgB;YACrB,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,4CAA6B,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,EAAE,CAClF,IAAI,CAAC,oCAAoC,CAAC,YAAY,CAAC,CACxD,CAAC;YACF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,qDAAsC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;YACtH,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,+CAAgC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;YAChH,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,sCAAuB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC,CAAC;QAC3G,CAAC;QAED;;;WAGG;QACK,oCAAoC,CAAC,YAA8D;YACzG,IAAI,CAAC,YAAY,CAAC,kBAAkB,GAAG,YAAY,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,sBAAsB,GAAG,EAAE,CAAC;YAC9C,IAAI,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QAChF,CAAC;QAED;;;WAGG;QACK,2BAA2B;YACjC,MAAM,cAAc,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACnC,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,kCAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzE,CAAC,CAAyB,CAAC;YAC3B,IAAI,CAAC,eAAe,CAAC,4BAA4B,CAAC,cAAc,CAAC,CAAC;QACpE,CAAC;QAED;;;;WAIG;QACK,2BAA2B;YACjC,IAAI,CAAC,YAAY,CAAC,uBAAuB,GAAG,IAAI,CAAC;QACnD,CAAC;QAEO,6BAA6B;YACnC,IAAI,CAAC,YAAY,CAAC,0BAA0B,GAAG,IAAI,CAAC;QACtD,CAAC;KACF;IA1DD,oDA0DC"}

View 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;
}

View File

@@ -0,0 +1,37 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../languageservice/services/yamlSchemaService", "../../requestTypes"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequestHandlers = void 0;
const yamlSchemaService_1 = require("../../languageservice/services/yamlSchemaService");
const requestTypes_1 = require("../../requestTypes");
class RequestHandlers {
constructor(connection, languageService) {
this.connection = connection;
this.languageService = languageService;
}
registerHandlers() {
this.connection.onRequest(requestTypes_1.SchemaModificationNotification.type, (modifications) => this.registerSchemaModificationNotificationHandler(modifications));
}
registerSchemaModificationNotificationHandler(modifications) {
if (modifications.action === yamlSchemaService_1.MODIFICATION_ACTIONS.add) {
this.languageService.modifySchemaContent(modifications);
}
else if (modifications.action === yamlSchemaService_1.MODIFICATION_ACTIONS.delete) {
this.languageService.deleteSchemaContent(modifications);
}
else if (modifications.action === yamlSchemaService_1.MODIFICATION_ACTIONS.deleteAll) {
this.languageService.deleteSchemasWhole(modifications);
}
}
}
exports.RequestHandlers = RequestHandlers;
});
//# sourceMappingURL=requestHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/requestHandlers.ts"],"names":[],"mappings":";;;;;;;;;;;;IAKA,wFAK0D;IAE1D,qDAAoE;IAEpE,MAAa,eAAe;QAE1B,YAA6B,UAAsB,EAAE,eAAgC;YAAxD,eAAU,GAAV,UAAU,CAAY;YACjD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACzC,CAAC;QAEM,gBAAgB;YACrB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,6CAA8B,CAAC,IAAI,EAAE,CAAC,aAAa,EAAE,EAAE,CAC/E,IAAI,CAAC,6CAA6C,CAAC,aAAa,CAAC,CAClE,CAAC;QACJ,CAAC;QAEO,6CAA6C,CACnD,aAAqE;YAErE,IAAI,aAAa,CAAC,MAAM,KAAK,wCAAoB,CAAC,GAAG,EAAE;gBACrD,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;aACzD;iBAAM,IAAI,aAAa,CAAC,MAAM,KAAK,wCAAoB,CAAC,MAAM,EAAE;gBAC/D,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;aACzD;iBAAM,IAAI,aAAa,CAAC,MAAM,KAAK,wCAAoB,CAAC,SAAS,EAAE;gBAClE,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;aACxD;QACH,CAAC;KACF;IAvBD,0CAuBC"}

View 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[]>;
}

View File

@@ -0,0 +1,86 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../languageservice/parser/yaml-documents", "../../languageservice/utils/schemaUrls", "../../requestTypes"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JSONSchemaSelection = void 0;
const yaml_documents_1 = require("../../languageservice/parser/yaml-documents");
const schemaUrls_1 = require("../../languageservice/utils/schemaUrls");
const requestTypes_1 = require("../../requestTypes");
class JSONSchemaSelection {
constructor(schemaService, yamlSettings, connection) {
this.schemaService = schemaService;
this.yamlSettings = yamlSettings;
this.connection = connection;
this.connection?.onRequest(requestTypes_1.SchemaSelectionRequests.getSchema, (fileUri) => {
return this.getSchemas(fileUri);
});
this.connection?.onRequest(requestTypes_1.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 = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
for (const currentYAMLDoc of yamlDoc.documents) {
const schema = await this.schemaService.getSchemaForResource(document.uri, currentYAMLDoc);
if (schema?.schema) {
const schemaUrls = (0, schemaUrls_1.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;
}
}
exports.JSONSchemaSelection = JSONSchemaSelection;
});
//# sourceMappingURL=schemaSelectionHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"schemaSelectionHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/schemaSelectionHandlers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAIhG,gFAAiF;IAEjF,uEAAuE;IAEvE,qDAA8G;IAE9G,MAAa,mBAAmB;QAC9B,YACmB,aAAgC,EAChC,YAA4B,EAC5B,UAAuB;YAFvB,kBAAa,GAAb,aAAa,CAAmB;YAChC,iBAAY,GAAZ,YAAY,CAAgB;YAC5B,eAAU,GAAV,UAAU,CAAa;YAExC,IAAI,CAAC,UAAU,EAAE,S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AI,CAAC,GAAG,iBAAiB,CAAC,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;YAE3B,OAAO,MAAM,CAAC;QAChB,CAAC;KACF;IAtED,kDAsEC"}

View 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;
}

View File

@@ -0,0 +1,313 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "request-light", "vscode-languageserver", "../../languageservice/utils/objects", "../../languageservice/utils/paths", "../../languageservice/utils/schemaUrls", "../../languageservice/yamlLanguageService", "../../requestTypes"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingsHandler = void 0;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const request_light_1 = require("request-light");
const vscode_languageserver_1 = require("vscode-languageserver");
const objects_1 = require("../../languageservice/utils/objects");
const paths_1 = require("../../languageservice/utils/paths");
const schemaUrls_1 = require("../../languageservice/utils/schemaUrls");
const yamlLanguageService_1 = require("../../languageservice/yamlLanguageService");
const requestTypes_1 = require("../../requestTypes");
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(vscode_languageserver_1.DidChangeConfigurationNotification.type);
}
catch (err) {
this.telemetry.sendError('yaml.settings.error', { error: (0, objects_1.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) {
(0, request_light_1.configure)(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: (0, schemaUrls_1.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(requestTypes_1.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(vscode_languageserver_1.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 = schemaUrls_1.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 (0, request_light_1.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: yamlLanguageService_1.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, yamlLanguageService_1.SchemaPriority.SchemaAssociation);
});
}
else {
for (const uri in this.yamlSettings.schemaAssociations) {
const fileMatch = this.yamlSettings.schemaAssociations[uri];
languageSettings = this.configureSchemas(uri, fileMatch, null, languageSettings, yamlLanguageService_1.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 ((0, paths_1.isRelativePath)(uri)) {
uri = (0, paths_1.relativeToAbsolutePath)(this.yamlSettings.workspaceFolders, this.yamlSettings.workspaceRoot, uri);
}
languageSettings = this.configureSchemas(uri, schema.fileMatch, schema.schema, languageSettings, yamlLanguageService_1.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 = (0, schemaUrls_1.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 === schemaUrls_1.KUBERNETES_SCHEMA_URL) {
fileMatch.forEach((url) => {
this.yamlSettings.specificValidatorPaths.push(url);
});
}
else if (uri === schemaUrls_1.KUBERNETES_SCHEMA_URL) {
this.yamlSettings.specificValidatorPaths.push(fileMatch);
}
return languageSettings;
}
}
exports.SettingsHandler = SettingsHandler;
});
//# sourceMappingURL=settingsHandlers.js.map

File diff suppressed because one or more lines are too long

View 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[]>;
}

View File

@@ -0,0 +1,68 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../languageservice/parser/isKubernetes", "../../languageservice/utils/arrUtils"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidationHandler = void 0;
const isKubernetes_1 = require("../../languageservice/parser/isKubernetes");
const arrUtils_1 = require("../../languageservice/utils/arrUtils");
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, (0, isKubernetes_1.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 = (0, arrUtils_1.removeDuplicatesObj)(diagnostics);
this.connection.sendDiagnostics({
uri: textDocument.uri,
diagnostics: removeDuplicatesDiagnostics,
});
return removeDuplicatesDiagnostics;
});
}
}
exports.ValidationHandler = ValidationHandler;
});
//# sourceMappingURL=validationHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"validationHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/validationHandlers.ts"],"names":[],"mappings":";;;;;;;;;;;;IAOA,4EAA2F;IAC3F,mEAA2E;IAI3E,MAAa,iBAAiB;QAI5B,YAA6B,UAAsB,EAAE,eAAgC,EAAE,YAA2B;YAArF,eAAU,GAAV,UAAU,CAAY;YACjD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;YACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;YAEjC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,MAAM,EAAE,EAAE;gBACxD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,IAAI,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AC1B,MAAM,WAAW,GAAiB,EAAE,CAAC;gBACrC,KAAK,MAAM,cAAc,IAAI,iBAAiB,EAAE;oBAC9C,iCAAiC;oBACjC,IAAI,cAAc,CAAC,QAAQ,KAAK,CAAC,EAAE;wBACjC,cAAc,CAAC,QAAQ,GAAG,CAAC,CAAC;qBAC7B;oBACD,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;iBAClC;gBAED,MAAM,2BAA2B,GAAG,IAAA,8BAAmB,EAAC,WAAW,CAAC,CAAC;gBACrE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;oBAC9B,GAAG,EAAE,YAAY,CAAC,GAAG;oBACrB,WAAW,EAAE,2BAA2B;iBACzC,CAAC,CAAC;gBACH,OAAO,2BAA2B,CAAC;YACrC,CAAC,CAAC,CAAC;QACP,CAAC;KACF;IA3DD,8CA2DC"}

View 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;
}

View File

@@ -0,0 +1,31 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkspaceHandlers = void 0;
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);
}
}
exports.WorkspaceHandlers = WorkspaceHandlers;
});
//# sourceMappingURL=workspaceHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"workspaceHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/workspaceHandlers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAKhG,MAAa,iBAAiB;QAC5B,YAA6B,UAAsB,EAAmB,eAAgC;YAAzE,eAAU,GAAV,UAAU,CAAY;YAAmB,oBAAe,GAAf,eAAe,CAAiB;QAAG,CAAC;QAE1G,gBAAgB;YACd,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5E,CAAC;QAEO,cAAc,CAAC,MAA4B;YACjD,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;KACF;IAVD,8CAUC"}

View 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;
}

View File

@@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TelemetryImpl = void 0;
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 });
}
}
exports.TelemetryImpl = TelemetryImpl;
});
//# sourceMappingURL=telemetry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../src/languageserver/telemetry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAKhG,MAAa,aAAa;QACxB,YAA6B,UAAsB;YAAtB,eAAU,GAAV,UAAU,CAAY;QAAG,CAAC;QAEvD,IAAI,CAAC,KAAqB;YACxB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QAED,SAAS,CAAC,IAAY,EAAE,UAAmB;YACzC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,SAAS,CAAC,IAAY,EAAE,UAAmB;YACzC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;QAC7D,CAAC;KACF;IAdD,sCAcC"}