vscode-css-languageservice
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -0,3 +1,7 @@ | ||
2.1.3 / 2017-08-15 | ||
================== | ||
* New argument `documentSettings` to `LanguageService.doValidation` to support resource specific settings. If present, document settings are used instead of the options passed in configure. | ||
2.0.0 / 2017-02-17 | ||
================== | ||
* Updating to [language server type 3.0](https://github.com/Microsoft/vscode-languageserver-node/tree/master/types) API |
@@ -5,3 +5,3 @@ import { TextDocument, Position, CompletionList, Hover, Range, SymbolInformation, Diagnostic, Location, DocumentHighlight, CodeActionContext, Command, WorkspaceEdit } from 'vscode-languageserver-types'; | ||
configure(raw: LanguageSettings): void; | ||
doValidation(document: TextDocument, stylesheet: Stylesheet): Diagnostic[]; | ||
doValidation(document: TextDocument, stylesheet: Stylesheet, documentSettings?: LanguageSettings): Diagnostic[]; | ||
parseStylesheet(document: TextDocument): Stylesheet; | ||
@@ -18,5 +18,8 @@ doComplete(document: TextDocument, position: Position, stylesheet: Stylesheet): CompletionList; | ||
} | ||
export declare type LintSettings = { | ||
[key: string]: string; | ||
}; | ||
export interface LanguageSettings { | ||
validate?: boolean; | ||
lint?: any; | ||
lint?: LintSettings; | ||
} | ||
@@ -23,0 +26,0 @@ export declare function getCSSLanguageService(): LanguageService; |
@@ -182,3 +182,3 @@ (function (factory) { | ||
case 'position': | ||
this.getColorProposals(entry, existingNode, result); | ||
this.getPositionProposals(entry, existingNode, result); | ||
break; | ||
@@ -185,0 +185,0 @@ case 'repeat': |
@@ -23,8 +23,8 @@ (function (factory) { | ||
} | ||
CSSValidation.prototype.configure = function (raw) { | ||
this.validationEnabled = !raw || raw.validate !== false; | ||
this.lintSettings = lintRules_1.sanitize(raw && raw.lint || {}); | ||
CSSValidation.prototype.configure = function (settings) { | ||
this.settings = settings; | ||
}; | ||
CSSValidation.prototype.doValidation = function (document, stylesheet) { | ||
if (!this.validationEnabled) { | ||
CSSValidation.prototype.doValidation = function (document, stylesheet, settings) { | ||
if (settings === void 0) { settings = this.settings; } | ||
if (settings && settings.validate === false) { | ||
return []; | ||
@@ -34,3 +34,3 @@ } | ||
entries.push.apply(entries, nodes.ParseErrorCollector.entries(stylesheet)); | ||
entries.push.apply(entries, lint_1.LintVisitor.entries(stylesheet, this.lintSettings)); | ||
entries.push.apply(entries, lint_1.LintVisitor.entries(stylesheet, new lintRules_1.LintConfigurationSettings(settings && settings.lint))); | ||
function toDiagnostic(marker) { | ||
@@ -37,0 +37,0 @@ var range = vscode_languageserver_types_1.Range.create(document.positionAt(marker.getOffset()), document.positionAt(marker.getOffset() + marker.getLength())); |
@@ -47,10 +47,4 @@ (function (factory) { | ||
function LintVisitor(settings) { | ||
if (settings === void 0) { settings = {}; } | ||
this.warnings = []; | ||
this.configuration = {}; | ||
for (var ruleKey in lintRules_1.Rules) { | ||
var rule = lintRules_1.Rules[ruleKey]; | ||
var level = settings[rule.id] || lintRules_1.toLevel(rule.defaultValue); | ||
this.configuration[rule.id] = level; | ||
} | ||
this.settings = settings; | ||
} | ||
@@ -111,3 +105,3 @@ LintVisitor.entries = function (node, settings) { | ||
LintVisitor.prototype.addEntry = function (node, rule, details) { | ||
var entry = new nodes.Marker(node, rule, this.configuration[rule.id], details); | ||
var entry = new nodes.Marker(node, rule, this.settings.get(rule), details); | ||
this.warnings.push(entry); | ||
@@ -114,0 +108,0 @@ }; |
@@ -19,5 +19,5 @@ (function (factory) { | ||
var localize = nls.loadMessageBundle(); | ||
var Warning = 'warning'; | ||
var Error = 'error'; | ||
var Ignore = 'ignore'; | ||
var Warning = nodes.Level.Warning; | ||
var Error = nodes.Level.Error; | ||
var Ignore = nodes.Level.Ignore; | ||
var Rule = (function () { | ||
@@ -53,14 +53,19 @@ function Rule(id, message, defaultValue) { | ||
}; | ||
function sanitize(conf) { | ||
var settings = {}; | ||
for (var ruleName in exports.Rules) { | ||
var rule = exports.Rules[ruleName]; | ||
var level = toLevel(conf[rule.id]); | ||
if (level) { | ||
settings[rule.id] = level; | ||
var LintConfigurationSettings = (function () { | ||
function LintConfigurationSettings(conf) { | ||
if (conf === void 0) { conf = {}; } | ||
this.conf = conf; | ||
} | ||
LintConfigurationSettings.prototype.get = function (rule) { | ||
if (this.conf.hasOwnProperty(rule.id)) { | ||
var level = toLevel(this.conf[rule.id]); | ||
if (level) { | ||
return level; | ||
} | ||
} | ||
} | ||
return settings; | ||
} | ||
exports.sanitize = sanitize; | ||
return rule.defaultValue; | ||
}; | ||
return LintConfigurationSettings; | ||
}()); | ||
exports.LintConfigurationSettings = LintConfigurationSettings; | ||
function toLevel(level) { | ||
@@ -74,4 +79,3 @@ switch (level) { | ||
} | ||
exports.toLevel = toLevel; | ||
}); | ||
//# sourceMappingURL=lintRules.js.map |
@@ -172,3 +172,3 @@ var __extends = (this && this.__extends) || (function () { | ||
// special case: a simple label | ||
if (element instanceof LabelElement) { | ||
if (element instanceof LabelElement || name === '\u2026') { | ||
this.writeLine(indent, name); | ||
@@ -175,0 +175,0 @@ return; |
{ | ||
"name": "vscode-css-languageservice", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Language service for CSS, LESS and SCSS", | ||
@@ -27,3 +27,3 @@ "main": "./lib/cssLanguageService.js", | ||
"dependencies": { | ||
"vscode-languageserver-types": "^3.2.0", | ||
"vscode-languageserver-types": "^3.3.0-alpha.1", | ||
"vscode-nls": "^2.0.1" | ||
@@ -30,0 +30,0 @@ }, |
@@ -36,3 +36,3 @@ # vscode-css-languageservice | ||
configure(raw: LanguageSettings): void; | ||
doValidation(document: TextDocument, stylesheet: Stylesheet): Diagnostic[]; | ||
doValidation(document: TextDocument, stylesheet: Stylesheet, documentSettings?: LanguageSettings): Diagnostic[]; | ||
parseStylesheet(document: TextDocument): Stylesheet; | ||
@@ -39,0 +39,0 @@ doComplete(document: TextDocument, position: Position, stylesheet: Stylesheet): CompletionList; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3641553
20683