Skip to content

Commit 117dd19

Browse files
committed
feat(commands): add and port more commands from the extension
1 parent d772604 commit 117dd19

20 files changed

Lines changed: 1519 additions & 226 deletions

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
end_of_line = lf
7+
indent_style = space
8+
max_line_length = 140
9+
insert_final_newline = true
10+
trim_trailing_whitespace=true
11+
12+
[*.yml]
13+
indent_size = 2
14+
end_of_line = lf
15+
indent_style = space

.prettierrc

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"bracketSpacing": true,
3+
"printWidth": 140,
4+
"singleQuote": false,
5+
"trailingComma": "none",
6+
"useTabs": false,
7+
"tabWidth": 4,
8+
"semi": true,
9+
"arrowParens": "always",
10+
"endOfLine": "lf",
11+
"proseWrap": "preserve",
12+
"quoteProps": "as-needed",
13+
"bracketSameLine": true,
14+
"jsxSingleQuote": false,
15+
"vueIndentScriptAndStyle": true,
16+
"embeddedLanguageFormatting": "auto",
17+
"htmlWhitespaceSensitivity": "css",
18+
"overrides": [
19+
{
20+
"files": ["*.md", "*.mdx"],
21+
"options": {
22+
"printWidth": 80,
23+
"proseWrap": "always"
24+
}
25+
},
26+
{
27+
"files": ["*.yml", "*.yaml"],
28+
"options": {
29+
"tabWidth": 2
30+
}
31+
},
32+
{
33+
"files": ["*.json", "*.jsonc", "*.json5"],
34+
"options": {
35+
"tabWidth": 4,
36+
"printWidth": 120,
37+
"trailingComma": "none"
38+
}
39+
},
40+
{
41+
"files": ["*.gql", "*.graphql"],
42+
"options": {
43+
"printWidth": 100
44+
}
45+
},
46+
{
47+
"files": ["*.html", "*.vue", "*.svelte", "*.astro"],
48+
"options": {
49+
"singleAttributePerLine": true,
50+
"bracketSameLine": false
51+
}
52+
},
53+
{
54+
"files": ["*.css", "*.scss", "*.less"],
55+
"options": {
56+
"singleQuote": false
57+
}
58+
}
59+
]
60+
}

package.json

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "coc-java-explorer",
33
"description": "coc.nvim extension project manager for java",
4-
"version": "0.1.9",
4+
"version": "0.2.0",
55
"main": "lib/index.js",
66
"repository": {
77
"type": "git",
@@ -69,28 +69,60 @@
6969
],
7070
"commands": [
7171
{
72-
"command": "java.view.package.revealProject",
73-
"title": "Reveal project in project view explorer"
72+
"command": "java.project.addLibraries",
73+
"title": "Add jar libraries to project"
7474
},
7575
{
76-
"command": "java.view.package.refresh",
77-
"title": "Refresh project & packages in view explorer"
76+
"command": "java.project.addLibraryFolders",
77+
"title": "Add library folders to project"
7878
},
7979
{
80-
"command": "java.view.package.changeToHierarchicalPackageView",
81-
"title": "Show package project view as hierarchical view"
80+
"command": "java.project.refreshLibraries",
81+
"title": "Refresh project libraries"
82+
},
83+
{
84+
"command": "java.project.create",
85+
"title": "Create a new Java project"
86+
},
87+
{
88+
"command": "java.view.package.linkWithFolder",
89+
"title": "Link package view with folder"
90+
},
91+
{
92+
"command": "java.view.package.unlinkWithFolder",
93+
"title": "Unlink package view from folder"
8294
},
8395
{
8496
"command": "java.view.package.changeToFlatPackageView",
85-
"title": "Show package project view as flat view"
97+
"title": "Show package view as flat view"
98+
},
99+
{
100+
"command": "java.view.package.changeToHierarchicalPackageView",
101+
"title": "Show package view as hierarchical view"
102+
},
103+
{
104+
"command": "java.view.package.internalRefresh",
105+
"title": "Internal refresh of package view"
106+
},
107+
{
108+
"command": "java.view.package.refresh",
109+
"title": "Refresh project & packages in view"
110+
},
111+
{
112+
"command": "java.view.package.exportJar",
113+
"title": "Export project jar file"
114+
},
115+
{
116+
"command": "java.view.package.revealProject",
117+
"title": "Reveal project in project view"
86118
},
87119
{
88120
"command": "java.view.explorer.showNonJavaResources",
89-
"title": "Show non-java resources within project view"
121+
"title": "Show non-Java resources in view"
90122
},
91123
{
92124
"command": "java.view.explorer.hideNonJavaResources",
93-
"title": "Hid non-java resources within project view"
125+
"title": "Hide non-Java resources in view"
94126
}
95127
],
96128
"configuration": {

src/commands.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
3+
import { commands } from "coc.nvim";
34

45
export namespace Commands {
6+
/**
7+
* Execute Workspace Command
8+
*/
59
export const EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand";
610

711
export const VIEW_PACKAGE_CHANGETOFLATPACKAGEVIEW = "java.view.package.changeToFlatPackageView";
@@ -12,9 +16,9 @@ export namespace Commands {
1216

1317
export const VIEW_PACKAGE_UNLINKWITHFOLDER = "java.view.package.unlinkWithFolderExplorer";
1418

15-
export const JAVA_PROJECT_EXPLORER_SHOW_NONJAVA_RESOURCES = "java.view.explorer.showNonJavaResources";
19+
export const JAVA_PROJECT_EXPLORER_SHOW_NONJAVA_RESOURCES = "java.project.explorer.showNonJavaResources";
1620

17-
export const JAVA_PROJECT_EXPLORER_HIDE_NONJAVA_RESOURCES = "java.view.explorer.hideNonJavaResources";
21+
export const JAVA_PROJECT_EXPLORER_HIDE_NONJAVA_RESOURCES = "java.project.explorer.hideNonJavaResources";
1822

1923
export const JAVA_PROJECT_EXPLORER_RESOURCE_OPEN = "java.view.explorer.openResourceNode"
2024

@@ -38,6 +42,8 @@ export namespace Commands {
3842

3943
export const VIEW_PACKAGE_NEW_JAVA_CLASS = "java.view.package.newJavaClass";
4044

45+
export const VIEW_MODERNIZE_JAVA_PROJECT = "_java.view.modernizeJavaProject";
46+
4147
export const VIEW_PACKAGE_NEW_JAVA_INTERFACE = "java.view.package.newJavaInterface";
4248

4349
export const VIEW_PACKAGE_NEW_JAVA_ENUM = "java.view.package.newJavaEnum";
@@ -50,13 +56,15 @@ export namespace Commands {
5056

5157
export const VIEW_PACKAGE_NEW_JAVA_PACKAGE = "java.view.package.newPackage";
5258

59+
export const VIEW_EXPLORER_NEW_PACKAGE = "java.view.fileExplorer.newPackage";
60+
5361
export const VIEW_PACKAGE_RENAME_FILE = "java.view.package.renameFile";
5462

5563
export const VIEW_PACKAGE_MOVE_FILE_TO_TRASH = "java.view.package.moveFileToTrash";
5664

5765
export const VIEW_PACKAGE_DELETE_FILE_PERMANENTLY = "java.view.package.deleteFilePermanently";
5866

59-
export const VIEW_PACKAGE_REVEAL_IN_PROJECT_EXPLORER = "java.view.package.revealProject";
67+
export const VIEW_PACKAGE_REVEAL_IN_PROJECT_EXPLORER = "java.view.package.revealInProjectExplorer";
6068

6169
export const VIEW_PACKAGE_NEW_FILE = "java.view.package.newFile";
6270

@@ -116,6 +124,8 @@ export namespace Commands {
116124

117125
export const JAVA_PROJECT_CONFIGURATION_UPDATE = "java.projectConfiguration.update";
118126

127+
export const JAVA_RESOLVE_BUILD_FILES = "vscode.java.resolveBuildFiles";
128+
119129
export const JAVA_PROJECT_LIST_SOURCE_PATHS = "java.project.listSourcePaths";
120130

121131
export const INSTALL_EXTENSION = "java.project.installExtension";
@@ -124,6 +134,13 @@ export namespace Commands {
124134

125135
export const JAVA_PROJECT_CHECK_IMPORT_STATUS = "java.project.checkImportStatus";
126136

137+
export const JAVA_UPGRADE_WITH_COPILOT = "_java.upgradeWithCopilot";
138+
139+
/**
140+
* Commands from Visual Studio Code
141+
*/
142+
export const VSCODE_OPEN_FOLDER = "vscode.openFolder";
143+
127144
export const VSCODE_OPEN = "vscode.open";
128145

129146
export const WORKBENCH_ACTION_FILES_OPENFOLDER = "workbench.action.files.openFolder";
@@ -132,6 +149,9 @@ export namespace Commands {
132149

133150
export const WORKBENCH_VIEW_PROBLEMS = "workbench.actions.view.problems";
134151

152+
/**
153+
* Commands from JLS
154+
*/
135155
export const LIST_SOURCEPATHS = "java.project.listSourcePaths";
136156

137157
export const COMPILE_WORKSPACE = "java.workspace.compile";
@@ -140,5 +160,22 @@ export namespace Commands {
140160

141161
export const BUILD_PROJECT = "java.project.build";
142162

143-
export const GET_PROJECT_SETTINGS = 'java.project.getSettings';
163+
/**
164+
* Commands from Java Upgrade Tool
165+
*/
166+
export const GOTO_AGENT_MODE = "javaupgrade.gotoAgentMode";
167+
168+
/**
169+
* Get the project settings
170+
*/
171+
export const GET_PROJECT_SETTINGS = "java.project.getSettings";
172+
}
173+
174+
export function executeJavaLanguageServerCommand(...rest: any[]) {
175+
return executeJavaExtensionCommand(Commands.EXECUTE_WORKSPACE_COMMAND, ...rest);
176+
}
177+
178+
export async function executeJavaExtensionCommand(commandName: string, ...rest: any[]) {
179+
// TODO: need to handle error
180+
return commands.executeCommand(commandName, ...rest);
144181
}

0 commit comments

Comments
 (0)