monaco-css
Advanced tools
Comparing version 2.3.0 to 2.4.0
{ | ||
"name": "monaco-css", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "CSS, LESS and SCSS plugin for the Monaco Editor", | ||
@@ -22,11 +22,11 @@ "scripts": { | ||
"devDependencies": { | ||
"monaco-editor-core": "0.15.0", | ||
"monaco-languages": "1.6.0", | ||
"monaco-editor-core": "0.16.0", | ||
"monaco-languages": "1.7.0", | ||
"monaco-plugin-helpers": "^1.0.2", | ||
"requirejs": "^2.3.6", | ||
"typescript": "3.1.6", | ||
"typescript": "3.3.3333", | ||
"uglify-js": "3.4.9", | ||
"vscode-css-languageservice": "3.0.9", | ||
"vscode-languageserver-types": "3.10.0" | ||
"vscode-css-languageservice": "4.0.0-next.2", | ||
"vscode-languageserver-types": "3.14.0" | ||
} | ||
} |
@@ -81,3 +81,3 @@ define('vs/language/css/monaco.contribution',["require", "exports"], function (require, exports) { | ||
function getMode() { | ||
return monaco.Promise.wrap(new Promise(function (resolve_1, reject_1) { require(['./cssMode'], resolve_1, reject_1); })); | ||
return new Promise(function (resolve_1, reject_1) { require(['./cssMode'], resolve_1, reject_1); }); | ||
} | ||
@@ -84,0 +84,0 @@ monaco.languages.onLanguage('less', function () { |
@@ -17,4 +17,6 @@ /*--------------------------------------------------------------------------------------------- | ||
import { getFoldingRanges } from './services/cssFolding'; | ||
import { cssDataManager } from './languageFacts/facts'; | ||
import { getSelectionRanges } from './services/cssSelectionRange'; | ||
export * from './cssLanguageTypes'; | ||
export * from './../vscode-languageserver-types/main'; | ||
export * from '../vscode-languageserver-types/main'; | ||
function createFacade(parser, completion, hover, navigation, codeActions, validation) { | ||
@@ -31,4 +33,6 @@ return { | ||
findDocumentHighlights: navigation.findDocumentHighlights.bind(navigation), | ||
findDocumentLinks: navigation.findDocumentLinks.bind(navigation), | ||
findDocumentSymbols: navigation.findDocumentSymbols.bind(navigation), | ||
doCodeActions: codeActions.doCodeActions.bind(codeActions), | ||
doCodeActions2: codeActions.doCodeActions2.bind(codeActions), | ||
findColorSymbols: function (d, s) { return navigation.findDocumentColors(d, s).map(function (s) { return s.range; }); }, | ||
@@ -38,14 +42,23 @@ findDocumentColors: navigation.findDocumentColors.bind(navigation), | ||
doRename: navigation.doRename.bind(navigation), | ||
getFoldingRanges: getFoldingRanges | ||
getFoldingRanges: getFoldingRanges, | ||
getSelectionRanges: getSelectionRanges | ||
}; | ||
} | ||
export function getCSSLanguageService() { | ||
function handleCustomData(options) { | ||
if (options && options.customDataProviders) { | ||
cssDataManager.addDataProviders(options.customDataProviders); | ||
} | ||
} | ||
export function getCSSLanguageService(options) { | ||
handleCustomData(options); | ||
return createFacade(new Parser(), new CSSCompletion(), new CSSHover(), new CSSNavigation(), new CSSCodeActions(), new CSSValidation()); | ||
} | ||
export function getSCSSLanguageService() { | ||
export function getSCSSLanguageService(options) { | ||
handleCustomData(options); | ||
return createFacade(new SCSSParser(), new SCSSCompletion(), new CSSHover(), new CSSNavigation(), new CSSCodeActions(), new CSSValidation()); | ||
} | ||
export function getLESSLanguageService() { | ||
export function getLESSLanguageService(options) { | ||
handleCustomData(options); | ||
return createFacade(new LESSParser(), new LESSCompletion(), new CSSHover(), new CSSNavigation(), new CSSCodeActions(), new CSSValidation()); | ||
} | ||
//# sourceMappingURL=cssLanguageService.js.map |
@@ -6,4 +6,25 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import { Range, TextEdit, Position } from "./../vscode-languageserver-types/main"; | ||
import { Range, TextEdit, Position } from '../vscode-languageserver-types/main'; | ||
export { Range, TextEdit, Position }; | ||
// #region Proposed types, remove once added to vscode-languageserver-types | ||
/** | ||
* Enum of known selection range kinds | ||
*/ | ||
export var SelectionRangeKind; | ||
(function (SelectionRangeKind) { | ||
/** | ||
* Empty Kind. | ||
*/ | ||
SelectionRangeKind["Empty"] = ""; | ||
/** | ||
* The statment kind, its value is `statement`, possible extensions can be | ||
* `statement.if` etc | ||
*/ | ||
SelectionRangeKind["Statement"] = "statement"; | ||
/** | ||
* The declaration kind, its value is `declaration`, possible extensions can be | ||
* `declaration.function`, `declaration.class` etc. | ||
*/ | ||
SelectionRangeKind["Declaration"] = "declaration"; | ||
})(SelectionRangeKind || (SelectionRangeKind = {})); | ||
//# sourceMappingURL=cssLanguageTypes.js.map |
@@ -6,3 +6,3 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -9,0 +9,0 @@ var CSSIssueType = /** @class */ (function () { |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -340,2 +343,13 @@ extendStatics(d, b); | ||
}; | ||
Node.prototype.findAParent = function () { | ||
var types = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
types[_i] = arguments[_i]; | ||
} | ||
var result = this; | ||
while (result && !types.some(function (t) { return result.type === t; })) { | ||
result = result.parent; | ||
} | ||
return result; | ||
}; | ||
Node.prototype.setData = function (key, value) { | ||
@@ -615,6 +629,6 @@ if (!this.options) { | ||
Declaration.prototype.setNestedProperties = function (value) { | ||
return this.setNode('nestedProprties', value); | ||
return this.setNode('nestedProperties', value); | ||
}; | ||
Declaration.prototype.getNestedProperties = function () { | ||
return this.nestedProprties; | ||
return this.nestedProperties; | ||
}; | ||
@@ -1267,2 +1281,3 @@ return Declaration; | ||
export { HexColorValue }; | ||
var _dot = '.'.charCodeAt(0), _0 = '0'.charCodeAt(0), _9 = '9'.charCodeAt(0); | ||
var NumericValue = /** @class */ (function (_super) { | ||
@@ -1282,3 +1297,4 @@ __extends(NumericValue, _super); | ||
var raw = this.getText(); | ||
var unitIdx = 0, code, _dot = '.'.charCodeAt(0), _0 = '0'.charCodeAt(0), _9 = '9'.charCodeAt(0); | ||
var unitIdx = 0; | ||
var code; | ||
for (var i = 0, len = raw.length; i < len; i++) { | ||
@@ -1302,3 +1318,5 @@ code = raw.charCodeAt(i); | ||
function VariableDeclaration(offset, length) { | ||
return _super.call(this, offset, length) || this; | ||
var _this = _super.call(this, offset, length) || this; | ||
_this.needsSemicolon = true; | ||
return _this; | ||
} | ||
@@ -1305,0 +1323,0 @@ Object.defineProperty(VariableDeclaration.prototype, "type", { |
@@ -9,3 +9,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { ParseError } from './cssErrors'; | ||
import * as languageFacts from '../services/languageFacts'; | ||
import * as languageFacts from '../languageFacts/facts'; | ||
/// <summary> | ||
@@ -143,5 +143,3 @@ /// A parser for the css core specification. See for reference: | ||
Parser.prototype.create = function (ctor) { | ||
var obj = Object.create(ctor.prototype); | ||
ctor.apply(obj, [this.token.offset, this.token.len]); | ||
return obj; | ||
return new ctor(this.token.offset, this.token.len); | ||
}; | ||
@@ -236,15 +234,17 @@ Parser.prototype.finish = function (node, error, resyncTokens, resyncStopTokens) { | ||
}; | ||
Parser.prototype._parseStylesheetStatement = function () { | ||
Parser.prototype._parseStylesheetStatement = function (isNested) { | ||
if (isNested === void 0) { isNested = false; } | ||
if (this.peek(TokenType.AtKeyword)) { | ||
return this._parseStylesheetAtStatement(); | ||
return this._parseStylesheetAtStatement(isNested); | ||
} | ||
return this._parseRuleset(false); | ||
return this._parseRuleset(isNested); | ||
}; | ||
Parser.prototype._parseStylesheetAtStatement = function () { | ||
Parser.prototype._parseStylesheetAtStatement = function (isNested) { | ||
if (isNested === void 0) { isNested = false; } | ||
return this._parseImport() | ||
|| this._parseMedia() | ||
|| this._parseMedia(isNested) | ||
|| this._parsePage() | ||
|| this._parseFontFace() | ||
|| this._parseKeyframe() | ||
|| this._parseSupports() | ||
|| this._parseSupports(isNested) | ||
|| this._parseViewPort() | ||
@@ -272,7 +272,10 @@ || this._parseNamespace() | ||
var node = this.create(nodes.RuleSet); | ||
if (!node.getSelectors().addChild(this._parseSelector(isNested))) { | ||
var selectors = node.getSelectors(); | ||
if (!selectors.addChild(this._parseSelector(isNested))) { | ||
return null; | ||
} | ||
while (this.accept(TokenType.Comma) && node.getSelectors().addChild(this._parseSelector(isNested))) { | ||
// loop | ||
while (this.accept(TokenType.Comma)) { | ||
if (!selectors.addChild(this._parseSelector(isNested))) { | ||
return this.finish(node, ParseError.SelectorExpected); | ||
} | ||
} | ||
@@ -282,3 +285,7 @@ return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); | ||
Parser.prototype._parseRuleSetDeclaration = function () { | ||
return this._parseAtApply() || this._tryParseCustomPropertyDeclaration() || this._parseDeclaration(); | ||
// https://www.w3.org/TR/css-syntax-3/#consume-a-list-of-declarations0 | ||
return this._parseAtApply() | ||
|| this._tryParseCustomPropertyDeclaration() | ||
|| this._parseDeclaration() | ||
|| this._parseUnknownAtRule(); | ||
}; | ||
@@ -316,3 +323,2 @@ /** | ||
return false; | ||
case nodes.NodeType.VariableDeclaration: | ||
case nodes.NodeType.ExtendsReference: | ||
@@ -327,2 +333,4 @@ case nodes.NodeType.MixinContent: | ||
return true; | ||
case nodes.NodeType.VariableDeclaration: | ||
return node.needsSemicolon; | ||
case nodes.NodeType.MixinReference: | ||
@@ -679,7 +687,7 @@ return !node.getContent(); | ||
// if nested, the body can contain rulesets, but also declarations | ||
return this._tryParseRuleset(isNested) | ||
return this._tryParseRuleset(true) | ||
|| this._tryToParseDeclaration() | ||
|| this._parseStylesheetStatement(); | ||
|| this._parseStylesheetStatement(true); | ||
} | ||
return this._parseStylesheetStatement(); | ||
return this._parseStylesheetStatement(false); | ||
}; | ||
@@ -748,5 +756,9 @@ Parser.prototype._parseSupportsCondition = function () { | ||
if (isNested === void 0) { isNested = false; } | ||
return this._tryParseRuleset(isNested) | ||
|| this._tryToParseDeclaration() | ||
|| this._parseStylesheetStatement(); | ||
if (isNested) { | ||
// if nested, the body can contain rulesets, but also declarations | ||
return this._tryParseRuleset(true) | ||
|| this._tryToParseDeclaration() | ||
|| this._parseStylesheetStatement(true); | ||
} | ||
return this._parseStylesheetStatement(false); | ||
}; | ||
@@ -857,3 +869,3 @@ Parser.prototype._parseMedia = function (isNested) { | ||
var node = this.create(nodes.PageBoxMarginBox); | ||
if (!this.acceptOneKeyword(languageFacts.getPageBoxDirectives())) { | ||
if (!this.acceptOneKeyword(languageFacts.pageBoxDirectives)) { | ||
this.markError(node, ParseError.UnknownAtRule, [], [TokenType.CurlyL]); | ||
@@ -890,2 +902,5 @@ } | ||
Parser.prototype._parseUnknownAtRule = function () { | ||
if (!this.peek(TokenType.AtKeyword)) { | ||
return null; | ||
} | ||
var node = this.create(nodes.UnknownAtRule); | ||
@@ -1355,2 +1370,5 @@ node.addChild(this._parseUnknownAtRuleName()); | ||
while (this.accept(TokenType.Comma)) { | ||
if (this.peek(TokenType.ParenthesisR)) { | ||
break; | ||
} | ||
if (!node.getArguments().addChild(this._parseFunctionArgument())) { | ||
@@ -1357,0 +1375,0 @@ this.markError(node, ParseError.ExpressionExpected); |
@@ -96,7 +96,7 @@ /*--------------------------------------------------------------------------------------------- | ||
MultiLineStream.prototype.advanceIfChars = function (ch) { | ||
var i; | ||
if (this.position + ch.length > this.source.length) { | ||
return false; | ||
} | ||
for (i = 0; i < ch.length; i++) { | ||
var i = 0; | ||
for (; i < ch.length; i++) { | ||
if (this.source.charCodeAt(this.position + i) !== ch[i]) { | ||
@@ -103,0 +103,0 @@ return false; |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -288,10 +291,6 @@ extendStatics(d, b); | ||
} | ||
var selector = node.findParent(nodes.NodeType.Selector); | ||
var selector = node.findAParent(nodes.NodeType.Selector, nodes.NodeType.ExtendsReference); | ||
if (selector) { | ||
return [nodes.ReferenceType.Rule]; | ||
} | ||
var extendsRef = node.findParent(nodes.NodeType.ExtendsReference); | ||
if (extendsRef) { | ||
return [nodes.ReferenceType.Rule]; | ||
} | ||
return null; | ||
@@ -298,0 +297,0 @@ }; |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -31,10 +34,12 @@ extendStatics(d, b); | ||
} | ||
LESSParser.prototype._parseStylesheetStatement = function () { | ||
LESSParser.prototype._parseStylesheetStatement = function (isNested) { | ||
if (isNested === void 0) { isNested = false; } | ||
if (this.peek(TokenType.AtKeyword)) { | ||
return this._parseVariableDeclaration() | ||
|| this._parsePlugin() | ||
|| _super.prototype._parseStylesheetAtStatement.call(this); | ||
|| _super.prototype._parseStylesheetAtStatement.call(this, isNested); | ||
} | ||
return this._tryParseMixinDeclaration() | ||
|| this._tryParseMixinReference(true) | ||
|| this._tryParseMixinReference() | ||
|| this._parseFunction() | ||
|| this._parseRuleset(true); | ||
@@ -102,3 +107,3 @@ }; | ||
|| this._parseDetachedRuleSetMixin() | ||
|| this._parseStylesheetStatement(); | ||
|| this._parseStylesheetStatement(isNested); | ||
}; | ||
@@ -112,3 +117,3 @@ LESSParser.prototype._parseMediaFeatureName = function () { | ||
var mark = this.mark(); | ||
if (!node.setVariable(this._parseVariable())) { | ||
if (!this.peekDelim('@') && !this.peek(TokenType.AtKeyword) || !node.setVariable(this._parseVariable())) { | ||
return null; | ||
@@ -118,3 +123,6 @@ } | ||
node.colonPosition = this.prevToken.offset; | ||
if (!node.setValue(this._parseDetachedRuleSet() || this._parseExpr())) { | ||
if (node.setValue(this._parseDetachedRuleSet())) { | ||
node.needsSemicolon = false; | ||
} | ||
else if (!node.setValue(this._parseExpr())) { | ||
return this.finish(node, ParseError.VariableValueExpected, [], panic); | ||
@@ -142,6 +150,6 @@ } | ||
LESSParser.prototype._parseDetachedRuleSetBody = function () { | ||
return this._tryParseKeyframeSelector() || this._tryParseRuleset(true) || _super.prototype._parseRuleSetDeclaration.call(this); | ||
return this._tryParseKeyframeSelector() || this._parseRuleSetDeclaration(); | ||
}; | ||
LESSParser.prototype._parseVariable = function () { | ||
if (!this.peekDelim('@') && !this.peek(TokenType.AtKeyword)) { | ||
if (!this.peekDelim('@') && !this.peekDelim('$') && !this.peek(TokenType.AtKeyword)) { | ||
return null; | ||
@@ -151,3 +159,3 @@ } | ||
var mark = this.mark(); | ||
while (this.acceptDelim('@')) { | ||
while (this.acceptDelim('@') || this.acceptDelim('$')) { | ||
if (this.hasWhitespace()) { | ||
@@ -158,3 +166,3 @@ this.restoreAtMark(mark); | ||
} | ||
if (!this.accept(TokenType.AtKeyword)) { | ||
if (!this.accept(TokenType.AtKeyword) && !this.accept(TokenType.Ident)) { | ||
this.restoreAtMark(mark); | ||
@@ -172,3 +180,4 @@ return null; | ||
if (term.setExpression(this._parseVariable()) || | ||
term.setExpression(this._parseEscaped())) { | ||
term.setExpression(this._parseEscaped()) || | ||
term.setExpression(this._tryParseMixinReference())) { | ||
return this.finish(term); | ||
@@ -188,3 +197,8 @@ } | ||
this.consumeToken(); | ||
return this.finish(node, this.accept(TokenType.String) ? null : ParseError.TermExpected); | ||
if (this.accept(TokenType.String) || this.accept(TokenType.EscapedJavaScript)) { | ||
return this.finish(node); | ||
} | ||
else { | ||
return this.finish(node, ParseError.TermExpected); | ||
} | ||
} | ||
@@ -230,3 +244,4 @@ return null; | ||
|| this._parseDetachedRuleSetMixin() // less detached ruleset mixin | ||
|| this._parseVariableDeclaration(); // Variable declarations | ||
|| this._parseVariableDeclaration() // Variable declarations | ||
|| this._parseUnknownAtRule(); | ||
} | ||
@@ -236,2 +251,3 @@ return this._tryParseMixinDeclaration() | ||
|| this._tryParseMixinReference() // less mixin reference | ||
|| this._parseFunction() | ||
|| this._parseExtend() // less extend declaration | ||
@@ -304,3 +320,6 @@ || _super.prototype._parseRuleSetDeclaration.call(this); // try css ruleset declaration as the last option | ||
LESSParser.prototype.peekInterpolatedIdent = function () { | ||
return this.peek(TokenType.Ident) || this.peekDelim('@') || this.peekDelim('-'); | ||
return this.peek(TokenType.Ident) || | ||
this.peekDelim('@') || | ||
this.peekDelim('$') || | ||
this.peekDelim('-'); | ||
}; | ||
@@ -310,18 +329,17 @@ LESSParser.prototype._acceptInterpolatedIdent = function (node) { | ||
var hasContent = false; | ||
var delimWithInterpolation = function () { | ||
if (!_this.acceptDelim('-')) { | ||
return null; | ||
var indentInterpolation = function () { | ||
var pos = _this.mark(); | ||
if (_this.acceptDelim('-')) { | ||
if (!_this.hasWhitespace()) { | ||
_this.acceptDelim('-'); | ||
} | ||
if (_this.hasWhitespace()) { | ||
_this.restoreAtMark(pos); | ||
return null; | ||
} | ||
} | ||
if (!_this.hasWhitespace() && _this.acceptDelim('-')) { | ||
} | ||
if (!_this.hasWhitespace()) { | ||
return _this._parseInterpolation(); | ||
} | ||
return null; | ||
return _this._parseInterpolation(); | ||
}; | ||
while (this.accept(TokenType.Ident) || node.addChild(this._parseInterpolation() || this.try(delimWithInterpolation))) { | ||
while (this.accept(TokenType.Ident) || node.addChild(indentInterpolation()) || (hasContent && (this.acceptDelim('-') || this.accept(TokenType.Num)))) { | ||
hasContent = true; | ||
if (!this.hasWhitespace() && this.acceptDelim('-')) { | ||
// '-' is a valid char inside a ident (special treatment here to support @{foo}-@{bar}) | ||
} | ||
if (this.hasWhitespace()) { | ||
@@ -334,5 +352,6 @@ break; | ||
LESSParser.prototype._parseInterpolation = function () { | ||
// @{name} | ||
// @{name} Variable or | ||
// ${name} Property | ||
var mark = this.mark(); | ||
if (this.peekDelim('@')) { | ||
if (this.peekDelim('@') || this.peekDelim('$')) { | ||
var node = this.createNode(nodes.NodeType.Interpolation); | ||
@@ -454,3 +473,3 @@ this.consumeToken(); | ||
var node = this.create(nodes.MixinReference); | ||
if (!node.addChild(this._parseVariable()) || !this.accept(TokenType.ParenthesisL)) { | ||
if (node.addChild(this._parseVariable()) && (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL))) { | ||
this.restoreAtMark(mark); | ||
@@ -464,4 +483,3 @@ return null; | ||
}; | ||
LESSParser.prototype._tryParseMixinReference = function (atRoot) { | ||
if (atRoot === void 0) { atRoot = false; } | ||
LESSParser.prototype._tryParseMixinReference = function () { | ||
var mark = this.mark(); | ||
@@ -544,3 +562,3 @@ var node = this.create(nodes.MixinReference); | ||
} | ||
// special let args: ... | ||
// special const args: ... | ||
if (this.peek(lessScanner.Ellipsis)) { | ||
@@ -558,3 +576,3 @@ var varargsNode = this.create(nodes.Node); | ||
} | ||
if (!node.setDefaultValue(this._parseExpr(true)) && !hasContent) { | ||
if (!node.setDefaultValue(this._parseDetachedRuleSet() || this._parseExpr(true)) && !hasContent) { | ||
return null; | ||
@@ -595,2 +613,27 @@ } | ||
}; | ||
LESSParser.prototype._parseFunction = function () { | ||
var pos = this.mark(); | ||
var node = this.create(nodes.Function); | ||
if (!node.setIdentifier(this._parseFunctionIdentifier())) { | ||
return null; | ||
} | ||
if (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL)) { | ||
this.restoreAtMark(pos); | ||
return null; | ||
} | ||
if (node.getArguments().addChild(this._parseMixinArgument())) { | ||
while (this.accept(TokenType.Comma) || this.accept(TokenType.SemiColon)) { | ||
if (this.peek(TokenType.ParenthesisR)) { | ||
break; | ||
} | ||
if (!node.getArguments().addChild(this._parseMixinArgument())) { | ||
return this.finish(node, ParseError.ExpressionExpected); | ||
} | ||
} | ||
} | ||
if (!this.accept(TokenType.ParenthesisR)) { | ||
return this.finish(node, ParseError.RightParenthesisExpected); | ||
} | ||
return this.finish(node); | ||
}; | ||
LESSParser.prototype._parseFunctionIdentifier = function () { | ||
@@ -597,0 +640,0 @@ if (this.peekDelim('%')) { |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -32,3 +35,3 @@ extendStatics(d, b); | ||
LESSScanner.prototype.scanNext = function (offset) { | ||
// LESS: escaped JavaScript code `let a = "dddd"` | ||
// LESS: escaped JavaScript code `const a = "dddd"` | ||
var tokenType = this.escapedJavaScript(); | ||
@@ -35,0 +38,0 @@ if (tokenType !== null) { |
@@ -6,3 +6,3 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -9,0 +9,0 @@ var SCSSIssueType = /** @class */ (function () { |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -115,20 +118,19 @@ extendStatics(d, b); | ||
node.referenceTypes = referenceTypes; | ||
node.isCustomProperty = this.peekRegExp(TokenType.Ident, /^--/); | ||
var hasContent = false; | ||
var delimWithInterpolation = function () { | ||
if (!_this.acceptDelim('-')) { | ||
return null; | ||
var indentInterpolation = function () { | ||
var pos = _this.mark(); | ||
if (_this.acceptDelim('-')) { | ||
if (!_this.hasWhitespace()) { | ||
_this.acceptDelim('-'); | ||
} | ||
if (_this.hasWhitespace()) { | ||
_this.restoreAtMark(pos); | ||
return null; | ||
} | ||
} | ||
if (!_this.hasWhitespace() && _this.acceptDelim('-')) { | ||
node.isCustomProperty = true; | ||
} | ||
if (!_this.hasWhitespace()) { | ||
return _this._parseInterpolation(); | ||
} | ||
return null; | ||
return _this._parseInterpolation(); | ||
}; | ||
while (this.accept(TokenType.Ident) || node.addChild(this._parseInterpolation() || this.try(delimWithInterpolation))) { | ||
while (this.accept(TokenType.Ident) || node.addChild(indentInterpolation()) || (hasContent && (this.acceptDelim('-') || this.accept(TokenType.Num)))) { | ||
hasContent = true; | ||
if (!this.hasWhitespace() && this.acceptDelim('-')) { | ||
// '-' is a valid char inside a ident (special treatment here to support #{foo}-#{bar}) | ||
} | ||
if (this.hasWhitespace()) { | ||
@@ -420,2 +422,5 @@ break; | ||
while (this.accept(TokenType.Comma)) { | ||
if (this.peek(TokenType.ParenthesisR)) { | ||
break; | ||
} | ||
if (!node.getParameters().addChild(this._parseParameterDeclaration())) { | ||
@@ -454,2 +459,5 @@ return this.finish(node, ParseError.VariableNameExpected); | ||
while (this.accept(TokenType.Comma)) { | ||
if (this.peek(TokenType.ParenthesisR)) { | ||
break; | ||
} | ||
if (!node.getParameters().addChild(this._parseParameterDeclaration())) { | ||
@@ -501,2 +509,5 @@ return this.finish(node, ParseError.VariableNameExpected); | ||
while (this.accept(TokenType.Comma)) { | ||
if (this.peek(TokenType.ParenthesisR)) { | ||
break; | ||
} | ||
if (!node.getArguments().addChild(this._parseFunctionArgument())) { | ||
@@ -503,0 +514,0 @@ return this.finish(node, ParseError.ExpressionExpected); |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -12,0 +15,0 @@ extendStatics(d, b); |
@@ -7,7 +7,7 @@ /*--------------------------------------------------------------------------------------------- | ||
import * as nodes from '../parser/cssNodes'; | ||
import * as languageFacts from './languageFacts'; | ||
import * as languageFacts from '../languageFacts/facts'; | ||
import { difference } from '../utils/strings'; | ||
import { Rules } from '../services/lintRules'; | ||
import { Command, TextEdit } from './../../vscode-languageserver-types/main'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import { Command, TextEdit, CodeAction, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier } from '../../vscode-languageserver-types/main'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -18,2 +18,7 @@ var CSSCodeActions = /** @class */ (function () { | ||
CSSCodeActions.prototype.doCodeActions = function (document, range, context, stylesheet) { | ||
return this.doCodeActions2(document, range, context, stylesheet).map(function (ca) { | ||
return Command.create(ca.title, '_css.applyCodeAction', document.uri, document.version, ca.edit.documentChanges[0].edits); | ||
}); | ||
}; | ||
CSSCodeActions.prototype.doCodeActions2 = function (document, range, context, stylesheet) { | ||
var result = []; | ||
@@ -31,8 +36,8 @@ if (context.diagnostics) { | ||
var candidates = []; | ||
for (var p in languageFacts.getProperties()) { | ||
var score = difference(propertyName, p); | ||
languageFacts.cssDataManager.getProperties().forEach(function (p) { | ||
var score = difference(propertyName, p.name); | ||
if (score >= propertyName.length / 2 /*score_lim*/) { | ||
candidates.push({ property: p, score: score }); | ||
candidates.push({ property: p.name, score: score }); | ||
} | ||
} | ||
}); | ||
// Sort in descending order. | ||
@@ -48,3 +53,7 @@ candidates.sort(function (a, b) { | ||
var edit = TextEdit.replace(marker.range, propertyName_1); | ||
result.push(Command.create(title, '_css.applyCodeAction', document.uri, document.version, [edit])); | ||
var documentIdentifier = VersionedTextDocumentIdentifier.create(document.uri, document.version); | ||
var workspaceEdit = { documentChanges: [TextDocumentEdit.create(documentIdentifier, [edit])] }; | ||
var codeAction = CodeAction.create(title, workspaceEdit, CodeActionKind.QuickFix); | ||
codeAction.diagnostics = [marker]; | ||
result.push(codeAction); | ||
if (--maxActions <= 0) { | ||
@@ -51,0 +60,0 @@ return; |
@@ -8,6 +8,6 @@ /*--------------------------------------------------------------------------------------------- | ||
import { Symbols } from '../parser/cssSymbolScope'; | ||
import * as languageFacts from './languageFacts'; | ||
import * as languageFacts from '../languageFacts/facts'; | ||
import * as strings from '../utils/strings'; | ||
import { Position, CompletionItemKind, Range, TextEdit, InsertTextFormat } from './../../vscode-languageserver-types/main'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import { Position, CompletionItemKind, Range, TextEdit, InsertTextFormat } from '../../vscode-languageserver-types/main'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -58,10 +58,12 @@ var SnippetFormat = InsertTextFormat.Snippet; | ||
else if (node instanceof nodes.SimpleSelector) { | ||
var parentExtRef = node.findParent(nodes.NodeType.ExtendsReference); | ||
if (parentExtRef) { | ||
this.getCompletionsForExtendsReference(parentExtRef, node, result); | ||
var parentRef = node.findAParent(nodes.NodeType.ExtendsReference, nodes.NodeType.Ruleset); | ||
if (parentRef) { | ||
if (parentRef.type === nodes.NodeType.ExtendsReference) { | ||
this.getCompletionsForExtendsReference(parentRef, node, result); | ||
} | ||
else { | ||
var parentRuleSet = parentRef; | ||
this.getCompletionsForSelector(parentRuleSet, parentRuleSet && parentRuleSet.isNested(), result); | ||
} | ||
} | ||
else { | ||
var parentRuleSet = node.findParent(nodes.NodeType.Ruleset); | ||
this.getCompletionsForSelector(parentRuleSet, parentRuleSet && parentRuleSet.isNested(), result); | ||
} | ||
} | ||
@@ -104,2 +106,5 @@ else if (node instanceof nodes.FunctionArgument) { | ||
} | ||
else if (node.type === nodes.NodeType.StringLiteral && node.parent.type === nodes.NodeType.Import) { | ||
this.getCompletionForImportPath(node, result); | ||
} | ||
else if (node.parent === null) { | ||
@@ -166,45 +171,40 @@ this.getCompletionForTopLevel(result); | ||
var _this = this; | ||
var properties = languageFacts.getProperties(); | ||
for (var key in properties) { | ||
if (properties.hasOwnProperty(key)) { | ||
var entry = properties[key]; | ||
if (entry.browsers.onCodeComplete) { | ||
var range = void 0; | ||
var insertText = void 0; | ||
var retrigger = false; | ||
if (declaration) { | ||
range = this.getCompletionRange(declaration.getProperty()); | ||
insertText = entry.name; | ||
if (!isDefined(declaration.colonPosition)) { | ||
insertText += ': '; | ||
retrigger = true; | ||
} | ||
} | ||
else { | ||
range = this.getCompletionRange(null); | ||
insertText = entry.name + ': '; | ||
retrigger = true; | ||
} | ||
var item = { | ||
label: entry.name, | ||
documentation: languageFacts.getEntryDescription(entry), | ||
textEdit: TextEdit.replace(range, insertText), | ||
kind: CompletionItemKind.Property | ||
}; | ||
if (entry.restrictions.length === 1 && entry.restrictions[0] === 'none') { | ||
retrigger = false; | ||
} | ||
if (retrigger) { | ||
item.command = { | ||
title: 'Suggest', | ||
command: 'editor.action.triggerSuggest' | ||
}; | ||
} | ||
if (strings.startsWith(entry.name, '-')) { | ||
item.sortText = 'x'; | ||
} | ||
result.items.push(item); | ||
var properties = languageFacts.cssDataManager.getProperties(); | ||
properties.forEach(function (entry) { | ||
var range; | ||
var insertText; | ||
var retrigger = false; | ||
if (declaration) { | ||
range = _this.getCompletionRange(declaration.getProperty()); | ||
insertText = entry.name; | ||
if (!isDefined(declaration.colonPosition)) { | ||
insertText += ': '; | ||
retrigger = true; | ||
} | ||
} | ||
} | ||
else { | ||
range = _this.getCompletionRange(null); | ||
insertText = entry.name + ': '; | ||
retrigger = true; | ||
} | ||
var item = { | ||
label: entry.name, | ||
documentation: languageFacts.getEntryDescription(entry), | ||
textEdit: TextEdit.replace(range, insertText), | ||
kind: CompletionItemKind.Property | ||
}; | ||
if (!entry.restrictions) { | ||
retrigger = false; | ||
} | ||
if (retrigger) { | ||
item.command = { | ||
title: 'Suggest', | ||
command: 'editor.action.triggerSuggest' | ||
}; | ||
} | ||
if (strings.startsWith(entry.name, '-')) { | ||
item.sortText = 'x'; | ||
} | ||
result.items.push(item); | ||
}); | ||
this.completionParticipants.forEach(function (participant) { | ||
@@ -223,3 +223,3 @@ if (participant.onCssProperty) { | ||
var propertyName = node.getFullPropertyName(); | ||
var entry = languageFacts.getProperties()[propertyName]; | ||
var entry = languageFacts.cssDataManager.getProperty(propertyName); | ||
var existingNode = node.getValue(); | ||
@@ -239,35 +239,37 @@ while (existingNode && existingNode.hasChildren()) { | ||
if (entry) { | ||
for (var _i = 0, _a = entry.restrictions; _i < _a.length; _i++) { | ||
var restriction = _a[_i]; | ||
switch (restriction) { | ||
case 'color': | ||
this.getColorProposals(entry, existingNode, result); | ||
break; | ||
case 'position': | ||
this.getPositionProposals(entry, existingNode, result); | ||
break; | ||
case 'repeat': | ||
this.getRepeatStyleProposals(entry, existingNode, result); | ||
break; | ||
case 'line-style': | ||
this.getLineStyleProposals(entry, existingNode, result); | ||
break; | ||
case 'line-width': | ||
this.getLineWidthProposals(entry, existingNode, result); | ||
break; | ||
case 'geometry-box': | ||
this.getGeometryBoxProposals(entry, existingNode, result); | ||
break; | ||
case 'box': | ||
this.getBoxProposals(entry, existingNode, result); | ||
break; | ||
case 'image': | ||
this.getImageProposals(entry, existingNode, result); | ||
break; | ||
case 'timing-function': | ||
this.getTimingFunctionProposals(entry, existingNode, result); | ||
break; | ||
case 'shape': | ||
this.getBasicShapeProposals(entry, existingNode, result); | ||
break; | ||
if (entry.restrictions) { | ||
for (var _i = 0, _a = entry.restrictions; _i < _a.length; _i++) { | ||
var restriction = _a[_i]; | ||
switch (restriction) { | ||
case 'color': | ||
this.getColorProposals(entry, existingNode, result); | ||
break; | ||
case 'position': | ||
this.getPositionProposals(entry, existingNode, result); | ||
break; | ||
case 'repeat': | ||
this.getRepeatStyleProposals(entry, existingNode, result); | ||
break; | ||
case 'line-style': | ||
this.getLineStyleProposals(entry, existingNode, result); | ||
break; | ||
case 'line-width': | ||
this.getLineWidthProposals(entry, existingNode, result); | ||
break; | ||
case 'geometry-box': | ||
this.getGeometryBoxProposals(entry, existingNode, result); | ||
break; | ||
case 'box': | ||
this.getBoxProposals(entry, existingNode, result); | ||
break; | ||
case 'image': | ||
this.getImageProposals(entry, existingNode, result); | ||
break; | ||
case 'timing-function': | ||
this.getTimingFunctionProposals(entry, existingNode, result); | ||
break; | ||
case 'shape': | ||
this.getBasicShapeProposals(entry, existingNode, result); | ||
break; | ||
} | ||
} | ||
@@ -298,3 +300,3 @@ } | ||
var value = _a[_i]; | ||
if (languageFacts.isCommonValue(value)) { // only show if supported by more than one browser | ||
if (languageFacts.supportedInMoreThanOneBrowser(value)) { | ||
var insertString = value.name; | ||
@@ -392,14 +394,16 @@ var insertTextFormat = void 0; | ||
} | ||
for (var _i = 0, _a = entry.restrictions; _i < _a.length; _i++) { | ||
var restriction = _a[_i]; | ||
var units = languageFacts.units[restriction]; | ||
if (units) { | ||
for (var _b = 0, units_1 = units; _b < units_1.length; _b++) { | ||
var unit = units_1[_b]; | ||
var insertText = currentWord + unit; | ||
result.items.push({ | ||
label: insertText, | ||
textEdit: TextEdit.replace(this.getCompletionRange(existingNode), insertText), | ||
kind: CompletionItemKind.Unit | ||
}); | ||
if (entry.restrictions) { | ||
for (var _i = 0, _a = entry.restrictions; _i < _a.length; _i++) { | ||
var restriction = _a[_i]; | ||
var units = languageFacts.units[restriction]; | ||
if (units) { | ||
for (var _b = 0, units_1 = units; _b < units_1.length; _b++) { | ||
var unit = units_1[_b]; | ||
var insertText = currentWord + unit; | ||
result.items.push({ | ||
label: insertText, | ||
textEdit: TextEdit.replace(this.getCompletionRange(existingNode), insertText), | ||
kind: CompletionItemKind.Unit | ||
}); | ||
} | ||
} | ||
@@ -583,13 +587,11 @@ } | ||
CSSCompletion.prototype.getCompletionForTopLevel = function (result) { | ||
for (var _i = 0, _a = languageFacts.getAtDirectives(); _i < _a.length; _i++) { | ||
var entry = _a[_i]; | ||
if (entry.browsers.count > 0) { | ||
result.items.push({ | ||
label: entry.name, | ||
textEdit: TextEdit.replace(this.getCompletionRange(null), entry.name), | ||
documentation: languageFacts.getEntryDescription(entry), | ||
kind: CompletionItemKind.Keyword | ||
}); | ||
} | ||
} | ||
var _this = this; | ||
languageFacts.cssDataManager.getAtDirectives().forEach(function (entry) { | ||
result.items.push({ | ||
label: entry.name, | ||
textEdit: TextEdit.replace(_this.getCompletionRange(null), entry.name), | ||
documentation: languageFacts.getEntryDescription(entry), | ||
kind: CompletionItemKind.Keyword | ||
}); | ||
}); | ||
this.getCompletionsForSelector(null, false, result); | ||
@@ -608,3 +610,2 @@ return result; | ||
} | ||
ruleSet.findParent(nodes.NodeType.Ruleset); | ||
return this.getCompletionsForDeclarations(ruleSet.getDeclarations(), result); | ||
@@ -620,39 +621,35 @@ }; | ||
} | ||
for (var _i = 0, _a = languageFacts.getPseudoClasses(); _i < _a.length; _i++) { | ||
var entry = _a[_i]; | ||
if (entry.browsers.onCodeComplete) { | ||
var insertText = moveCursorInsideParenthesis(entry.name); | ||
var item = { | ||
label: entry.name, | ||
textEdit: TextEdit.replace(this.getCompletionRange(existingNode), insertText), | ||
documentation: languageFacts.getEntryDescription(entry), | ||
kind: CompletionItemKind.Function, | ||
insertTextFormat: entry.name !== insertText ? SnippetFormat : void 0 | ||
}; | ||
if (strings.startsWith(entry.name, ':-')) { | ||
item.sortText = 'x'; | ||
} | ||
result.items.push(item); | ||
var pseudoClasses = languageFacts.cssDataManager.getPseudoClasses(); | ||
pseudoClasses.forEach(function (entry) { | ||
var insertText = moveCursorInsideParenthesis(entry.name); | ||
var item = { | ||
label: entry.name, | ||
textEdit: TextEdit.replace(_this.getCompletionRange(existingNode), insertText), | ||
documentation: languageFacts.getEntryDescription(entry), | ||
kind: CompletionItemKind.Function, | ||
insertTextFormat: entry.name !== insertText ? SnippetFormat : void 0 | ||
}; | ||
if (strings.startsWith(entry.name, ':-')) { | ||
item.sortText = 'x'; | ||
} | ||
} | ||
for (var _b = 0, _c = languageFacts.getPseudoElements(); _b < _c.length; _b++) { | ||
var entry = _c[_b]; | ||
if (entry.browsers.onCodeComplete) { | ||
var insertText = moveCursorInsideParenthesis(entry.name); | ||
var item = { | ||
label: entry.name, | ||
textEdit: TextEdit.replace(this.getCompletionRange(existingNode), insertText), | ||
documentation: languageFacts.getEntryDescription(entry), | ||
kind: CompletionItemKind.Function, | ||
insertTextFormat: entry.name !== insertText ? SnippetFormat : void 0 | ||
}; | ||
if (strings.startsWith(entry.name, '::-')) { | ||
item.sortText = 'x'; | ||
} | ||
result.items.push(item); | ||
result.items.push(item); | ||
}); | ||
var pseudoElements = languageFacts.cssDataManager.getPseudoElements(); | ||
pseudoElements.forEach(function (entry) { | ||
var insertText = moveCursorInsideParenthesis(entry.name); | ||
var item = { | ||
label: entry.name, | ||
textEdit: TextEdit.replace(_this.getCompletionRange(existingNode), insertText), | ||
documentation: languageFacts.getEntryDescription(entry), | ||
kind: CompletionItemKind.Function, | ||
insertTextFormat: entry.name !== insertText ? SnippetFormat : void 0 | ||
}; | ||
if (strings.startsWith(entry.name, '::-')) { | ||
item.sortText = 'x'; | ||
} | ||
} | ||
result.items.push(item); | ||
}); | ||
if (!isNested) { // show html tags only for top level | ||
for (var _d = 0, _e = languageFacts.html5Tags; _d < _e.length; _d++) { | ||
var entry = _e[_d]; | ||
for (var _i = 0, _a = languageFacts.html5Tags; _i < _a.length; _i++) { | ||
var entry = _a[_i]; | ||
result.items.push({ | ||
@@ -664,4 +661,4 @@ label: entry, | ||
} | ||
for (var _f = 0, _g = languageFacts.svgElements; _f < _g.length; _f++) { | ||
var entry = _g[_f]; | ||
for (var _b = 0, _c = languageFacts.svgElements; _b < _c.length; _b++) { | ||
var entry = _c[_b]; | ||
result.items.push({ | ||
@@ -872,2 +869,15 @@ label: entry, | ||
}; | ||
CSSCompletion.prototype.getCompletionForImportPath = function (importPathNode, result) { | ||
var _this = this; | ||
this.completionParticipants.forEach(function (participant) { | ||
if (participant.onCssImportPath) { | ||
participant.onCssImportPath({ | ||
pathValue: importPathNode.getText(), | ||
position: _this.position, | ||
range: _this.getCompletionRange(importPathNode) | ||
}); | ||
} | ||
}); | ||
return result; | ||
}; | ||
return CSSCompletion; | ||
@@ -874,0 +884,0 @@ }()); |
@@ -7,4 +7,4 @@ /*--------------------------------------------------------------------------------------------- | ||
import * as nodes from '../parser/cssNodes'; | ||
import * as languageFacts from './languageFacts'; | ||
import { Range, MarkedString } from './../../vscode-languageserver-types/main'; | ||
import * as languageFacts from '../languageFacts/facts'; | ||
import { Range, MarkedString } from '../../vscode-languageserver-types/main'; | ||
import { selectorToMarkedString, simpleSelectorToMarkedString } from './selectorPrinting'; | ||
@@ -36,3 +36,3 @@ var CSSHover = /** @class */ (function () { | ||
var propertyName = node.getFullPropertyName(); | ||
var entry = languageFacts.getProperties()[propertyName]; | ||
var entry = languageFacts.cssDataManager.getProperty(propertyName); | ||
if (entry) { | ||
@@ -39,0 +39,0 @@ var contents = []; |
@@ -6,7 +6,8 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import { DocumentHighlightKind, Location, Range, SymbolKind, TextEdit } from '../../vscode-languageserver-types/main'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
import * as nodes from '../parser/cssNodes'; | ||
import { Range, Location, DocumentHighlightKind, SymbolKind, TextEdit } from './../../vscode-languageserver-types/main'; | ||
import { Symbols } from '../parser/cssSymbolScope'; | ||
import { getColorValue, hslFromColor } from '../services/languageFacts'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import { getColorValue, hslFromColor } from '../languageFacts/facts'; | ||
import { endsWith, startsWith } from '../utils/strings'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -48,2 +49,5 @@ var CSSNavigation = /** @class */ (function () { | ||
} | ||
if (node.type === nodes.NodeType.Identifier && node.parent && node.parent.type === nodes.NodeType.ClassSelector) { | ||
node = node.parent; | ||
} | ||
var symbols = new Symbols(stylesheet); | ||
@@ -73,2 +77,27 @@ var symbol = symbols.findSymbolFromNode(node); | ||
}; | ||
CSSNavigation.prototype.findDocumentLinks = function (document, stylesheet, documentContext) { | ||
var result = []; | ||
stylesheet.accept(function (candidate) { | ||
if (candidate.type === nodes.NodeType.URILiteral) { | ||
var link = uriLiteralNodeToDocumentLink(document, candidate, documentContext); | ||
if (link) { | ||
result.push(link); | ||
} | ||
return false; | ||
} | ||
/** | ||
* In @import, it is possible to include links that do not use `url()` | ||
* For example, `@import 'foo.css';` | ||
*/ | ||
if (candidate.parent && candidate.parent.type === nodes.NodeType.Import) { | ||
var rawText = candidate.getText(); | ||
if (startsWith(rawText, "'") || startsWith(rawText, "\"")) { | ||
result.push(uriStringNodeToDocumentLink(document, candidate, documentContext)); | ||
} | ||
return false; | ||
} | ||
return true; | ||
}); | ||
return result; | ||
}; | ||
CSSNavigation.prototype.findDocumentSymbols = function (document, stylesheet) { | ||
@@ -85,3 +114,8 @@ var result = []; | ||
entry.name = node.getText(); | ||
locationNode = node.findParent(nodes.NodeType.Ruleset); | ||
locationNode = node.findAParent(nodes.NodeType.Ruleset, nodes.NodeType.ExtendsReference); | ||
if (locationNode) { | ||
entry.location = Location.create(document.uri, getRange(locationNode, document)); | ||
result.push(entry); | ||
} | ||
return false; | ||
} | ||
@@ -172,2 +206,59 @@ else if (node instanceof nodes.VariableDeclaration) { | ||
} | ||
function uriLiteralNodeToDocumentLink(document, uriLiteralNode, documentContext) { | ||
if (uriLiteralNode.getChildren().length === 0) { | ||
return null; | ||
} | ||
var uriStringNode = uriLiteralNode.getChild(0); | ||
return uriStringNodeToDocumentLink(document, uriStringNode, documentContext); | ||
} | ||
function uriStringNodeToDocumentLink(document, uriStringNode, documentContext) { | ||
var rawUri = uriStringNode.getText(); | ||
var range = getRange(uriStringNode, document); | ||
// Make sure the range is not empty | ||
if (range.start.line === range.end.line && range.start.character === range.end.character) { | ||
return null; | ||
} | ||
if (startsWith(rawUri, "'") || startsWith(rawUri, "\"")) { | ||
rawUri = rawUri.slice(1, -1); | ||
} | ||
var target; | ||
if (startsWith(rawUri, 'http://') || startsWith(rawUri, 'https://')) { | ||
target = rawUri; | ||
} | ||
else if (/^\w+:\/\//g.test(rawUri)) { | ||
target = rawUri; | ||
} | ||
else { | ||
/** | ||
* In SCSS, @import 'foo' could be referring to `_foo.scss`, if none of the following is true: | ||
* - The file's extension is .css. | ||
* - The filename begins with http://. | ||
* - The filename is a url(). | ||
* - The @import has any media queries. | ||
*/ | ||
if (document.languageId === 'scss') { | ||
if (!endsWith(rawUri, '.css') && | ||
!startsWith(rawUri, 'http://') && !startsWith(rawUri, 'https://') && | ||
!(uriStringNode.parent && uriStringNode.parent.type === nodes.NodeType.URILiteral) && | ||
uriStringNode.parent.getChildren().length === 1) { | ||
target = toScssPartialUri(documentContext.resolveReference(rawUri, document.uri)); | ||
} | ||
else { | ||
target = documentContext.resolveReference(rawUri, document.uri); | ||
} | ||
} | ||
else { | ||
target = documentContext.resolveReference(rawUri, document.uri); | ||
} | ||
} | ||
return { | ||
range: range, | ||
target: target | ||
}; | ||
} | ||
function toScssPartialUri(uri) { | ||
return uri.replace(/\/(\w+)(.scss)?$/gm, function (match, fileName) { | ||
return '/_' + fileName + '.scss'; | ||
}); | ||
} | ||
function getRange(node, document) { | ||
@@ -174,0 +265,0 @@ return Range.create(document.positionAt(node.offset), document.positionAt(node.end)); |
@@ -7,4 +7,4 @@ /*--------------------------------------------------------------------------------------------- | ||
import * as nodes from '../parser/cssNodes'; | ||
import { Range, DiagnosticSeverity } from './../../vscode-languageserver-types/main'; | ||
import { LintConfigurationSettings } from './lintRules'; | ||
import { Range, DiagnosticSeverity } from '../../vscode-languageserver-types/main'; | ||
import { LintConfigurationSettings, Rules } from './lintRules'; | ||
import { LintVisitor } from './lint'; | ||
@@ -25,7 +25,12 @@ var CSSValidation = /** @class */ (function () { | ||
entries.push.apply(entries, LintVisitor.entries(stylesheet, document, new LintConfigurationSettings(settings && settings.lint))); | ||
var ruleIds = []; | ||
for (var r in Rules) { | ||
ruleIds.push(Rules[r].id); | ||
} | ||
function toDiagnostic(marker) { | ||
var range = Range.create(document.positionAt(marker.getOffset()), document.positionAt(marker.getOffset() + marker.getLength())); | ||
var source = document.languageId; | ||
return { | ||
code: marker.getRule().id, | ||
source: document.languageId, | ||
source: source, | ||
message: marker.getMessage(), | ||
@@ -32,0 +37,0 @@ severity: marker.getLevel() === nodes.Level.Warning ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error, |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -18,4 +21,4 @@ extendStatics(d, b); | ||
import { CSSCompletion } from './cssCompletion'; | ||
import { CompletionItemKind, InsertTextFormat, TextEdit } from './../../vscode-languageserver-types/main'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import { CompletionItemKind, InsertTextFormat, TextEdit } from '../../vscode-languageserver-types/main'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -62,3 +65,36 @@ var LESSCompletion = /** @class */ (function (_super) { | ||
LESSCompletion.builtInProposals = [ | ||
// Boolean functions | ||
{ | ||
'name': 'if', | ||
'example': 'if(condition, trueValue [, falseValue]);', | ||
'description': localize('less.builtin.if', 'returns one of two values depending on a condition.') | ||
}, | ||
{ | ||
'name': 'boolean', | ||
'example': 'boolean(condition);', | ||
'description': localize('less.builtin.boolean', '"store" a boolean test for later evaluation in a guard or if().') | ||
}, | ||
// List functions | ||
{ | ||
'name': 'length', | ||
'example': 'length(@list);', | ||
'description': localize('less.builtin.length', 'returns the number of elements in a value list') | ||
}, | ||
{ | ||
'name': 'extract', | ||
'example': 'extract(@list, index);', | ||
'description': localize('less.builtin.extract', 'returns a value at the specified position in the list') | ||
}, | ||
{ | ||
'name': 'range', | ||
'example': 'range([start, ] end [, step]);', | ||
'description': localize('less.builtin.range', 'generate a list spanning a range of values') | ||
}, | ||
{ | ||
'name': 'each', | ||
'example': 'each(@list, ruleset);', | ||
'description': localize('less.builtin.each', 'bind the evaluation of a ruleset to each member of a list.') | ||
}, | ||
// Other built-ins | ||
{ | ||
'name': 'escape', | ||
@@ -101,12 +137,2 @@ 'example': 'escape(@string);', | ||
{ | ||
'name': 'length', | ||
'example': 'length(@list);', | ||
'description': localize('less.builtin.length', 'returns the number of elements in a value list') | ||
}, | ||
{ | ||
'name': 'extract', | ||
'example': 'extract(@list, index);', | ||
'description': localize('less.builtin.extract', 'returns a value at the specified position in the list') | ||
}, | ||
{ | ||
'name': 'abs', | ||
@@ -113,0 +139,0 @@ 'description': localize('less.builtin.abs', 'absolute value of a number'), |
@@ -6,14 +6,9 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import * as languageFacts from './languageFacts'; | ||
import { Rules } from './lintRules'; | ||
import * as languageFacts from '../languageFacts/facts'; | ||
import { Rules, Settings } from './lintRules'; | ||
import * as nodes from '../parser/cssNodes'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import calculateBoxModel, { Element } from './lintUtil'; | ||
import { union } from '../utils/arrays'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
var Element = /** @class */ (function () { | ||
function Element(text, data) { | ||
this.name = text; | ||
this.node = data; | ||
} | ||
return Element; | ||
}()); | ||
var NodesByRootMap = /** @class */ (function () { | ||
@@ -38,2 +33,3 @@ function NodesByRootMap() { | ||
function LintVisitor(document, settings) { | ||
var _this = this; | ||
this.warnings = []; | ||
@@ -43,2 +39,14 @@ this.settings = settings; | ||
this.keyframes = new NodesByRootMap(); | ||
this.validProperties = {}; | ||
var properties = settings.getSetting(Settings.ValidProperties); | ||
if (Array.isArray(properties)) { | ||
properties.forEach(function (p) { | ||
if (typeof p === 'string') { | ||
var name = p.trim().toLowerCase(); | ||
if (name.length) { | ||
_this.validProperties[name] = true; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
@@ -51,2 +59,6 @@ LintVisitor.entries = function (node, document, settings, entryFilter) { | ||
}; | ||
LintVisitor.prototype.isValidPropertyDeclaration = function (decl) { | ||
var propertyName = decl.getFullPropertyName().toLowerCase(); | ||
return this.validProperties[propertyName]; | ||
}; | ||
LintVisitor.prototype.fetch = function (input, s) { | ||
@@ -92,3 +104,3 @@ var elements = []; | ||
LintVisitor.prototype.addEntry = function (node, rule, details) { | ||
var entry = new nodes.Marker(node, rule, this.settings.get(rule), details); | ||
var entry = new nodes.Marker(node, rule, this.settings.getRule(rule), details); | ||
this.warnings.push(entry); | ||
@@ -222,3 +234,2 @@ }; | ||
} | ||
var self = this; | ||
var propertyTable = []; | ||
@@ -239,46 +250,33 @@ for (var _i = 0, _a = declarations.getChildren(); _i < _a.length; _i++) { | ||
///////////////////////////////////////////////////////////// | ||
if (this.fetch(propertyTable, 'box-sizing').length === 0) { | ||
var widthEntries = this.fetch(propertyTable, 'width'); | ||
if (widthEntries.length > 0) { | ||
var problemDetected = false; | ||
for (var _b = 0, _c = ['border', 'border-left', 'border-right', 'padding', 'padding-left', 'padding-right']; _b < _c.length; _b++) { | ||
var p = _c[_b]; | ||
var elements_3 = this.fetch(propertyTable, p); | ||
for (var _d = 0, elements_1 = elements_3; _d < elements_1.length; _d++) { | ||
var element = elements_1[_d]; | ||
var value = element.node.getValue(); | ||
if (value && !value.matches('none')) { | ||
this.addEntry(element.node, Rules.BewareOfBoxModelSize); | ||
problemDetected = true; | ||
} | ||
} | ||
var boxModel = calculateBoxModel(propertyTable); | ||
if (boxModel.width) { | ||
var properties = []; | ||
if (boxModel.right.value) { | ||
properties = union(properties, boxModel.right.properties); | ||
} | ||
if (boxModel.left.value) { | ||
properties = union(properties, boxModel.left.properties); | ||
} | ||
if (properties.length !== 0) { | ||
for (var _b = 0, properties_1 = properties; _b < properties_1.length; _b++) { | ||
var item = properties_1[_b]; | ||
this.addEntry(item.node, Rules.BewareOfBoxModelSize); | ||
} | ||
if (problemDetected) { | ||
for (var _e = 0, widthEntries_1 = widthEntries; _e < widthEntries_1.length; _e++) { | ||
var widthEntry = widthEntries_1[_e]; | ||
this.addEntry(widthEntry.node, Rules.BewareOfBoxModelSize); | ||
} | ||
} | ||
this.addEntry(boxModel.width.node, Rules.BewareOfBoxModelSize); | ||
} | ||
var heightEntries = this.fetch(propertyTable, 'height'); | ||
if (heightEntries.length > 0) { | ||
var problemDetected = false; | ||
for (var _f = 0, _g = ['border', 'border-top', 'border-bottom', 'padding', 'padding-top', 'padding-bottom']; _f < _g.length; _f++) { | ||
var p = _g[_f]; | ||
var elements_4 = this.fetch(propertyTable, p); | ||
for (var _h = 0, elements_2 = elements_4; _h < elements_2.length; _h++) { | ||
var element = elements_2[_h]; | ||
var value = element.node.getValue(); | ||
if (value && !value.matches('none')) { | ||
this.addEntry(element.node, Rules.BewareOfBoxModelSize); | ||
problemDetected = true; | ||
} | ||
} | ||
} | ||
if (boxModel.height) { | ||
var properties = []; | ||
if (boxModel.top.value) { | ||
properties = union(properties, boxModel.top.properties); | ||
} | ||
if (boxModel.bottom.value) { | ||
properties = union(properties, boxModel.bottom.properties); | ||
} | ||
if (properties.length !== 0) { | ||
for (var _c = 0, properties_2 = properties; _c < properties_2.length; _c++) { | ||
var item = properties_2[_c]; | ||
this.addEntry(item.node, Rules.BewareOfBoxModelSize); | ||
} | ||
if (problemDetected) { | ||
for (var _j = 0, heightEntries_1 = heightEntries; _j < heightEntries_1.length; _j++) { | ||
var heightEntry = heightEntries_1[_j]; | ||
this.addEntry(heightEntry.node, Rules.BewareOfBoxModelSize); | ||
} | ||
} | ||
this.addEntry(boxModel.height.node, Rules.BewareOfBoxModelSize); | ||
} | ||
@@ -292,5 +290,5 @@ } | ||
if (displayElems.length > 0) { | ||
for (var _k = 0, _l = ['width', 'height', 'margin-top', 'margin-bottom', 'float']; _k < _l.length; _k++) { | ||
var prop = _l[_k]; | ||
var elem = self.fetch(propertyTable, prop); | ||
for (var _d = 0, _e = ['width', 'height', 'margin-top', 'margin-bottom', 'float']; _d < _e.length; _d++) { | ||
var prop = _e[_d]; | ||
var elem = this.fetch(propertyTable, prop); | ||
for (var index = 0; index < elem.length; index++) { | ||
@@ -302,3 +300,3 @@ var node_1 = elem[index].node; | ||
} | ||
self.addEntry(node_1, Rules.PropertyIgnoredDueToDisplay, localize('rule.propertyIgnoredDueToDisplayInline', "Property is ignored due to the display. With 'display: inline', the width, height, margin-top, margin-bottom, and float properties have no effect.")); | ||
this.addEntry(node_1, Rules.PropertyIgnoredDueToDisplay, localize('rule.propertyIgnoredDueToDisplayInline', "Property is ignored due to the display. With 'display: inline', the width, height, margin-top, margin-bottom, and float properties have no effect.")); | ||
} | ||
@@ -332,3 +330,6 @@ } | ||
for (var index = 0; index < elements.length; index++) { | ||
this.addEntry(elements[index].node, Rules.AvoidFloat); | ||
var decl = elements[index].node; | ||
if (!this.isValidPropertyDeclaration(decl)) { | ||
this.addEntry(decl, Rules.AvoidFloat); | ||
} | ||
} | ||
@@ -340,10 +341,10 @@ ///////////////////////////////////////////////////////////// | ||
var element = propertyTable[i]; | ||
if (element.name !== 'background') { | ||
if (element.name !== 'background' && !this.validProperties[element.name]) { | ||
var value = element.node.getValue(); | ||
if (value && this.documentText.charAt(value.offset) !== '-') { | ||
var elements_5 = this.fetch(propertyTable, element.name); | ||
if (elements_5.length > 1) { | ||
for (var k = 0; k < elements_5.length; k++) { | ||
var value_1 = elements_5[k].node.getValue(); | ||
if (value_1 && this.documentText.charAt(value_1.offset) !== '-' && elements_5[k] !== element) { | ||
var elements_1 = this.fetch(propertyTable, element.name); | ||
if (elements_1.length > 1) { | ||
for (var k = 0; k < elements_1.length; k++) { | ||
var value_1 = elements_1[k].node.getValue(); | ||
if (value_1 && this.documentText.charAt(value_1.offset) !== '-' && elements_1[k] !== element) { | ||
this.addEntry(element.node, Rules.DuplicateDeclarations); | ||
@@ -359,60 +360,67 @@ } | ||
///////////////////////////////////////////////////////////// | ||
var propertiesBySuffix = new NodesByRootMap(); | ||
var containsUnknowns = false; | ||
for (var _m = 0, _o = declarations.getChildren(); _m < _o.length; _m++) { | ||
var node_3 = _o[_m]; | ||
if (this.isCSSDeclaration(node_3)) { | ||
var decl = node_3; | ||
var name = decl.getFullPropertyName(); | ||
var firstChar = name.charAt(0); | ||
if (firstChar === '-') { | ||
if (name.charAt(1) !== '-') { // avoid css variables | ||
if (!languageFacts.isKnownProperty(name)) { | ||
this.addEntry(decl.getProperty(), Rules.UnknownVendorSpecificProperty); | ||
var isExportBlock = node.getSelectors().getText() === ":export"; | ||
if (!isExportBlock) { | ||
var propertiesBySuffix = new NodesByRootMap(); | ||
var containsUnknowns = false; | ||
for (var _f = 0, _g = declarations.getChildren(); _f < _g.length; _f++) { | ||
var node_3 = _g[_f]; | ||
if (this.isCSSDeclaration(node_3)) { | ||
var decl = node_3; | ||
var name = decl.getFullPropertyName().toLowerCase(); | ||
var firstChar = name.charAt(0); | ||
if (firstChar === '-') { | ||
if (name.charAt(1) !== '-') { // avoid css variables | ||
if (!languageFacts.cssDataManager.isKnownProperty(name) && !this.validProperties[name]) { | ||
this.addEntry(decl.getProperty(), Rules.UnknownVendorSpecificProperty); | ||
} | ||
var nonPrefixedName = decl.getNonPrefixedPropertyName(); | ||
propertiesBySuffix.add(nonPrefixedName, name, decl.getProperty()); | ||
} | ||
var nonPrefixedName = decl.getNonPrefixedPropertyName(); | ||
propertiesBySuffix.add(nonPrefixedName, name, decl.getProperty()); | ||
} | ||
else { | ||
var fullName = name; | ||
if (firstChar === '*' || firstChar === '_') { | ||
this.addEntry(decl.getProperty(), Rules.IEStarHack); | ||
name = name.substr(1); | ||
} | ||
// _property and *property might be contributed via custom data | ||
if (!languageFacts.cssDataManager.isKnownProperty(fullName) && !languageFacts.cssDataManager.isKnownProperty(name)) { | ||
if (!this.validProperties[name]) { | ||
this.addEntry(decl.getProperty(), Rules.UnknownProperty, localize('property.unknownproperty.detailed', "Unknown property: '{0}'", name)); | ||
} | ||
} | ||
propertiesBySuffix.add(name, name, null); // don't pass the node as we don't show errors on the standard | ||
} | ||
} | ||
else { | ||
if (firstChar === '*' || firstChar === '_') { | ||
this.addEntry(decl.getProperty(), Rules.IEStarHack); | ||
name = name.substr(1); | ||
} | ||
if (!languageFacts.isKnownProperty(name)) { | ||
this.addEntry(decl.getProperty(), Rules.UnknownProperty, localize('property.unknownproperty.detailed', "Unknown property: '{0}'", name)); | ||
} | ||
propertiesBySuffix.add(name, name, null); // don't pass the node as we don't show errors on the standard | ||
containsUnknowns = true; | ||
} | ||
} | ||
else { | ||
containsUnknowns = true; | ||
} | ||
} | ||
if (!containsUnknowns) { // don't perform this test if there are | ||
for (var suffix in propertiesBySuffix.data) { | ||
var entry = propertiesBySuffix.data[suffix]; | ||
var actual = entry.names; | ||
var needsStandard = languageFacts.isStandardProperty(suffix) && (actual.indexOf(suffix) === -1); | ||
if (!needsStandard && actual.length === 1) { | ||
continue; // only the non-vendor specific rule is used, that's fine, no warning | ||
} | ||
var expected = []; | ||
for (var i = 0, len = LintVisitor.prefixes.length; i < len; i++) { | ||
var prefix = LintVisitor.prefixes[i]; | ||
if (languageFacts.isStandardProperty(prefix + suffix)) { | ||
expected.push(prefix + suffix); | ||
if (!containsUnknowns) { // don't perform this test if there are | ||
for (var suffix in propertiesBySuffix.data) { | ||
var entry = propertiesBySuffix.data[suffix]; | ||
var actual = entry.names; | ||
var needsStandard = languageFacts.cssDataManager.isStandardProperty(suffix) && (actual.indexOf(suffix) === -1); | ||
if (!needsStandard && actual.length === 1) { | ||
continue; // only the non-vendor specific rule is used, that's fine, no warning | ||
} | ||
} | ||
var missingVendorSpecific = this.getMissingNames(expected, actual); | ||
if (missingVendorSpecific || needsStandard) { | ||
for (var _p = 0, _q = entry.nodes; _p < _q.length; _p++) { | ||
var node_4 = _q[_p]; | ||
if (needsStandard) { | ||
var message = localize('property.standard.missing', "Also define the standard property '{0}' for compatibility", suffix); | ||
this.addEntry(node_4, Rules.IncludeStandardPropertyWhenUsingVendorPrefix, message); | ||
var expected = []; | ||
for (var i = 0, len = LintVisitor.prefixes.length; i < len; i++) { | ||
var prefix = LintVisitor.prefixes[i]; | ||
if (languageFacts.cssDataManager.isStandardProperty(prefix + suffix)) { | ||
expected.push(prefix + suffix); | ||
} | ||
if (missingVendorSpecific) { | ||
var message = localize('property.vendorspecific.missing', "Always include all vendor specific properties: Missing: {0}", missingVendorSpecific); | ||
this.addEntry(node_4, Rules.AllVendorPrefixes, message); | ||
} | ||
var missingVendorSpecific = this.getMissingNames(expected, actual); | ||
if (missingVendorSpecific || needsStandard) { | ||
for (var _h = 0, _j = entry.nodes; _h < _j.length; _h++) { | ||
var node_4 = _j[_h]; | ||
if (needsStandard) { | ||
var message = localize('property.standard.missing', "Also define the standard property '{0}' for compatibility", suffix); | ||
this.addEntry(node_4, Rules.IncludeStandardPropertyWhenUsingVendorPrefix, message); | ||
} | ||
if (missingVendorSpecific) { | ||
var message = localize('property.vendorspecific.missing', "Always include all vendor specific properties: Missing: {0}", missingVendorSpecific); | ||
this.addEntry(node_4, Rules.AllVendorPrefixes, message); | ||
} | ||
} | ||
@@ -436,6 +444,10 @@ } | ||
///////////////////////////////////////////////////////////// | ||
var funcDecl = node.findParent(nodes.NodeType.Function); | ||
if (funcDecl && funcDecl.getName() === 'calc') { | ||
return true; | ||
} | ||
var decl = node.findParent(nodes.NodeType.Declaration); | ||
if (decl) { | ||
var declValue = decl.getValue(); | ||
if (declValue && declValue.offset === node.offset && declValue.length === node.length) { | ||
if (declValue) { | ||
var value = node.getValue(); | ||
@@ -445,3 +457,3 @@ if (!value.unit || languageFacts.units.length.indexOf(value.unit.toLowerCase()) === -1) { | ||
} | ||
if (parseFloat(value.value) === 0.0 && !!value.unit) { | ||
if (parseFloat(value.value) === 0.0 && !!value.unit && !this.validProperties[decl.getFullPropertyName()]) { | ||
this.addEntry(node, Rules.ZeroWithUnit); | ||
@@ -495,3 +507,3 @@ } | ||
LintVisitor.prototype.visitHexColorValue = function (node) { | ||
// Rule: #eeff0011 or #eeff00 or #ef01 or #ef0 | ||
// Rule: #eeff0011 or #eeff00 or #ef01 or #ef0 | ||
var length = node.length; | ||
@@ -498,0 +510,0 @@ if (length !== 9 && length !== 7 && length !== 5 && length !== 4) { |
@@ -7,3 +7,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import * as nodes from '../parser/cssNodes'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -23,2 +23,12 @@ var Warning = nodes.Level.Warning; | ||
export { Rule }; | ||
var Setting = /** @class */ (function () { | ||
function Setting(id, message, defaultValue) { | ||
this.id = id; | ||
this.message = message; | ||
this.defaultValue = defaultValue; | ||
// nothing to do | ||
} | ||
return Setting; | ||
}()); | ||
export { Setting }; | ||
export var Rules = { | ||
@@ -45,2 +55,5 @@ AllVendorPrefixes: new Rule('compatibleVendorPrefixes', localize('rule.vendorprefixes.all', "When using a vendor-specific prefix make sure to also include all other vendor-specific properties"), Ignore), | ||
}; | ||
export var Settings = { | ||
ValidProperties: new Setting('validProperties', localize('rule.validProperties', "A list of properties that are not validated against the `unknownProperties` rule."), []) | ||
}; | ||
var LintConfigurationSettings = /** @class */ (function () { | ||
@@ -51,3 +64,3 @@ function LintConfigurationSettings(conf) { | ||
} | ||
LintConfigurationSettings.prototype.get = function (rule) { | ||
LintConfigurationSettings.prototype.getRule = function (rule) { | ||
if (this.conf.hasOwnProperty(rule.id)) { | ||
@@ -61,2 +74,5 @@ var level = toLevel(this.conf[rule.id]); | ||
}; | ||
LintConfigurationSettings.prototype.getSetting = function (setting) { | ||
return this.conf[setting.id]; | ||
}; | ||
return LintConfigurationSettings; | ||
@@ -63,0 +79,0 @@ }()); |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -19,4 +22,4 @@ extendStatics(d, b); | ||
import * as nodes from '../parser/cssNodes'; | ||
import { CompletionItemKind, TextEdit, InsertTextFormat } from './../../vscode-languageserver-types/main'; | ||
import * as nls from './../../../fillers/vscode-nls'; | ||
import { CompletionItemKind, TextEdit, InsertTextFormat } from '../../vscode-languageserver-types/main'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
@@ -30,3 +33,3 @@ var SCSSCompletion = /** @class */ (function (_super) { | ||
var tabStopCounter = 1; | ||
return function (match, p1) { | ||
return function (_match, p1) { | ||
return '\\' + p1 + ': ${' + tabStopCounter++ + ':' + (SCSSCompletion.variableDefaults[p1] || '') + '}'; | ||
@@ -76,3 +79,3 @@ }; | ||
}; | ||
SCSSCompletion.prototype.getCompletionsForExtendsReference = function (extendsRef, existingNode, result) { | ||
SCSSCompletion.prototype.getCompletionsForExtendsReference = function (_extendsRef, existingNode, result) { | ||
var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Rule); | ||
@@ -79,0 +82,0 @@ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { |
@@ -7,5 +7,8 @@ /*--------------------------------------------------------------------------------------------- | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -19,2 +22,4 @@ extendStatics(d, b); | ||
import { Scanner } from '../parser/cssScanner'; | ||
import * as nls from '../../../fillers/vscode-nls'; | ||
var localize = nls.loadMessageBundle(); | ||
var Element = /** @class */ (function () { | ||
@@ -311,9 +316,54 @@ function Element() { | ||
} | ||
function selectorToSpecificityMarkedString(node) { | ||
//https://www.w3.org/TR/selectors-3/#specificity | ||
function calculateScore(node) { | ||
node.getChildren().forEach(function (element) { | ||
switch (element.type) { | ||
case nodes.NodeType.IdentifierSelector: | ||
specificity[0] += 1; //a | ||
break; | ||
case nodes.NodeType.ClassSelector: | ||
case nodes.NodeType.AttributeSelector: | ||
specificity[1] += 1; //b | ||
break; | ||
case nodes.NodeType.ElementNameSelector: | ||
//ignore universal selector | ||
if (element.getText() === "*") { | ||
break; | ||
} | ||
specificity[2] += 1; //c | ||
break; | ||
case nodes.NodeType.PseudoSelector: | ||
if (element.getText().match(/^::/)) { | ||
specificity[2] += 1; //c (pseudo element) | ||
} | ||
else { | ||
//ignore psuedo class NOT | ||
if (element.getText().match(/^:not/i)) { | ||
break; | ||
} | ||
specificity[1] += 1; //b (pseudo class) | ||
} | ||
break; | ||
} | ||
if (element.getChildren().length > 0) { | ||
calculateScore(element); | ||
} | ||
}); | ||
} | ||
var specificity = [0, 0, 0]; //a,b,c | ||
calculateScore(node); | ||
return localize.apply(void 0, ['specificity', "[Selector Specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity): ({0}, {1}, {2})"].concat(specificity)); | ||
} | ||
export function selectorToMarkedString(node) { | ||
var root = selectorToElement(node); | ||
return new MarkedStringPrinter('"').print(root); | ||
var markedStrings = new MarkedStringPrinter('"').print(root); | ||
markedStrings.push(selectorToSpecificityMarkedString(node)); | ||
return markedStrings; | ||
} | ||
export function simpleSelectorToMarkedString(node) { | ||
var element = toElement(node); | ||
return new MarkedStringPrinter('"').print(element); | ||
var markedStrings = new MarkedStringPrinter('"').print(element); | ||
markedStrings.push(selectorToSpecificityMarkedString(node)); | ||
return markedStrings; | ||
} | ||
@@ -346,3 +396,3 @@ var SelectorElementBuilder = /** @class */ (function () { | ||
} | ||
else if (this.prev && (this.prev.matches('+') || this.prev.matches('~'))) { | ||
else if (this.prev && (this.prev.matches('+') || this.prev.matches('~')) && this.element.parent) { | ||
this.element = this.element.parent; | ||
@@ -349,0 +399,0 @@ } |
@@ -27,2 +27,22 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
export function includes(array, item) { | ||
return array.indexOf(item) !== -1; | ||
} | ||
export function union() { | ||
var arrays = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
arrays[_i] = arguments[_i]; | ||
} | ||
var result = []; | ||
for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) { | ||
var array = arrays_1[_a]; | ||
for (var _b = 0, array_1 = array; _b < array_1.length; _b++) { | ||
var item = array_1[_b]; | ||
if (!includes(result, item)) { | ||
result.push(item); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
//# sourceMappingURL=arrays.js.map |
@@ -82,2 +82,30 @@ /* -------------------------------------------------------------------------------------------- | ||
/** | ||
* The LocationLink namespace provides helper functions to work with | ||
* [LocationLink](#LocationLink) literals. | ||
*/ | ||
export var LocationLink; | ||
(function (LocationLink) { | ||
/** | ||
* Creates a LocationLink literal. | ||
* @param targetUri The definition's uri. | ||
* @param targetRange The full range of the definition. | ||
* @param targetSelectionRange The span of the symbol definition at the target. | ||
* @param originSelectionRange The span of the symbol being defined in the originating source file. | ||
*/ | ||
function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) { | ||
return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange }; | ||
} | ||
LocationLink.create = create; | ||
/** | ||
* Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface. | ||
*/ | ||
function is(value) { | ||
var candidate = value; | ||
return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) | ||
&& (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange)) | ||
&& (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange)); | ||
} | ||
LocationLink.is = is; | ||
})(LocationLink || (LocationLink = {})); | ||
/** | ||
* The Color namespace provides helper functions to work with | ||
@@ -400,2 +428,66 @@ * [Color](#Color) literals. | ||
})(TextDocumentEdit || (TextDocumentEdit = {})); | ||
export var CreateFile; | ||
(function (CreateFile) { | ||
function create(uri, options) { | ||
var result = { | ||
kind: 'create', | ||
uri: uri | ||
}; | ||
if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) { | ||
result.options = options; | ||
} | ||
return result; | ||
} | ||
CreateFile.create = create; | ||
function is(value) { | ||
var candidate = value; | ||
return candidate && candidate.kind === 'create' && Is.string(candidate.uri) && | ||
(candidate.options === void 0 || | ||
((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists)))); | ||
} | ||
CreateFile.is = is; | ||
})(CreateFile || (CreateFile = {})); | ||
export var RenameFile; | ||
(function (RenameFile) { | ||
function create(oldUri, newUri, options) { | ||
var result = { | ||
kind: 'rename', | ||
oldUri: oldUri, | ||
newUri: newUri | ||
}; | ||
if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) { | ||
result.options = options; | ||
} | ||
return result; | ||
} | ||
RenameFile.create = create; | ||
function is(value) { | ||
var candidate = value; | ||
return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && | ||
(candidate.options === void 0 || | ||
((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists)))); | ||
} | ||
RenameFile.is = is; | ||
})(RenameFile || (RenameFile = {})); | ||
export var DeleteFile; | ||
(function (DeleteFile) { | ||
function create(uri, options) { | ||
var result = { | ||
kind: 'delete', | ||
uri: uri | ||
}; | ||
if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) { | ||
result.options = options; | ||
} | ||
return result; | ||
} | ||
DeleteFile.create = create; | ||
function is(value) { | ||
var candidate = value; | ||
return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) && | ||
(candidate.options === void 0 || | ||
((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists)))); | ||
} | ||
DeleteFile.is = is; | ||
})(DeleteFile || (DeleteFile = {})); | ||
export var WorkspaceEdit; | ||
@@ -407,3 +499,10 @@ (function (WorkspaceEdit) { | ||
(candidate.changes !== void 0 || candidate.documentChanges !== void 0) && | ||
(candidate.documentChanges === void 0 || Is.typedArray(candidate.documentChanges, TextDocumentEdit.is)); | ||
(candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) { | ||
if (Is.string(change.kind)) { | ||
return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change); | ||
} | ||
else { | ||
return TextDocumentEdit.is(change); | ||
} | ||
})); | ||
} | ||
@@ -446,5 +545,7 @@ WorkspaceEdit.is = is; | ||
if (workspaceEdit.documentChanges) { | ||
workspaceEdit.documentChanges.forEach(function (textDocumentEdit) { | ||
var textEditChange = new TextEditChangeImpl(textDocumentEdit.edits); | ||
_this._textEditChanges[textDocumentEdit.textDocument.uri] = textEditChange; | ||
workspaceEdit.documentChanges.forEach(function (change) { | ||
if (TextDocumentEdit.is(change)) { | ||
var textEditChange = new TextEditChangeImpl(change.edits); | ||
_this._textEditChanges[change.textDocument.uri] = textEditChange; | ||
} | ||
}); | ||
@@ -479,3 +580,3 @@ } | ||
if (!this._workspaceEdit.documentChanges) { | ||
throw new Error('Workspace edit is not configured for versioned document changes.'); | ||
throw new Error('Workspace edit is not configured for document changes.'); | ||
} | ||
@@ -515,2 +616,19 @@ var textDocument = key; | ||
}; | ||
WorkspaceChange.prototype.createFile = function (uri, options) { | ||
this.checkDocumentChanges(); | ||
this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options)); | ||
}; | ||
WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) { | ||
this.checkDocumentChanges(); | ||
this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options)); | ||
}; | ||
WorkspaceChange.prototype.deleteFile = function (uri, options) { | ||
this.checkDocumentChanges(); | ||
this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options)); | ||
}; | ||
WorkspaceChange.prototype.checkDocumentChanges = function () { | ||
if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) { | ||
throw new Error('Workspace edit is not configured for document changes.'); | ||
} | ||
}; | ||
return WorkspaceChange; | ||
@@ -562,3 +680,3 @@ }()); | ||
var candidate = value; | ||
return Is.defined(candidate) && Is.string(candidate.uri) && Is.number(candidate.version); | ||
return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version)); | ||
} | ||
@@ -744,3 +862,3 @@ VersionedTextDocumentIdentifier.is = is; | ||
var candidate = value; | ||
return Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || | ||
return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || | ||
MarkedString.is(candidate.contents) || | ||
@@ -930,4 +1048,5 @@ Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range)); | ||
return candidate && | ||
Is.string(candidate.name) && Is.string(candidate.detail) && Is.number(candidate.kind) && | ||
Is.string(candidate.name) && Is.number(candidate.kind) && | ||
Range.is(candidate.range) && Range.is(candidate.selectionRange) && | ||
(candidate.detail === void 0 || Is.string(candidate.detail)) && | ||
(candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && | ||
@@ -1169,3 +1288,3 @@ (candidate.children === void 0 || Array.isArray(candidate.children)); | ||
else { | ||
throw new Error('Ovelapping edit'); | ||
throw new Error('Overlapping edit'); | ||
} | ||
@@ -1172,0 +1291,0 @@ lastModifiedOffset = startOffset; |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -6,3 +6,2 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
var Promise = monaco.Promise; | ||
import * as cssService from './_deps/vscode-css-languageservice/cssLanguageService'; | ||
@@ -36,5 +35,5 @@ import * as ls from './_deps/vscode-languageserver-types/main'; | ||
var diagnostics = this._languageService.doValidation(document, stylesheet); | ||
return Promise.as(diagnostics); | ||
return Promise.resolve(diagnostics); | ||
} | ||
return Promise.as([]); | ||
return Promise.resolve([]); | ||
}; | ||
@@ -45,3 +44,3 @@ CSSWorker.prototype.doComplete = function (uri, position) { | ||
var completions = this._languageService.doComplete(document, position, stylesheet); | ||
return Promise.as(completions); | ||
return Promise.resolve(completions); | ||
}; | ||
@@ -52,3 +51,3 @@ CSSWorker.prototype.doHover = function (uri, position) { | ||
var hover = this._languageService.doHover(document, position, stylesheet); | ||
return Promise.as(hover); | ||
return Promise.resolve(hover); | ||
}; | ||
@@ -59,3 +58,3 @@ CSSWorker.prototype.findDefinition = function (uri, position) { | ||
var definition = this._languageService.findDefinition(document, position, stylesheet); | ||
return Promise.as(definition); | ||
return Promise.resolve(definition); | ||
}; | ||
@@ -66,3 +65,3 @@ CSSWorker.prototype.findReferences = function (uri, position) { | ||
var references = this._languageService.findReferences(document, position, stylesheet); | ||
return Promise.as(references); | ||
return Promise.resolve(references); | ||
}; | ||
@@ -73,3 +72,3 @@ CSSWorker.prototype.findDocumentHighlights = function (uri, position) { | ||
var highlights = this._languageService.findDocumentHighlights(document, position, stylesheet); | ||
return Promise.as(highlights); | ||
return Promise.resolve(highlights); | ||
}; | ||
@@ -80,3 +79,3 @@ CSSWorker.prototype.findDocumentSymbols = function (uri) { | ||
var symbols = this._languageService.findDocumentSymbols(document, stylesheet); | ||
return Promise.as(symbols); | ||
return Promise.resolve(symbols); | ||
}; | ||
@@ -87,3 +86,3 @@ CSSWorker.prototype.doCodeActions = function (uri, range, context) { | ||
var actions = this._languageService.doCodeActions(document, range, context, stylesheet); | ||
return Promise.as(actions); | ||
return Promise.resolve(actions); | ||
}; | ||
@@ -94,3 +93,3 @@ CSSWorker.prototype.findDocumentColors = function (uri) { | ||
var colorSymbols = this._languageService.findDocumentColors(document, stylesheet); | ||
return Promise.as(colorSymbols); | ||
return Promise.resolve(colorSymbols); | ||
}; | ||
@@ -101,3 +100,3 @@ CSSWorker.prototype.getColorPresentations = function (uri, color, range) { | ||
var colorPresentations = this._languageService.getColorPresentations(document, stylesheet, color, range); | ||
return Promise.as(colorPresentations); | ||
return Promise.resolve(colorPresentations); | ||
}; | ||
@@ -107,3 +106,3 @@ CSSWorker.prototype.provideFoldingRanges = function (uri, context) { | ||
var ranges = this._languageService.getFoldingRanges(document, context); | ||
return Promise.as(ranges); | ||
return Promise.resolve(ranges); | ||
}; | ||
@@ -114,3 +113,3 @@ CSSWorker.prototype.doRename = function (uri, position, newName) { | ||
var renames = this._languageService.doRename(document, position, newName, stylesheet); | ||
return Promise.as(renames); | ||
return Promise.resolve(renames); | ||
}; | ||
@@ -117,0 +116,0 @@ CSSWorker.prototype._getTextDocument = function (uri) { |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -8,2 +8,3 @@ /*--------------------------------------------------------------------------------------------- | ||
var Uri = monaco.Uri; | ||
var Range = monaco.Range; | ||
// --- diagnostics --- --- | ||
@@ -168,3 +169,2 @@ var DiagnosticsAdapter = /** @class */ (function () { | ||
CompletionAdapter.prototype.provideCompletionItems = function (model, position, context, token) { | ||
var wordInfo = model.getWordUntilPosition(position); | ||
var resource = model.uri; | ||
@@ -177,2 +177,4 @@ return this._worker(resource).then(function (worker) { | ||
} | ||
var wordInfo = model.getWordUntilPosition(position); | ||
var wordRange = new Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn); | ||
var items = info.items.map(function (entry) { | ||
@@ -186,2 +188,3 @@ var item = { | ||
detail: entry.detail, | ||
range: wordRange, | ||
kind: toCompletionItemKind(entry.kind), | ||
@@ -188,0 +191,0 @@ }; |
@@ -79,3 +79,3 @@ /*--------------------------------------------------------------------------------------------- | ||
function getMode() { | ||
return monaco.Promise.wrap(import('./cssMode')); | ||
return import('./cssMode'); | ||
} | ||
@@ -82,0 +82,0 @@ monaco.languages.onLanguage('less', function () { |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
/*!----------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* monaco-css version: 2.3.0(a450f6054cbfb890c2ede882f6d2e47cc0e47f2f) | ||
* monaco-css version: 2.4.0(f94dca207a17e2fa88193f4c4eaf14358dbd4845) | ||
* Released under the MIT license | ||
* https://github.com/Microsoft/monaco-css/blob/master/LICENSE.md | ||
*-----------------------------------------------------------------------------*/ | ||
define("vs/language/css/workerManager",["require","exports"],function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=function(){function e(e){var n=this;this._defaults=e,this._worker=null,this._idleCheckInterval=setInterval(function(){return n._checkIfIdle()},3e4),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(function(){return n._stopWorker()})}return e.prototype._stopWorker=function(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null},e.prototype.dispose=function(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()},e.prototype._checkIfIdle=function(){this._worker&&(12e4<Date.now()-this._lastUsedTime&&this._stopWorker())},e.prototype._getClient=function(){return this._lastUsedTime=Date.now(),this._client||(this._worker=monaco.editor.createWebWorker({moduleId:"vs/language/css/cssWorker",label:this._defaults.languageId,createData:{languageSettings:this._defaults.diagnosticsOptions,languageId:this._defaults.languageId}}),this._client=this._worker.getProxy()),this._client},e.prototype.getLanguageServiceWorker=function(){for(var n,t=this,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return this._getClient().then(function(e){n=e}).then(function(e){return t._worker.withSyncedResources(r)}).then(function(e){return n})},e}();n.WorkerManager=t}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var n=e(require,exports);void 0!==n&&(module.exports=n)}else"function"==typeof define&&define.amd&&define("vscode-languageserver-types/main",["require","exports"],e)}(function(e,n){"use strict";var a,t,r,i,o,u,s,c,d,l,g,f,m,p,h,v,y,b,C,_,k,x,I,w;Object.defineProperty(n,"__esModule",{value:!0}),(t=a=n.Position||(n.Position={})).create=function(e,n){return{line:e,character:n}},t.is=function(e){var n=e;return Z.objectLiteral(n)&&Z.number(n.line)&&Z.number(n.character)},(i=r=n.Range||(n.Range={})).create=function(e,n,t,r){if(Z.number(e)&&Z.number(n)&&Z.number(t)&&Z.number(r))return{start:a.create(e,n),end:a.create(t,r)};if(a.is(e)&&a.is(n))return{start:e,end:n};throw new Error("Range#create called with invalid arguments["+e+", "+n+", "+t+", "+r+"]")},i.is=function(e){var n=e;return Z.objectLiteral(n)&&a.is(n.start)&&a.is(n.end)},(u=o=n.Location||(n.Location={})).create=function(e,n){return{uri:e,range:n}},u.is=function(e){var n=e;return Z.defined(n)&&r.is(n.range)&&(Z.string(n.uri)||Z.undefined(n.uri))},(c=s=n.Color||(n.Color={})).create=function(e,n,t,r){return{red:e,green:n,blue:t,alpha:r}},c.is=function(e){var n=e;return Z.number(n.red)&&Z.number(n.green)&&Z.number(n.blue)&&Z.number(n.alpha)},(d=n.ColorInformation||(n.ColorInformation={})).create=function(e,n){return{range:e,color:n}},d.is=function(e){var n=e;return r.is(n.range)&&s.is(n.color)},(l=n.ColorPresentation||(n.ColorPresentation={})).create=function(e,n,t){return{label:e,textEdit:n,additionalTextEdits:t}},l.is=function(e){var n=e;return Z.string(n.label)&&(Z.undefined(n.textEdit)||_.is(n))&&(Z.undefined(n.additionalTextEdits)||Z.typedArray(n.additionalTextEdits,_.is))},(g=n.FoldingRangeKind||(n.FoldingRangeKind={})).Comment="comment",g.Imports="imports",g.Region="region",(f=n.FoldingRange||(n.FoldingRange={})).create=function(e,n,t,r,i){var o={startLine:e,endLine:n};return Z.defined(t)&&(o.startCharacter=t),Z.defined(r)&&(o.endCharacter=r),Z.defined(i)&&(o.kind=i),o},f.is=function(e){var n=e;return Z.number(n.startLine)&&Z.number(n.startLine)&&(Z.undefined(n.startCharacter)||Z.number(n.startCharacter))&&(Z.undefined(n.endCharacter)||Z.number(n.endCharacter))&&(Z.undefined(n.kind)||Z.string(n.kind))},(p=m=n.DiagnosticRelatedInformation||(n.DiagnosticRelatedInformation={})).create=function(e,n){return{location:e,message:n}},p.is=function(e){var n=e;return Z.defined(n)&&o.is(n.location)&&Z.string(n.message)},(h=n.DiagnosticSeverity||(n.DiagnosticSeverity={})).Error=1,h.Warning=2,h.Information=3,h.Hint=4,(y=v=n.Diagnostic||(n.Diagnostic={})).create=function(e,n,t,r,i,o){var a={range:e,message:n};return Z.defined(t)&&(a.severity=t),Z.defined(r)&&(a.code=r),Z.defined(i)&&(a.source=i),Z.defined(o)&&(a.relatedInformation=o),a},y.is=function(e){var n=e;return Z.defined(n)&&r.is(n.range)&&Z.string(n.message)&&(Z.number(n.severity)||Z.undefined(n.severity))&&(Z.number(n.code)||Z.string(n.code)||Z.undefined(n.code))&&(Z.string(n.source)||Z.undefined(n.source))&&(Z.undefined(n.relatedInformation)||Z.typedArray(n.relatedInformation,m.is))},(C=b=n.Command||(n.Command={})).create=function(e,n){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var i={title:e,command:n};return Z.defined(t)&&0<t.length&&(i.arguments=t),i},C.is=function(e){var n=e;return Z.defined(n)&&Z.string(n.title)&&Z.string(n.command)},(k=_=n.TextEdit||(n.TextEdit={})).replace=function(e,n){return{range:e,newText:n}},k.insert=function(e,n){return{range:{start:e,end:e},newText:n}},k.del=function(e){return{range:e,newText:""}},k.is=function(e){var n=e;return Z.objectLiteral(n)&&Z.string(n.newText)&&r.is(n.range)},(I=x=n.TextDocumentEdit||(n.TextDocumentEdit={})).create=function(e,n){return{textDocument:e,edits:n}},I.is=function(e){var n=e;return Z.defined(n)&&D.is(n.textDocument)&&Array.isArray(n.edits)},(w=n.WorkspaceEdit||(n.WorkspaceEdit={})).is=function(e){var n=e;return n&&(void 0!==n.changes||void 0!==n.documentChanges)&&(void 0===n.documentChanges||Z.typedArray(n.documentChanges,x.is))};var S,D,K,E,T,A,M,R,F,P,L,O,j,H,W=function(){function e(e){this.edits=e}return e.prototype.insert=function(e,n){this.edits.push(_.insert(e,n))},e.prototype.replace=function(e,n){this.edits.push(_.replace(e,n))},e.prototype.delete=function(e){this.edits.push(_.del(e))},e.prototype.add=function(e){this.edits.push(e)},e.prototype.all=function(){return this.edits},e.prototype.clear=function(){this.edits.splice(0,this.edits.length)},e}(),N=function(){function e(t){var r=this;this._textEditChanges=Object.create(null),t&&((this._workspaceEdit=t).documentChanges?t.documentChanges.forEach(function(e){var n=new W(e.edits);r._textEditChanges[e.textDocument.uri]=n}):t.changes&&Object.keys(t.changes).forEach(function(e){var n=new W(t.changes[e]);r._textEditChanges[e]=n}))}return Object.defineProperty(e.prototype,"edit",{get:function(){return this._workspaceEdit},enumerable:!0,configurable:!0}),e.prototype.getTextEditChange=function(e){if(D.is(e)){if(this._workspaceEdit||(this._workspaceEdit={documentChanges:[]}),!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for versioned document changes.");var n=e;if(!(r=this._textEditChanges[n.uri])){var t={textDocument:n,edits:i=[]};this._workspaceEdit.documentChanges.push(t),r=new W(i),this._textEditChanges[n.uri]=r}return r}if(this._workspaceEdit||(this._workspaceEdit={changes:Object.create(null)}),!this._workspaceEdit.changes)throw new Error("Workspace edit is not configured for normal text edit changes.");var r;if(!(r=this._textEditChanges[e])){var i=[];this._workspaceEdit.changes[e]=i,r=new W(i),this._textEditChanges[e]=r}return r},e}();n.WorkspaceChange=N,(S=n.TextDocumentIdentifier||(n.TextDocumentIdentifier={})).create=function(e){return{uri:e}},S.is=function(e){var n=e;return Z.defined(n)&&Z.string(n.uri)},(K=D=n.VersionedTextDocumentIdentifier||(n.VersionedTextDocumentIdentifier={})).create=function(e,n){return{uri:e,version:n}},K.is=function(e){var n=e;return Z.defined(n)&&Z.string(n.uri)&&Z.number(n.version)},(E=n.TextDocumentItem||(n.TextDocumentItem={})).create=function(e,n,t,r){return{uri:e,languageId:n,version:t,text:r}},E.is=function(e){var n=e;return Z.defined(n)&&Z.string(n.uri)&&Z.string(n.languageId)&&Z.number(n.version)&&Z.string(n.text)},(A=T=n.MarkupKind||(n.MarkupKind={})).PlainText="plaintext",A.Markdown="markdown",(M=T=n.MarkupKind||(n.MarkupKind={})).is=function(e){var n=e;return n===M.PlainText||n===M.Markdown},(R=n.MarkupContent||(n.MarkupContent={})).is=function(e){var n=e;return Z.objectLiteral(e)&&T.is(n.kind)&&Z.string(n.value)},(F=n.CompletionItemKind||(n.CompletionItemKind={})).Text=1,F.Method=2,F.Function=3,F.Constructor=4,F.Field=5,F.Variable=6,F.Class=7,F.Interface=8,F.Module=9,F.Property=10,F.Unit=11,F.Value=12,F.Enum=13,F.Keyword=14,F.Snippet=15,F.Color=16,F.File=17,F.Reference=18,F.Folder=19,F.EnumMember=20,F.Constant=21,F.Struct=22,F.Event=23,F.Operator=24,F.TypeParameter=25,(P=n.InsertTextFormat||(n.InsertTextFormat={})).PlainText=1,P.Snippet=2,(n.CompletionItem||(n.CompletionItem={})).create=function(e){return{label:e}},(n.CompletionList||(n.CompletionList={})).create=function(e,n){return{items:e||[],isIncomplete:!!n}},(O=L=n.MarkedString||(n.MarkedString={})).fromPlainText=function(e){return e.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")},O.is=function(e){var n=e;return Z.string(n)||Z.objectLiteral(n)&&Z.string(n.language)&&Z.string(n.value)},(n.Hover||(n.Hover={})).is=function(e){var n=e;return Z.objectLiteral(n)&&(R.is(n.contents)||L.is(n.contents)||Z.typedArray(n.contents,L.is))&&(void 0===e.range||r.is(e.range))},(n.ParameterInformation||(n.ParameterInformation={})).create=function(e,n){return n?{label:e,documentation:n}:{label:e}},(n.SignatureInformation||(n.SignatureInformation={})).create=function(e,n){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var i={label:e};return Z.defined(n)&&(i.documentation=n),Z.defined(t)?i.parameters=t:i.parameters=[],i},(j=n.DocumentHighlightKind||(n.DocumentHighlightKind={})).Text=1,j.Read=2,j.Write=3,(n.DocumentHighlight||(n.DocumentHighlight={})).create=function(e,n){var t={range:e};return Z.number(n)&&(t.kind=n),t},(H=n.SymbolKind||(n.SymbolKind={})).File=1,H.Module=2,H.Namespace=3,H.Package=4,H.Class=5,H.Method=6,H.Property=7,H.Field=8,H.Constructor=9,H.Enum=10,H.Interface=11,H.Function=12,H.Variable=13,H.Constant=14,H.String=15,H.Number=16,H.Boolean=17,H.Array=18,H.Object=19,H.Key=20,H.Null=21,H.EnumMember=22,H.Struct=23,H.Event=24,H.Operator=25,H.TypeParameter=26,(n.SymbolInformation||(n.SymbolInformation={})).create=function(e,n,t,r,i){var o={name:e,kind:n,location:{uri:r,range:t}};return i&&(o.containerName=i),o};var V,U,q,z,B,$,Q=function(){};n.DocumentSymbol=Q,(V=Q=n.DocumentSymbol||(n.DocumentSymbol={})).create=function(e,n,t,r,i,o){var a={name:e,detail:n,kind:t,range:r,selectionRange:i};return void 0!==o&&(a.children=o),a},V.is=function(e){var n=e;return n&&Z.string(n.name)&&Z.string(n.detail)&&Z.number(n.kind)&&r.is(n.range)&&r.is(n.selectionRange)&&(void 0===n.deprecated||Z.boolean(n.deprecated))&&(void 0===n.children||Array.isArray(n.children))},n.DocumentSymbol=Q,(U=n.CodeActionKind||(n.CodeActionKind={})).QuickFix="quickfix",U.Refactor="refactor",U.RefactorExtract="refactor.extract",U.RefactorInline="refactor.inline",U.RefactorRewrite="refactor.rewrite",U.Source="source",U.SourceOrganizeImports="source.organizeImports",(q=n.CodeActionContext||(n.CodeActionContext={})).create=function(e,n){var t={diagnostics:e};return null!=n&&(t.only=n),t},q.is=function(e){var n=e;return Z.defined(n)&&Z.typedArray(n.diagnostics,v.is)&&(void 0===n.only||Z.typedArray(n.only,Z.string))},(z=n.CodeAction||(n.CodeAction={})).create=function(e,n,t){var r={title:e};return b.is(n)?r.command=n:r.edit=n,void 0!==t&&(r.kind=t),r},z.is=function(e){var n=e;return n&&Z.string(n.title)&&(void 0===n.diagnostics||Z.typedArray(n.diagnostics,v.is))&&(void 0===n.kind||Z.string(n.kind))&&(void 0!==n.edit||void 0!==n.command)&&(void 0===n.command||b.is(n.command))&&(void 0===n.edit||w.is(n.edit))},(B=n.CodeLens||(n.CodeLens={})).create=function(e,n){var t={range:e};return Z.defined(n)&&(t.data=n),t},B.is=function(e){var n=e;return Z.defined(n)&&r.is(n.range)&&(Z.undefined(n.command)||b.is(n.command))},($=n.FormattingOptions||(n.FormattingOptions={})).create=function(e,n){return{tabSize:e,insertSpaces:n}},$.is=function(e){var n=e;return Z.defined(n)&&Z.number(n.tabSize)&&Z.boolean(n.insertSpaces)};var G,J,X,Y=function(){};n.DocumentLink=Y,(G=Y=n.DocumentLink||(n.DocumentLink={})).create=function(e,n,t){return{range:e,target:n,data:t}},G.is=function(e){var n=e;return Z.defined(n)&&r.is(n.range)&&(Z.undefined(n.target)||Z.string(n.target))},n.DocumentLink=Y,n.EOL=["\n","\r\n","\r"],(J=n.TextDocument||(n.TextDocument={})).create=function(e,n,t,r){return new te(e,n,t,r)},J.is=function(e){var n=e;return!!(Z.defined(n)&&Z.string(n.uri)&&(Z.undefined(n.languageId)||Z.string(n.languageId))&&Z.number(n.lineCount)&&Z.func(n.getText)&&Z.func(n.positionAt)&&Z.func(n.offsetAt))},J.applyEdits=function(e,n){for(var t=e.getText(),r=function e(n,t){if(n.length<=1)return n;var r=n.length/2|0,i=n.slice(0,r),o=n.slice(r);e(i,t),e(o,t);for(var a=0,u=0,s=0;a<i.length&&u<o.length;){var c=t(i[a],o[u]);n[s++]=c<=0?i[a++]:o[u++]}for(;a<i.length;)n[s++]=i[a++];for(;u<o.length;)n[s++]=o[u++];return n}(n,function(e,n){var t=e.range.start.line-n.range.start.line;return 0===t?e.range.start.character-n.range.start.character:t}),i=t.length,o=r.length-1;0<=o;o--){var a=r[o],u=e.offsetAt(a.range.start),s=e.offsetAt(a.range.end);if(!(s<=i))throw new Error("Ovelapping edit");t=t.substring(0,u)+a.newText+t.substring(s,t.length),i=u}return t},(X=n.TextDocumentSaveReason||(n.TextDocumentSaveReason={})).Manual=1,X.AfterDelay=2,X.FocusOut=3;var Z,ee,ne,te=function(){function e(e,n,t,r){this._uri=e,this._languageId=n,this._version=t,this._content=r,this._lineOffsets=null}return Object.defineProperty(e.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!0,configurable:!0}),e.prototype.getText=function(e){if(e){var n=this.offsetAt(e.start),t=this.offsetAt(e.end);return this._content.substring(n,t)}return this._content},e.prototype.update=function(e,n){this._content=e.text,this._version=n,this._lineOffsets=null},e.prototype.getLineOffsets=function(){if(null===this._lineOffsets){for(var e=[],n=this._content,t=!0,r=0;r<n.length;r++){t&&(e.push(r),t=!1);var i=n.charAt(r);t="\r"===i||"\n"===i,"\r"===i&&r+1<n.length&&"\n"===n.charAt(r+1)&&r++}t&&0<n.length&&e.push(n.length),this._lineOffsets=e}return this._lineOffsets},e.prototype.positionAt=function(e){e=Math.max(Math.min(e,this._content.length),0);var n=this.getLineOffsets(),t=0,r=n.length;if(0===r)return a.create(0,e);for(;t<r;){var i=Math.floor((t+r)/2);n[i]>e?r=i:t=i+1}var o=t-1;return a.create(o,e-n[o])},e.prototype.offsetAt=function(e){var n=this.getLineOffsets();if(e.line>=n.length)return this._content.length;if(e.line<0)return 0;var t=n[e.line],r=e.line+1<n.length?n[e.line+1]:this._content.length;return Math.max(Math.min(t+e.character,r),t)},Object.defineProperty(e.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!0,configurable:!0}),e}();ee=Z||(Z={}),ne=Object.prototype.toString,ee.defined=function(e){return void 0!==e},ee.undefined=function(e){return void 0===e},ee.boolean=function(e){return!0===e||!1===e},ee.string=function(e){return"[object String]"===ne.call(e)},ee.number=function(e){return"[object Number]"===ne.call(e)},ee.func=function(e){return"[object Function]"===ne.call(e)},ee.objectLiteral=function(e){return null!==e&&"object"==typeof e},ee.typedArray=function(e,n){return Array.isArray(e)&&e.every(n)}}),define("vscode-languageserver-types",["vscode-languageserver-types/main"],function(e){return e}),define("vs/language/css/languageFeatures",["require","exports","vscode-languageserver-types"],function(e,n,o){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var u=monaco.Uri,t=function(){function e(e,n,t){var r=this;this._languageId=e,this._worker=n,this._disposables=[],this._listener=Object.create(null);var i=function(e){var n,t=e.getModeId();t===r._languageId&&(r._listener[e.uri.toString()]=e.onDidChangeContent(function(){clearTimeout(n),n=setTimeout(function(){return r._doValidate(e.uri,t)},500)}),r._doValidate(e.uri,t))},o=function(e){monaco.editor.setModelMarkers(e,r._languageId,[]);var n=e.uri.toString(),t=r._listener[n];t&&(t.dispose(),delete r._listener[n])};this._disposables.push(monaco.editor.onDidCreateModel(i)),this._disposables.push(monaco.editor.onWillDisposeModel(o)),this._disposables.push(monaco.editor.onDidChangeModelLanguage(function(e){o(e.model),i(e.model)})),t.onDidChange(function(e){monaco.editor.getModels().forEach(function(e){e.getModeId()===r._languageId&&(o(e),i(e))})}),this._disposables.push({dispose:function(){for(var e in r._listener)r._listener[e].dispose()}}),monaco.editor.getModels().forEach(i)}return e.prototype.dispose=function(){this._disposables.forEach(function(e){return e&&e.dispose()}),this._disposables=[]},e.prototype._doValidate=function(r,i){this._worker(r).then(function(e){return e.doValidation(r.toString())}).then(function(e){var n=e.map(function(e){return t="number"==typeof(n=e).code?String(n.code):n.code,{severity:function(e){switch(e){case o.DiagnosticSeverity.Error:return monaco.MarkerSeverity.Error;case o.DiagnosticSeverity.Warning:return monaco.MarkerSeverity.Warning;case o.DiagnosticSeverity.Information:return monaco.MarkerSeverity.Info;case o.DiagnosticSeverity.Hint:return monaco.MarkerSeverity.Hint;default:return monaco.MarkerSeverity.Info}}(n.severity),startLineNumber:n.range.start.line+1,startColumn:n.range.start.character+1,endLineNumber:n.range.end.line+1,endColumn:n.range.end.character+1,message:n.message,code:t,source:n.source};var n,t}),t=monaco.editor.getModel(r);t.getModeId()===i&&monaco.editor.setModelMarkers(t,i,n)}).then(void 0,function(e){console.error(e)})},e}();function a(e){if(e)return{character:e.column-1,line:e.lineNumber-1}}function s(e){if(e)return new monaco.Range(e.start.line+1,e.start.character+1,e.end.line+1,e.end.character+1)}function c(e){if(e)return{range:s(e.range),text:e.newText}}n.DiagnosticsAdapter=t;var r=function(){function e(e){this._worker=e}return Object.defineProperty(e.prototype,"triggerCharacters",{get:function(){return[" ",":"]},enumerable:!0,configurable:!0}),e.prototype.provideCompletionItems=function(e,n,t,r){e.getWordUntilPosition(n);var i=e.uri;return this._worker(i).then(function(e){return e.doComplete(i.toString(),a(n))}).then(function(e){if(e){var n=e.items.map(function(e){var n={label:e.label,insertText:e.insertText||e.label,sortText:e.sortText,filterText:e.filterText,documentation:e.documentation,detail:e.detail,kind:function(e){var n=monaco.languages.CompletionItemKind;switch(e){case o.CompletionItemKind.Text:return n.Text;case o.CompletionItemKind.Method:return n.Method;case o.CompletionItemKind.Function:return n.Function;case o.CompletionItemKind.Constructor:return n.Constructor;case o.CompletionItemKind.Field:return n.Field;case o.CompletionItemKind.Variable:return n.Variable;case o.CompletionItemKind.Class:return n.Class;case o.CompletionItemKind.Interface:return n.Interface;case o.CompletionItemKind.Module:return n.Module;case o.CompletionItemKind.Property:return n.Property;case o.CompletionItemKind.Unit:return n.Unit;case o.CompletionItemKind.Value:return n.Value;case o.CompletionItemKind.Enum:return n.Enum;case o.CompletionItemKind.Keyword:return n.Keyword;case o.CompletionItemKind.Snippet:return n.Snippet;case o.CompletionItemKind.Color:return n.Color;case o.CompletionItemKind.File:return n.File;case o.CompletionItemKind.Reference:return n.Reference}return n.Property}(e.kind)};return e.textEdit&&(n.range=s(e.textEdit.range),n.insertText=e.textEdit.newText),e.additionalTextEdits&&(n.additionalTextEdits=e.additionalTextEdits.map(c)),e.insertTextFormat===o.InsertTextFormat.Snippet&&(n.insertTextRules=monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet),n});return{isIncomplete:e.isIncomplete,suggestions:n}}})},e}();function i(e){return"string"==typeof e?{value:e}:(n=e)&&"object"==typeof n&&"string"==typeof n.kind?"plaintext"===e.kind?{value:e.value.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}:{value:e.value}:{value:"```"+e.language+"\n"+e.value+"\n```\n"};var n}n.CompletionAdapter=r;var d=function(){function e(e){this._worker=e}return e.prototype.provideHover=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.doHover(r.toString(),a(n))}).then(function(e){if(e)return{range:s(e.range),contents:function(e){if(e)return Array.isArray(e)?e.map(i):[i(e)]}(e.contents)}})},e}();n.HoverAdapter=d;var l=function(){function e(e){this._worker=e}return e.prototype.provideDocumentHighlights=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.findDocumentHighlights(r.toString(),a(n))}).then(function(e){if(e)return e.map(function(e){return{range:s(e.range),kind:function(e){switch(e){case o.DocumentHighlightKind.Read:return monaco.languages.DocumentHighlightKind.Read;case o.DocumentHighlightKind.Write:return monaco.languages.DocumentHighlightKind.Write;case o.DocumentHighlightKind.Text:return monaco.languages.DocumentHighlightKind.Text}return monaco.languages.DocumentHighlightKind.Text}(e.kind)}})})},e}();function g(e){return{uri:u.parse(e.uri),range:s(e.range)}}n.DocumentHighlightAdapter=l;var f=function(){function e(e){this._worker=e}return e.prototype.provideDefinition=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.findDefinition(r.toString(),a(n))}).then(function(e){if(e)return[g(e)]})},e}();n.DefinitionAdapter=f;var m=function(){function e(e){this._worker=e}return e.prototype.provideReferences=function(e,n,t,r){var i=e.uri;return this._worker(i).then(function(e){return e.findReferences(i.toString(),a(n))}).then(function(e){if(e)return e.map(g)})},e}();n.ReferenceAdapter=m;var p=function(){function e(e){this._worker=e}return e.prototype.provideRenameEdits=function(e,n,t,r){var i=e.uri;return this._worker(i).then(function(e){return e.doRename(i.toString(),a(n),t)}).then(function(e){return function(e){if(e&&e.changes){var n=[];for(var t in e.changes){for(var r=[],i=0,o=e.changes[t];i<o.length;i++){var a=o[i];r.push({range:s(a.range),text:a.newText})}n.push({resource:u.parse(t),edits:r})}return{edits:n}}}(e)})},e}();n.RenameAdapter=p;var h=function(){function e(e){this._worker=e}return e.prototype.provideDocumentSymbols=function(e,n){var t=e.uri;return this._worker(t).then(function(e){return e.findDocumentSymbols(t.toString())}).then(function(e){if(e)return e.map(function(e){return{name:e.name,detail:"",containerName:e.containerName,kind:function(e){var n=monaco.languages.SymbolKind;switch(e){case o.SymbolKind.File:return n.Array;case o.SymbolKind.Module:return n.Module;case o.SymbolKind.Namespace:return n.Namespace;case o.SymbolKind.Package:return n.Package;case o.SymbolKind.Class:return n.Class;case o.SymbolKind.Method:return n.Method;case o.SymbolKind.Property:return n.Property;case o.SymbolKind.Field:return n.Field;case o.SymbolKind.Constructor:return n.Constructor;case o.SymbolKind.Enum:return n.Enum;case o.SymbolKind.Interface:return n.Interface;case o.SymbolKind.Function:return n.Function;case o.SymbolKind.Variable:return n.Variable;case o.SymbolKind.Constant:return n.Constant;case o.SymbolKind.String:return n.String;case o.SymbolKind.Number:return n.Number;case o.SymbolKind.Boolean:return n.Boolean;case o.SymbolKind.Array:return n.Array}return n.Function}(e.kind),range:s(e.location.range),selectionRange:s(e.location.range)}})})},e}();n.DocumentSymbolAdapter=h;var v=function(){function e(e){this._worker=e}return e.prototype.provideDocumentColors=function(e,n){var t=e.uri;return this._worker(t).then(function(e){return e.findDocumentColors(t.toString())}).then(function(e){if(e)return e.map(function(e){return{color:e.color,range:s(e.range)}})})},e.prototype.provideColorPresentations=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.getColorPresentations(r.toString(),n.color,function(e){if(e)return{start:{line:e.startLineNumber-1,character:e.startColumn-1},end:{line:e.endLineNumber-1,character:e.endColumn-1}}}(n.range))}).then(function(e){if(e)return e.map(function(e){var n={label:e.label};return e.textEdit&&(n.textEdit=c(e.textEdit)),e.additionalTextEdits&&(n.additionalTextEdits=e.additionalTextEdits.map(c)),n})})},e}();n.DocumentColorAdapter=v;var y=function(){function e(e){this._worker=e}return e.prototype.provideFoldingRanges=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.provideFoldingRanges(r.toString(),n)}).then(function(e){if(e)return e.map(function(e){var n={start:e.startLine+1,end:e.endLine+1};return void 0!==e.kind&&(n.kind=function(e){switch(e){case o.FoldingRangeKind.Comment:return monaco.languages.FoldingRangeKind.Comment;case o.FoldingRangeKind.Imports:return monaco.languages.FoldingRangeKind.Imports;case o.FoldingRangeKind.Region:return monaco.languages.FoldingRangeKind.Region}return}(e.kind)),n})})},e}();n.FoldingRangeAdapter=y}),define("vs/language/css/cssMode",["require","exports","./workerManager","./languageFeatures"],function(e,n,i,o){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.setupMode=function(e){var r=new i.WorkerManager(e),n=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return r.getLanguageServiceWorker.apply(r,[e].concat(n))},t=e.languageId;monaco.languages.registerCompletionItemProvider(t,new o.CompletionAdapter(n)),monaco.languages.registerHoverProvider(t,new o.HoverAdapter(n)),monaco.languages.registerDocumentHighlightProvider(t,new o.DocumentHighlightAdapter(n)),monaco.languages.registerDefinitionProvider(t,new o.DefinitionAdapter(n)),monaco.languages.registerReferenceProvider(t,new o.ReferenceAdapter(n)),monaco.languages.registerDocumentSymbolProvider(t,new o.DocumentSymbolAdapter(n)),monaco.languages.registerRenameProvider(t,new o.RenameAdapter(n)),monaco.languages.registerColorProvider(t,new o.DocumentColorAdapter(n)),monaco.languages.registerFoldingRangeProvider(t,new o.FoldingRangeAdapter(n)),new o.DiagnosticsAdapter(t,n,e)}}); | ||
define("vs/language/css/workerManager",["require","exports"],function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=function(){function e(e){var n=this;this._defaults=e,this._worker=null,this._idleCheckInterval=setInterval(function(){return n._checkIfIdle()},3e4),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(function(){return n._stopWorker()})}return e.prototype._stopWorker=function(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null},e.prototype.dispose=function(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()},e.prototype._checkIfIdle=function(){this._worker&&(12e4<Date.now()-this._lastUsedTime&&this._stopWorker())},e.prototype._getClient=function(){return this._lastUsedTime=Date.now(),this._client||(this._worker=monaco.editor.createWebWorker({moduleId:"vs/language/css/cssWorker",label:this._defaults.languageId,createData:{languageSettings:this._defaults.diagnosticsOptions,languageId:this._defaults.languageId}}),this._client=this._worker.getProxy()),this._client},e.prototype.getLanguageServiceWorker=function(){for(var n,t=this,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return this._getClient().then(function(e){n=e}).then(function(e){return t._worker.withSyncedResources(r)}).then(function(e){return n})},e}();n.WorkerManager=t}),function(e){if("object"==typeof module&&"object"==typeof module.exports){var n=e(require,exports);void 0!==n&&(module.exports=n)}else"function"==typeof define&&define.amd&&define("vscode-languageserver-types/main",["require","exports"],e)}(function(e,n){"use strict";var a,t,r,i,o,u,s,c,d,l,g,f,m,p,h,v,y,b,C,k,_,x,w,I,S,D,E,K,T,R,M;Object.defineProperty(n,"__esModule",{value:!0}),(t=a=n.Position||(n.Position={})).create=function(e,n){return{line:e,character:n}},t.is=function(e){var n=e;return ae.objectLiteral(n)&&ae.number(n.line)&&ae.number(n.character)},(i=r=n.Range||(n.Range={})).create=function(e,n,t,r){if(ae.number(e)&&ae.number(n)&&ae.number(t)&&ae.number(r))return{start:a.create(e,n),end:a.create(t,r)};if(a.is(e)&&a.is(n))return{start:e,end:n};throw new Error("Range#create called with invalid arguments["+e+", "+n+", "+t+", "+r+"]")},i.is=function(e){var n=e;return ae.objectLiteral(n)&&a.is(n.start)&&a.is(n.end)},(u=o=n.Location||(n.Location={})).create=function(e,n){return{uri:e,range:n}},u.is=function(e){var n=e;return ae.defined(n)&&r.is(n.range)&&(ae.string(n.uri)||ae.undefined(n.uri))},(s=n.LocationLink||(n.LocationLink={})).create=function(e,n,t,r){return{targetUri:e,targetRange:n,targetSelectionRange:t,originSelectionRange:r}},s.is=function(e){var n=e;return ae.defined(n)&&r.is(n.targetRange)&&ae.string(n.targetUri)&&(r.is(n.targetSelectionRange)||ae.undefined(n.targetSelectionRange))&&(r.is(n.originSelectionRange)||ae.undefined(n.originSelectionRange))},(d=c=n.Color||(n.Color={})).create=function(e,n,t,r){return{red:e,green:n,blue:t,alpha:r}},d.is=function(e){var n=e;return ae.number(n.red)&&ae.number(n.green)&&ae.number(n.blue)&&ae.number(n.alpha)},(l=n.ColorInformation||(n.ColorInformation={})).create=function(e,n){return{range:e,color:n}},l.is=function(e){var n=e;return r.is(n.range)&&c.is(n.color)},(g=n.ColorPresentation||(n.ColorPresentation={})).create=function(e,n,t){return{label:e,textEdit:n,additionalTextEdits:t}},g.is=function(e){var n=e;return ae.string(n.label)&&(ae.undefined(n.textEdit)||_.is(n))&&(ae.undefined(n.additionalTextEdits)||ae.typedArray(n.additionalTextEdits,_.is))},(f=n.FoldingRangeKind||(n.FoldingRangeKind={})).Comment="comment",f.Imports="imports",f.Region="region",(m=n.FoldingRange||(n.FoldingRange={})).create=function(e,n,t,r,i){var o={startLine:e,endLine:n};return ae.defined(t)&&(o.startCharacter=t),ae.defined(r)&&(o.endCharacter=r),ae.defined(i)&&(o.kind=i),o},m.is=function(e){var n=e;return ae.number(n.startLine)&&ae.number(n.startLine)&&(ae.undefined(n.startCharacter)||ae.number(n.startCharacter))&&(ae.undefined(n.endCharacter)||ae.number(n.endCharacter))&&(ae.undefined(n.kind)||ae.string(n.kind))},(h=p=n.DiagnosticRelatedInformation||(n.DiagnosticRelatedInformation={})).create=function(e,n){return{location:e,message:n}},h.is=function(e){var n=e;return ae.defined(n)&&o.is(n.location)&&ae.string(n.message)},(v=n.DiagnosticSeverity||(n.DiagnosticSeverity={})).Error=1,v.Warning=2,v.Information=3,v.Hint=4,(b=y=n.Diagnostic||(n.Diagnostic={})).create=function(e,n,t,r,i,o){var a={range:e,message:n};return ae.defined(t)&&(a.severity=t),ae.defined(r)&&(a.code=r),ae.defined(i)&&(a.source=i),ae.defined(o)&&(a.relatedInformation=o),a},b.is=function(e){var n=e;return ae.defined(n)&&r.is(n.range)&&ae.string(n.message)&&(ae.number(n.severity)||ae.undefined(n.severity))&&(ae.number(n.code)||ae.string(n.code)||ae.undefined(n.code))&&(ae.string(n.source)||ae.undefined(n.source))&&(ae.undefined(n.relatedInformation)||ae.typedArray(n.relatedInformation,p.is))},(k=C=n.Command||(n.Command={})).create=function(e,n){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var i={title:e,command:n};return ae.defined(t)&&0<t.length&&(i.arguments=t),i},k.is=function(e){var n=e;return ae.defined(n)&&ae.string(n.title)&&ae.string(n.command)},(x=_=n.TextEdit||(n.TextEdit={})).replace=function(e,n){return{range:e,newText:n}},x.insert=function(e,n){return{range:{start:e,end:e},newText:n}},x.del=function(e){return{range:e,newText:""}},x.is=function(e){var n=e;return ae.objectLiteral(n)&&ae.string(n.newText)&&r.is(n.range)},(I=w=n.TextDocumentEdit||(n.TextDocumentEdit={})).create=function(e,n){return{textDocument:e,edits:n}},I.is=function(e){var n=e;return ae.defined(n)&&F.is(n.textDocument)&&Array.isArray(n.edits)},(D=S=n.CreateFile||(n.CreateFile={})).create=function(e,n){var t={kind:"create",uri:e};return void 0===n||void 0===n.overwrite&&void 0===n.ignoreIfExists||(t.options=n),t},D.is=function(e){var n=e;return n&&"create"===n.kind&&ae.string(n.uri)&&(void 0===n.options||(void 0===n.options.overwrite||ae.boolean(n.options.overwrite))&&(void 0===n.options.ignoreIfExists||ae.boolean(n.options.ignoreIfExists)))},(K=E=n.RenameFile||(n.RenameFile={})).create=function(e,n,t){var r={kind:"rename",oldUri:e,newUri:n};return void 0===t||void 0===t.overwrite&&void 0===t.ignoreIfExists||(r.options=t),r},K.is=function(e){var n=e;return n&&"rename"===n.kind&&ae.string(n.oldUri)&&ae.string(n.newUri)&&(void 0===n.options||(void 0===n.options.overwrite||ae.boolean(n.options.overwrite))&&(void 0===n.options.ignoreIfExists||ae.boolean(n.options.ignoreIfExists)))},(R=T=n.DeleteFile||(n.DeleteFile={})).create=function(e,n){var t={kind:"delete",uri:e};return void 0===n||void 0===n.recursive&&void 0===n.ignoreIfNotExists||(t.options=n),t},R.is=function(e){var n=e;return n&&"delete"===n.kind&&ae.string(n.uri)&&(void 0===n.options||(void 0===n.options.recursive||ae.boolean(n.options.recursive))&&(void 0===n.options.ignoreIfNotExists||ae.boolean(n.options.ignoreIfNotExists)))},(M=n.WorkspaceEdit||(n.WorkspaceEdit={})).is=function(e){var n=e;return n&&(void 0!==n.changes||void 0!==n.documentChanges)&&(void 0===n.documentChanges||n.documentChanges.every(function(e){return ae.string(e.kind)?S.is(e)||E.is(e)||T.is(e):w.is(e)}))};var A,F,P,L,O,j,H,W,N,V,U,q,z,B,$=function(){function e(e){this.edits=e}return e.prototype.insert=function(e,n){this.edits.push(_.insert(e,n))},e.prototype.replace=function(e,n){this.edits.push(_.replace(e,n))},e.prototype.delete=function(e){this.edits.push(_.del(e))},e.prototype.add=function(e){this.edits.push(e)},e.prototype.all=function(){return this.edits},e.prototype.clear=function(){this.edits.splice(0,this.edits.length)},e}(),Q=function(){function e(t){var r=this;this._textEditChanges=Object.create(null),t&&((this._workspaceEdit=t).documentChanges?t.documentChanges.forEach(function(e){if(w.is(e)){var n=new $(e.edits);r._textEditChanges[e.textDocument.uri]=n}}):t.changes&&Object.keys(t.changes).forEach(function(e){var n=new $(t.changes[e]);r._textEditChanges[e]=n}))}return Object.defineProperty(e.prototype,"edit",{get:function(){return this._workspaceEdit},enumerable:!0,configurable:!0}),e.prototype.getTextEditChange=function(e){if(F.is(e)){if(this._workspaceEdit||(this._workspaceEdit={documentChanges:[]}),!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for document changes.");var n=e;if(!(r=this._textEditChanges[n.uri])){var t={textDocument:n,edits:i=[]};this._workspaceEdit.documentChanges.push(t),r=new $(i),this._textEditChanges[n.uri]=r}return r}if(this._workspaceEdit||(this._workspaceEdit={changes:Object.create(null)}),!this._workspaceEdit.changes)throw new Error("Workspace edit is not configured for normal text edit changes.");var r;if(!(r=this._textEditChanges[e])){var i=[];this._workspaceEdit.changes[e]=i,r=new $(i),this._textEditChanges[e]=r}return r},e.prototype.createFile=function(e,n){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(S.create(e,n))},e.prototype.renameFile=function(e,n,t){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(E.create(e,n,t))},e.prototype.deleteFile=function(e,n){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(T.create(e,n))},e.prototype.checkDocumentChanges=function(){if(!this._workspaceEdit||!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for document changes.")},e}();n.WorkspaceChange=Q,(A=n.TextDocumentIdentifier||(n.TextDocumentIdentifier={})).create=function(e){return{uri:e}},A.is=function(e){var n=e;return ae.defined(n)&&ae.string(n.uri)},(P=F=n.VersionedTextDocumentIdentifier||(n.VersionedTextDocumentIdentifier={})).create=function(e,n){return{uri:e,version:n}},P.is=function(e){var n=e;return ae.defined(n)&&ae.string(n.uri)&&(null===n.version||ae.number(n.version))},(L=n.TextDocumentItem||(n.TextDocumentItem={})).create=function(e,n,t,r){return{uri:e,languageId:n,version:t,text:r}},L.is=function(e){var n=e;return ae.defined(n)&&ae.string(n.uri)&&ae.string(n.languageId)&&ae.number(n.version)&&ae.string(n.text)},(j=O=n.MarkupKind||(n.MarkupKind={})).PlainText="plaintext",j.Markdown="markdown",(H=O=n.MarkupKind||(n.MarkupKind={})).is=function(e){var n=e;return n===H.PlainText||n===H.Markdown},(W=n.MarkupContent||(n.MarkupContent={})).is=function(e){var n=e;return ae.objectLiteral(e)&&O.is(n.kind)&&ae.string(n.value)},(N=n.CompletionItemKind||(n.CompletionItemKind={})).Text=1,N.Method=2,N.Function=3,N.Constructor=4,N.Field=5,N.Variable=6,N.Class=7,N.Interface=8,N.Module=9,N.Property=10,N.Unit=11,N.Value=12,N.Enum=13,N.Keyword=14,N.Snippet=15,N.Color=16,N.File=17,N.Reference=18,N.Folder=19,N.EnumMember=20,N.Constant=21,N.Struct=22,N.Event=23,N.Operator=24,N.TypeParameter=25,(V=n.InsertTextFormat||(n.InsertTextFormat={})).PlainText=1,V.Snippet=2,(n.CompletionItem||(n.CompletionItem={})).create=function(e){return{label:e}},(n.CompletionList||(n.CompletionList={})).create=function(e,n){return{items:e||[],isIncomplete:!!n}},(q=U=n.MarkedString||(n.MarkedString={})).fromPlainText=function(e){return e.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")},q.is=function(e){var n=e;return ae.string(n)||ae.objectLiteral(n)&&ae.string(n.language)&&ae.string(n.value)},(n.Hover||(n.Hover={})).is=function(e){var n=e;return!!n&&ae.objectLiteral(n)&&(W.is(n.contents)||U.is(n.contents)||ae.typedArray(n.contents,U.is))&&(void 0===e.range||r.is(e.range))},(n.ParameterInformation||(n.ParameterInformation={})).create=function(e,n){return n?{label:e,documentation:n}:{label:e}},(n.SignatureInformation||(n.SignatureInformation={})).create=function(e,n){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var i={label:e};return ae.defined(n)&&(i.documentation=n),ae.defined(t)?i.parameters=t:i.parameters=[],i},(z=n.DocumentHighlightKind||(n.DocumentHighlightKind={})).Text=1,z.Read=2,z.Write=3,(n.DocumentHighlight||(n.DocumentHighlight={})).create=function(e,n){var t={range:e};return ae.number(n)&&(t.kind=n),t},(B=n.SymbolKind||(n.SymbolKind={})).File=1,B.Module=2,B.Namespace=3,B.Package=4,B.Class=5,B.Method=6,B.Property=7,B.Field=8,B.Constructor=9,B.Enum=10,B.Interface=11,B.Function=12,B.Variable=13,B.Constant=14,B.String=15,B.Number=16,B.Boolean=17,B.Array=18,B.Object=19,B.Key=20,B.Null=21,B.EnumMember=22,B.Struct=23,B.Event=24,B.Operator=25,B.TypeParameter=26,(n.SymbolInformation||(n.SymbolInformation={})).create=function(e,n,t,r,i){var o={name:e,kind:n,location:{uri:r,range:t}};return i&&(o.containerName=i),o};var G,J,X,Y,Z,ee,ne=function(){};n.DocumentSymbol=ne,(G=ne=n.DocumentSymbol||(n.DocumentSymbol={})).create=function(e,n,t,r,i,o){var a={name:e,detail:n,kind:t,range:r,selectionRange:i};return void 0!==o&&(a.children=o),a},G.is=function(e){var n=e;return n&&ae.string(n.name)&&ae.number(n.kind)&&r.is(n.range)&&r.is(n.selectionRange)&&(void 0===n.detail||ae.string(n.detail))&&(void 0===n.deprecated||ae.boolean(n.deprecated))&&(void 0===n.children||Array.isArray(n.children))},n.DocumentSymbol=ne,(J=n.CodeActionKind||(n.CodeActionKind={})).QuickFix="quickfix",J.Refactor="refactor",J.RefactorExtract="refactor.extract",J.RefactorInline="refactor.inline",J.RefactorRewrite="refactor.rewrite",J.Source="source",J.SourceOrganizeImports="source.organizeImports",(X=n.CodeActionContext||(n.CodeActionContext={})).create=function(e,n){var t={diagnostics:e};return null!=n&&(t.only=n),t},X.is=function(e){var n=e;return ae.defined(n)&&ae.typedArray(n.diagnostics,y.is)&&(void 0===n.only||ae.typedArray(n.only,ae.string))},(Y=n.CodeAction||(n.CodeAction={})).create=function(e,n,t){var r={title:e};return C.is(n)?r.command=n:r.edit=n,void 0!==t&&(r.kind=t),r},Y.is=function(e){var n=e;return n&&ae.string(n.title)&&(void 0===n.diagnostics||ae.typedArray(n.diagnostics,y.is))&&(void 0===n.kind||ae.string(n.kind))&&(void 0!==n.edit||void 0!==n.command)&&(void 0===n.command||C.is(n.command))&&(void 0===n.edit||M.is(n.edit))},(Z=n.CodeLens||(n.CodeLens={})).create=function(e,n){var t={range:e};return ae.defined(n)&&(t.data=n),t},Z.is=function(e){var n=e;return ae.defined(n)&&r.is(n.range)&&(ae.undefined(n.command)||C.is(n.command))},(ee=n.FormattingOptions||(n.FormattingOptions={})).create=function(e,n){return{tabSize:e,insertSpaces:n}},ee.is=function(e){var n=e;return ae.defined(n)&&ae.number(n.tabSize)&&ae.boolean(n.insertSpaces)};var te,re,ie,oe=function(){};n.DocumentLink=oe,(te=oe=n.DocumentLink||(n.DocumentLink={})).create=function(e,n,t){return{range:e,target:n,data:t}},te.is=function(e){var n=e;return ae.defined(n)&&r.is(n.range)&&(ae.undefined(n.target)||ae.string(n.target))},n.DocumentLink=oe,n.EOL=["\n","\r\n","\r"],(re=n.TextDocument||(n.TextDocument={})).create=function(e,n,t,r){return new ce(e,n,t,r)},re.is=function(e){var n=e;return!!(ae.defined(n)&&ae.string(n.uri)&&(ae.undefined(n.languageId)||ae.string(n.languageId))&&ae.number(n.lineCount)&&ae.func(n.getText)&&ae.func(n.positionAt)&&ae.func(n.offsetAt))},re.applyEdits=function(e,n){for(var t=e.getText(),r=function e(n,t){if(n.length<=1)return n;var r=n.length/2|0,i=n.slice(0,r),o=n.slice(r);e(i,t),e(o,t);for(var a=0,u=0,s=0;a<i.length&&u<o.length;){var c=t(i[a],o[u]);n[s++]=c<=0?i[a++]:o[u++]}for(;a<i.length;)n[s++]=i[a++];for(;u<o.length;)n[s++]=o[u++];return n}(n,function(e,n){var t=e.range.start.line-n.range.start.line;return 0===t?e.range.start.character-n.range.start.character:t}),i=t.length,o=r.length-1;0<=o;o--){var a=r[o],u=e.offsetAt(a.range.start),s=e.offsetAt(a.range.end);if(!(s<=i))throw new Error("Overlapping edit");t=t.substring(0,u)+a.newText+t.substring(s,t.length),i=u}return t},(ie=n.TextDocumentSaveReason||(n.TextDocumentSaveReason={})).Manual=1,ie.AfterDelay=2,ie.FocusOut=3;var ae,ue,se,ce=function(){function e(e,n,t,r){this._uri=e,this._languageId=n,this._version=t,this._content=r,this._lineOffsets=null}return Object.defineProperty(e.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!0,configurable:!0}),e.prototype.getText=function(e){if(e){var n=this.offsetAt(e.start),t=this.offsetAt(e.end);return this._content.substring(n,t)}return this._content},e.prototype.update=function(e,n){this._content=e.text,this._version=n,this._lineOffsets=null},e.prototype.getLineOffsets=function(){if(null===this._lineOffsets){for(var e=[],n=this._content,t=!0,r=0;r<n.length;r++){t&&(e.push(r),t=!1);var i=n.charAt(r);t="\r"===i||"\n"===i,"\r"===i&&r+1<n.length&&"\n"===n.charAt(r+1)&&r++}t&&0<n.length&&e.push(n.length),this._lineOffsets=e}return this._lineOffsets},e.prototype.positionAt=function(e){e=Math.max(Math.min(e,this._content.length),0);var n=this.getLineOffsets(),t=0,r=n.length;if(0===r)return a.create(0,e);for(;t<r;){var i=Math.floor((t+r)/2);n[i]>e?r=i:t=i+1}var o=t-1;return a.create(o,e-n[o])},e.prototype.offsetAt=function(e){var n=this.getLineOffsets();if(e.line>=n.length)return this._content.length;if(e.line<0)return 0;var t=n[e.line],r=e.line+1<n.length?n[e.line+1]:this._content.length;return Math.max(Math.min(t+e.character,r),t)},Object.defineProperty(e.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!0,configurable:!0}),e}();ue=ae||(ae={}),se=Object.prototype.toString,ue.defined=function(e){return void 0!==e},ue.undefined=function(e){return void 0===e},ue.boolean=function(e){return!0===e||!1===e},ue.string=function(e){return"[object String]"===se.call(e)},ue.number=function(e){return"[object Number]"===se.call(e)},ue.func=function(e){return"[object Function]"===se.call(e)},ue.objectLiteral=function(e){return null!==e&&"object"==typeof e},ue.typedArray=function(e,n){return Array.isArray(e)&&e.every(n)}}),define("vscode-languageserver-types",["vscode-languageserver-types/main"],function(e){return e}),define("vs/language/css/languageFeatures",["require","exports","vscode-languageserver-types"],function(e,n,a){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var u=monaco.Uri,s=monaco.Range,t=function(){function e(e,n,t){var r=this;this._languageId=e,this._worker=n,this._disposables=[],this._listener=Object.create(null);var i=function(e){var n,t=e.getModeId();t===r._languageId&&(r._listener[e.uri.toString()]=e.onDidChangeContent(function(){clearTimeout(n),n=setTimeout(function(){return r._doValidate(e.uri,t)},500)}),r._doValidate(e.uri,t))},o=function(e){monaco.editor.setModelMarkers(e,r._languageId,[]);var n=e.uri.toString(),t=r._listener[n];t&&(t.dispose(),delete r._listener[n])};this._disposables.push(monaco.editor.onDidCreateModel(i)),this._disposables.push(monaco.editor.onWillDisposeModel(o)),this._disposables.push(monaco.editor.onDidChangeModelLanguage(function(e){o(e.model),i(e.model)})),t.onDidChange(function(e){monaco.editor.getModels().forEach(function(e){e.getModeId()===r._languageId&&(o(e),i(e))})}),this._disposables.push({dispose:function(){for(var e in r._listener)r._listener[e].dispose()}}),monaco.editor.getModels().forEach(i)}return e.prototype.dispose=function(){this._disposables.forEach(function(e){return e&&e.dispose()}),this._disposables=[]},e.prototype._doValidate=function(r,i){this._worker(r).then(function(e){return e.doValidation(r.toString())}).then(function(e){var n=e.map(function(e){return t="number"==typeof(n=e).code?String(n.code):n.code,{severity:function(e){switch(e){case a.DiagnosticSeverity.Error:return monaco.MarkerSeverity.Error;case a.DiagnosticSeverity.Warning:return monaco.MarkerSeverity.Warning;case a.DiagnosticSeverity.Information:return monaco.MarkerSeverity.Info;case a.DiagnosticSeverity.Hint:return monaco.MarkerSeverity.Hint;default:return monaco.MarkerSeverity.Info}}(n.severity),startLineNumber:n.range.start.line+1,startColumn:n.range.start.character+1,endLineNumber:n.range.end.line+1,endColumn:n.range.end.character+1,message:n.message,code:t,source:n.source};var n,t}),t=monaco.editor.getModel(r);t.getModeId()===i&&monaco.editor.setModelMarkers(t,i,n)}).then(void 0,function(e){console.error(e)})},e}();function c(e){if(e)return{character:e.column-1,line:e.lineNumber-1}}function d(e){if(e)return new monaco.Range(e.start.line+1,e.start.character+1,e.end.line+1,e.end.character+1)}function l(e){if(e)return{range:d(e.range),text:e.newText}}n.DiagnosticsAdapter=t;var r=function(){function e(e){this._worker=e}return Object.defineProperty(e.prototype,"triggerCharacters",{get:function(){return[" ",":"]},enumerable:!0,configurable:!0}),e.prototype.provideCompletionItems=function(i,o,e,n){var t=i.uri;return this._worker(t).then(function(e){return e.doComplete(t.toString(),c(o))}).then(function(e){if(e){var n=i.getWordUntilPosition(o),t=new s(o.lineNumber,n.startColumn,o.lineNumber,n.endColumn),r=e.items.map(function(e){var n={label:e.label,insertText:e.insertText||e.label,sortText:e.sortText,filterText:e.filterText,documentation:e.documentation,detail:e.detail,range:t,kind:function(e){var n=monaco.languages.CompletionItemKind;switch(e){case a.CompletionItemKind.Text:return n.Text;case a.CompletionItemKind.Method:return n.Method;case a.CompletionItemKind.Function:return n.Function;case a.CompletionItemKind.Constructor:return n.Constructor;case a.CompletionItemKind.Field:return n.Field;case a.CompletionItemKind.Variable:return n.Variable;case a.CompletionItemKind.Class:return n.Class;case a.CompletionItemKind.Interface:return n.Interface;case a.CompletionItemKind.Module:return n.Module;case a.CompletionItemKind.Property:return n.Property;case a.CompletionItemKind.Unit:return n.Unit;case a.CompletionItemKind.Value:return n.Value;case a.CompletionItemKind.Enum:return n.Enum;case a.CompletionItemKind.Keyword:return n.Keyword;case a.CompletionItemKind.Snippet:return n.Snippet;case a.CompletionItemKind.Color:return n.Color;case a.CompletionItemKind.File:return n.File;case a.CompletionItemKind.Reference:return n.Reference}return n.Property}(e.kind)};return e.textEdit&&(n.range=d(e.textEdit.range),n.insertText=e.textEdit.newText),e.additionalTextEdits&&(n.additionalTextEdits=e.additionalTextEdits.map(l)),e.insertTextFormat===a.InsertTextFormat.Snippet&&(n.insertTextRules=monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet),n});return{isIncomplete:e.isIncomplete,suggestions:r}}})},e}();function i(e){return"string"==typeof e?{value:e}:(n=e)&&"object"==typeof n&&"string"==typeof n.kind?"plaintext"===e.kind?{value:e.value.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}:{value:e.value}:{value:"```"+e.language+"\n"+e.value+"\n```\n"};var n}n.CompletionAdapter=r;var o=function(){function e(e){this._worker=e}return e.prototype.provideHover=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.doHover(r.toString(),c(n))}).then(function(e){if(e)return{range:d(e.range),contents:function(e){if(e)return Array.isArray(e)?e.map(i):[i(e)]}(e.contents)}})},e}();n.HoverAdapter=o;var g=function(){function e(e){this._worker=e}return e.prototype.provideDocumentHighlights=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.findDocumentHighlights(r.toString(),c(n))}).then(function(e){if(e)return e.map(function(e){return{range:d(e.range),kind:function(e){switch(e){case a.DocumentHighlightKind.Read:return monaco.languages.DocumentHighlightKind.Read;case a.DocumentHighlightKind.Write:return monaco.languages.DocumentHighlightKind.Write;case a.DocumentHighlightKind.Text:return monaco.languages.DocumentHighlightKind.Text}return monaco.languages.DocumentHighlightKind.Text}(e.kind)}})})},e}();function f(e){return{uri:u.parse(e.uri),range:d(e.range)}}n.DocumentHighlightAdapter=g;var m=function(){function e(e){this._worker=e}return e.prototype.provideDefinition=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.findDefinition(r.toString(),c(n))}).then(function(e){if(e)return[f(e)]})},e}();n.DefinitionAdapter=m;var p=function(){function e(e){this._worker=e}return e.prototype.provideReferences=function(e,n,t,r){var i=e.uri;return this._worker(i).then(function(e){return e.findReferences(i.toString(),c(n))}).then(function(e){if(e)return e.map(f)})},e}();n.ReferenceAdapter=p;var h=function(){function e(e){this._worker=e}return e.prototype.provideRenameEdits=function(e,n,t,r){var i=e.uri;return this._worker(i).then(function(e){return e.doRename(i.toString(),c(n),t)}).then(function(e){return function(e){if(e&&e.changes){var n=[];for(var t in e.changes){for(var r=[],i=0,o=e.changes[t];i<o.length;i++){var a=o[i];r.push({range:d(a.range),text:a.newText})}n.push({resource:u.parse(t),edits:r})}return{edits:n}}}(e)})},e}();n.RenameAdapter=h;var v=function(){function e(e){this._worker=e}return e.prototype.provideDocumentSymbols=function(e,n){var t=e.uri;return this._worker(t).then(function(e){return e.findDocumentSymbols(t.toString())}).then(function(e){if(e)return e.map(function(e){return{name:e.name,detail:"",containerName:e.containerName,kind:function(e){var n=monaco.languages.SymbolKind;switch(e){case a.SymbolKind.File:return n.Array;case a.SymbolKind.Module:return n.Module;case a.SymbolKind.Namespace:return n.Namespace;case a.SymbolKind.Package:return n.Package;case a.SymbolKind.Class:return n.Class;case a.SymbolKind.Method:return n.Method;case a.SymbolKind.Property:return n.Property;case a.SymbolKind.Field:return n.Field;case a.SymbolKind.Constructor:return n.Constructor;case a.SymbolKind.Enum:return n.Enum;case a.SymbolKind.Interface:return n.Interface;case a.SymbolKind.Function:return n.Function;case a.SymbolKind.Variable:return n.Variable;case a.SymbolKind.Constant:return n.Constant;case a.SymbolKind.String:return n.String;case a.SymbolKind.Number:return n.Number;case a.SymbolKind.Boolean:return n.Boolean;case a.SymbolKind.Array:return n.Array}return n.Function}(e.kind),range:d(e.location.range),selectionRange:d(e.location.range)}})})},e}();n.DocumentSymbolAdapter=v;var y=function(){function e(e){this._worker=e}return e.prototype.provideDocumentColors=function(e,n){var t=e.uri;return this._worker(t).then(function(e){return e.findDocumentColors(t.toString())}).then(function(e){if(e)return e.map(function(e){return{color:e.color,range:d(e.range)}})})},e.prototype.provideColorPresentations=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.getColorPresentations(r.toString(),n.color,function(e){if(e)return{start:{line:e.startLineNumber-1,character:e.startColumn-1},end:{line:e.endLineNumber-1,character:e.endColumn-1}}}(n.range))}).then(function(e){if(e)return e.map(function(e){var n={label:e.label};return e.textEdit&&(n.textEdit=l(e.textEdit)),e.additionalTextEdits&&(n.additionalTextEdits=e.additionalTextEdits.map(l)),n})})},e}();n.DocumentColorAdapter=y;var b=function(){function e(e){this._worker=e}return e.prototype.provideFoldingRanges=function(e,n,t){var r=e.uri;return this._worker(r).then(function(e){return e.provideFoldingRanges(r.toString(),n)}).then(function(e){if(e)return e.map(function(e){var n={start:e.startLine+1,end:e.endLine+1};return void 0!==e.kind&&(n.kind=function(e){switch(e){case a.FoldingRangeKind.Comment:return monaco.languages.FoldingRangeKind.Comment;case a.FoldingRangeKind.Imports:return monaco.languages.FoldingRangeKind.Imports;case a.FoldingRangeKind.Region:return monaco.languages.FoldingRangeKind.Region}return}(e.kind)),n})})},e}();n.FoldingRangeAdapter=b}),define("vs/language/css/cssMode",["require","exports","./workerManager","./languageFeatures"],function(e,n,i,o){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.setupMode=function(e){var r=new i.WorkerManager(e),n=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return r.getLanguageServiceWorker.apply(r,[e].concat(n))},t=e.languageId;monaco.languages.registerCompletionItemProvider(t,new o.CompletionAdapter(n)),monaco.languages.registerHoverProvider(t,new o.HoverAdapter(n)),monaco.languages.registerDocumentHighlightProvider(t,new o.DocumentHighlightAdapter(n)),monaco.languages.registerDefinitionProvider(t,new o.DefinitionAdapter(n)),monaco.languages.registerReferenceProvider(t,new o.ReferenceAdapter(n)),monaco.languages.registerDocumentSymbolProvider(t,new o.DocumentSymbolAdapter(n)),monaco.languages.registerRenameProvider(t,new o.RenameAdapter(n)),monaco.languages.registerColorProvider(t,new o.DocumentColorAdapter(n)),monaco.languages.registerFoldingRangeProvider(t,new o.FoldingRangeAdapter(n)),new o.DiagnosticsAdapter(t,n,e)}}); |
/*!----------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* monaco-css version: 2.3.0(a450f6054cbfb890c2ede882f6d2e47cc0e47f2f) | ||
* monaco-css version: 2.4.0(f94dca207a17e2fa88193f4c4eaf14358dbd4845) | ||
* Released under the MIT license | ||
* https://github.com/Microsoft/monaco-css/blob/master/LICENSE.md | ||
*-----------------------------------------------------------------------------*/ | ||
define("vs/language/css/monaco.contribution",["require","exports"],function(o,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=monaco.Emitter,n=function(){function e(e,n){this._onDidChange=new t,this._languageId=e,this.setDiagnosticsOptions(n)}return Object.defineProperty(e.prototype,"onDidChange",{get:function(){return this._onDidChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"diagnosticsOptions",{get:function(){return this._diagnosticsOptions},enumerable:!0,configurable:!0}),e.prototype.setDiagnosticsOptions=function(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)},e}(),i={validate:!0,lint:{compatibleVendorPrefixes:"ignore",vendorPrefix:"warning",duplicateProperties:"warning",emptyRules:"warning",importStatement:"ignore",boxModel:"ignore",universalSelector:"ignore",zeroUnits:"ignore",fontFaceProperties:"warning",hexColorLength:"error",argumentsInColorFunction:"error",unknownProperties:"warning",ieHack:"ignore",unknownVendorSpecificProperties:"ignore",propertyIgnoredDueToDisplay:"warning",important:"ignore",float:"ignore",idSelector:"ignore"}},r=new(e.LanguageServiceDefaultsImpl=n)("css",i),s=new n("scss",i),a=new n("less",i);function u(){return monaco.Promise.wrap(new Promise(function(e,n){o(["./cssMode"],e,n)}))}monaco.languages.css={cssDefaults:r,lessDefaults:a,scssDefaults:s},monaco.languages.onLanguage("less",function(){u().then(function(e){return e.setupMode(a)})}),monaco.languages.onLanguage("scss",function(){u().then(function(e){return e.setupMode(s)})}),monaco.languages.onLanguage("css",function(){u().then(function(e){return e.setupMode(r)})})}); | ||
define("vs/language/css/monaco.contribution",["require","exports"],function(o,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=monaco.Emitter,n=function(){function e(e,n){this._onDidChange=new t,this._languageId=e,this.setDiagnosticsOptions(n)}return Object.defineProperty(e.prototype,"onDidChange",{get:function(){return this._onDidChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"diagnosticsOptions",{get:function(){return this._diagnosticsOptions},enumerable:!0,configurable:!0}),e.prototype.setDiagnosticsOptions=function(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)},e}(),i={validate:!0,lint:{compatibleVendorPrefixes:"ignore",vendorPrefix:"warning",duplicateProperties:"warning",emptyRules:"warning",importStatement:"ignore",boxModel:"ignore",universalSelector:"ignore",zeroUnits:"ignore",fontFaceProperties:"warning",hexColorLength:"error",argumentsInColorFunction:"error",unknownProperties:"warning",ieHack:"ignore",unknownVendorSpecificProperties:"ignore",propertyIgnoredDueToDisplay:"warning",important:"ignore",float:"ignore",idSelector:"ignore"}},r=new(e.LanguageServiceDefaultsImpl=n)("css",i),s=new n("scss",i),a=new n("less",i);function u(){return new Promise(function(e,n){o(["./cssMode"],e,n)})}monaco.languages.css={cssDefaults:r,lessDefaults:a,scssDefaults:s},monaco.languages.onLanguage("less",function(){u().then(function(e){return e.setupMode(a)})}),monaco.languages.onLanguage("scss",function(){u().then(function(e){return e.setupMode(s)})}),monaco.languages.onLanguage("css",function(){u().then(function(e){return e.setupMode(r)})})}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
3163856
53
61025