vscode-html-languageservice
Advanced tools
Comparing version 2.0.10 to 2.0.11
@@ -18,3 +18,3 @@ import { TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, DocumentHighlight, FormattingOptions, MarkedString, DocumentLink } from 'vscode-languageserver-types'; | ||
export interface CompletionConfiguration { | ||
[provider: string]: boolean; | ||
[provider: string]: boolean | undefined; | ||
hideAutoCompleteProposals?: boolean; | ||
@@ -28,5 +28,5 @@ } | ||
children: Node[]; | ||
parent: Node; | ||
parent?: Node; | ||
attributes?: { | ||
[name: string]: string; | ||
[name: string]: string | null; | ||
}; | ||
@@ -78,3 +78,3 @@ } | ||
getTokenText(): string; | ||
getTokenError(): string; | ||
getTokenError(): string | undefined; | ||
getScannerState(): ScannerState; | ||
@@ -95,8 +95,8 @@ } | ||
doComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument, options?: CompletionConfiguration): CompletionList; | ||
doHover(document: TextDocument, position: Position, htmlDocument: HTMLDocument): Hover; | ||
format(document: TextDocument, range: Range, options: HTMLFormatConfiguration): TextEdit[]; | ||
doHover(document: TextDocument, position: Position, htmlDocument: HTMLDocument): Hover | null; | ||
format(document: TextDocument, range: Range | undefined, options: HTMLFormatConfiguration): TextEdit[]; | ||
findDocumentLinks(document: TextDocument, documentContext: DocumentContext): DocumentLink[]; | ||
findDocumentSymbols(document: TextDocument, htmlDocument: HTMLDocument): SymbolInformation[]; | ||
doTagComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument): string; | ||
doTagComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument): string | null; | ||
} | ||
export declare function getLanguageService(): LanguageService; |
@@ -19,3 +19,3 @@ (function (factory) { | ||
var htmlTags_1 = require("./htmlTags"); | ||
var Node = (function () { | ||
var Node = /** @class */ (function () { | ||
function Node(start, end, children, parent) { | ||
@@ -32,3 +32,2 @@ this.start = start; | ||
}); | ||
; | ||
Node.prototype.isSameTag = function (tagInLowerCase) { | ||
@@ -79,3 +78,3 @@ return this.tag && tagInLowerCase && this.tag.length === tagInLowerCase.length && this.tag.toLowerCase() === tagInLowerCase; | ||
var scanner = htmlScanner_1.createScanner(text); | ||
var htmlDocument = new Node(0, text.length, [], null); | ||
var htmlDocument = new Node(0, text.length, [], void 0); | ||
var curr = htmlDocument; | ||
@@ -97,3 +96,3 @@ var endTagStart = -1; | ||
curr.end = scanner.getTokenEnd(); // might be later set to end tag position | ||
if (htmlTags_1.isEmptyElement(curr.tag) && curr !== htmlDocument) { | ||
if (htmlTags_1.isEmptyElement(curr.tag) && curr.parent) { | ||
curr.closed = true; | ||
@@ -108,3 +107,3 @@ curr = curr.parent; | ||
var closeTag = scanner.getTokenText().toLowerCase(); | ||
while (!curr.isSameTag(closeTag) && curr !== htmlDocument) { | ||
while (!curr.isSameTag(closeTag) && curr.parent) { | ||
curr.end = endTagStart; | ||
@@ -120,3 +119,3 @@ curr.closed = false; | ||
case htmlScanner_1.TokenType.StartTagSelfClose: | ||
if (curr !== htmlDocument) { | ||
if (curr.parent) { | ||
curr.closed = true; | ||
@@ -128,3 +127,3 @@ curr.end = scanner.getTokenEnd(); | ||
case htmlScanner_1.TokenType.EndTagClose: | ||
if (curr !== htmlDocument) { | ||
if (curr.parent) { | ||
curr.end = scanner.getTokenEnd(); | ||
@@ -134,3 +133,3 @@ curr = curr.parent; | ||
break; | ||
case htmlScanner_1.TokenType.AttributeName: | ||
case htmlScanner_1.TokenType.AttributeName: { | ||
var attributeName = pendingAttribute = scanner.getTokenText(); | ||
@@ -143,4 +142,6 @@ var attributes = curr.attributes; | ||
break; | ||
case htmlScanner_1.TokenType.AttributeValue: | ||
} | ||
case htmlScanner_1.TokenType.AttributeValue: { | ||
var value = scanner.getTokenText(); | ||
var attributes = curr.attributes; | ||
if (attributes && pendingAttribute) { | ||
@@ -151,6 +152,7 @@ attributes[pendingAttribute] = value; | ||
break; | ||
} | ||
} | ||
token = scanner.scan(); | ||
} | ||
while (curr !== htmlDocument) { | ||
while (curr.parent) { | ||
curr.end = text.length; | ||
@@ -157,0 +159,0 @@ curr.closed = false; |
@@ -45,5 +45,5 @@ export declare enum TokenType { | ||
getTokenText(): string; | ||
getTokenError(): string; | ||
getTokenError(): string | undefined; | ||
getScannerState(): ScannerState; | ||
} | ||
export declare function createScanner(input: string, initialOffset?: number, initialState?: ScannerState): Scanner; |
@@ -43,3 +43,3 @@ (function (factory) { | ||
})(TokenType = exports.TokenType || (exports.TokenType = {})); | ||
var MultiLineStream = (function () { | ||
var MultiLineStream = /** @class */ (function () { | ||
function MultiLineStream(source, position) { | ||
@@ -192,3 +192,3 @@ this.source = source; | ||
var tokenOffset = 0; | ||
var tokenType = void 0; | ||
var tokenType = TokenType.Unknown; | ||
var tokenError; | ||
@@ -291,4 +291,4 @@ var hasSpaceAfterTag; | ||
lastTag = nextElementName(); | ||
lastTypeValue = null; | ||
lastAttributeName = null; | ||
lastTypeValue = void 0; | ||
lastAttributeName = void 0; | ||
if (lastTag.length > 0) { | ||
@@ -295,0 +295,0 @@ hasSpaceAfterTag = false; |
@@ -53,6 +53,6 @@ /*--------------------------------------------------------------------------------------------- | ||
function isEmptyElement(e) { | ||
return e && arrays.binarySearch(exports.EMPTY_ELEMENTS, e.toLowerCase(), function (s1, s2) { return s1.localeCompare(s2); }) >= 0; | ||
return !!e && arrays.binarySearch(exports.EMPTY_ELEMENTS, e.toLowerCase(), function (s1, s2) { return s1.localeCompare(s2); }) >= 0; | ||
} | ||
exports.isEmptyElement = isEmptyElement; | ||
var HTMLTagSpecification = (function () { | ||
var HTMLTagSpecification = /** @class */ (function () { | ||
function HTMLTagSpecification(label, attributes) { | ||
@@ -327,4 +327,4 @@ if (attributes === void 0) { attributes = []; } | ||
attributes.forEach(function (a) { | ||
collector(a, null); | ||
collector('data-' + a, null); | ||
collector(a); | ||
collector('data-' + a); | ||
}); | ||
@@ -334,4 +334,4 @@ } | ||
globalAttributes.forEach(function (a) { | ||
collector(a, null); | ||
collector('data-' + a, null); | ||
collector(a); | ||
collector('data-' + a); | ||
}); | ||
@@ -338,0 +338,0 @@ }, |
@@ -36,3 +36,3 @@ (function (factory) { | ||
if (attributes) { | ||
attributes.forEach(function (a) { return collector(a, null); }); | ||
attributes.forEach(function (a) { return collector(a); }); | ||
} | ||
@@ -39,0 +39,0 @@ } |
@@ -33,3 +33,3 @@ (function (factory) { | ||
var scanner = htmlScanner_1.createScanner(text, node.start); | ||
var currentTag; | ||
var currentTag = ''; | ||
var currentAttributeName; | ||
@@ -166,2 +166,3 @@ function getReplaceRange(replaceStart, replaceEnd) { | ||
function collectAttributeValueSuggestions(valueStart, valueEnd) { | ||
if (valueEnd === void 0) { valueEnd = offset; } | ||
var range; | ||
@@ -299,3 +300,3 @@ var addQuotes; | ||
if (offset <= 0) { | ||
return; | ||
return null; | ||
} | ||
@@ -302,0 +303,0 @@ var char = document.getText().charAt(offset - 1); |
@@ -23,2 +23,3 @@ (function (factory) { | ||
var initialIndentLevel = 0; | ||
var tabSize = options.tabSize || 4; | ||
if (range) { | ||
@@ -61,3 +62,3 @@ var startOffset = document.offsetAt(range.start); | ||
var htmlOptions = { | ||
indent_size: options.insertSpaces ? options.tabSize : 1, | ||
indent_size: options.insertSpaces ? tabSize : 1, | ||
indent_char: options.insertSpaces ? ' ' : '\t', | ||
@@ -78,3 +79,3 @@ wrap_line_length: getFormatOption(options, 'wrapLineLength', 120), | ||
if (initialIndentLevel > 0) { | ||
var indent = options.insertSpaces ? strings_1.repeat(' ', options.tabSize * initialIndentLevel) : strings_1.repeat('\t', initialIndentLevel); | ||
var indent = options.insertSpaces ? strings_1.repeat(' ', tabSize * initialIndentLevel) : strings_1.repeat('\t', initialIndentLevel); | ||
result = result.split('\n').join('\n' + indent); | ||
@@ -81,0 +82,0 @@ if (range.start.character === 0) { |
@@ -23,3 +23,3 @@ (function (factory) { | ||
if (!node || !node.tag) { | ||
return void 0; | ||
return null; | ||
} | ||
@@ -30,3 +30,3 @@ var tagProviders = tagProviders_1.allTagProviders.filter(function (p) { return p.isApplicable(document.languageId); }); | ||
var _loop_1 = function (provider) { | ||
var hover; | ||
var hover = null; | ||
provider.collectTags(function (t, label) { | ||
@@ -48,3 +48,3 @@ if (t === tag) { | ||
} | ||
return void 0; | ||
return null; | ||
} | ||
@@ -67,3 +67,3 @@ function getTagNameRange(tokenType, startOffset) { | ||
} | ||
return void 0; | ||
return null; | ||
} | ||
@@ -74,3 +74,3 @@ var tagRange = getTagNameRange(htmlScanner_1.TokenType.StartTag, node.start); | ||
} | ||
return void 0; | ||
return null; | ||
} | ||
@@ -77,0 +77,0 @@ exports.doHover = doHover; |
{ | ||
"name": "vscode-html-languageservice", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "Language service for HTML", | ||
@@ -17,11 +17,11 @@ "main": "./lib/htmlLanguageService.js", | ||
"devDependencies": { | ||
"@types/mocha": "^2.2.33", | ||
"@types/node": "^6.0.51", | ||
"@types/mocha": "2.2.33", | ||
"@types/node": "7.0.43", | ||
"cpy-cli": "^1.0.1", | ||
"mocha": "^2.4.5", | ||
"tslint": "^5.1.0", | ||
"typescript": "^2.4.2" | ||
"mocha": "^4.0.1", | ||
"tslint": "^5.8.0", | ||
"typescript": "^2.6.1" | ||
}, | ||
"dependencies": { | ||
"vscode-languageserver-types": "^3.3.0", | ||
"vscode-languageserver-types": "3.5.0", | ||
"vscode-nls": "^2.0.2", | ||
@@ -31,7 +31,7 @@ "vscode-uri": "^1.0.1" | ||
"scripts": { | ||
"prepublish": "npm run test && npm run lint", | ||
"prepublish": "npm run test", | ||
"postpublish": "node ./build/post-publish.js", | ||
"compile": "tsc -p ./src && cpy ./src/beautify/*.js ./lib/beautify", | ||
"watch": "cpy ./src/beautify/*.js ./lib/beautify && tsc -w -p ./src", | ||
"test": "npm run compile && mocha", | ||
"test": "npm run compile && mocha && npm run lint", | ||
"lint": "tslint src/**/*.ts", | ||
@@ -38,0 +38,0 @@ "install-types-next": "npm install vscode-languageserver-types@next -f -S", |
270556
27
4574
+ Addedvscode-languageserver-types@3.5.0(transitive)
- Removedvscode-languageserver-types@3.17.5(transitive)