提交 9e867994 编写于 作者: J Johannes Rieken

fix #32788

上级 83ac7b4e
...@@ -265,7 +265,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -265,7 +265,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerDocumentLinkProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any> { $registerDocumentLinkProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
this._registrations[handle] = modes.LinkProviderRegistry.register(selector, <modes.LinkProvider>{ this._registrations[handle] = modes.LinkProviderRegistry.register(selector, <modes.LinkProvider>{
provideLinks: (model, token) => { provideLinks: (model, token) => {
return wireCancellationToken(token, this._proxy.$provideDocumentLinks(handle, model.uri)); return this._heapService.trackRecursive(wireCancellationToken(token, this._proxy.$provideDocumentLinks(handle, model.uri)));
}, },
resolveLink: (link, token) => { resolveLink: (link, token) => {
return wireCancellationToken(token, this._proxy.$resolveDocumentLink(handle, link)); return wireCancellationToken(token, this._proxy.$resolveDocumentLink(handle, link));
......
...@@ -634,10 +634,12 @@ class SignatureHelpAdapter { ...@@ -634,10 +634,12 @@ class SignatureHelpAdapter {
class LinkProviderAdapter { class LinkProviderAdapter {
private _documents: ExtHostDocuments; private _documents: ExtHostDocuments;
private _heapService: ExtHostHeapService;
private _provider: vscode.DocumentLinkProvider; private _provider: vscode.DocumentLinkProvider;
constructor(documents: ExtHostDocuments, provider: vscode.DocumentLinkProvider) { constructor(documents: ExtHostDocuments, heapService: ExtHostHeapService, provider: vscode.DocumentLinkProvider) {
this._documents = documents; this._documents = documents;
this._heapService = heapService;
this._provider = provider; this._provider = provider;
} }
...@@ -645,23 +647,37 @@ class LinkProviderAdapter { ...@@ -645,23 +647,37 @@ class LinkProviderAdapter {
const doc = this._documents.getDocumentData(resource).document; const doc = this._documents.getDocumentData(resource).document;
return asWinJsPromise(token => this._provider.provideDocumentLinks(doc, token)).then(links => { return asWinJsPromise(token => this._provider.provideDocumentLinks(doc, token)).then(links => {
if (Array.isArray(links)) { if (!Array.isArray(links)) {
return links.map(TypeConverters.DocumentLink.from); 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> { resolveLink(link: modes.ILink): TPromise<modes.ILink> {
if (typeof this._provider.resolveDocumentLink === 'function') { if (typeof this._provider.resolveDocumentLink !== 'function') {
return asWinJsPromise(token => this._provider.resolveDocumentLink(TypeConverters.DocumentLink.to(link), token)).then(value => { return undefined;
if (value) {
return TypeConverters.DocumentLink.from(value);
}
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 { ...@@ -993,7 +1009,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
registerDocumentLinkProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable { registerDocumentLinkProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable {
const handle = this._nextHandle(); 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); this._proxy.$registerDocumentLinkProvider(handle, selector);
return this._createDisposable(handle); return this._createDisposable(handle);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册