New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vscode-css-languageservice

Package Overview
Dependencies
Maintainers
5
Versions
187
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 3.0.8 to 3.0.9-next.1

yarn.lock

26

lib/esm/cssLanguageService.d.ts

@@ -33,12 +33,20 @@ import { TextDocument, Position, CompletionList, Hover, Range, SymbolInformation, Diagnostic, Location, DocumentHighlight, CodeActionContext, Command, WorkspaceEdit, TextEdit } from 'vscode-languageserver-types';

}
export interface PropertyCompletionContext {
propertyName: string;
range: Range;
}
export interface PropertyValueCompletionContext {
propertyName: string;
propertyValue?: string;
range: Range;
}
export interface URILiteralCompletionContext {
uriValue: string;
position: Position;
range: Range;
}
export interface ICompletionParticipant {
onCssProperty: (context: {
propertyName: string;
range: Range;
}) => void;
onCssPropertyValue: (context: {
propertyName: string;
propertyValue?: string;
range: Range;
}) => void;
onProperty?: (context: PropertyCompletionContext) => void;
onPropertyValue?: (context: PropertyValueCompletionContext) => void;
onURILiteralValue?: (context: URILiteralCompletionContext) => void;
}

@@ -45,0 +53,0 @@ export interface LanguageService {

@@ -128,3 +128,4 @@ /*---------------------------------------------------------------------------------------------

export function getNodePath(node, offset) {
var candidate = getNodeAtOffset(node, offset), path = [];
var candidate = getNodeAtOffset(node, offset);
var path = [];
while (candidate) {

@@ -242,3 +243,3 @@ path.unshift(candidate);

Node.prototype.hasIssue = function (rule) {
return this.issues && this.issues.some(function (i) { return i.getRule() === rule; });
return Array.isArray(this.issues) && this.issues.some(function (i) { return i.getRule() === rule; });
};

@@ -250,3 +251,3 @@ Node.prototype.isErroneous = function (recursive) {

}
return recursive && this.children && this.children.some(function (c) { return c.isErroneous(true); });
return recursive && Array.isArray(this.children) && this.children.some(function (c) { return c.isErroneous(true); });
};

@@ -454,3 +455,3 @@ Node.prototype.setNode = function (field, node, index) {

RuleSet.prototype.isNested = function () {
return this.parent && this.parent.findParent(NodeType.Declarations) !== null;
return !!this.parent && this.parent.findParent(NodeType.Declarations) !== null;
};

@@ -457,0 +458,0 @@ return RuleSet;

@@ -190,2 +190,3 @@ /*---------------------------------------------------------------------------------------------

function Scanner() {
this.stream = new MultiLineStream('');
this.ignoreComment = true;

@@ -192,0 +193,0 @@ this.ignoreWhitespace = true;

@@ -98,3 +98,5 @@ /*---------------------------------------------------------------------------------------------

var current = this.scope.findScope(node.offset, node.length);
current.addSymbol(new Symbol(name, value, node, type));
if (current) {
current.addSymbol(new Symbol(name, value, node, type));
}
}

@@ -105,3 +107,3 @@ };

var current = this.scope.findScope(node.offset, node.length);
if (current.offset !== node.offset || current.length !== node.length) {
if (current && (current.offset !== node.offset || current.length !== node.length)) {
var newScope = new Scope(node.offset, node.length);

@@ -118,3 +120,5 @@ current.addChild(newScope);

var current = this.addScope(scopeNode); // create the scope or gets the existing one
current.addSymbol(new Symbol(name, value, node, type));
if (current) {
current.addSymbol(new Symbol(name, value, node, type));
}
}

@@ -125,3 +129,3 @@ };

case nodes.NodeType.Keyframe:
this.addSymbol(node, node.getName(), null, nodes.ReferenceType.Keyframe);
this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Keyframe);
return true;

@@ -135,6 +139,6 @@ case nodes.NodeType.CustomPropertyDeclaration:

case nodes.NodeType.MixinDeclaration:
this.addSymbol(node, node.getName(), null, nodes.ReferenceType.Mixin);
this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Mixin);
return true;
case nodes.NodeType.FunctionDeclaration:
this.addSymbol(node, node.getName(), null, nodes.ReferenceType.Function);
this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Function);
return true;

@@ -151,3 +155,3 @@ case nodes.NodeType.FunctionParameter: {

if (scopeNode) {
this.addSymbolToChildScope(scopeNode, forNode.variable, forNode.variable.getName(), null, nodes.ReferenceType.Variable);
this.addSymbolToChildScope(scopeNode, forNode.variable, forNode.variable.getName(), void 0, nodes.ReferenceType.Variable);
}

@@ -162,3 +166,3 @@ return true;

var variable = variables_1[_i];
this.addSymbolToChildScope(scopeNode_1, variable, variable.getName(), null, nodes.ReferenceType.Variable);
this.addSymbolToChildScope(scopeNode_1, variable, variable.getName(), void 0, nodes.ReferenceType.Variable);
}

@@ -173,7 +177,9 @@ }

var current = this.scope.findScope(node.offset, node.length);
for (var _i = 0, _a = node.getSelectors().getChildren(); _i < _a.length; _i++) {
var child = _a[_i];
if (child instanceof nodes.Selector) {
if (child.getChildren().length === 1) {
current.addSymbol(new Symbol(child.getChild(0).getText(), null, child, nodes.ReferenceType.Rule));
if (current) {
for (var _i = 0, _a = node.getSelectors().getChildren(); _i < _a.length; _i++) {
var child = _a[_i];
if (child instanceof nodes.Selector) {
if (child.getChildren().length === 1) {
current.addSymbol(new Symbol(child.getChild(0).getText(), void 0, child, nodes.ReferenceType.Rule));
}
}

@@ -185,3 +191,3 @@ }

ScopeBuilder.prototype.visitVariableDeclarationNode = function (node) {
var value = node.getValue() ? node.getValue().getText() : null;
var value = node.getValue() ? node.getValue().getText() : void 0;
this.addSymbol(node, node.getName(), value, nodes.ReferenceType.Variable);

@@ -195,3 +201,3 @@ return true;

var valueNode = node.getDefaultValue();
var value = valueNode ? valueNode.getText() : null;
var value = valueNode ? valueNode.getText() : void 0;
this.addSymbolToChildScope(scopeNode, node, node.getName(), value, nodes.ReferenceType.Variable);

@@ -208,13 +214,5 @@ }

if (node.offset !== -1) {
var globalScope = this.getGlobalScope(node, name, type);
globalScope.addSymbol(new Symbol(name, value, node, type));
this.scope.addSymbol(new Symbol(name, value, node, type));
}
};
ScopeBuilder.prototype.getGlobalScope = function (node, name, type) {
var current = this.scope.findScope(node.offset, node.length);
while (current.parent !== null) {
current = current.parent;
}
return current;
};
return ScopeBuilder;

@@ -325,3 +323,3 @@ }());

if (!node) {
return null;
return false;
}

@@ -328,0 +326,0 @@ while (node.type === nodes.NodeType.Interpolation) {

@@ -94,2 +94,5 @@ /*---------------------------------------------------------------------------------------------

}
else if (node.type === nodes.NodeType.URILiteral) {
this.getCompletionForUriLiteralValue(node, result);
}
if (result.items.length > 0) {

@@ -155,5 +158,10 @@ return this.finalize(result);

var insertText = void 0;
var retrigger = false;
if (declaration) {
range = this.getCompletionRange(declaration.getProperty());
insertText = entry.name + (!isDefined(declaration.colonPosition) ? ': ' : '');
insertText = entry.name;
if (!isDefined(declaration.colonPosition)) {
insertText += ': ';
retrigger = true;
}
}

@@ -163,2 +171,3 @@ else {

insertText = entry.name + ': ';
retrigger = true;
}

@@ -169,8 +178,10 @@ var item = {

textEdit: TextEdit.replace(range, insertText),
kind: CompletionItemKind.Property,
command: {
kind: CompletionItemKind.Property
};
if (retrigger) {
item.command = {
title: 'Suggest',
command: 'editor.action.triggerSuggest'
}
};
};
}
if (strings.startsWith(entry.name, '-')) {

@@ -184,6 +195,8 @@ item.sortText = 'x';

this.completionParticipants.forEach(function (participant) {
participant.onCssProperty({
propertyName: _this.currentWord,
range: _this.defaultReplaceRange
});
if (participant.onProperty) {
participant.onProperty({
propertyName: _this.currentWord,
range: _this.defaultReplaceRange
});
}
});

@@ -201,7 +214,9 @@ return result;

this.completionParticipants.forEach(function (participant) {
participant.onCssPropertyValue({
propertyName: propertyName,
propertyValue: _this.currentWord,
range: _this.getCompletionRange(existingNode)
});
if (participant.onPropertyValue) {
participant.onPropertyValue({
propertyName: propertyName,
propertyValue: _this.currentWord,
range: _this.getCompletionRange(existingNode)
});
}
});

@@ -804,2 +819,30 @@ if (entry) {

};
CSSCompletion.prototype.getCompletionForUriLiteralValue = function (uriLiteralNode, result) {
var uriValue;
var position;
var range;
// No children, empty value
if (uriLiteralNode.getChildren().length === 0) {
uriValue = '';
position = this.position;
var emptyURIValuePosition = this.textDocument.positionAt(uriLiteralNode.offset + 'url('.length);
range = Range.create(emptyURIValuePosition, emptyURIValuePosition);
}
else {
var uriValueNode = uriLiteralNode.getChild(0);
uriValue = uriValueNode.getText();
position = this.position;
range = this.getCompletionRange(uriValueNode);
}
this.completionParticipants.forEach(function (participant) {
if (participant.onURILiteralValue) {
participant.onURILiteralValue({
uriValue: uriValue,
position: position,
range: range
});
}
});
return result;
};
return CSSCompletion;

@@ -806,0 +849,0 @@ }());

@@ -315,3 +315,3 @@ /*---------------------------------------------------------------------------------------------

else if (node.type === nodes.NodeType.Function) {
return this.isColorConstructor(node);
return isColorConstructor(node);
}

@@ -552,3 +552,3 @@ else if (node.type === nodes.NodeType.Identifier) {

var desc = entry.description || '';
var browserLabel = this.getBrowserLabel(entry.browsers);
var browserLabel = getBrowserLabel(entry.browsers);
if (browserLabel) {

@@ -555,0 +555,0 @@ if (desc) {

@@ -33,12 +33,20 @@ import { TextDocument, Position, CompletionList, Hover, Range, SymbolInformation, Diagnostic, Location, DocumentHighlight, CodeActionContext, Command, WorkspaceEdit, TextEdit } from 'vscode-languageserver-types';

}
export interface PropertyCompletionContext {
propertyName: string;
range: Range;
}
export interface PropertyValueCompletionContext {
propertyName: string;
propertyValue?: string;
range: Range;
}
export interface URILiteralCompletionContext {
uriValue: string;
position: Position;
range: Range;
}
export interface ICompletionParticipant {
onCssProperty: (context: {
propertyName: string;
range: Range;
}) => void;
onCssPropertyValue: (context: {
propertyName: string;
propertyValue?: string;
range: Range;
}) => void;
onProperty?: (context: PropertyCompletionContext) => void;
onPropertyValue?: (context: PropertyValueCompletionContext) => void;
onURILiteralValue?: (context: URILiteralCompletionContext) => void;
}

@@ -45,0 +53,0 @@ export interface LanguageService {

@@ -200,2 +200,3 @@ (function (factory) {

function Scanner() {
this.stream = new MultiLineStream('');
this.ignoreComment = true;

@@ -202,0 +203,0 @@ this.ignoreWhitespace = true;

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

var current = this.scope.findScope(node.offset, node.length);
current.addSymbol(new Symbol(name, value, node, type));
if (current) {
current.addSymbol(new Symbol(name, value, node, type));
}
}

@@ -115,3 +117,3 @@ };

var current = this.scope.findScope(node.offset, node.length);
if (current.offset !== node.offset || current.length !== node.length) {
if (current && (current.offset !== node.offset || current.length !== node.length)) {
var newScope = new Scope(node.offset, node.length);

@@ -128,3 +130,5 @@ current.addChild(newScope);

var current = this.addScope(scopeNode); // create the scope or gets the existing one
current.addSymbol(new Symbol(name, value, node, type));
if (current) {
current.addSymbol(new Symbol(name, value, node, type));
}
}

@@ -135,3 +139,3 @@ };

case nodes.NodeType.Keyframe:
this.addSymbol(node, node.getName(), null, nodes.ReferenceType.Keyframe);
this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Keyframe);
return true;

@@ -145,6 +149,6 @@ case nodes.NodeType.CustomPropertyDeclaration:

case nodes.NodeType.MixinDeclaration:
this.addSymbol(node, node.getName(), null, nodes.ReferenceType.Mixin);
this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Mixin);
return true;
case nodes.NodeType.FunctionDeclaration:
this.addSymbol(node, node.getName(), null, nodes.ReferenceType.Function);
this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Function);
return true;

@@ -161,3 +165,3 @@ case nodes.NodeType.FunctionParameter: {

if (scopeNode) {
this.addSymbolToChildScope(scopeNode, forNode.variable, forNode.variable.getName(), null, nodes.ReferenceType.Variable);
this.addSymbolToChildScope(scopeNode, forNode.variable, forNode.variable.getName(), void 0, nodes.ReferenceType.Variable);
}

@@ -172,3 +176,3 @@ return true;

var variable = variables_1[_i];
this.addSymbolToChildScope(scopeNode_1, variable, variable.getName(), null, nodes.ReferenceType.Variable);
this.addSymbolToChildScope(scopeNode_1, variable, variable.getName(), void 0, nodes.ReferenceType.Variable);
}

@@ -183,7 +187,9 @@ }

var current = this.scope.findScope(node.offset, node.length);
for (var _i = 0, _a = node.getSelectors().getChildren(); _i < _a.length; _i++) {
var child = _a[_i];
if (child instanceof nodes.Selector) {
if (child.getChildren().length === 1) {
current.addSymbol(new Symbol(child.getChild(0).getText(), null, child, nodes.ReferenceType.Rule));
if (current) {
for (var _i = 0, _a = node.getSelectors().getChildren(); _i < _a.length; _i++) {
var child = _a[_i];
if (child instanceof nodes.Selector) {
if (child.getChildren().length === 1) {
current.addSymbol(new Symbol(child.getChild(0).getText(), void 0, child, nodes.ReferenceType.Rule));
}
}

@@ -195,3 +201,3 @@ }

ScopeBuilder.prototype.visitVariableDeclarationNode = function (node) {
var value = node.getValue() ? node.getValue().getText() : null;
var value = node.getValue() ? node.getValue().getText() : void 0;
this.addSymbol(node, node.getName(), value, nodes.ReferenceType.Variable);

@@ -205,3 +211,3 @@ return true;

var valueNode = node.getDefaultValue();
var value = valueNode ? valueNode.getText() : null;
var value = valueNode ? valueNode.getText() : void 0;
this.addSymbolToChildScope(scopeNode, node, node.getName(), value, nodes.ReferenceType.Variable);

@@ -218,13 +224,5 @@ }

if (node.offset !== -1) {
var globalScope = this.getGlobalScope(node, name, type);
globalScope.addSymbol(new Symbol(name, value, node, type));
this.scope.addSymbol(new Symbol(name, value, node, type));
}
};
ScopeBuilder.prototype.getGlobalScope = function (node, name, type) {
var current = this.scope.findScope(node.offset, node.length);
while (current.parent !== null) {
current = current.parent;
}
return current;
};
return ScopeBuilder;

@@ -335,3 +333,3 @@ }());

if (!node) {
return null;
return false;
}

@@ -338,0 +336,0 @@ while (node.type === nodes.NodeType.Interpolation) {

@@ -104,2 +104,5 @@ (function (factory) {

}
else if (node.type === nodes.NodeType.URILiteral) {
this.getCompletionForUriLiteralValue(node, result);
}
if (result.items.length > 0) {

@@ -165,5 +168,10 @@ return this.finalize(result);

var insertText = void 0;
var retrigger = false;
if (declaration) {
range = this.getCompletionRange(declaration.getProperty());
insertText = entry.name + (!isDefined(declaration.colonPosition) ? ': ' : '');
insertText = entry.name;
if (!isDefined(declaration.colonPosition)) {
insertText += ': ';
retrigger = true;
}
}

@@ -173,2 +181,3 @@ else {

insertText = entry.name + ': ';
retrigger = true;
}

@@ -179,8 +188,10 @@ var item = {

textEdit: vscode_languageserver_types_1.TextEdit.replace(range, insertText),
kind: vscode_languageserver_types_1.CompletionItemKind.Property,
command: {
kind: vscode_languageserver_types_1.CompletionItemKind.Property
};
if (retrigger) {
item.command = {
title: 'Suggest',
command: 'editor.action.triggerSuggest'
}
};
};
}
if (strings.startsWith(entry.name, '-')) {

@@ -194,6 +205,8 @@ item.sortText = 'x';

this.completionParticipants.forEach(function (participant) {
participant.onCssProperty({
propertyName: _this.currentWord,
range: _this.defaultReplaceRange
});
if (participant.onProperty) {
participant.onProperty({
propertyName: _this.currentWord,
range: _this.defaultReplaceRange
});
}
});

@@ -211,7 +224,9 @@ return result;

this.completionParticipants.forEach(function (participant) {
participant.onCssPropertyValue({
propertyName: propertyName,
propertyValue: _this.currentWord,
range: _this.getCompletionRange(existingNode)
});
if (participant.onPropertyValue) {
participant.onPropertyValue({
propertyName: propertyName,
propertyValue: _this.currentWord,
range: _this.getCompletionRange(existingNode)
});
}
});

@@ -814,2 +829,30 @@ if (entry) {

};
CSSCompletion.prototype.getCompletionForUriLiteralValue = function (uriLiteralNode, result) {
var uriValue;
var position;
var range;
// No children, empty value
if (uriLiteralNode.getChildren().length === 0) {
uriValue = '';
position = this.position;
var emptyURIValuePosition = this.textDocument.positionAt(uriLiteralNode.offset + 'url('.length);
range = vscode_languageserver_types_1.Range.create(emptyURIValuePosition, emptyURIValuePosition);
}
else {
var uriValueNode = uriLiteralNode.getChild(0);
uriValue = uriValueNode.getText();
position = this.position;
range = this.getCompletionRange(uriValueNode);
}
this.completionParticipants.forEach(function (participant) {
if (participant.onURILiteralValue) {
participant.onURILiteralValue({
uriValue: uriValue,
position: position,
range: range
});
}
});
return result;
};
return CSSCompletion;

@@ -816,0 +859,0 @@ }());

@@ -326,3 +326,3 @@ (function (factory) {

else if (node.type === nodes.NodeType.Function) {
return this.isColorConstructor(node);
return isColorConstructor(node);
}

@@ -573,3 +573,3 @@ else if (node.type === nodes.NodeType.Identifier) {

var desc = entry.description || '';
var browserLabel = this.getBrowserLabel(entry.browsers);
var browserLabel = getBrowserLabel(entry.browsers);
if (browserLabel) {

@@ -576,0 +576,0 @@ if (desc) {

{
"name": "vscode-css-languageservice",
"version": "3.0.8",
"version": "3.0.9-next.1",
"description": "Language service for CSS, LESS and SCSS",

@@ -5,0 +5,0 @@ "main": "./lib/umd/cssLanguageService.js",

@@ -6,4 +6,9 @@ {

"no-duplicate-variable": true,
"no-duplicate-imports": true,
"no-require-imports": true,
"new-parens": true,
"no-invalid-this": true,
"curly": true,
"class-name": true,
"indent": [true, "tabs", 2],
"semicolon": [

@@ -10,0 +15,0 @@ true,

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc