Setting for browser to open live request mapping URL via CodeLens
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2024 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -48,14 +48,19 @@ public class HighlightsCodeLensProvider extends AbstractCodeMiningProvider {
|
||||
private static final Map<String, Function<Command, Consumer<MouseEvent>>> ACTION_MAP = new HashMap<>();
|
||||
static {
|
||||
ACTION_MAP.put("sts.open.url", (cmd) -> {
|
||||
return (me) -> {
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
if (!cmd.getArguments().isEmpty() && cmd.getArguments().get(0) instanceof JsonPrimitive) {
|
||||
String url = ((JsonPrimitive)cmd.getArguments().get(0)).getAsString();
|
||||
LSPEclipseUtils.open(url, page, null);
|
||||
}
|
||||
};
|
||||
return (me) -> opneUrlCommand(cmd);
|
||||
});
|
||||
ACTION_MAP.put("vscode-spring-boot.open.url", (cmd) -> {
|
||||
return (me) -> opneUrlCommand(cmd);
|
||||
});
|
||||
}
|
||||
|
||||
private static void opneUrlCommand(Command cmd) {
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
if (!cmd.getArguments().isEmpty() && cmd.getArguments().get(0) instanceof JsonPrimitive) {
|
||||
String url = ((JsonPrimitive)cmd.getArguments().get(0)).getAsString();
|
||||
LSPEclipseUtils.open(url, page, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static Consumer<MouseEvent> action(Command cmd) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2024 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -376,7 +376,7 @@ public class RequestMappingHoverProvider implements HoverProvider {
|
||||
String content = codeLensContent.toString();
|
||||
codeLens.setData(content);
|
||||
cmd.setTitle(content);
|
||||
cmd.setCommand("sts.open.url");
|
||||
cmd.setCommand("vscode-spring-boot.open.url");
|
||||
cmd.setArguments(ImmutableList.of(url));
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,12 @@ export function activate(context: ExtensionContext): Thenable<ExtensionAPI> {
|
||||
}
|
||||
});
|
||||
|
||||
commands.registerCommand('vscode-spring-boot.open.url', (openUrl) => {
|
||||
const openWithExternalBrowser = workspace.getConfiguration("spring.tools").get("openWith") === "external";
|
||||
const browserCommand = openWithExternalBrowser ? "vscode.open" : "simpleBrowser.api.open";
|
||||
return commands.executeCommand(browserCommand, Uri.parse(openUrl));
|
||||
});
|
||||
|
||||
return new ApiManager(client).api;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,6 +134,12 @@
|
||||
"command": "vscode-spring-boot.set.log-levels",
|
||||
"title": "Set Log Levels",
|
||||
"category": "Spring Boot"
|
||||
},
|
||||
{
|
||||
"command": "vscode-spring-boot.open.url",
|
||||
"title": "Open Boot App Page URL",
|
||||
"category": "Spring Boot",
|
||||
"enablement": "never"
|
||||
}
|
||||
],
|
||||
"configuration": [
|
||||
@@ -238,6 +244,20 @@
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Enable/Disable Spring Boot TestJars launch environment variables"
|
||||
},
|
||||
"spring.tools.openWith": {
|
||||
"default": "integrated",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"integrated",
|
||||
"external"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"VS Code's integrated browser",
|
||||
"External default browser"
|
||||
],
|
||||
"scope": "window",
|
||||
"description": "Defines which browser to use when opening Spring Boot apps web pages."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user