-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathbuildpath.ts
More file actions
58 lines (51 loc) · 2.45 KB
/
buildpath.ts
File metadata and controls
58 lines (51 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
import { window, commands, ExtensionContext, Uri } from 'vscode';
import { Commands } from './commands';
interface Result {
status: boolean;
message: string;
}
interface SourcePath {
path: string;
displayPath: string;
projectName: string;
projectType: string;
}
interface ListCommandResult extends Result {
data?: SourcePath[];
}
export function registerCommands(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand(Commands.ADD_TO_SOURCEPATH, async (uri: Uri) => {
const result = await <any>commands.executeCommand(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.ADD_TO_SOURCEPATH, uri.toString());
if (result.status) {
window.showInformationMessage(result.message ? result.message : 'Successfully added the folder to the source path.');
} else {
window.showErrorMessage(result.message);
}
}));
context.subscriptions.push(commands.registerCommand(Commands.REMOVE_FROM_SOURCEPATH, async (uri: Uri) => {
const result = await <any>commands.executeCommand(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.REMOVE_FROM_SOURCEPATH, uri.toString());
if (result.status) {
window.showInformationMessage(result.message ? result.message : 'Successfully removed the folder from the source path.');
} else {
window.showErrorMessage(result.message);
}
}));
context.subscriptions.push(commands.registerCommand(Commands.LIST_SOURCEPATHS, async() => {
const result: ListCommandResult = await commands.executeCommand<ListCommandResult>(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.LIST_SOURCEPATHS);
if (result.status) {
if (!result.data || !result.data.length) {
window.showInformationMessage("No Java source directories found in the workspace, please use the command 'Add Folder to Java Source Path' first.");
} else {
window.showQuickPick(result.data.map(sourcePath => {
return {
label: sourcePath.displayPath,
detail: `$(file-directory) ${sourcePath.projectType} Project: ${sourcePath.projectName}`,
};
}), { placeHolder: 'All Java source directories recognized by the workspace.'});
}
} else {
window.showErrorMessage(result.message);
}
}));
}