Skip to content

Commit 5e61c9b

Browse files
bors[bot]Veetaha
andauthored
Merge #2987
2987: vscode refactoring: use more laconic export snytax, split huge string literal r=matklad a=Veetaha Co-authored-by: Veetaha <gerzoh1@gmail.com>
2 parents e72771e + 4bf5f59 commit 5e61c9b

File tree

3 files changed

+18
-33
lines changed

3 files changed

+18
-33
lines changed

editors/code/src/commands/index.ts

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ import * as lc from 'vscode-languageclient';
44
import { Ctx, Cmd } from '../ctx';
55
import * as sourceChange from '../source_change';
66

7-
import { analyzerStatus } from './analyzer_status';
8-
import { matchingBrace } from './matching_brace';
9-
import { joinLines } from './join_lines';
10-
import { onEnter } from './on_enter';
11-
import { parentModule } from './parent_module';
12-
import { syntaxTree } from './syntax_tree';
13-
import { expandMacro } from './expand_macro';
14-
import { run, runSingle } from './runnables';
15-
16-
function collectGarbage(ctx: Ctx): Cmd {
7+
export * from './analyzer_status';
8+
export * from './matching_brace';
9+
export * from './join_lines';
10+
export * from './on_enter';
11+
export * from './parent_module';
12+
export * from './syntax_tree';
13+
export * from './expand_macro';
14+
export * from './runnables';
15+
16+
export function collectGarbage(ctx: Ctx): Cmd {
1717
return async () => {
1818
ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null);
1919
};
2020
}
2121

22-
function showReferences(ctx: Ctx): Cmd {
22+
export function showReferences(ctx: Ctx): Cmd {
2323
return (uri: string, position: lc.Position, locations: lc.Location[]) => {
2424
const client = ctx.client;
2525
if (client) {
@@ -33,13 +33,13 @@ function showReferences(ctx: Ctx): Cmd {
3333
};
3434
}
3535

36-
function applySourceChange(ctx: Ctx): Cmd {
36+
export function applySourceChange(ctx: Ctx): Cmd {
3737
return async (change: sourceChange.SourceChange) => {
3838
sourceChange.applySourceChange(ctx, change);
3939
};
4040
}
4141

42-
function selectAndApplySourceChange(ctx: Ctx): Cmd {
42+
export function selectAndApplySourceChange(ctx: Ctx): Cmd {
4343
return async (changes: sourceChange.SourceChange[]) => {
4444
if (changes.length === 1) {
4545
await sourceChange.applySourceChange(ctx, changes[0]);
@@ -51,26 +51,9 @@ function selectAndApplySourceChange(ctx: Ctx): Cmd {
5151
};
5252
}
5353

54-
function reload(ctx: Ctx): Cmd {
54+
export function reload(ctx: Ctx): Cmd {
5555
return async () => {
5656
vscode.window.showInformationMessage('Reloading rust-analyzer...');
5757
await ctx.restartServer();
5858
};
5959
}
60-
61-
export {
62-
analyzerStatus,
63-
expandMacro,
64-
joinLines,
65-
matchingBrace,
66-
parentModule,
67-
syntaxTree,
68-
onEnter,
69-
collectGarbage,
70-
run,
71-
runSingle,
72-
showReferences,
73-
applySourceChange,
74-
selectAndApplySourceChange,
75-
reload
76-
};

editors/code/src/ctx.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export class Ctx {
6666
this.pushCleanup(d);
6767
} catch (_) {
6868
vscode.window.showWarningMessage(
69-
'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',
69+
'Enhanced typing feature is disabled because of incompatibility ' +
70+
'with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: ' +
71+
'https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
7072
);
7173
}
7274
}

editors/code/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let ctx!: Ctx;
1111
export async function activate(context: vscode.ExtensionContext) {
1212
ctx = new Ctx(context);
1313

14-
// Commands which invokes manually via command pallet, shortcut, etc.
14+
// Commands which invokes manually via command palette, shortcut, etc.
1515
ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
1616
ctx.registerCommand('collectGarbage', commands.collectGarbage);
1717
ctx.registerCommand('matchingBrace', commands.matchingBrace);

0 commit comments

Comments
 (0)