Merge branch 'main' into bmw/schema

This commit is contained in:
Brandon Waterloo [MSFT] 2022-02-14 14:41:16 -05:00
Родитель b63130107c dc321560e6
Коммит 3ae3b4c33b
7 изменённых файлов: 70 добавлений и 119 удалений

1
.vscode/launch.json поставляемый
Просмотреть файл

@ -59,6 +59,7 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/src/test/clientExtension",
"--disable-extension=ms-azuretools.vscode-docker", // Keep the Docker extension from running so it doesn't interfere with testing
"--disable-extension=redhat.vscode-yaml", // Keep the YAML extension from running so it doesn't interfere with testing
],
"preLaunchTask": "tsc-watch: client extension",
"presentation": {

Просмотреть файл

@ -1,3 +1,8 @@
## 0.1.0 - 14 February 2022
### Fixed
* Merge keys are now allowed. [#78](https://github.com/microsoft/compose-language-service/issues/78)
* Better error messages. [#88](https://github.com/microsoft/compose-language-service/pull/88)
## 0.0.5-alpha - 15 December 2021
### Added
* Completions under the `build` section within a service. [#48](https://github.com/microsoft/compose-language-service/issues/48)

7
NOTICE.html поставляемый
Просмотреть файл

@ -143,10 +143,11 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
<li>
<details>
<summary>
yaml 2.0.0-8 - ISC
yaml 2.0.0-10 - ISC
</summary>
<p><a href="https://eemeli.org/yaml/">https://eemeli.org/yaml/</a></p>
<ul><li>Copyright (c) Microsoft Corporation.</li>
<li>Copyright Eemeli Aro &lt;eemeli@gmail.com&gt;</li></ul>
<pre>
Copyright Eemeli Aro &lt;eemeli@gmail.com&gt;
@ -358,7 +359,7 @@ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
<li>
<details>
<summary>
vscode-languageserver-textdocument 1.0.2 - MIT
vscode-languageserver-textdocument 1.0.3 - MIT
</summary>
<p><a href="https://github.com/Microsoft/vscode-languageserver-node#readme">https://github.com/Microsoft/vscode-languageserver-node#readme</a></p>
<ul><li>Copyright (c) Microsoft Corporation.</li></ul>

144
package-lock.json сгенерированный
Просмотреть файл

@ -1,19 +1,19 @@
{
"name": "@microsoft/compose-language-service",
"version": "0.0.6-alpha",
"version": "0.1.1-alpha",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@microsoft/compose-language-service",
"version": "0.0.6-alpha",
"version": "0.1.1-alpha",
"license": "See LICENSE in the project root for license information.",
"dependencies": {
"ajv": "^8.6.3",
"ajv-formats": "^2.1.1",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.3",
"yaml": "^2.0.0-9"
"yaml": "^2.0.0-10"
},
"devDependencies": {
"@types/chai": "^4.3.0",
@ -594,10 +594,16 @@
}
},
"node_modules/chokidar": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz",
"integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==",
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"dev": true,
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
@ -1192,9 +1198,9 @@
}
},
"node_modules/glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
"dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
@ -1533,32 +1539,32 @@
}
},
"node_modules/mocha": {
"version": "9.1.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz",
"integrity": "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==",
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz",
"integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==",
"dev": true,
"dependencies": {
"@ungap/promise-all-settled": "1.1.2",
"ansi-colors": "4.1.1",
"browser-stdout": "1.3.1",
"chokidar": "3.5.2",
"debug": "4.3.2",
"chokidar": "3.5.3",
"debug": "4.3.3",
"diff": "5.0.0",
"escape-string-regexp": "4.0.0",
"find-up": "5.0.0",
"glob": "7.1.7",
"glob": "7.2.0",
"growl": "1.10.5",
"he": "1.2.0",
"js-yaml": "4.1.0",
"log-symbols": "4.1.0",
"minimatch": "3.0.4",
"ms": "2.1.3",
"nanoid": "3.1.25",
"nanoid": "3.2.0",
"serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1",
"supports-color": "8.1.1",
"which": "2.0.2",
"workerpool": "6.1.5",
"workerpool": "6.2.0",
"yargs": "16.2.0",
"yargs-parser": "20.2.4",
"yargs-unparser": "2.0.0"
@ -1575,29 +1581,6 @@
"url": "https://opencollective.com/mochajs"
}
},
"node_modules/mocha/node_modules/debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
"integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
"dev": true,
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/mocha/node_modules/debug/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"node_modules/mocha/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@ -1626,9 +1609,9 @@
"dev": true
},
"node_modules/nanoid": {
"version": "3.1.25",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz",
"integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz",
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==",
"dev": true,
"bin": {
"nanoid": "bin/nanoid.cjs"
@ -2216,9 +2199,9 @@
}
},
"node_modules/workerpool": {
"version": "6.1.5",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz",
"integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==",
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz",
"integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==",
"dev": true
},
"node_modules/wrap-ansi": {
@ -2260,9 +2243,9 @@
"dev": true
},
"node_modules/yaml": {
"version": "2.0.0-9",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-9.tgz",
"integrity": "sha512-Bf2KowHjyVkIIiGMt7+fbhmlvKOaE8DWuD07bnL4+FQ9sPmEl/5IzGpBpoxPqOaHuyasBjJhyXDcISpJWfhCGw==",
"version": "2.0.0-10",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-10.tgz",
"integrity": "sha512-FHV8s5ODFFQXX/enJEU2EkanNl1UDBUz8oa4k5Qo/sR+Iq7VmhCDkRMb0/mjJCNeAWQ31W8WV6PYStDE4d9EIw==",
"engines": {
"node": ">= 12"
}
@ -2719,9 +2702,9 @@
"dev": true
},
"chokidar": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz",
"integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==",
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"dev": true,
"requires": {
"anymatch": "~3.1.2",
@ -3179,9 +3162,9 @@
"dev": true
},
"glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
@ -3424,54 +3407,37 @@
}
},
"mocha": {
"version": "9.1.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz",
"integrity": "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==",
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz",
"integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==",
"dev": true,
"requires": {
"@ungap/promise-all-settled": "1.1.2",
"ansi-colors": "4.1.1",
"browser-stdout": "1.3.1",
"chokidar": "3.5.2",
"debug": "4.3.2",
"chokidar": "3.5.3",
"debug": "4.3.3",
"diff": "5.0.0",
"escape-string-regexp": "4.0.0",
"find-up": "5.0.0",
"glob": "7.1.7",
"glob": "7.2.0",
"growl": "1.10.5",
"he": "1.2.0",
"js-yaml": "4.1.0",
"log-symbols": "4.1.0",
"minimatch": "3.0.4",
"ms": "2.1.3",
"nanoid": "3.1.25",
"nanoid": "3.2.0",
"serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1",
"supports-color": "8.1.1",
"which": "2.0.2",
"workerpool": "6.1.5",
"workerpool": "6.2.0",
"yargs": "16.2.0",
"yargs-parser": "20.2.4",
"yargs-unparser": "2.0.0"
},
"dependencies": {
"debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
"integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
"dev": true,
"requires": {
"ms": "2.1.2"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
}
}
},
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@ -3496,9 +3462,9 @@
"dev": true
},
"nanoid": {
"version": "3.1.25",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz",
"integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz",
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==",
"dev": true
},
"natural-compare": {
@ -3886,9 +3852,9 @@
"dev": true
},
"workerpool": {
"version": "6.1.5",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz",
"integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==",
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz",
"integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==",
"dev": true
},
"wrap-ansi": {
@ -3921,9 +3887,9 @@
"dev": true
},
"yaml": {
"version": "2.0.0-9",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-9.tgz",
"integrity": "sha512-Bf2KowHjyVkIIiGMt7+fbhmlvKOaE8DWuD07bnL4+FQ9sPmEl/5IzGpBpoxPqOaHuyasBjJhyXDcISpJWfhCGw=="
"version": "2.0.0-10",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-10.tgz",
"integrity": "sha512-FHV8s5ODFFQXX/enJEU2EkanNl1UDBUz8oa4k5Qo/sR+Iq7VmhCDkRMb0/mjJCNeAWQ31W8WV6PYStDE4d9EIw=="
},
"yargs": {
"version": "16.2.0",

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "@microsoft/compose-language-service",
"author": "Microsoft Corporation",
"version": "0.0.6-alpha",
"version": "0.1.1-alpha",
"publisher": "ms-azuretools",
"description": "Language service for Docker Compose documents",
"license": "See LICENSE in the project root for license information.",
@ -45,6 +45,6 @@
"ajv-formats": "^2.1.1",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.3",
"yaml": "^2.0.0-9"
"yaml": "^2.0.0-10"
}
}

Просмотреть файл

@ -5,24 +5,16 @@
import { ErrorCodes, Position, Range, ResponseError, TextDocumentIdentifier, TextDocumentsConfiguration } from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { CST, Document as YamlDocument, Parser, Composer, isDocument } from 'yaml';
import { Document as YamlDocument, isDocument, parseDocument } from 'yaml';
import { CRLF, DocumentSettings, DocumentSettingsParams, DocumentSettingsRequest, LF } from '../client/DocumentSettings';
import { ExtendedPositionParams, PositionInfo } from './ExtendedParams';
import { getCurrentContext } from './utils/ActionContext';
import { Lazy } from './utils/Lazy';
const EmptyDocumentCST: CST.Document = {
type: 'document',
offset: 0,
start: [],
};
// The stated behavior of character number in the `Position` class is to roll back to line length if it exceeds the line length. So, this will work for any line <1m characters. That should cover most of them.
const MaximumLineLength = 1000 * 1000;
export class ComposeDocument {
public readonly fullCst = new Lazy(() => this.buildFullCst());
public readonly documentCst = new Lazy(() => this.buildDocumentCst());
public readonly yamlDocument = new Lazy(() => this.buildYamlDocument());
private documentSettings: DocumentSettings | undefined;
@ -45,8 +37,6 @@ export class ComposeDocument {
private update(doc: TextDocument): ComposeDocument {
this.#textDocument = doc;
this.yamlDocument.clear();
this.documentCst.clear();
this.fullCst.clear();
return this;
}
@ -157,20 +147,8 @@ export class ComposeDocument {
update: (document, changes, version) => document.update(TextDocument.update(document.textDocument, changes, version)),
};
private buildFullCst(): CST.Token[] {
return Array.from(new Parser().parse(this.textDocument.getText()));
}
private buildDocumentCst(): CST.Document {
// The CST can consist of more than just the document
// Get the first `type === 'document'` item out of the list; this is the actual document
// If there isn't one, return `EmptyDocumentCST`
return this.fullCst.value.find(t => t.type === 'document') as CST.Document || EmptyDocumentCST;
}
private buildYamlDocument(): YamlDocument {
const composedTokens = new Composer().compose(this.fullCst.value, true);
const [yamlDocument] = composedTokens;
const yamlDocument = parseDocument(this.textDocument.getText(), { merge: true, prettyErrors: true });
if (!isDocument(yamlDocument)) {
throw new ResponseError(ErrorCodes.ParseError, 'Malformed YAML document');

Просмотреть файл

@ -68,7 +68,7 @@ services:
},
{
range: Range.create(8, 0, 8, 0),
contentCanary: 'sequence to end with ]',
contentCanary: 'and end with a ]',
},
];