mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
fix #32788
This commit is contained in:
@@ -634,10 +634,12 @@ class SignatureHelpAdapter {
|
||||
class LinkProviderAdapter {
|
||||
|
||||
private _documents: ExtHostDocuments;
|
||||
private _heapService: ExtHostHeapService;
|
||||
private _provider: vscode.DocumentLinkProvider;
|
||||
|
||||
constructor(documents: ExtHostDocuments, provider: vscode.DocumentLinkProvider) {
|
||||
constructor(documents: ExtHostDocuments, heapService: ExtHostHeapService, provider: vscode.DocumentLinkProvider) {
|
||||
this._documents = documents;
|
||||
this._heapService = heapService;
|
||||
this._provider = provider;
|
||||
}
|
||||
|
||||
@@ -645,23 +647,37 @@ class LinkProviderAdapter {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
|
||||
return asWinJsPromise(token => this._provider.provideDocumentLinks(doc, token)).then(links => {
|
||||
if (Array.isArray(links)) {
|
||||
return links.map(TypeConverters.DocumentLink.from);
|
||||
if (!Array.isArray(links)) {
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
const result: modes.ILink[] = [];
|
||||
for (const link of links) {
|
||||
let data = TypeConverters.DocumentLink.from(link);
|
||||
let id = this._heapService.keep(link);
|
||||
ObjectIdentifier.mixin(data, id);
|
||||
result.push(data);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
resolveLink(link: modes.ILink): TPromise<modes.ILink> {
|
||||
if (typeof this._provider.resolveDocumentLink === 'function') {
|
||||
return asWinJsPromise(token => this._provider.resolveDocumentLink(TypeConverters.DocumentLink.to(link), token)).then(value => {
|
||||
if (value) {
|
||||
return TypeConverters.DocumentLink.from(value);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
if (typeof this._provider.resolveDocumentLink !== 'function') {
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
|
||||
const id = ObjectIdentifier.of(link);
|
||||
const item = this._heapService.get<vscode.DocumentLink>(id);
|
||||
if (!item) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return asWinJsPromise(token => this._provider.resolveDocumentLink(item, token)).then(value => {
|
||||
if (value) {
|
||||
return TypeConverters.DocumentLink.from(value);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -993,7 +1009,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
|
||||
|
||||
registerDocumentLinkProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable {
|
||||
const handle = this._nextHandle();
|
||||
this._adapter.set(handle, new LinkProviderAdapter(this._documents, provider));
|
||||
this._adapter.set(handle, new LinkProviderAdapter(this._documents, this._heapService, provider));
|
||||
this._proxy.$registerDocumentLinkProvider(handle, selector);
|
||||
return this._createDisposable(handle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user