Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,11 @@
"command": "java.runtimes.add",
"title": "%java.runtimes.add%",
"category": "Java"
},
{
"command": "java.action.copyFullyQualifiedName",
"title": "%java.action.copyFullyQualifiedName%",
"category": "Java"
}
],
"keybindings": [
Expand Down Expand Up @@ -1951,6 +1956,11 @@
"command": "java.action.showTypeHierarchy",
"when": "javaLSReady && editorTextFocus && editorLangId == java",
"group": "0_navigation@3"
},
{
"command": "java.action.copyFullyQualifiedName",
"when": "javaLSReady && editorTextFocus && editorLangId == java",
"group": "1_javaactions"
}
],
"commandPalette": [
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
"java.action.doCleanup": "Performs Cleanup Actions",
"java.change.searchScope": "Change Search Scope",
"java.action.showExtendedOutline": "Open Extended Outline",
"java.runtimes.add": "Add Java Runtime"
"java.runtimes.add": "Add Java Runtime",
"java.action.copyFullyQualifiedName": "Copy Fully Qualified Name"
}
6 changes: 6 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ export namespace Commands {
* Add Java Runtime
*/
export const ADD_JAVA_RUNTIME = 'java.runtimes.add';

/**
* Copy fully qualified name.
*/
export const COPY_FULLY_QUALIFIED_NAME = 'java.action.copyFullyQualifiedName';
export const GET_FULLY_QUALIFIED_NAME = 'java.getFullyQualifiedName';
}

/**
Expand Down
27 changes: 27 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,33 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
}
}));

context.subscriptions.push(commands.registerCommand(Commands.COPY_FULLY_QUALIFIED_NAME, async () => {
const editor = window.activeTextEditor;
if (!editor || editor.document.languageId !== 'java') {
return;
}

const params = {
textDocument: {
uri: editor.document.uri.toString()
},
position: {
line: editor.selection.active.line,
character: editor.selection.active.character
}
};

const fullyQualifiedName = await commands.executeCommand<string>(
Commands.EXECUTE_WORKSPACE_COMMAND,
Commands.GET_FULLY_QUALIFIED_NAME,
JSON.stringify(params)
);

if (fullyQualifiedName) {
await env.clipboard.writeText(fullyQualifiedName);
window.showInformationMessage(`Copied: ${fullyQualifiedName}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this information message before merging. We want to avoid overwhelming the user with information through the notifications.

}
}));
registerRestartJavaLanguageServerCommand(context);

/**
Expand Down
3 changes: 2 additions & 1 deletion test/lightweight-mode-suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ suite('Java Language Extension - LightWeight', () => {
Commands.FILESEXPLORER_ONPASTE,
Commands.CHANGE_JAVA_SEARCH_SCOPE,
Commands.OPEN_JAVA_DASHBOARD,
Commands.ADD_JAVA_RUNTIME
Commands.ADD_JAVA_RUNTIME,
Commands.COPY_FULLY_QUALIFIED_NAME
].sort();
const foundJavaCommands = commands.filter((value) => {
return JAVA_COMMANDS.indexOf(value)>=0 || value.startsWith('java.');
Expand Down
3 changes: 3 additions & 0 deletions test/standard-mode-suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ suite('Java Language Extension - Standard', () => {
Commands.FILESEXPLORER_ONPASTE,
Commands.RESOLVE_PASTED_TEXT,
Commands.CHANGE_JAVA_SEARCH_SCOPE,
Commands.COPY_FULLY_QUALIFIED_NAME,
Commands.GET_FULLY_QUALIFIED_NAME,
"java.getTroubleshootingInfo",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "java.getTroubleshootingInfo"? What does it do? It seems unrelated to this PR.

Commands.OPEN_JAVA_DASHBOARD,
Commands.ADD_JAVA_RUNTIME
].sort();
Expand Down
Loading