Skip to content

Commit 452296b

Browse files
yaohaizhfbricon
authored andcommitted
Use common VSCode UI for organize imports (#722)
Signed-off-by: Yaohai Zheng <yaozheng@microsoft.com>
1 parent 98eb5ab commit 452296b

5 files changed

Lines changed: 4 additions & 37 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ The following commands are available:
5757
- `Java:Update Project configuration` (`Shift+Alt+U`): is available when the editor is focused on a Maven pom.xml or a Gradle file. It forces project configuration / classpath updates (eg. dependency changes or Java compilation level), according to the project build descriptor.
5858
- `Java:Open Java Language Server log file`: opens the Java Language Server log file, useful for troubleshooting problems.
5959
- `Java:Force Java compilation` (`Shift+Alt+B`): manually triggers compilation of the workspace.
60-
- `Java:Organize imports` (`Shift+Alt+O`): Organize imports in the currently opened Java file.
6160
- `Java:Open Java formatter settings`: Open the Eclipse formatter settings. Creates a new settings file if none exists.
6261
- `Java:Clean the Java language server workspace`: Clean the Java language server workspace.
63-
64-
*New in 0.34.0:*
6562
- `Java:Attach Source`: Attach a jar/zip source to the currently opened binary class file. This command is only available in the editor context menu.
6663

64+
*Changes in 0.35.0:*
65+
- `Java:Organize imports` command has been removed from the editor context menu. It is now a code action item of the standard context menu `Source Action...`. Its default shortcut (`Shift+Alt+O`) is unchanged. See this [link](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions) about how to customize keybindings for code actions.
66+
67+
6768
Supported VS Code settings
6869
==========================
6970
The following settings are supported:

package.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,6 @@
277277
"title": "Force Java compilation",
278278
"category": "Java"
279279
},
280-
{
281-
"command": "java.edit.organizeImports",
282-
"title": "Organize Imports",
283-
"category": "Java"
284-
},
285280
{
286281
"command": "java.open.formatter.settings",
287282
"title": "Open Java formatter settings",
@@ -304,11 +299,6 @@
304299
"key": "shift+alt+u",
305300
"when": "editorFocus"
306301
},
307-
{
308-
"command": "java.edit.organizeImports",
309-
"key": "shift+alt+o",
310-
"when": "editorTextFocus && !editorReadonly && editorLangId == java"
311-
},
312302
{
313303
"command": "java.workspace.compile",
314304
"key": "shift+alt+b"
@@ -323,11 +313,6 @@
323313
}
324314
],
325315
"editor/context": [
326-
{
327-
"command": "java.edit.organizeImports",
328-
"when": "editorLangId == java",
329-
"group": "1_javaactions"
330-
},
331316
{
332317
"command": "java.project.updateSourceAttachment",
333318
"when": "editorReadonly && editorLangId == java",
@@ -340,10 +325,6 @@
340325
}
341326
],
342327
"commandPalette": [
343-
{
344-
"command": "java.edit.organizeImports",
345-
"when": "!editorReadonly && editorLangId == java"
346-
},
347328
{
348329
"command": "java.project.updateSourceAttachment",
349330
"when": "false"

src/commands.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ export namespace Commands {
7474
*/
7575
export const OPEN_SERVER_LOG = 'java.open.serverLog';
7676

77-
/**
78-
* Organize Java file imports command from language server
79-
*/
80-
export const EDIT_ORGANIZE_IMPORTS = 'java.edit.organizeImports';
8177
/**
8278
* Open Java formatter settings
8379
*/

src/extension.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
212212
applyWorkspaceEdit(obj, languageClient);
213213
});
214214

215-
commands.registerCommand(Commands.EDIT_ORGANIZE_IMPORTS, async () => {
216-
let activeEditor = window.activeTextEditor;
217-
if (!activeEditor || !activeEditor.document || activeEditor.document.languageId !== 'java') {
218-
return;
219-
}
220-
if (activeEditor.document.uri instanceof Uri) {
221-
await <any>commands.executeCommand(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.EDIT_ORGANIZE_IMPORTS, activeEditor.document.uri.toString());
222-
}
223-
});
224-
225215
commands.registerCommand(Commands.EXECUTE_WORKSPACE_COMMAND, (command, ...rest) => {
226216
const params: ExecuteCommandParams = {
227217
command,

test/extension.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ suite('Java Language Extension', () => {
3535
Commands.EXECUTE_WORKSPACE_COMMAND,
3636
Commands.OPEN_SERVER_LOG,
3737
Commands.COMPILE_WORKSPACE,
38-
Commands.EDIT_ORGANIZE_IMPORTS,
3938
Commands.OPEN_FORMATTER,
4039
Commands.CLEAN_WORKSPACE,
4140
Commands.UPDATE_SOURCE_ATTACHMENT

0 commit comments

Comments
 (0)