Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscode-html-languageservice

Package Overview
Dependencies
Maintainers
5
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-html-languageservice - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

8

CHANGELOG.md
4.2.0 / 2021-11-29
==================
* Added new API `htmlLanguageService.doQuoteComplete`. Called after an `attribute=`, it will compute either `""` or `''` depending on `CompletionConfiguration.attributeDefaultValue` or null, if no quote completion should be performed.
4.1.0 / 2021-09-27

@@ -14,3 +18,3 @@ ==================

* New parameter `HoverSettings` for `LanguageService.doHover`: Defines whether the hover contains element documentation and/or a reference to MDN.
* Deprecated `LanguageService.findOnTypeRenameRanges`, replaced by New API `LanguageService.findLinkedEditingRanges`.
* Deprecated `LanguageService.findOnTypeRenameRanges`, replaced by New API `LanguageService.findLinkedEditingRanges`.

@@ -20,3 +24,3 @@ 3.1.0 / 2020-07-29

* Use `TextDocument` from `vscode-languageserver-textdocument`
* Fix formatting for `<p>` tags with optional closing
* Fix formatting for `<p>` tags with optional closing
* New API `LanguageService.findOnTypeRenameRanges`. For a given position, find the matching close tag so they can be renamed synchronously.

@@ -23,0 +27,0 @@ * New API `LanguageServiceOptions.customDataProviders` to add the knowledge of custom tags, attributes and attribute-values and `LanguageService.setDataProviders` to update the data providers.

@@ -15,2 +15,3 @@ import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions, TextDocument, SelectionRange, WorkspaceEdit, Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, HoverSettings } from './htmlLanguageTypes';

findDocumentSymbols(document: TextDocument, htmlDocument: HTMLDocument): SymbolInformation[];
doQuoteComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument, options?: CompletionConfiguration): string | null;
doTagComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument): string | null;

@@ -17,0 +18,0 @@ getFoldingRanges(document: TextDocument, context?: {

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

getSelectionRanges: getSelectionRanges,
doQuoteComplete: htmlCompletion.doQuoteComplete.bind(htmlCompletion),
doTagComplete: htmlCompletion.doTagComplete.bind(htmlCompletion),

@@ -44,0 +45,0 @@ doRename: doRename,

@@ -502,2 +502,40 @@ /*---------------------------------------------------------------------------------------------

};
HTMLCompletion.prototype.doQuoteComplete = function (document, position, htmlDocument, settings) {
var _a;
var offset = document.offsetAt(position);
if (offset <= 0) {
return null;
}
var defaultValue = (_a = settings === null || settings === void 0 ? void 0 : settings.attributeDefaultValue) !== null && _a !== void 0 ? _a : 'doublequotes';
if (defaultValue === 'empty') {
return null;
}
var char = document.getText().charAt(offset - 1);
if (char !== '=') {
return null;
}
var value = defaultValue === 'doublequotes' ? '""' : '\'\'';
var node = htmlDocument.findNodeBefore(offset);
if (node && node.attributes && node.start < offset && (!node.endTagStart || node.endTagStart > offset)) {
var scanner = createScanner(document.getText(), node.start);
var token = scanner.scan();
while (token !== TokenType.EOS && scanner.getTokenEnd() <= offset) {
if (token === TokenType.AttributeName && scanner.getTokenEnd() === offset - 1) {
// Ensure the token is a valid standalone attribute name
token = scanner.scan(); // this should be the = just written
if (token !== TokenType.DelimiterAssign) {
return null;
}
token = scanner.scan();
// Any non-attribute valid tag
if (token === TokenType.Unknown || token === TokenType.AttributeValue) {
return null;
}
return value;
}
token = scanner.scan();
}
}
return null;
};
HTMLCompletion.prototype.doTagComplete = function (document, position, htmlDocument) {

@@ -504,0 +542,0 @@ var offset = document.offsetAt(position);

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

function isPathAttribute(tag, attr) {
if (attr === 'src' || attr === 'href') {
return true;
}
var a = PATH_TAG_AND_ATTR[tag];

@@ -141,0 +144,0 @@ if (a) {

@@ -15,2 +15,3 @@ import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions, TextDocument, SelectionRange, WorkspaceEdit, Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, HoverSettings } from './htmlLanguageTypes';

findDocumentSymbols(document: TextDocument, htmlDocument: HTMLDocument): SymbolInformation[];
doQuoteComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument, options?: CompletionConfiguration): string | null;
doTagComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument): string | null;

@@ -17,0 +18,0 @@ getFoldingRanges(document: TextDocument, context?: {

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

getSelectionRanges: htmlSelectionRange_1.getSelectionRanges,
doQuoteComplete: htmlCompletion.doQuoteComplete.bind(htmlCompletion),
doTagComplete: htmlCompletion.doTagComplete.bind(htmlCompletion),

@@ -66,0 +67,0 @@ doRename: htmlRename_1.doRename,

@@ -514,2 +514,40 @@ /*---------------------------------------------------------------------------------------------

};
HTMLCompletion.prototype.doQuoteComplete = function (document, position, htmlDocument, settings) {
var _a;
var offset = document.offsetAt(position);
if (offset <= 0) {
return null;
}
var defaultValue = (_a = settings === null || settings === void 0 ? void 0 : settings.attributeDefaultValue) !== null && _a !== void 0 ? _a : 'doublequotes';
if (defaultValue === 'empty') {
return null;
}
var char = document.getText().charAt(offset - 1);
if (char !== '=') {
return null;
}
var value = defaultValue === 'doublequotes' ? '""' : '\'\'';
var node = htmlDocument.findNodeBefore(offset);
if (node && node.attributes && node.start < offset && (!node.endTagStart || node.endTagStart > offset)) {
var scanner = (0, htmlScanner_1.createScanner)(document.getText(), node.start);
var token = scanner.scan();
while (token !== htmlLanguageTypes_1.TokenType.EOS && scanner.getTokenEnd() <= offset) {
if (token === htmlLanguageTypes_1.TokenType.AttributeName && scanner.getTokenEnd() === offset - 1) {
// Ensure the token is a valid standalone attribute name
token = scanner.scan(); // this should be the = just written
if (token !== htmlLanguageTypes_1.TokenType.DelimiterAssign) {
return null;
}
token = scanner.scan();
// Any non-attribute valid tag
if (token === htmlLanguageTypes_1.TokenType.Unknown || token === htmlLanguageTypes_1.TokenType.AttributeValue) {
return null;
}
return value;
}
token = scanner.scan();
}
}
return null;
};
HTMLCompletion.prototype.doTagComplete = function (document, position, htmlDocument) {

@@ -516,0 +554,0 @@ var offset = document.offsetAt(position);

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

function isPathAttribute(tag, attr) {
if (attr === 'src' || attr === 'href') {
return true;
}
var a = PATH_TAG_AND_ATTR[tag];

@@ -153,0 +156,0 @@ if (a) {

{
"name": "vscode-html-languageservice",
"version": "4.1.1",
"version": "4.2.0",
"description": "Language service for HTML",

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

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