🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

vscode-css-languageservice

Package Overview
Dependencies
Maintainers
6
Versions
197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-css-languageservice - npm Package Compare versions

Comparing version

to
4.3.6

54

lib/esm/parser/cssParser.js

@@ -6,9 +6,2 @@ /*---------------------------------------------------------------------------------------------

'use strict';
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
import { TokenType, Scanner } from './cssScanner';

@@ -44,2 +37,5 @@ import * as nodes from './cssNodes';

};
Parser.prototype.peekOne = function (types) {
return types.indexOf(this.token.type) !== -1;
};
Parser.prototype.peekRegExp = function (type, regEx) {

@@ -317,4 +313,3 @@ if (type !== this.token.type) {

}
return this._tryParseCustomPropertyDeclaration()
|| this._parseDeclaration();
return this._parseDeclaration();
};

@@ -417,3 +412,7 @@ /**

};
Parser.prototype._parseDeclaration = function (resyncStopTokens) {
Parser.prototype._parseDeclaration = function (stopTokens) {
var custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
if (custonProperty) {
return custonProperty;
}
var node = this.create(nodes.Declaration);

@@ -424,4 +423,3 @@ if (!node.setProperty(this._parseProperty())) {

if (!this.accept(TokenType.Colon)) {
var stopTokens = resyncStopTokens ? __spreadArrays(resyncStopTokens, [TokenType.SemiColon]) : [TokenType.SemiColon];
return this.finish(node, ParseError.ColonExpected, [TokenType.Colon], stopTokens);
return this.finish(node, ParseError.ColonExpected, [TokenType.Colon], stopTokens || [TokenType.SemiColon]);
}

@@ -440,3 +438,3 @@ if (this.prevToken) {

};
Parser.prototype._tryParseCustomPropertyDeclaration = function () {
Parser.prototype._tryParseCustomPropertyDeclaration = function (stopTokens) {
if (!this.peekRegExp(TokenType.Ident, /^--/)) {

@@ -475,3 +473,3 @@ return null;

this._parsePrio();
if (this.peek(TokenType.SemiColon)) {
if (this.peekOne(stopTokens || [TokenType.SemiColon])) {
node.setValue(expression);

@@ -483,3 +481,3 @@ node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist

this.restoreAtMark(mark);
node.addChild(this._parseCustomPropertyValue());
node.addChild(this._parseCustomPropertyValue(stopTokens));
node.addChild(this._parsePrio());

@@ -502,5 +500,8 @@ if (isDefined(node.colonPosition) && this.token.offset === node.colonPosition + 1) {

*/
Parser.prototype._parseCustomPropertyValue = function () {
Parser.prototype._parseCustomPropertyValue = function (stopTokens) {
var _this = this;
if (stopTokens === void 0) { stopTokens = [TokenType.CurlyR]; }
var node = this.create(nodes.Node);
var isTopLevel = function () { return curlyDepth === 0 && parensDepth === 0 && bracketsDepth === 0; };
var onStopToken = function () { return stopTokens.indexOf(_this.token.type) !== -1; };
var curlyDepth = 0;

@@ -531,3 +532,3 @@ var parensDepth = 0;

// this is the last declaration in the ruleset.
if (parensDepth === 0 && bracketsDepth === 0) {
if (onStopToken() && parensDepth === 0 && bracketsDepth === 0) {
break done;

@@ -544,2 +545,5 @@ }

if (parensDepth < 0) {
if (onStopToken() && bracketsDepth === 0 && curlyDepth === 0) {
break done;
}
return this.finish(node, ParseError.LeftParenthesisExpected);

@@ -575,3 +579,3 @@ }

};
Parser.prototype._tryToParseDeclaration = function () {
Parser.prototype._tryToParseDeclaration = function (stopTokens) {
var mark = this.mark();

@@ -581,3 +585,3 @@ if (this._parseProperty() && this.accept(TokenType.Colon)) {

this.restoreAtMark(mark);
return this._parseDeclaration();
return this._parseDeclaration(stopTokens);
}

@@ -769,3 +773,3 @@ this.restoreAtMark(mark);

}
if (!node.addChild(this._tryToParseDeclaration())) {
if (!node.addChild(this._tryToParseDeclaration([TokenType.ParenthesisR]))) {
if (!this._parseSupportsCondition()) {

@@ -1242,9 +1246,7 @@ return this.finish(node, ParseError.ConditionExpected);

// optional, support ::
if (this.accept(TokenType.Colon) && this.hasWhitespace()) {
this.markError(node, ParseError.IdentifierExpected);
this.accept(TokenType.Colon);
if (this.hasWhitespace() || !node.addChild(this._parseIdent())) {
return this.finish(node, ParseError.IdentifierExpected);
}
if (!node.addChild(this._parseIdent())) {
this.markError(node, ParseError.IdentifierExpected);
}
return node;
return this.finish(node);
};

@@ -1251,0 +1253,0 @@ Parser.prototype._tryParsePrio = function () {

@@ -240,3 +240,7 @@ /*---------------------------------------------------------------------------------------------

};
SCSSParser.prototype._parseDeclaration = function (resyncStopTokens) {
SCSSParser.prototype._parseDeclaration = function (stopTokens) {
var custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
if (custonProperty) {
return custonProperty;
}
var node = this.create(nodes.Declaration);

@@ -247,3 +251,3 @@ if (!node.setProperty(this._parseProperty())) {

if (!this.accept(TokenType.Colon)) {
return this.finish(node, ParseError.ColonExpected, [TokenType.Colon], resyncStopTokens);
return this.finish(node, ParseError.ColonExpected, [TokenType.Colon], stopTokens || [TokenType.SemiColon]);
}

@@ -737,2 +741,7 @@ if (this.prevToken) {

}
if (this.accept(TokenType.Exclamation)) {
if (this.hasWhitespace() || !this.acceptIdent('default')) {
return this.finish(node, ParseError.UnknownKeyword);
}
}
return this.finish(node);

@@ -749,2 +758,22 @@ };

}
if (this.acceptIdent('with')) {
if (!this.accept(TokenType.ParenthesisL)) {
return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.ParenthesisR]);
}
// First variable statement, no comma.
if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
return this.finish(node, ParseError.VariableNameExpected);
}
while (this.accept(TokenType.Comma)) {
if (this.peek(TokenType.ParenthesisR)) {
break;
}
if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
return this.finish(node, ParseError.VariableNameExpected);
}
}
if (!this.accept(TokenType.ParenthesisR)) {
return this.finish(node, ParseError.RightParenthesisExpected);
}
}
if (!this.peek(TokenType.SemiColon) && !this.peek(TokenType.EOF)) {

@@ -781,2 +810,3 @@ if (!this.peekRegExp(TokenType.Ident, /as|hide|show/)) {

// Consume all variables and idents ahead.
this.accept(TokenType.Comma);
}

@@ -783,0 +813,0 @@ // More than just identifier

@@ -733,5 +733,8 @@ /*---------------------------------------------------------------------------------------------

var existingNode = this.findInNodePath(nodes.NodeType.PseudoSelector, nodes.NodeType.IdentifierSelector, nodes.NodeType.ClassSelector, nodes.NodeType.ElementNameSelector);
if (!existingNode && this.offset - this.currentWord.length > 0 && this.textDocument.getText()[this.offset - this.currentWord.length - 1] === ':') {
if (!existingNode && this.hasCharacterAtPosition(this.offset - this.currentWord.length - 1, ':')) {
// after the ':' of a pseudo selector, no node generated for just ':'
this.currentWord = ':' + this.currentWord;
if (this.hasCharacterAtPosition(this.offset - this.currentWord.length - 1, ':')) {
this.currentWord = ':' + this.currentWord; // for '::'
}
this.defaultReplaceRange = Range.create(Position.create(this.position.line, this.position.character - this.currentWord.length), this.position);

@@ -1015,2 +1018,6 @@ }

};
CSSCompletion.prototype.hasCharacterAtPosition = function (offset, char) {
var text = this.textDocument.getText();
return (offset >= 0 && offset < text.length) && text.charAt(offset) === char;
};
CSSCompletion.prototype.doesSupportMarkdown = function () {

@@ -1017,0 +1024,0 @@ var _a, _b, _c;

@@ -251,3 +251,7 @@ var __extends = (this && this.__extends) || (function () {

};
SCSSParser.prototype._parseDeclaration = function (resyncStopTokens) {
SCSSParser.prototype._parseDeclaration = function (stopTokens) {
var custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
if (custonProperty) {
return custonProperty;
}
var node = this.create(nodes.Declaration);

@@ -258,3 +262,3 @@ if (!node.setProperty(this._parseProperty())) {

if (!this.accept(cssScanner_1.TokenType.Colon)) {
return this.finish(node, cssErrors_1.ParseError.ColonExpected, [cssScanner_1.TokenType.Colon], resyncStopTokens);
return this.finish(node, cssErrors_1.ParseError.ColonExpected, [cssScanner_1.TokenType.Colon], stopTokens || [cssScanner_1.TokenType.SemiColon]);
}

@@ -748,2 +752,7 @@ if (this.prevToken) {

}
if (this.accept(cssScanner_1.TokenType.Exclamation)) {
if (this.hasWhitespace() || !this.acceptIdent('default')) {
return this.finish(node, cssErrors_1.ParseError.UnknownKeyword);
}
}
return this.finish(node);

@@ -760,2 +769,22 @@ };

}
if (this.acceptIdent('with')) {
if (!this.accept(cssScanner_1.TokenType.ParenthesisL)) {
return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [cssScanner_1.TokenType.ParenthesisR]);
}
// First variable statement, no comma.
if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
return this.finish(node, cssErrors_1.ParseError.VariableNameExpected);
}
while (this.accept(cssScanner_1.TokenType.Comma)) {
if (this.peek(cssScanner_1.TokenType.ParenthesisR)) {
break;
}
if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
return this.finish(node, cssErrors_1.ParseError.VariableNameExpected);
}
}
if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected);
}
}
if (!this.peek(cssScanner_1.TokenType.SemiColon) && !this.peek(cssScanner_1.TokenType.EOF)) {

@@ -792,2 +821,3 @@ if (!this.peekRegExp(cssScanner_1.TokenType.Ident, /as|hide|show/)) {

// Consume all variables and idents ahead.
this.accept(cssScanner_1.TokenType.Comma);
}

@@ -794,0 +824,0 @@ // More than just identifier

@@ -744,5 +744,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

var existingNode = this.findInNodePath(nodes.NodeType.PseudoSelector, nodes.NodeType.IdentifierSelector, nodes.NodeType.ClassSelector, nodes.NodeType.ElementNameSelector);
if (!existingNode && this.offset - this.currentWord.length > 0 && this.textDocument.getText()[this.offset - this.currentWord.length - 1] === ':') {
if (!existingNode && this.hasCharacterAtPosition(this.offset - this.currentWord.length - 1, ':')) {
// after the ':' of a pseudo selector, no node generated for just ':'
this.currentWord = ':' + this.currentWord;
if (this.hasCharacterAtPosition(this.offset - this.currentWord.length - 1, ':')) {
this.currentWord = ':' + this.currentWord; // for '::'
}
this.defaultReplaceRange = cssLanguageTypes_1.Range.create(cssLanguageTypes_1.Position.create(this.position.line, this.position.character - this.currentWord.length), this.position);

@@ -1026,2 +1029,6 @@ }

};
CSSCompletion.prototype.hasCharacterAtPosition = function (offset, char) {
var text = this.textDocument.getText();
return (offset >= 0 && offset < text.length) && text.charAt(offset) === char;
};
CSSCompletion.prototype.doesSupportMarkdown = function () {

@@ -1028,0 +1035,0 @@ var _a, _b, _c;

{
"name": "vscode-css-languageservice",
"version": "4.3.5",
"version": "4.3.6",
"description": "Language service for CSS, LESS and SCSS",

@@ -18,13 +18,11 @@ "main": "./lib/umd/cssLanguageService.js",

"devDependencies": {
"@types/mocha": "^8.0.3",
"@types/mocha": "^8.0.4",
"@types/node": "^10.12.21",
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/parser": "^4.1.1",
"eslint": "^7.9.0",
"mkdirp": "~1.0.4",
"mocha": "^8.1.3",
"nyc": "^15.1.0",
"@typescript-eslint/eslint-plugin": "^4.8.2",
"@typescript-eslint/parser": "^4.8.2",
"eslint": "^7.14.0",
"mocha": "^8.2.1",
"rimraf": "^3.0.2",
"typescript": "^4.0.2",
"vscode-web-custom-data": "^0.3.1"
"typescript": "^4.1.2",
"vscode-web-custom-data": "^0.3.2"
},

@@ -47,3 +45,3 @@ "dependencies": {

"mocha": "mocha",
"coverage": "nyc --reporter=html --reporter=text mocha",
"coverage": "npm run compile && npx nyc --reporter=html --reporter=text mocha",
"lint": "eslint src/**/*.ts",

@@ -50,0 +48,0 @@ "update-data": "yarn add vscode-web-custom-data && node ./build/generateData.js",

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