forked from redhat-developer/vscode-yaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code action to open json schema (redhat-developer#395)
* add code action to open json schema Signed-off-by: Yevhen Vydolob <[email protected]> * Fix eslint warning, fix review comments Signed-off-by: Yevhen Vydolob <[email protected]> * Fix tests Signed-off-by: Yevhen Vydolob <[email protected]> * simplify code actions implementation Signed-off-by: Yevhen Vydolob <[email protected]> * add code action to open schema only if 'showDocument' supported Signed-off-by: Yevhen Vydolob <[email protected]> * Fix tests Signed-off-by: Yevhen Vydolob <[email protected]> * fix test Signed-off-by: Yevhen Vydolob <[email protected]> * Add supported protocol version in readme Signed-off-by: Yevhen Vydolob <[email protected]>
- Loading branch information
Showing
29 changed files
with
581 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,6 +234,10 @@ To run the image you can use: | |
docker run -it quay.io/redhat-developer/yaml-language-server:latest | ||
``` | ||
|
||
## Language Server Protocol version | ||
|
||
`yaml-language-server` use `[email protected]` which implements [LSP 3.16](https://github.com/Microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md) | ||
|
||
## Clients | ||
|
||
This repository only contains the server implementation. Here are some known clients consuming this server: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
export enum YamlCommands { | ||
JUMP_TO_SCHEMA = 'jumpToSchema', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { ExecuteCommandParams } from 'vscode-languageserver'; | ||
|
||
export interface CommandHandler { | ||
(...args: unknown[]): void; | ||
} | ||
|
||
export class CommandExecutor { | ||
private commands = new Map<string, CommandHandler>(); | ||
executeCommand(params: ExecuteCommandParams): void { | ||
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: string, handler: CommandHandler): void { | ||
this.commands.set(commandId, handler); | ||
} | ||
} | ||
|
||
export const commandExecutor = new CommandExecutor(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { ExecuteCommandParams, Connection } from 'vscode-languageserver'; | ||
import { CommandExecutor } from '../commandExecutor'; | ||
|
||
export class WorkspaceHandlers { | ||
constructor(private readonly connection: Connection, private readonly commandExecutor: CommandExecutor) {} | ||
|
||
registerHandlers(): void { | ||
this.connection.onExecuteCommand((params) => this.executeCommand(params)); | ||
} | ||
|
||
private executeCommand(params: ExecuteCommandParams): void { | ||
return this.commandExecutor.executeCommand(params); | ||
} | ||
} |
Oops, something went wrong.