From f345353b94573319395ee781056f647592c555fe Mon Sep 17 00:00:00 2001 From: Yan Zhang Date: Wed, 26 Aug 2020 11:23:57 +0800 Subject: [PATCH] add 'open pom' command to Project Manager Signed-off-by: Yan Zhang --- package.json | 5 +++++ src/extension.ts | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2831d1ff..d9a3f4e6 100644 --- a/package.json +++ b/package.json @@ -365,6 +365,11 @@ "when": "view == mavenProjects && viewItem == MavenProject", "group": "inline" }, + { + "command": "maven.project.openPom", + "when": "view == javaProjectExplorer && viewItem =~ /java:project(?=.*?\\b\\+maven\\b)(?=.*?\\b\\+uri\\b)/", + "group": "inline" + }, { "command": "maven.plugin.execute", "when": "view == mavenProjects && viewItem == PluginGoal", diff --git a/src/extension.ts b/src/extension.ts index c4a8fe0c..81664f66 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2,6 +2,7 @@ // Licensed under the MIT license. "use strict"; +import * as path from "path"; import * as vscode from "vscode"; import { Progress, Uri } from "vscode"; import { dispose as disposeTelemetryWrapper, initialize, instrumentOperation, sendInfo } from "vscode-extension-telemetry-wrapper"; @@ -205,8 +206,16 @@ async function refreshExplorerHandler(item?: ITreeItem): Promise { } } -async function openPomHandler(node: MavenProject): Promise { - if (node !== undefined && node.pomPath) { - await openFileIfExists(node.pomPath); +async function openPomHandler(node: MavenProject | {uri: string}): Promise { + if (node instanceof MavenProject) { + if (node.pomPath) { + await openFileIfExists(node.pomPath); + } + } else { + // for nodes from Project Manager + if (node.uri) { + const pomPath: string = path.join(Uri.parse(node.uri).fsPath, "pom.xml"); + await openFileIfExists(pomPath); + } } }