add cache and rename some files

This commit is contained in:
2026-01-15 15:41:19 +01:00
parent 7879f15726
commit b64815d9ab
4753 changed files with 931902 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
install-strategy=shallow

View File

@@ -0,0 +1 @@
{"schema_version":"1.1","primary_source":{"type":"registry+v1","id":"pkg:npm/yaml-language-server@1.19.1"},"metrics":{"completion_time":1759337509860,"start_time":1759337507835},"links":{"bin":{"yaml-language-server":"node_modules/.bin/yaml-language-server"},"share":{"mason-schemas/lsp/yaml-language-server.json":"mason-schemas/lsp.json"},"opt":{}},"name":"yaml-language-server","secondary_sources":[]}

View File

@@ -0,0 +1 @@
{"properties":{"redhat.telemetry.enabled":{"scope":"window","markdownDescription":"Enable usage data and errors to be sent to Red Hat servers. Read our [privacy statement](https://developers.redhat.com/article/tool-data-collection).","type":"boolean","default":null},"yaml.format.printWidth":{"description":"Specify the line length that the printer will wrap on","type":"integer","default":80},"yaml.disableAdditionalProperties":{"description":"Globally set additionalProperties to false for all objects. So if its true, no extra properties are allowed inside yaml.","type":"boolean","default":false},"yaml.trace.server":{"description":"Traces the communication between VSCode and the YAML language service.","default":"off","enum":["off","messages","verbose"],"type":"string"},"yaml.validate":{"description":"Enable/disable validation feature","type":"boolean","default":true},"yaml.schemas":{"description":"Associate schemas to YAML files in the current workspace","type":"object","default":{}},"yaml.hover":{"description":"Enable/disable hover feature","type":"boolean","default":true},"yaml.format.enable":{"description":"Enable/disable default YAML formatter","type":"boolean","default":true},"yaml.completion":{"description":"Enable/disable completion feature","type":"boolean","default":true},"yaml.format.singleQuote":{"description":"Use single quotes instead of double quotes","type":"boolean","default":false},"yaml.customTags":{"description":"Custom tags for the parser to use","type":"array","default":[]},"yaml.format.bracketSpacing":{"description":"Print spaces between brackets in objects","type":"boolean","default":true},"yaml.maxItemsComputed":{"description":"The maximum number of outline symbols and folding regions computed (limited for performance reasons).","type":"integer","default":5000},"yaml.format.proseWrap":{"description":"Always: wrap prose if it exeeds the print width, Never: never wrap the prose, Preserve: wrap prose as-is","type":"string","enum":["preserve","never","always"],"default":"preserve"},"yaml.schemaStore.url":{"description":"URL of schema store catalog to use","type":"string","default":"https://www.schemastore.org/api/json/catalog.json"},"yaml.schemaStore.enable":{"description":"Automatically pull available YAML schemas from JSON Schema Store","type":"boolean","default":true}}}

View File

@@ -0,0 +1 @@
../yaml-language-server/bin/yaml-language-server

View File

@@ -0,0 +1,221 @@
{
"name": "@mason/yaml-language-server",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/yaml-language-server": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/yaml-language-server/-/yaml-language-server-1.19.1.tgz",
"integrity": "sha512-EO07kunMFvRQHnhSmtf9xU0if7yRndhsv9GD4uBYC0nzzSBeb/CkLWN7EjWNJ9+0OysMBx/GnGQiGTyKsnfNFg==",
"license": "MIT",
"dependencies": {
"@vscode/l10n": "^0.0.18",
"ajv": "^8.17.1",
"ajv-draft-04": "^1.0.0",
"lodash": "4.17.21",
"prettier": "^3.5.0",
"request-light": "^0.5.7",
"vscode-json-languageservice": "4.1.8",
"vscode-languageserver": "^9.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-languageserver-types": "^3.16.0",
"vscode-uri": "^3.0.2",
"yaml": "2.7.1"
},
"bin": {
"yaml-language-server": "bin/yaml-language-server"
}
},
"node_modules/yaml-language-server/node_modules/@vscode/l10n": {
"version": "0.0.18",
"resolved": "https://registry.npmjs.org/@vscode/l10n/-/l10n-0.0.18.tgz",
"integrity": "sha512-KYSIHVmslkaCDyw013pphY+d7x1qV8IZupYfeIfzNA+nsaWHbn5uPuQRvdRFsa9zFzGeudPuoGoZ1Op4jrJXIQ==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/ajv": {
"version": "8.17.1",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz",
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
"license": "MIT",
"peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/yaml-language-server/node_modules/ajv-draft-04": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/ajv-draft-04/-/ajv-draft-04-1.0.0.tgz",
"integrity": "sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==",
"license": "MIT",
"peerDependencies": {
"ajv": "^8.5.0"
},
"peerDependenciesMeta": {
"ajv": {
"optional": true
}
}
},
"node_modules/yaml-language-server/node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/fast-uri": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz",
"integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "BSD-3-Clause"
},
"node_modules/yaml-language-server/node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/jsonc-parser": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz",
"integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/prettier": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/yaml-language-server/node_modules/request-light": {
"version": "0.5.8",
"resolved": "https://registry.npmjs.org/request-light/-/request-light-0.5.8.tgz",
"integrity": "sha512-3Zjgh+8b5fhRJBQZoy+zbVKpAQGLyka0MPgW3zruTF4dFFJ8Fqcfu9YsAvi/rvdcaTeWG3MkbZv4WKxAn/84Lg==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/yaml-language-server/node_modules/vscode-json-languageservice": {
"version": "4.1.8",
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-4.1.8.tgz",
"integrity": "sha512-0vSpg6Xd9hfV+eZAaYN63xVVMOTmJ4GgHxXnkLCh+9RsQBkWKIghzLhW2B9ebfG+LQQg8uLtsQ2aUKjTgE+QOg==",
"license": "MIT",
"dependencies": {
"jsonc-parser": "^3.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-languageserver-types": "^3.16.0",
"vscode-nls": "^5.0.0",
"vscode-uri": "^3.0.2"
},
"engines": {
"npm": ">=7.0.0"
}
},
"node_modules/yaml-language-server/node_modules/vscode-jsonrpc": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz",
"integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/yaml-language-server/node_modules/vscode-languageserver": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz",
"integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==",
"license": "MIT",
"dependencies": {
"vscode-languageserver-protocol": "3.17.5"
},
"bin": {
"installServerIntoExtension": "bin/installServerIntoExtension"
}
},
"node_modules/yaml-language-server/node_modules/vscode-languageserver-protocol": {
"version": "3.17.5",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz",
"integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==",
"license": "MIT",
"dependencies": {
"vscode-jsonrpc": "8.2.0",
"vscode-languageserver-types": "3.17.5"
}
},
"node_modules/yaml-language-server/node_modules/vscode-languageserver-textdocument": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz",
"integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/vscode-languageserver-types": {
"version": "3.17.5",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz",
"integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/vscode-nls": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz",
"integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/vscode-uri": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.1.0.tgz",
"integrity": "sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==",
"license": "MIT"
},
"node_modules/yaml-language-server/node_modules/yaml": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.1.tgz",
"integrity": "sha512-10ULxpnOCQXxJvBgxsn9ptjq6uviG/htZKk9veJGhlqn3w/DxQ631zFF+nlQXLwmImeS5amR2dl2U8sg6U9jsQ==",
"license": "ISC",
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14"
}
}
}
}

View File

@@ -0,0 +1,656 @@
### 1.19.1
- Feat: Support formatting docker-compose.yml by default [#1071](https://github.com/redhat-developer/yaml-language-server/issues/1071)
- Feat: Support statically registering format support [#1062](https://github.com/redhat-developer/yaml-language-server/pull/1062)
- Feat: Support localization in the YAML language server [#1081](https://github.com/redhat-developer/yaml-language-server/issues/1081)
- Feat: Migrated to NPM [#1097](https://github.com/redhat-developer/yaml-language-server/issues/1097)
- Feat: Add formatting option to remove trailing comma [#1112](https://github.com/redhat-developer/vscode-yaml/issues/1112)
- Fix: OpenAPI 3.0.0 specification is treated as invalid [#752](https://github.com/redhat-developer/yaml-language-server/issues/752)
- Fix: YAML Language Server checks against JSON Schema Draft 7 instead of the defined one [#780](https://github.com/redhat-developer/yaml-language-server/issues/780)
- Fix: Numbers in comments should not break schema validation [#922](https://github.com/redhat-developer/yaml-language-server/issues/922)
- Fix: Make enum values easier to read on hover [#982](https://github.com/redhat-developer/yaml-language-server/issues/982)
- Fix: No more quickfix for indent with tab [#1052](https://github.com/redhat-developer/yaml-language-server/issues/1052)
- Fix: QuickFix for "flow sequence forbidden" leaves in trailing `]` [#1060](https://github.com/redhat-developer/yaml-language-server/issues/1060)
- Fix: YAML conversion does not resolve aliases correctly [#1075](https://github.com/redhat-developer/yaml-language-server/issues/1075)
- Fix: Fix enum values to be unique [#1028](https://github.com/redhat-developer/yaml-language-server/pull/1028)
- Fix: Using bool values in enum and const generates a validation error for valid values [#1078](https://github.com/redhat-developer/yaml-language-server/issues/1078)
- Fix: improve enum value descriptions for merged enum lists [#1085](https://github.com/redhat-developer/yaml-language-server/pull/1085)
- Fix: Array of const completion [#1092](https://github.com/redhat-developer/yaml-language-server/pull/1092)
- Fix: Error for missing anchor (unidentified alias) broken since 1.0 [#1098](https://github.com/redhat-developer/vscode-yaml/issues/1098)
- Fix: Invalid tab indentation error [#1110](https://github.com/redhat-developer/vscode-yaml/issues/1110)
- Fix: Validation shows false negative errors if using boolean with const [#1116](https://github.com/redhat-developer/vscode-yaml/issues/1116)
- Fix: Broken link to JSON Schema website [#1113](https://github.com/redhat-developer/yaml-language-server/pull/1113)
- Fix: GitHub Actions release process was broken [#1127](https://github.com/redhat-developer/yaml-language-server/pull/1127), [#1128](https://github.com/redhat-developer/yaml-language-server/issues/1128)
- Bump: ajv version [#1067](https://github.com/redhat-developer/yaml-language-server/pull/1067)
Thanks to [Trevor Dixon](https://github.com/trevordixon), [David Lechner](https://github.com/dlech), [pjsk-stripe](https://github.com/pjsk-stripe), [Lucy Dryaeva
](https://github.com/ShadiestGoat), [Kosta](https://github.com/Kosta-Github) and [August Johansson ](https://github.com/webdevred) for your contributions.
### 1.18.0
- Feat: Do not suggest propertyNames if doNotSuggest is true [#1045](https://github.com/redhat-developer/yaml-language-server/pull/1045)
- Feat: Exclude not suggest properties from possible properties error [#1051](https://github.com/redhat-developer/yaml-language-server/pull/1051)
- Feat: Fix enum values to be unique [#1028](https://github.com/redhat-developer/yaml-language-server/pull/1028)
- Fix: URL-encoded characters in $ref paths break schema resolution [#1082](https://github.com/redhat-developer/vscode-yaml/issues/1082)
- Fix: Tests fail with Node.JS 23.7.x [#1018](https://github.com/redhat-developer/yaml-language-server/issues/1018)
- Fix: Autocompletion problem when value is null inside anyOf object [#684](https://github.com/redhat-developer/yaml-language-server/issues/684)
- Fix: Enum strings YES / NO are converted to boolean incorrectly [#1036](https://github.com/redhat-developer/yaml-language-server/issues/1036)
- Fix: Autocompletion with escape sequence chars [#1040](https://github.com/redhat-developer/yaml-language-server/pull/1040)
- Fix: multipleOf does not work for floats [#985](https://github.com/redhat-developer/yaml-language-server/issues/985)
Thanks to [Petr Spacek](https://github.com/p-spacek), [Kosta](https://github.com/Kosta-Github) and [Willem Jan](https://github.com/Willem-J-an) for your contributions.
### 1.17.0
- Feat: Supported docker arm64 image [#1027](https://github.com/redhat-developer/yaml-language-server/pull/1027)
- Fix: Reverted ajv-draft04 as it not support HTTPS [#1026](https://github.com/redhat-developer/yaml-language-server/pull/1026)
- Fix: Use replaceAll() instead of replace() when turning a label into a regex [#1078](https://github.com/redhat-developer/vscode-yaml/issues/1078)
### 1.16.0
- Feat: Add support for draft-04 (2019 and 2020 included) json schemas while supporting draft-07 [#1006](https://github.com/redhat-developer/yaml-language-server/pull/1006)
- Feat: quickFix for enum, const, property [#900](https://github.com/redhat-developer/yaml-language-server/pull/900)
- Add: Send real errors to telemetry [#981](https://github.com/redhat-developer/yaml-language-server/pull/981)
- Add: Missing field descriptions for anyOf [#1007](https://github.com/redhat-developer/yaml-language-server/pull/1007)
- Add: k8s update schema to 1.32.1 [#1011](https://github.com/redhat-developer/yaml-language-server/pull/1011)
- Add: Adjust to new hover behviour for enum [#1030](https://github.com/redhat-developer/vscode-yaml/pull/1030)
- Bump: Dependencies [#1000](https://github.com/redhat-developer/yaml-language-server/pull/1000) [#1001](https://github.com/redhat-developer/yaml-language-server/pull/1001) [#1002](https://github.com/redhat-developer/yaml-language-server/pull/1002) [#1003](https://github.com/redhat-developer/yaml-language-server/pull/1003)
Thanks to [Remco Haszing](https://github.com/remcohaszing), [Petr Spacek](https://github.com/p-spacek), [David Hernando](https://github.com/Davidonium), [Yannik Tausch](https://github.com/ytausch), [Lauri Tirkkonen](https://github.com/lotheac) for your contributions.
### 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)
- Fix: Parsing example object as plain string [#889](https://github.com/redhat-developer/yaml-language-server/issues/889)
- Fix: Improve smart select [#307](https://github.com/redhat-developer/vscode-yaml/issues/307)
- Fix: Local YAML schema applied to schema file itself [#894](https://github.com/redhat-developer/vscode-yaml/issues/894)
- Fix: Recursive anchors crash extension [#897](https://github.com/redhat-developer/yaml-language-server/issues/897)
Thanks to [Tony](https://github.com/Legend-Master),[Ace](https://github.com/AceTheCreator) and [PetrSpacek](https://github.com/p-spacek) for your contributions.
### 1.13.0
- Fix: The default value for keyorder [#859](https://github.com/redhat-developer/yaml-language-server/pull/859)
- Fix: older changelog heading levels [#861](https://github.com/redhat-developer/yaml-language-server/pull/861)
- Fix: hover behavior when indentation not set [#863](https://github.com/redhat-developer/yaml-language-server/pull/863)
- Add: Run sarif seperately [#866](https://github.com/redhat-developer/yaml-language-server/pull/866)
- Fix: Formatting YAML file inserts ternary operators [#255](https://github.com/redhat-developer/vscode-yaml/issues/255)
- Fix: Mark settings readonly [#868](https://github.com/redhat-developer/yaml-language-server/pull/868)
Thanks to [Kasama](https://github.com/Kasama)
### 1.12.0
- Fix: Completion Value with dash [#832](https://github.com/redhat-developer/yaml-language-server/pull/832)
- Add: Enforce alphabetical ordering of keys in mappings and provide codeaction to fix it. [#839](https://github.com/redhat-developer/yaml-language-server/pull/839)
- Fix: Value completion with trailing spaces [#834](https://github.com/redhat-developer/yaml-language-server/pull/834)
- Add: IPv4 and IPv6 validation [#843](https://github.com/redhat-developer/yaml-language-server/pull/843)
- Fix: Type errors inform wrong type when parent schema has keyword "title" [#845](https://github.com/redhat-developer/yaml-language-server/issues/845)
- Fix: Anchor diagnostics [#846](https://github.com/redhat-developer/yaml-language-server/pull/846)
- Fix: Underscore being escaped in description attribute when hovering over an attribute [#886](https://github.com/redhat-developer/vscode-yaml/issues/886)
- Add: OpenShift Toolkit extension recommendation [#892](https://github.com/redhat-developer/vscode-yaml/pull/892)
Thanks to Petr Spacek
### 1.11.0
- Fix: only the first choice is shown when hovering anyOf-typed properties [#784](https://github.com/redhat-developer/vscode-yaml/issues/784)
- Fix: Description in the schema root does not get displayed [#809](https://github.com/redhat-developer/vscode-yaml/issues/809)
- Fix: yaml.validation.error telemetry events are broken [#816](https://github.com/redhat-developer/vscode-yaml/issues/816)
- Add: add diagnostic data with missing properties [#775](https://github.com/redhat-developer/yaml-language-server/pull/775)
- Fix: Can't suggest object correctly with certain schema definition. [#769](https://github.com/redhat-developer/yaml-language-server/issues/769)
- Fix: Property shows up multiple times in completions [#829](https://github.com/redhat-developer/vscode-yaml/issues/829)
- Fix: oneOf validation of keys using "required" not working since 1.3.0 [#769](https://github.com/redhat-developer/vscode-yaml/issues/769)
- Fix: incorrect behavior of keys with quotes [#842](https://github.com/redhat-developer/vscode-yaml/issues/842)
- Fix: bad completion with array of objects [#793](https://github.com/redhat-developer/yaml-language-server/issues/793)
- Add: Modeline takes precendence over registerContributor API [#806](https://github.com/redhat-developer/yaml-language-server/pull/806)
Thanks to Petr Spacek,Josh Pinkney
### 1.10.0
- Fix: TypeError: i.startsWith is not a function [#747](https://github.com/redhat-developer/yaml-language-server/issues/747)
- Fix: fix: autocomplete indent on object within an array [#751](https://github.com/redhat-developer/yaml-language-server/pull/751)
- Add: Yaml style linting to forbid flow style [#753](https://github.com/redhat-developer/yaml-language-server/pull/753)
- Fix: enum validation [#803](https://github.com/redhat-developer/vscode-yaml/issues/803)
- Fix: autocompletion problem when value is null inside anyOf object [#684](https://github.com/redhat-developer/yaml-language-server/issues/684)
- Fix: indentation with extra spaces after cursor. [#764](https://github.com/redhat-developer/yaml-language-server/pull/764)
Thanks to Rickcowan
### 1.9.0
- Add: Publish pre-release extension on nightly CI build [#682](https://github.com/redhat-developer/vscode-yaml/issues/682)
- Add: Add title to extension configuration [#793](https://github.com/redhat-developer/vscode-yaml/pull/793)
- Fix: [object Object] with malformed type definition on hover [#788](https://github.com/redhat-developer/vscode-yaml/issues/788)
- Fix: Description not returned on hover when using yaml anchors [#737](https://github.com/redhat-developer/yaml-language-server/issues/737)
- Fix: Validation of enums that are numbers stopped working in 1.8.0 [#790](https://github.com/redhat-developer/vscode-yaml/issues/790)
- Fix: extra space after position [#732](https://github.com/redhat-developer/yaml-language-server/pull/732)
- Fix: zero-based index [#735](https://github.com/redhat-developer/yaml-language-server/pull/735)
- Fix: proper indenting of snippet within an array [#745](https://github.com/redhat-developer/yaml-language-server/pull/745)
Thanks to Whazor Nanne, Petr Spacek, Golergka and Rickcowan
### 1.8.0
- Fix: yaml-language-server fails for yaml version [#711](https://github.com/redhat-developer/yaml-language-server/issues/711)
- Fix: Missing Schema from catalog.json in ui [#747] (https://github.com/redhat-developer/vscode-yaml/issues/747)
- Fix: JSON Schema not applied for custom file extension [#701] (https://github.com/redhat-developer/vscode-yaml/issues/701)
- Add: Enable eslint import checks [#716] (https://github.com/redhat-developer/yaml-language-server/pull/716)
- Add: object with additional properties completion [#717] (https://github.com/redhat-developer/yaml-language-server/pull/717)
- Fix: Unable to get suggestions without typing a specific order of parameters [#705] (https://github.com/redhat-developer/vscode-yaml/issues/705)
- Add: add completion for additionalProperties propertyName [#720] (https://github.com/redhat-developer/yaml-language-server/pull/720)
- Fix: use virtual caret in tests [#722] (https://github.com/redhat-developer/yaml-language-server/pull/722)
- Add: Add nova-yaml to extension readme [#723] (https://github.com/redhat-developer/yaml-language-server/pull/723)
Thanks to Petr Spacek and Grant Dickinson
### 1.7.0
- Fix: merge simple property completion [#685](https://github.com/redhat-developer/yaml-language-server/pull/685)
- Fix: schemaStore.enable setting does not work as expected [#721](https://github.com/redhat-developer/vscode-yaml/issues/721)
- Fix: oneOf: misleading validation failures with Incorrect type. Expected "object" [#692](https://github.com/redhat-developer/vscode-yaml/issues/692)
- Fix: Yaml errors after updating to v1.5.0 [#708](https://github.com/redhat-developer/vscode-yaml/issues/708)
- Fix: Complex YAML generates many linting errors [#712](https://github.com/redhat-developer/vscode-yaml/issues/712)
- Chore: Upgrade `yaml` parser to `2.0.0-11` [#693](https://github.com/redhat-developer/yaml-language-server/pull/693)
- Fix: Subschema mappings wrongly assign the parent schema file [#694](https://github.com/redhat-developer/yaml-language-server/issues/694)
- Feat: Select parent skeleton first before other properties are suggested [#691](https://github.com/redhat-developer/yaml-language-server/pull/691)
- Fix: change completion that is invoked just after array symbol [#698](https://github.com/redhat-developer/yaml-language-server/pull/698)
- Fix: fix array completion in the middle of the empty text [#697](https://github.com/redhat-developer/yaml-language-server/pull/697)
- Fix: completion in the middle of the empty text [#696](https://github.com/redhat-developer/yaml-language-server/pull/696)
- Chore: Update mocha to 9.2.2 [#706](https://github.com/redhat-developer/yaml-language-server/pull/706)
Thanks to Petr Spacek
### 1.6.0
- Add: differentiate similar schemas on completion [#681](https://github.com/redhat-developer/yaml-language-server/pull/681)
- Fix: changed on specific to undefined check instead of null and undefined check [#678](https://github.com/redhat-developer/yaml-language-server/issues/665)
- Fix: array object completion - should not suggest const [#620](https://github.com/redhat-developer/yaml-language-server/pull/670)
Thanks to Petr Spacek
### 1.5.1
- Fix: Yaml errors after updating to v1.5.0 [#708](https://github.com/redhat-developer/vscode-yaml/issues/708)
### 1.5.0
- Fix: TypeError: Cannot create property 'url' on string [#652](https://github.com/redhat-developer/yaml-language-server/issues/652)
- Fix: suggestion item title [#659](https://github.com/redhat-developer/yaml-language-server/pull/659)
- Remove data from unused anchor diagnostics [#661](https://github.com/redhat-developer/yaml-language-server/pull/661)
- doc: add vim-easycomplete support for yaml-lsp [#662](https://github.com/redhat-developer/yaml-language-server/pull/662)
- Remove duplicate codelens entries [#667](https://github.com/redhat-developer/yaml-language-server/pull/667)
- Add: show examples on hover. [#660](https://github.com/redhat-developer/yaml-language-server/pull/660)
- Fix: oneOf: misleading validation failures with Incorrect type. Expected "object" [#692](https://github.com/redhat-developer/vscode-yaml/issues/692)
- Fix: typos in doc [#700](https://github.com/redhat-developer/vscode-yaml/pull/700)
- Fix: using inline schema reference (# yaml-language-server: $schema) seems to not support relative paths [#587](https://github.com/redhat-developer/vscode-yaml/issues/587)
Thanks to lijing00333, Remco Haszing, Petr Spacek and yassun4dev
### 1.4.0
- Feat: Report unused anchors [#587](https://github.com/redhat-developer/yaml-language-server/issues/587)
- Fix: Formatter does not respect `Editor: Detect Indentation = false` [#573](https://github.com/redhat-developer/vscode-yaml/issues/573)
- Fix: Flakiness in validator: Incorrect type. Expected "string" [#671](https://github.com/redhat-developer/vscode-yaml/issues/671)
- Fix: TypeError: Cannot read property 'filter' of undefined [#651](https://github.com/redhat-developer/vscode-yaml/issues/651)
- Fix: TypeError: Cannot create property 'url' on string 'array' [#653](https://github.com/redhat-developer/vscode-yaml/issues/653)
- Fix: Hover doesn't show up when a new line is behind nested prop with null value [#615](https://github.com/redhat-developer/yaml-language-server/issues/615)
- Fix: Error "Matches multiple schemas" is recognized in v1.2.2 but not in v1.3.0 [#683](https://github.com/redhat-developer/vscode-yaml/issues/683)
- Fix: Schema validation matches @bitnami as a uri-formatted string. [#586](https://github.com/redhat-developer/yaml-language-server/issues/586)
### 1.3.0
- Fix: Wrong hover information [#647](https://github.com/redhat-developer/vscode-yaml/issues/647)
- Fix: relative file paths with fragments [#603](https://github.com/redhat-developer/yaml-language-server/pull/603)
- Update K8S json schema version from 1.20.5 to 1.22.4 [#611](https://github.com/redhat-developer/yaml-language-server/pull/611)
- Feat: extend array documentation on completion [#608](https://github.com/redhat-developer/yaml-language-server/pull/608)
- Feat: add more detail into anyOf array completion [#607](https://github.com/redhat-developer/yaml-language-server/pull/607)
- Feat: trim end $1 from completion [#609](https://github.com/redhat-developer/yaml-language-server/pull/609)
- Fix: auto-complete is not working properly [#563](https://github.com/redhat-developer/yaml-language-server/issues/563)
- Fix: TypeError: Cannot read property 'type' of undefined [#652](https://github.com/redhat-developer/vscode-yaml/issues/652)
- Feat: Improve telemetry error logging [#602](https://github.com/redhat-developer/yaml-language-server/pull/602)
- Fix: completion invoke in three different scenarios [#617](https://github.com/redhat-developer/yaml-language-server/pull/617)
- Fix: DefaultSnippets quick suggestions don't show description if they overlap with const defined in if else [#642](https://github.com/redhat-developer/vscode-yaml/issues/642)
- Fix: If maxProperties is set, completion does not work for the last property [#612](https://github.com/redhat-developer/yaml-language-server/issues/612)
- Feat: Add convert to boolean code action [#622](https://github.com/redhat-developer/yaml-language-server/pull/622)
- Remove `getSchemas` method [#626](https://github.com/redhat-developer/yaml-language-server/pull/626)
- Lock `vscode-json-languageservice@4.1.8` [#637](https://github.com/redhat-developer/yaml-language-server/pull/637)
- Feat: disable default props [#606](https://github.com/redhat-developer/yaml-language-server/pull/606)
- Fix: Schema validation matches `@bitnami` as a uri-formatted string. [#586](https://github.com/redhat-developer/yaml-language-server/issues/586)
- Fix: Array indent doesn't work properly inside another array [#634](https://github.com/redhat-developer/yaml-language-server/pull/634)
- Fix: _PROXY environment and setting not honoured since 1.1.1 [#588](https://github.com/redhat-developer/yaml-language-server/issues/588)
- Fix: array indent on different index position [#635](https://github.com/redhat-developer/yaml-language-server/pull/635)
- Feat: parent completion [#628](https://github.com/redhat-developer/yaml-language-server/pull/628)
Thanks to tonypai, Martti Laine, Petr Spacek, sfalmo
### 1.2.2
- Fix: LSP triggeringregisterCapability despite dynamicRegistration set to false [#583](https://github.com/redhat-developer/yaml-language-server/issues/583)
- Add methods which allow client get schemas info [#556](https://github.com/redhat-developer/yaml-language-server/pull/556)
- Fix: links error reporting [#596](https://github.com/redhat-developer/yaml-language-server/pull/596)
### 1.2.1
- Fix: Can not load schema file when the URL is redirected. [#586](https://github.com/redhat-developer/vscode-yaml/issues/586)
- docs: fix typos [#592](https://github.com/redhat-developer/yaml-language-server/pull/592)
- Fix: Schema comment still not working properly in 1.1.0. [#629](https://github.com/redhat-developer/vscode-yaml/issues/629)
- Fix: document symbols, when key is not string [#594](https://github.com/redhat-developer/yaml-language-server/pull/594)
Thanks to Alexander Steppke and dundargoc
### 1.2.0
- Fix: Pattern (Regex) not parsed correctly, e.g. `^[\w\-_]+$` [#636](https://github.com/redhat-developer/vscode-yaml/issues/636)
- Fix: Autocomplete bug with nested objects in arrays in the 1.0.0 version [#621](https://github.com/redhat-developer/vscode-yaml/issues/621)
- Add: Implementation `Go to Definition` for alias nodes [#541](https://github.com/redhat-developer/yaml-language-server/issues/541)
- Provide completion for reachable schema [#560](https://github.com/redhat-developer/yaml-language-server/issues/560)
- Fix: very slow completion with aws cloudformation schema [#626](https://github.com/redhat-developer/vscode-yaml/issues/626)
Thanks to Aurélien Pupier
### 1.1.1
- Fix: Autocomplete should not escape colon without white-space following [#571](https://github.com/redhat-developer/yaml-language-server/issues/571)
- Fix: Unescape regexp string to be compatible with 'u' flag [#576](https://github.com/redhat-developer/yaml-language-server/pull/576)
### 1.1.0
- Add Web VSCode support [#594](https://github.com/redhat-developer/vscode-yaml/pull/594)
- schemas: Unicode support for pattern and patternProperties keywords [#554](https://github.com/redhat-developer/yaml-language-server/issues/554)
- Fix: IntelliSense broken with v1.0.0 [#616](https://github.com/redhat-developer/vscode-yaml/issues/616)
- Fix: Cannot read property '0' of undefined Code [#617](https://github.com/redhat-developer/vscode-yaml/issues/617)
- Fix: Completion of second level for Camel K files are no more working [#619](https://github.com/redhat-developer/vscode-yaml/issues/619)
- Provide completion for inlined schema syntax [#559](https://github.com/redhat-developer/yaml-language-server/issues/559)
- Fix: Schema comment ignored if it isn't the first line in the file. [#618](https://github.com/redhat-developer/vscode-yaml/issues/618)
Thanks to Johnny Graettinger, Martin Aeschlimann and Aurélien Pupier
### 1.0.0
- Use [eemeli/yaml](https://github.com/eemeli/yaml) as YAML parser [#421](https://github.com/redhat-developer/yaml-language-server/issues/421)
- Fix: Completion provider: t.replace is not a function [#547](https://github.com/redhat-developer/yaml-language-server/issues/547)
### 0.23.0
- Replace js-yaml with yaml [#526](https://github.com/redhat-developer/yaml-language-server/pull/526)
- Update monaco-yaml link in docs [#527](https://github.com/redhat-developer/yaml-language-server/pull/527)
- Update vscode-nls and vscode-uri dependencies [#531](https://github.com/redhat-developer/yaml-language-server/pull/531)
- Fix: error handling in hover and codelens [#534](https://github.com/redhat-developer/yaml-language-server/pull/534)
- Fix: 'label.replace is not a function' error [#544](https://github.com/redhat-developer/yaml-language-server/pull/544)
- Fix: Fragment resolution from #512 doesn't always work [#522](https://github.com/redhat-developer/yaml-language-server/issues/522)
Thanks to Remco Haszing
### 0.22.0
- Fix: fetching nested http settings [#511](https://github.com/redhat-developer/yaml-language-server/pull/511)
- Fix: Cannot create property 'url' on string 'en' [#556](https://github.com/redhat-developer/vscode-yaml/issues/556)
- Fix: Error on 'textDocument/codeLens' request [#497](https://github.com/redhat-developer/yaml-language-server/issues/497)
- Do not send `null` in to telemetry [#513](https://github.com/redhat-developer/yaml-language-server/pull/513)
- Fix: UnhandledPromiseRejectionWarning on jsonParser [#494](https://github.com/redhat-developer/yaml-language-server/issues/494)
- Fix: Schema URL fragments broken since 0.21.0 [#557](https://github.com/redhat-developer/vscode-yaml/issues/557)
- Fix: Unhandled Promise rejections with dynamicRegistration disabled [#498](https://github.com/redhat-developer/yaml-language-server/issues/498)
Thanks to Rob Anderson
### 0.21.1
- Fix: Unable to load remote schema with http protocol [#550](https://github.com/redhat-developer/vscode-yaml/issues/550)
- Log more errors in to telemetry [#508](https://github.com/redhat-developer/yaml-language-server/pull/508)
### 0.21.0
- Upgrade jsonc-parser to latest version [#492](https://github.com/redhat-developer/yaml-language-server/pull/492)
- Fix: Request textDocument/completion failed with message: label.replace is not a function [#536](https://github.com/redhat-developer/vscode-yaml/issues/536)
- Fix: `TypeError: customTags.filter is not a function` [#495](https://github.com/redhat-developer/yaml-language-server/pull/495)
- Support relative path in inline schema comment [#499](https://github.com/redhat-developer/yaml-language-server/pull/499)
- Improve hover to include title, description and source schema link [#480](https://github.com/redhat-developer/yaml-language-server/issues/480)
### 0.20.0
- Fix: Autocomplete not working when certain characters are in object property keys [#496](https://github.com/redhat-developer/vscode-yaml/issues/496) [#474](https://github.com/redhat-developer/yaml-language-server/issues/474)
- `workspace/configuration` request used to fetch preferences [#327](https://github.com/redhat-developer/yaml-language-server/issues/327)
- Now `main` branch used as default [#472](https://github.com/redhat-developer/yaml-language-server/issues/472)
- Fix: Schema link does not work when schema is a local file [#513](https://github.com/redhat-developer/vscode-yaml/issues/513)
### 0.19.2
- Remove fileMatch workaround, now glob patterns should work as expected [#467](https://github.com/redhat-developer/yaml-language-server/pull/467)
### 0.19.1
- Fix: "Billion Laughs" attack [#463](https://github.com/redhat-developer/yaml-language-server/issues/463)
- Added implementation of telemetry event [#439](https://github.com/redhat-developer/yaml-language-server/issues/439)
- Added option to specify custom schema store [#459](https://github.com/redhat-developer/yaml-language-server/pull/459)
Thanks to Ryan (hackercat)
### 0.19.0
- Fix: Inconsistent way to generate whole property snippet and value snippet, when it contains `\"` [#353](https://github.com/redhat-developer/yaml-language-server/issues/353)
- Upgrade to `4.1.0` version of `vscode-json-languageservice` which enables used of the extended glob patterns. [#448](https://github.com/redhat-developer/yaml-language-server/pull/448)
- Fix: Anchor on property which uses alias fails validation [#273](https://github.com/redhat-developer/yaml-language-server/issues/273)
- Update `js-yaml` to `4.1.0` [#454](https://github.com/redhat-developer/yaml-language-server/pull/454)
- Add monaco-yaml in the readme under clients [#455](https://github.com/redhat-developer/yaml-language-server/pull/455)
- Add support for `maxItemsComputed` for document symbols and folding ranges [#444](https://github.com/redhat-developer/yaml-language-server/pull/444)
- Add config parameter to disable additional properties [#452](https://github.com/redhat-developer/yaml-language-server/pull/452)
- add safety measure for preventing use of npm instead of yarn (engines version trick) [#458](https://github.com/redhat-developer/yaml-language-server/pull/458)
Thanks to Andrew Metcalf, Remco Haszing, Petr Spacek and Sorin Sbarnea
### 0.18.0
- Fix: additionalItems does not support $ref [#408](https://github.com/redhat-developer/yaml-language-server/issues/408)
- Fix: vscode/jsonschema markdownDescription support seems patchy [#417](https://github.com/redhat-developer/vscode-yaml/issues/417)
- Fix: Inconsistent way to generate whole property snippet and value snippet, when it contains `\"` [#353](https://github.com/redhat-developer/yaml-language-server/issues/353)
- Fix: Keys requiring quotation can bork the schema [#439](https://github.com/redhat-developer/vscode-yaml/issues/439)
- Fix: yaml.customTags not working in `0.17.0` [#461](https://github.com/redhat-developer/vscode-yaml/issues/461)
- Fix: unknown tag <tag:yaml.org,2002:str> [#173](https://github.com/redhat-developer/vscode-yaml/issues/173)
### 0.17.0
- Disable folding range provider [#400](https://github.com/redhat-developer/yaml-language-server/issues/400)
- Re-add schema priority levels [#418](https://github.com/redhat-developer/yaml-language-server/pull/418)
- Fix: No diagnostics reported on empty files [#413](https://github.com/redhat-developer/yaml-language-server/issues/413)
- Update kubernetes schema to 1.20.5 [#429](https://github.com/redhat-developer/yaml-language-server/pull/429)
- Add CodeLens with links to JSON Schema used [#424](https://github.com/redhat-developer/yaml-language-server/pull/424)
- Fix: Completion for existing property [#428](https://github.com/redhat-developer/yaml-language-server/pull/428)
### 0.16.0
- CodeAction to open json schema from yaml error [#395](https://github.com/redhat-developer/yaml-language-server/pull/395)
- Upgrade to `4.0.2` vscode-json-languageservice [#405](https://github.com/redhat-developer/yaml-language-server/issues/405)
- feat: add ability to delete all schemas from cache [#397](https://github.com/redhat-developer/yaml-language-server/pull/397)
- feat: multiple schema distinction in validation [#410](https://github.com/redhat-developer/yaml-language-server/pull/410)
- Fix: Object autocompletion in arrays with custom indentation produces invalid output [#432](https://github.com/redhat-developer/vscode-yaml/issues/432)
- Fix: Auto completing an object underneath an array can produce the wrong indentation [#392](https://github.com/redhat-developer/yaml-language-server/issues/392)
- CodeAction to convert Tab characters to spaces [#416](https://github.com/redhat-developer/yaml-language-server/pull/416)
- Fix: Incorrect Matching Against Schema Store [#354](https://github.com/redhat-developer/vscode-yaml/issues/354)
- Fix: Uses the wrong schema, even when yaml.schemas is set [#397](https://github.com/redhat-developer/vscode-yaml/issues/397)
- feat: add new params to completion snippet [#388](https://github.com/redhat-developer/yaml-language-server/pull/388)
Thanks to Petr Spacek
### 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)
- Keep space before word after inserting completion [#363](https://github.com/redhat-developer/yaml-language-server/pull/363)
- Update readme with example of an array of glob patterns for schema [#366](https://github.com/redhat-developer/yaml-language-server/pull/366)
- Add Dockerfile [#335](https://github.com/redhat-developer/yaml-language-server/issues/335)
- Fix: Code completion list empty on empty file [#349](https://github.com/redhat-developer/vscode-yaml/issues/349)
- Fix: Autocompletion missing space in value for default snippets when autocompleting on root node [#364](https://github.com/redhat-developer/yaml-language-server/issues/364)
- Check if dynamic registration is enabled before executing onDidChangeWorkspaceFolders [#378](https://github.com/redhat-developer/yaml-language-server/pull/378)
- Fix: Array indentation in autocomplete is broken after upgrade to 0.13 [#376](https://github.com/redhat-developer/yaml-language-server/issues/376)
- Added folding ranges provider implementation [#337](https://github.com/redhat-developer/yaml-language-server/issues/337)
- Fix: Hover doesn't work when there is now symbol after property [#382](https://github.com/redhat-developer/yaml-language-server/pull/382)
- Fix: Code completion array new line ending with no indent [#384](https://github.com/redhat-developer/yaml-language-server/pull/384)
- Fix: Code completion with defaultSnippet and makdown [#385](https://github.com/redhat-developer/yaml-language-server/pull/385)
### 0.13.0
- Improve 'hover' with complex k8s schemas [#347](https://github.com/redhat-developer/yaml-language-server/pull/347)
- Allow array for fileMatch in yamlValidation contribution, now this property complies with `contributes.jsonValidation` [#348](https://github.com/redhat-developer/yaml-language-server/pull/348)
- yaml-language-server now compatible with the newest version of vscode-json-languageservice. [#350](https://github.com/redhat-developer/yaml-language-server/pull/350)
- Code cleanup related to Promises usage [#351](https://github.com/redhat-developer/yaml-language-server/pull/351) and [#352](https://github.com/redhat-developer/yaml-language-server/pull/352)
- Fix: If blocks don't evaluate properties correctly [#393](https://github.com/redhat-developer/vscode-yaml/issues/393)
### 0.12.0
- Fix: Error when file has "Type" attribute [#317](https://github.com/redhat-developer/yaml-language-server/issues/317)
- Added all user settings in to README.md [#334](https://github.com/redhat-developer/yaml-language-server/pull/334)
- Added schema information (schema title or URL) to diagnostic [#310](https://github.com/redhat-developer/yaml-language-server/issues/310)
- Fix: autogenerated snippet for keys that contain an array of objects is badly indented [#329](https://github.com/redhat-developer/yaml-language-server/issues/329)
- Fix: example string of type integer gets pasted as int [#371](https://github.com/redhat-developer/vscode-yaml/issues/371)
- Fix: Auto completion can't suggest string enums correctly in Flow Style content. [#239](https://github.com/redhat-developer/yaml-language-server/issues/239)
### 0.11.1
- Fix: Latest version breaks auto-save formatting [#366](https://github.com/redhat-developer/vscode-yaml/issues/366)
### 0.11.0
- Make yaml-language-server available as ESM and UMD modules in the `/lib` directory [#305](https://github.com/redhat-developer/yaml-language-server/pull/305)
- Fix: `yaml.schemas` configuration doesn't work on windows with full path [#347](https://github.com/redhat-developer/vscode-yaml/issues/347)
- Completion text use space instead of tab for indentation [#283](https://github.com/redhat-developer/yaml-language-server/issues/283)
- YAML Schemas can now be used for validation [#318](https://github.com/redhat-developer/yaml-language-server/pull/318)
### 0.10.1
- Fix for cannot read property 'lineComments' of undefined Code: -32603 [redhat-developer/vscode-yaml#312](https://github.com/redhat-developer/vscode-yaml/issues/358)
### 0.10.0
- Allows to declare a schema inside the yaml file through modeline `# yaml-language-server: $schema=<urlOfTheSchema>` [#280](https://github.com/redhat-developer/yaml-language-server/pull/280)
- Insert empty string instead of 'null' for string array completion [#277](https://github.com/redhat-developer/yaml-language-server/pull/277)
- Handle workspace/workspaceFolders event for multi root workspaces [#281](https://github.com/redhat-developer/yaml-language-server/pull/281)
- Provide default object as completion snippet [#291] https://github.com/redhat-developer/yaml-language-server/pull/291
- Add validation of date and time formats [#292](https://github.com/redhat-developer/yaml-language-server/pull/292)
- Fix document symbols computation if yaml has complex mappings [#293](https://github.com/redhat-developer/yaml-language-server/pull/293)
### 0.9.0
- Improve Diagnostic positions [#260](https://github.com/redhat-developer/yaml-language-server/issues/260)
- Support `maxProperties` when providing completion [#269](https://github.com/redhat-developer/yaml-language-server/issues/269)
- Fix for required attributes are inserted with wrong level of indentation on first array item [redhat-developer/vscode-yaml#312](https://github.com/redhat-developer/vscode-yaml/issues/312)
- Use https endpoints for schemastore [#PR](https://github.com/redhat-developer/yaml-language-server/pull/264)
### 0.8.0
- Start using yarn for everything instead of npm
- Allow for partial configurations in onDidChangeConfiguration [#256](https://github.com/redhat-developer/yaml-language-server/issues/256)
- Support for textDocument/findDefinition [#PR](https://github.com/redhat-developer/yaml-language-server/pull/257)
- Fix kubernetes schema back to 1.17.0 [#PR](https://github.com/redhat-developer/yaml-language-server/pull/236)
- Fix for @ symbol in relative path [#PR](https://github.com/redhat-developer/yaml-language-server/pull/254)
- Fix for null literals [#118](https://github.com/redhat-developer/yaml-language-server/issues/118)
- Fix for autocompletion on default values [#281](https://github.com/redhat-developer/vscode-yaml/issues/281)
### 0.7.2
- Fix the way default snippets is handled when we have boolean values [#PR](https://github.com/redhat-developer/yaml-language-server/pull/234)
### 0.7.1
- Allow contributor API to contribute multiple schemas for the same file [#PR](https://github.com/redhat-developer/yaml-language-server/pull/227)
- Fix issue with arrays in default snippets [#PR](https://github.com/redhat-developer/yaml-language-server/pull/226)
### 0.7.0
- Updates kubernetes schema to 1.17.0 [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/68d0f395ccc12abf9f180fa39ce49b77d52863ad)
- Added API for modifiying schemas in memory [#151](https://github.com/redhat-developer/yaml-language-server/issues/151)
- Updated yaml completion to use JSON 7 Parser [#150](https://github.com/redhat-developer/yaml-language-server/issues/150)
- Server side snippet support [#205](https://github.com/redhat-developer/yaml-language-server/issues/205)
- Fix issue with language server not issuing warnings on duplicate keys [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/20a8b07cd8f054d1374cbab17ef479320ac5669c)
- Fix for collecting completion items if array contains objects [#PR](https://github.com/redhat-developer/yaml-language-server/pull/224)
- Fix for merge key error with JSON Schema [#PR](https://github.com/redhat-developer/yaml-language-server/pull/222)
### 0.6.1
- Fix for setting kubernetes in yaml.schemas gives error [#202](https://github.com/redhat-developer/yaml-language-server/issues/202)
### 0.6.0
- Fix for schema sequence custom property [#PR](https://github.com/redhat-developer/yaml-language-server/pull/197)
- Fix for obeying the initialization specification [#PR](https://github.com/redhat-developer/yaml-language-server/pull/193)
### 0.5.8
- Remove document range formatter registration [#PR](https://github.com/redhat-developer/yaml-language-server/pull/179)
- Catch errors that happen when schema store schemas cannot be grabbed [#PR](https://github.com/redhat-developer/yaml-language-server/pull/183)
### 0.5.7
- Fix for custom schema contributor API [#PR](https://github.com/redhat-developer/yaml-language-server/pull/177)
- Disable range formatter in initialize [#PR](https://github.com/redhat-developer/yaml-language-server/pull/178)
### 0.5.6
- Include the package-lock.json
### 0.5.5
- Fix for language server initialize erroring when rootURI is not set
### 0.5.4
- Fix for autocompletion not working when there are multiple enums available
- Fix for showing the correct validation when a key has an associated null value for kubernetes
- Add Eclipse Wild Web Developer as client
- Fix for Array item properties being created with the wrong indent
- Update of various dependencies
### 0.5.3
- Make prettier an optional dependency because of issues with webpack
### 0.5.2
- Adds in custom kubernetes schema comparator
### 0.5.1
- Adds in missing js-yaml dependency
### 0.5.0
- Fixed offset of undefined when hovering [#162](https://github.com/redhat-developer/yaml-language-server/issues/162)
- Fixed relative path schema loading [#154](https://github.com/redhat-developer/yaml-language-server/issues/154)
- Realigned features of YAML Language Server with JSON Language Server [#142](https://github.com/redhat-developer/yaml-language-server/issues/142)
### 0.4.1
- Updated the kubernetes schema to be an upstream one [#PR](https://github.com/redhat-developer/yaml-language-server/pull/108)
### 0.4.0
- Allow custom tags to have multiple types [#77](https://github.com/redhat-developer/yaml-language-server/issues/77)
- Made the formatter respect the yaml.format.enable setting [#PR](https://github.com/redhat-developer/yaml-language-server/pull/126)
- yaml-language-server command is now executable [#PR](https://github.com/redhat-developer/yaml-language-server/pull/130)
### 0.3.2
- Only set CompletionItem.textEdit if it encompasses a single line [#139](https://github.com/redhat-developer/vscode-yaml/issues/139)
### 0.3.1
- Fixed custom tags crashing the language server [#112](https://github.com/redhat-developer/yaml-language-server/commit/4bcd36d629ef2c64641dc6edc948dbd02f35c437)
- Added setting yaml.schemaStore.enable to enable/disable the schema store [#115](https://github.com/redhat-developer/yaml-language-server/commit/4aa28a7dacadcc68126bd26e3b5311e046348799)
- Use the language server tab size when formatting [#116](https://github.com/redhat-developer/yaml-language-server/commit/1458e25926c7189cefc383141f4fad1d14a568b8)
### 0.2.1
- Added fix for language server crashing when settings.yaml.format was not sent [#111](https://github.com/redhat-developer/yaml-language-server/issues/111)
### 0.2.0
- Added fix for bracket spacing option in formatter [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/3b79ef397dbd215744c4577da9227298b3447bad)
- Added fix for boolean type [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/9351ef54348e0a967a672e7c0f45b091ed53c533)
### 0.1.0
- Added a new formatter that uses prettier [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/a5092e3d33a2e208bfea7941076518dedd2aba7b)
- Added a registration for custom schema provider extension [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/c82830b2e1933fae6197d09e85b1e637b46b3896)
- Add ability to toggle hover and autocompletion [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/0e4192cfacbbb5d442f817a7337d388ac3d01eff)
### 0.0.19
- Support intellisense default value [#86](https://github.com/redhat-developer/yaml-language-server/pull/86)
- Fix intellisense doesn't work for array item [#85](https://github.com/redhat-developer/yaml-language-server/pull/85)
### 0.0.18
- Fix handling scenario of multiple documents in single yaml file [#81](https://github.com/redhat-developer/yaml-language-server/commit/38da50092285aa499930d0e95fbbd7960b37b670)
- Support associate schemas with files in a regular expression [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/d4a05e3dd72f55c53f1b0325c521a58f688839c9)
### 0.0.15
- Fixed dynamic registration of formatter [#74](https://github.com/redhat-developer/yaml-language-server/issues/74)
### 0.0.14
- Bumped to fix jenkins errors
### 0.0.13
- Show errors if schema cannot be grabbed [#73](https://github.com/redhat-developer/yaml-language-server/issues/73)
- The validator should support null values [#72](https://github.com/redhat-developer/yaml-language-server/issues/72)
- Server returning nothing on things such as completion errors Eclipse Che [#66](https://github.com/redhat-developer/yaml-language-server/issues/66)
- Return promises that resolve to null [#PR-71](https://github.com/redhat-developer/yaml-language-server/pull/71)
- Remove unused dependency to deep-equal [#PR-70](https://github.com/redhat-developer/yaml-language-server/pull/70)
- Added custom tags to autocompletion [#Commit](https://github.com/redhat-developer/yaml-language-server/commit/73c244a3efe09ec4250def78068c54af3acaed58)
### 0.0.12
- Support for custom tags [#59](https://github.com/redhat-developer/yaml-language-server/issues/59)
- Incorrect duplicate key registered when using YAML anchors [#82](https://github.com/redhat-developer/vscode-yaml/issues/82)
- Automatically insert colon on autocomplete [#78](https://github.com/redhat-developer/vscode-yaml/issues/78)
### 0.0.11
- Fix for completion helper if it contains \r [#37](https://github.com/redhat-developer/yaml-language-server/issues/37)
### 0.0.10
- Programmatically associate YAML files with schemas by other extensions [#61](https://github.com/redhat-developer/vscode-yaml/issues/61)
- Autocompletion not triggered while typing [#46](https://github.com/redhat-developer/vscode-yaml/issues/46)
### 0.0.9
- Remove console.log from jsonSchemaService [#49](https://github.com/redhat-developer/yaml-language-server/issues/49)
- Change "Property {\$property_name} is not allowed" error message [#42](https://github.com/redhat-developer/yaml-language-server/issues/42)
- New Kubernetes Schema + Updated support for Kubernetes [#40](https://github.com/redhat-developer/yaml-language-server/issues/40)
### 0.0.8
- Added Kedge back in as one of the default schemas
- Added file watch for json schema files in the workspace [#34](https://github.com/redhat-developer/yaml-language-server/issues/34)
- Multi root settings [#50](https://github.com/redhat-developer/vscode-yaml/issues/50)
- Fix for crashing yaml language server when !include is present [#52](https://github.com/redhat-developer/vscode-yaml/issues/52)
- Update tests to work on windows [#30](https://github.com/redhat-developer/yaml-language-server/issues/30)
### 0.0.7
- Added validation toggle in settings [#20](https://github.com/redhat-developer/yaml-language-server/issues/20)
- YAML Schemas are pulled from JSON Schema Store [#15](https://github.com/redhat-developer/yaml-language-server/issues/15)
- YAML Diagnostics throw on a single line instead of the entire file [#19](https://github.com/redhat-developer/yaml-language-server/issues/19)
- Fix for getNodeFromOffset [#18](https://github.com/redhat-developer/yaml-language-server/issues/18)
### 0.0.6
- Hotfix for making multiple schemas in the settings work again
### 0.0.5
- Fixed Schema validation reports errors in valid YAML document [#42](https://github.com/redhat-developer/vscode-yaml/issues/42)
- Fixed Support for multiple YAML documents in single file [#43](https://github.com/redhat-developer/vscode-yaml/issues/43)
### 0.0.4
- Fixed support for kubernetes files
- Fixed boolean notation for validation [#40](https://github.com/redhat-developer/vscode-yaml/issues/40)
- Fixed autocompletion for first new list item [#39](https://github.com/redhat-developer/vscode-yaml/issues/39)
### 0.0.3
- Added new autocompletion service which is better for json schemas
- Added yamlValidation contribution point [#37](https://github.com/redhat-developer/vscode-yaml/issues/37)
### 0.0.1
- Initial release with support for hover, document outlining, validation and auto completion

View File

@@ -0,0 +1,8 @@
## Contributing
### Certificate of Origin
By contributing to this project you agree to the Developer Certificate of
Origin (DCO). This document was created by the Linux Kernel community and is a
simple statement that you, as a contributor, have the legal right to make the
contribution. See the [DCO](DCO) file for details.

View File

@@ -0,0 +1,37 @@
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

View File

@@ -0,0 +1,11 @@
FROM node:lts
WORKDIR /yaml-language-server
COPY . .
RUN npm install && \
npm run build
ENTRYPOINT [ "node", "./out/server/src/server.js" ]
CMD [ "--stdio" ]

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Red Hat Inc. and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,425 @@
![CI](https://github.com/redhat-developer/yaml-language-server/workflows/CI/badge.svg) [![version](https://img.shields.io/npm/v/yaml-language-server.svg)](https://www.npmjs.com/package/yaml-language-server) [![Coverage Status](https://coveralls.io/repos/github/redhat-developer/yaml-language-server/badge.svg?branch=main)](https://coveralls.io/github/redhat-developer/yaml-language-server?branch=main)
# YAML Language Server
Supports JSON Schema 7 and below.
Starting from `1.0.0` the language server uses [eemeli/yaml](https://github.com/eemeli/yaml) as the new YAML parser, which strictly enforces the specified YAML spec version. Default YAML spec version is `1.2`, it can be changed with `yaml.yamlVersion` setting.
## Features
1. YAML validation:
- Detects whether the entire file is valid yaml
2. Validation:
- Detects errors such as:
- Node is not found
- Node has an invalid key node type
- Node has an invalid type
- Node is not a valid child node
- Detects warnings such as:
- Node is an additional property of parent
3. Auto completion:
- Auto completes on all commands
- Scalar nodes autocomplete to schema's defaults if they exist
4. Hover support:
- Hovering over a node shows description _if available_
5. Document outlining:
- Shows a complete document outline of all nodes in the document
## Language Server Settings
The following settings are supported:
- `yaml.yamlVersion`: Set default YAML spec version (1.2 or 1.1)
- `yaml.format.enable`: Enable/disable default YAML formatter (requires restart)
- `yaml.format.singleQuote`: Use single quotes instead of double quotes
- `yaml.format.bracketSpacing`: Print spaces between brackets in objects
- `yaml.format.proseWrap`: Always: wrap prose if it exceeds the print width, Never: never wrap the prose, Preserve: wrap prose as-is
- `yaml.format.printWidth`: Specify the line length that the printer will wrap on
- `yaml.validate`: Enable/disable validation feature
- `yaml.hover`: Enable/disable hover
- `yaml.completion`: Enable/disable autocompletion
- `yaml.schemas`: Helps you associate schemas with files in a glob pattern
- `yaml.schemaStore.enable`: When set to true the YAML language server will pull in all available schemas from [JSON Schema Store](https://www.schemastore.org)
- `yaml.schemaStore.url`: URL of a schema store catalog to use when downloading schemas.
- `yaml.customTags`: Array of custom tags that the parser will validate against. It has two ways to be used. Either an item in the array is a custom tag such as "!Ref" and it will automatically map !Ref to scalar or you can specify the type of the object !Ref should be e.g. "!Ref sequence". The type of object can be either scalar (for strings and booleans), sequence (for arrays), map (for objects).
- `yaml.maxItemsComputed`: The maximum number of outline symbols and folding regions computed (limited for performance reasons).
- `[yaml].editor.tabSize`: the number of spaces to use when autocompleting. Takes priority over editor.tabSize.
- `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
- `yaml.disableDefaultProperties`: Disable adding not required properties with default values into completion text
- `yaml.suggest.parentSkeletonSelectedFirst`: If true, the user must select some parent skeleton first before autocompletion starts to suggest the rest of the properties.\nWhen yaml object is not empty, autocompletion ignores this setting and returns all properties and skeletons.
- `yaml.style.flowMapping` : Forbids flow style mappings if set to `forbid`
- `yaml.style.flowSequence` : Forbids flow style sequences if set to `forbid`
- `yaml.keyOrdering` : Enforces alphabetical ordering of keys in mappings when set to `true`. Default is `false`
##### Adding custom tags
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.customTags": [
"!Scalar-example scalar",
"!Seq-example sequence",
"!Mapping-example mapping"
]
```
The !Scalar-example would map to a scalar custom tag, the !Seq-example would map to a sequence custom tag, the !Mapping-example would map to a mapping custom tag.
We can then use the newly defined custom tags inside our YAML file:
```yaml
some_key: !Scalar-example some_value
some_sequence: !Seq-example
- some_seq_key_1: some_seq_value_1
- some_seq_key_2: some_seq_value_2
some_mapping: !Mapping-example
some_mapping_key_1: some_mapping_value_1
some_mapping_key_2: some_mapping_value_2
```
##### Associating a schema to a glob pattern via yaml.schemas:
yaml.schemas applies a schema to a file. In other words, the schema (placed on the left) is applied to the glob pattern on the right. Your schema can be local or online. Your schema path must be relative to the project root and not an absolute path to the schema.
For example:
If you have project structure
myProject
&nbsp;&nbsp;&nbsp;> myYamlFile.yaml
you can do
```yaml
yaml.schemas: {
"https://json.schemastore.org/composer": "/myYamlFile.yaml"
}
```
and that will associate the composer schema with myYamlFile.yaml.
## More examples of schema association:
### Using yaml.schemas settings
#### Single root schema association:
When associating a schema it should follow the format below
```yaml
yaml.schemas: {
"url": "globPattern",
"Kubernetes": "globPattern"
}
```
e.g.
```yaml
yaml.schemas: {
"https://json.schemastore.org/composer": "/*"
}
```
e.g.
```yaml
yaml.schemas: {
"kubernetes": "/myYamlFile.yaml"
}
```
e.g.
```yaml
yaml.schemas: {
"https://json.schemastore.org/composer": "/*",
"kubernetes": "/myYamlFile.yaml"
}
```
On Windows with full path:
```yaml
yaml.schemas: {
"C:\\Users\\user\\Documents\\custom_schema.json": "someFilePattern.yaml",
}
```
On Mac/Linux with full path:
```yaml
yaml.schemas: {
"/home/user/custom_schema.json": "someFilePattern.yaml",
}
```
Since `0.11.0` YAML Schemas can be used for validation:
```yaml
"/home/user/custom_schema.yaml": "someFilePattern.yaml"
```
A schema can be associated with multiple globs using a json array, e.g.
```yaml
yaml.schemas: {
"kubernetes": ["filePattern1.yaml", "filePattern2.yaml"]
}
```
e.g.
```yaml
"yaml.schemas": {
"http://json.schemastore.org/composer": ["/*"],
"file:///home/johnd/some-schema.json": ["some.yaml"],
"../relative/path/schema.json": ["/config*.yaml"],
"/Users/johnd/some-schema.json": ["some.yaml"],
}
```
e.g.
```yaml
"yaml.schemas": {
"kubernetes": ["/myYamlFile.yaml"]
}
```
e.g.
```yaml
"yaml.schemas": {
"http://json.schemastore.org/composer": ["/*"],
"kubernetes": ["/myYamlFile.yaml"]
}
```
#### Multi root schema association:
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
My_second_project:
test2.yaml
my_schema2.json
```
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"
}
```
`yaml.schemas` allows you to specify json schemas that you want to validate against the yaml that you write. Kubernetes is an optional field. It does not require a url as the language server will provide that. You just need the keyword kubernetes and a glob pattern.
### Nested Schema References
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",
}
```
> **Note**
> This will require reading your existing schema and understanding the schemastore structure a bit. (TODO: link to a documentation or blog post here?)
### Using inlined schema
It is possible to specify a yaml schema using a modeline.
```yaml
# yaml-language-server: $schema=<urlToTheSchema>
```
Also it is possible to use relative path in a modeline:
```yaml
# yaml-language-server: $schema=../relative/path/to/schema
```
or absolute path:
```yaml
# yaml-language-server: $schema=/absolute/path/to/schema
```
### Schema priority
The following is the priority of schema association in highest to lowest priority:
1. Modeline
2. CustomSchemaProvider API
3. yaml.settings
4. Schema association notification
5. Schema Store
## Containerized Language Server
An image is provided for users who would like to use the YAML language server without having to install dependencies locally.
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
```
## 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)
## 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:
- [Eclipse Che](https://www.eclipse.org/che/)
- [vscode-yaml](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) for VSCode
- [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
- [vim-lsp](https://github.com/prabirshrestha/vim-lsp) for Vim
- [LSP-yaml](https://packagecontrol.io/packages/LSP-yaml) for Sublime Text
- [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
### Getting started
1. Install prerequisites:
- latest [Visual Studio Code](https://code.visualstudio.com/)
- [Node.js](https://nodejs.org/) v12.0.0 or higher
2. Fork and clone this repository
3. Install the dependencies
```bash
cd yaml-language-server
$ npm install
```
4. Build the language server
```bash
$ npm run build
```
5. The new built server is now located in ./out/server/src/server.js.
```bash
node (Yaml Language Server Location)/out/server/src/server.js [--stdio]
```
### Connecting to the language server via stdio
We have included the option to connect to the language server via [stdio](https://github.com/redhat-developer/yaml-language-server/blob/681985b5a059c2cb55c8171235b07e1651b6c546/src/server.ts#L46-L51) to help with integrating the language server into different clients.
### ESM and UMD Modules
Building the YAML Language Server produces [CommonJS](http://www.commonjs.org/) modules in the `/out/server/src` directory. In addition, a build also produces [UMD](https://github.com/umdjs/umd) (Universal Module Definition) modules and [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) in the `/lib` directory. That gives you choices in using the YAML Language Server with different module loaders on the server side and in the browser with bundlers like webpack.
### CI
We use a GitHub Action to publish each change in the `main` branch to [npm registry](https://www.npmjs.com/package/yaml-language-server) with the `next` tag.
You may use the `next` version to adopt the latest changes into your project.

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../out/server/src/server.js');

View File

@@ -0,0 +1,56 @@
{
"Default Value": "Standardwert",
"json.schema.invalidref": "$ref '{0}' in '{1}' kann nicht aufgelöst werden.",
"json.schema.problemloadingref": "Probleme beim Laden der Referenz '{0}': {1}",
"json.schema.nocontent": "Schema konnte nicht von '{0}' geladen werden: Kein Inhalt.",
"json.schema.invalidFormat": "Inhalt von '{0}' konnte nicht analysiert werden: Analysefehler in Zeile:{1}, Spalte:{2}",
"colorHexFormatWarning": "Ungültiges Farbformat. Verwenden Sie #RGB, #RGBA, #RRGGBB oder #RRGGBBAA.",
"dateTimeFormatWarning": "Zeichenfolge ist kein RFC3339-Datum-Zeit-Wert.",
"dateFormatWarning": "Zeichenfolge ist kein RFC3339-Datum.",
"timeFormatWarning": "Zeichenfolge ist keine RFC3339-Zeit.",
"emailFormatWarning": "Zeichenfolge ist keine E-Mail-Adresse.",
"ipv4FormatWarning": "Zeichenfolge entspricht nicht dem IPv4-Format.",
"ipv6FormatWarning": "Zeichenfolge entspricht nicht dem IPv6-Format.",
"enumWarning": "Wert wird nicht akzeptiert. Gültige Werte: {0}.",
"typeArrayMismatchWarning": "Falscher Typ. Erwartet wird einer von {0}.",
"notSchemaWarning": "Entspricht einem Schema, das nicht zulässig ist.",
"oneOfWarning": "Entspricht mehreren Schemata, obwohl nur eines gültig sein darf.",
"ifFilePatternAssociation": "filePatternAssociation '{0}' stimmt nicht mit der Dokument-URI '{1}' überein",
"multipleOfWarning": "Wert ist nicht durch {0} teilbar.",
"exclusiveMinimumWarning": "Wert liegt unter dem exklusiven Minimum von {0}.",
"exclusiveMaximumWarning": "Wert liegt über dem exklusiven Maximum von {0}.",
"minimumWarning": "Wert liegt unter dem Minimum von {0}.",
"maximumWarning": "Wert liegt über dem Maximum von {0}.",
"minLengthWarning": "Zeichenfolge ist kürzer als die minimale Länge von {0}.",
"maxLengthWarning": "Zeichenfolge ist länger als die maximale Länge von {0}.",
"patternWarning": "Zeichenfolge stimmt nicht mit dem Muster \"{0}\" überein.",
"uriEmpty": "URI erwartet.",
"uriSchemeMissing": "URI mit Schema wird erwartet.",
"uriFormatWarning": "Zeichenfolge ist keine gültige URI: {0}",
"additionalItemsWarning": "Array hat zu viele Elemente laut Schema. Erwartet: {0} oder weniger.",
"requiredItemMissingWarning": "Array enthält das erforderliche Element nicht.",
"minItemsWarning": "Array hat zu wenige Elemente. Erwartet: {0} oder mehr.",
"maxItemsWarning": "Array hat zu viele Elemente. Erwartet: {0} oder weniger.",
"uniqueItemsWarning": "Array enthält doppelte Elemente.",
"DisallowedExtraPropWarning": "Eigenschaft {0} ist nicht erlaubt.",
"MaxPropWarning": "Objekt hat mehr Eigenschaften als das Limit von {0}.",
"MinPropWarning": "Objekt hat weniger Eigenschaften als die erforderliche Anzahl von {0}.",
"RequiredDependentPropWarning": "Objekt fehlt die Eigenschaft {0}, die von Eigenschaft {1} benötigt wird.",
"Inline schema": "Inline-Schema",
"create.item.array": "Ein Element eines Arrays erstellen{0}{1}",
"array.item": "- (Array-Element) ",
"allowedValues": "Erlaubte Werte:",
"example": "Beispiel:",
"source": "Quelle: [{0}]({1})",
"jumpToSchema": "Zur Schema-Position springen ({0})",
"convertToSpace": "Tab in Leerzeichen umwandeln",
"convertAllSpaceToTab": "Alle Tabs in Leerzeichen umwandeln",
"deleteUnusedAnchor": "Nicht verwendeten Anker löschen: {0}",
"convertToBoolean": "In Boolean umwandeln",
"convertToBlockStyle": "In Blockstil {0} umwandeln",
"fixKeyOrderToMap": "Schlüsselreihenfolge für diese Map korrigieren",
"flowStyleMapForbidden": "Flow-Stil-Mapping ist verboten",
"flowStyleSeqForbidden": "Flow-Stil-Sequenz ist verboten",
"unUsedAnchor": "Nicht verwendeter Anker \"{0}\"",
"unUsedAlias": "Nicht aufgelöstes Alias \"{0}\""
}

View File

@@ -0,0 +1,56 @@
{
"Default Value": "Valeur par défaut",
"json.schema.invalidref": "$ref '{0}' dans '{1}' ne peut pas être résolu",
"json.schema.problemloadingref": "Problèmes de chargement de la référence '{0}' : {1}",
"json.schema.noContent": "Impossible de charger le schéma à partir de {0}: aucun contenu.",
"json.schema.invalidFormat": "Impossible danalyser le contenu de {0}: erreur danalyse à la ligne:{1}, colonne:{2}",
"colorHexFormatWarning": "Format de couleur non valide. Utilisez #RGB, #RGBA, #RRGGBB ou #RRGGBBAA.",
"dateTimeFormatWarning": "La chaîne n'est pas une date-heure RFC3339.",
"dateFormatWarning": "La chaîne n'est pas une date RFC3339.",
"timeFormatWarning": "La chaîne n'est pas une heure RFC3339.",
"emailFormatWarning": "La chaîne n'est pas une adresse e-mail.",
"ipv4FormatWarning": "La chaîne ne correspond pas au format IPv4.",
"ipv6FormatWarning": "La chaîne ne correspond pas au format IPv6.",
"enumWarning": "Valeur non acceptée. Valeurs valides: {0}.",
"typeArrayMismatchWarning": "Type incorrect. On attend un des {0}.",
"notSchemaWarning": "Correspond à un schéma qui n'est pas autorisé.",
"oneOfWarning": "Correspond à plusieurs schémas lorsqu'un seul doit être validé.",
"ifFilePatternAssociation": "filePatternAssociation '{0}' ne correspond pas à l'URI du document '{1}'",
"multipleOfWarning": "La valeur n'est pas divisible par {0}.",
"exclusiveMinimumWarning": "La valeur est inférieure au minimum exclusif de {0}.",
"exclusiveMaximumWarning": "La valeur est supérieure au maximum exclusif de {0}.",
"minimumWarning": "La valeur est inférieure au minimum de {0}.",
"maximumWarning": "La valeur est supérieure au maximum de {0}.",
"minLengthWarning": "La chaîne est plus courte que la longueur minimale de {0}.",
"maxLengthWarning": "La chaîne est plus longue que la longueur maximale de {0}.",
"patternWarning": "La chaîne ne correspond pas au modèle de '{0}'.",
"uriEmpty": "URI attendu.",
"uriSchemeMissing": "Une URI avec un schéma est attendue.",
"uriFormatWarning": "La chaîne n'est pas un URI: {0}",
"additionalItemsWarning": "Le tableau contient trop d'éléments selon le schéma. Valeur attendue : {0} ou moins.",
"requiredItemMissingWarning": "Le tableau ne contient pas l'élément requis.",
"minItemsWarning": "Le tableau contient trop peu d'éléments. On attend {0} ou plus.",
"maxItemsWarning": "Le tableau contient trop d'éléments. On attend {0} ou moins.",
"uniqueItemsWarning": "Le tableau contient des éléments en double.",
"DisallowedExtraPropWarning": "La propriété {0} n'est pas autorisée.",
"MaxPropWarning": "L'objet a plus de propriétés que la limite de {0}.",
"MinPropWarning": "L'objet a moins de propriétés que le nombre requis de {0}",
"RequiredDependentPropWarning": "L'objet ne possède pas la propriété {0} requise par la propriété {1}.",
"Inline schema": "Schéma en ligne",
"create.item.array": "Créer un élément d'un tableau {0} {1}",
"array.item": "- (élément de tableau)",
"allowedValues": "Valeurs autorisées:",
"example": "Exemple:",
"source": "Source: [{0}]{1}",
"jumpToSchema": "Accéder à l'emplacement du schéma ({0})",
"convertToSpace": "Convertir les tabulations en espaces",
"convertAllSpaceToTab": "Convertir toutes les tabulations en espaces",
"deleteUnusedAnchor": "Supprimer l'ancre inutilisée: {0}",
"convertToBoolean": "Convertir en booléen",
"convertToBlockStyle": "Convertir en style de bloc {0}",
"fixKeyOrderToMap": "Corriger l'ordre des touches pour cette carte",
"flowStyleMapForbidden": "Le mappage de style de flux est interdit",
"flowStyleSeqForbidden": "La séquence de style Flow est interdite",
"unUsedAnchor": "Ancre inutilisée '{0}'",
"unUsedAlias": "Alias non résolu '{0}'"
}

View File

@@ -0,0 +1,56 @@
{
"Default Value": "デフォルト値",
"json.schema.invalidref": "'{1}' の $ref '{0}' を解決できません。",
"json.schema.problemloadingref": "参照 '{0}' の読み込み中に問題が発生しました: {1}",
"json.schema.nocontent": "'{0}' からスキーマを読み込めませんでした: コンテンツがありません。",
"json.schema.invalidFormat": "'{0}' の内容を解析できませんでした: 行 {1}、列 {2} で解析エラーが発生しました",
"colorHexFormatWarning": "無効なカラー形式です。#RGB、#RGBA、#RRGGBB、または #RRGGBBAA を使用してください。",
"dateTimeFormatWarning": "文字列は RFC3339 の日付と時刻形式ではありません。",
"dateFormatWarning": "文字列は RFC3339 の日付形式ではありません。",
"timeFormatWarning": "文字列は RFC3339 の時刻形式ではありません。",
"emailFormatWarning": "文字列はメールアドレスではありません。",
"ipv4FormatWarning": "文字列が IPv4 形式と一致しません。",
"ipv6FormatWarning": "文字列が IPv6 形式と一致しません。",
"enumWarning": "値が許可されていません。有効な値: {0}。",
"typeArrayMismatchWarning": "タイプが正しくありません。期待される型: {0} のいずれか。",
"notSchemaWarning": "許可されていないスキーマに一致しています。",
"oneOfWarning": "複数のスキーマに一致しています。1つだけが有効である必要があります。",
"ifFilePatternAssociation": "filePatternAssociation '{0}' がドキュメント URI '{1}' と一致しません",
"multipleOfWarning": "値は {0} で割り切れません。",
"exclusiveMinimumWarning": "値が {0} の排他的最小値より小さいです。",
"exclusiveMaximumWarning": "値が {0} の排他的最大値を超えています。",
"minimumWarning": "値が最小値 {0} を下回っています。",
"maximumWarning": "値が最大値 {0} を超えています。",
"minLengthWarning": "文字列の長さが最小長 {0} 未満です。",
"maxLengthWarning": "文字列の長さが最大長 {0} を超えています。",
"patternWarning": "文字列がパターン \"{0}\" に一致しません。",
"uriEmpty": "URI が必要です。",
"uriSchemeMissing": "スキームを含む URI が必要です。",
"uriFormatWarning": "文字列が有効な URI ではありません: {0}",
"additionalItemsWarning": "配列に含まれる項目数がスキーマの上限 {0} を超えています。",
"requiredItemMissingWarning": "配列に必要な項目が含まれていません。",
"minItemsWarning": "配列の項目数が少なすぎます。{0} 項目以上必要です。",
"maxItemsWarning": "配列の項目数が多すぎます。{0} 項目以下にしてください。",
"uniqueItemsWarning": "配列に重複する項目があります。",
"DisallowedExtraPropWarning": "プロパティ {0} は許可されていません。",
"MaxPropWarning": "オブジェクトのプロパティ数が制限値 {0} を超えています。",
"MinPropWarning": "オブジェクトのプロパティ数が必要数 {0} に満たないです。",
"RequiredDependentPropWarning": "プロパティ {1} によって必要とされるプロパティ {0} が存在しません。",
"Inline schema": "インラインスキーマ",
"create.item.array": "配列の項目を作成する{0}{1}",
"array.item": "- (配列項目)",
"allowedValues": "許可された値:",
"example": "例:",
"source": "出典: [{0}]({1})",
"jumpToSchema": "スキーマの位置へジャンプ ({0})",
"convertToSpace": "タブをスペースに変換",
"convertAllSpaceToTab": "すべてのスペースをタブに変換",
"deleteUnusedAnchor": "未使用のアンカーを削除: {0}",
"convertToBoolean": "ブール値に変換",
"convertToBlockStyle": "ブロックスタイル {0} に変換",
"fixKeyOrderToMap": "このマップのキーの順序を修正する",
"flowStyleMapForbidden": "フロースタイルのマッピングは禁止されています",
"flowStyleSeqForbidden": "フロースタイルのシーケンスは禁止されています",
"unUsedAnchor": "未使用のアンカー \"{0}\"",
"unUsedAlias": "未解決のエイリアス \"{0}\""
}

View File

@@ -0,0 +1,56 @@
{
"Default Value": "Default value",
"json.schema.invalidref": "$ref '{0}' in '{1}' can not be resolved.",
"json.schema.problemloadingref": "Problems loading reference '{0}': {1}",
"json.schema.noContent": "Unable to load schema from '{0}': No content.",
"json.schema.invalidFormat": "Unable to parse content from '{0}': Parse error at line: {1} column: {2}",
"colorHexFormatWarning": "Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.",
"dateTimeFormatWarning": "String is not a RFC3339 date-time.",
"dateFormatWarning": "String is not a RFC3339 date.",
"timeFormatWarning": "String is not a RFC3339 time.",
"emailFormatWarning": "String is not an e-mail address.",
"ipv4FormatWarning": "String does not match IPv4 format.",
"ipv6FormatWarning": "String does not match IPv6 format.",
"enumWarning": "Value is not accepted. Valid values: {0}.",
"typeArrayMismatchWarning": "Incorrect type. Expected one of {0}.",
"notSchemaWarning": "Matches a schema that is not allowed.",
"oneOfWarning": "Matches multiple schemas when only one must validate.",
"ifFilePatternAssociation": "filePatternAssociation '{0}' does not match with doc uri '{1}'",
"multipleOfWarning": "Value is not divisible by {0}.",
"exclusiveMinimumWarning": "Value is below the exclusive minimum of {0}.",
"exclusiveMaximumWarning": "Value is above the exclusive maximum of {0}.",
"minimumWarning": "Value is below the minimum of {0}.",
"maximumWarning": "Value is above the maximum of {0}.",
"minLengthWarning": "String is shorter than the minimum length of {0}.",
"maxLengthWarning": "String is longer than the maximum length of {0}.",
"patternWarning": "String does not match the pattern of \"{0}\".",
"uriEmpty": "URI expected.",
"uriSchemeMissing": "URI with a scheme is expected.",
"uriFormatWarning": "String is not a URI: {0}",
"additionalItemsWarning": "Array has too many items according to schema. Expected {0} or fewer.",
"requiredItemMissingWarning": "Array does not contain required item.",
"minItemsWarning": "Array has too few items. Expected {0} or more.",
"maxItemsWarning": "Array has too many items. Expected {0} or fewer.",
"uniqueItemsWarning": "Array has duplicate items.",
"DisallowedExtraPropWarning": "Property {0} is not allowed.",
"MaxPropWarning": "Object has more properties than limit of {0}.",
"MinPropWarning": "Object has fewer properties than the required number of {0}",
"RequiredDependentPropWarning": "Object is missing property {0} required by property {1}.",
"Inline schema": "Inline schema",
"create.item.array": "Create an item of an array{0}{1}",
"array.item": "- (array item) ",
"allowedValues": "Allowed Values:",
"example": "Example:",
"source": "Source: [{0}]({1})",
"jumpToSchema": "Jump to schema location ({0})",
"convertToSpace": "Convert Tab to Spaces",
"convertAllSpaceToTab": "Convert all Tabs to Spaces",
"deleteUnusedAnchor": "Delete unused anchor: {0}",
"convertToBoolean": "Convert to boolean",
"convertToBlockStyle": "Convert to block style {0}",
"fixKeyOrderToMap": "Fix key order for this map",
"flowStyleMapForbidden": "Flow style mapping is forbidden",
"flowStyleSeqForbidden": "Flow style sequence is forbidden",
"unUsedAnchor": "Unused anchor \"{0}\"",
"unUsedAlias": "Unresolved alias \"{0}\""
}

View File

@@ -0,0 +1,56 @@
{
"Default Value": "기본값",
"json.schema.invalidref": "'{1}'의 $ref '{0}'을(를) 확인할 수 없습니다.",
"json.schema.problemloadingref": "'{0}' 참조를 불러오는 데 문제가 발생했습니다: {1}",
"json.schema.nocontent": "'{0}'에서 스키마를 불러올 수 없습니다: 내용이 없습니다.",
"json.schema.invalidFormat": "'{0}'의 내용을 구문 분석할 수 없습니다: {1}행 {2}열에서 구문 오류가 발생했습니다",
"colorHexFormatWarning": "잘못된 색상 형식입니다. #RGB, #RGBA, #RRGGBB 또는 #RRGGBBAA를 사용하세요.",
"dateTimeFormatWarning": "문자열이 RFC3339 날짜-시간 형식이 아닙니다.",
"dateFormatWarning": "문자열이 RFC3339 날짜 형식이 아닙니다.",
"timeFormatWarning": "문자열이 RFC3339 시간 형식이 아닙니다.",
"emailFormatWarning": "문자열이 유효한 이메일 주소가 아닙니다.",
"ipv4FormatWarning": "문자열이 IPv4 형식과 일치하지 않습니다.",
"ipv6FormatWarning": "문자열이 IPv6 형식과 일치하지 않습니다.",
"enumWarning": "값이 허용되지 않았습니다. 허용 가능한 값: {0}.",
"typeArrayMismatchWarning": "잘못된 유형입니다. 예상 값: {0}.",
"notSchemaWarning": "허용되지 않은 스키마와 일치합니다.",
"oneOfWarning": "여러 스키마와 일치합니다. 하나만 유효해야 합니다.",
"ifFilePatternAssociation": "filePatternAssociation '{0}'이(가) 문서 URI '{1}'과(와) 일치하지 않습니다.",
"multipleOfWarning": "값이 {0}으로 나눌 수 없습니다.",
"exclusiveMinimumWarning": "값이 최소값 {0}보다 작습니다.",
"exclusiveMaximumWarning": "값이 최대값 {0}보다 큽니다.",
"minimumWarning": "값이 최소값 {0}보다 작습니다.",
"maximumWarning": "값이 최대값 {0}보다 큽니다.",
"minLengthWarning": "문자열 길이가 최소 길이 {0}보다 짧습니다.",
"maxLengthWarning": "문자열 길이가 최대 길이 {0}보다 깁니다.",
"patternWarning": "문자열이 \"{0}\" 패턴과 일치하지 않습니다.",
"uriEmpty": "URI가 필요합니다.",
"uriSchemeMissing": "스킴이 있는 URI가 필요합니다.",
"uriFormatWarning": "문자열이 URI 형식이 아닙니다: {0}",
"additionalItemsWarning": "배열의 항목 수가 스키마에서 허용된 {0}개를 초과합니다.",
"requiredItemMissingWarning": "배열에 필수 항목이 없습니다.",
"minItemsWarning": "배열 항목 수가 너무 적습니다. 최소 {0}개 필요합니다.",
"maxItemsWarning": "배열 항목 수가 너무 많습니다. 최대 {0}개 허용됩니다.",
"uniqueItemsWarning": "배열에 중복된 항목이 있습니다.",
"DisallowedExtraPropWarning": "속성 {0}은(는) 허용되지 않습니다.",
"MaxPropWarning": "객체에 허용된 속성 수 {0}을 초과했습니다.",
"MinPropWarning": "객체에 필요한 최소 속성 수 {0}보다 적습니다.",
"RequiredDependentPropWarning": "속성 {1}에 필요한 속성 {0}이 누락되었습니다.",
"Inline schema": "인라인 스키마",
"create.item.array": "배열 항목 생성{0}{1}",
"array.item": "- (배열 항목)",
"allowedValues": "허용 값:",
"example": "예시:",
"source": "출처: [{0}]({1})",
"jumpToSchema": "스키마 위치로 이동 ({0})",
"convertToSpace": "탭을 공백으로 변환",
"convertAllSpaceToTab": "모든 공백을 탭으로 변환",
"deleteUnusedAnchor": "사용되지 않은 앵커 삭제: {0}",
"convertToBoolean": "불리언으로 변환",
"convertToBlockStyle": "블록 스타일 {0}(으)로 변환",
"fixKeyOrderToMap": "이 맵의 키 순서 정렬",
"flowStyleMapForbidden": "Flow 스타일 맵 사용이 금지됨",
"flowStyleSeqForbidden": "Flow 스타일 시퀀스 사용이 금지됨",
"unUsedAnchor": "사용되지 않은 앵커 \"{0}\"",
"unUsedAlias": "해결되지 않은 별칭 \"{0}\""
}

View File

@@ -0,0 +1,56 @@
{
"Default Value": "默认值",
"json.schema.invalidref": "在 '{1}' 中的 $ref '{0}' 无法解析。",
"json.schema.problemloadingref": "加载引用 '{0}' 时出现问题:{1}",
"json.schema.nocontent": "无法从“{0}”加载架构:没有内容。",
"json.schema.invalidFormat": "无法解析来自“{0}”的内容:在第 {1} 行第 {2} 列发生解析错误",
"colorHexFormatWarning": "无效的颜色格式。请使用 #RGB、#RGBA、#RRGGBB 或 #RRGGBBAA。",
"dateTimeFormatWarning": "字符串不是 RFC3339 日期时间格式。",
"dateFormatWarning": "字符串不是 RFC3339 日期格式。",
"timeFormatWarning": "字符串不是 RFC3339 时间格式。",
"emailFormatWarning": "字符串不是有效的电子邮件地址。",
"ipv4FormatWarning": "字符串与 IPv4 格式不匹配。",
"ipv6FormatWarning": "字符串与 IPv6 格式不匹配。",
"enumWarning": "值无效。允许的值:{0}。",
"typeArrayMismatchWarning": "类型不正确。应为以下之一:{0}。",
"notSchemaWarning": "匹配了不被允许的模式。",
"oneOfWarning": "同时匹配多个模式,必须只匹配一个。",
"ifFilePatternAssociation": "filePatternAssociation '{0}' 与文档 URI '{1}' 不匹配",
"multipleOfWarning": "值不能被 {0} 整除。",
"exclusiveMinimumWarning": "值低于最小(不包含)限制 {0}。",
"exclusiveMaximumWarning": "值高于最大(不包含)限制 {0}。",
"minimumWarning": "值低于最小值 {0}。",
"maximumWarning": "值高于最大值 {0}。",
"minLengthWarning": "字符串长度小于最小长度 {0}。",
"maxLengthWarning": "字符串长度超过最大长度 {0}。",
"patternWarning": "字符串不符合模式 \"{0}\"。",
"uriEmpty": "需要提供 URI。",
"uriSchemeMissing": "需要带有协议的 URI。",
"uriFormatWarning": "字符串不是有效的 URI{0}",
"additionalItemsWarning": "数组项数超过了模式限制。最多允许 {0} 项。",
"requiredItemMissingWarning": "数组中缺少必需项。",
"minItemsWarning": "数组项数不足。应为 {0} 项或更多。",
"maxItemsWarning": "数组项数过多。应为 {0} 项或更少。",
"uniqueItemsWarning": "数组中包含重复项。",
"DisallowedExtraPropWarning": "属性 {0} 不被允许。",
"MaxPropWarning": "对象的属性数超过了限制 {0}。",
"MinPropWarning": "对象的属性数少于所需数量 {0}。",
"RequiredDependentPropWarning": "属性 {1} 依赖的属性 {0} 缺失。",
"Inline schema": "内联模式",
"create.item.array": "创建数组项{0}{1}",
"array.item": "- (数组项)",
"allowedValues": "允许的值:",
"example": "示例:",
"source": "来源:[ {0} ]({1})",
"jumpToSchema": "跳转到模式位置({0}",
"convertToSpace": "将 Tab 转换为空格",
"convertAllSpaceToTab": "将所有空格转换为 Tab",
"deleteUnusedAnchor": "删除未使用的锚点:{0}",
"convertToBoolean": "转换为布尔值",
"convertToBlockStyle": "转换为块样式 {0}",
"fixKeyOrderToMap": "修复此映射的键顺序",
"flowStyleMapForbidden": "禁止使用 flow 样式的映射",
"flowStyleSeqForbidden": "禁止使用 flow 样式的序列",
"unUsedAnchor": "未使用的锚点 \"{0}\"",
"unUsedAlias": "未解析的别名 \"{0}\""
}

View File

@@ -0,0 +1,56 @@
{
"Default Value": "預設值",
"json.schema.invalidref": "在 '{1}' 中的 $ref '{0}' 無法解析。",
"json.schema.problemloadingref": "載入參考 '{0}' 時出現問題:{1}",
"json.schema.nocontent": "無法從「{0}」載入結構描述:沒有內容。",
"json.schema.invalidFormat": "無法解析來自「{0}」的內容:在第 {1} 行第 {2} 欄發生解析錯誤",
"colorHexFormatWarning": "無效的顏色格式。請使用 #RGB、#RGBA、#RRGGBB 或 #RRGGBBAA。",
"dateTimeFormatWarning": "字串不是 RFC3339 日期時間格式。",
"dateFormatWarning": "字串不是 RFC3339 日期格式。",
"timeFormatWarning": "字串不是 RFC3339 時間格式。",
"emailFormatWarning": "字串不是有效的電子郵件地址。",
"ipv4FormatWarning": "字串不符合 IPv4 格式。",
"ipv6FormatWarning": "字串不符合 IPv6 格式。",
"enumWarning": "值無效。有效值為:{0}。",
"typeArrayMismatchWarning": "類型不正確。應為以下其中之一:{0}。",
"notSchemaWarning": "符合了不被允許的結構。",
"oneOfWarning": "符合多個結構,但只能有一個有效。",
"ifFilePatternAssociation": "filePatternAssociation '{0}' 與文件 URI '{1}' 不相符",
"multipleOfWarning": "值不能被 {0} 整除。",
"exclusiveMinimumWarning": "值低於排除最小值 {0}。",
"exclusiveMaximumWarning": "值超過排除最大值 {0}。",
"minimumWarning": "值低於最小值 {0}。",
"maximumWarning": "值超過最大值 {0}。",
"minLengthWarning": "字串長度小於最小長度 {0}。",
"maxLengthWarning": "字串長度超過最大長度 {0}。",
"patternWarning": "字串不符合模式 \"{0}\"。",
"uriEmpty": "需要 URI。",
"uriSchemeMissing": "需要包含 scheme 的 URI。",
"uriFormatWarning": "字串不是有效的 URI{0}",
"additionalItemsWarning": "陣列項目超出結構所允許的數量。應為 {0} 項或更少。",
"requiredItemMissingWarning": "陣列中缺少必要項目。",
"minItemsWarning": "陣列項目數太少。應為 {0} 項或更多。",
"maxItemsWarning": "陣列項目數太多。應為 {0} 項或更少。",
"uniqueItemsWarning": "陣列中有重複項目。",
"DisallowedExtraPropWarning": "不允許的屬性 {0}。",
"MaxPropWarning": "物件的屬性數量超過限制 {0}。",
"MinPropWarning": "物件的屬性數量少於所需的 {0}。",
"RequiredDependentPropWarning": "缺少由屬性 {1} 所需的屬性 {0}。",
"Inline schema": "內嵌結構",
"create.item.array": "建立陣列項目{0}{1}",
"array.item": "-(陣列項目)",
"allowedValues": "允許的值:",
"example": "範例:",
"source": "來源:[ {0} ]({1})",
"jumpToSchema": "跳至結構位置({0}",
"convertToSpace": "將 Tab 轉換為空格",
"convertAllSpaceToTab": "將所有空格轉換為 Tab",
"deleteUnusedAnchor": "刪除未使用的錨點:{0}",
"convertToBoolean": "轉換為布林值",
"convertToBlockStyle": "轉換為區塊樣式 {0}",
"fixKeyOrderToMap": "修正此映射的鍵順序",
"flowStyleMapForbidden": "禁止使用 Flow 風格的對應",
"flowStyleSeqForbidden": "禁止使用 Flow 風格的序列",
"unUsedAnchor": "未使用的錨點 \"{0}\"",
"unUsedAlias": "未解析的別名 \"{0}\""
}

View File

@@ -0,0 +1,3 @@
export declare enum YamlCommands {
JUMP_TO_SCHEMA = "jumpToSchema"
}

View File

@@ -0,0 +1,9 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export var YamlCommands;
(function (YamlCommands) {
YamlCommands["JUMP_TO_SCHEMA"] = "jumpToSchema";
})(YamlCommands || (YamlCommands = {}));
//# sourceMappingURL=commands.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,MAAM,CAAN,IAAY,YAEX;AAFD,WAAY,YAAY;IACtB,+CAA+B,CAAA;AACjC,CAAC,EAFW,YAAY,KAAZ,YAAY,QAEvB"}

View File

@@ -0,0 +1,3 @@
export * from './languageservice/yamlLanguageService';
export { getLanguageService as getJSONLanguageService } from 'vscode-json-languageservice';
export * from 'vscode-languageserver-types';

View File

@@ -0,0 +1,4 @@
export * from './languageservice/yamlLanguageService';
export { getLanguageService as getJSONLanguageService } from 'vscode-json-languageservice';
export * from 'vscode-languageserver-types';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC3F,cAAc,6BAA6B,CAAC"}

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,21 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export 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);
}
}
export const 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;AAQhG,MAAM,OAAO,eAAe;IAA5B;QACU,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAYvD,CAAC;IAXC,cAAc,CAAC,MAA4B;QACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClD,OAAO,OAAO,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;SACrC;QACD,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;IAC3D,CAAC;IAED,eAAe,CAAC,SAAiB,EAAE,OAAuB;QACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,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): Promise<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,198 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
import { ResultLimitReachedNotification } from '../../requestTypes';
import * as path from 'path';
export 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, 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(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;
}
};
}
}
//# sourceMappingURL=languageHandlers.js.map

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,46 @@
import { CustomSchemaRequest, DynamicCustomSchemaRequestRegistration, SchemaAssociationNotification, SchemaSelectionRequests, VSCodeContentRequestRegistration, } from '../../requestTypes';
export class NotificationHandlers {
constructor(connection, languageService, yamlSettings, settingsHandler) {
this.connection = connection;
this.languageService = languageService;
this.yamlSettings = yamlSettings;
this.settingsHandler = settingsHandler;
}
registerHandlers() {
this.connection.onNotification(SchemaAssociationNotification.type, (associations) => this.schemaAssociationNotificationHandler(associations));
this.connection.onNotification(DynamicCustomSchemaRequestRegistration.type, () => this.dynamicSchemaRequestHandler());
this.connection.onNotification(VSCodeContentRequestRegistration.type, () => this.vscodeContentRequestHandler());
this.connection.onNotification(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(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;
}
}
//# sourceMappingURL=notificationHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"notificationHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/notificationHandlers.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACtC,6BAA6B,EAC7B,uBAAuB,EACvB,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAI5B,MAAM,OAAO,oBAAoB;IAK/B,YACmB,UAAsB,EACvC,eAAgC,EAChC,YAA2B,EAC3B,eAAgC;QAHf,eAAU,GAAV,UAAU,CAAY;QAKvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAEM,gBAAgB;QACrB,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,6BAA6B,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,EAAE,CAClF,IAAI,CAAC,oCAAoC,CAAC,YAAY,CAAC,CACxD,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,sCAAsC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;QACtH,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,gCAAgC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;QAChH,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,uBAAuB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC,CAAC;IAC3G,CAAC;IAED;;;OAGG;IACK,oCAAoC,CAAC,YAA8D;QACzG,IAAI,CAAC,YAAY,CAAC,kBAAkB,GAAG,YAAY,CAAC;QACpD,IAAI,CAAC,YAAY,CAAC,sBAAsB,GAAG,EAAE,CAAC;QAC9C,IAAI,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAChF,CAAC;IAED;;;OAGG;IACK,2BAA2B;QACjC,MAAM,cAAc,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnC,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACzE,CAAC,CAAyB,CAAC;QAC3B,IAAI,CAAC,eAAe,CAAC,4BAA4B,CAAC,cAAc,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACK,2BAA2B;QACjC,IAAI,CAAC,YAAY,CAAC,uBAAuB,GAAG,IAAI,CAAC;IACnD,CAAC;IAEO,6BAA6B;QACnC,IAAI,CAAC,YAAY,CAAC,0BAA0B,GAAG,IAAI,CAAC;IACtD,CAAC;CACF"}

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,23 @@
import { MODIFICATION_ACTIONS, } from '../../languageservice/services/yamlSchemaService';
import { SchemaModificationNotification } from '../../requestTypes';
export class RequestHandlers {
constructor(connection, languageService) {
this.connection = connection;
this.languageService = languageService;
}
registerHandlers() {
this.connection.onRequest(SchemaModificationNotification.type, (modifications) => this.registerSchemaModificationNotificationHandler(modifications));
}
registerSchemaModificationNotificationHandler(modifications) {
if (modifications.action === MODIFICATION_ACTIONS.add) {
this.languageService.modifySchemaContent(modifications);
}
else if (modifications.action === MODIFICATION_ACTIONS.delete) {
this.languageService.deleteSchemaContent(modifications);
}
else if (modifications.action === MODIFICATION_ACTIONS.deleteAll) {
this.languageService.deleteSchemasWhole(modifications);
}
}
}
//# sourceMappingURL=requestHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/requestHandlers.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,oBAAoB,GAIrB,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,OAAO,eAAe;IAE1B,YACmB,UAAsB,EACvC,eAAgC;QADf,eAAU,GAAV,UAAU,CAAY;QAGvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAEM,gBAAgB;QACrB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,8BAA8B,CAAC,IAAI,EAAE,CAAC,aAAa,EAAE,EAAE,CAC/E,IAAI,CAAC,6CAA6C,CAAC,aAAa,CAAC,CAClE,CAAC;IACJ,CAAC;IAEO,6CAA6C,CACnD,aAAqE;QAErE,IAAI,aAAa,CAAC,MAAM,KAAK,oBAAoB,CAAC,GAAG,EAAE;YACrD,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;SACzD;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,oBAAoB,CAAC,MAAM,EAAE;YAC/D,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;SACzD;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,oBAAoB,CAAC,SAAS,EAAE;YAClE,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;SACxD;IACH,CAAC;CACF"}

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,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents';
import { getSchemaUrls } from '../../languageservice/utils/schemaUrls';
import { SchemaSelectionRequests } from '../../requestTypes';
export class JSONSchemaSelection {
constructor(schemaService, yamlSettings, connection) {
this.schemaService = schemaService;
this.yamlSettings = yamlSettings;
this.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) {
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 = 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) {
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;
}
}
//# 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;AAIhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EAAmD,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE9G,MAAM,OAAO,mBAAmB;IAC9B,YACmB,aAAgC,EAChC,YAA4B,EAC5B,UAAuB;QAFvB,kBAAa,GAAb,aAAa,CAAmB;QAChC,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,eAAU,GAAV,UAAU,CAAa;QAExC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;YACxE,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,uBAAuB,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE;YAC5E,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACrC,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;gBAClB,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;gBACX,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW;gBAC/B,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;aAC1B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,MAAc;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC9C,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,OAAO,GAAG,kBAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAE7D,KAAK,MAAM,cAAc,IAAI,OAAO,CAAC,SAAS,EAAE;YAC9C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YAC3F,IAAI,MAAM,EAAE,MAAM,EAAE;gBAClB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACjD,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE;oBACzB,SAAS;iBACV;gBACD,KAAK,MAAM,WAAW,IAAI,UAAU,EAAE;oBACpC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC7C;aACF;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAc;QAChC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACzD,MAAM,iBAAiB,GAA+B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAClG,OAAO;gBACL,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;gBACX,SAAS,EAAE,KAAK;gBAChB,kBAAkB,EAAE,IAAI;gBACxB,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;gBAClB,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW;gBAC/B,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;aAC1B,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;QACpD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAE3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}

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,306 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { configure as configureHttpRequests, xhr } from 'request-light';
import { DidChangeConfigurationNotification, DocumentFormattingRequest } from 'vscode-languageserver';
import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths';
import { checkSchemaURI, JSON_SCHEMASTORE_URL, KUBERNETES_SCHEMA_URL } from '../../languageservice/utils/schemaUrls';
import { SchemaPriority } from '../../languageservice/yamlLanguageService';
import { SchemaSelectionRequests } from '../../requestTypes';
export 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(DidChangeConfigurationNotification.type);
}
catch (err) {
this.telemetry.sendError('yaml.settings.error', 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) {
configureHttpRequests(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.trailingComma !== undefined) {
this.yamlSettings.yamlFormatterSettings.trailingComma = settings.yaml.format.trailingComma;
}
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: 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(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(DocumentFormattingRequest.type, {
documentSelector: [
{ language: 'yaml' },
{ language: 'dockercompose' },
{ language: 'github-actions-workflow' },
{ pattern: '*.y(a)ml' },
],
});
}
}
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 = 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 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: 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, SchemaPriority.SchemaAssociation);
});
}
else {
for (const uri in this.yamlSettings.schemaAssociations) {
const fileMatch = this.yamlSettings.schemaAssociations[uri];
languageSettings = this.configureSchemas(uri, fileMatch, null, languageSettings, 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 (isRelativePath(uri)) {
uri = relativeToAbsolutePath(this.yamlSettings.workspaceFolders, this.yamlSettings.workspaceRoot, uri);
}
languageSettings = this.configureSchemas(uri, schema.fileMatch, schema.schema, languageSettings, 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 = 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 === KUBERNETES_SCHEMA_URL) {
fileMatch.forEach((url) => {
this.yamlSettings.specificValidatorPaths.push(url);
});
}
else if (uri === KUBERNETES_SCHEMA_URL) {
this.yamlSettings.specificValidatorPaths.push(fileMatch);
}
return languageSettings;
}
}
//# sourceMappingURL=settingsHandlers.js.map

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,54 @@
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils';
export 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, 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 = removeDuplicatesObj(diagnostics);
this.connection.sendDiagnostics({
uri: textDocument.uri,
diagnostics: removeDuplicatesDiagnostics,
});
return removeDuplicatesDiagnostics;
});
}
}
//# sourceMappingURL=validationHandlers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"validationHandlers.js","sourceRoot":"","sources":["../../../../src/languageserver/handlers/validationHandlers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAI3E,MAAM,OAAO,iBAAiB;IAI5B,YACmB,UAAsB,EACvC,eAAgC,EAChC,YAA2B;QAFV,eAAU,GAAV,UAAU,CAAY;QAIvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QAEjC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,MAAM,EAAE,EAAE;YACxD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;YAC/C,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,YAA0B;QACjC,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC;QAC1C,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9E,OAAO,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YACrE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;QAC1C,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAC1C,CAAC;IAEO,sBAAsB,CAAC,YAA0B;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAE9E,IAAI,OAAO,EAAE;YACX,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;SACtE;IACH,CAAC;IAED,oBAAoB,CAAC,YAA0B;QAC7C,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QAED,OAAO,IAAI,CAAC,eAAe;aACxB,YAAY,CAAC,YAAY,EAAE,8BAA8B,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;aAClH,IAAI,CAAC,CAAC,iBAAiB,EAAE,EAAE;YAC1B,MAAM,WAAW,GAAiB,EAAE,CAAC;YACrC,KAAK,MAAM,cAAc,IAAI,iBAAiB,EAAE;gBAC9C,iCAAiC;gBACjC,IAAI,cAAc,CAAC,QAAQ,KAAK,CAAC,EAAE;oBACjC,cAAc,CAAC,QAAQ,GAAG,CAAC,CAAC;iBAC7B;gBACD,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aAClC;YAED,MAAM,2BAA2B,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;YACrE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;gBAC9B,GAAG,EAAE,YAAY,CAAC,GAAG;gBACrB,WAAW,EAAE,2BAA2B;aACzC,CAAC,CAAC;YACH,OAAO,2BAA2B,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC;CACF"}

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,17 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export 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);
}
}
//# 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;AAKhG,MAAM,OAAO,iBAAiB;IAC5B,YACmB,UAAsB,EACtB,eAAgC;QADhC,eAAU,GAAV,UAAU,CAAY;QACtB,oBAAe,GAAf,eAAe,CAAiB;IAChD,CAAC;IAEJ,gBAAgB;QACd,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,cAAc,CAAC,MAA4B;QACjD,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;CACF"}

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, error: unknown): void;
sendTrack(name: string, properties: unknown): void;
}

View File

@@ -0,0 +1,20 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { convertErrorToTelemetryMsg } from '../languageservice/utils/objects';
export class TelemetryImpl {
constructor(connection) {
this.connection = connection;
}
send(event) {
this.connection.telemetry.logEvent(event);
}
sendError(name, error) {
this.send({ name, type: 'track', properties: { error: convertErrorToTelemetryMsg(error) } });
}
sendTrack(name, properties) {
this.send({ name, type: 'track', properties: properties });
}
}
//# sourceMappingURL=telemetry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../src/languageserver/telemetry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAE9E,MAAM,OAAO,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,IAAI,CAAC,KAAqB;QACxB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,KAAc;QACpC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,0BAA0B,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,UAAmB;QACzC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF"}

View File

@@ -0,0 +1,49 @@
import { Node, Pair } from 'yaml';
export type YamlNode = Node | Pair;
export type ASTNode = ObjectASTNode | PropertyASTNode | ArrayASTNode | StringASTNode | NumberASTNode | BooleanASTNode | NullASTNode;
export interface BaseASTNode {
readonly type: 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null';
readonly parent?: ASTNode;
readonly offset: number;
readonly length: number;
readonly children?: ASTNode[];
readonly value?: string | boolean | number | null;
readonly internalNode: YamlNode;
location: string;
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
}
export interface ObjectASTNode extends BaseASTNode {
readonly type: 'object';
readonly properties: PropertyASTNode[];
readonly children: ASTNode[];
}
export interface PropertyASTNode extends BaseASTNode {
readonly type: 'property';
readonly keyNode: StringASTNode;
readonly valueNode?: ASTNode;
readonly colonOffset?: number;
readonly children: ASTNode[];
}
export interface ArrayASTNode extends BaseASTNode {
readonly type: 'array';
readonly items: ASTNode[];
readonly children: ASTNode[];
}
export interface StringASTNode extends BaseASTNode {
readonly type: 'string';
readonly value: string;
}
export interface NumberASTNode extends BaseASTNode {
readonly type: 'number';
readonly value: number;
readonly isInteger: boolean;
}
export interface BooleanASTNode extends BaseASTNode {
readonly type: 'boolean';
readonly value: boolean;
readonly source: string;
}
export interface NullASTNode extends BaseASTNode {
readonly type: 'null';
readonly value: null;
}

View File

@@ -0,0 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export {};
//# sourceMappingURL=jsonASTTypes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"jsonASTTypes.js","sourceRoot":"","sources":["../../../src/languageservice/jsonASTTypes.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}

View File

@@ -0,0 +1,79 @@
import { CompletionItemKind } from 'vscode-json-languageservice';
import { SchemaVersions } from './yamlTypes';
export type JSONSchemaRef = JSONSchema | boolean;
export interface JSONSchema {
id?: string;
$id?: string;
$schema?: string;
url?: string;
type?: string | string[];
title?: string;
closestTitle?: string;
versions?: SchemaVersions;
default?: any;
definitions?: {
[name: string]: JSONSchema;
};
description?: string;
properties?: JSONSchemaMap;
patternProperties?: JSONSchemaMap;
additionalProperties?: boolean | JSONSchemaRef;
minProperties?: number;
maxProperties?: number;
dependencies?: JSONSchemaMap | {
[prop: string]: string[];
};
items?: JSONSchemaRef | JSONSchemaRef[];
minItems?: number;
maxItems?: number;
uniqueItems?: boolean;
additionalItems?: boolean | JSONSchemaRef;
pattern?: string;
minLength?: number;
maxLength?: number;
minimum?: number;
maximum?: number;
exclusiveMinimum?: boolean | number;
exclusiveMaximum?: boolean | number;
multipleOf?: number;
required?: string[];
$ref?: string;
_$ref?: string;
anyOf?: JSONSchemaRef[];
allOf?: JSONSchemaRef[];
oneOf?: JSONSchemaRef[];
not?: JSONSchemaRef;
enum?: any[];
format?: string;
const?: any;
contains?: JSONSchemaRef;
propertyNames?: JSONSchemaRef;
examples?: any[];
$comment?: string;
if?: JSONSchemaRef;
then?: JSONSchemaRef;
else?: JSONSchemaRef;
defaultSnippets?: {
label?: string;
description?: string;
markdownDescription?: string;
type?: string;
suggestionKind?: CompletionItemKind;
sortText?: string;
body?: any;
bodyText?: string;
}[];
errorMessage?: string;
patternErrorMessage?: string;
deprecationMessage?: string;
enumDescriptions?: string[];
markdownEnumDescriptions?: string[];
markdownDescription?: string;
doNotSuggest?: boolean;
allowComments?: boolean;
schemaSequence?: JSONSchema[];
filePatternAssociation?: string;
}
export interface JSONSchemaMap {
[name: string]: JSONSchemaRef;
}

View File

@@ -0,0 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export {};
//# sourceMappingURL=jsonSchema.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"jsonSchema.js","sourceRoot":"","sources":["../../../src/languageservice/jsonSchema.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}

View File

@@ -0,0 +1,11 @@
import { Alias, Document, LineCounter } from 'yaml';
import { ASTNode, YamlNode } from '../jsonASTTypes';
type NodeRange = [number, number, number];
export declare const aliasDepth: {
maxRefCount: number;
currentRefDepth: number;
aliasResolutionCache: Map<Alias, ASTNode>;
};
export declare function convertAST(parent: ASTNode, node: YamlNode, doc: Document, lineCounter: LineCounter): ASTNode | undefined;
export declare function toOffsetLength(range: NodeRange): [number, number];
export {};

View File

@@ -0,0 +1,176 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { isScalar, isMap, isPair, isSeq, isNode, isAlias, } from 'yaml';
import { NullASTNodeImpl, PropertyASTNodeImpl, StringASTNodeImpl, ObjectASTNodeImpl, NumberASTNodeImpl, ArrayASTNodeImpl, BooleanASTNodeImpl, } from './jsonParser07';
// Exported for tests
export const aliasDepth = {
maxRefCount: 1000,
currentRefDepth: 0,
aliasResolutionCache: new Map(),
};
export function convertAST(parent, node, doc, lineCounter) {
if (!parent) {
// first invocation
aliasDepth.currentRefDepth = 0;
aliasDepth.aliasResolutionCache = new Map();
}
if (!node) {
return null;
}
if (isMap(node)) {
return convertMap(node, parent, doc, lineCounter);
}
if (isPair(node)) {
return convertPair(node, parent, doc, lineCounter);
}
if (isSeq(node)) {
return convertSeq(node, parent, doc, lineCounter);
}
if (isScalar(node)) {
return convertScalar(node, parent);
}
if (isAlias(node) && aliasDepth.currentRefDepth < aliasDepth.maxRefCount) {
return convertAlias(node, parent, doc, lineCounter);
}
else {
return;
}
}
function convertMap(node, parent, doc, lineCounter) {
let range;
if (node.flow && !node.range) {
range = collectFlowMapRange(node);
}
else {
range = node.range;
}
const result = new ObjectASTNodeImpl(parent, node, ...toFixedOffsetLength(range, lineCounter));
for (const it of node.items) {
if (isPair(it)) {
result.properties.push(convertAST(result, it, doc, lineCounter));
}
}
return result;
}
function convertPair(node, parent, doc, lineCounter) {
const keyNode = node.key;
const valueNode = node.value;
const rangeStart = keyNode.range[0];
let rangeEnd = keyNode.range[1];
let nodeEnd = keyNode.range[2];
if (valueNode) {
rangeEnd = valueNode.range[1];
nodeEnd = valueNode.range[2];
}
// Pair does not return a range using the key/value ranges to fake one.
const result = new PropertyASTNodeImpl(parent, node, ...toFixedOffsetLength([rangeStart, rangeEnd, nodeEnd], lineCounter));
if (isAlias(keyNode)) {
const keyAlias = new StringASTNodeImpl(parent, keyNode, ...toOffsetLength(keyNode.range));
keyAlias.value = keyNode.source;
result.keyNode = keyAlias;
}
else {
result.keyNode = convertAST(result, keyNode, doc, lineCounter);
}
result.valueNode = convertAST(result, valueNode, doc, lineCounter);
return result;
}
function convertSeq(node, parent, doc, lineCounter) {
const result = new ArrayASTNodeImpl(parent, node, ...toOffsetLength(node.range));
for (const it of node.items) {
if (isNode(it)) {
const convertedNode = convertAST(result, it, doc, lineCounter);
// due to recursion protection, convertAST may return undefined
if (convertedNode) {
result.children.push(convertedNode);
}
}
}
return result;
}
function convertScalar(node, parent) {
if (node.value === null) {
return new NullASTNodeImpl(parent, node, ...toOffsetLength(node.range));
}
switch (typeof node.value) {
case 'string': {
const result = new StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
result.value = node.value;
return result;
}
case 'boolean':
return new BooleanASTNodeImpl(parent, node, node.value, node.source, ...toOffsetLength(node.range));
case 'number': {
const result = new NumberASTNodeImpl(parent, node, ...toOffsetLength(node.range));
result.value = node.value;
result.isInteger = Number.isInteger(result.value);
return result;
}
default: {
// fail safe converting, we need to return some node anyway
const result = new StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
result.value = node.source;
return result;
}
}
}
function convertAlias(node, parent, doc, lineCounter) {
if (aliasDepth.aliasResolutionCache.has(node)) {
return aliasDepth.aliasResolutionCache.get(node);
}
aliasDepth.currentRefDepth++;
const resolvedNode = node.resolve(doc);
let ans;
if (resolvedNode) {
ans = convertAST(parent, resolvedNode, doc, lineCounter);
}
else {
const resultNode = new StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
resultNode.value = node.source;
ans = resultNode;
}
aliasDepth.currentRefDepth--;
aliasDepth.aliasResolutionCache.set(node, ans);
return ans;
}
export function toOffsetLength(range) {
return [range[0], range[1] - range[0]];
}
/**
* Convert offsets to offset+length with fix length to not include '\n' character in some cases
* @param range the yaml ast range
* @param lineCounter the line counter
* @returns the offset and length
*/
function toFixedOffsetLength(range, lineCounter) {
const start = lineCounter.linePos(range[0]);
const end = lineCounter.linePos(range[1]);
const result = [range[0], range[1] - range[0]];
// -1 as range may include '\n'
if (start.line !== end.line && (lineCounter.lineStarts.length !== end.line || end.col === 1)) {
result[1]--;
}
return result;
}
function collectFlowMapRange(node) {
let start = Number.MAX_SAFE_INTEGER;
let end = 0;
for (const it of node.items) {
if (isPair(it)) {
if (isNode(it.key)) {
if (it.key.range && it.key.range[0] <= start) {
start = it.key.range[0];
}
}
if (isNode(it.value)) {
if (it.value.range && it.value.range[2] >= end) {
end = it.value.range[2];
}
}
}
}
return [start, end, end];
}
//# sourceMappingURL=ast-converter.js.map

View File

@@ -0,0 +1,7 @@
import { Tags } from 'yaml';
/**
* Converts the tags from settings and adds known tags such as !include
* and returns Tags that can be used by the parser.
* @param customTags Tags for parser
*/
export declare function getCustomTags(customTags: string[]): Tags;

View File

@@ -0,0 +1,58 @@
import { isSeq, isMap } from 'yaml';
import { filterInvalidCustomTags } from '../utils/arrUtils';
class CommonTagImpl {
constructor(tag, type) {
this.tag = tag;
this.type = type;
}
get collection() {
if (this.type === 'mapping') {
return 'map';
}
if (this.type === 'sequence') {
return 'seq';
}
return undefined;
}
resolve(value) {
if (isMap(value) && this.type === 'mapping') {
return value;
}
if (isSeq(value) && this.type === 'sequence') {
return value;
}
if (typeof value === 'string' && this.type === 'scalar') {
return value;
}
}
}
class IncludeTag {
constructor() {
this.tag = '!include';
this.type = 'scalar';
}
resolve(value, onError) {
if (value && value.length > 0 && value.trim()) {
return value;
}
onError('!include without value');
}
}
/**
* Converts the tags from settings and adds known tags such as !include
* and returns Tags that can be used by the parser.
* @param customTags Tags for parser
*/
export function getCustomTags(customTags) {
const tags = [];
const filteredTags = filterInvalidCustomTags(customTags);
for (const tag of filteredTags) {
const typeInfo = tag.split(' ');
const tagName = typeInfo[0];
const tagType = (typeInfo[1] && typeInfo[1].toLowerCase()) || 'scalar';
tags.push(new CommonTagImpl(tagName, tagType));
}
tags.push(new IncludeTag());
return tags;
}
//# sourceMappingURL=custom-tag-provider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"custom-tag-provider.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/custom-tag-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,EAAE,KAAK,EAAoB,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,aAAa;IAIjB,YAAY,GAAW,EAAE,IAAY;QACnC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,UAAU;QACZ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;YAC3B,OAAO,KAAK,CAAC;SACd;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YAC5B,OAAO,KAAK,CAAC;SACd;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,KAAiC;QACvC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;YAC3C,OAAO,KAAK,CAAC;SACd;QACD,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;YACvD,OAAO,KAAK,CAAC;SACd;IACH,CAAC;CACF;AAED,MAAM,UAAU;IAAhB;QACkB,QAAG,GAAG,UAAU,CAAC;QACjB,SAAI,GAAG,QAAQ,CAAC;IAUlC,CAAC;IANC,OAAO,CAAC,KAAa,EAAE,OAAkC;QACvD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE;YAC7C,OAAO,KAAK,CAAC;SACd;QACD,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACpC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,UAAoB;IAChD,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,MAAM,YAAY,GAAG,uBAAuB,CAAC,UAAU,CAAC,CAAC;IACzD,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE;QAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,QAAQ,CAAC;QACvE,IAAI,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;KAChD;IACD,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC"}

View File

@@ -0,0 +1,4 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import * as Parser from './jsonParser07';
export declare function setKubernetesParserOption(jsonDocuments: Parser.JSONDocument[], option: boolean): void;
export declare function isKubernetesAssociatedDocument(textDocument: TextDocument, paths: string[]): boolean;

View File

@@ -0,0 +1,17 @@
import { FilePatternAssociation } from '../services/yamlSchemaService';
export function setKubernetesParserOption(jsonDocuments, option) {
for (const jsonDoc of jsonDocuments) {
jsonDoc.isKubernetes = option;
}
}
export function isKubernetesAssociatedDocument(textDocument, paths) {
for (const path in paths) {
const globPath = paths[path];
const fpa = new FilePatternAssociation(globPath);
if (fpa.matchesPattern(textDocument.uri)) {
return true;
}
}
return false;
}
//# sourceMappingURL=isKubernetes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isKubernetes.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/isKubernetes.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,MAAM,UAAU,yBAAyB,CAAC,aAAoC,EAAE,MAAe;IAC7F,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;QACnC,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC;KAC/B;AACH,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,YAA0B,EAAE,KAAe;IACxF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QAEjD,IAAI,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;YACxC,OAAO,IAAI,CAAC;SACb;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}

View File

@@ -0,0 +1,186 @@
import { JSONSchema, JSONSchemaRef } from '../jsonSchema';
import { ASTNode, ObjectASTNode, ArrayASTNode, BooleanASTNode, NumberASTNode, StringASTNode, NullASTNode, PropertyASTNode, YamlNode } from '../jsonASTTypes';
import { ErrorCode } from 'vscode-json-languageservice';
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Node, Pair } from 'yaml';
export interface IRange {
offset: number;
length: number;
}
export declare const formats: {
'color-hex': {
errorMessage: string;
pattern: RegExp;
};
'date-time': {
errorMessage: string;
pattern: RegExp;
};
date: {
errorMessage: string;
pattern: RegExp;
};
time: {
errorMessage: string;
pattern: RegExp;
};
email: {
errorMessage: string;
pattern: RegExp;
};
ipv4: {
errorMessage: string;
pattern: RegExp;
};
ipv6: {
errorMessage: string;
pattern: RegExp;
};
};
export declare const YAML_SOURCE = "YAML";
export declare enum ProblemType {
missingRequiredPropWarning = "missingRequiredPropWarning",
typeMismatchWarning = "typeMismatchWarning",
constWarning = "constWarning"
}
export declare const ProblemTypeMessages: Record<ProblemType, string>;
export interface IProblem {
location: IRange;
severity: DiagnosticSeverity;
code?: ErrorCode;
message: string;
source?: string;
problemType?: ProblemType;
problemArgs?: string[];
schemaUri?: string[];
data?: Record<string, unknown>;
}
export declare abstract class ASTNodeImpl {
abstract readonly type: 'object' | 'property' | 'array' | 'number' | 'boolean' | 'null' | 'string';
offset: number;
length: number;
readonly parent: ASTNode;
location: string;
readonly internalNode: YamlNode;
constructor(parent: ASTNode, internalNode: YamlNode, offset: number, length?: number);
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
get children(): ASTNode[];
toString(): string;
}
export declare class NullASTNodeImpl extends ASTNodeImpl implements NullASTNode {
type: 'null';
value: any;
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
}
export declare class BooleanASTNodeImpl extends ASTNodeImpl implements BooleanASTNode {
type: 'boolean';
value: boolean;
source: string;
constructor(parent: ASTNode, internalNode: Node, boolValue: boolean, boolSource: string, offset: number, length?: number);
}
export declare class ArrayASTNodeImpl extends ASTNodeImpl implements ArrayASTNode {
type: 'array';
items: ASTNode[];
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
get children(): ASTNode[];
}
export declare class NumberASTNodeImpl extends ASTNodeImpl implements NumberASTNode {
type: 'number';
isInteger: boolean;
value: number;
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
}
export declare class StringASTNodeImpl extends ASTNodeImpl implements StringASTNode {
type: 'string';
value: string;
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
}
export declare class PropertyASTNodeImpl extends ASTNodeImpl implements PropertyASTNode {
type: 'property';
keyNode: StringASTNode;
valueNode: ASTNode;
colonOffset: number;
constructor(parent: ObjectASTNode, internalNode: Pair, offset: number, length?: number);
get children(): ASTNode[];
}
export declare class ObjectASTNodeImpl extends ASTNodeImpl implements ObjectASTNode {
type: 'object';
properties: PropertyASTNode[];
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
get children(): ASTNode[];
}
export declare function asSchema(schema: JSONSchemaRef): JSONSchema | undefined;
export interface JSONDocumentConfig {
collectComments?: boolean;
}
export interface IApplicableSchema {
node: ASTNode;
inverted?: boolean;
schema: JSONSchema;
}
export declare enum EnumMatch {
Key = 0,
Enum = 1
}
export interface ISchemaCollector {
schemas: IApplicableSchema[];
add(schema: IApplicableSchema): void;
merge(other: ISchemaCollector): void;
include(node: ASTNode): boolean;
newSub(): ISchemaCollector;
}
export declare class ValidationResult {
problems: IProblem[];
propertiesMatches: number;
propertiesValueMatches: number;
primaryValueMatches: number;
enumValueMatch: boolean;
enumValues: any[];
constructor(isKubernetes: boolean);
hasProblems(): boolean;
mergeAll(validationResults: ValidationResult[]): void;
merge(validationResult: ValidationResult): void;
mergeEnumValues(validationResult: ValidationResult): void;
/**
* Merge multiple warnings with same problemType together
* @param subValidationResult another possible result
*/
mergeWarningGeneric(subValidationResult: ValidationResult, problemTypesToMerge: ProblemType[]): void;
mergePropertyMatch(propertyValidationResult: ValidationResult): void;
private mergeSources;
compareGeneric(other: ValidationResult): number;
compareKubernetes(other: ValidationResult): number;
}
export declare function newJSONDocument(root: ASTNode, diagnostics?: Diagnostic[]): JSONDocument;
export declare function getNodeValue(node: ASTNode): any;
export declare function contains(node: ASTNode, offset: number, includeRightBound?: boolean): boolean;
export declare function findNodeAtOffset(node: ASTNode, offset: number, includeRightBound: boolean): ASTNode;
export declare class JSONDocument {
readonly root: ASTNode;
readonly syntaxErrors: Diagnostic[];
readonly comments: Range[];
isKubernetes: boolean;
disableAdditionalProperties: boolean;
uri: string;
constructor(root: ASTNode, syntaxErrors?: Diagnostic[], comments?: Range[]);
getNodeFromOffset(offset: number, includeRightBound?: boolean): ASTNode | undefined;
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
visit(visitor: (node: ASTNode) => boolean): void;
validate(textDocument: TextDocument, schema: JSONSchema): Diagnostic[];
/**
* This method returns the list of applicable schemas
*
* currently used @param didCallFromAutoComplete flag to differentiate the method call, when it is from auto complete
* then user still types something and skip the validation for timebeing untill completed.
* On https://github.com/redhat-developer/yaml-language-server/pull/719 the auto completes need to populate the list of enum string which matches to the enum
* and on https://github.com/redhat-developer/vscode-yaml/issues/803 the validation should throw the error based on the enum string.
*
* @param schema schema
* @param focusOffset offsetValue
* @param exclude excluded Node
* @param didCallFromAutoComplete true if method called from AutoComplete
* @returns array of applicable schemas
*/
getMatchingSchemas(schema: JSONSchema, focusOffset?: number, exclude?: ASTNode, didCallFromAutoComplete?: boolean): IApplicableSchema[];
}

View File

@@ -0,0 +1,8 @@
/**
* Parse a boolean according to the specification
*
* Return:
* true if its a true value
* false if its a false value
*/
export declare function parseYamlBoolean(input: string): boolean;

View File

@@ -0,0 +1,17 @@
/**
* Parse a boolean according to the specification
*
* Return:
* true if its a true value
* false if its a false value
*/
export function parseYamlBoolean(input) {
if (['true', 'True', 'TRUE', 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON'].lastIndexOf(input) >= 0) {
return true;
}
else if (['false', 'False', 'FALSE', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'].lastIndexOf(input) >= 0) {
return false;
}
throw `Invalid boolean "${input}"`;
}
//# sourceMappingURL=scalar-type.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"scalar-type.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/scalar-type.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QACrG,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QAC/G,OAAO,KAAK,CAAC;KACd;IACD,MAAM,oBAAoB,KAAK,GAAG,CAAC;AACrC,CAAC"}

View File

@@ -0,0 +1,71 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import { JSONDocument } from './jsonParser07';
import { Document, LineCounter } from 'yaml';
import { ASTNode, YamlNode } from '../jsonASTTypes';
import { ParserOptions } from './yamlParser07';
import { YAMLDocDiagnostic } from '../utils/parseUtils';
import { TextBuffer } from '../utils/textBuffer';
import { Token } from 'yaml/dist/parse/cst';
/**
* These documents are collected into a final YAMLDocument
* and passed to the `parseYAML` caller.
*/
export declare class SingleYAMLDocument extends JSONDocument {
private lineCounter;
private _internalDocument;
root: ASTNode;
currentDocIndex: number;
private _lineComments;
constructor(lineCounter?: LineCounter);
/**
* Create a deep copy of this document
*/
clone(): SingleYAMLDocument;
private collectLineComments;
/**
* Updates the internal AST tree of the object
* from the internal node. This is call whenever the
* internalDocument is set but also can be called to
* reflect any changes on the underlying document
* without setting the internalDocument explicitly.
*/
updateFromInternalDocument(): void;
set internalDocument(document: Document);
get internalDocument(): Document;
get lineComments(): string[];
set lineComments(val: string[]);
get errors(): YAMLDocDiagnostic[];
get warnings(): YAMLDocDiagnostic[];
getNodeFromPosition(positionOffset: number, textBuffer: TextBuffer, configuredIndentation?: number): [YamlNode | undefined, boolean];
findClosestNode(offset: number, textBuffer: TextBuffer, configuredIndentation?: number): YamlNode;
private getProperParentByIndentation;
getParent(node: YamlNode): YamlNode | undefined;
}
/**
* Contains the SingleYAMLDocuments, to be passed
* to the `parseYAML` caller.
*/
export declare class YAMLDocument {
documents: SingleYAMLDocument[];
tokens: Token[];
private errors;
private warnings;
constructor(documents: SingleYAMLDocument[], tokens: Token[]);
}
export declare class YamlDocuments {
private cache;
/**
* Get cached YAMLDocument
* @param document TextDocument to parse
* @param parserOptions YAML parserOptions
* @param addRootObject if true and document is empty add empty object {} to force schema usage
* @returns the YAMLDocument
*/
getYamlDocument(document: TextDocument, parserOptions?: ParserOptions, addRootObject?: boolean): YAMLDocument;
/**
* For test purpose only!
*/
clear(): void;
private ensureCache;
}
export declare const yamlDocumentsCache: YamlDocuments;

View File

@@ -0,0 +1,258 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { JSONDocument } from './jsonParser07';
import { isNode, isPair, isScalar, visit } from 'yaml';
import { defaultOptions, parse as parseYAML } from './yamlParser07';
import { ErrorCode } from 'vscode-json-languageservice';
import { convertAST } from './ast-converter';
import { isArrayEqual } from '../utils/arrUtils';
import { getParent } from '../utils/astUtils';
import { getIndentation } from '../utils/strings';
/**
* These documents are collected into a final YAMLDocument
* and passed to the `parseYAML` caller.
*/
export class SingleYAMLDocument extends JSONDocument {
constructor(lineCounter) {
super(null, []);
this.lineCounter = lineCounter;
}
/**
* Create a deep copy of this document
*/
clone() {
const copy = new SingleYAMLDocument(this.lineCounter);
copy.isKubernetes = this.isKubernetes;
copy.disableAdditionalProperties = this.disableAdditionalProperties;
copy.uri = this.uri;
copy.currentDocIndex = this.currentDocIndex;
copy._lineComments = this.lineComments.slice();
// this will re-create root node
copy.internalDocument = this._internalDocument.clone();
return copy;
}
collectLineComments() {
this._lineComments = [];
if (this._internalDocument.commentBefore) {
const comments = this._internalDocument.commentBefore.split('\n');
comments.forEach((comment) => this._lineComments.push(`#${comment}`));
}
visit(this.internalDocument, (_key, node) => {
if (node?.commentBefore) {
const comments = node?.commentBefore.split('\n');
comments.forEach((comment) => this._lineComments.push(`#${comment}`));
}
if (node?.comment) {
this._lineComments.push(`#${node.comment}`);
}
});
if (this._internalDocument.comment) {
this._lineComments.push(`#${this._internalDocument.comment}`);
}
}
/**
* Updates the internal AST tree of the object
* from the internal node. This is call whenever the
* internalDocument is set but also can be called to
* reflect any changes on the underlying document
* without setting the internalDocument explicitly.
*/
updateFromInternalDocument() {
this.root = convertAST(null, this._internalDocument.contents, this._internalDocument, this.lineCounter);
}
set internalDocument(document) {
this._internalDocument = document;
this.updateFromInternalDocument();
}
get internalDocument() {
return this._internalDocument;
}
get lineComments() {
if (!this._lineComments) {
this.collectLineComments();
}
return this._lineComments;
}
set lineComments(val) {
this._lineComments = val;
}
get errors() {
return this.internalDocument.errors.map(YAMLErrorToYamlDocDiagnostics);
}
get warnings() {
return this.internalDocument.warnings.map(YAMLErrorToYamlDocDiagnostics);
}
getNodeFromPosition(positionOffset, textBuffer, configuredIndentation) {
const position = textBuffer.getPosition(positionOffset);
const lineContent = textBuffer.getLineContent(position.line);
if (lineContent.trim().length === 0) {
return [this.findClosestNode(positionOffset, textBuffer, configuredIndentation), true];
}
const textAfterPosition = lineContent.substring(position.character);
const spacesAfterPositionMatch = textAfterPosition.match(/^([ ]+)\n?$/);
const areOnlySpacesAfterPosition = !!spacesAfterPositionMatch;
const countOfSpacesAfterPosition = spacesAfterPositionMatch?.[1].length;
let closestNode;
visit(this.internalDocument, (key, node) => {
if (!node) {
return;
}
const range = node.range;
if (!range) {
return;
}
const isNullNodeOnTheLine = () => areOnlySpacesAfterPosition &&
positionOffset + countOfSpacesAfterPosition === range[2] &&
isScalar(node) &&
node.value === null;
if ((range[0] <= positionOffset && range[1] >= positionOffset) || isNullNodeOnTheLine()) {
closestNode = node;
}
else {
return visit.SKIP;
}
});
return [closestNode, false];
}
findClosestNode(offset, textBuffer, configuredIndentation) {
let offsetDiff = this.internalDocument.range[2];
let maxOffset = this.internalDocument.range[0];
let closestNode;
visit(this.internalDocument, (key, node) => {
if (!node) {
return;
}
const range = node.range;
if (!range) {
return;
}
const diff = range[1] - offset;
if (maxOffset <= range[0] && diff <= 0 && Math.abs(diff) <= offsetDiff) {
offsetDiff = Math.abs(diff);
maxOffset = range[0];
closestNode = node;
}
});
const position = textBuffer.getPosition(offset);
const lineContent = textBuffer.getLineContent(position.line);
const indentation = getIndentation(lineContent, position.character);
if (isScalar(closestNode) && closestNode.value === null) {
return closestNode;
}
if (indentation === position.character) {
closestNode = this.getProperParentByIndentation(indentation, closestNode, textBuffer, '', configuredIndentation);
}
return closestNode;
}
getProperParentByIndentation(indentation, node, textBuffer, currentLine, configuredIndentation, rootParent) {
if (!node) {
return this.internalDocument.contents;
}
configuredIndentation = !configuredIndentation ? 2 : configuredIndentation;
if (isNode(node) && node.range) {
const position = textBuffer.getPosition(node.range[0]);
const lineContent = textBuffer.getLineContent(position.line);
currentLine = currentLine === '' ? lineContent.trim() : currentLine;
if (currentLine.startsWith('-') && indentation === configuredIndentation && currentLine === lineContent.trim()) {
position.character += indentation;
}
if (position.character > indentation && position.character > 0) {
const parent = this.getParent(node);
if (parent) {
return this.getProperParentByIndentation(indentation, parent, textBuffer, currentLine, configuredIndentation, rootParent);
}
}
else if (position.character < indentation) {
const parent = this.getParent(node);
if (isPair(parent) && isNode(parent.value)) {
return parent.value;
}
else if (isPair(rootParent) && isNode(rootParent.value)) {
return rootParent.value;
}
}
else {
return node;
}
}
else if (isPair(node)) {
rootParent = node;
const parent = this.getParent(node);
return this.getProperParentByIndentation(indentation, parent, textBuffer, currentLine, configuredIndentation, rootParent);
}
return node;
}
getParent(node) {
return getParent(this.internalDocument, node);
}
}
/**
* Contains the SingleYAMLDocuments, to be passed
* to the `parseYAML` caller.
*/
export class YAMLDocument {
constructor(documents, tokens) {
this.documents = documents;
this.tokens = tokens;
this.errors = [];
this.warnings = [];
}
}
export class YamlDocuments {
constructor() {
// a mapping of URIs to cached documents
this.cache = new Map();
}
/**
* Get cached YAMLDocument
* @param document TextDocument to parse
* @param parserOptions YAML parserOptions
* @param addRootObject if true and document is empty add empty object {} to force schema usage
* @returns the YAMLDocument
*/
getYamlDocument(document, parserOptions, addRootObject = false) {
this.ensureCache(document, parserOptions ?? defaultOptions, addRootObject);
return this.cache.get(document.uri).document;
}
/**
* For test purpose only!
*/
clear() {
this.cache.clear();
}
ensureCache(document, parserOptions, addRootObject) {
const key = document.uri;
if (!this.cache.has(key)) {
this.cache.set(key, { version: -1, document: new YAMLDocument([], []), parserOptions: defaultOptions });
}
const cacheEntry = this.cache.get(key);
if (cacheEntry.version !== document.version ||
(parserOptions.customTags && !isArrayEqual(cacheEntry.parserOptions.customTags, parserOptions.customTags))) {
let text = document.getText();
// if text is contains only whitespace wrap all text in object to force schema selection
if (addRootObject && !/\S/.test(text)) {
text = `{${text}}`;
}
const doc = parseYAML(text, parserOptions, document);
cacheEntry.document = doc;
cacheEntry.version = document.version;
cacheEntry.parserOptions = parserOptions;
}
}
}
export const yamlDocumentsCache = new YamlDocuments();
function YAMLErrorToYamlDocDiagnostics(error) {
return {
message: error.message,
location: {
start: error.pos[0],
end: error.pos[1],
toLineEnd: true,
},
severity: 1,
code: ErrorCode.Undefined,
};
}
//# sourceMappingURL=yaml-documents.js.map

View File

@@ -0,0 +1,15 @@
import { YAMLDocument, SingleYAMLDocument } from './yaml-documents';
import { TextDocument } from 'vscode-languageserver-textdocument';
export { YAMLDocument, SingleYAMLDocument };
export type YamlVersion = '1.1' | '1.2';
export interface ParserOptions {
customTags: string[];
yamlVersion: YamlVersion;
}
export declare const defaultOptions: ParserOptions;
/**
* `yaml-ast-parser-custom-tags` parses the AST and
* returns YAML AST nodes, which are then formatted
* for consumption via the language server.
*/
export declare function parse(text: string, parserOptions?: ParserOptions, document?: TextDocument): YAMLDocument;

View File

@@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Copyright (c) Adam Voss. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Parser, Composer, LineCounter } from 'yaml';
import { YAMLDocument, SingleYAMLDocument } from './yaml-documents';
import { getCustomTags } from './custom-tag-provider';
import { TextBuffer } from '../utils/textBuffer';
export { YAMLDocument, SingleYAMLDocument };
export const defaultOptions = {
customTags: [],
yamlVersion: '1.2',
};
/**
* `yaml-ast-parser-custom-tags` parses the AST and
* returns YAML AST nodes, which are then formatted
* for consumption via the language server.
*/
export function parse(text, parserOptions = defaultOptions, document) {
const options = {
strict: false,
customTags: getCustomTags(parserOptions.customTags),
version: parserOptions.yamlVersion ?? defaultOptions.yamlVersion,
keepSourceTokens: true,
};
const composer = new Composer(options);
const lineCounter = new LineCounter();
let isLastLineEmpty = false;
if (document) {
const textBuffer = new TextBuffer(document);
const position = textBuffer.getPosition(text.length);
const lineContent = textBuffer.getLineContent(position.line);
isLastLineEmpty = lineContent.trim().length === 0;
}
const parser = isLastLineEmpty ? new Parser() : new Parser(lineCounter.addNewLine);
const tokens = parser.parse(text);
const tokensArr = Array.from(tokens);
const docs = composer.compose(tokensArr, true, text.length);
// Generate the SingleYAMLDocs from the AST nodes
const yamlDocs = Array.from(docs, (doc) => parsedDocToSingleYAMLDocument(doc, lineCounter));
// Consolidate the SingleYAMLDocs
return new YAMLDocument(yamlDocs, tokensArr);
}
function parsedDocToSingleYAMLDocument(parsedDoc, lineCounter) {
const syd = new SingleYAMLDocument(lineCounter);
syd.internalDocument = parsedDoc;
return syd;
}
//# sourceMappingURL=yamlParser07.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"yamlParser07.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/yamlParser07.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;AAEhG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAY,WAAW,EAAgD,MAAM,MAAM,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAO5C,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,UAAU,EAAE,EAAE;IACd,WAAW,EAAE,KAAK;CACnB,CAAC;AACF;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,IAAY,EAAE,gBAA+B,cAAc,EAAE,QAAuB;IACxG,MAAM,OAAO,GAAmD;QAC9D,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC;QACnD,OAAO,EAAE,aAAa,CAAC,WAAW,IAAI,cAAc,CAAC,WAAW;QAChE,gBAAgB,EAAE,IAAI;KACvB,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IACtC,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,QAAQ,EAAE;QACZ,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7D,eAAe,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;KACnD;IACD,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5D,iDAAiD;IACjD,MAAM,QAAQ,GAAyB,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,6BAA6B,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;IAElH,iCAAiC;IACjC,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,6BAA6B,CAAC,SAAmB,EAAE,WAAwB;IAClF,MAAM,GAAG,GAAG,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAChD,GAAG,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC"}

View File

@@ -0,0 +1,12 @@
import { SymbolInformation, DocumentSymbol } from 'vscode-languageserver-types';
import { YAMLSchemaService } from './yamlSchemaService';
import { DocumentSymbolsContext } from 'vscode-json-languageservice/lib/umd/jsonLanguageTypes';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Telemetry } from '../telemetry';
export declare class YAMLDocumentSymbols {
private readonly telemetry?;
private jsonDocumentSymbols;
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
findDocumentSymbols(document: TextDocument, context?: DocumentSymbolsContext): SymbolInformation[];
findHierarchicalDocumentSymbols(document: TextDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
}

View File

@@ -0,0 +1,67 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { JSONDocumentSymbols } from 'vscode-json-languageservice/lib/umd/services/jsonDocumentSymbols';
import { yamlDocumentsCache } from '../parser/yaml-documents';
import { isMap, isSeq } from 'yaml';
export class YAMLDocumentSymbols {
constructor(schemaService, telemetry) {
this.telemetry = telemetry;
this.jsonDocumentSymbols = new JSONDocumentSymbols(schemaService);
// override 'getKeyLabel' to handle complex mapping
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.jsonDocumentSymbols.getKeyLabel = (property) => {
const keyNode = property.keyNode.internalNode;
let name = '';
if (isMap(keyNode)) {
name = '{}';
}
else if (isSeq(keyNode)) {
name = '[]';
}
else {
name = keyNode.source;
}
return name;
};
}
findDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
let results = [];
try {
const doc = yamlDocumentsCache.getYamlDocument(document);
if (!doc || doc['documents'].length === 0) {
return null;
}
for (const yamlDoc of doc['documents']) {
if (yamlDoc.root) {
results = results.concat(this.jsonDocumentSymbols.findDocumentSymbols(document, yamlDoc, context));
}
}
}
catch (err) {
this.telemetry?.sendError('yaml.documentSymbols.error', err);
}
return results;
}
findHierarchicalDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
let results = [];
try {
const doc = yamlDocumentsCache.getYamlDocument(document);
if (!doc || doc['documents'].length === 0) {
return null;
}
for (const yamlDoc of doc['documents']) {
if (yamlDoc.root) {
results = results.concat(this.jsonDocumentSymbols.findDocumentSymbols2(document, yamlDoc, context));
}
}
}
catch (err) {
this.telemetry?.sendError('yaml.hierarchicalDocumentSymbols.error', err);
}
return results;
}
}
//# sourceMappingURL=documentSymbols.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"documentSymbols.js","sourceRoot":"","sources":["../../../../src/languageservice/services/documentSymbols.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;AAIhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AAGvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAQ,MAAM,MAAM,CAAC;AAE1C,MAAM,OAAO,mBAAmB;IAG9B,YACE,aAAgC,EACf,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QAEtC,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAElE,mDAAmD;QACnD,8DAA8D;QAC9D,IAAI,CAAC,mBAAmB,CAAC,WAAW,GAAG,CAAC,QAAa,EAAE,EAAE;YACvD,MAAM,OAAO,GAAS,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;YACpD,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;gBAClB,IAAI,GAAG,IAAI,CAAC;aACb;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;gBACzB,IAAI,GAAG,IAAI,CAAC;aACb;iBAAM;gBACL,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;aACvB;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;IAEM,mBAAmB,CACxB,QAAsB,EACtB,UAAkC,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE;QAEnE,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI;YACF,MAAM,GAAG,GAAG,kBAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACzD,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;gBACzC,OAAO,IAAI,CAAC;aACb;YAED,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,EAAE;gBACtC,IAAI,OAAO,CAAC,IAAI,EAAE;oBAChB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;iBACpG;aACF;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;SAC9D;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEM,+BAA+B,CACpC,QAAsB,EACtB,UAAkC,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE;QAEnE,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI;YACF,MAAM,GAAG,GAAG,kBAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACzD,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;gBACzC,OAAO,IAAI,CAAC;aACb;YAED,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,EAAE;gBACtC,IAAI,OAAO,CAAC,IAAI,EAAE;oBAChB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;iBACrG;aACF;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,wCAAwC,EAAE,GAAG,CAAC,CAAC;SAC1E;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}

View File

@@ -0,0 +1,9 @@
import { SingleYAMLDocument } from '../parser/yamlParser07';
import { JSONDocument } from '../parser/jsonParser07';
/**
* Retrieve schema if declared as modeline.
* Public for testing purpose, not part of the API.
* @param doc
*/
export declare function getSchemaFromModeline(doc: SingleYAMLDocument | JSONDocument): string;
export declare function isModeline(lineText: string): boolean;

View File

@@ -0,0 +1,32 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { SingleYAMLDocument } from '../parser/yamlParser07';
/**
* Retrieve schema if declared as modeline.
* Public for testing purpose, not part of the API.
* @param doc
*/
export function getSchemaFromModeline(doc) {
if (doc instanceof SingleYAMLDocument) {
const yamlLanguageServerModeline = doc.lineComments.find((lineComment) => {
return isModeline(lineComment);
});
if (yamlLanguageServerModeline != undefined) {
const schemaMatchs = yamlLanguageServerModeline.match(/\$schema=\S+/g);
if (schemaMatchs !== null && schemaMatchs.length >= 1) {
if (schemaMatchs.length >= 2) {
console.log('Several $schema attributes have been found on the yaml-language-server modeline. The first one will be picked.');
}
return schemaMatchs[0].substring('$schema='.length);
}
}
}
return undefined;
}
export function isModeline(lineText) {
const matchModeline = lineText.match(/^#\s+yaml-language-server\s*:/g);
return matchModeline !== null && matchModeline.length === 1;
}
//# sourceMappingURL=modelineUtil.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"modelineUtil.js","sourceRoot":"","sources":["../../../../src/languageservice/services/modelineUtil.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAsC;IAC1E,IAAI,GAAG,YAAY,kBAAkB,EAAE;QACrC,MAAM,0BAA0B,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;YACvE,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,IAAI,0BAA0B,IAAI,SAAS,EAAE;YAC3C,MAAM,YAAY,GAAG,0BAA0B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACvE,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;gBACrD,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;oBAC5B,OAAO,CAAC,GAAG,CACT,gHAAgH,CACjH,CAAC;iBACH;gBACD,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aACrD;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACvE,OAAO,aAAa,KAAK,IAAI,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;AAC9D,CAAC"}

View File

@@ -0,0 +1,12 @@
import { URI } from 'vscode-uri';
import { Connection, WorkspaceFolder } from 'vscode-languageserver';
import { WorkspaceContextService } from '../yamlLanguageService';
export interface FileSystem {
readFile(fsPath: string, encoding?: string): Promise<string>;
}
/**
* Handles schema content requests given the schema URI
* @param uri can be a local file, vscode request, http(s) request or a custom request
*/
export declare const schemaRequestHandler: (connection: Connection, uri: string, workspaceFolders: WorkspaceFolder[], workspaceRoot: URI, useVSCodeContentRequest: boolean, fs: FileSystem) => Promise<string>;
export declare const workspaceContext: WorkspaceContextService;

View File

@@ -0,0 +1,62 @@
import { URI } from 'vscode-uri';
import { xhr, getErrorStatusDescription } from 'request-light';
import * as URL from 'url';
import { CustomSchemaContentRequest, VSCodeContentRequest } from '../../requestTypes';
import { isRelativePath, relativeToAbsolutePath } from '../utils/paths';
/**
* Handles schema content requests given the schema URI
* @param uri can be a local file, vscode request, http(s) request or a custom request
*/
export const schemaRequestHandler = (connection, uri, workspaceFolders, workspaceRoot, useVSCodeContentRequest, fs) => {
if (!uri) {
return Promise.reject('No schema specified');
}
// If the requested schema URI is a relative file path
// Convert it into a proper absolute path URI
if (isRelativePath(uri)) {
uri = relativeToAbsolutePath(workspaceFolders, workspaceRoot, uri);
}
let scheme = URI.parse(uri).scheme.toLowerCase();
// test if uri is windows path, ie starts with 'c:\'
if (/^[a-z]:[\\/]/i.test(uri)) {
const winUri = URI.file(uri);
scheme = winUri.scheme.toLowerCase();
uri = winUri.toString();
}
// If the requested schema is a local file, read and return the file contents
if (scheme === 'file') {
const fsPath = URI.parse(uri).fsPath;
return fs.readFile(fsPath, 'UTF-8').catch(() => {
// If there was an error reading the file, return empty error message
// Otherwise return the file contents as a string
return '';
});
}
// HTTP(S) requests are sent and the response result is either the schema content or an error
if (scheme === 'http' || scheme === 'https') {
// If we are running inside of VSCode we need to make a content request. This content request
// will make it so that schemas behind VPN's will resolve correctly
if (useVSCodeContentRequest) {
return connection.sendRequest(VSCodeContentRequest.type, uri).then((responseText) => {
return responseText;
}, (error) => {
return Promise.reject(error.message);
});
}
// Send the HTTP(S) schema content request and return the result
const headers = { 'Accept-Encoding': 'gzip, deflate' };
return xhr({ url: uri, followRedirects: 5, headers }).then((response) => {
return response.responseText;
}, (error) => {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
});
}
// Neither local file nor vscode, nor HTTP(S) schema request, so send it off as a custom request
return connection.sendRequest(CustomSchemaContentRequest.type, uri);
};
export const workspaceContext = {
resolveRelativePath: (relativePath, resource) => {
return URL.resolve(resource, relativePath);
},
};
//# sourceMappingURL=schemaRequestHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"schemaRequestHandler.js","sourceRoot":"","sources":["../../../../src/languageservice/services/schemaRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,GAAG,EAAe,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAOxE;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,UAAsB,EACtB,GAAW,EACX,gBAAmC,EACnC,aAAkB,EAClB,uBAAgC,EAChC,EAAc,EACG,EAAE;IACnB,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;KAC9C;IAED,sDAAsD;IACtD,6CAA6C;IAC7C,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE;QACvB,GAAG,GAAG,sBAAsB,CAAC,gBAAgB,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;KACpE;IAED,IAAI,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAEjD,oDAAoD;IACpD,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACrC,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;KACzB;IAED,6EAA6E;IAC7E,IAAI,MAAM,KAAK,MAAM,EAAE;QACrB,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;QAErC,OAAO,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YAC7C,qEAAqE;YACrE,iDAAiD;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;KACJ;IAED,6FAA6F;IAC7F,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO,EAAE;QAC3C,6FAA6F;QAC7F,mEAAmE;QACnE,IAAI,uBAAuB,EAAE;YAC3B,OAAO,UAAU,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAChE,CAAC,YAAY,EAAE,EAAE;gBACf,OAAO,YAAY,CAAC;YACtB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;gBACR,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvC,CAAC,CACiB,CAAC;SACtB;QAED,gEAAgE;QAChE,MAAM,OAAO,GAAG,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;QACvD,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CACxD,CAAC,QAAQ,EAAE,EAAE;YACX,OAAO,QAAQ,CAAC,YAAY,CAAC;QAC/B,CAAC,EACD,CAAC,KAAkB,EAAE,EAAE;YACrB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,yBAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3G,CAAC,CACF,CAAC;KACH;IAED,gGAAgG;IAChG,OAAO,UAAU,CAAC,WAAW,CAAC,0BAA0B,CAAC,IAAI,EAAE,GAAG,CAAoB,CAAC;AACzF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA4B;IACvD,mBAAmB,EAAE,CAAC,YAAoB,EAAE,QAAgB,EAAE,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}

View File

@@ -0,0 +1,7 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Diagnostic } from 'vscode-languageserver-types';
import { SingleYAMLDocument } from '../../parser/yaml-documents';
import { AdditionalValidator } from './types';
export declare class MapKeyOrderValidator implements AdditionalValidator {
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
}

View File

@@ -0,0 +1,36 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
import { isMap, visit } from 'yaml';
export class MapKeyOrderValidator {
validate(document, yamlDoc) {
const result = [];
visit(yamlDoc.internalDocument, (key, node) => {
if (isMap(node)) {
for (let i = 1; i < node.items.length; i++) {
if (compare(node.items[i - 1], node.items[i]) > 0) {
const range = createRange(document, node.items[i - 1]);
result.push(Diagnostic.create(range, `Wrong ordering of key "${node.items[i - 1].key}" in mapping`, DiagnosticSeverity.Error, 'mapKeyOrder'));
}
}
}
});
return result;
}
}
function createRange(document, node) {
const start = node?.srcToken.start[0]?.offset ?? node?.srcToken?.key.offset ?? node?.srcToken?.sep[0]?.offset;
const end = node?.srcToken?.value.offset ||
node?.srcToken?.sep[0]?.offset ||
node?.srcToken?.key.offset ||
node?.srcToken.start[node.srcToken.start.length - 1]?.offset;
return Range.create(document.positionAt(start), document.positionAt(end));
}
function compare(thiz, that) {
const thatKey = String(that.key);
const thisKey = String(thiz.key);
return thisKey.localeCompare(thatKey);
}
//# sourceMappingURL=map-key-order.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"map-key-order.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/map-key-order.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAGpF,OAAO,EAAE,KAAK,EAAQ,KAAK,EAAE,MAAM,MAAM,CAAC;AAE1C,MAAM,OAAO,oBAAoB;IAC/B,QAAQ,CAAC,QAAsB,EAAE,OAA2B;QAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;QAElB,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YAC5C,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE;gBACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;wBACjD,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;wBACvD,MAAM,CAAC,IAAI,CACT,UAAU,CAAC,MAAM,CACf,KAAK,EACL,0BAA0B,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,cAAc,EAC7D,kBAAkB,CAAC,KAAK,EACxB,aAAa,CACd,CACF,CAAC;qBACH;iBACF;aACF;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,WAAW,CAAC,QAAsB,EAAE,IAAU;IACrD,MAAM,KAAK,GAAG,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAC9G,MAAM,GAAG,GACP,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM;QAC5B,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM;QAC9B,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM;QAC1B,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,OAAO,CAAC,IAAU,EAAE,IAAU;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}

View File

@@ -0,0 +1,6 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Diagnostic } from 'vscode-languageserver-types';
import { SingleYAMLDocument } from '../../parser/yaml-documents';
export interface AdditionalValidator {
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
}

View File

@@ -0,0 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/types.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}

View File

@@ -0,0 +1,8 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Diagnostic } from 'vscode-languageserver-types';
import { SingleYAMLDocument } from '../../parser/yaml-documents';
import { AdditionalValidator } from './types';
export declare class UnusedAnchorsValidator implements AdditionalValidator {
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
private getAnchorNode;
}

View File

@@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Diagnostic, DiagnosticSeverity, DiagnosticTag, Range } from 'vscode-languageserver-types';
import { isAlias, isCollection, isNode, isScalar, visit, CST } from 'yaml';
import { isCollectionItem } from '../../../languageservice/utils/astUtils';
import * as l10n from '@vscode/l10n';
export class UnusedAnchorsValidator {
validate(document, yamlDoc) {
const result = [];
const anchors = new Set();
const usedAnchors = new Set();
const unIdentifiedAlias = new Set();
const anchorParent = new Map();
visit(yamlDoc.internalDocument, (key, node, path) => {
if (!isNode(node)) {
return;
}
if ((isCollection(node) || isScalar(node)) && node.anchor) {
anchors.add(node);
anchorParent.set(node, path[path.length - 1]);
}
if (isAlias(node)) {
if (!node.resolve(yamlDoc.internalDocument)) {
unIdentifiedAlias.add(node);
}
else {
usedAnchors.add(node.resolve(yamlDoc.internalDocument));
}
}
});
for (const anchor of anchors) {
if (!usedAnchors.has(anchor)) {
const aToken = this.getAnchorNode(anchorParent.get(anchor), anchor);
if (aToken) {
const range = Range.create(document.positionAt(aToken.offset), document.positionAt(aToken.offset + aToken.source.length));
const warningDiagnostic = Diagnostic.create(range, l10n.t('unUsedAnchor', aToken.source), DiagnosticSeverity.Information, 0);
warningDiagnostic.tags = [DiagnosticTag.Unnecessary];
result.push(warningDiagnostic);
}
}
}
unIdentifiedAlias.forEach((node) => {
const nodeRange = node.range;
if (nodeRange) {
const startOffset = nodeRange[0];
const endOffset = nodeRange[1];
const range = Range.create(document.positionAt(startOffset), document.positionAt(endOffset));
const warningDiagnostic = Diagnostic.create(range, l10n.t('unUsedAlias', node.toString()), DiagnosticSeverity.Information, 0);
warningDiagnostic.tags = [DiagnosticTag.Unnecessary];
result.push(warningDiagnostic);
}
});
return result;
}
getAnchorNode(parentNode, node) {
if (parentNode && parentNode.srcToken) {
const token = parentNode.srcToken;
if (isCollectionItem(token)) {
return getAnchorFromCollectionItem(token);
}
else if (CST.isCollection(token)) {
for (const t of token.items) {
if (node.srcToken !== t.value)
continue;
const anchor = getAnchorFromCollectionItem(t);
if (anchor) {
return anchor;
}
}
}
}
return undefined;
}
}
function getAnchorFromCollectionItem(token) {
for (const t of token.start) {
if (t.type === 'anchor') {
return t;
}
}
if (token.sep && Array.isArray(token.sep)) {
for (const t of token.sep) {
if (t.type === 'anchor') {
return t;
}
}
}
}
//# sourceMappingURL=unused-anchors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"unused-anchors.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/unused-anchors.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAgB,KAAK,EAAoB,GAAG,EAAQ,MAAM,MAAM,CAAC;AAIjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AAErC,MAAM,OAAO,sBAAsB;IACjC,QAAQ,CAAC,QAAsB,EAAE,OAA2B;QAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;QACtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAQ,CAAC;QACpC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAQ,CAAC;QAC1C,MAAM,YAAY,GAAG,IAAI,GAAG,EAA2C,CAAC;QAExE,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YAClD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACjB,OAAO;aACR;YACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE;gBACzD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClB,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAS,CAAC,CAAC;aACvD;YACD,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;oBAC3C,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;iBAC7B;qBAAM;oBACL,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;iBACzD;aACF;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;gBACpE,IAAI,MAAM,EAAE;oBACV,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CACxB,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAClC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAC1D,CAAC;oBACF,MAAM,iBAAiB,GAAG,UAAU,CAAC,MAAM,CACzC,KAAK,EACL,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,EACrC,kBAAkB,CAAC,WAAW,EAC9B,CAAC,CACF,CAAC;oBACF,iBAAiB,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;oBACrD,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBAChC;aACF;SACF;QAED,iBAAiB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACjC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;YAC7B,IAAI,SAAS,EAAE;gBACb,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBACjC,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC7F,MAAM,iBAAiB,GAAG,UAAU,CAAC,MAAM,CACzC,KAAK,EACL,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EACtC,kBAAkB,CAAC,WAAW,EAC9B,CAAC,CACF,CAAC;gBACF,iBAAiB,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBACrD,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;aAChC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IACO,aAAa,CAAC,UAAoB,EAAE,IAAU;QACpD,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,EAAE;YACrC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC;YAClC,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;gBAC3B,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;aAC3C;iBAAM,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;gBAClC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;oBAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC,KAAK;wBAAE,SAAS;oBACxC,MAAM,MAAM,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAC;oBAC9C,IAAI,MAAM,EAAE;wBACV,OAAO,MAAM,CAAC;qBACf;iBACF;aACF;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AACD,SAAS,2BAA2B,CAAC,KAAyB;IAC5D,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;QAC3B,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;YACvB,OAAO,CAAC,CAAC;SACV;KACF;IACD,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACzC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE;YACzB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvB,OAAO,CAAC,CAAC;aACV;SACF;KACF;AACH,CAAC"}

View File

@@ -0,0 +1,12 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Diagnostic } from 'vscode-languageserver-types';
import { SingleYAMLDocument } from '../../parser/yaml-documents';
import { LanguageSettings } from '../../yamlLanguageService';
import { AdditionalValidator } from './types';
export declare class YAMLStyleValidator implements AdditionalValidator {
private forbidSequence;
private forbidMapping;
constructor(settings: LanguageSettings);
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
private getRangeOf;
}

View File

@@ -0,0 +1,28 @@
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
import { isMap, isSeq, visit } from 'yaml';
import * as l10n from '@vscode/l10n';
export class YAMLStyleValidator {
constructor(settings) {
this.forbidMapping = settings.flowMapping === 'forbid';
this.forbidSequence = settings.flowSequence === 'forbid';
}
validate(document, yamlDoc) {
const result = [];
visit(yamlDoc.internalDocument, (key, node) => {
if (this.forbidMapping && isMap(node) && node.srcToken?.type === 'flow-collection') {
result.push(Diagnostic.create(this.getRangeOf(document, node.srcToken), l10n.t('flowStyleMapForbidden', 'Flow style mapping is forbidden'), DiagnosticSeverity.Error, 'flowMap'));
}
if (this.forbidSequence && isSeq(node) && node.srcToken?.type === 'flow-collection') {
result.push(Diagnostic.create(this.getRangeOf(document, node.srcToken), l10n.t('flowStyleSeqForbidden'), DiagnosticSeverity.Error, 'flowSeq'));
}
});
return result;
}
getRangeOf(document, node) {
const endOffset = node.end[0].offset;
let endPosition = document.positionAt(endOffset);
endPosition = { character: endPosition.character + 1, line: endPosition.line };
return Range.create(document.positionAt(node.start.offset), endPosition);
}
}
//# sourceMappingURL=yaml-style.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"yaml-style.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/yaml-style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAK3C,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AAErC,MAAM,OAAO,kBAAkB;IAI7B,YAAY,QAA0B;QACpC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC;QACvD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,YAAY,KAAK,QAAQ,CAAC;IAC3D,CAAC;IACD,QAAQ,CAAC,QAAsB,EAAE,OAA2B;QAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YAC5C,IAAI,IAAI,CAAC,aAAa,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;gBAClF,MAAM,CAAC,IAAI,CACT,UAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,IAAI,CAAC,CAAC,CAAC,uBAAuB,EAAE,iCAAiC,CAAC,EAClE,kBAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;aACH;YACD,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;gBACnF,MAAM,CAAC,IAAI,CACT,UAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,EAC/B,kBAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;aACH;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,UAAU,CAAC,QAAsB,EAAE,IAAoB;QAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACrC,IAAI,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACjD,WAAW,GAAG,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAC/E,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;CACF"}

Some files were not shown because too many files have changed in this diff Show More