vscode-html-languageservice
Advanced tools
Comparing version 3.1.0-next.2 to 3.1.0-next.3
@@ -5,7 +5,10 @@ 3.1.0 / | ||
* Fix formatting for `<p>` tags with optional closing | ||
* New API `findOnTypeRenameRanges` | ||
* New API `LanguageService.findOnTypeRenameRanges`. For a given position, find the matching close tag so they can be renamed synchronously. | ||
* New API `LanguageServiceOptions.customDataProviders` to add the knowledge of custom tags, attributes and attribute-values and `LanguageService.setDataProviders` to update the data providers. | ||
* New API `LanguageServiceOptions.fileSystemProvider` with `FileSystemProvider` to query the file system (currently used for path completion) | ||
* New API `LanguageService.doComplete2` which is synchronous and also returns path completion proposals when `LanguageServiceOptions.fileSystemProvider` is provided. | ||
3.0.3 / 2019-07-25 | ||
================== | ||
* DocumentContext.resolveReference can also return undefined (if the ref is invalid) | ||
* `DocumentContext.resolveReference` can also return undefined (if the ref is invalid) | ||
@@ -12,0 +15,0 @@ 3.0.0 / 2019-06-12 |
@@ -1,8 +0,5 @@ | ||
import { Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, SelectionRange, WorkspaceEdit } from 'vscode-languageserver-types'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions } from './htmlLanguageTypes'; | ||
import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions, TextDocument, SelectionRange, WorkspaceEdit, Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange } from './htmlLanguageTypes'; | ||
export * from './htmlLanguageTypes'; | ||
export { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export * from 'vscode-languageserver-types'; | ||
export interface LanguageService { | ||
setDataProviders(useDefaultDataProvider: boolean, customDataProviders: IHTMLDataProvider[]): void; | ||
createScanner(input: string, initialOffset?: number): Scanner; | ||
@@ -12,2 +9,3 @@ parseHTMLDocument(document: TextDocument): HTMLDocument; | ||
doComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument, options?: CompletionConfiguration): CompletionList; | ||
doComplete2(document: TextDocument, position: Position, htmlDocument: HTMLDocument, documentContext: DocumentContext, options?: CompletionConfiguration): Promise<CompletionList>; | ||
setCompletionParticipants(registeredCompletionParticipants: ICompletionParticipant[]): void; | ||
@@ -14,0 +12,0 @@ doHover(document: TextDocument, position: Position, htmlDocument: HTMLDocument): Hover | null; |
@@ -18,17 +18,17 @@ /*--------------------------------------------------------------------------------------------- | ||
import { getSelectionRanges } from './services/htmlSelectionRange'; | ||
import { handleCustomDataProviders } from './languageFacts/builtinDataProviders'; | ||
import { HTMLDataProvider } from './languageFacts/dataProvider'; | ||
import { HTMLDataManager } from './languageFacts/dataManager'; | ||
export * from './htmlLanguageTypes'; | ||
export { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export * from 'vscode-languageserver-types'; | ||
var defaultLanguageServiceOptions = {}; | ||
export function getLanguageService(options) { | ||
var htmlHover = new HTMLHover(options && options.clientCapabilities); | ||
var htmlCompletion = new HTMLCompletion(options && options.clientCapabilities); | ||
if (options && options.customDataProviders) { | ||
handleCustomDataProviders(options.customDataProviders); | ||
} | ||
if (options === void 0) { options = defaultLanguageServiceOptions; } | ||
var dataManager = new HTMLDataManager(options); | ||
var htmlHover = new HTMLHover(options, dataManager); | ||
var htmlCompletion = new HTMLCompletion(options, dataManager); | ||
return { | ||
setDataProviders: dataManager.setDataProviders.bind(dataManager), | ||
createScanner: createScanner, | ||
parseHTMLDocument: function (document) { return parse(document.getText()); }, | ||
doComplete: htmlCompletion.doComplete.bind(htmlCompletion), | ||
doComplete2: htmlCompletion.doComplete2.bind(htmlCompletion), | ||
setCompletionParticipants: htmlCompletion.setCompletionParticipants.bind(htmlCompletion), | ||
@@ -35,0 +35,0 @@ doHover: htmlHover.doHover.bind(htmlHover), |
@@ -1,3 +0,5 @@ | ||
import { Position, Range, MarkupContent, MarkupKind } from 'vscode-languageserver-types'; | ||
import { Position, Range, MarkupContent, MarkupKind, DocumentUri } from 'vscode-languageserver-types'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export * from 'vscode-languageserver-types'; | ||
export interface HTMLFormatConfiguration { | ||
@@ -88,3 +90,3 @@ tabSize?: number; | ||
export interface DocumentContext { | ||
resolveReference(ref: string, base?: string): string | undefined; | ||
resolveReference(ref: string, base: string): string | undefined; | ||
} | ||
@@ -187,2 +189,8 @@ export interface HtmlAttributeValueContext { | ||
/** | ||
* Unless set to false, the default HTML data provider will be used | ||
* along with the providers from customDataProviders. | ||
* Defaults to true. | ||
*/ | ||
useDefaultDataProvider?: boolean; | ||
/** | ||
* Provide data that could enhance the service's understanding of | ||
@@ -193,2 +201,7 @@ * HTML tag / attribute / attribute-value | ||
/** | ||
* Abstract file system access away from the service. | ||
* Used for path completion, etc. | ||
*/ | ||
fileSystemProvider?: FileSystemProvider; | ||
/** | ||
* Describes the LSP capabilities the client supports. | ||
@@ -198,1 +211,42 @@ */ | ||
} | ||
export declare enum FileType { | ||
/** | ||
* The file type is unknown. | ||
*/ | ||
Unknown = 0, | ||
/** | ||
* A regular file. | ||
*/ | ||
File = 1, | ||
/** | ||
* A directory. | ||
*/ | ||
Directory = 2, | ||
/** | ||
* A symbolic link to a file. | ||
*/ | ||
SymbolicLink = 64 | ||
} | ||
export interface FileStat { | ||
/** | ||
* The type of the file, e.g. is a regular file, a directory, or symbolic link | ||
* to a file. | ||
*/ | ||
type: FileType; | ||
/** | ||
* The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
*/ | ||
ctime: number; | ||
/** | ||
* The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
*/ | ||
mtime: number; | ||
/** | ||
* The size in bytes. | ||
*/ | ||
size: number; | ||
} | ||
export interface FileSystemProvider { | ||
stat(uri: DocumentUri): Promise<FileStat>; | ||
readDirectory?(uri: DocumentUri): Promise<[string, FileType][]>; | ||
} |
@@ -6,2 +6,4 @@ /*--------------------------------------------------------------------------------------------- | ||
import { MarkupKind } from 'vscode-languageserver-types'; | ||
export { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export * from 'vscode-languageserver-types'; | ||
export var TokenType; | ||
@@ -61,1 +63,20 @@ (function (TokenType) { | ||
})(ClientCapabilities || (ClientCapabilities = {})); | ||
export var FileType; | ||
(function (FileType) { | ||
/** | ||
* The file type is unknown. | ||
*/ | ||
FileType[FileType["Unknown"] = 0] = "Unknown"; | ||
/** | ||
* A regular file. | ||
*/ | ||
FileType[FileType["File"] = 1] = "File"; | ||
/** | ||
* A directory. | ||
*/ | ||
FileType[FileType["Directory"] = 2] = "Directory"; | ||
/** | ||
* A symbolic link to a file. | ||
*/ | ||
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink"; | ||
})(FileType || (FileType = {})); |
@@ -5,2 +5,38 @@ /*--------------------------------------------------------------------------------------------- | ||
*--------------------------------------------------------------------------------------------*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
import { Position, CompletionItemKind, Range, TextEdit, InsertTextFormat, MarkupKind } from 'vscode-languageserver-types'; | ||
@@ -12,10 +48,11 @@ import { createScanner } from '../parser/htmlScanner'; | ||
import { isLetterOrDigit, endsWith, startsWith } from '../utils/strings'; | ||
import { getAllDataProviders } from '../languageFacts/builtinDataProviders'; | ||
import { isVoidElement } from '../languageFacts/fact'; | ||
import { isDefined } from '../utils/object'; | ||
import { generateDocumentation } from '../languageFacts/dataProvider'; | ||
import { PathCompletionParticipant } from './pathCompletion'; | ||
var localize = nls.loadMessageBundle(); | ||
var HTMLCompletion = /** @class */ (function () { | ||
function HTMLCompletion(clientCapabilities) { | ||
this.clientCapabilities = clientCapabilities; | ||
function HTMLCompletion(lsOptions, dataManager) { | ||
this.lsOptions = lsOptions; | ||
this.dataManager = dataManager; | ||
this.completionParticipants = []; | ||
@@ -26,2 +63,33 @@ } | ||
}; | ||
HTMLCompletion.prototype.doComplete2 = function (document, position, htmlDocument, documentContext, settings) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var participant, contributedParticipants, result, pathCompletionResult; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!this.lsOptions.fileSystemProvider || !this.lsOptions.fileSystemProvider.readDirectory) { | ||
return [2 /*return*/, this.doComplete(document, position, htmlDocument, settings)]; | ||
} | ||
participant = new PathCompletionParticipant(this.lsOptions.fileSystemProvider.readDirectory); | ||
contributedParticipants = this.completionParticipants; | ||
this.completionParticipants = [participant].concat(contributedParticipants); | ||
result = this.doComplete(document, position, htmlDocument, settings); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, , 3, 4]); | ||
return [4 /*yield*/, participant.computeCompletions(document, documentContext)]; | ||
case 2: | ||
pathCompletionResult = _a.sent(); | ||
return [2 /*return*/, { | ||
isIncomplete: result.isIncomplete || pathCompletionResult.isIncomplete, | ||
items: pathCompletionResult.items.concat(result.items) | ||
}]; | ||
case 3: | ||
this.completionParticipants = contributedParticipants; | ||
return [7 /*endfinally*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HTMLCompletion.prototype.doComplete = function (document, position, htmlDocument, settings) { | ||
@@ -37,3 +105,3 @@ var result = this._doComplete(document, position, htmlDocument, settings); | ||
var completionParticipants = this.completionParticipants; | ||
var dataProviders = getAllDataProviders().filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var dataProviders = this.dataManager.getDataProviders().filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var doesSupportMarkdown = this.doesSupportMarkdown(); | ||
@@ -468,9 +536,10 @@ var text = document.getText(); | ||
HTMLCompletion.prototype.doesSupportMarkdown = function () { | ||
var _a, _b, _c; | ||
if (!isDefined(this.supportsMarkdown)) { | ||
if (!isDefined(this.clientCapabilities)) { | ||
if (!isDefined(this.lsOptions.clientCapabilities)) { | ||
this.supportsMarkdown = true; | ||
return this.supportsMarkdown; | ||
} | ||
var hover = this.clientCapabilities && this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.hover; | ||
this.supportsMarkdown = hover && hover.contentFormat && Array.isArray(hover.contentFormat) && hover.contentFormat.indexOf(MarkupKind.Markdown) !== -1; | ||
var documentationFormat = (_c = (_b = (_a = this.lsOptions.clientCapabilities.textDocument) === null || _a === void 0 ? void 0 : _a.completion) === null || _b === void 0 ? void 0 : _b.completionItem) === null || _c === void 0 ? void 0 : _c.documentationFormat; | ||
this.supportsMarkdown = Array.isArray(documentationFormat) && documentationFormat.indexOf(MarkupKind.Markdown) !== -1; | ||
} | ||
@@ -477,0 +546,0 @@ return this.supportsMarkdown; |
@@ -8,8 +8,8 @@ /*--------------------------------------------------------------------------------------------- | ||
import { TokenType } from '../htmlLanguageTypes'; | ||
import { getAllDataProviders } from '../languageFacts/builtinDataProviders'; | ||
import { isDefined } from '../utils/object'; | ||
import { generateDocumentation } from '../languageFacts/dataProvider'; | ||
var HTMLHover = /** @class */ (function () { | ||
function HTMLHover(clientCapabilities) { | ||
this.clientCapabilities = clientCapabilities; | ||
function HTMLHover(lsOptions, dataManager) { | ||
this.lsOptions = lsOptions; | ||
this.dataManager = dataManager; | ||
} | ||
@@ -24,3 +24,3 @@ HTMLHover.prototype.doHover = function (document, position, htmlDocument) { | ||
} | ||
var dataProviders = getAllDataProviders().filter(function (p) { return p.isApplicable(document.languageId); }); | ||
var dataProviders = this.dataManager.getDataProviders().filter(function (p) { return p.isApplicable(document.languageId); }); | ||
function getTagHover(currTag, range, open) { | ||
@@ -40,3 +40,2 @@ currTag = currTag.toLowerCase(); | ||
} | ||
markupContent.value = '```html\n' + tagLabel + '\n```\n' + markupContent.value; | ||
hover = { contents: markupContent, range: range }; | ||
@@ -191,9 +190,10 @@ } | ||
HTMLHover.prototype.doesSupportMarkdown = function () { | ||
var _a, _b, _c; | ||
if (!isDefined(this.supportsMarkdown)) { | ||
if (!isDefined(this.clientCapabilities)) { | ||
if (!isDefined(this.lsOptions.clientCapabilities)) { | ||
this.supportsMarkdown = true; | ||
return this.supportsMarkdown; | ||
} | ||
var hover = this.clientCapabilities && this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.hover; | ||
this.supportsMarkdown = hover && hover.contentFormat && Array.isArray(hover.contentFormat) && hover.contentFormat.indexOf(MarkupKind.Markdown) !== -1; | ||
var contentFormat = (_c = (_b = (_a = this.lsOptions.clientCapabilities) === null || _a === void 0 ? void 0 : _a.textDocument) === null || _b === void 0 ? void 0 : _b.hover) === null || _c === void 0 ? void 0 : _c.contentFormat; | ||
this.supportsMarkdown = Array.isArray(contentFormat) && contentFormat.indexOf(MarkupKind.Markdown) !== -1; | ||
} | ||
@@ -200,0 +200,0 @@ return this.supportsMarkdown; |
@@ -1,8 +0,5 @@ | ||
import { Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, SelectionRange, WorkspaceEdit } from 'vscode-languageserver-types'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions } from './htmlLanguageTypes'; | ||
import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions, TextDocument, SelectionRange, WorkspaceEdit, Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange } from './htmlLanguageTypes'; | ||
export * from './htmlLanguageTypes'; | ||
export { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export * from 'vscode-languageserver-types'; | ||
export interface LanguageService { | ||
setDataProviders(useDefaultDataProvider: boolean, customDataProviders: IHTMLDataProvider[]): void; | ||
createScanner(input: string, initialOffset?: number): Scanner; | ||
@@ -12,2 +9,3 @@ parseHTMLDocument(document: TextDocument): HTMLDocument; | ||
doComplete(document: TextDocument, position: Position, htmlDocument: HTMLDocument, options?: CompletionConfiguration): CompletionList; | ||
doComplete2(document: TextDocument, position: Position, htmlDocument: HTMLDocument, documentContext: DocumentContext, options?: CompletionConfiguration): Promise<CompletionList>; | ||
setCompletionParticipants(registeredCompletionParticipants: ICompletionParticipant[]): void; | ||
@@ -14,0 +12,0 @@ doHover(document: TextDocument, position: Position, htmlDocument: HTMLDocument): Hover | null; |
@@ -11,3 +11,3 @@ /*--------------------------------------------------------------------------------------------- | ||
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/htmlRename", "./services/htmlMatchingTagPosition", "./services/htmlSyncedRegions", "./services/htmlFolding", "./services/htmlSelectionRange", "./languageFacts/builtinDataProviders", "./languageFacts/dataProvider", "./htmlLanguageTypes", "vscode-languageserver-textdocument", "vscode-languageserver-types"], factory); | ||
define(["require", "exports", "./parser/htmlScanner", "./parser/htmlParser", "./services/htmlCompletion", "./services/htmlHover", "./services/htmlFormatter", "./services/htmlLinks", "./services/htmlHighlighting", "./services/htmlSymbolsProvider", "./services/htmlRename", "./services/htmlMatchingTagPosition", "./services/htmlSyncedRegions", "./services/htmlFolding", "./services/htmlSelectionRange", "./languageFacts/dataProvider", "./languageFacts/dataManager", "./htmlLanguageTypes"], factory); | ||
} | ||
@@ -33,18 +33,17 @@ })(function (require, exports) { | ||
var htmlSelectionRange_1 = require("./services/htmlSelectionRange"); | ||
var builtinDataProviders_1 = require("./languageFacts/builtinDataProviders"); | ||
var dataProvider_1 = require("./languageFacts/dataProvider"); | ||
var dataManager_1 = require("./languageFacts/dataManager"); | ||
__export(require("./htmlLanguageTypes")); | ||
var vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument"); | ||
exports.TextDocument = vscode_languageserver_textdocument_1.TextDocument; | ||
__export(require("vscode-languageserver-types")); | ||
var defaultLanguageServiceOptions = {}; | ||
function getLanguageService(options) { | ||
var htmlHover = new htmlHover_1.HTMLHover(options && options.clientCapabilities); | ||
var htmlCompletion = new htmlCompletion_1.HTMLCompletion(options && options.clientCapabilities); | ||
if (options && options.customDataProviders) { | ||
builtinDataProviders_1.handleCustomDataProviders(options.customDataProviders); | ||
} | ||
if (options === void 0) { options = defaultLanguageServiceOptions; } | ||
var dataManager = new dataManager_1.HTMLDataManager(options); | ||
var htmlHover = new htmlHover_1.HTMLHover(options, dataManager); | ||
var htmlCompletion = new htmlCompletion_1.HTMLCompletion(options, dataManager); | ||
return { | ||
setDataProviders: dataManager.setDataProviders.bind(dataManager), | ||
createScanner: htmlScanner_1.createScanner, | ||
parseHTMLDocument: function (document) { return htmlParser_1.parse(document.getText()); }, | ||
doComplete: htmlCompletion.doComplete.bind(htmlCompletion), | ||
doComplete2: htmlCompletion.doComplete2.bind(htmlCompletion), | ||
setCompletionParticipants: htmlCompletion.setCompletionParticipants.bind(htmlCompletion), | ||
@@ -51,0 +50,0 @@ doHover: htmlHover.doHover.bind(htmlHover), |
@@ -1,3 +0,5 @@ | ||
import { Position, Range, MarkupContent, MarkupKind } from 'vscode-languageserver-types'; | ||
import { Position, Range, MarkupContent, MarkupKind, DocumentUri } from 'vscode-languageserver-types'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export * from 'vscode-languageserver-types'; | ||
export interface HTMLFormatConfiguration { | ||
@@ -88,3 +90,3 @@ tabSize?: number; | ||
export interface DocumentContext { | ||
resolveReference(ref: string, base?: string): string | undefined; | ||
resolveReference(ref: string, base: string): string | undefined; | ||
} | ||
@@ -187,2 +189,8 @@ export interface HtmlAttributeValueContext { | ||
/** | ||
* Unless set to false, the default HTML data provider will be used | ||
* along with the providers from customDataProviders. | ||
* Defaults to true. | ||
*/ | ||
useDefaultDataProvider?: boolean; | ||
/** | ||
* Provide data that could enhance the service's understanding of | ||
@@ -193,2 +201,7 @@ * HTML tag / attribute / attribute-value | ||
/** | ||
* Abstract file system access away from the service. | ||
* Used for path completion, etc. | ||
*/ | ||
fileSystemProvider?: FileSystemProvider; | ||
/** | ||
* Describes the LSP capabilities the client supports. | ||
@@ -198,1 +211,42 @@ */ | ||
} | ||
export declare enum FileType { | ||
/** | ||
* The file type is unknown. | ||
*/ | ||
Unknown = 0, | ||
/** | ||
* A regular file. | ||
*/ | ||
File = 1, | ||
/** | ||
* A directory. | ||
*/ | ||
Directory = 2, | ||
/** | ||
* A symbolic link to a file. | ||
*/ | ||
SymbolicLink = 64 | ||
} | ||
export interface FileStat { | ||
/** | ||
* The type of the file, e.g. is a regular file, a directory, or symbolic link | ||
* to a file. | ||
*/ | ||
type: FileType; | ||
/** | ||
* The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
*/ | ||
ctime: number; | ||
/** | ||
* The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
*/ | ||
mtime: number; | ||
/** | ||
* The size in bytes. | ||
*/ | ||
size: number; | ||
} | ||
export interface FileSystemProvider { | ||
stat(uri: DocumentUri): Promise<FileStat>; | ||
readDirectory?(uri: DocumentUri): Promise<[string, FileType][]>; | ||
} |
@@ -11,8 +11,14 @@ /*--------------------------------------------------------------------------------------------- | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "vscode-languageserver-types"], factory); | ||
define(["require", "exports", "vscode-languageserver-types", "vscode-languageserver-textdocument", "vscode-languageserver-types"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var vscode_languageserver_types_1 = require("vscode-languageserver-types"); | ||
var vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument"); | ||
exports.TextDocument = vscode_languageserver_textdocument_1.TextDocument; | ||
__export(require("vscode-languageserver-types")); | ||
var TokenType; | ||
@@ -72,2 +78,21 @@ (function (TokenType) { | ||
})(ClientCapabilities = exports.ClientCapabilities || (exports.ClientCapabilities = {})); | ||
var FileType; | ||
(function (FileType) { | ||
/** | ||
* The file type is unknown. | ||
*/ | ||
FileType[FileType["Unknown"] = 0] = "Unknown"; | ||
/** | ||
* A regular file. | ||
*/ | ||
FileType[FileType["File"] = 1] = "File"; | ||
/** | ||
* A directory. | ||
*/ | ||
FileType[FileType["Directory"] = 2] = "Directory"; | ||
/** | ||
* A symbolic link to a file. | ||
*/ | ||
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink"; | ||
})(FileType = exports.FileType || (exports.FileType = {})); | ||
}); |
@@ -5,2 +5,38 @@ /*--------------------------------------------------------------------------------------------- | ||
*--------------------------------------------------------------------------------------------*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
(function (factory) { | ||
@@ -12,3 +48,3 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "vscode-languageserver-types", "../parser/htmlScanner", "../htmlLanguageTypes", "../parser/htmlEntities", "vscode-nls", "../utils/strings", "../languageFacts/builtinDataProviders", "../languageFacts/fact", "../utils/object", "../languageFacts/dataProvider"], factory); | ||
define(["require", "exports", "vscode-languageserver-types", "../parser/htmlScanner", "../htmlLanguageTypes", "../parser/htmlEntities", "vscode-nls", "../utils/strings", "../languageFacts/fact", "../utils/object", "../languageFacts/dataProvider", "./pathCompletion"], factory); | ||
} | ||
@@ -24,10 +60,11 @@ })(function (require, exports) { | ||
var strings_1 = require("../utils/strings"); | ||
var builtinDataProviders_1 = require("../languageFacts/builtinDataProviders"); | ||
var fact_1 = require("../languageFacts/fact"); | ||
var object_1 = require("../utils/object"); | ||
var dataProvider_1 = require("../languageFacts/dataProvider"); | ||
var pathCompletion_1 = require("./pathCompletion"); | ||
var localize = nls.loadMessageBundle(); | ||
var HTMLCompletion = /** @class */ (function () { | ||
function HTMLCompletion(clientCapabilities) { | ||
this.clientCapabilities = clientCapabilities; | ||
function HTMLCompletion(lsOptions, dataManager) { | ||
this.lsOptions = lsOptions; | ||
this.dataManager = dataManager; | ||
this.completionParticipants = []; | ||
@@ -38,2 +75,33 @@ } | ||
}; | ||
HTMLCompletion.prototype.doComplete2 = function (document, position, htmlDocument, documentContext, settings) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var participant, contributedParticipants, result, pathCompletionResult; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!this.lsOptions.fileSystemProvider || !this.lsOptions.fileSystemProvider.readDirectory) { | ||
return [2 /*return*/, this.doComplete(document, position, htmlDocument, settings)]; | ||
} | ||
participant = new pathCompletion_1.PathCompletionParticipant(this.lsOptions.fileSystemProvider.readDirectory); | ||
contributedParticipants = this.completionParticipants; | ||
this.completionParticipants = [participant].concat(contributedParticipants); | ||
result = this.doComplete(document, position, htmlDocument, settings); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, , 3, 4]); | ||
return [4 /*yield*/, participant.computeCompletions(document, documentContext)]; | ||
case 2: | ||
pathCompletionResult = _a.sent(); | ||
return [2 /*return*/, { | ||
isIncomplete: result.isIncomplete || pathCompletionResult.isIncomplete, | ||
items: pathCompletionResult.items.concat(result.items) | ||
}]; | ||
case 3: | ||
this.completionParticipants = contributedParticipants; | ||
return [7 /*endfinally*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HTMLCompletion.prototype.doComplete = function (document, position, htmlDocument, settings) { | ||
@@ -49,3 +117,3 @@ var result = this._doComplete(document, position, htmlDocument, settings); | ||
var completionParticipants = this.completionParticipants; | ||
var dataProviders = builtinDataProviders_1.getAllDataProviders().filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var dataProviders = this.dataManager.getDataProviders().filter(function (p) { return p.isApplicable(document.languageId) && (!settings || settings[p.getId()] !== false); }); | ||
var doesSupportMarkdown = this.doesSupportMarkdown(); | ||
@@ -480,9 +548,10 @@ var text = document.getText(); | ||
HTMLCompletion.prototype.doesSupportMarkdown = function () { | ||
var _a, _b, _c; | ||
if (!object_1.isDefined(this.supportsMarkdown)) { | ||
if (!object_1.isDefined(this.clientCapabilities)) { | ||
if (!object_1.isDefined(this.lsOptions.clientCapabilities)) { | ||
this.supportsMarkdown = true; | ||
return this.supportsMarkdown; | ||
} | ||
var hover = this.clientCapabilities && this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.hover; | ||
this.supportsMarkdown = hover && hover.contentFormat && Array.isArray(hover.contentFormat) && hover.contentFormat.indexOf(vscode_languageserver_types_1.MarkupKind.Markdown) !== -1; | ||
var documentationFormat = (_c = (_b = (_a = this.lsOptions.clientCapabilities.textDocument) === null || _a === void 0 ? void 0 : _a.completion) === null || _b === void 0 ? void 0 : _b.completionItem) === null || _c === void 0 ? void 0 : _c.documentationFormat; | ||
this.supportsMarkdown = Array.isArray(documentationFormat) && documentationFormat.indexOf(vscode_languageserver_types_1.MarkupKind.Markdown) !== -1; | ||
} | ||
@@ -489,0 +558,0 @@ return this.supportsMarkdown; |
@@ -11,3 +11,3 @@ /*--------------------------------------------------------------------------------------------- | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "../parser/htmlScanner", "vscode-languageserver-types", "../htmlLanguageTypes", "../languageFacts/builtinDataProviders", "../utils/object", "../languageFacts/dataProvider"], factory); | ||
define(["require", "exports", "../parser/htmlScanner", "vscode-languageserver-types", "../htmlLanguageTypes", "../utils/object", "../languageFacts/dataProvider"], factory); | ||
} | ||
@@ -20,8 +20,8 @@ })(function (require, exports) { | ||
var htmlLanguageTypes_1 = require("../htmlLanguageTypes"); | ||
var builtinDataProviders_1 = require("../languageFacts/builtinDataProviders"); | ||
var object_1 = require("../utils/object"); | ||
var dataProvider_1 = require("../languageFacts/dataProvider"); | ||
var HTMLHover = /** @class */ (function () { | ||
function HTMLHover(clientCapabilities) { | ||
this.clientCapabilities = clientCapabilities; | ||
function HTMLHover(lsOptions, dataManager) { | ||
this.lsOptions = lsOptions; | ||
this.dataManager = dataManager; | ||
} | ||
@@ -36,3 +36,3 @@ HTMLHover.prototype.doHover = function (document, position, htmlDocument) { | ||
} | ||
var dataProviders = builtinDataProviders_1.getAllDataProviders().filter(function (p) { return p.isApplicable(document.languageId); }); | ||
var dataProviders = this.dataManager.getDataProviders().filter(function (p) { return p.isApplicable(document.languageId); }); | ||
function getTagHover(currTag, range, open) { | ||
@@ -52,3 +52,2 @@ currTag = currTag.toLowerCase(); | ||
} | ||
markupContent.value = '```html\n' + tagLabel + '\n```\n' + markupContent.value; | ||
hover = { contents: markupContent, range: range }; | ||
@@ -203,9 +202,10 @@ } | ||
HTMLHover.prototype.doesSupportMarkdown = function () { | ||
var _a, _b, _c; | ||
if (!object_1.isDefined(this.supportsMarkdown)) { | ||
if (!object_1.isDefined(this.clientCapabilities)) { | ||
if (!object_1.isDefined(this.lsOptions.clientCapabilities)) { | ||
this.supportsMarkdown = true; | ||
return this.supportsMarkdown; | ||
} | ||
var hover = this.clientCapabilities && this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.hover; | ||
this.supportsMarkdown = hover && hover.contentFormat && Array.isArray(hover.contentFormat) && hover.contentFormat.indexOf(vscode_languageserver_types_1.MarkupKind.Markdown) !== -1; | ||
var contentFormat = (_c = (_b = (_a = this.lsOptions.clientCapabilities) === null || _a === void 0 ? void 0 : _a.textDocument) === null || _b === void 0 ? void 0 : _b.hover) === null || _c === void 0 ? void 0 : _c.contentFormat; | ||
this.supportsMarkdown = Array.isArray(contentFormat) && contentFormat.indexOf(vscode_languageserver_types_1.MarkupKind.Markdown) !== -1; | ||
} | ||
@@ -212,0 +212,0 @@ return this.supportsMarkdown; |
{ | ||
"name": "vscode-html-languageservice", | ||
"version": "3.1.0-next.2", | ||
"version": "3.1.0-next.3", | ||
"description": "Language service for HTML", | ||
@@ -27,9 +27,9 @@ "main": "./lib/umd/htmlLanguageService.js", | ||
"typescript": "^3.8.3", | ||
"vscode-web-custom-data": "^0.1.3" | ||
"vscode-web-custom-data": "^0.1.4" | ||
}, | ||
"dependencies": { | ||
"vscode-languageserver-textdocument": "^1.0.1", | ||
"vscode-languageserver-types": "^3.15.1", | ||
"vscode-languageserver-types": "3.16.0-next.2", | ||
"vscode-nls": "^4.1.2", | ||
"vscode-uri": "^2.1.1" | ||
"vscode-uri": "^2.1.2" | ||
}, | ||
@@ -36,0 +36,0 @@ "scripts": { |
1534015
79
32315
+ Addedvscode-languageserver-types@3.16.0-next.2(transitive)
- Removedvscode-languageserver-types@3.17.5(transitive)
Updatedvscode-uri@^2.1.2