mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
vscode refactoring: use more laconic export snytax, split huge string to several lines
This commit is contained in:
parent
e72771ebc6
commit
8184752470
3 changed files with 17 additions and 32 deletions
|
@ -4,22 +4,22 @@ import * as lc from 'vscode-languageclient';
|
|||
import { Ctx, Cmd } from '../ctx';
|
||||
import * as sourceChange from '../source_change';
|
||||
|
||||
import { analyzerStatus } from './analyzer_status';
|
||||
import { matchingBrace } from './matching_brace';
|
||||
import { joinLines } from './join_lines';
|
||||
import { onEnter } from './on_enter';
|
||||
import { parentModule } from './parent_module';
|
||||
import { syntaxTree } from './syntax_tree';
|
||||
import { expandMacro } from './expand_macro';
|
||||
import { run, runSingle } from './runnables';
|
||||
export * from './analyzer_status';
|
||||
export * from './matching_brace';
|
||||
export * from './join_lines';
|
||||
export * from './on_enter';
|
||||
export * from './parent_module';
|
||||
export * from './syntax_tree';
|
||||
export * from './expand_macro';
|
||||
export * from './runnables';
|
||||
|
||||
function collectGarbage(ctx: Ctx): Cmd {
|
||||
export function collectGarbage(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null);
|
||||
};
|
||||
}
|
||||
|
||||
function showReferences(ctx: Ctx): Cmd {
|
||||
export function showReferences(ctx: Ctx): Cmd {
|
||||
return (uri: string, position: lc.Position, locations: lc.Location[]) => {
|
||||
const client = ctx.client;
|
||||
if (client) {
|
||||
|
@ -33,13 +33,13 @@ function showReferences(ctx: Ctx): Cmd {
|
|||
};
|
||||
}
|
||||
|
||||
function applySourceChange(ctx: Ctx): Cmd {
|
||||
export function applySourceChange(ctx: Ctx): Cmd {
|
||||
return async (change: sourceChange.SourceChange) => {
|
||||
sourceChange.applySourceChange(ctx, change);
|
||||
};
|
||||
}
|
||||
|
||||
function selectAndApplySourceChange(ctx: Ctx): Cmd {
|
||||
export function selectAndApplySourceChange(ctx: Ctx): Cmd {
|
||||
return async (changes: sourceChange.SourceChange[]) => {
|
||||
if (changes.length === 1) {
|
||||
await sourceChange.applySourceChange(ctx, changes[0]);
|
||||
|
@ -51,26 +51,9 @@ function selectAndApplySourceChange(ctx: Ctx): Cmd {
|
|||
};
|
||||
}
|
||||
|
||||
function reload(ctx: Ctx): Cmd {
|
||||
export function reload(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
vscode.window.showInformationMessage('Reloading rust-analyzer...');
|
||||
await ctx.restartServer();
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
analyzerStatus,
|
||||
expandMacro,
|
||||
joinLines,
|
||||
matchingBrace,
|
||||
parentModule,
|
||||
syntaxTree,
|
||||
onEnter,
|
||||
collectGarbage,
|
||||
run,
|
||||
runSingle,
|
||||
showReferences,
|
||||
applySourceChange,
|
||||
selectAndApplySourceChange,
|
||||
reload
|
||||
};
|
||||
|
|
|
@ -66,7 +66,9 @@ export class Ctx {
|
|||
this.pushCleanup(d);
|
||||
} catch (_) {
|
||||
vscode.window.showWarningMessage(
|
||||
'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
|
||||
'Enhanced typing feature is disabled because of incompatibility ' +
|
||||
'with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: ' +
|
||||
'https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ let ctx!: Ctx;
|
|||
export async function activate(context: vscode.ExtensionContext) {
|
||||
ctx = new Ctx(context);
|
||||
|
||||
// Commands which invokes manually via command pallet, shortcut, etc.
|
||||
// Commands which invokes manually via command pallete, shortcut, etc.
|
||||
ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
|
||||
ctx.registerCommand('collectGarbage', commands.collectGarbage);
|
||||
ctx.registerCommand('matchingBrace', commands.matchingBrace);
|
||||
|
|
Loading…
Reference in a new issue