From 81847524702dd7cb1eeae25a53444b325295b129 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 21:37:22 +0200 Subject: vscode refactoring: use more laconic export snytax, split huge string to several lines --- editors/code/src/commands/index.ts | 45 ++++++++++++-------------------------- editors/code/src/ctx.ts | 4 +++- editors/code/src/main.ts | 2 +- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 4501809e2..5a4c1df5e 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -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'; - -function collectGarbage(ctx: Ctx): Cmd { +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'; + +export function collectGarbage(ctx: Ctx): Cmd { return async () => { ctx.client?.sendRequest('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 -}; diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index b882a8e52..094566d09 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -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', ); } } diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 0494ccf63..de45f660b 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -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); -- cgit v1.2.3 From 4bf5f595604c2c3fa0ca981a843d04a8732dabf9 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 21:38:49 +0200 Subject: vscode: fix type --- editors/code/src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index de45f660b..6813c3c4c 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -11,7 +11,7 @@ let ctx!: Ctx; export async function activate(context: vscode.ExtensionContext) { ctx = new Ctx(context); - // Commands which invokes manually via command pallete, shortcut, etc. + // Commands which invokes manually via command palette, shortcut, etc. ctx.registerCommand('analyzerStatus', commands.analyzerStatus); ctx.registerCommand('collectGarbage', commands.collectGarbage); ctx.registerCommand('matchingBrace', commands.matchingBrace); -- cgit v1.2.3