mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
Adopt new editor, bump TypeScript
This commit is contained in:
parent
e054e6cb4c
commit
27f5823a7e
8 changed files with 238774 additions and 232347 deletions
|
|
@ -177,7 +177,7 @@ export class DiagnostcsAdapter extends Adapter {
|
|||
.map(d => this._convertDiagnostics(resource, d));
|
||||
|
||||
monaco.editor.setModelMarkers(monaco.editor.getModel(resource), this._selector, markers);
|
||||
}).done(undefined, err => {
|
||||
}).then(undefined, err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
|
@ -210,12 +210,12 @@ export class SuggestAdapter extends Adapter implements monaco.languages.Completi
|
|||
return ['.'];
|
||||
}
|
||||
|
||||
provideCompletionItems(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.CompletionItem[]> {
|
||||
provideCompletionItems(model: monaco.editor.IReadOnlyModel, position: Position, _context: monaco.languages.CompletionContext, token: CancellationToken): Thenable<monaco.languages.CompletionList> {
|
||||
const wordInfo = model.getWordUntilPosition(position);
|
||||
const resource = model.uri;
|
||||
const offset = this._positionToOffset(resource, position);
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getCompletionsAtPosition(resource.toString(), offset);
|
||||
}).then(info => {
|
||||
if (!info) {
|
||||
|
|
@ -226,21 +226,24 @@ export class SuggestAdapter extends Adapter implements monaco.languages.Completi
|
|||
uri: resource,
|
||||
position: position,
|
||||
label: entry.name,
|
||||
insertText: entry.name,
|
||||
sortText: entry.sortText,
|
||||
kind: SuggestAdapter.convertKind(entry.kind)
|
||||
};
|
||||
});
|
||||
|
||||
return suggestions;
|
||||
}));
|
||||
return {
|
||||
suggestions
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
resolveCompletionItem(item: monaco.languages.CompletionItem, token: CancellationToken): Thenable<monaco.languages.CompletionItem> {
|
||||
resolveCompletionItem(_model: monaco.editor.IReadOnlyModel, _position: Position, item: monaco.languages.CompletionItem, token: CancellationToken): Thenable<monaco.languages.CompletionItem> {
|
||||
let myItem = <MyCompletionItem>item;
|
||||
const resource = myItem.uri;
|
||||
const position = myItem.position;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getCompletionEntryDetails(resource.toString(),
|
||||
this._positionToOffset(resource, position),
|
||||
myItem.label);
|
||||
|
|
@ -259,7 +262,7 @@ export class SuggestAdapter extends Adapter implements monaco.languages.Completi
|
|||
value: displayPartsToString(details.documentation)
|
||||
}
|
||||
};
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
private static convertKind(kind: string): monaco.languages.CompletionItemKind {
|
||||
|
|
@ -302,7 +305,7 @@ export class SignatureHelpAdapter extends Adapter implements monaco.languages.Si
|
|||
|
||||
provideSignatureHelp(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.SignatureHelp> {
|
||||
let resource = model.uri;
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => worker.getSignatureHelpItems(resource.toString(), this._positionToOffset(resource, position))).then(info => {
|
||||
return this._worker(resource).then(worker => worker.getSignatureHelpItems(resource.toString(), this._positionToOffset(resource, position))).then(info => {
|
||||
|
||||
if (!info) {
|
||||
return;
|
||||
|
|
@ -341,7 +344,7 @@ export class SignatureHelpAdapter extends Adapter implements monaco.languages.Si
|
|||
|
||||
return ret;
|
||||
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -352,7 +355,7 @@ export class QuickInfoAdapter extends Adapter implements monaco.languages.HoverP
|
|||
provideHover(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.Hover> {
|
||||
let resource = model.uri;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getQuickInfoAtPosition(resource.toString(), this._positionToOffset(resource, position));
|
||||
}).then(info => {
|
||||
if (!info) {
|
||||
|
|
@ -376,7 +379,7 @@ export class QuickInfoAdapter extends Adapter implements monaco.languages.HoverP
|
|||
value: documentation + (tags ? '\n\n' + tags : '')
|
||||
}]
|
||||
};
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -387,7 +390,7 @@ export class OccurrencesAdapter extends Adapter implements monaco.languages.Docu
|
|||
public provideDocumentHighlights(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.DocumentHighlight[]> {
|
||||
const resource = model.uri;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getOccurrencesAtPosition(resource.toString(), this._positionToOffset(resource, position));
|
||||
}).then(entries => {
|
||||
if (!entries) {
|
||||
|
|
@ -399,7 +402,7 @@ export class OccurrencesAdapter extends Adapter implements monaco.languages.Docu
|
|||
kind: entry.isWriteAccess ? monaco.languages.DocumentHighlightKind.Write : monaco.languages.DocumentHighlightKind.Text
|
||||
};
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -410,7 +413,7 @@ export class DefinitionAdapter extends Adapter {
|
|||
public provideDefinition(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.Definition> {
|
||||
const resource = model.uri;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getDefinitionAtPosition(resource.toString(), this._positionToOffset(resource, position));
|
||||
}).then(entries => {
|
||||
if (!entries) {
|
||||
|
|
@ -427,7 +430,7 @@ export class DefinitionAdapter extends Adapter {
|
|||
}
|
||||
}
|
||||
return result;
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -438,7 +441,7 @@ export class ReferenceAdapter extends Adapter implements monaco.languages.Refere
|
|||
provideReferences(model: monaco.editor.IReadOnlyModel, position: Position, context: monaco.languages.ReferenceContext, token: CancellationToken): Thenable<monaco.languages.Location[]> {
|
||||
const resource = model.uri;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getReferencesAtPosition(resource.toString(), this._positionToOffset(resource, position));
|
||||
}).then(entries => {
|
||||
if (!entries) {
|
||||
|
|
@ -455,7 +458,7 @@ export class ReferenceAdapter extends Adapter implements monaco.languages.Refere
|
|||
}
|
||||
}
|
||||
return result;
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -466,7 +469,7 @@ export class OutlineAdapter extends Adapter implements monaco.languages.Document
|
|||
public provideDocumentSymbols(model: monaco.editor.IReadOnlyModel, token: CancellationToken): Thenable<monaco.languages.DocumentSymbol[]> {
|
||||
const resource = model.uri;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => worker.getNavigationBarItems(resource.toString())).then(items => {
|
||||
return this._worker(resource).then(worker => worker.getNavigationBarItems(resource.toString())).then(items => {
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -493,7 +496,7 @@ export class OutlineAdapter extends Adapter implements monaco.languages.Document
|
|||
let result: monaco.languages.DocumentSymbol[] = [];
|
||||
items.forEach(item => convert(result, item));
|
||||
return result;
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -580,7 +583,7 @@ export class FormatAdapter extends FormatHelper implements monaco.languages.Docu
|
|||
provideDocumentRangeFormattingEdits(model: monaco.editor.IReadOnlyModel, range: Range, options: monaco.languages.FormattingOptions, token: CancellationToken): Thenable<monaco.editor.ISingleEditOperation[]> {
|
||||
const resource = model.uri;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getFormattingEditsForRange(resource.toString(),
|
||||
this._positionToOffset(resource, { lineNumber: range.startLineNumber, column: range.startColumn }),
|
||||
this._positionToOffset(resource, { lineNumber: range.endLineNumber, column: range.endColumn }),
|
||||
|
|
@ -589,7 +592,7 @@ export class FormatAdapter extends FormatHelper implements monaco.languages.Docu
|
|||
if (edits) {
|
||||
return edits.map(edit => this._convertTextChanges(resource, edit));
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -602,7 +605,7 @@ export class FormatOnTypeAdapter extends FormatHelper implements monaco.language
|
|||
provideOnTypeFormattingEdits(model: monaco.editor.IReadOnlyModel, position: Position, ch: string, options: monaco.languages.FormattingOptions, token: CancellationToken): Thenable<monaco.editor.ISingleEditOperation[]> {
|
||||
const resource = model.uri;
|
||||
|
||||
return wireCancellationToken(token, this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then(worker => {
|
||||
return worker.getFormattingEditsAfterKeystroke(resource.toString(),
|
||||
this._positionToOffset(resource, position),
|
||||
ch, FormatHelper._convertOptions(options));
|
||||
|
|
@ -610,14 +613,6 @@ export class FormatOnTypeAdapter extends FormatHelper implements monaco.language
|
|||
if (edits) {
|
||||
return edits.map(edit => this._convertTextChanges(resource, edit));
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook a cancellation token to a WinJS Promise
|
||||
*/
|
||||
function wireCancellationToken<T>(token: CancellationToken, promise: Promise<T>): Thenable<T> {
|
||||
token.onCancellationRequested(() => promise.cancel());
|
||||
return promise;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue