diff --git a/org.eclipse.wildwebdeveloper.embedder.node/META-INF/MANIFEST.MF b/org.eclipse.wildwebdeveloper.embedder.node/META-INF/MANIFEST.MF
index cbb968f672..d9774b18b9 100644
--- a/org.eclipse.wildwebdeveloper.embedder.node/META-INF/MANIFEST.MF
+++ b/org.eclipse.wildwebdeveloper.embedder.node/META-INF/MANIFEST.MF
@@ -2,14 +2,14 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Manager for embedded Node.js
Bundle-SymbolicName: org.eclipse.wildwebdeveloper.embedder.node
-Bundle-Version: 1.0.4.qualifier
+Bundle-Version: 1.0.5.qualifier
Bundle-Vendor: Eclipse Wild Web Developer
Automatic-Module-Name: org.eclipse.wildwebdeveloper.embedder.node
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.eclipse.ui,
org.eclipse.ui.workbench,
org.eclipse.swt,
- org.eclipse.core.runtime;bundle-version="3.18.0",
+ org.eclipse.core.runtime;bundle-version="3.29.0",
org.eclipse.jface;bundle-version="3.20.0"
Import-Package: org.apache.commons.compress.archivers;version="1.22",
org.apache.commons.compress.archivers.dump,
diff --git a/org.eclipse.wildwebdeveloper.embedder.node/pom.xml b/org.eclipse.wildwebdeveloper.embedder.node/pom.xml
index d4d8ee9499..50d8ec39af 100644
--- a/org.eclipse.wildwebdeveloper.embedder.node/pom.xml
+++ b/org.eclipse.wildwebdeveloper.embedder.node/pom.xml
@@ -7,7 +7,7 @@
1.0.0-SNAPSHOT
eclipse-plugin
- 1.0.4-SNAPSHOT
+ 1.0.5-SNAPSHOT
diff --git a/org.eclipse.wildwebdeveloper.embedder.node/src/org/eclipse/wildwebdeveloper/embedder/node/NodeJSManager.java b/org.eclipse.wildwebdeveloper.embedder.node/src/org/eclipse/wildwebdeveloper/embedder/node/NodeJSManager.java
index e5b6707eae..1ef0fdfc9f 100644
--- a/org.eclipse.wildwebdeveloper.embedder.node/src/org/eclipse/wildwebdeveloper/embedder/node/NodeJSManager.java
+++ b/org.eclipse.wildwebdeveloper.embedder.node/src/org/eclipse/wildwebdeveloper/embedder/node/NodeJSManager.java
@@ -28,339 +28,328 @@
import java.util.Properties;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.widgets.Display;
public class NodeJSManager {
- public static final String NODE_ROOT_DIRECTORY = ".node";
-
- private static final String MACOS_DSCL_SHELL_PREFIX = "UserShell: ";
-
- private static boolean alreadyWarned;
- private static Properties cachedNodeJsInfoProperties;
- private static final Object EXPAND_LOCK = new Object();
-
- /**
- * Finds Node.js executable installed in following list of locations:
- * - Location, specified in `org.eclipse.wildwebdeveloper.nodeJSLocation` system property
- * - Platform Install Location
- * - Platform User Location
- * - WWD Node bundle configuration location
- * - OS dependent default installation path
- * In case of Node.js cannot be found installs the embedded version into the first
- * available location of platform install/user/workspace locations
- *
- * @return The file for Node.js executable or null if it cannot be installed
- */
- public static File getNodeJsLocation() {
- String nodeJsLocation = System.getProperty("org.eclipse.wildwebdeveloper.nodeJSLocation");
- if (nodeJsLocation != null) {
- File nodejs = new File(nodeJsLocation);
- if (nodejs.exists()) {
- validateNodeVersion(nodejs);
- return new File(nodeJsLocation);
- }
- }
-
- Properties properties = getNodeJsInfoProperties();
- if (properties != null) {
- try {
- File nodePath = probeNodeJsExacutable(properties);
- if (nodePath != null) {
- return nodePath;
- }
-
- File installationPath = probeNodeJsInstallLocationn();
- if (installationPath != null) {
- nodePath = new File(installationPath, properties.getProperty("nodePath"));
- synchronized (EXPAND_LOCK) {
- if (!nodePath.exists() || !nodePath.canRead() || !nodePath.canExecute()) {
- CompressUtils.unarchive(FileLocator.find(Activator.getDefault().getBundle(),
- new Path(properties.getProperty("archiveFile"))), installationPath);
- }
- }
- return nodePath;
- }
- } catch (IOException e) {
- Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
- }
- }
-
- File res = which("node");
- if (res == null && getDefaultNodePath().exists()) {
- res = getDefaultNodePath();
- }
-
- if (res != null) {
- validateNodeVersion(res);
- return res;
- } else if (!alreadyWarned) {
- warnNodeJSMissing();
- alreadyWarned = true;
- }
- return null;
- }
-
- /**
- * Finds NPM executable installed in Node.js bundle location
- *
- * @return The file for NPM executable or null if it cannot be found
- * @since 0.2
- */
- public static File getNpmLocation() {
- String npmFileName = Platform.getOS().equals(Platform.OS_WIN32) ? "npm.cmd" : "npm";
- File nodeJsLocation = getNodeJsLocation();
- if (nodeJsLocation != null) {
- File res = new File(nodeJsLocation.getParentFile(), npmFileName);
- if (res.exists()) {
- return res;
- }
- }
- return which(npmFileName);
- }
-
- public static File getNpmJSLocation() {
-
- try {
- File npmLocation = getNpmLocation().getCanonicalFile();
- if (npmLocation.getAbsolutePath().endsWith(".js")) {
- return npmLocation;
- }
- String path = "node_modules/npm/bin/npm-cli.js";
- if (new File(npmLocation.getParentFile(), "node_modules").exists()) {
- return new File(npmLocation.getParentFile(), path);
- }
- File target = new File( npmLocation.getParentFile().getParentFile(), path);
- if (target.exists()) {
- return target;
- }
-
-
- return new File( npmLocation.getParentFile(), "lib/cli.js");
- } catch (IOException e) {
- }
-
- return null;
-
-
- }
-
- public static ProcessBuilder prepareNodeProcessBuilder(String... commands)
- {
- return prepareNodeProcessBuilder(Arrays.asList(commands));
- }
-
- public static ProcessBuilder prepareNodeProcessBuilder(List commands)
- {
- List tmp = new ArrayList<>();
- tmp.add(getNodeJsLocation().getAbsolutePath());
- tmp.addAll(commands);
-
- return new ProcessBuilder(tmp);
- }
-
- public static ProcessBuilder prepareNPMProcessBuilder(String... commands)
- {
- return prepareNPMProcessBuilder(Arrays.asList(commands));
- }
-
- public static ProcessBuilder prepareNPMProcessBuilder(List commands)
- {
- List tmp = new ArrayList<>();
-
-
- tmp.add(getNpmJSLocation().getAbsolutePath());
- tmp.addAll(commands);
-
- return prepareNodeProcessBuilder(tmp);
- }
-
- public static File which(String program) {
- Properties properties = getNodeJsInfoProperties();
- if (properties != null) {
- File nodePath = probeNodeJsExacutable(properties);
- if (nodePath != null && nodePath.exists() && nodePath.canRead() && nodePath.canExecute()) {
- File exe = new File(nodePath.getParent(), program);
- if (exe.canExecute()) {
- return exe;
- } else if (Platform.OS_WIN32.equals(Platform.getOS())) {
- exe = new File(nodePath.getParent(), program + ".exe");
- if (exe.canExecute()) {
- return exe;
- }
- }
- }
- }
-
- String[] paths = System.getenv("PATH").split(System.getProperty("path.separator"));
- for (String path : paths) {
- File exe = new File(path, program);
- if (exe.canExecute())
- return exe;
- }
-
- String res = null;
- String[] command = new String[] { "/bin/bash", "-c", "-l", "which " + program };
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- command = new String[] { "cmd", "/c", "where " + program };
- } else if (Platform.getOS().equals(Platform.OS_MACOSX)) {
- command = new String[] { getDefaultShellMacOS(), "-c", "-li", "which " + program };
- }
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream()));) {
- res = reader.readLine();
- } catch (IOException e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e));
- }
- return res != null ? new File(res) : null;
- }
-
- private static Properties getNodeJsInfoProperties() {
- if (cachedNodeJsInfoProperties == null) {
- URL nodeJsInfo = FileLocator.find(Activator.getDefault().getBundle(), new Path("nodejs-info.properties"));
- if (nodeJsInfo != null) {
- try (InputStream infoStream = nodeJsInfo.openStream()) {
- Properties properties = new Properties();
- properties.load(infoStream);
- cachedNodeJsInfoProperties = properties;
- } catch (IOException e) {
- Activator.getDefault().getLog()
- .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
- }
- }
- }
- return cachedNodeJsInfoProperties;
- }
-
- private static final File probeNodeJsInstallLocationn() {
- File[] nodeJsLocations = getOrderedInstallationLocations();
- for (File installationPath : nodeJsLocations) {
- if (probeDirectoryForInstallation(installationPath)) {
- return installationPath;
- }
- }
- return null;
- }
-
- private static final boolean probeDirectoryForInstallation(File directory) {
- if (directory == null) {
- return false;
- }
- if (directory.exists() && directory.isDirectory()
- && directory.canWrite() && directory.canExecute()) {
- return true;
- }
- return probeDirectoryForInstallation(directory.getParentFile());
- }
-
- private static final File probeNodeJsExacutable(Properties properties) {
- File[] nodeJsLocations = getOrderedInstallationLocations();
- for (File installationPath : nodeJsLocations) {
- File nodePath = getNodeJsExecutablen(installationPath, properties);
- if (nodePath != null) {
- return nodePath;
- }
- }
- return null;
- }
-
- private static final File[] getOrderedInstallationLocations() {
- return new File[] {
- toFile(Platform.getInstallLocation(), NODE_ROOT_DIRECTORY), // Platform Install Location
- toFile(Platform.getUserLocation(), NODE_ROOT_DIRECTORY), // Platform User Location
- toFile(Platform.getStateLocation(Activator.getDefault().getBundle())) // Default
- };
- }
-
- private static final File toFile(Location location, String binDirectory) {
- File installLocation = location != null && location.getURL() != null ? new File(location.getURL().getFile()) : null;
- if (installLocation != null && binDirectory != null) {
- installLocation = new File(installLocation, binDirectory);
- }
- return installLocation;
- }
-
- private static final File toFile(IPath locationPath) {
- return locationPath != null ? locationPath.toFile() : null;
- }
-
- private static final File getNodeJsExecutablen(File installationLocation, Properties properties) {
- if (installationLocation != null) {
- File nodePath = new File(installationLocation, properties.getProperty("nodePath"));
- if (nodePath.exists() && nodePath.canRead() && nodePath.canExecute()) {
- return nodePath;
- }
- }
- return null;
- }
-
- private static String getDefaultShellMacOS() {
- String res = null;
- String[] command = { "/bin/bash", "-c", "-l", "dscl . -read ~/ UserShell" };
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream()));) {
- res = reader.readLine();
- if (!res.startsWith(MACOS_DSCL_SHELL_PREFIX)) {
- Activator.getDefault().getLog()
- .log(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(),
- "Cannot find default shell. Use '/bin/zsh' instead."));
- return "/bin/zsh"; // Default shell since macOS 10.15
- }
- res = res.substring(MACOS_DSCL_SHELL_PREFIX.length());
- } catch (IOException e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e));
- }
- return res;
- }
-
- private static File getDefaultNodePath() {
- return new File(switch (Platform.getOS()) {
- case Platform.OS_MACOSX -> "/usr/local/bin/node";
- case Platform.OS_WIN32 -> "C:\\Program Files\\nodejs\\node.exe";
- default -> "/usr/bin/node";
- });
- }
-
- private static void validateNodeVersion(File nodeJsLocation) {
- String nodeVersion = null;
- String[] nodeVersionCommand = { nodeJsLocation.getAbsolutePath(), "-v" };
-
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(Runtime.getRuntime().exec(nodeVersionCommand).getInputStream()));) {
- nodeVersion = reader.readLine();
- } catch (IOException e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e));
- }
-
- if (nodeVersion == null) {
- warnNodeJSVersionCouldNotBeDetermined();
- }
- }
-
- private static void warnNodeJSMissing() {
- if (!alreadyWarned) {
- Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
- "Missing node.js", "Could not find node.js. This will result in editors missing key features.\n"
- + "Please make sure node.js is installed and that your PATH environment variable contains the location to the `node` executable."));
- }
- alreadyWarned = true;
- }
-
- private static void warnNodeJSVersionCouldNotBeDetermined() {
- if (!alreadyWarned) {
- Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
- "Node.js version could not be determined",
- "Node.js version could not be determined. Please make sure a recent version of node.js is installed, editors may be missing key features otherwise.\n"));
- }
- alreadyWarned = true;
- }
+ public static final String NODE_ROOT_DIRECTORY = ".node";
+
+ private static final String MACOS_DSCL_SHELL_PREFIX = "UserShell: ";
+
+ private static boolean alreadyWarned;
+ private static Properties cachedNodeJsInfoProperties;
+ private static final Object EXPAND_LOCK = new Object();
+
+ /**
+ * Finds Node.js executable installed in following list of locations:
+ * - Location, specified in `org.eclipse.wildwebdeveloper.nodeJSLocation` system
+ * property
+ * - Platform Install Location
+ * - Platform User Location
+ * - WWD Node bundle configuration location
+ * - OS dependent default installation path
+ * In case of Node.js cannot be found installs the embedded version into the
+ * first
+ * available location of platform install/user/workspace locations
+ *
+ * @return The file for Node.js executable or null if it cannot be installed
+ */
+ public static File getNodeJsLocation() {
+ String nodeJsLocation = System.getProperty("org.eclipse.wildwebdeveloper.nodeJSLocation");
+ if (nodeJsLocation != null) {
+ File nodejs = new File(nodeJsLocation);
+ if (nodejs.exists()) {
+ validateNodeVersion(nodejs);
+ return new File(nodeJsLocation);
+ }
+ }
+
+ Properties properties = getNodeJsInfoProperties();
+ if (properties != null) {
+ try {
+ File nodePath = probeNodeJsExacutable(properties);
+ if (nodePath != null) {
+ return nodePath;
+ }
+
+ File installationPath = probeNodeJsInstallLocationn();
+ if (installationPath != null) {
+ nodePath = new File(installationPath, properties.getProperty("nodePath"));
+ synchronized (EXPAND_LOCK) {
+ if (!nodePath.exists() || !nodePath.canRead() || !nodePath.canExecute()) {
+ CompressUtils.unarchive(FileLocator.find(Activator.getDefault().getBundle(),
+ new Path(properties.getProperty("archiveFile"))), installationPath);
+ }
+ }
+ return nodePath;
+ }
+ } catch (IOException e) {
+ ILog.get().error(e.getMessage(), e);
+ }
+ }
+
+ File res = which("node");
+ if (res == null && getDefaultNodePath().exists()) {
+ res = getDefaultNodePath();
+ }
+
+ if (res != null) {
+ validateNodeVersion(res);
+ return res;
+ } else if (!alreadyWarned) {
+ warnNodeJSMissing();
+ alreadyWarned = true;
+ }
+ return null;
+ }
+
+ /**
+ * Finds NPM executable installed in Node.js bundle location
+ *
+ * @return The file for NPM executable or null if it cannot be found
+ * @since 0.2
+ */
+ public static File getNpmLocation() {
+ String npmFileName = Platform.getOS().equals(Platform.OS_WIN32) ? "npm.cmd" : "npm";
+ File nodeJsLocation = getNodeJsLocation();
+ if (nodeJsLocation != null) {
+ File res = new File(nodeJsLocation.getParentFile(), npmFileName);
+ if (res.exists()) {
+ return res;
+ }
+ }
+ return which(npmFileName);
+ }
+
+ public static File getNpmJSLocation() {
+
+ try {
+ File npmLocation = getNpmLocation().getCanonicalFile();
+ if (npmLocation.getAbsolutePath().endsWith(".js")) {
+ return npmLocation;
+ }
+ String path = "node_modules/npm/bin/npm-cli.js";
+ if (new File(npmLocation.getParentFile(), "node_modules").exists()) {
+ return new File(npmLocation.getParentFile(), path);
+ }
+ File target = new File(npmLocation.getParentFile().getParentFile(), path);
+ if (target.exists()) {
+ return target;
+ }
+
+ return new File(npmLocation.getParentFile(), "lib/cli.js");
+ } catch (IOException e) {
+ }
+
+ return null;
+
+ }
+
+ public static ProcessBuilder prepareNodeProcessBuilder(String... commands) {
+ return prepareNodeProcessBuilder(Arrays.asList(commands));
+ }
+
+ public static ProcessBuilder prepareNodeProcessBuilder(List commands) {
+ List tmp = new ArrayList<>();
+ tmp.add(getNodeJsLocation().getAbsolutePath());
+ tmp.addAll(commands);
+
+ return new ProcessBuilder(tmp);
+ }
+
+ public static ProcessBuilder prepareNPMProcessBuilder(String... commands) {
+ return prepareNPMProcessBuilder(Arrays.asList(commands));
+ }
+
+ public static ProcessBuilder prepareNPMProcessBuilder(List commands) {
+ List tmp = new ArrayList<>();
+
+ tmp.add(getNpmJSLocation().getAbsolutePath());
+ tmp.addAll(commands);
+
+ return prepareNodeProcessBuilder(tmp);
+ }
+
+ public static File which(String program) {
+ Properties properties = getNodeJsInfoProperties();
+ if (properties != null) {
+ File nodePath = probeNodeJsExacutable(properties);
+ if (nodePath != null && nodePath.exists() && nodePath.canRead() && nodePath.canExecute()) {
+ File exe = new File(nodePath.getParent(), program);
+ if (exe.canExecute()) {
+ return exe;
+ } else if (Platform.OS_WIN32.equals(Platform.getOS())) {
+ exe = new File(nodePath.getParent(), program + ".exe");
+ if (exe.canExecute()) {
+ return exe;
+ }
+ }
+ }
+ }
+
+ String[] paths = System.getenv("PATH").split(System.getProperty("path.separator"));
+ for (String path : paths) {
+ File exe = new File(path, program);
+ if (exe.canExecute())
+ return exe;
+ }
+
+ String res = null;
+ String[] command = new String[] { "/bin/bash", "-c", "-l", "which " + program };
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ command = new String[] { "cmd", "/c", "where " + program };
+ } else if (Platform.getOS().equals(Platform.OS_MACOSX)) {
+ command = new String[] { getDefaultShellMacOS(), "-c", "-li", "which " + program };
+ }
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream()));) {
+ res = reader.readLine();
+ } catch (IOException e) {
+ ILog.get().error(e.getMessage(), e);
+ }
+ return res != null ? new File(res) : null;
+ }
+
+ private static Properties getNodeJsInfoProperties() {
+ if (cachedNodeJsInfoProperties == null) {
+ URL nodeJsInfo = FileLocator.find(Activator.getDefault().getBundle(), new Path("nodejs-info.properties"));
+ if (nodeJsInfo != null) {
+ try (InputStream infoStream = nodeJsInfo.openStream()) {
+ Properties properties = new Properties();
+ properties.load(infoStream);
+ cachedNodeJsInfoProperties = properties;
+ } catch (IOException e) {
+ ILog.get().error(e.getMessage(), e);
+ }
+ }
+ }
+ return cachedNodeJsInfoProperties;
+ }
+
+ private static final File probeNodeJsInstallLocationn() {
+ File[] nodeJsLocations = getOrderedInstallationLocations();
+ for (File installationPath : nodeJsLocations) {
+ if (probeDirectoryForInstallation(installationPath)) {
+ return installationPath;
+ }
+ }
+ return null;
+ }
+
+ private static final boolean probeDirectoryForInstallation(File directory) {
+ if (directory == null) {
+ return false;
+ }
+ if (directory.exists() && directory.isDirectory()
+ && directory.canWrite() && directory.canExecute()) {
+ return true;
+ }
+ return probeDirectoryForInstallation(directory.getParentFile());
+ }
+
+ private static final File probeNodeJsExacutable(Properties properties) {
+ File[] nodeJsLocations = getOrderedInstallationLocations();
+ for (File installationPath : nodeJsLocations) {
+ File nodePath = getNodeJsExecutablen(installationPath, properties);
+ if (nodePath != null) {
+ return nodePath;
+ }
+ }
+ return null;
+ }
+
+ private static final File[] getOrderedInstallationLocations() {
+ return new File[] {
+ toFile(Platform.getInstallLocation(), NODE_ROOT_DIRECTORY), // Platform Install Location
+ toFile(Platform.getUserLocation(), NODE_ROOT_DIRECTORY), // Platform User Location
+ toFile(Platform.getStateLocation(Activator.getDefault().getBundle())) // Default
+ };
+ }
+
+ private static final File toFile(Location location, String binDirectory) {
+ File installLocation = location != null && location.getURL() != null ? new File(location.getURL().getFile())
+ : null;
+ if (installLocation != null && binDirectory != null) {
+ installLocation = new File(installLocation, binDirectory);
+ }
+ return installLocation;
+ }
+
+ private static final File toFile(IPath locationPath) {
+ return locationPath != null ? locationPath.toFile() : null;
+ }
+
+ private static final File getNodeJsExecutablen(File installationLocation, Properties properties) {
+ if (installationLocation != null) {
+ File nodePath = new File(installationLocation, properties.getProperty("nodePath"));
+ if (nodePath.exists() && nodePath.canRead() && nodePath.canExecute()) {
+ return nodePath;
+ }
+ }
+ return null;
+ }
+
+ private static String getDefaultShellMacOS() {
+ String res = null;
+ String[] command = { "/bin/bash", "-c", "-l", "dscl . -read ~/ UserShell" };
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream()));) {
+ res = reader.readLine();
+ if (!res.startsWith(MACOS_DSCL_SHELL_PREFIX)) {
+ ILog.get().error("Cannot find default shell. Use '/bin/zsh' instead.");
+ return "/bin/zsh"; // Default shell since macOS 10.15
+ }
+ res = res.substring(MACOS_DSCL_SHELL_PREFIX.length());
+ } catch (IOException e) {
+ ILog.get().error(e.getMessage(), e);
+ }
+ return res;
+ }
+
+ private static File getDefaultNodePath() {
+ return new File(switch (Platform.getOS()) {
+ case Platform.OS_MACOSX -> "/usr/local/bin/node";
+ case Platform.OS_WIN32 -> "C:\\Program Files\\nodejs\\node.exe";
+ default -> "/usr/bin/node";
+ });
+ }
+
+ private static void validateNodeVersion(File nodeJsLocation) {
+ String nodeVersion = null;
+ String[] nodeVersionCommand = { nodeJsLocation.getAbsolutePath(), "-v" };
+
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(Runtime.getRuntime().exec(nodeVersionCommand).getInputStream()));) {
+ nodeVersion = reader.readLine();
+ } catch (IOException e) {
+ ILog.get().error(e.getMessage(), e);
+ }
+
+ if (nodeVersion == null) {
+ warnNodeJSVersionCouldNotBeDetermined();
+ }
+ }
+
+ private static void warnNodeJSMissing() {
+ if (!alreadyWarned) {
+ Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
+ "Missing node.js", "Could not find node.js. This will result in editors missing key features.\n"
+ + "Please make sure node.js is installed and that your PATH environment variable contains the location to the `node` executable."));
+ }
+ alreadyWarned = true;
+ }
+
+ private static void warnNodeJSVersionCouldNotBeDetermined() {
+ if (!alreadyWarned) {
+ Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
+ "Node.js version could not be determined",
+ "Node.js version could not be determined. Please make sure a recent version of node.js is installed, editors may be missing key features otherwise.\n"));
+ }
+ alreadyWarned = true;
+ }
}
diff --git a/org.eclipse.wildwebdeveloper.feature/feature.xml b/org.eclipse.wildwebdeveloper.feature/feature.xml
index d9f2c0a52d..e7e695a4eb 100644
--- a/org.eclipse.wildwebdeveloper.feature/feature.xml
+++ b/org.eclipse.wildwebdeveloper.feature/feature.xml
@@ -30,8 +30,6 @@
diff --git a/org.eclipse.wildwebdeveloper.xml.feature/feature.xml b/org.eclipse.wildwebdeveloper.xml.feature/feature.xml
index cf216d20c8..04302bcfef 100644
--- a/org.eclipse.wildwebdeveloper.xml.feature/feature.xml
+++ b/org.eclipse.wildwebdeveloper.xml.feature/feature.xml
@@ -2,7 +2,7 @@
diff --git a/org.eclipse.wildwebdeveloper.xml.feature/pom.xml b/org.eclipse.wildwebdeveloper.xml.feature/pom.xml
index d9adf04072..ce08f0fabf 100644
--- a/org.eclipse.wildwebdeveloper.xml.feature/pom.xml
+++ b/org.eclipse.wildwebdeveloper.xml.feature/pom.xml
@@ -7,7 +7,7 @@
1.0.0-SNAPSHOT
eclipse-feature
- 1.3.2-SNAPSHOT
+ 1.3.3-SNAPSHOT
diff --git a/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF b/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF
index e634db6de7..9b38a1711a 100644
--- a/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF
+++ b/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wildwebdeveloper.xml;singleton:=true
-Bundle-Version: 1.3.2.qualifier
+Bundle-Version: 1.3.3.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Automatic-Module-Name: org.eclipse.wildwebdeveloper.xml
@@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.tm4e.registry;bundle-version="0.3.0",
org.eclipse.lsp4j;bundle-version="0.9.0",
org.eclipse.core.filesystem;bundle-version="1.7.0",
org.eclipse.core.resources;bundle-version="3.12.0",
- org.eclipse.core.runtime;bundle-version="3.10.0",
+ org.eclipse.core.runtime;bundle-version="3.29.0",
org.eclipse.ui;bundle-version="3.105.0",
org.eclipse.ui.ide;bundle-version="3.14.0",
org.eclipse.ui.genericeditor;bundle-version="1.0.0",
diff --git a/org.eclipse.wildwebdeveloper.xml/pom.xml b/org.eclipse.wildwebdeveloper.xml/pom.xml
index 46ed839840..742b3fd85e 100644
--- a/org.eclipse.wildwebdeveloper.xml/pom.xml
+++ b/org.eclipse.wildwebdeveloper.xml/pom.xml
@@ -7,7 +7,7 @@
1.0.0-SNAPSHOT
eclipse-plugin
- 1.3.2-SNAPSHOT
+ 1.3.3-SNAPSHOT
diff --git a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLExtensionRegistry.java b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLExtensionRegistry.java
index a484c2d9f9..bedaea2250 100644
--- a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLExtensionRegistry.java
+++ b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLExtensionRegistry.java
@@ -25,11 +25,10 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
import org.eclipse.wildwebdeveloper.xml.InitializationOptionsProvider;
import org.eclipse.wildwebdeveloper.xml.LemminxClasspathExtensionProvider;
@@ -64,8 +63,7 @@ public List getXMLExtensionJars() {
new Path(extension.getValue())))
.getPath()).getAbsolutePath();
} catch (InvalidRegistryObjectException | IOException e) {
- Activator.getDefault().getLog()
- .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
+ ILog.get().error(e.getMessage(), e);
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
@@ -95,8 +93,7 @@ private Map getRegiste
}
}
} catch (Exception ex) {
- Activator.getDefault().getLog()
- .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex));
+ ILog.get().error(ex.getMessage(), ex);
}
}
@@ -114,8 +111,7 @@ private void sync() {
this.extensions.put(extension, extension.getAttribute("path"));
}
} catch (Exception ex) {
- Activator.getDefault().getLog()
- .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex));
+ ILog.get().error(ex.getMessage(), ex);
}
}
}
@@ -139,8 +135,7 @@ public Map getInitiatizationOptions() {
}
}
} catch (Exception ex) {
- Activator.getDefault().getLog()
- .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex));
+ ILog.get().error(ex.getMessage(), ex);
}
}
diff --git a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java
index 085a7b583e..1f9c2e99df 100644
--- a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java
+++ b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java
@@ -32,9 +32,8 @@
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.lsp4e.LanguageServers;
@@ -113,8 +112,7 @@ public XMLLanguageServer() {
setCommands(commands);
setWorkingDirectory(System.getProperty("user.dir"));
} catch (IOException e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e));
+ ILog.get().error(e.getMessage(), e);
}
}
@@ -123,7 +121,7 @@ private Collection extends String> getProxySettings() {
for (Entry