diff --git a/CHANGELOG.md b/CHANGELOG.md index ea3e0e3..c5d5173 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file. - versions prior to 4.x of Mocha dependended on Growl 1.9.2 which contained a [security vulnerability](https://github.com/tj/node-growl/issues/60) - as Mocha is a `devDependencies` module, there is no reason to believe that consumers of the `dockerfile-language-server-nodejs` module itself was affected by this vulnerability +### Fixed +- textDocument/completion + - send back deprecated items for MAINTAINER if the client supports it ([#224](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/224)) + ## [0.0.18] - 2018-06-30 ### Added - documentLink/resolve diff --git a/package-lock.json b/package-lock.json index 0276af9..93e5392 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2064,39 +2064,41 @@ "integrity": "sha1-7znN6ierrAtQAkLWcmq5DgyEZjE=", "dev": true }, - "vscode-jsonrpc": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.6.0.tgz", - "integrity": "sha512-PqHHjuTlz3ks0vyZv3IkdduJReA/lqe6OP5zRl5nXn2ptMLW++fBotNyayyZEQLIF6nNrx/Rn6WhMSHElf02Yw==" - }, "vscode-languageserver": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-4.0.0.tgz", - "integrity": "sha512-bxj9nRadNkXYfVG/fjA5a+KA5WaJCeP1F2Tnj3rYFS0pKALZQCPNqk3KO/LdiGFidjyICMG7xoHvYO9J9xosXg==", - "requires": { - "vscode-languageserver-protocol": "3.6.0", - "vscode-uri": "1.0.1" - } - }, - "vscode-languageserver-protocol": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0.tgz", - "integrity": "sha512-PN5hVQQQxrtHSZR8UCstqaoI9f2H9JctFTtdIpONWjzQNurWrc48qSXXU/vTfnbSrNou8qrJgkZ4QEZsyozOMA==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-4.2.1.tgz", + "integrity": "sha512-5WAxaK1nEpe52ZaWNMqmd6rO5CIE72J/7UkGKPUTdGa0l0haWHS69tpRz+LetBlgTpP7PYacl4xhDaLZv82a+g==", "requires": { - "vscode-jsonrpc": "3.6.0", - "vscode-languageserver-types": "3.6.0" + "vscode-languageserver-protocol": "3.8.1", + "vscode-uri": "1.0.5" + }, + "dependencies": { + "vscode-jsonrpc": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz", + "integrity": "sha512-T24Jb5V48e4VgYliUXMnZ379ItbrXgOimweKaJshD84z+8q7ZOZjJan0MeDe+Ugb+uqERDVV8SBmemaGMSMugA==" + }, + "vscode-languageserver-protocol": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.8.1.tgz", + "integrity": "sha512-KdeetvQ2JavRiuE9afNrV5+xJZocj7NGPQwH4kpSFw5cp+0wijv87qgXfSEvmwPUaknhMBoSuSrSIG/LRrzWJQ==", + "requires": { + "vscode-jsonrpc": "3.6.2", + "vscode-languageserver-types": "3.8.2" + } + }, + "vscode-languageserver-types": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.8.2.tgz", + "integrity": "sha512-2RMkyt1O1czGPCnkjKZWSio2D8oh3XlQ4zi4W2xL8q2Dvi4hB3/DEt+wYyzo4hmE2ZFP0RB8PXyzHyed7p1hbw==" + }, + "vscode-uri": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.5.tgz", + "integrity": "sha1-O4majvccN/MFTXm9vdoxx7828g0=" + } } }, - "vscode-languageserver-types": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.6.0.tgz", - "integrity": "sha512-GSgQtGmtza4PoNH0+iHWylWg/1sw2DODezqYWRxbN910dPchI3CQaSJN76csKcQGv55wsWgX82T6n74q8mFSpw==" - }, - "vscode-uri": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.1.tgz", - "integrity": "sha1-Eahr7+rDxKo+wIYjZRo8gabQu8g=" - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 733a556..0ab8833 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "dockerfile-language-service": "0.0.5", "dockerfile-utils": "0.0.8", - "vscode-languageserver": "^4.0.0" + "vscode-languageserver": "^4.1.3" }, "devDependencies": { "@types/mocha": "^2.2.33", diff --git a/src/server.ts b/src/server.ts index 905bea2..f06bb8a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -79,6 +79,13 @@ function getDocument(uri: string): PromiseLike { }); } +function supportsDeprecatedItems(capabilities: ClientCapabilities): boolean { + return capabilities.textDocument + && capabilities.textDocument.completion + && capabilities.textDocument.completion.completionItem + && capabilities.textDocument.completion.completionItem.deprecatedSupport; +} + function supportsSnippets(capabilities: ClientCapabilities): boolean { return capabilities.textDocument && capabilities.textDocument.completion @@ -109,6 +116,7 @@ function setServiceCapabilities(capabilities: ClientCapabilities): void { service.setCapabilities({ completion: { completionItem: { + deprecatedSupport: supportsDeprecatedItems(capabilities), documentationFormat: getCompletionItemDocumentationFormat(capabilities), snippetSupport: supportsSnippets(capabilities) } diff --git a/test/server.test.ts b/test/server.test.ts index 4249491..8e1418c 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -5,7 +5,7 @@ import * as child_process from "child_process"; import * as assert from "assert"; -import { TextDocumentSyncKind, MarkupKind, SymbolKind } from 'vscode-languageserver'; +import { TextDocumentSyncKind, MarkupKind, SymbolKind, InsertTextFormat, CompletionItemKind } from 'vscode-languageserver'; import { CommandIds } from 'dockerfile-language-service'; import { ValidationCode } from 'dockerfile-utils'; @@ -41,6 +41,7 @@ function initialize(applyEdit: boolean): number { textDocument: { completion: { completionItem: { + deprecatedSupport: true, documentationFormat: [ MarkupKind.Markdown ], snippetSupport: true } @@ -464,6 +465,47 @@ describe("Dockerfile LSP Tests", function() { lspProcess.on("message", listener221); }); + it("issue #224", function (finished) { + this.timeout(5000); + let document = { + languageId: "dockerfile", + version: 1, + uri: "uri://dockerfile/224.txt", + text: "FROM node\nMAIN" + }; + sendNotification("textDocument/didOpen", { + textDocument: document + }); + + let completion = sendRequest("textDocument/completion", { + textDocument: { + uri: document.uri + }, + position: { + line: 1, + character: 4 + } + }); + const listener224 = (json) => { + if (json.id === completion) { + lspProcess.removeListener("message", listener224); + assert.equal(json.result.length, 1); + assert.equal(json.result[0].data, "MAINTAINER"); + assert.equal(json.result[0].deprecated, true); + assert.equal(json.result[0].insertTextFormat, InsertTextFormat.Snippet); + assert.equal(json.result[0].kind, CompletionItemKind.Keyword); + assert.equal(json.result[0].label, "MAINTAINER name"); + assert.equal(json.result[0].textEdit.newText, "MAINTAINER ${1:name}"); + assert.equal(json.result[0].textEdit.range.start.line, 1); + assert.equal(json.result[0].textEdit.range.start.character, 0); + assert.equal(json.result[0].textEdit.range.end.line, 1); + assert.equal(json.result[0].textEdit.range.end.character, 4); + finished(); + } + }; + lspProcess.on("message", listener224); + }); + after(() => { // terminate the forked LSP process after all the tests have been run lspProcess.kill();