mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Move DocumentLinkAdapter to /common/
This commit is contained in:
parent
81023950c6
commit
89d05c5889
3 changed files with 44 additions and 28 deletions
|
|
@ -463,7 +463,7 @@ function toMarkedStringArray(
|
|||
|
||||
//#endregion
|
||||
|
||||
//#region
|
||||
//#region DocumentHighlightAdapter
|
||||
|
||||
export interface ILanguageWorkerWithDocumentHighlights {
|
||||
findDocumentHighlights(
|
||||
|
|
@ -728,3 +728,38 @@ function toSymbolKind(kind: lsTypes.SymbolKind): languages.SymbolKind {
|
|||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region DocumentLinkAdapter
|
||||
|
||||
export interface ILanguageWorkerWithDocumentLinks {
|
||||
findDocumentLinks(uri: string): Promise<lsTypes.DocumentLink[]>;
|
||||
}
|
||||
|
||||
export class DocumentLinkAdapter<T extends ILanguageWorkerWithDocumentLinks>
|
||||
implements languages.LinkProvider
|
||||
{
|
||||
constructor(private _worker: WorkerAccessor<T>) {}
|
||||
|
||||
public provideLinks(
|
||||
model: editor.IReadOnlyModel,
|
||||
token: CancellationToken
|
||||
): Promise<languages.ILinksList> {
|
||||
const resource = model.uri;
|
||||
|
||||
return this._worker(resource)
|
||||
.then((worker) => worker.findDocumentLinks(resource.toString()))
|
||||
.then((items) => {
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
links: items.map((item) => ({
|
||||
range: toRange(item.range),
|
||||
url: item.target
|
||||
}))
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue