🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

dockerfile-language-server-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dockerfile-language-server-nodejs - npm Package Compare versions

Comparing version

to
0.0.15

24

CHANGELOG.md
# Changelog
All notable changes to this project will be documented in this file.
## [0.0.15] - 2018-04-14
### Added
- settings
- docker.languageserver.diagnostics.instructionJSONInSingleQuotes? ([#217](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/217))
- value = ( "ignore" | "warning" | "error" )
- completionItem/resolve
- use Markdown for a completion item's documentation field if the client supports it ([#207](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/207))
- textDocument/publishDiagnostics
- warn if hyphens are being parsed as a unit of time in HEALTHCHECK duration flags ([rcjsuen/dockerfile-utils#24](https://github.com/rcjsuen/dockerfile-utils/issues/24))
- warn if two or more decimals found in a unit of time in HEALTHCHECK duration flags ([rcjsuen/dockerfile-utils#25](https://github.com/rcjsuen/dockerfile-utils/issues/25))
- warn if two hyphens are found in HEALTHCHECK duration flags ([rcjsuen/dockerfile-utils#26](https://github.com/rcjsuen/dockerfile-utils/issues/26))
- warn if instruction is written in JSON form incorrectly with single quotes ([rcjsuen/dockerfile-utils#28](https://github.com/rcjsuen/dockerfile-utils/issues/28))
### Fixed
- textDocument/didChange
- apply received changes in a textDocument/didChange in the order given in the JSON result instead of trying to sort them and apply them backwards ([#216](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/216))
- textDocument/publishDiagnostics
- clear diagnostics when server receives textDocument/didClose so that they do not linger in the client ([#214](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/214))
- fix incorrect validation error if a COPY uses JSON arguments and its last string argument is correctly defined as a folder ([#217](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/217))
- fix incorrect validation error if an ADD uses JSON arguments and its last string argument is correctly defined as a folder ([rcjsuen/dockerfile-utils#30](https://github.com/rcjsuen/dockerfile-utils/issues/30))
- skip validation of content after a JSON's closing bracket ([rcjsuen/dockerfile-utils#33](https://github.com/rcjsuen/dockerfile-utils/issues/33))
- fix validation of number of arguments for ADD and COPY instructions written in JSON ([rcjsuen/dockerfile-utils#34](https://github.com/rcjsuen/dockerfile-utils/issues/34))
## [0.0.14] - 2018-03-08

@@ -321,2 +344,3 @@ ### Added

[v0.0.15]: https://github.com/rcjsuen/dockerfile-language-server-nodejs/compare/v0.0.14...v0.0.15
[0.0.14]: https://github.com/rcjsuen/dockerfile-language-server-nodejs/compare/v0.0.13...v0.0.14

@@ -323,0 +347,0 @@ [0.0.13]: https://github.com/rcjsuen/dockerfile-language-server-nodejs/compare/v0.0.12...v0.0.13

81

lib/server.js

@@ -43,2 +43,14 @@ /* --------------------------------------------------------------------------------------------

}
/**
* Gets the MarkupKind[] that the client supports for the
* documentation field of a CompletionItem.
*
* @return the supported MarkupKind[], may be null or undefined
*/
function getCompletionItemDocumentationFormat(capabilities) {
return capabilities.textDocument
&& capabilities.textDocument.completion
&& capabilities.textDocument.completion.completionItem
&& capabilities.textDocument.completion.completionItem.documentationFormat;
}
function getHoverContentFormat(capabilities) {

@@ -53,2 +65,3 @@ return capabilities.textDocument

completionItem: {
documentationFormat: getCompletionItemDocumentationFormat(capabilities),
snippetSupport: supportsSnippets(capabilities)

@@ -139,2 +152,3 @@ }

let instructionHealthcheckMultiple = dockerfile_utils_1.ValidationSeverity.WARNING;
let instructionJSONInSingleQuotes = dockerfile_utils_1.ValidationSeverity.WARNING;
if (config) {

@@ -148,2 +162,3 @@ maintainer = getSeverity(config.deprecatedMaintainer);

instructionHealthcheckMultiple = getSeverity(config.instructionHealthcheckMultiple);
instructionJSONInSingleQuotes = getSeverity(config.instructionHealthcheckMultiple);
}

@@ -157,3 +172,4 @@ const fileSettings = {

instructionEntrypointMultiple: instructionEntrypointMultiple,
instructionHealthcheckMultiple: instructionHealthcheckMultiple
instructionHealthcheckMultiple: instructionHealthcheckMultiple,
instructionJSONInSingleQuotes: instructionJSONInSingleQuotes
};

@@ -390,53 +406,21 @@ const diagnostics = service.validate(textDocument.getText(), fileSettings);

});
function getLaterChange(changes, i, j) {
if (changes[i].range.start.line === changes[j].range.start.line) {
return changes[i].range.start.character < changes[j].range.start.character ? j : i;
}
else if (changes[i].range.start.line < changes[j].range.start.line) {
return j;
}
return i;
}
function sortChanges(changes) {
let sorted = [];
let length = changes.length;
for (let i = 0; i < length; i++) {
let candidate = 0;
for (let j = 1; j < changes.length; j++) {
candidate = getLaterChange(changes, candidate, j);
}
sorted.push(changes[candidate]);
changes.splice(candidate, 1);
}
return sorted;
}
function handleChanges(document, content, changes) {
if (changes.length === 1 && !changes[0].range) {
// not an incremental change
return changes[0].text;
}
else if (changes.length !== 0) {
changes = sortChanges(changes);
for (let i = 0; i < changes.length; i++) {
let offset = document.offsetAt(changes[i].range.start);
let end = null;
if (changes[i].range.end) {
end = document.offsetAt(changes[i].range.end);
}
else {
end = offset + changes[i].rangeLength;
}
content = content.substring(0, offset) + changes[i].text + content.substring(end);
}
}
return content;
}
connection.onDidChangeTextDocument((didChangeTextDocumentParams) => {
let document = documents[didChangeTextDocumentParams.textDocument.uri];
let buffer = document.getText();
let content = buffer;
let changes = didChangeTextDocumentParams.contentChanges;
let changed = handleChanges(document, buffer, changes);
if (changed !== buffer) {
document = vscode_languageserver_1.TextDocument.create(didChangeTextDocumentParams.textDocument.uri, document.languageId, didChangeTextDocumentParams.textDocument.version, changed);
documents[didChangeTextDocumentParams.textDocument.uri] = document;
for (let i = 0; i < changes.length; i++) {
let offset = document.offsetAt(changes[i].range.start);
let end = null;
if (changes[i].range.end) {
end = document.offsetAt(changes[i].range.end);
}
else {
end = offset + changes[i].rangeLength;
}
buffer = buffer.substring(0, offset) + changes[i].text + buffer.substring(end);
}
document = vscode_languageserver_1.TextDocument.create(didChangeTextDocumentParams.textDocument.uri, document.languageId, didChangeTextDocumentParams.textDocument.version, buffer);
documents[didChangeTextDocumentParams.textDocument.uri] = document;
if (content !== buffer) {
validateTextDocument(document);

@@ -447,2 +431,3 @@ }

validatorConfigurations.delete(didCloseTextDocumentParams.textDocument.uri);
connection.sendDiagnostics({ uri: didCloseTextDocumentParams.textDocument.uri, diagnostics: [] });
delete documents[didCloseTextDocumentParams.textDocument.uri];

@@ -449,0 +434,0 @@ });

@@ -11,3 +11,3 @@ {

],
"version": "0.0.14",
"version": "0.0.15",
"author": "Remy Suen",

@@ -25,4 +25,4 @@ "license": "MIT",

"dockerfile-ast": "0.0.3",
"dockerfile-language-service": "0.0.2",
"dockerfile-utils": "0.0.6",
"dockerfile-language-service": "0.0.3",
"dockerfile-utils": "0.0.8",
"vscode-languageserver": "^4.0.0"

@@ -29,0 +29,0 @@ },

@@ -97,4 +97,5 @@ # Dockerfile Language Server

instructionCmdMultiple?: string,
instructionEntrypointMultiple?: string
instructionHealthcheckMultiple?: string
instructionEntrypointMultiple?: string,
instructionHealthcheckMultiple?: string,
instructionJSONInSingleQuotes?: string
}

@@ -101,0 +102,0 @@ }