mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
This change renames the main markdown reference provider class to `MdReferenceComputer` and then uses this to implement a `vscode.ReferenceProvider` This more cleanly splits the VS Code part of the logic from the general reference calculation stuff other providers consume
24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import * as vscode from 'vscode';
|
|
import { Disposable } from '../util/dispose';
|
|
import { SkinnyTextDocument } from '../workspaceContents';
|
|
import { MdReferencesComputer } from './references';
|
|
|
|
export class MdDefinitionProvider extends Disposable implements vscode.DefinitionProvider {
|
|
|
|
constructor(
|
|
private readonly referencesComputer: MdReferencesComputer
|
|
) {
|
|
super();
|
|
}
|
|
|
|
async provideDefinition(document: SkinnyTextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Definition | undefined> {
|
|
const allRefs = await this.referencesComputer.getReferencesAtPosition(document, position, token);
|
|
|
|
return allRefs.find(ref => ref.kind === 'link' && ref.isDefinition)?.location;
|
|
}
|
|
}
|