mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 13:55:41 +01:00
Enable strict typescript compilation
This commit is contained in:
parent
a33b7cee5a
commit
4f03f6c4bf
12 changed files with 112 additions and 38 deletions
|
|
@ -153,7 +153,7 @@ function toDiagnostics(resource: Uri, diag: lsTypes.Diagnostic): editor.IMarkerD
|
||||||
//#region CompletionAdapter
|
//#region CompletionAdapter
|
||||||
|
|
||||||
export interface ILanguageWorkerWithCompletions {
|
export interface ILanguageWorkerWithCompletions {
|
||||||
doComplete(uri: string, position: lsTypes.Position): Promise<lsTypes.CompletionList>;
|
doComplete(uri: string, position: lsTypes.Position): Promise<lsTypes.CompletionList | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CompletionAdapter<T extends ILanguageWorkerWithCompletions>
|
export class CompletionAdapter<T extends ILanguageWorkerWithCompletions>
|
||||||
|
|
@ -481,7 +481,7 @@ export class DocumentHighlightAdapter<T extends ILanguageWorkerWithDocumentHighl
|
||||||
model: editor.IReadOnlyModel,
|
model: editor.IReadOnlyModel,
|
||||||
position: Position,
|
position: Position,
|
||||||
token: CancellationToken
|
token: CancellationToken
|
||||||
): Promise<languages.DocumentHighlight[]> {
|
): Promise<languages.DocumentHighlight[] | undefined> {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
|
|
@ -501,7 +501,7 @@ export class DocumentHighlightAdapter<T extends ILanguageWorkerWithDocumentHighl
|
||||||
}
|
}
|
||||||
|
|
||||||
function toDocumentHighlightKind(
|
function toDocumentHighlightKind(
|
||||||
kind: lsTypes.DocumentHighlightKind
|
kind: lsTypes.DocumentHighlightKind | undefined
|
||||||
): languages.DocumentHighlightKind {
|
): languages.DocumentHighlightKind {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case lsTypes.DocumentHighlightKind.Read:
|
case lsTypes.DocumentHighlightKind.Read:
|
||||||
|
|
@ -519,7 +519,7 @@ function toDocumentHighlightKind(
|
||||||
//#region DefinitionAdapter
|
//#region DefinitionAdapter
|
||||||
|
|
||||||
export interface ILanguageWorkerWithDefinitions {
|
export interface ILanguageWorkerWithDefinitions {
|
||||||
findDefinition(uri: string, position: lsTypes.Position): Promise<lsTypes.Location>;
|
findDefinition(uri: string, position: lsTypes.Position): Promise<lsTypes.Location | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DefinitionAdapter<T extends ILanguageWorkerWithDefinitions>
|
export class DefinitionAdapter<T extends ILanguageWorkerWithDefinitions>
|
||||||
|
|
@ -531,7 +531,7 @@ export class DefinitionAdapter<T extends ILanguageWorkerWithDefinitions>
|
||||||
model: editor.IReadOnlyModel,
|
model: editor.IReadOnlyModel,
|
||||||
position: Position,
|
position: Position,
|
||||||
token: CancellationToken
|
token: CancellationToken
|
||||||
): Promise<languages.Definition> {
|
): Promise<languages.Definition | undefined> {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
|
|
@ -572,7 +572,7 @@ export class ReferenceAdapter<T extends ILanguageWorkerWithReferences>
|
||||||
position: Position,
|
position: Position,
|
||||||
context: languages.ReferenceContext,
|
context: languages.ReferenceContext,
|
||||||
token: CancellationToken
|
token: CancellationToken
|
||||||
): Promise<languages.Location[]> {
|
): Promise<languages.Location[] | undefined> {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
|
|
@ -597,7 +597,7 @@ export interface ILanguageWorkerWithRename {
|
||||||
uri: string,
|
uri: string,
|
||||||
position: lsTypes.Position,
|
position: lsTypes.Position,
|
||||||
newName: string
|
newName: string
|
||||||
): Promise<lsTypes.WorkspaceEdit>;
|
): Promise<lsTypes.WorkspaceEdit | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RenameAdapter<T extends ILanguageWorkerWithRename>
|
export class RenameAdapter<T extends ILanguageWorkerWithRename>
|
||||||
|
|
@ -610,7 +610,7 @@ export class RenameAdapter<T extends ILanguageWorkerWithRename>
|
||||||
position: Position,
|
position: Position,
|
||||||
newName: string,
|
newName: string,
|
||||||
token: CancellationToken
|
token: CancellationToken
|
||||||
): Promise<languages.WorkspaceEdit> {
|
): Promise<languages.WorkspaceEdit | undefined> {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
|
|
@ -623,7 +623,7 @@ export class RenameAdapter<T extends ILanguageWorkerWithRename>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toWorkspaceEdit(edit: lsTypes.WorkspaceEdit): languages.WorkspaceEdit {
|
function toWorkspaceEdit(edit: lsTypes.WorkspaceEdit | null): languages.WorkspaceEdit | undefined {
|
||||||
if (!edit || !edit.changes) {
|
if (!edit || !edit.changes) {
|
||||||
return void 0;
|
return void 0;
|
||||||
}
|
}
|
||||||
|
|
@ -743,7 +743,7 @@ export class DocumentLinkAdapter<T extends ILanguageWorkerWithDocumentLinks>
|
||||||
public provideLinks(
|
public provideLinks(
|
||||||
model: editor.IReadOnlyModel,
|
model: editor.IReadOnlyModel,
|
||||||
token: CancellationToken
|
token: CancellationToken
|
||||||
): Promise<languages.ILinksList> {
|
): Promise<languages.ILinksList | undefined> {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,6 @@ function asDisposable(disposables: IDisposable[]): IDisposable {
|
||||||
|
|
||||||
function disposeAll(disposables: IDisposable[]) {
|
function disposeAll(disposables: IDisposable[]) {
|
||||||
while (disposables.length) {
|
while (disposables.length) {
|
||||||
disposables.pop().dispose();
|
disposables.pop()!.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,26 +61,44 @@ export class CSSWorker {
|
||||||
}
|
}
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
async doComplete(uri: string, position: cssService.Position): Promise<cssService.CompletionList> {
|
async doComplete(
|
||||||
|
uri: string,
|
||||||
|
position: cssService.Position
|
||||||
|
): Promise<cssService.CompletionList | null> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let completions = this._languageService.doComplete(document, position, stylesheet);
|
let completions = this._languageService.doComplete(document, position, stylesheet);
|
||||||
return Promise.resolve(completions);
|
return Promise.resolve(completions);
|
||||||
}
|
}
|
||||||
async doHover(uri: string, position: cssService.Position): Promise<cssService.Hover> {
|
async doHover(uri: string, position: cssService.Position): Promise<cssService.Hover | null> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let hover = this._languageService.doHover(document, position, stylesheet);
|
let hover = this._languageService.doHover(document, position, stylesheet);
|
||||||
return Promise.resolve(hover);
|
return Promise.resolve(hover);
|
||||||
}
|
}
|
||||||
async findDefinition(uri: string, position: cssService.Position): Promise<cssService.Location> {
|
async findDefinition(
|
||||||
|
uri: string,
|
||||||
|
position: cssService.Position
|
||||||
|
): Promise<cssService.Location | null> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let definition = this._languageService.findDefinition(document, position, stylesheet);
|
let definition = this._languageService.findDefinition(document, position, stylesheet);
|
||||||
return Promise.resolve(definition);
|
return Promise.resolve(definition);
|
||||||
}
|
}
|
||||||
async findReferences(uri: string, position: cssService.Position): Promise<cssService.Location[]> {
|
async findReferences(uri: string, position: cssService.Position): Promise<cssService.Location[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let references = this._languageService.findReferences(document, position, stylesheet);
|
let references = this._languageService.findReferences(document, position, stylesheet);
|
||||||
return Promise.resolve(references);
|
return Promise.resolve(references);
|
||||||
|
|
@ -90,12 +108,18 @@ export class CSSWorker {
|
||||||
position: cssService.Position
|
position: cssService.Position
|
||||||
): Promise<cssService.DocumentHighlight[]> {
|
): Promise<cssService.DocumentHighlight[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let highlights = this._languageService.findDocumentHighlights(document, position, stylesheet);
|
let highlights = this._languageService.findDocumentHighlights(document, position, stylesheet);
|
||||||
return Promise.resolve(highlights);
|
return Promise.resolve(highlights);
|
||||||
}
|
}
|
||||||
async findDocumentSymbols(uri: string): Promise<cssService.SymbolInformation[]> {
|
async findDocumentSymbols(uri: string): Promise<cssService.SymbolInformation[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let symbols = this._languageService.findDocumentSymbols(document, stylesheet);
|
let symbols = this._languageService.findDocumentSymbols(document, stylesheet);
|
||||||
return Promise.resolve(symbols);
|
return Promise.resolve(symbols);
|
||||||
|
|
@ -106,12 +130,18 @@ export class CSSWorker {
|
||||||
context: cssService.CodeActionContext
|
context: cssService.CodeActionContext
|
||||||
): Promise<cssService.Command[]> {
|
): Promise<cssService.Command[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let actions = this._languageService.doCodeActions(document, range, context, stylesheet);
|
let actions = this._languageService.doCodeActions(document, range, context, stylesheet);
|
||||||
return Promise.resolve(actions);
|
return Promise.resolve(actions);
|
||||||
}
|
}
|
||||||
async findDocumentColors(uri: string): Promise<cssService.ColorInformation[]> {
|
async findDocumentColors(uri: string): Promise<cssService.ColorInformation[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let colorSymbols = this._languageService.findDocumentColors(document, stylesheet);
|
let colorSymbols = this._languageService.findDocumentColors(document, stylesheet);
|
||||||
return Promise.resolve(colorSymbols);
|
return Promise.resolve(colorSymbols);
|
||||||
|
|
@ -122,6 +152,9 @@ export class CSSWorker {
|
||||||
range: cssService.Range
|
range: cssService.Range
|
||||||
): Promise<cssService.ColorPresentation[]> {
|
): Promise<cssService.ColorPresentation[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let colorPresentations = this._languageService.getColorPresentations(
|
let colorPresentations = this._languageService.getColorPresentations(
|
||||||
document,
|
document,
|
||||||
|
|
@ -136,6 +169,9 @@ export class CSSWorker {
|
||||||
context?: { rangeLimit?: number }
|
context?: { rangeLimit?: number }
|
||||||
): Promise<cssService.FoldingRange[]> {
|
): Promise<cssService.FoldingRange[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let ranges = this._languageService.getFoldingRanges(document, context);
|
let ranges = this._languageService.getFoldingRanges(document, context);
|
||||||
return Promise.resolve(ranges);
|
return Promise.resolve(ranges);
|
||||||
}
|
}
|
||||||
|
|
@ -144,6 +180,9 @@ export class CSSWorker {
|
||||||
positions: cssService.Position[]
|
positions: cssService.Position[]
|
||||||
): Promise<cssService.SelectionRange[]> {
|
): Promise<cssService.SelectionRange[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let ranges = this._languageService.getSelectionRanges(document, positions, stylesheet);
|
let ranges = this._languageService.getSelectionRanges(document, positions, stylesheet);
|
||||||
return Promise.resolve(ranges);
|
return Promise.resolve(ranges);
|
||||||
|
|
@ -152,13 +191,16 @@ export class CSSWorker {
|
||||||
uri: string,
|
uri: string,
|
||||||
position: cssService.Position,
|
position: cssService.Position,
|
||||||
newName: string
|
newName: string
|
||||||
): Promise<cssService.WorkspaceEdit> {
|
): Promise<cssService.WorkspaceEdit | null> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let stylesheet = this._languageService.parseStylesheet(document);
|
let stylesheet = this._languageService.parseStylesheet(document);
|
||||||
let renames = this._languageService.doRename(document, position, newName, stylesheet);
|
let renames = this._languageService.doRename(document, position, newName, stylesheet);
|
||||||
return Promise.resolve(renames);
|
return Promise.resolve(renames);
|
||||||
}
|
}
|
||||||
private _getTextDocument(uri: string): cssService.TextDocument {
|
private _getTextDocument(uri: string): cssService.TextDocument | null {
|
||||||
let models = this._ctx.getMirrorModels();
|
let models = this._ctx.getMirrorModels();
|
||||||
for (let model of models) {
|
for (let model of models) {
|
||||||
if (model.uri.toString() === uri) {
|
if (model.uri.toString() === uri) {
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,8 @@ export type DiagnosticsOptions = Options;
|
||||||
|
|
||||||
class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
||||||
private _onDidChange = new Emitter<LanguageServiceDefaults>();
|
private _onDidChange = new Emitter<LanguageServiceDefaults>();
|
||||||
private _options: Options;
|
private _options!: Options;
|
||||||
private _modeConfiguration: ModeConfiguration;
|
private _modeConfiguration!: ModeConfiguration;
|
||||||
private _languageId: string;
|
private _languageId: string;
|
||||||
|
|
||||||
constructor(languageId: string, options: Options, modeConfiguration: ModeConfiguration) {
|
constructor(languageId: string, options: Options, modeConfiguration: ModeConfiguration) {
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,13 @@ export class WorkerManager {
|
||||||
private _lastUsedTime: number;
|
private _lastUsedTime: number;
|
||||||
private _configChangeListener: IDisposable;
|
private _configChangeListener: IDisposable;
|
||||||
|
|
||||||
private _worker: editor.MonacoWebWorker<CSSWorker>;
|
private _worker: editor.MonacoWebWorker<CSSWorker> | null;
|
||||||
private _client: Promise<CSSWorker>;
|
private _client: Promise<CSSWorker> | null;
|
||||||
|
|
||||||
constructor(defaults: LanguageServiceDefaults) {
|
constructor(defaults: LanguageServiceDefaults) {
|
||||||
this._defaults = defaults;
|
this._defaults = defaults;
|
||||||
this._worker = null;
|
this._worker = null;
|
||||||
|
this._client = null;
|
||||||
this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1000);
|
this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1000);
|
||||||
this._lastUsedTime = 0;
|
this._lastUsedTime = 0;
|
||||||
this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
|
this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
|
||||||
|
|
@ -80,7 +81,9 @@ export class WorkerManager {
|
||||||
_client = client;
|
_client = client;
|
||||||
})
|
})
|
||||||
.then((_) => {
|
.then((_) => {
|
||||||
|
if (this._worker) {
|
||||||
return this._worker.withSyncedResources(resources);
|
return this._worker.withSyncedResources(resources);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then((_) => _client);
|
.then((_) => _client);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,6 @@ function asDisposable(disposables: IDisposable[]): IDisposable {
|
||||||
|
|
||||||
function disposeAll(disposables: IDisposable[]) {
|
function disposeAll(disposables: IDisposable[]) {
|
||||||
while (disposables.length) {
|
while (disposables.length) {
|
||||||
disposables.pop().dispose();
|
disposables.pop()!.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,11 @@ export class HTMLWorker {
|
||||||
async doComplete(
|
async doComplete(
|
||||||
uri: string,
|
uri: string,
|
||||||
position: htmlService.Position
|
position: htmlService.Position
|
||||||
): Promise<htmlService.CompletionList> {
|
): Promise<htmlService.CompletionList | null> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||||
return Promise.resolve(
|
return Promise.resolve(
|
||||||
this._languageService.doComplete(
|
this._languageService.doComplete(
|
||||||
|
|
@ -55,12 +58,18 @@ export class HTMLWorker {
|
||||||
options: htmlService.FormattingOptions
|
options: htmlService.FormattingOptions
|
||||||
): Promise<htmlService.TextEdit[]> {
|
): Promise<htmlService.TextEdit[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let formattingOptions = { ...this._languageSettings.format, ...options };
|
let formattingOptions = { ...this._languageSettings.format, ...options };
|
||||||
let textEdits = this._languageService.format(document, range, formattingOptions);
|
let textEdits = this._languageService.format(document, range, formattingOptions);
|
||||||
return Promise.resolve(textEdits);
|
return Promise.resolve(textEdits);
|
||||||
}
|
}
|
||||||
async doHover(uri: string, position: htmlService.Position): Promise<htmlService.Hover> {
|
async doHover(uri: string, position: htmlService.Position): Promise<htmlService.Hover | null> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||||
let hover = this._languageService.doHover(document, position, htmlDocument);
|
let hover = this._languageService.doHover(document, position, htmlDocument);
|
||||||
return Promise.resolve(hover);
|
return Promise.resolve(hover);
|
||||||
|
|
@ -70,17 +79,26 @@ export class HTMLWorker {
|
||||||
position: htmlService.Position
|
position: htmlService.Position
|
||||||
): Promise<htmlService.DocumentHighlight[]> {
|
): Promise<htmlService.DocumentHighlight[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||||
let highlights = this._languageService.findDocumentHighlights(document, position, htmlDocument);
|
let highlights = this._languageService.findDocumentHighlights(document, position, htmlDocument);
|
||||||
return Promise.resolve(highlights);
|
return Promise.resolve(highlights);
|
||||||
}
|
}
|
||||||
async findDocumentLinks(uri: string): Promise<htmlService.DocumentLink[]> {
|
async findDocumentLinks(uri: string): Promise<htmlService.DocumentLink[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
let links = this._languageService.findDocumentLinks(document, null);
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
let links = this._languageService.findDocumentLinks(document, null! /*TODO@aeschli*/);
|
||||||
return Promise.resolve(links);
|
return Promise.resolve(links);
|
||||||
}
|
}
|
||||||
async findDocumentSymbols(uri: string): Promise<htmlService.SymbolInformation[]> {
|
async findDocumentSymbols(uri: string): Promise<htmlService.SymbolInformation[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||||
let symbols = this._languageService.findDocumentSymbols(document, htmlDocument);
|
let symbols = this._languageService.findDocumentSymbols(document, htmlDocument);
|
||||||
return Promise.resolve(symbols);
|
return Promise.resolve(symbols);
|
||||||
|
|
@ -90,6 +108,9 @@ export class HTMLWorker {
|
||||||
context?: { rangeLimit?: number }
|
context?: { rangeLimit?: number }
|
||||||
): Promise<htmlService.FoldingRange[]> {
|
): Promise<htmlService.FoldingRange[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let ranges = this._languageService.getFoldingRanges(document, context);
|
let ranges = this._languageService.getFoldingRanges(document, context);
|
||||||
return Promise.resolve(ranges);
|
return Promise.resolve(ranges);
|
||||||
}
|
}
|
||||||
|
|
@ -98,6 +119,9 @@ export class HTMLWorker {
|
||||||
positions: htmlService.Position[]
|
positions: htmlService.Position[]
|
||||||
): Promise<htmlService.SelectionRange[]> {
|
): Promise<htmlService.SelectionRange[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let ranges = this._languageService.getSelectionRanges(document, positions);
|
let ranges = this._languageService.getSelectionRanges(document, positions);
|
||||||
return Promise.resolve(ranges);
|
return Promise.resolve(ranges);
|
||||||
}
|
}
|
||||||
|
|
@ -105,13 +129,16 @@ export class HTMLWorker {
|
||||||
uri: string,
|
uri: string,
|
||||||
position: htmlService.Position,
|
position: htmlService.Position,
|
||||||
newName: string
|
newName: string
|
||||||
): Promise<htmlService.WorkspaceEdit> {
|
): Promise<htmlService.WorkspaceEdit | null> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
|
if (!document) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||||
let renames = this._languageService.doRename(document, position, newName, htmlDocument);
|
let renames = this._languageService.doRename(document, position, newName, htmlDocument);
|
||||||
return Promise.resolve(renames);
|
return Promise.resolve(renames);
|
||||||
}
|
}
|
||||||
private _getTextDocument(uri: string): htmlService.TextDocument {
|
private _getTextDocument(uri: string): htmlService.TextDocument | null {
|
||||||
let models = this._ctx.getMirrorModels();
|
let models = this._ctx.getMirrorModels();
|
||||||
for (let model of models) {
|
for (let model of models) {
|
||||||
if (model.uri.toString() === uri) {
|
if (model.uri.toString() === uri) {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export interface HTMLFormatConfiguration {
|
||||||
readonly contentUnformatted: string;
|
readonly contentUnformatted: string;
|
||||||
readonly indentInnerHtml: boolean;
|
readonly indentInnerHtml: boolean;
|
||||||
readonly preserveNewLines: boolean;
|
readonly preserveNewLines: boolean;
|
||||||
readonly maxPreserveNewLines: number;
|
readonly maxPreserveNewLines: number | undefined;
|
||||||
readonly indentHandlebars: boolean;
|
readonly indentHandlebars: boolean;
|
||||||
readonly endWithNewline: boolean;
|
readonly endWithNewline: boolean;
|
||||||
readonly extraLiners: string;
|
readonly extraLiners: string;
|
||||||
|
|
@ -114,8 +114,8 @@ export interface LanguageServiceDefaults {
|
||||||
|
|
||||||
class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
||||||
private _onDidChange = new Emitter<LanguageServiceDefaults>();
|
private _onDidChange = new Emitter<LanguageServiceDefaults>();
|
||||||
private _options: Options;
|
private _options!: Options;
|
||||||
private _modeConfiguration: ModeConfiguration;
|
private _modeConfiguration!: ModeConfiguration;
|
||||||
private _languageId: string;
|
private _languageId: string;
|
||||||
|
|
||||||
constructor(languageId: string, options: Options, modeConfiguration: ModeConfiguration) {
|
constructor(languageId: string, options: Options, modeConfiguration: ModeConfiguration) {
|
||||||
|
|
@ -160,7 +160,7 @@ const formatDefaults: Required<HTMLFormatConfiguration> = {
|
||||||
contentUnformatted: 'pre',
|
contentUnformatted: 'pre',
|
||||||
indentInnerHtml: false,
|
indentInnerHtml: false,
|
||||||
preserveNewLines: true,
|
preserveNewLines: true,
|
||||||
maxPreserveNewLines: null,
|
maxPreserveNewLines: undefined,
|
||||||
indentHandlebars: false,
|
indentHandlebars: false,
|
||||||
endWithNewline: false,
|
endWithNewline: false,
|
||||||
extraLiners: 'head, body, /html',
|
extraLiners: 'head, body, /html',
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,13 @@ export class WorkerManager {
|
||||||
private _lastUsedTime: number;
|
private _lastUsedTime: number;
|
||||||
private _configChangeListener: IDisposable;
|
private _configChangeListener: IDisposable;
|
||||||
|
|
||||||
private _worker: editor.MonacoWebWorker<HTMLWorker>;
|
private _worker: editor.MonacoWebWorker<HTMLWorker> | null;
|
||||||
private _client: Promise<HTMLWorker>;
|
private _client: Promise<HTMLWorker> | null;
|
||||||
|
|
||||||
constructor(defaults: LanguageServiceDefaults) {
|
constructor(defaults: LanguageServiceDefaults) {
|
||||||
this._defaults = defaults;
|
this._defaults = defaults;
|
||||||
this._worker = null;
|
this._worker = null;
|
||||||
|
this._client = null;
|
||||||
this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1000);
|
this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1000);
|
||||||
this._lastUsedTime = 0;
|
this._lastUsedTime = 0;
|
||||||
this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
|
this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"declaration": true,
|
||||||
|
"lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"],
|
||||||
"module": "amd",
|
"module": "amd",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"outDir": "../out/amd",
|
"outDir": "../out/amd",
|
||||||
"declaration": true,
|
"strict": true,
|
||||||
"target": "es5",
|
"target": "es5"
|
||||||
"lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7594,7 +7594,7 @@ declare namespace monaco.languages.html {
|
||||||
readonly contentUnformatted: string;
|
readonly contentUnformatted: string;
|
||||||
readonly indentInnerHtml: boolean;
|
readonly indentInnerHtml: boolean;
|
||||||
readonly preserveNewLines: boolean;
|
readonly preserveNewLines: boolean;
|
||||||
readonly maxPreserveNewLines: number;
|
readonly maxPreserveNewLines: number | undefined;
|
||||||
readonly indentHandlebars: boolean;
|
readonly indentHandlebars: boolean;
|
||||||
readonly endWithNewline: boolean;
|
readonly endWithNewline: boolean;
|
||||||
readonly extraLiners: string;
|
readonly extraLiners: string;
|
||||||
|
|
|
||||||
2
website/typedoc/monaco.d.ts
vendored
2
website/typedoc/monaco.d.ts
vendored
|
|
@ -7594,7 +7594,7 @@ declare namespace monaco.languages.html {
|
||||||
readonly contentUnformatted: string;
|
readonly contentUnformatted: string;
|
||||||
readonly indentInnerHtml: boolean;
|
readonly indentInnerHtml: boolean;
|
||||||
readonly preserveNewLines: boolean;
|
readonly preserveNewLines: boolean;
|
||||||
readonly maxPreserveNewLines: number;
|
readonly maxPreserveNewLines: number | undefined;
|
||||||
readonly indentHandlebars: boolean;
|
readonly indentHandlebars: boolean;
|
||||||
readonly endWithNewline: boolean;
|
readonly endWithNewline: boolean;
|
||||||
readonly extraLiners: string;
|
readonly extraLiners: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue