Skip to content

Commit

Permalink
Merge branch 'master' into feat/delete-multiple-schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Spacek committed Feb 15, 2021
2 parents 4ab48e4 + 1802872 commit 653ce39
Show file tree
Hide file tree
Showing 33 changed files with 700 additions and 184 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
### 0.15.0

- Fix: Array new line ending with no indent [#384](https://github.com/redhat-developer/yaml-language-server/pull/384)
- Fix: Code Completion with defaultSnippet and markdown [#385](https://github.com/redhat-developer/yaml-language-server/pull/385)
- Fix: Test yaml-schema package [#386](https://github.com/redhat-developer/yaml-language-server/pull/386)
- Fix: Completion with default snippet when node is array [#387](https://github.com/redhat-developer/yaml-language-server/pull/387)
- Auto formatting for list, with `onTypeFormatting` implementation [#179](https://github.com/redhat-developer/vscode-yaml/issues/179)
- Fix: Completion array anyOf [#390](https://github.com/redhat-developer/yaml-language-server/pull/390)
- Fix CodeCompletion with defaultSnippet and markdown [#393](https://github.com/redhat-developer/yaml-language-server/pull/393)
- Fix: Services initialization [#399](https://github.com/redhat-developer/yaml-language-server/pull/399)
- Update kubernetes schema to 1.18.1 [#401](https://github.com/redhat-developer/yaml-language-server/pull/401)
- Fix: Folding misbehaves in version 0.14.0 [#400](https://github.com/redhat-developer/yaml-language-server/issues/400)
- Use mocha bdd interface for all tests [#403](https://github.com/redhat-developer/yaml-language-server/pull/403)

Thanks to Petr Spacek and tonypai

### 0.14.0

- yaml-language-server use a non-standard LSP request to resolve schemas content on client [#359](https://github.com/redhat-developer/yaml-language-server/pull/359)
- Fix error on completion 'null' value [#360](https://github.com/redhat-developer/yaml-language-server/pull/360)
- Select schemas based off on their priority [#362](https://github.com/redhat-developer/yaml-language-server/pull/362)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The following settings are supported:
- `editor.tabSize`: the number of spaces to use when autocompleting. Default is 2.
- `http.proxy`: The URL of the proxy server that will be used when attempting to download a schema. If it is not set or it is undefined no proxy server will be used.
- `http.proxyStrictSSL`: If true the proxy server certificate should be verified against the list of supplied CAs. Default is false.
- `[yaml].editor.formatOnType`: Enable/disable on type indent and auto formatting array

##### Adding custom tags

Expand Down Expand Up @@ -233,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 `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)

## Clients

This repository only contains the server implementation. Here are some known clients consuming this server:
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"name": "yaml-language-server",
"description": "YAML language server",
"version": "0.14.0",
"version": "0.15.0",
"author": "Gorkem Ercan (Red Hat)",
"license": "MIT",
"contributors": [
{
"name": "Joshua Pinkney",
"email": "joshpinkney@gmail.com"
},
{
"name": "Yevhen Vydolob",
"email": "yvydolob@redhat.com"
},
{
"name": "Google LLC"
}
Expand All @@ -35,10 +39,10 @@
"js-yaml": "^3.13.1",
"jsonc-parser": "^2.2.1",
"request-light": "^0.2.4",
"vscode-json-languageservice": "^3.10.0",
"vscode-languageserver": "^5.2.1",
"vscode-json-languageservice": "^4.0.2",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-languageserver-types": "^3.15.1",
"vscode-languageserver-types": "^3.16.0",
"vscode-nls": "^4.1.2",
"vscode-uri": "^2.1.1",
"yaml-language-server-parser": "next"
Expand All @@ -49,6 +53,7 @@
"@types/node": "^12.11.7",
"@types/prettier": "2.0.2",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^3.2.0",
"@typescript-eslint/parser": "^3.2.0",
"chai": "^4.2.0",
Expand Down
8 changes: 8 additions & 0 deletions src/commands.ts
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',
}
27 changes: 27 additions & 0 deletions src/languageserver/commandExecutor.ts
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();
16 changes: 14 additions & 2 deletions src/languageserver/handlers/languageHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import { FoldingRange } from 'vscode-json-languageservice';
import {
CodeAction,
CodeActionParams,
CompletionList,
DidChangeWatchedFilesParams,
DocumentFormattingParams,
Expand All @@ -12,7 +14,7 @@ import {
DocumentOnTypeFormattingParams,
DocumentSymbolParams,
FoldingRangeParams,
IConnection,
Connection,
TextDocumentPositionParams,
} from 'vscode-languageserver';
import { DocumentSymbol, Hover, SymbolInformation, TextEdit } from 'vscode-languageserver-types';
Expand All @@ -27,7 +29,7 @@ export class LanguageHandlers {
private validationHandler: ValidationHandler;

constructor(
private readonly connection: IConnection,
private readonly connection: Connection,
languageService: LanguageService,
yamlSettings: SettingsState,
validationHandler: ValidationHandler
Expand All @@ -45,6 +47,7 @@ export class LanguageHandlers {
this.connection.onCompletion((textDocumentPosition) => this.completionHandler(textDocumentPosition));
this.connection.onDidChangeWatchedFiles((change) => this.watchedFilesHandler(change));
this.connection.onFoldingRanges((params) => this.foldingRangeHandler(params));
this.connection.onCodeAction((params) => this.codeActionHandler(params));
this.connection.onDocumentOnTypeFormatting((params) => this.formatOnTypeHandler(params));
}

Expand Down Expand Up @@ -165,4 +168,13 @@ export class LanguageHandlers {

return this.languageService.getFoldingRanges(textDocument, this.yamlSettings.capabilities.textDocument.foldingRange);
}

codeActionHandler(params: CodeActionParams): CodeAction[] | undefined {
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
if (!textDocument) {
return;
}

return this.languageService.getCodeAction(textDocument, params);
}
}
4 changes: 2 additions & 2 deletions src/languageserver/handlers/notificationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IConnection } from 'vscode-languageserver';
import { Connection } from 'vscode-languageserver';
import { CustomSchemaProvider } from '../../languageservice/services/yamlSchemaService';
import { LanguageService, SchemaConfiguration } from '../../languageservice/yamlLanguageService';
import {
Expand All @@ -20,7 +20,7 @@ export class NotificationHandlers {
private settingsHandler: SettingsHandler;

constructor(
private readonly connection: IConnection,
private readonly connection: Connection,
languageService: LanguageService,
yamlSettings: SettingsState,
settingsHandler: SettingsHandler
Expand Down
8 changes: 4 additions & 4 deletions src/languageserver/handlers/requestHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,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 { IConnection } from 'vscode-languageserver';
import { Connection } from 'vscode-languageserver';
import {
MODIFICATION_ACTIONS,
SchemaAdditions,
SchemaDeletions,
SchemaDeletionsWhole,
SchemaDeletionsAll,
} from '../../languageservice/services/yamlSchemaService';
import { LanguageService } from '../../languageservice/yamlLanguageService';
import { SchemaModificationNotification } from '../../requestTypes';

export class RequestHandlers {
private languageService: LanguageService;
constructor(private readonly connection: IConnection, languageService: LanguageService) {
constructor(private readonly connection: Connection, languageService: LanguageService) {
this.languageService = languageService;
}

Expand All @@ -25,7 +25,7 @@ export class RequestHandlers {
}

private registerSchemaModificationNotificationHandler(
modifications: SchemaAdditions | SchemaDeletions | SchemaDeletionsWhole
modifications: SchemaAdditions | SchemaDeletions | SchemaDeletionsAll
): void {
if (modifications.action === MODIFICATION_ACTIONS.add) {
this.languageService.modifySchemaContent(modifications);
Expand Down
4 changes: 2 additions & 2 deletions src/languageserver/handlers/settingsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { xhr, configure as configureHttpRequests } from 'request-light';
import { DidChangeConfigurationParams, DocumentFormattingRequest, IConnection } from 'vscode-languageserver';
import { DidChangeConfigurationParams, DocumentFormattingRequest, Connection } from 'vscode-languageserver';
import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths';
import { checkSchemaURI, JSON_SCHEMASTORE_URL, KUBERNETES_SCHEMA_URL } from '../../languageservice/utils/schemaUrls';
import { LanguageService, LanguageSettings } from '../../languageservice/yamlLanguageService';
Expand All @@ -12,7 +12,7 @@ import { ValidationHandler } from './validationHandlers';

export class SettingsHandler {
constructor(
private readonly connection: IConnection,
private readonly connection: Connection,
private readonly languageService: LanguageService,
private readonly yamlSettings: SettingsState,
private readonly validationHandler: ValidationHandler
Expand Down
4 changes: 2 additions & 2 deletions src/languageserver/handlers/validationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IConnection } from 'vscode-languageserver';
import { Connection } from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Diagnostic } from 'vscode-languageserver-types';
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
Expand All @@ -14,7 +14,7 @@ export class ValidationHandler {
private languageService: LanguageService;
private yamlSettings: SettingsState;

constructor(private readonly connection: IConnection, languageService: LanguageService, yamlSettings: SettingsState) {
constructor(private readonly connection: Connection, languageService: LanguageService, yamlSettings: SettingsState) {
this.languageService = languageService;
this.yamlSettings = yamlSettings;

Expand Down
19 changes: 19 additions & 0 deletions src/languageserver/handlers/workspaceHandlers.ts
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);
}
}

0 comments on commit 653ce39

Please sign in to comment.