vscode-html-languageservice
Advanced tools
Comparing version 2.1.10 to 2.1.11-next.1
import { TextDocument, Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange } from 'vscode-languageserver-types'; | ||
import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext } from './htmlLanguageTypes'; | ||
import { ITagSet, IAttributeSet } from './parser/htmlTags'; | ||
export * from './htmlLanguageTypes'; | ||
@@ -20,2 +21,6 @@ export * from 'vscode-languageserver-types'; | ||
} | ||
export declare function getLanguageService(): LanguageService; | ||
export interface LanguageServiceOptions { | ||
customTags?: ITagSet; | ||
customAttributes?: IAttributeSet; | ||
} | ||
export declare function getLanguageService(options?: LanguageServiceOptions): LanguageService; |
@@ -15,6 +15,15 @@ /*--------------------------------------------------------------------------------------------- | ||
import { getFoldingRanges } from './services/htmlFolding'; | ||
import { addTags, addAttributes } from './services/tagProviders'; | ||
export * from './htmlLanguageTypes'; | ||
export * from 'vscode-languageserver-types'; | ||
export function getLanguageService() { | ||
export function getLanguageService(options) { | ||
var htmlCompletion = new HTMLCompletion(); | ||
if (options) { | ||
if (options.customTags) { | ||
addTags(options.customTags); | ||
} | ||
if (options.customAttributes) { | ||
addAttributes(options.customAttributes); | ||
} | ||
} | ||
return { | ||
@@ -21,0 +30,0 @@ createScanner: createScanner, |
import { TextDocument, Position, Range } from 'vscode-languageserver-types'; | ||
export { HTMLTagSpecification, ITagSet, IAttributeSet } from './parser/htmlTags'; | ||
export interface HTMLFormatConfiguration { | ||
@@ -3,0 +4,0 @@ tabSize?: number; |
@@ -6,2 +6,3 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
export { HTMLTagSpecification } from './parser/htmlTags'; | ||
export var TokenType; | ||
@@ -8,0 +9,0 @@ (function (TokenType) { |
@@ -368,3 +368,3 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
function collectTagsDefault(collector, tagSet) { | ||
export function collectTagsDefault(collector, tagSet) { | ||
for (var tag in tagSet) { | ||
@@ -374,3 +374,3 @@ collector(tag, tagSet[tag].label); | ||
} | ||
function collectAttributesDefault(tag, collector, tagSet, globalAttributes) { | ||
export function collectAttributesDefault(tag, collector, tagSet, globalAttributes) { | ||
globalAttributes.forEach(function (attr) { | ||
@@ -377,0 +377,0 @@ var segments = attr.split(':'); |
@@ -9,3 +9,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { isEmptyElement } from '../parser/htmlTags'; | ||
import { allTagProviders } from './tagProviders'; | ||
import { getAllTagProviders } from './tagProviders'; | ||
import { ScannerState, TokenType } from '../htmlLanguageTypes'; | ||
@@ -29,3 +29,3 @@ import { entities } from '../parser/htmlEntities'; | ||
var completionParticipants = this.completionParticipants; | ||
var tagProviders = allTagProviders.filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var tagProviders = getAllTagProviders().filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var text = document.getText(); | ||
@@ -299,2 +299,12 @@ var offset = document.offsetAt(position); | ||
} | ||
function suggestDoctype(replaceStart, replaceEnd) { | ||
var range = getReplaceRange(replaceStart, replaceEnd); | ||
result.items.push({ | ||
label: '!DOCTYPE', | ||
kind: CompletionItemKind.Property, | ||
documentation: 'A preamble for an HTML document.', | ||
textEdit: TextEdit.replace(range, '!DOCTYPE html>'), | ||
insertTextFormat: InsertTextFormat.PlainText | ||
}); | ||
} | ||
var token = scanner.scan(); | ||
@@ -306,2 +316,5 @@ while (token !== TokenType.EOS && scanner.getTokenOffset() <= offset) { | ||
var endPos = scanNextForEndPos(TokenType.StartTag); | ||
if (position.line === 0) { | ||
suggestDoctype(offset, endPos); | ||
} | ||
return collectTagSuggestions(offset, endPos); | ||
@@ -308,0 +321,0 @@ } |
@@ -8,3 +8,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { MarkedString } from 'vscode-languageserver-types'; | ||
import { allTagProviders } from './tagProviders'; | ||
import { getAllTagProviders } from './tagProviders'; | ||
import { TokenType } from '../htmlLanguageTypes'; | ||
@@ -17,3 +17,3 @@ export function doHover(document, position, htmlDocument) { | ||
} | ||
var tagProviders = allTagProviders.filter(function (p) { return p.isApplicable(document.languageId); }); | ||
var tagProviders = getAllTagProviders().filter(function (p) { return p.isApplicable(document.languageId); }); | ||
function getTagHover(tag, range, open) { | ||
@@ -20,0 +20,0 @@ tag = tag.toLowerCase(); |
@@ -6,10 +6,58 @@ /*--------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
import { getHTML5TagProvider, getAngularTagProvider, getIonicTagProvider } from '../parser/htmlTags'; | ||
import { getHTML5TagProvider, getAngularTagProvider, getIonicTagProvider, collectTagsDefault, collectAttributesDefault } from '../parser/htmlTags'; | ||
import { getRazorTagProvider } from '../parser/razorTags'; | ||
export var allTagProviders = [ | ||
getHTML5TagProvider(), | ||
getAngularTagProvider(), | ||
getIonicTagProvider(), | ||
getRazorTagProvider() | ||
]; | ||
var TagProviderCollection = /** @class */ (function () { | ||
function TagProviderCollection(tagProviders) { | ||
this._tagProviders = [ | ||
getHTML5TagProvider(), | ||
getAngularTagProvider(), | ||
getIonicTagProvider(), | ||
getRazorTagProvider() | ||
].concat(tagProviders); | ||
} | ||
Object.defineProperty(TagProviderCollection.prototype, "tagProviders", { | ||
get: function () { | ||
return this._tagProviders; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
TagProviderCollection.prototype.addTagProviders = function (tagProviders) { | ||
this._tagProviders = this._tagProviders.concat(tagProviders); | ||
return this; | ||
}; | ||
return TagProviderCollection; | ||
}()); | ||
export { TagProviderCollection }; | ||
var defaultCollection = new TagProviderCollection([]); | ||
export function getAllTagProviders() { | ||
return defaultCollection.tagProviders; | ||
} | ||
export function addTagProviders(tagProviders) { | ||
return defaultCollection.addTagProviders(tagProviders); | ||
} | ||
export function addTags(tagSet) { | ||
var provider = { | ||
getId: function () { return 'userTagProvider'; }, | ||
isApplicable: function () { return true; }, | ||
collectTags: function (collector) { return collectTagsDefault(collector, tagSet); }, | ||
collectAttributes: function (tag, collector) { | ||
collectAttributesDefault(tag, collector, tagSet, []); | ||
}, | ||
collectValues: function (tag, attribute, collector) { } | ||
}; | ||
defaultCollection.addTagProviders([provider]); | ||
} | ||
export function addAttributes(attributeSet) { | ||
var provider = { | ||
getId: function () { return 'userAttributeProvider'; }, | ||
isApplicable: function () { return true; }, | ||
collectTags: function (collector) { }, | ||
collectAttributes: function (tag, collector) { | ||
collectAttributesDefault(tag, collector, {}, Object.keys(attributeSet)); | ||
}, | ||
collectValues: function (tag, attribute, collector) { } | ||
}; | ||
defaultCollection.addTagProviders([provider]); | ||
} | ||
//# sourceMappingURL=tagProviders.js.map |
import { TextDocument, Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange } from 'vscode-languageserver-types'; | ||
import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext } from './htmlLanguageTypes'; | ||
import { ITagSet, IAttributeSet } from './parser/htmlTags'; | ||
export * from './htmlLanguageTypes'; | ||
@@ -20,2 +21,6 @@ export * from 'vscode-languageserver-types'; | ||
} | ||
export declare function getLanguageService(): LanguageService; | ||
export interface LanguageServiceOptions { | ||
customTags?: ITagSet; | ||
customAttributes?: IAttributeSet; | ||
} | ||
export declare function getLanguageService(options?: LanguageServiceOptions): LanguageService; |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./parser/htmlScanner", "./parser/htmlParser", "./services/htmlCompletion", "./services/htmlHover", "./services/htmlFormatter", "./services/htmlLinks", "./services/htmlHighlighting", "./services/htmlSymbolsProvider", "./services/htmlFolding", "./htmlLanguageTypes", "vscode-languageserver-types"], factory); | ||
define(["require", "exports", "./parser/htmlScanner", "./parser/htmlParser", "./services/htmlCompletion", "./services/htmlHover", "./services/htmlFormatter", "./services/htmlLinks", "./services/htmlHighlighting", "./services/htmlSymbolsProvider", "./services/htmlFolding", "./services/tagProviders", "./htmlLanguageTypes", "vscode-languageserver-types"], factory); | ||
} | ||
@@ -29,6 +29,15 @@ })(function (require, exports) { | ||
var htmlFolding_1 = require("./services/htmlFolding"); | ||
var tagProviders_1 = require("./services/tagProviders"); | ||
__export(require("./htmlLanguageTypes")); | ||
__export(require("vscode-languageserver-types")); | ||
function getLanguageService() { | ||
function getLanguageService(options) { | ||
var htmlCompletion = new htmlCompletion_1.HTMLCompletion(); | ||
if (options) { | ||
if (options.customTags) { | ||
tagProviders_1.addTags(options.customTags); | ||
} | ||
if (options.customAttributes) { | ||
tagProviders_1.addAttributes(options.customAttributes); | ||
} | ||
} | ||
return { | ||
@@ -35,0 +44,0 @@ createScanner: htmlScanner_1.createScanner, |
import { TextDocument, Position, Range } from 'vscode-languageserver-types'; | ||
export { HTMLTagSpecification, ITagSet, IAttributeSet } from './parser/htmlTags'; | ||
export interface HTMLFormatConfiguration { | ||
@@ -3,0 +4,0 @@ tabSize?: number; |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
define(["require", "exports", "./parser/htmlTags"], factory); | ||
} | ||
@@ -17,2 +17,4 @@ })(function (require, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var htmlTags_1 = require("./parser/htmlTags"); | ||
exports.HTMLTagSpecification = htmlTags_1.HTMLTagSpecification; | ||
var TokenType; | ||
@@ -19,0 +21,0 @@ (function (TokenType) { |
@@ -388,2 +388,3 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
exports.collectTagsDefault = collectTagsDefault; | ||
function collectAttributesDefault(tag, collector, tagSet, globalAttributes) { | ||
@@ -407,2 +408,3 @@ globalAttributes.forEach(function (attr) { | ||
} | ||
exports.collectAttributesDefault = collectAttributesDefault; | ||
function collectValuesDefault(tag, attribute, collector, tagSet, globalAttributes, valueSets, customTags) { | ||
@@ -409,0 +411,0 @@ var prefix = attribute + ':'; |
@@ -38,3 +38,3 @@ (function (factory) { | ||
var completionParticipants = this.completionParticipants; | ||
var tagProviders = tagProviders_1.allTagProviders.filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var tagProviders = tagProviders_1.getAllTagProviders().filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var text = document.getText(); | ||
@@ -308,2 +308,12 @@ var offset = document.offsetAt(position); | ||
} | ||
function suggestDoctype(replaceStart, replaceEnd) { | ||
var range = getReplaceRange(replaceStart, replaceEnd); | ||
result.items.push({ | ||
label: '!DOCTYPE', | ||
kind: vscode_languageserver_types_1.CompletionItemKind.Property, | ||
documentation: 'A preamble for an HTML document.', | ||
textEdit: vscode_languageserver_types_1.TextEdit.replace(range, '!DOCTYPE html>'), | ||
insertTextFormat: vscode_languageserver_types_1.InsertTextFormat.PlainText | ||
}); | ||
} | ||
var token = scanner.scan(); | ||
@@ -315,2 +325,5 @@ while (token !== htmlLanguageTypes_1.TokenType.EOS && scanner.getTokenOffset() <= offset) { | ||
var endPos = scanNextForEndPos(htmlLanguageTypes_1.TokenType.StartTag); | ||
if (position.line === 0) { | ||
suggestDoctype(offset, endPos); | ||
} | ||
return collectTagSuggestions(offset, endPos); | ||
@@ -317,0 +330,0 @@ } |
@@ -26,3 +26,3 @@ (function (factory) { | ||
} | ||
var tagProviders = tagProviders_1.allTagProviders.filter(function (p) { return p.isApplicable(document.languageId); }); | ||
var tagProviders = tagProviders_1.getAllTagProviders().filter(function (p) { return p.isApplicable(document.languageId); }); | ||
function getTagHover(tag, range, open) { | ||
@@ -29,0 +29,0 @@ tag = tag.toLowerCase(); |
@@ -18,9 +18,61 @@ (function (factory) { | ||
var razorTags_1 = require("../parser/razorTags"); | ||
exports.allTagProviders = [ | ||
htmlTags_1.getHTML5TagProvider(), | ||
htmlTags_1.getAngularTagProvider(), | ||
htmlTags_1.getIonicTagProvider(), | ||
razorTags_1.getRazorTagProvider() | ||
]; | ||
var TagProviderCollection = /** @class */ (function () { | ||
function TagProviderCollection(tagProviders) { | ||
this._tagProviders = [ | ||
htmlTags_1.getHTML5TagProvider(), | ||
htmlTags_1.getAngularTagProvider(), | ||
htmlTags_1.getIonicTagProvider(), | ||
razorTags_1.getRazorTagProvider() | ||
].concat(tagProviders); | ||
} | ||
Object.defineProperty(TagProviderCollection.prototype, "tagProviders", { | ||
get: function () { | ||
return this._tagProviders; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
TagProviderCollection.prototype.addTagProviders = function (tagProviders) { | ||
this._tagProviders = this._tagProviders.concat(tagProviders); | ||
return this; | ||
}; | ||
return TagProviderCollection; | ||
}()); | ||
exports.TagProviderCollection = TagProviderCollection; | ||
var defaultCollection = new TagProviderCollection([]); | ||
function getAllTagProviders() { | ||
return defaultCollection.tagProviders; | ||
} | ||
exports.getAllTagProviders = getAllTagProviders; | ||
function addTagProviders(tagProviders) { | ||
return defaultCollection.addTagProviders(tagProviders); | ||
} | ||
exports.addTagProviders = addTagProviders; | ||
function addTags(tagSet) { | ||
var provider = { | ||
getId: function () { return 'userTagProvider'; }, | ||
isApplicable: function () { return true; }, | ||
collectTags: function (collector) { return htmlTags_1.collectTagsDefault(collector, tagSet); }, | ||
collectAttributes: function (tag, collector) { | ||
htmlTags_1.collectAttributesDefault(tag, collector, tagSet, []); | ||
}, | ||
collectValues: function (tag, attribute, collector) { } | ||
}; | ||
defaultCollection.addTagProviders([provider]); | ||
} | ||
exports.addTags = addTags; | ||
function addAttributes(attributeSet) { | ||
var provider = { | ||
getId: function () { return 'userAttributeProvider'; }, | ||
isApplicable: function () { return true; }, | ||
collectTags: function (collector) { }, | ||
collectAttributes: function (tag, collector) { | ||
htmlTags_1.collectAttributesDefault(tag, collector, {}, Object.keys(attributeSet)); | ||
}, | ||
collectValues: function (tag, attribute, collector) { } | ||
}; | ||
defaultCollection.addTagProviders([provider]); | ||
} | ||
exports.addAttributes = addAttributes; | ||
}); | ||
//# sourceMappingURL=tagProviders.js.map |
{ | ||
"name": "vscode-html-languageservice", | ||
"version": "2.1.10", | ||
"version": "2.1.11-next.1", | ||
"description": "Language service for HTML", | ||
@@ -5,0 +5,0 @@ "main": "./lib/umd/htmlLanguageService.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
714584
16137
2
1