Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/get-func-name-2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
msivasubramaniaan authored Dec 19, 2024
2 parents 89d9fe4 + d0a7299 commit b1b7cd9
Show file tree
Hide file tree
Showing 39 changed files with 641 additions and 261 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
### 1.15.0
- Fix: some small type issues [#918](https://github.com/redhat-developer/yaml-language-server/pull/918)
- Add: volar-service-yaml to clients [#920](https://github.com/redhat-developer/yaml-language-server/pull/920)
- Fix: Remove ide-yaml from known clients [#921](https://github.com/redhat-developer/yaml-language-server/pull/921)
- Fix: schema loading performance [#923](https://github.com/redhat-developer/yaml-language-server/pull/923)
- Fix: undefined error in mergingResult.problemArgs [#924](https://github.com/redhat-developer/yaml-language-server/pull/924)
- Add: unify string insert text for array and property [#934](https://github.com/redhat-developer/yaml-language-server/pull/934)
- Add: Improve some special cases for selection ranges [#939](https://github.com/redhat-developer/yaml-language-server/pull/939)
- Fix: show all enums on hover [#942](https://github.com/redhat-developer/yaml-language-server/pull/942)
- Fix: update README syntax highlighting [#945](https://github.com/redhat-developer/yaml-language-server/pull/945)
- Fix: render examples as yaml on hover [#947](https://github.com/redhat-developer/yaml-language-server/pull/947)
- Fix: snippets in additionalProperties [#951](https://github.com/redhat-developer/yaml-language-server/pull/951)
- Fix: crash when url is undefined [#954](https://github.com/redhat-developer/yaml-language-server/pull/954)
- Fix: Add null check for customTags [#955](https://github.com/redhat-developer/yaml-language-server/pull/955)

Thanks to [Remco Haszing](https://github.com/remcohaszing), [Petr Spacek](https://github.com/p-spacek), [Tony](https://github.com/Legend-Master), [Gustav Eikaas](https://github.com/GustavEikaas), [Skip Baney](https://github.com/twelvelabs) and [Pierre Prinetti](https://github.com/pierreprinetti) for your contributions.

### 1.14.0
- Fix: Request textDocument/hover failed with message: Invalid regular expression: /(?s).*/: Invalid group [#874](https://github.com/redhat-developer/yaml-language-server/issues/874)
- Fix: nested anyof const [#888](https://github.com/redhat-developer/yaml-language-server/pull/888)
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The following settings are supported:

In order to use the custom tags in your YAML file you need to first specify the custom tags in the setting of your code editor. For example, we can have the following custom tags:

```YAML
```yaml
"yaml.customTags": [
"!Scalar-example scalar",
"!Seq-example sequence",
Expand All @@ -70,7 +70,7 @@ The !Scalar-example would map to a scalar custom tag, the !Seq-example would map

We can then use the newly defined custom tags inside our YAML file:

```YAML
```yaml
some_key: !Scalar-example some_value
some_sequence: !Seq-example
- some_seq_key_1: some_seq_value_1
Expand All @@ -93,7 +93,7 @@ myProject
you can do
```
```yaml
yaml.schemas: {
"https://json.schemastore.org/composer": "/myYamlFile.yaml"
}
Expand All @@ -109,7 +109,7 @@ and that will associate the composer schema with myYamlFile.yaml.

When associating a schema it should follow the format below

```json
```yaml
yaml.schemas: {
"url": "globPattern",
"Kubernetes": "globPattern"
Expand All @@ -118,23 +118,23 @@ yaml.schemas: {

e.g.

```json
```yaml
yaml.schemas: {
"https://json.schemastore.org/composer": "/*"
}
```

e.g.

```json
```yaml
yaml.schemas: {
"kubernetes": "/myYamlFile.yaml"
}
```

e.g.

```json
```yaml
yaml.schemas: {
"https://json.schemastore.org/composer": "/*",
"kubernetes": "/myYamlFile.yaml"
Expand All @@ -143,37 +143,37 @@ yaml.schemas: {

On Windows with full path:

```json
```yaml
yaml.schemas: {
"C:\\Users\\user\\Documents\\custom_schema.json": "someFilePattern.yaml",
}
```

On Mac/Linux with full path:

```json
```yaml
yaml.schemas: {
"/home/user/custom_schema.json": "someFilePattern.yaml",
}
```

Since `0.11.0` YAML Schemas can be used for validation:

```json
```yaml
"/home/user/custom_schema.yaml": "someFilePattern.yaml"
```
A schema can be associated with multiple globs using a json array, e.g.
```json
```yaml
yaml.schemas: {
"kubernetes": ["filePattern1.yaml", "filePattern2.yaml"]
}
```

e.g.

```json
```yaml
"yaml.schemas": {
"http://json.schemastore.org/composer": ["/*"],
"file:///home/johnd/some-schema.json": ["some.yaml"],
Expand All @@ -184,15 +184,15 @@ e.g.

e.g.

```json
```yaml
"yaml.schemas": {
"kubernetes": ["/myYamlFile.yaml"]
}
```

e.g.

```json
```yaml
"yaml.schemas": {
"http://json.schemastore.org/composer": ["/*"],
"kubernetes": ["/myYamlFile.yaml"]
Expand All @@ -205,7 +205,7 @@ You can also use relative paths when working with multi root workspaces.

Suppose you have a multi root workspace that is laid out like:

```
```yaml
My_first_project:
test.yaml
my_schema.json
Expand All @@ -216,7 +216,7 @@ My_second_project:
You must then associate schemas relative to the root of the multi root workspace project.
```
```yaml
yaml.schemas: {
"My_first_project/my_schema.json": "test.yaml",
"My_second_project/my_schema2.json": "test2.yaml"
Expand All @@ -229,7 +229,7 @@ yaml.schemas: {

Suppose a file is meant to be a component of an existing schema (like a `job.yaml` file in a circleci orb), but there isn't a standalone schema that you can reference. If there is a nested schema definition for this subcomponent, you can reference it using a url fragment, e.g.:

```
```yaml
yaml.schemas: {
"https://json.schemastore.org/circleciconfig#/definitions/jobs/additionalProperties": "/src/jobs/*.yaml",
}
Expand Down Expand Up @@ -275,7 +275,7 @@ The image is located at `quay.io/redhat-developer/yaml-language-server`

To run the image you can use:

```
```sh
docker run -it quay.io/redhat-developer/yaml-language-server:latest
```

Expand Down Expand Up @@ -379,7 +379,6 @@ This repository only contains the server implementation. Here are some known cli

- [Eclipse Che](https://www.eclipse.org/che/)
- [vscode-yaml](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) for VSCode
- [ide-yaml](https://atom.io/packages/ide-yaml) for Atom editor
- [coc-yaml](https://github.com/neoclide/coc-yaml) for [coc.nvim](https://github.com/neoclide/coc.nvim)
- [Eclipse Wild Web Developer](https://marketplace.eclipse.org/content/eclipse-wild-web-developer-web-development-eclipse-ide) for Eclipse IDE
- [lsp-mode](https://github.com/emacs-lsp/lsp-mode) for Emacs
Expand All @@ -388,6 +387,7 @@ This repository only contains the server implementation. Here are some known cli
- [monaco-yaml](https://monaco-yaml.js.org) for Monaco editor
- [Vim-EasyComplete](https://github.com/jayli/vim-easycomplete) for Vim/NeoVim
- [nova-yaml](https://github.com/robb-j/nova-yaml/) for Nova
- [volar-service-yaml](https://github.com/volarjs/services/tree/master/packages/yaml) for Volar

## Developer Support

Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@
"type": "git",
"url": "https://github.com/redhat-developer/yaml-language-server.git"
},
"optionalDependencies": {
"prettier": "2.8.7"
},
"dependencies": {
"ajv": "^8.11.0",
"lodash": "4.17.21",
"prettier": "^3.0.0",
"request-light": "^0.5.7",
"vscode-json-languageservice": "4.1.8",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver": "^9.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-languageserver-types": "^3.16.0",
"vscode-nls": "^5.0.0",
Expand All @@ -49,17 +47,16 @@
"@types/chai": "^4.2.12",
"@types/mocha": "8.2.2",
"@types/node": "16.x",
"@types/prettier": "2.7.2",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"chai": "^4.2.0",
"coveralls": "3.1.1",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"mocha": "9.2.2",
Expand Down
6 changes: 3 additions & 3 deletions src/languageserver/handlers/languageHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class LanguageHandlers {
* Called when the formatter is invoked
* Returns the formatted document content using prettier
*/
formatterHandler(formatParams: DocumentFormattingParams): TextEdit[] {
formatterHandler(formatParams: DocumentFormattingParams): Promise<TextEdit[]> {
const document = this.yamlSettings.documents.get(formatParams.textDocument.uri);

if (!document) {
Expand Down Expand Up @@ -229,15 +229,15 @@ export class LanguageHandlers {
return this.languageService.getCodeAction(textDocument, params);
}

codeLensHandler(params: CodeLensParams): Thenable<CodeLens[] | undefined> | CodeLens[] | undefined {
codeLensHandler(params: CodeLensParams): PromiseLike<CodeLens[] | undefined> | CodeLens[] | undefined {
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
if (!textDocument) {
return;
}
return this.languageService.getCodeLens(textDocument);
}

codeLensResolveHandler(param: CodeLens): Thenable<CodeLens> | CodeLens {
codeLensResolveHandler(param: CodeLens): PromiseLike<CodeLens> | CodeLens {
return this.languageService.resolveCodeLens(param);
}

Expand Down
5 changes: 4 additions & 1 deletion src/languageserver/handlers/requestHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { SchemaModificationNotification } from '../../requestTypes';

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

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 @@ -81,7 +81,7 @@ export class SettingsHandler {

if (settings.yaml.schemaStore) {
this.yamlSettings.schemaStoreEnabled = settings.yaml.schemaStore.enable;
if (settings.yaml.schemaStore.url.length !== 0) {
if (settings.yaml.schemaStore.url?.length !== 0) {
this.yamlSettings.schemaStoreUrl = settings.yaml.schemaStore.url;
}
}
Expand Down Expand Up @@ -180,7 +180,7 @@ export class SettingsHandler {
private async setSchemaStoreSettingsIfNotSet(): Promise<void> {
const schemaStoreIsSet = this.yamlSettings.schemaStoreSettings.length !== 0;
let schemaStoreUrl = '';
if (this.yamlSettings.schemaStoreUrl.length !== 0) {
if (this.yamlSettings.schemaStoreUrl?.length !== 0) {
schemaStoreUrl = this.yamlSettings.schemaStoreUrl;
} else {
schemaStoreUrl = JSON_SCHEMASTORE_URL;
Expand Down
6 changes: 5 additions & 1 deletion src/languageserver/handlers/validationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export class ValidationHandler {
private languageService: LanguageService;
private yamlSettings: SettingsState;

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

Expand Down
5 changes: 4 additions & 1 deletion src/languageserver/handlers/workspaceHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { ExecuteCommandParams, Connection } from 'vscode-languageserver';
import { CommandExecutor } from '../commandExecutor';

export class WorkspaceHandlers {
constructor(private readonly connection: Connection, private readonly commandExecutor: CommandExecutor) {}
constructor(
private readonly connection: Connection,
private readonly commandExecutor: CommandExecutor
) {}

registerHandlers(): void {
this.connection.onExecuteCommand((params) => this.executeCommand(params));
Expand Down
10 changes: 8 additions & 2 deletions src/languageservice/parser/jsonParser07.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ export interface ISchemaCollector {

class SchemaCollector implements ISchemaCollector {
schemas: IApplicableSchema[] = [];
constructor(private focusOffset = -1, private exclude: ASTNode = null) {}
constructor(
private focusOffset = -1,
private exclude: ASTNode = null
) {}
add(schema: IApplicableSchema): void {
this.schemas.push(schema);
}
Expand Down Expand Up @@ -400,7 +403,7 @@ export class ValidationResult {
(problemType !== ProblemType.missingRequiredPropWarning || isArrayEqual(p.problemArgs, bestResult.problemArgs)) // missingProp is merged only with same problemArg
);
if (mergingResult) {
if (mergingResult.problemArgs.length) {
if (mergingResult.problemArgs?.length) {
mergingResult.problemArgs
.filter((p) => !bestResult.problemArgs.includes(p))
.forEach((p) => bestResult.problemArgs.push(p));
Expand Down Expand Up @@ -888,6 +891,7 @@ function validate(
),
source: getSchemaSource(schema, originalSchema),
schemaUri: getSchemaUri(schema, originalSchema),
data: { values: schema.enum },
});
}
}
Expand All @@ -907,6 +911,7 @@ function validate(
source: getSchemaSource(schema, originalSchema),
schemaUri: getSchemaUri(schema, originalSchema),
problemArgs: [JSON.stringify(schema.const)],
data: { values: [schema.const] },
});
validationResult.enumValueMatch = false;
} else {
Expand Down Expand Up @@ -1385,6 +1390,7 @@ function validate(
length: propertyNode.keyNode.length,
},
severity: DiagnosticSeverity.Warning,
code: ErrorCode.PropertyExpected,
message: schema.errorMessage || localize('DisallowedExtraPropWarning', MSG_PROPERTY_NOT_ALLOWED, propertyName),
source: getSchemaSource(schema, originalSchema),
schemaUri: getSchemaUri(schema, originalSchema),
Expand Down
1 change: 0 additions & 1 deletion src/languageservice/parser/yamlParser07.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright (c) Adam Voss. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

import { Parser, Composer, Document, LineCounter, ParseOptions, DocumentOptions, SchemaOptions } from 'yaml';
import { YAMLDocument, SingleYAMLDocument } from './yaml-documents';
Expand Down
6 changes: 4 additions & 2 deletions src/languageservice/services/documentSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

import { SymbolInformation, DocumentSymbol } from 'vscode-languageserver-types';
import { YAMLSchemaService } from './yamlSchemaService';
Expand All @@ -18,7 +17,10 @@ import { convertErrorToTelemetryMsg } from '../utils/objects';
export class YAMLDocumentSymbols {
private jsonDocumentSymbols;

constructor(schemaService: YAMLSchemaService, private readonly telemetry?: Telemetry) {
constructor(
schemaService: YAMLSchemaService,
private readonly telemetry?: Telemetry
) {
this.jsonDocumentSymbols = new JSONDocumentSymbols(schemaService);

// override 'getKeyLabel' to handle complex mapping
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/modelineUtil.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.
*--------------------------------------------------------------------------------------------*/
'use strict';

import { SingleYAMLDocument } from '../parser/yamlParser07';
import { JSONDocument } from '../parser/jsonParser07';

Expand Down
Loading

0 comments on commit b1b7cd9

Please sign in to comment.