From 520a328beb0b82b1ee9d5c3beaa9bcc5d47fd538 Mon Sep 17 00:00:00 2001 From: Yevhen Vydolob Date: Tue, 30 Nov 2021 11:06:49 +0200 Subject: [PATCH] Add methods which allow client get schemas info (#556) * Add methods which allow client get schemas info Signed-off-by: Yevhen Vydolob * fix review comment Signed-off-by: Yevhen Vydolob * Delete commented line Signed-off-by: Yevhen Vydolob --- README.md | 84 +++++++++++++ .../handlers/notificationHandlers.ts | 6 + .../handlers/schemaSelectionHandlers.ts | 84 +++++++++++++ .../handlers/settingsHandlers.ts | 8 +- src/languageservice/services/yamlCodeLens.ts | 46 +------- src/languageservice/utils/schemaUrls.ts | 47 ++++++++ src/languageservice/yamlLanguageService.ts | 6 + src/requestTypes.ts | 7 ++ src/yamlServerInit.ts | 1 + src/yamlSettings.ts | 1 + test/schemaSelectionHandlers.test.ts | 111 ++++++++++++++++++ test/yamlCodeLens.test.ts | 32 +++-- 12 files changed, 375 insertions(+), 58 deletions(-) create mode 100644 src/languageserver/handlers/schemaSelectionHandlers.ts create mode 100644 test/schemaSelectionHandlers.test.ts diff --git a/README.md b/README.md index ceb5b88a..d5499da5 100755 --- a/README.md +++ b/README.md @@ -254,6 +254,90 @@ docker run -it quay.io/redhat-developer/yaml-language-server:latest `yaml-language-server` use `vscode-languageserver@7.0.0` which implements [LSP 3.16](https://github.com/Microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md) +## Language Server Protocol extensions + +### SchemaSelectionRequests + +#### SupportSchemaSelection Notification + +The support schema selection notification is sent from a client to the server to inform server that client supports JSON Schema selection. + +_Notification:_ +- method: `'yaml/supportSchemaSelection'` +- params: `void` + +#### SchemaStoreInitialized Notification + +The schema store initialized notification is sent from the server to a client to inform client that server has finished initializing/loading schemas from schema store, and client now can ask for schemas. + +_Notification:_ +- method: `'yaml/schema/store/initialized'` +- params: `void` + +#### GetAllSchemas Request + +The get all schemas request sent from a client to server to get all known schemas. + +_Request:_ +- method: `'yaml/get/all/jsonSchemas'`; +- params: the document uri, server will mark used schema for document + +_Response:_ + +- result: `JSONSchemaDescriptionExt[]` +```typescript +interface JSONSchemaDescriptionExt { + /** + * Schema URI + */ + uri: string; + /** + * Schema name, from schema store + */ + name?: string; + /** + * Schema description, from schema store + */ + description?: string; + /** + * Is schema used for current document + */ + usedForCurrentFile: boolean; + /** + * Is schema from schema store + */ + fromStore: boolean; +} +``` + +#### GetSchemas Request + +The request sent from a client to server to get schemas used for current document. Client can use this method to indicate in UI which schemas used for current YAML document. + +_Request:_ +- method: `'yaml/get/jsonSchema'`; +- params: the document uri to get used schemas + +_Response:_ +- result: `JSONSchemaDescription[]` + +```typescript +interface JSONSchemaDescriptionExt { + /** + * Schema URI + */ + uri: string; + /** + * Schema name, from schema store + */ + name?: string; + /** + * Schema description, from schema store + */ + description?: string; +} +``` + ## Clients This repository only contains the server implementation. Here are some known clients consuming this server: diff --git a/src/languageserver/handlers/notificationHandlers.ts b/src/languageserver/handlers/notificationHandlers.ts index 75159d46..9f70a1b0 100644 --- a/src/languageserver/handlers/notificationHandlers.ts +++ b/src/languageserver/handlers/notificationHandlers.ts @@ -9,6 +9,7 @@ import { CustomSchemaRequest, DynamicCustomSchemaRequestRegistration, SchemaAssociationNotification, + SchemaSelectionRequests, VSCodeContentRequestRegistration, } from '../../requestTypes'; import { SettingsState } from '../../yamlSettings'; @@ -36,6 +37,7 @@ export class NotificationHandlers { ); this.connection.onNotification(DynamicCustomSchemaRequestRegistration.type, () => this.dynamicSchemaRequestHandler()); this.connection.onNotification(VSCodeContentRequestRegistration.type, () => this.vscodeContentRequestHandler()); + this.connection.onNotification(SchemaSelectionRequests.type, () => this.schemaSelectionRequestHandler()); } /** @@ -68,4 +70,8 @@ export class NotificationHandlers { private vscodeContentRequestHandler(): void { this.yamlSettings.useVSCodeContentRequest = true; } + + private schemaSelectionRequestHandler(): void { + this.yamlSettings.useSchemaSelectionRequests = true; + } } diff --git a/src/languageserver/handlers/schemaSelectionHandlers.ts b/src/languageserver/handlers/schemaSelectionHandlers.ts new file mode 100644 index 00000000..ac8d756e --- /dev/null +++ b/src/languageserver/handlers/schemaSelectionHandlers.ts @@ -0,0 +1,84 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Red Hat, Inc. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Connection } from 'vscode-languageserver/node'; +import { JSONSchema } from '../../languageservice/jsonSchema'; +import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents'; +import { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService'; +import { getSchemaUrls } from '../../languageservice/utils/schemaUrls'; +import { SettingsState } from '../../yamlSettings'; +import { JSONSchemaDescription, JSONSchemaDescriptionExt, SchemaSelectionRequests } from '../../requestTypes'; + +export class JSONSchemaSelection { + constructor( + private readonly schemaService: YAMLSchemaService, + private readonly yamlSettings: SettingsState, + private readonly 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: string): Promise { + const schemas = await this.getSchemasForFile(docUri); + const result = Array.from(schemas).map((val) => { + return { + name: val[1].title, + uri: val[0], + description: val[1].description, + }; + }); + + return result; + } + + private async getSchemasForFile(docUri: string): Promise> { + 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: string): Promise { + const fileSchemas = await this.getSchemasForFile(docUri); + const fileSchemasHandle: JSONSchemaDescriptionExt[] = Array.from(fileSchemas.entries()).map((val) => { + return { + uri: val[0], + fromStore: false, + usedForCurrentFile: true, + name: val[1].title, + description: val[1].description, + }; + }); + const result = []; + let allSchemas = this.schemaService.getAllSchemas(); + allSchemas = allSchemas.filter((val) => !fileSchemas.has(val.uri)); + result.push(...fileSchemasHandle); + result.push(...allSchemas); + + return result; + } +} diff --git a/src/languageserver/handlers/settingsHandlers.ts b/src/languageserver/handlers/settingsHandlers.ts index 608a6723..60b64d6f 100644 --- a/src/languageserver/handlers/settingsHandlers.ts +++ b/src/languageserver/handlers/settingsHandlers.ts @@ -7,6 +7,7 @@ import { DocumentFormattingRequest, Connection, DidChangeConfigurationNotificati import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths'; import { checkSchemaURI, JSON_SCHEMASTORE_URL, KUBERNETES_SCHEMA_URL } from '../../languageservice/utils/schemaUrls'; import { LanguageService, LanguageSettings, SchemaPriority } from '../../languageservice/yamlLanguageService'; +import { SchemaSelectionRequests } from '../../requestTypes'; import { Settings, SettingsState } from '../../yamlSettings'; import { Telemetry } from '../telemetry'; import { ValidationHandler } from './validationHandlers'; @@ -53,7 +54,7 @@ export class SettingsHandler { this.setConfiguration(settings); } - setConfiguration(settings: Settings): void { + async setConfiguration(settings: Settings): Promise { configureHttpRequests(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL); this.yamlSettings.specificValidatorPaths = []; @@ -120,8 +121,11 @@ export class SettingsHandler { this.yamlSettings.schemaConfigurationSettings.push(schemaObj); } - this.setSchemaStoreSettingsIfNotSet(); + await this.setSchemaStoreSettingsIfNotSet(); this.updateConfiguration(); + if (this.yamlSettings.useSchemaSelectionRequests) { + this.connection.sendNotification(SchemaSelectionRequests.schemaStoreInitialized, {}); + } // dynamically enable & disable the formatter if (this.yamlSettings.clientDynamicRegisterSupport) { diff --git a/src/languageservice/services/yamlCodeLens.ts b/src/languageservice/services/yamlCodeLens.ts index d1f96bca..71f529ec 100644 --- a/src/languageservice/services/yamlCodeLens.ts +++ b/src/languageservice/services/yamlCodeLens.ts @@ -10,10 +10,10 @@ import { yamlDocumentsCache } from '../parser/yaml-documents'; import { YAMLSchemaService } from './yamlSchemaService'; import { URI } from 'vscode-uri'; import * as path from 'path'; -import { JSONSchema, JSONSchemaRef } from '../jsonSchema'; +import { JSONSchema } from '../jsonSchema'; import { CodeLensParams } from 'vscode-languageserver-protocol'; -import { isBoolean } from '../utils/objects'; import { Telemetry } from '../../languageserver/telemetry'; +import { getSchemaUrls } from '../utils/schemaUrls'; export class YamlCodeLens { constructor(private schemaService: YAMLSchemaService, private readonly telemetry: Telemetry) {} @@ -26,7 +26,7 @@ export class YamlCodeLens { for (const currentYAMLDoc of yamlDocument.documents) { const schema = await this.schemaService.getSchemaForResource(document.uri, currentYAMLDoc); if (schema?.schema) { - const schemaUrls = getSchemaUrl(schema?.schema); + const schemaUrls = getSchemaUrls(schema?.schema); if (schemaUrls.size === 0) { continue; } @@ -66,43 +66,3 @@ function getCommandTitle(url: string, schema: JSONSchema): string { return baseName; } - -function getSchemaUrl(schema: JSONSchema): Map { - const result = new Map(); - if (!schema) { - return result; - } - const url = schema.url; - if (url) { - if (url.startsWith('schemaservice://combinedSchema/')) { - addSchemasForOf(schema, result); - } else { - result.set(schema.url, schema); - } - } else { - addSchemasForOf(schema, result); - } - return result; -} - -function addSchemasForOf(schema: JSONSchema, result: Map): void { - if (schema.allOf) { - addInnerSchemaUrls(schema.allOf, result); - } - if (schema.anyOf) { - addInnerSchemaUrls(schema.anyOf, result); - } - if (schema.oneOf) { - addInnerSchemaUrls(schema.oneOf, result); - } -} - -function addInnerSchemaUrls(schemas: JSONSchemaRef[], result: Map): void { - for (const subSchema of schemas) { - if (!isBoolean(subSchema)) { - if (subSchema.url && !result.has(subSchema.url)) { - result.set(subSchema.url, subSchema); - } - } - } -} diff --git a/src/languageservice/utils/schemaUrls.ts b/src/languageservice/utils/schemaUrls.ts index 78e999bd..a61f4fbc 100644 --- a/src/languageservice/utils/schemaUrls.ts +++ b/src/languageservice/utils/schemaUrls.ts @@ -1,6 +1,8 @@ import { WorkspaceFolder } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; import { Telemetry } from '../../languageserver/telemetry'; +import { JSONSchema, JSONSchemaRef } from '../jsonSchema'; +import { isBoolean } from './objects'; import { isRelativePath, relativeToAbsolutePath } from './paths'; export const KUBERNETES_SCHEMA_URL = @@ -22,3 +24,48 @@ export function checkSchemaURI( return uri; } } + +/** + * Collect all urls of sub schemas + * @param schema the root schema + * @returns map url to schema + */ +export function getSchemaUrls(schema: JSONSchema): Map { + const result = new Map(); + if (!schema) { + return result; + } + + if (schema.url) { + if (schema.url.startsWith('schemaservice://combinedSchema/')) { + addSchemasForOf(schema, result); + } else { + result.set(schema.url, schema); + } + } else { + addSchemasForOf(schema, result); + } + return result; +} + +function addSchemasForOf(schema: JSONSchema, result: Map): void { + if (schema.allOf) { + addInnerSchemaUrls(schema.allOf, result); + } + if (schema.anyOf) { + addInnerSchemaUrls(schema.anyOf, result); + } + if (schema.oneOf) { + addInnerSchemaUrls(schema.oneOf, result); + } +} + +function addInnerSchemaUrls(schemas: JSONSchemaRef[], result: Map): void { + for (const subSchema of schemas) { + if (!isBoolean(subSchema)) { + if (subSchema.url && !result.has(subSchema.url)) { + result.set(subSchema.url, subSchema); + } + } + } +} diff --git a/src/languageservice/yamlLanguageService.ts b/src/languageservice/yamlLanguageService.ts index ad90fc2b..c56195bc 100644 --- a/src/languageservice/yamlLanguageService.ts +++ b/src/languageservice/yamlLanguageService.ts @@ -52,6 +52,8 @@ import { Telemetry } from '../languageserver/telemetry'; import { YamlVersion } from './parser/yamlParser07'; import { YamlCompletion } from './services/yamlCompletion'; import { yamlDocumentsCache } from './parser/yaml-documents'; +import { SettingsState } from '../yamlSettings'; +import { JSONSchemaSelection } from '../languageserver/handlers/schemaSelectionHandlers'; import { getDefinition } from './services/yamlDefinition'; export enum SchemaPriority { @@ -159,6 +161,7 @@ export function getLanguageService( workspaceContext: WorkspaceContextService, connection: Connection, telemetry: Telemetry, + yamlSettings: SettingsState, clientCapabilities?: ClientCapabilities ): LanguageService { const schemaService = new YAMLSchemaService(schemaRequestService, workspaceContext); @@ -169,6 +172,9 @@ export function getLanguageService( const formatter = new YAMLFormatter(); const yamlCodeActions = new YamlCodeActions(clientCapabilities); const yamlCodeLens = new YamlCodeLens(schemaService, telemetry); + + new JSONSchemaSelection(schemaService, yamlSettings, connection); + // register all commands registerCommands(commandExecutor, connection); return { diff --git a/src/requestTypes.ts b/src/requestTypes.ts index 7a306de1..2708f88c 100644 --- a/src/requestTypes.ts +++ b/src/requestTypes.ts @@ -70,3 +70,10 @@ export namespace ColorSymbolRequest { export namespace SchemaModificationNotification { export const type: RequestType = new RequestType('json/schema/modify'); } + +export namespace SchemaSelectionRequests { + export const type: NotificationType = new NotificationType('yaml/supportSchemaSelection'); + export const getSchema: RequestType = new RequestType('yaml/get/jsonSchema'); + export const getAllSchemas: RequestType = new RequestType('yaml/get/all/jsonSchemas'); + export const schemaStoreInitialized: NotificationType<{}> = new NotificationType('yaml/schema/store/initialized'); +} diff --git a/src/yamlServerInit.ts b/src/yamlServerInit.ts index 70174122..d81e4537 100644 --- a/src/yamlServerInit.ts +++ b/src/yamlServerInit.ts @@ -63,6 +63,7 @@ export class YAMLServerInit { this.workspaceContext, this.connection, this.telemetry, + this.yamlSettings, params.capabilities ); diff --git a/src/yamlSettings.ts b/src/yamlSettings.ts index 027a587d..a782d22c 100644 --- a/src/yamlSettings.ts +++ b/src/yamlSettings.ts @@ -84,6 +84,7 @@ export class SettingsState { hasConfigurationCapability = false; useVSCodeContentRequest = false; yamlVersion: YamlVersion = '1.2'; + useSchemaSelectionRequests = false; hasWsChangeWatchedFileDynamicRegistration = false; } diff --git a/test/schemaSelectionHandlers.test.ts b/test/schemaSelectionHandlers.test.ts new file mode 100644 index 00000000..8e13f7ec --- /dev/null +++ b/test/schemaSelectionHandlers.test.ts @@ -0,0 +1,111 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Red Hat, Inc. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import * as sinon from 'sinon'; +import * as chai from 'chai'; +import * as sinonChai from 'sinon-chai'; +import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers'; +import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService'; +import { Connection, RemoteClient } from 'vscode-languageserver/node'; +import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings'; +import { SchemaSelectionRequests } from '../src/requestTypes'; +import { SCHEMA_ID, setupSchemaIDTextDocument } from './utils/testHelper'; + +const expect = chai.expect; +chai.use(sinonChai); + +describe('Schema Selection Handlers', () => { + const sandbox = sinon.createSandbox(); + const connection: Connection = {} as Connection; + let service: YAMLSchemaService; + let requestServiceMock: sinon.SinonSpy; + + beforeEach(() => { + requestServiceMock = sandbox.fake.resolves(undefined); + service = new YAMLSchemaService(requestServiceMock); + connection.client = {} as RemoteClient; + const onRequest = sandbox.fake(); + connection.onRequest = onRequest; + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('add handler for "getSchema" and "getAllSchemas" requests', () => { + new JSONSchemaSelection(service, new SettingsState(), connection); + expect(connection.onRequest).calledWith(SchemaSelectionRequests.getSchema); + expect(connection.onRequest).calledWith(SchemaSelectionRequests.getAllSchemas); + }); + + it('getAllSchemas should return all schemas', async () => { + service.registerExternalSchema('https://some.com/some.json', ['foo.yaml'], undefined, 'Schema name', 'Schema description'); + const settings = new SettingsState(); + const testTextDocument = setupSchemaIDTextDocument(''); + settings.documents = new TextDocumentTestManager(); + (settings.documents as TextDocumentTestManager).set(testTextDocument); + const selection = new JSONSchemaSelection(service, settings, connection); + + const result = await selection.getAllSchemas(testTextDocument.uri); + + expect(result).length(1); + expect(result[0]).to.be.eqls({ + uri: 'https://some.com/some.json', + fromStore: true, + usedForCurrentFile: false, + name: 'Schema name', + description: 'Schema description', + }); + }); + + it('getAllSchemas should return all schemas and mark used for current file', async () => { + service.registerExternalSchema('https://some.com/some.json', [SCHEMA_ID], undefined, 'Schema name', 'Schema description'); + const settings = new SettingsState(); + const testTextDocument = setupSchemaIDTextDocument(''); + settings.documents = new TextDocumentTestManager(); + (settings.documents as TextDocumentTestManager).set(testTextDocument); + const selection = new JSONSchemaSelection(service, settings, connection); + + const result = await selection.getAllSchemas(testTextDocument.uri); + + expect(result).length(1); + expect(result[0]).to.be.eqls({ + uri: 'https://some.com/some.json', + fromStore: false, + usedForCurrentFile: true, + name: 'Schema name', + description: 'Schema description', + }); + }); + + it('getSchemas should return all schemas', async () => { + service.registerExternalSchema('https://some.com/some.json', [SCHEMA_ID], undefined, 'Schema name', 'Schema description'); + const settings = new SettingsState(); + const testTextDocument = setupSchemaIDTextDocument(''); + settings.documents = new TextDocumentTestManager(); + (settings.documents as TextDocumentTestManager).set(testTextDocument); + const selection = new JSONSchemaSelection(service, settings, connection); + + const result = await selection.getSchemas(testTextDocument.uri); + + expect(result).length(1); + expect(result[0]).to.be.eqls({ + uri: 'https://some.com/some.json', + name: 'Schema name', + description: 'Schema description', + }); + }); + + it('getSchemas should handle empty schemas', async () => { + const settings = new SettingsState(); + const testTextDocument = setupSchemaIDTextDocument(''); + settings.documents = new TextDocumentTestManager(); + (settings.documents as TextDocumentTestManager).set(testTextDocument); + const selection = new JSONSchemaSelection(service, settings, connection); + + const result = await selection.getSchemas(testTextDocument.uri); + + expect(result).length(0); + }); +}); diff --git a/test/yamlCodeLens.test.ts b/test/yamlCodeLens.test.ts index e3cb20f1..824bf8c8 100644 --- a/test/yamlCodeLens.test.ts +++ b/test/yamlCodeLens.test.ts @@ -32,17 +32,17 @@ describe('YAML CodeLens', () => { sandbox.restore(); }); - function createCommand(title: string, arg: string): Command { + function createCommand(title: string, command: string, arg: string): Command { return { title, - command: YamlCommands.JUMP_TO_SCHEMA, + command, arguments: [arg], }; } - function createCodeLens(title: string, arg: string): CodeLens { + function createCodeLens(title: string, command: string, arg: string): CodeLens { const lens = CodeLens.create(Range.create(0, 0, 0, 0)); - lens.command = createCommand(title, arg); + lens.command = createCommand(title, command, arg); return lens; } @@ -56,7 +56,9 @@ describe('YAML CodeLens', () => { const result = await codeLens.getCodeLens(doc, { textDocument: { uri: doc.uri } }); expect(result).is.not.empty; expect(result[0].command).is.not.undefined; - expect(result[0].command).is.deep.equal(createCommand('schema.json', 'some://url/to/schema.json')); + expect(result[0].command).is.deep.equal( + createCommand('schema.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/to/schema.json') + ); }); it('should place CodeLens at beginning of the file and it has command', async () => { @@ -68,7 +70,9 @@ describe('YAML CodeLens', () => { const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc, { textDocument: { uri: doc.uri } }); expect(result[0].range).is.deep.equal(Range.create(0, 0, 0, 0)); - expect(result[0].command).is.deep.equal(createCommand('schema.json', 'some://url/to/schema.json')); + expect(result[0].command).is.deep.equal( + createCommand('schema.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/to/schema.json') + ); }); it('command name should contains schema title', async () => { @@ -80,7 +84,9 @@ describe('YAML CodeLens', () => { yamlSchemaService.getSchemaForResource.resolves({ schema }); const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc, { textDocument: { uri: doc.uri } }); - expect(result[0].command).is.deep.equal(createCommand('fooBar (schema.json)', 'some://url/to/schema.json')); + expect(result[0].command).is.deep.equal( + createCommand('fooBar (schema.json)', YamlCommands.JUMP_TO_SCHEMA, 'some://url/to/schema.json') + ); }); it('should provide lens for oneOf schemas', async () => { @@ -100,8 +106,8 @@ describe('YAML CodeLens', () => { const result = await codeLens.getCodeLens(doc, { textDocument: { uri: doc.uri } }); expect(result).has.length(2); expect(result).is.deep.equal([ - createCodeLens('schema1.json', 'some://url/schema1.json'), - createCodeLens('schema2.json', 'some://url/schema2.json'), + createCodeLens('schema1.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/schema1.json'), + createCodeLens('schema2.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/schema2.json'), ]); }); @@ -122,8 +128,8 @@ describe('YAML CodeLens', () => { const result = await codeLens.getCodeLens(doc, { textDocument: { uri: doc.uri } }); expect(result).has.length(2); expect(result).is.deep.equal([ - createCodeLens('schema1.json', 'some://url/schema1.json'), - createCodeLens('schema2.json', 'some://url/schema2.json'), + createCodeLens('schema1.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/schema1.json'), + createCodeLens('schema2.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/schema2.json'), ]); }); @@ -144,8 +150,8 @@ describe('YAML CodeLens', () => { const result = await codeLens.getCodeLens(doc, { textDocument: { uri: doc.uri } }); expect(result).has.length(2); expect(result).is.deep.equal([ - createCodeLens('schema1.json', 'some://url/schema1.json'), - createCodeLens('schema2.json', 'some://url/schema2.json'), + createCodeLens('schema1.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/schema1.json'), + createCodeLens('schema2.json', YamlCommands.JUMP_TO_SCHEMA, 'some://url/schema2.json'), ]); }); });