vscode-css-languageservice
Advanced tools
Comparing version 3.0.3 to 3.0.4
@@ -33,2 +33,13 @@ import { TextDocument, Position, CompletionList, Hover, Range, SymbolInformation, Diagnostic, Location, DocumentHighlight, CodeActionContext, Command, WorkspaceEdit, TextEdit } from 'vscode-languageserver-types'; | ||
} | ||
export interface ICompletionParticipant { | ||
onCssProperty: (context: { | ||
propertyName: string; | ||
range: Range; | ||
}) => void; | ||
onCssPropertyValue: (context: { | ||
propertyName: string; | ||
propertyValue?: string; | ||
range: Range; | ||
}) => void; | ||
} | ||
export interface LanguageService { | ||
@@ -39,2 +50,3 @@ configure(raw: LanguageSettings): void; | ||
doComplete(document: TextDocument, position: Position, stylesheet: Stylesheet): CompletionList | null; | ||
setCompletionParticipants(registeredCompletionParticipants: ICompletionParticipant[]): void; | ||
doHover(document: TextDocument, position: Position, stylesheet: Stylesheet): Hover | null; | ||
@@ -41,0 +53,0 @@ findDefinition(document: TextDocument, position: Position, stylesheet: Stylesheet): Location | null; |
@@ -35,2 +35,3 @@ (function (factory) { | ||
doComplete: completion.doComplete.bind(completion), | ||
setCompletionParticipants: completion.setCompletionParticipants.bind(completion), | ||
doHover: hover.doHover.bind(hover), | ||
@@ -37,0 +38,0 @@ findDefinition: navigation.findDefinition.bind(navigation), |
@@ -1026,7 +1026,7 @@ (function (factory) { | ||
} | ||
var node = this.createNode(nodes.NodeType.AttributeSelector); | ||
var node = this.create(nodes.AttributeSelector); | ||
this.consumeToken(); // BracketL | ||
// Optional attrib namespace | ||
node.addChild(this._parseNamespacePrefix()); | ||
if (!node.addChild(this._parseBinaryExpr())) { | ||
node.setNamespacePrefix(this._parseNamespacePrefix()); | ||
if (!node.setExpression(this._parseBinaryExpr())) { | ||
// is this bad? | ||
@@ -1033,0 +1033,0 @@ } |
@@ -27,2 +27,3 @@ (function (factory) { | ||
if (variablePrefix === void 0) { variablePrefix = null; } | ||
this.completionParticipants = []; | ||
this.valueTypes = [ | ||
@@ -40,2 +41,5 @@ nodes.NodeType.Identifier, nodes.NodeType.Value, nodes.NodeType.StringLiteral, nodes.NodeType.URILiteral, nodes.NodeType.NumericValue, | ||
}; | ||
CSSCompletion.prototype.setCompletionParticipants = function (registeredCompletionParticipants) { | ||
this.completionParticipants = registeredCompletionParticipants || []; | ||
}; | ||
CSSCompletion.prototype.doComplete = function (document, position, styleSheet) { | ||
@@ -145,2 +149,3 @@ this.offset = document.offsetAt(position); | ||
CSSCompletion.prototype.getPropertyProposals = function (declaration, result) { | ||
var _this = this; | ||
var properties = languageFacts.getProperties(); | ||
@@ -178,5 +183,12 @@ for (var key in properties) { | ||
} | ||
this.completionParticipants.forEach(function (participant) { | ||
participant.onCssProperty({ | ||
propertyName: _this.currentWord, | ||
range: _this.defaultReplaceRange | ||
}); | ||
}); | ||
return result; | ||
}; | ||
CSSCompletion.prototype.getCompletionsForDeclarationValue = function (node, result) { | ||
var _this = this; | ||
var propertyName = node.getFullPropertyName(); | ||
@@ -188,2 +200,9 @@ var entry = languageFacts.getProperties()[propertyName]; | ||
} | ||
this.completionParticipants.forEach(function (participant) { | ||
participant.onCssPropertyValue({ | ||
propertyName: propertyName, | ||
propertyValue: _this.currentWord, | ||
range: _this.getCompletionRange(existingNode) | ||
}); | ||
}); | ||
if (entry) { | ||
@@ -190,0 +209,0 @@ for (var _i = 0, _a = entry.restrictions; _i < _a.length; _i++) { |
@@ -270,3 +270,3 @@ var __extends = (this && this.__extends) || (function () { | ||
case nodes.NodeType.AttributeSelector: | ||
var expr = child.getChildren()[0]; | ||
var expr = child.getExpression(); | ||
if (expr) { | ||
@@ -273,0 +273,0 @@ var value = void 0; |
{ | ||
"name": "vscode-css-languageservice", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"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
806440
21209