vscode-css-languageservice
Advanced tools
Comparing version 2.1.5 to 2.1.6
@@ -55,5 +55,6 @@ (function (factory) { | ||
StringLiteralExpected: new CSSIssueType('css-stringliteralexpected', localize('expected.stringliteral', "string literal expected")), | ||
WhitespaceExpected: new CSSIssueType('css-whitespaceexpected', localize('expected.whitespace', "whitespace expected")) | ||
WhitespaceExpected: new CSSIssueType('css-whitespaceexpected', localize('expected.whitespace', "whitespace expected")), | ||
MediaQueryExpected: new CSSIssueType('css-mediaqueryexpected', localize('expected.mediaquery', "media query expected")) | ||
}; | ||
}); | ||
//# sourceMappingURL=cssErrors.js.map |
@@ -546,3 +546,5 @@ (function (factory) { | ||
} | ||
node.setMedialist(this._parseMediaList()); | ||
if (!this.peek(cssScanner_1.TokenType.SemiColon) && !this.peek(cssScanner_1.TokenType.EOF)) { | ||
node.setMedialist(this._parseMediaQueryList()); | ||
} | ||
return this.finish(node); | ||
@@ -600,3 +602,3 @@ }; | ||
} | ||
if (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Keyframe]))) { | ||
if (!node.setIdentifier(this._parseKeyframeIdent())) { | ||
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [cssScanner_1.TokenType.CurlyR]); | ||
@@ -606,2 +608,5 @@ } | ||
}; | ||
Parser.prototype._parseKeyframeIdent = function () { | ||
return this._parseIdent([nodes.ReferenceType.Keyframe]); | ||
}; | ||
Parser.prototype._parseKeyframeSelector = function () { | ||
@@ -619,2 +624,20 @@ var node = this.create(nodes.KeyframeSelector); | ||
}; | ||
Parser.prototype._tryParseKeyframeSelector = function () { | ||
var node = this.create(nodes.KeyframeSelector); | ||
var pos = this.mark(); | ||
if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) { | ||
return null; | ||
} | ||
while (this.accept(cssScanner_1.TokenType.Comma)) { | ||
if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) { | ||
this.restoreAtMark(pos); | ||
return null; | ||
} | ||
} | ||
if (!this.peek(cssScanner_1.TokenType.CurlyL)) { | ||
this.restoreAtMark(pos); | ||
return null; | ||
} | ||
return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); | ||
}; | ||
Parser.prototype._parseSupports = function (isNested) { | ||
@@ -716,11 +739,18 @@ if (isNested === void 0) { isNested = false; } | ||
} | ||
if (!node.addChild(this._parseMediaQueryList())) { | ||
return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected); | ||
} | ||
return this._parseBody(node, this._parseMediaDeclaration.bind(this, isNested)); | ||
}; | ||
Parser.prototype._parseMediaQueryList = function () { | ||
var node = this.create(nodes.Medialist); | ||
if (!node.addChild(this._parseMediaQuery([cssScanner_1.TokenType.CurlyL]))) { | ||
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); | ||
return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected); | ||
} | ||
while (this.accept(cssScanner_1.TokenType.Comma)) { | ||
if (!node.addChild(this._parseMediaQuery([cssScanner_1.TokenType.CurlyL]))) { | ||
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); | ||
return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected); | ||
} | ||
} | ||
return this._parseBody(node, this._parseMediaDeclaration.bind(this, isNested)); | ||
return this.finish(node); | ||
}; | ||
@@ -764,3 +794,3 @@ Parser.prototype._parseMediaQuery = function (resyncStopToken) { | ||
} | ||
return node; | ||
return this.finish(node); | ||
}; | ||
@@ -770,14 +800,2 @@ Parser.prototype._parseMediaFeatureName = function () { | ||
}; | ||
Parser.prototype._parseMediaList = function () { | ||
var node = this.create(nodes.Medialist); | ||
if (node.getMediums().addChild(this._parseMedium())) { | ||
while (this.accept(cssScanner_1.TokenType.Comma)) { | ||
if (!node.getMediums().addChild(this._parseMedium())) { | ||
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); | ||
} | ||
} | ||
return this.finish(node); | ||
} | ||
return null; | ||
}; | ||
Parser.prototype._parseMedium = function () { | ||
@@ -784,0 +802,0 @@ var node = this.create(nodes.Node); |
@@ -68,3 +68,6 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
node.setMedialist(this._parseMediaList()); | ||
if (!this.peek(cssScanner_1.TokenType.SemiColon) && !this.peek(cssScanner_1.TokenType.EOF)) { | ||
node.setMedialist(this._parseMediaQueryList()); | ||
} | ||
; | ||
return this.finish(node); | ||
@@ -120,5 +123,8 @@ }; | ||
var content = this.create(nodes.BodyDeclaration); | ||
this._parseBody(content, this._parseRuleSetDeclaration.bind(this)); | ||
this._parseBody(content, this._parseDetachedRuleSetBody.bind(this)); | ||
return this.finish(content); | ||
}; | ||
LESSParser.prototype._parseDetachedRuleSetBody = function () { | ||
return this._tryParseKeyframeSelector() || _super.prototype._parseRuleSetDeclaration.call(this); | ||
}; | ||
LESSParser.prototype._parseVariable = function () { | ||
@@ -201,2 +207,9 @@ var node = this.create(nodes.Variable); | ||
}; | ||
LESSParser.prototype._parseKeyframeIdent = function () { | ||
return this._parseIdent([nodes.ReferenceType.Keyframe]) || this._parseVariable(); | ||
}; | ||
LESSParser.prototype._parseKeyframeSelector = function () { | ||
return this._parseDetachedRuleSetMixin() // less detached ruleset mixin | ||
|| _super.prototype._parseKeyframeSelector.call(this); | ||
}; | ||
LESSParser.prototype._parseSimpleSelectorBody = function () { | ||
@@ -226,7 +239,27 @@ return this._parseSelectorCombinator() || _super.prototype._parseSimpleSelectorBody.call(this); | ||
LESSParser.prototype._parseSelectorIdent = function () { | ||
return this._parseIdent() || this._parseSelectorInterpolation(); | ||
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.hasWhitespace() && _this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
} | ||
return !_this.hasWhitespace() && node.addChild(_this._parseSelectorInterpolation()); | ||
}; | ||
while (this.accept(cssScanner_1.TokenType.Ident) || node.addChild(this._parseSelectorInterpolation()) || this.try(delimWithInterpolation)) { | ||
hasContent = true; | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.Delim, '-')) { | ||
// '-' is a valid char inside a ident (special treatment here to support @{foo}-@{bar}) | ||
} | ||
if (this.hasWhitespace()) { | ||
break; | ||
} | ||
} | ||
return hasContent ? this.finish(node) : null; | ||
}; | ||
LESSParser.prototype._parseSelectorInterpolation = function () { | ||
// Selector interpolation; old: ~"@{name}", new: @{name} | ||
var node = this.createNode(nodes.NodeType.SelectorInterpolation); | ||
var node = this.createNode(nodes.NodeType.Interpolation); | ||
if (this.accept(cssScanner_1.TokenType.Delim, '~')) { | ||
@@ -265,3 +298,3 @@ if (!this.hasWhitespace() && (this.accept(cssScanner_1.TokenType.String) || this.accept(cssScanner_1.TokenType.BadString))) { | ||
if (!node.getParameters().addChild(this._parseMixinParameter())) { | ||
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); | ||
this.markError(node, cssErrors_1.ParseError.IdentifierExpected, [], [cssScanner_1.TokenType.ParenthesisR]); | ||
} | ||
@@ -379,3 +412,5 @@ } | ||
} | ||
var hasArguments = false; | ||
if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.ParenthesisL)) { | ||
hasArguments = true; | ||
if (node.getArguments().addChild(this._parseMixinArgument())) { | ||
@@ -400,3 +435,3 @@ while (this.accept(cssScanner_1.TokenType.Comma) || this.accept(cssScanner_1.TokenType.SemiColon)) { | ||
node.addChild(this._parsePrio()); | ||
if (atRoot && !this.peek(cssScanner_1.TokenType.SemiColon)) { | ||
if (!hasArguments && !this.peek(cssScanner_1.TokenType.SemiColon) && !this.peek(cssScanner_1.TokenType.CurlyR) && !this.peek(cssScanner_1.TokenType.EOF)) { | ||
this.restoreAtMark(mark); | ||
@@ -403,0 +438,0 @@ return null; |
@@ -64,3 +64,5 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
node.setMedialist(this._parseMediaList()); | ||
if (!this.peek(cssScanner_1.TokenType.SemiColon) && !this.peek(cssScanner_1.TokenType.EOF)) { | ||
node.setMedialist(this._parseMediaQueryList()); | ||
} | ||
return this.finish(node); | ||
@@ -96,3 +98,3 @@ }; | ||
SCSSParser.prototype._parseKeyframeSelector = function () { | ||
return _super.prototype._parseKeyframeSelector.call(this) || this._parseMixinContent(); | ||
return this._tryParseKeyframeSelector() || this._parseMixinContent(); | ||
}; | ||
@@ -232,2 +234,5 @@ SCSSParser.prototype._parseVariable = function () { | ||
} | ||
while (this.accept(cssScanner_1.TokenType.Comma)) { | ||
node.getSelectors().addChild(this._parseSimpleSelector()); | ||
} | ||
if (this.accept(cssScanner_1.TokenType.Exclamation)) { | ||
@@ -482,3 +487,3 @@ if (!this.accept(cssScanner_1.TokenType.Ident, 'optional', true)) { | ||
SCSSParser.prototype._parseMixinReferenceBodyStatement = function () { | ||
return this._parseRuleSetDeclaration() || this._parseKeyframeSelector(); | ||
return this._tryParseKeyframeSelector() || this._parseRuleSetDeclaration(); | ||
}; | ||
@@ -485,0 +490,0 @@ SCSSParser.prototype._parseFunctionArgument = function () { |
@@ -250,5 +250,2 @@ (function (factory) { | ||
}; | ||
if (insertTextFormat) { | ||
item.insertTextFormat = insertTextFormat; | ||
} | ||
result.items.push(item); | ||
@@ -463,7 +460,9 @@ } | ||
for (var image in languageFacts.imageFunctions) { | ||
var insertText = image.replace(/\(\)$/, "($1)"); | ||
result.items.push({ | ||
label: image, | ||
documentation: languageFacts.imageFunctions[image], | ||
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), image), | ||
kind: vscode_languageserver_types_1.CompletionItemKind.Function | ||
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText), | ||
kind: vscode_languageserver_types_1.CompletionItemKind.Function, | ||
insertTextFormat: image !== insertText ? SnippetFormat : void 0 | ||
}); | ||
@@ -475,7 +474,9 @@ } | ||
for (var timing in languageFacts.transitionTimingFunctions) { | ||
var insertText = timing.replace(/\(\)$/, "($1)"); | ||
result.items.push({ | ||
label: timing, | ||
documentation: languageFacts.transitionTimingFunctions[timing], | ||
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), timing), | ||
kind: vscode_languageserver_types_1.CompletionItemKind.Function | ||
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText), | ||
kind: vscode_languageserver_types_1.CompletionItemKind.Function, | ||
insertTextFormat: timing !== insertText ? SnippetFormat : void 0 | ||
}); | ||
@@ -487,7 +488,9 @@ } | ||
for (var shape in languageFacts.basicShapeFunctions) { | ||
var insertText = shape.replace(/\(\)$/, "($1)"); | ||
result.items.push({ | ||
label: shape, | ||
documentation: languageFacts.basicShapeFunctions[shape], | ||
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), shape), | ||
kind: vscode_languageserver_types_1.CompletionItemKind.Function | ||
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText), | ||
kind: vscode_languageserver_types_1.CompletionItemKind.Function, | ||
insertTextFormat: shape !== insertText ? SnippetFormat : void 0 | ||
}); | ||
@@ -530,6 +533,2 @@ } | ||
if (isInSelectors) { | ||
var currentWordStart = this.textDocument.offsetAt(this.defaultReplaceRange.start); | ||
while (currentWordStart > 0 && this.textDocument.getText().charAt(currentWordStart - 1) === ':') { | ||
currentWordStart--; | ||
} | ||
return this.getCompletionsForSelector(ruleSet, ruleSet.isNested(), result); | ||
@@ -543,6 +542,6 @@ } | ||
var existingNode = this.findInNodePath(nodes.NodeType.PseudoSelector, nodes.NodeType.IdentifierSelector, nodes.NodeType.ClassSelector, nodes.NodeType.ElementNameSelector); | ||
if (!existingNode && this.currentWord.length === 0 && this.offset > 0 && this.textDocument.getText()[this.offset - 1] === ':') { | ||
if (!existingNode && this.offset - this.currentWord.length > 0 && this.textDocument.getText()[this.offset - this.currentWord.length - 1] === ':') { | ||
// after the ':' of a pseudo selector, no node generated for just ':' | ||
this.currentWord = ':'; | ||
this.defaultReplaceRange = vscode_languageserver_types_1.Range.create(vscode_languageserver_types_1.Position.create(this.position.line, this.position.character - 1), this.position); | ||
this.currentWord = ':' + this.currentWord; | ||
this.defaultReplaceRange = vscode_languageserver_types_1.Range.create(vscode_languageserver_types_1.Position.create(this.position.line, this.position.character - this.currentWord.length), this.position); | ||
} | ||
@@ -792,3 +791,3 @@ languageFacts.getPseudoClasses().forEach(function (entry) { | ||
var text = document.getText(); | ||
while (i >= 0 && ' \t\n\r":{[()]},'.indexOf(text.charAt(i)) === -1) { | ||
while (i >= 0 && ' \t\n\r":{[()]},*>+'.indexOf(text.charAt(i)) === -1) { | ||
i--; | ||
@@ -795,0 +794,0 @@ } |
@@ -65,2 +65,6 @@ var __extends = (this && this.__extends) || (function () { | ||
}; | ||
LESSCompletion.prototype.getCompletionsForDeclarationProperty = function (declaration, result) { | ||
this.getCompletionsForSelector(null, true, result); | ||
return _super.prototype.getCompletionsForDeclarationProperty.call(this, declaration, result); | ||
}; | ||
LESSCompletion.builtInProposals = [ | ||
@@ -67,0 +71,0 @@ { |
@@ -38,3 +38,3 @@ var __extends = (this && this.__extends) || (function () { | ||
return function (match, p1) { | ||
return p1 + ': ${' + tabStopCounter++ + ':' + (SCSSCompletion.variableDefaults[p1] || '') + '}'; | ||
return '\\' + p1 + ': ${' + tabStopCounter++ + ':' + (SCSSCompletion.variableDefaults[p1] || '') + '}'; | ||
}; | ||
@@ -87,3 +87,3 @@ }; | ||
'$alpha': '1.0', | ||
'$color': '$color', | ||
'$color': '#000000', | ||
'$weight': '0.5', | ||
@@ -90,0 +90,0 @@ '$hue': '0', |
{ | ||
"name": "vscode-css-languageservice", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"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
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
3667523
21271