Clean up structure of markdown extension (#161148)

- Move things related to the client under `client`
- Remove extra abstractions that are no longer used
- Add MdLanguageClient type
This commit is contained in:
Matt Bierner
2022-09-18 22:16:45 -07:00
committed by GitHub
parent f4bf1f30a2
commit d03f015931
17 changed files with 183 additions and 226 deletions

View File

@@ -4,11 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { BaseLanguageClient } from 'vscode-languageclient';
import type * as lsp from 'vscode-languageserver-types';
import * as nls from 'vscode-nls';
import { MdLanguageClient } from '../client/client';
import { Command, CommandManager } from '../commandManager';
import { getReferencesToFileInWorkspace } from '../protocol';
const localize = nls.loadMessageBundle();
@@ -18,7 +17,7 @@ export class FindFileReferencesCommand implements Command {
public readonly id = 'markdown.findAllFileReferences';
constructor(
private readonly client: BaseLanguageClient,
private readonly client: MdLanguageClient,
) { }
public async execute(resource?: vscode.Uri) {
@@ -35,7 +34,7 @@ export class FindFileReferencesCommand implements Command {
location: vscode.ProgressLocation.Window,
title: localize('progress.title', "Finding file references")
}, async (_progress, token) => {
const locations = (await this.client.sendRequest(getReferencesToFileInWorkspace, { uri: resource!.toString() }, token)).map(loc => {
const locations = (await this.client.getReferencesToFileInWorkspace(resource!, token)).map(loc => {
return new vscode.Location(vscode.Uri.parse(loc.uri), convertRange(loc.range));
});
@@ -58,7 +57,7 @@ export function convertRange(range: lsp.Range): vscode.Range {
export function registerFindFileReferenceSupport(
commandManager: CommandManager,
client: BaseLanguageClient,
client: MdLanguageClient,
): vscode.Disposable {
return commandManager.register(new FindFileReferencesCommand(client));
}

View File

@@ -6,9 +6,9 @@
import * as path from 'path';
import * as picomatch from 'picomatch';
import * as vscode from 'vscode';
import { BaseLanguageClient, TextDocumentEdit } from 'vscode-languageclient';
import { TextDocumentEdit } from 'vscode-languageclient';
import * as nls from 'vscode-nls';
import { getEditForFileRenames } from '../protocol';
import { MdLanguageClient } from '../client/client';
import { Delayer } from '../util/async';
import { noopToken } from '../util/cancellation';
import { Disposable } from '../util/dispose';
@@ -40,7 +40,7 @@ class UpdateLinksOnFileRenameHandler extends Disposable {
private readonly _pendingRenames = new Set<RenameAction>();
public constructor(
private readonly client: BaseLanguageClient,
private readonly client: MdLanguageClient,
) {
super();
@@ -200,7 +200,7 @@ class UpdateLinksOnFileRenameHandler extends Disposable {
newUri: vscode.Uri,
token: vscode.CancellationToken,
): Promise<boolean> {
const edit = await this.client.sendRequest(getEditForFileRenames, [{ oldUri: oldUri.toString(), newUri: newUri.toString() }], token);
const edit = await this.client.getEditForFileRenames([{ oldUri: oldUri.toString(), newUri: newUri.toString() }], token);
if (!edit.documentChanges?.length) {
return false;
}
@@ -248,6 +248,6 @@ class UpdateLinksOnFileRenameHandler extends Disposable {
}
}
export function registerUpdateLinksOnRename(client: BaseLanguageClient) {
export function registerUpdateLinksOnRename(client: MdLanguageClient) {
return new UpdateLinksOnFileRenameHandler(client);
}