vscode-css-languageservice
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -101,2 +101,4 @@ var __extends = (this && this.__extends) || (function () { | ||
NodeType[NodeType["SupportsCondition"] = 68] = "SupportsCondition"; | ||
NodeType[NodeType["NamespacePrefix"] = 69] = "NamespacePrefix"; | ||
NodeType[NodeType["GridLine"] = 70] = "GridLine"; | ||
})(NodeType = exports.NodeType || (exports.NodeType = {})); | ||
@@ -103,0 +105,0 @@ var ReferenceType; |
@@ -73,7 +73,8 @@ (function (factory) { | ||
var pos = this.mark(); | ||
if (!func()) { | ||
var node = func(); | ||
if (!node) { | ||
this.restoreAtMark(pos); | ||
return false; | ||
return null; | ||
} | ||
return true; | ||
return node; | ||
}; | ||
@@ -98,2 +99,9 @@ Parser.prototype.acceptOne = function (type, text, ignoreCase) { | ||
}; | ||
Parser.prototype.acceptDelim = function (text) { | ||
if (cssScanner_1.TokenType.Delim === this.token.type && text === this.token.text) { | ||
this.consumeToken(); | ||
return true; | ||
} | ||
return false; | ||
}; | ||
Parser.prototype.acceptUnquotedString = function () { | ||
@@ -512,3 +520,3 @@ var pos = this.scanner.pos(); | ||
var mark = this.mark(); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '*') || this.accept(cssScanner_1.TokenType.Delim, '_')) { | ||
if (this.acceptDelim('*') || this.acceptDelim('_')) { | ||
// support for IE 5.x, 6 and 7 star hack: see http://en.wikipedia.org/wiki/CSS_filter#Star_hack | ||
@@ -655,2 +663,8 @@ if (this.hasWhitespace()) { | ||
if (isNested === void 0) { isNested = false; } | ||
if (isNested) { | ||
// if nested, the body can contain rulesets, but also declarations | ||
return this._tryParseRuleset(isNested) | ||
|| this._tryToParseDeclaration() | ||
|| this._parseStylesheetStatement(); | ||
} | ||
return this._parseStylesheetStatement(); | ||
@@ -858,6 +872,6 @@ }; | ||
var node = this.createNode(nodes.NodeType.Operator); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '/') || | ||
this.accept(cssScanner_1.TokenType.Delim, '*') || | ||
this.accept(cssScanner_1.TokenType.Delim, '+') || | ||
this.accept(cssScanner_1.TokenType.Delim, '-') || | ||
if (this.acceptDelim('/') || | ||
this.acceptDelim('*') || | ||
this.acceptDelim('+') || | ||
this.acceptDelim('-') || | ||
this.accept(cssScanner_1.TokenType.Dashmatch) || | ||
@@ -868,3 +882,3 @@ this.accept(cssScanner_1.TokenType.Includes) || | ||
this.accept(cssScanner_1.TokenType.SuffixOperator) || | ||
this.accept(cssScanner_1.TokenType.Delim, '=')) { | ||
this.acceptDelim('=')) { | ||
return this.finish(node); | ||
@@ -878,3 +892,3 @@ } | ||
var node = this.create(nodes.Node); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '+') || this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
if (this.acceptDelim('+') || this.acceptDelim('-')) { | ||
return this.finish(node); | ||
@@ -888,6 +902,6 @@ } | ||
var node = this.create(nodes.Node); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '>')) { | ||
if (this.acceptDelim('>')) { | ||
var mark = this.mark(); | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Delim, '>')) { | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Delim, '>')) { | ||
if (!this.hasWhitespace() && this.acceptDelim('>')) { | ||
if (!this.hasWhitespace() && this.acceptDelim('>')) { | ||
node.type = nodes.NodeType.SelectorCombinatorShadowPiercingDescendant; | ||
@@ -901,13 +915,13 @@ return this.finish(node); | ||
} | ||
else if (this.accept(cssScanner_1.TokenType.Delim, '+')) { | ||
else if (this.acceptDelim('+')) { | ||
node.type = nodes.NodeType.SelectorCombinatorSibling; | ||
return this.finish(node); | ||
} | ||
else if (this.accept(cssScanner_1.TokenType.Delim, '~')) { | ||
else if (this.acceptDelim('~')) { | ||
node.type = nodes.NodeType.SelectorCombinatorAllSiblings; | ||
return this.finish(node); | ||
} | ||
else if (this.accept(cssScanner_1.TokenType.Delim, '/')) { | ||
else if (this.acceptDelim('/')) { | ||
var mark = this.mark(); | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Ident, 'deep') && !this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Delim, '/')) { | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Ident, 'deep') && !this.hasWhitespace() && this.acceptDelim('/')) { | ||
node.type = nodes.NodeType.SelectorCombinatorShadowPiercingDescendant; | ||
@@ -946,3 +960,3 @@ return this.finish(node); | ||
var node = this.createNode(nodes.NodeType.IdentifierSelector); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '#')) { | ||
if (this.acceptDelim('#')) { | ||
if (this.hasWhitespace() || !node.addChild(this._parseSelectorIdent())) { | ||
@@ -970,9 +984,24 @@ return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); | ||
Parser.prototype._parseElementName = function () { | ||
// element_name: IDENT | '*'; | ||
// element_name: (ns? '|')? IDENT | '*'; | ||
var pos = this.mark(); | ||
var node = this.createNode(nodes.NodeType.ElementNameSelector); | ||
if (node.addChild(this._parseSelectorIdent()) || this.accept(cssScanner_1.TokenType.Delim, '*')) { | ||
return this.finish(node); | ||
node.addChild(this._parseNamespacePrefix()); | ||
if (!node.addChild(this._parseSelectorIdent()) && !this.acceptDelim('*')) { | ||
this.restoreAtMark(pos); | ||
return null; | ||
} | ||
return null; | ||
return this.finish(node); | ||
}; | ||
Parser.prototype._parseNamespacePrefix = function () { | ||
var pos = this.mark(); | ||
var node = this.createNode(nodes.NodeType.NamespacePrefix); | ||
if (!node.addChild(this._parseIdent()) && !this.acceptDelim('*')) { | ||
// ns is optional | ||
} | ||
if (!this.acceptDelim('|')) { | ||
this.restoreAtMark(pos); | ||
return null; | ||
} | ||
return this.finish(node); | ||
}; | ||
Parser.prototype._parseAttrib = function () { | ||
@@ -986,6 +1015,3 @@ // attrib : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S* [ IDENT | STRING ] S* ]? ']' | ||
// Optional attrib namespace | ||
var pos = this.mark(); | ||
if (!this.accept(cssScanner_1.TokenType.Ident) || !this.accept(cssScanner_1.TokenType.Delim, '|')) { | ||
this.restoreAtMark(pos); | ||
} | ||
node.addChild(this._parseNamespacePrefix()); | ||
if (!node.addChild(this._parseBinaryExpr())) { | ||
@@ -1000,2 +1026,3 @@ // is this bad? | ||
Parser.prototype._parsePseudo = function () { | ||
var _this = this; | ||
// pseudo: ':' [ IDENT | FUNCTION S* [IDENT S*]? ')' ] | ||
@@ -1017,3 +1044,10 @@ if (!this.peek(cssScanner_1.TokenType.Colon)) { | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.ParenthesisL)) { | ||
node.addChild(this._parseBinaryExpr() || this._parseSimpleSelector()); | ||
var tryAsSelector = function () { | ||
var selector = _this._parseSimpleSelector(); | ||
if (selector && _this.peek(cssScanner_1.TokenType.ParenthesisR)) { | ||
return selector; | ||
} | ||
return null; | ||
}; | ||
node.addChild(this.try(tryAsSelector) || this._parseBinaryExpr()); | ||
if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { | ||
@@ -1041,3 +1075,3 @@ return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); | ||
var node = this.create(nodes.Expression); | ||
if (!node.addChild(this._parseBinaryExpr())) { | ||
if (!node.addChild(this._parseNamedLine() || this._parseBinaryExpr())) { | ||
return null; | ||
@@ -1052,3 +1086,3 @@ } | ||
} | ||
if (!node.addChild(this._parseBinaryExpr())) { | ||
if (!node.addChild(this._parseNamedLine() || this._parseBinaryExpr())) { | ||
break; | ||
@@ -1059,2 +1093,17 @@ } | ||
}; | ||
Parser.prototype._parseNamedLine = function () { | ||
// https://www.w3.org/TR/css-grid-1/#named-lines | ||
if (!this.peek(cssScanner_1.TokenType.BracketL)) { | ||
return null; | ||
} | ||
var node = this.createNode(nodes.NodeType.GridLine); | ||
this.consumeToken(); | ||
while (node.addChild(this._parseIdent())) { | ||
// repeat | ||
} | ||
if (!this.accept(cssScanner_1.TokenType.BracketR)) { | ||
return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected); | ||
} | ||
return this.finish(node); | ||
}; | ||
Parser.prototype._parseBinaryExpr = function (preparsedLeft, preparsedOper) { | ||
@@ -1134,7 +1183,10 @@ var node = this.create(nodes.BinaryExpression); | ||
this.accept(cssScanner_1.TokenType.Ident); | ||
if (this.hasWhitespace() || !this.accept(cssScanner_1.TokenType.ParenthesisL)) { | ||
if (this.hasWhitespace() || !this.peek(cssScanner_1.TokenType.ParenthesisL)) { | ||
this.restoreAtMark(pos); | ||
return null; | ||
} | ||
this.scanner.inURL = true; | ||
this.consumeToken(); // consume () | ||
node.addChild(this._parseURLArgument()); // argument is optional | ||
this.scanner.inURL = false; | ||
if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { | ||
@@ -1191,3 +1243,3 @@ return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); | ||
if (this.accept(cssScanner_1.TokenType.Colon)) { | ||
while (this.accept(cssScanner_1.TokenType.Ident) && this.accept(cssScanner_1.TokenType.Delim, '.')) { | ||
while (this.accept(cssScanner_1.TokenType.Ident) && this.acceptDelim('.')) { | ||
// loop | ||
@@ -1194,0 +1246,0 @@ } |
@@ -202,2 +202,3 @@ (function (factory) { | ||
this.ignoreWhitespace = true; | ||
this.inURL = false; | ||
} | ||
@@ -504,3 +505,3 @@ Scanner.prototype.setSource = function (input) { | ||
var ch = this.stream.peekChar(); | ||
if (ch !== 0 && ch !== _SQO && ch !== _DQO && ch !== _LPA && ch !== _RPA && ch !== _WSP && ch !== _TAB && ch !== _NWL && ch !== _LFD && ch !== _CAR) { | ||
if (ch !== 0 && ch !== _BSL && ch !== _SQO && ch !== _DQO && ch !== _LPA && ch !== _RPA && ch !== _WSP && ch !== _TAB && ch !== _NWL && ch !== _LFD && ch !== _CAR) { | ||
this.stream.advance(1); | ||
@@ -507,0 +508,0 @@ result.push(String.fromCharCode(ch)); |
@@ -130,3 +130,3 @@ var __extends = (this && this.__extends) || (function () { | ||
var mark = this.mark(); | ||
while (this.accept(cssScanner_1.TokenType.Delim, '@')) { | ||
while (this.acceptDelim('@')) { | ||
if (this.hasWhitespace()) { | ||
@@ -161,3 +161,3 @@ this.restoreAtMark(mark); | ||
} | ||
if (this.accept(cssScanner_1.TokenType.Delim, '~')) { | ||
if (this.acceptDelim('~')) { | ||
return this.finish(node, this.accept(cssScanner_1.TokenType.String) ? null : cssErrors_1.ParseError.TermExpected); | ||
@@ -178,12 +178,12 @@ } | ||
var node = this.createNode(nodes.NodeType.Operator); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '>')) { | ||
this.accept(cssScanner_1.TokenType.Delim, '='); | ||
if (this.acceptDelim('>')) { | ||
this.acceptDelim('='); | ||
return node; | ||
} | ||
else if (this.accept(cssScanner_1.TokenType.Delim, '=')) { | ||
this.accept(cssScanner_1.TokenType.Delim, '<'); | ||
else if (this.acceptDelim('=')) { | ||
this.acceptDelim('<'); | ||
return node; | ||
} | ||
else if (this.accept(cssScanner_1.TokenType.Delim, '<')) { | ||
this.accept(cssScanner_1.TokenType.Delim, '='); | ||
else if (this.acceptDelim('<')) { | ||
this.acceptDelim('='); | ||
return node; | ||
@@ -198,2 +198,3 @@ } | ||
|| this._parseImport() | ||
|| this._parseSupports(true) // @supports | ||
|| this._parseDetachedRuleSetMixin() // less detached ruleset mixin | ||
@@ -239,4 +240,4 @@ || this._parseVariableDeclaration(); // Variable declarations | ||
var node = this.createNode(nodes.NodeType.SelectorCombinator); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '&')) { | ||
while (!this.hasWhitespace() && (this.accept(cssScanner_1.TokenType.Delim, '-') || this.accept(cssScanner_1.TokenType.Num) || node.addChild(this._parseIdent()) || this.accept(cssScanner_1.TokenType.Delim, '&'))) { | ||
if (this.acceptDelim('&')) { | ||
while (!this.hasWhitespace() && (this.acceptDelim('-') || this.accept(cssScanner_1.TokenType.Num) || this.accept(cssScanner_1.TokenType.Dimension) || node.addChild(this._parseIdent()) || this.acceptDelim('&'))) { | ||
// support &-foo | ||
@@ -249,16 +250,35 @@ } | ||
LESSParser.prototype._parseSelectorIdent = function () { | ||
var node = this.createNode(nodes.NodeType.SelectorInterpolation); | ||
var hasContent = this._acceptInterpolatedIdent(node); | ||
return hasContent ? this.finish(node) : null; | ||
}; | ||
LESSParser.prototype._parsePropertyIdentifier = function () { | ||
var node = this.create(nodes.Identifier); | ||
node.isCustomProperty = this.peekRegExp(cssScanner_1.TokenType.Ident, /^--/); | ||
var hasContent = this._acceptInterpolatedIdent(node); | ||
if (hasContent && !this.hasWhitespace()) { | ||
this.acceptDelim('+'); | ||
if (!this.hasWhitespace()) { | ||
this.accept(cssScanner_1.TokenType.Ident, '_'); | ||
} | ||
} | ||
return hasContent ? this.finish(node) : null; | ||
}; | ||
LESSParser.prototype._acceptInterpolatedIdent = function (node) { | ||
var _this = this; | ||
var node = this.createNode(nodes.NodeType.SelectorInterpolation); | ||
var hasContent = false; | ||
var delimWithInterpolation = function () { | ||
if (!_this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
return false; | ||
if (!_this.acceptDelim('-')) { | ||
return null; | ||
} | ||
if (!_this.hasWhitespace() && _this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
if (!_this.hasWhitespace() && _this.acceptDelim('-')) { | ||
} | ||
return !_this.hasWhitespace() && node.addChild(_this._parseSelectorInterpolation()); | ||
if (!_this.hasWhitespace()) { | ||
return _this._parseInterpolation(); | ||
} | ||
return null; | ||
}; | ||
while (this.accept(cssScanner_1.TokenType.Ident) || node.addChild(this._parseSelectorInterpolation()) || this.try(delimWithInterpolation)) { | ||
while (this.accept(cssScanner_1.TokenType.Ident) || node.addChild(this._parseInterpolation() || this.try(delimWithInterpolation))) { | ||
hasContent = true; | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
if (!this.hasWhitespace() && this.acceptDelim('-')) { | ||
// '-' is a valid char inside a ident (special treatment here to support @{foo}-@{bar}) | ||
@@ -270,16 +290,12 @@ } | ||
} | ||
return hasContent ? this.finish(node) : null; | ||
return hasContent; | ||
}; | ||
LESSParser.prototype._parseSelectorInterpolation = function () { | ||
// Selector interpolation; old: ~"@{name}", new: @{name} | ||
LESSParser.prototype._parseInterpolation = function () { | ||
// @{name} | ||
var mark = this.mark(); | ||
var node = this.createNode(nodes.NodeType.Interpolation); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '~')) { | ||
if (!this.hasWhitespace() && (this.accept(cssScanner_1.TokenType.String) || this.accept(cssScanner_1.TokenType.BadString))) { | ||
return this.finish(node); | ||
} | ||
return this.finish(node, cssErrors_1.ParseError.StringLiteralExpected); | ||
} | ||
else if (this.accept(cssScanner_1.TokenType.Delim, '@')) { | ||
if (this.acceptDelim('@')) { | ||
if (this.hasWhitespace() || !this.accept(cssScanner_1.TokenType.CurlyL)) { | ||
return this.finish(node, cssErrors_1.ParseError.LeftCurlyExpected); | ||
this.restoreAtMark(mark); | ||
return null; | ||
} | ||
@@ -322,4 +338,7 @@ if (!node.addChild(this._parseIdent())) { | ||
} | ||
return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); | ||
return this._parseBody(node, this._parseMixInBodyDeclaration.bind(this)); | ||
}; | ||
LESSParser.prototype._parseMixInBodyDeclaration = function () { | ||
return this._parseFontFace() || this._parseRuleSetDeclaration(); | ||
}; | ||
LESSParser.prototype._parseMixinDeclarationIdentifier = function () { | ||
@@ -409,3 +428,3 @@ var identifier; | ||
while (identifier) { | ||
this.accept(cssScanner_1.TokenType.Delim, '>'); | ||
this.acceptDelim('>'); | ||
var nextId = this._parseMixinDeclarationIdentifier(); | ||
@@ -540,15 +559,2 @@ if (nextId) { | ||
}; | ||
LESSParser.prototype._parsePropertyIdentifier = function () { | ||
var identifier = this._parseIdent(); | ||
if (!identifier) { | ||
return null; | ||
} | ||
if (!this.hasWhitespace()) { | ||
this.accept(cssScanner_1.TokenType.Delim, '+'); | ||
if (!this.hasWhitespace()) { | ||
this.accept(cssScanner_1.TokenType.Ident, '_'); | ||
} | ||
} | ||
return this.finish(identifier); | ||
}; | ||
LESSParser.prototype._parseURLArgument = function () { | ||
@@ -555,0 +561,0 @@ var pos = this.mark(); |
@@ -55,3 +55,3 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
if (this.stream.advanceIfChars([_FSL, _FSL])) { | ||
if (!this.inURL && this.stream.advanceIfChars([_FSL, _FSL])) { | ||
this.stream.advanceWhileChar(function (ch) { | ||
@@ -58,0 +58,0 @@ switch (ch) { |
@@ -112,13 +112,16 @@ var __extends = (this && this.__extends) || (function () { | ||
var delimWithInterpolation = function () { | ||
if (!_this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
return false; | ||
if (!_this.acceptDelim('-')) { | ||
return null; | ||
} | ||
if (!_this.hasWhitespace() && _this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
if (!_this.hasWhitespace() && _this.acceptDelim('-')) { | ||
node.isCustomProperty = true; | ||
} | ||
return !_this.hasWhitespace() && node.addChild(_this._parseInterpolation()); | ||
if (!_this.hasWhitespace()) { | ||
return _this._parseInterpolation(); | ||
} | ||
return null; | ||
}; | ||
while (this.accept(cssScanner_1.TokenType.Ident) || node.addChild(this._parseInterpolation()) || this.try(delimWithInterpolation)) { | ||
while (this.accept(cssScanner_1.TokenType.Ident) || node.addChild(this._parseInterpolation() || this.try(delimWithInterpolation))) { | ||
hasContent = true; | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
if (!this.hasWhitespace() && this.acceptDelim('-')) { | ||
// '-' is a valid char inside a ident (special treatment here to support #{foo}-#{bar}) | ||
@@ -190,3 +193,4 @@ } | ||
|| this._parseMixinDeclaration() // nested @mixin | ||
|| this._parseRuleset(true); // @at-rule | ||
|| this._parseRuleset(true) // @at-rule | ||
|| this._parseSupports(true); // @supports | ||
} | ||
@@ -251,4 +255,4 @@ return this._parseVariableDeclaration() // variable declaration | ||
var node = this.createNode(nodes.NodeType.SelectorCombinator); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '&')) { | ||
while (!this.hasWhitespace() && (this.accept(cssScanner_1.TokenType.Delim, '-') || this.accept(cssScanner_1.TokenType.Num) || node.addChild(this._parseIdent()) || this.accept(cssScanner_1.TokenType.Delim, '&'))) { | ||
if (this.acceptDelim('&')) { | ||
while (!this.hasWhitespace() && (this.acceptDelim('-') || this.accept(cssScanner_1.TokenType.Num) || this.accept(cssScanner_1.TokenType.Dimension) || node.addChild(this._parseIdent()) || this.acceptDelim('&'))) { | ||
// support &-foo-1 | ||
@@ -262,3 +266,3 @@ } | ||
var node = this.createNode(nodes.NodeType.SelectorPlaceholder); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '%')) { | ||
if (this.acceptDelim('%')) { | ||
this._parseIdent(); | ||
@@ -265,0 +269,0 @@ return this.finish(node); |
@@ -100,3 +100,3 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
if (this.stream.advanceIfChars([_FSL, _FSL])) { | ||
if (!this.inURL && this.stream.advanceIfChars([_FSL, _FSL])) { | ||
this.stream.advanceWhileChar(function (ch) { | ||
@@ -103,0 +103,0 @@ switch (ch) { |
@@ -416,3 +416,3 @@ (function (factory) { | ||
if (sat === 0) { | ||
return { red: 0, green: 0, blue: 0, alpha: alpha }; | ||
return { red: light, green: light, blue: light, alpha: alpha }; | ||
} | ||
@@ -419,0 +419,0 @@ else { |
@@ -383,3 +383,3 @@ (function (factory) { | ||
if (!languageFacts.isKnownProperty(name)) { | ||
_this.addEntry(decl.getProperty(), lintRules_1.Rules.UnknownProperty); | ||
_this.addEntry(decl.getProperty(), lintRules_1.Rules.UnknownProperty, localize('property.unknownproperty.detailed', "Unknown property: '{0}'", name)); | ||
} | ||
@@ -386,0 +386,0 @@ propertiesBySuffix.add(name, name, null); // don't pass the node as we don't show errors on the standard |
@@ -17,3 +17,3 @@ var __extends = (this && this.__extends) || (function () { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "../parser/cssNodes"], factory); | ||
define(["require", "exports", "../parser/cssNodes", "../parser/cssScanner"], factory); | ||
} | ||
@@ -28,2 +28,3 @@ })(function (require, exports) { | ||
var nodes = require("../parser/cssNodes"); | ||
var cssScanner_1 = require("../parser/cssScanner"); | ||
var Element = /** @class */ (function () { | ||
@@ -255,9 +256,9 @@ function Element() { | ||
var text = child.getText(); | ||
result.addAttr('name', text === '*' ? 'element' : text); | ||
result.addAttr('name', text === '*' ? 'element' : unescape(text)); | ||
break; | ||
case nodes.NodeType.ClassSelector: | ||
result.addAttr('class', child.getText().substring(1)); | ||
result.addAttr('class', unescape(child.getText().substring(1))); | ||
break; | ||
case nodes.NodeType.IdentifierSelector: | ||
result.addAttr('id', child.getText().substring(1)); | ||
result.addAttr('id', unescape(child.getText().substring(1))); | ||
break; | ||
@@ -268,3 +269,3 @@ case nodes.NodeType.MixinDeclaration: | ||
case nodes.NodeType.PseudoSelector: | ||
result.addAttr(child.getText(), ''); | ||
result.addAttr(unescape(child.getText()), ''); | ||
break; | ||
@@ -276,29 +277,29 @@ case nodes.NodeType.AttributeSelector: | ||
if (expr.getRight()) { | ||
switch (expr.getOperator().getText()) { | ||
switch (unescape(expr.getOperator().getText())) { | ||
case '|=': | ||
// excatly or followed by -words | ||
value = quotes.remove(expr.getRight().getText()) + "-\u2026"; | ||
value = quotes.remove(unescape(expr.getRight().getText())) + "-\u2026"; | ||
break; | ||
case '^=': | ||
// prefix | ||
value = quotes.remove(expr.getRight().getText()) + "\u2026"; | ||
value = quotes.remove(unescape(expr.getRight().getText())) + "\u2026"; | ||
break; | ||
case '$=': | ||
// suffix | ||
value = "\u2026" + quotes.remove(expr.getRight().getText()); | ||
value = "\u2026" + quotes.remove(unescape(expr.getRight().getText())); | ||
break; | ||
case '~=': | ||
// one of a list of words | ||
value = " \u2026 " + quotes.remove(expr.getRight().getText()) + " \u2026 "; | ||
value = " \u2026 " + quotes.remove(unescape(expr.getRight().getText())) + " \u2026 "; | ||
break; | ||
case '*=': | ||
// substring | ||
value = "\u2026" + quotes.remove(expr.getRight().getText()) + "\u2026"; | ||
value = "\u2026" + quotes.remove(unescape(expr.getRight().getText())) + "\u2026"; | ||
break; | ||
default: | ||
value = quotes.remove(expr.getRight().getText()); | ||
value = quotes.remove(unescape(expr.getRight().getText())); | ||
break; | ||
} | ||
} | ||
result.addAttr(expr.getLeft().getText(), value); | ||
result.addAttr(unescape(expr.getLeft().getText()), value); | ||
} | ||
@@ -311,2 +312,11 @@ break; | ||
exports.toElement = toElement; | ||
function unescape(content) { | ||
var scanner = new cssScanner_1.Scanner(); | ||
scanner.setSource(content); | ||
var token = scanner.scanUnquotedString(); | ||
if (token) { | ||
return token.text; | ||
} | ||
return content; | ||
} | ||
function selectorToMarkedString(node) { | ||
@@ -313,0 +323,0 @@ var root = selectorToElement(node); |
{ | ||
"name": "vscode-css-languageservice", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Language service for CSS, LESS and SCSS", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cssLanguageService.js", |
Sorry, the diff of this file is too big to display
801575
21079
32