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 getProxySettings() { for (Entry entry : System.getProperties().entrySet()) { if (entry.getKey() instanceof String property && entry.getValue() instanceof String value) { if (property.toLowerCase().contains("proxy") || property.toLowerCase().contains("proxies")) { - res.put(property, (String) entry.getValue()); + res.put(property, value); } } } diff --git a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarDialog.java b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarDialog.java index b41e85fa04..cc73840737 100644 --- a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarDialog.java +++ b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarDialog.java @@ -42,7 +42,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; -import org.eclipse.wildwebdeveloper.xml.internal.Activator; import org.eclipse.wildwebdeveloper.xml.internal.ui.Messages; /** @@ -236,20 +235,18 @@ private IStatus performValidation() { String grammarURI = grammarURIText.getText(); // Test if grammar file is filled if (grammarURI.isBlank()) { - return createStatus(IStatus.ERROR, Messages.AssociateGrammarDialog_validation_grammar_file_required); + return Status.error(Messages.AssociateGrammarDialog_validation_grammar_file_required); } // Test if grammar file exists IFile file = xmlResourceContainer.getFile(new Path(grammarURI)); if (file == null || !file.exists()) { - return createStatus(IStatus.WARNING, - Messages.bind(Messages.AssociateGrammarDialog_validation_grammar_file_notExists, grammarURI)); + return Status.warning(Messages.bind(Messages.AssociateGrammarDialog_validation_grammar_file_notExists, grammarURI)); } // In case of RelaxNG file, only xml-model association is allowed if (isRelaxNGGrammarFile(file.getFileExtension())) { BindingType bindingType = (BindingType) bindingTypeViewer.getStructuredSelection().getFirstElement(); if (bindingType == BindingType.standard) { - return createStatus(IStatus.ERROR, - Messages.bind( + return Status.error(Messages.bind( Messages.AssociateGrammarDialog_validation_grammar_file_invalid_association_for_relaxng, grammarURI, BindingType.standard.getLabel())); } @@ -257,8 +254,7 @@ private IStatus performValidation() { } // Test if selected grammar file is a XSD, DTD or RelaxNG (rnc, rng) file if (!isStandardGramarFile(file.getFileExtension())) { - return createStatus(IStatus.WARNING, - Messages.bind(Messages.AssociateGrammarDialog_validation_grammar_file_invalid_fileExtension, + return Status.warning(Messages.bind(Messages.AssociateGrammarDialog_validation_grammar_file_invalid_fileExtension, grammarURI, ALL_GRAMMAR_FILE_EXTENSION.stream().collect(Collectors.joining(", ")))); } return Status.OK_STATUS; @@ -276,10 +272,6 @@ private static int getMessageType(int severity) { return IMessageProvider.NONE; } - private static IStatus createStatus(int severity, String message) { - return new Status(severity, Activator.PLUGIN_ID, message, null); - } - private static boolean isStandardGramarFile(String fileExtension) { return W3C_GRAMMAR_FILE_EXTENSION.contains(fileExtension); } diff --git a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarHandler.java b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarHandler.java index c71fd3cd64..7742678694 100644 --- a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarHandler.java +++ b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/commands/AssociateGrammarHandler.java @@ -20,6 +20,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.lsp4e.LSPEclipseUtils; @@ -35,7 +36,6 @@ import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.eclipse.lsp4j.services.LanguageServer; import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.wildwebdeveloper.xml.internal.Activator; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -81,7 +81,7 @@ public Object execute(ExecutionEvent event, Command command, IPath path) throws LSPEclipseUtils.applyWorkspaceEdit(workEdits, ASSOCIATE_GRAMMAR_INSERT); }); } catch (Exception e) { - Activator.getDefault().getLog().error("Error while insert grammar association", e); + ILog.get().error("Error while insert grammar association", e); } } return null; diff --git a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogPreferencePage.java b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogPreferencePage.java index 4a78e619f6..ebdf075e0f 100644 --- a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogPreferencePage.java +++ b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogPreferencePage.java @@ -21,6 +21,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Adapters; +import org.eclipse.core.runtime.ILog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.PreferencePage; @@ -149,7 +150,7 @@ protected Control createContents(Composite parent) { "org.eclipse.ui.genericeditor.GenericEditor", true); } catch (PartInitException e1) { - Activator.getDefault().getLog().error(e1.getMessage(), e1); + ILog.get().error(e1.getMessage(), e1); } } } @@ -226,7 +227,7 @@ public EntriesLabelProvider() { try (InputStream imageResource = getClass().getResourceAsStream("/icons/xmlEditorIcon.png")) { image = new Image(Display.getDefault(), imageResource); } catch (IOException e) { - Activator.getDefault().getLog().error(e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } } diff --git a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogs.java b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogs.java index de071fa224..d33a33eedb 100644 --- a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogs.java +++ b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogs.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.jface.preference.IPreferenceStore; import org.eclipse.wildwebdeveloper.xml.internal.Activator; @@ -120,7 +119,7 @@ private static File getWTPExtensionCatalog() { try { Files.writeString(SYSTEM_CATALOG.toPath(), catalogFile.toString()); } catch (IOException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } return SYSTEM_CATALOG; } @@ -140,12 +139,11 @@ private static URI resolveURI(IConfigurationElement element) { if (url != null) { uri = convertToURI(url); } else { - Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, - "A URL object was not found for the given URI " + uri + " from " + contributorName)); + ILog.get().warn("A URL object was not found for the given URI " + uri + " from " + contributorName); return null; } } catch (InvalidRegistryObjectException | URISyntaxException | MalformedURLException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); return null; } } @@ -169,16 +167,13 @@ private static URI resolveURI(IConfigurationElement element) { } // Could not convert to any supported scheme - Activator.getDefault().getLog().log( - new Status(IStatus.WARNING, Activator.PLUGIN_ID, "The given URI " + element.getAttribute("uri") - + " from " + contributorName + " could not be resolved for local access")); + ILog.get().warn("The given URI " + element.getAttribute("uri") + + " from " + contributorName + " could not be resolved for local access"); return null; } catch (InvalidRegistryObjectException | IOException | URISyntaxException e) { String plugin = element.getNamespaceIdentifier(); String uriString = element.getAttribute("uri"); - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, - "Error while getting URI '" + uriString + "' from plugin '" + plugin + "' : " + e.getMessage(), - e)); + ILog.get().error("Error while getting URI '" + uriString + "' from plugin '" + plugin + "' : " + e.getMessage(), e); return null; } } diff --git a/org.eclipse.wildwebdeveloper/META-INF/MANIFEST.MF b/org.eclipse.wildwebdeveloper/META-INF/MANIFEST.MF index 389247e65d..dc7e90a50c 100644 --- a/org.eclipse.wildwebdeveloper/META-INF/MANIFEST.MF +++ b/org.eclipse.wildwebdeveloper/META-INF/MANIFEST.MF @@ -8,7 +8,7 @@ Automatic-Module-Name: org.eclipse.wildwebdeveloper Bundle-Version: 1.2.1.qualifier Bundle-Activator: org.eclipse.wildwebdeveloper.Activator Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, + org.eclipse.core.runtime;bundle-version="3.29.0", org.eclipse.lsp4e;bundle-version="0.16.0", org.eclipse.lsp4j.jsonrpc;bundle-version="0.12.0", org.eclipse.lsp4j;bundle-version="0.12.0", diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/angular/AngularLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/angular/AngularLanguageServer.java index 984ee298cd..57eef05dbc 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/angular/AngularLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/angular/AngularLanguageServer.java @@ -16,13 +16,11 @@ import java.util.List; 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.core.runtime.preferences.InstanceScope; import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; import org.eclipse.ui.preferences.ScopedPreferenceStore; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; public class AngularLanguageServer extends ProcessStreamConnectionProvider { @@ -62,7 +60,7 @@ public AngularLanguageServer() { 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); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/css/CSSLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/css/CSSLanguageServer.java index 57f47b7ae2..9d0cfe394b 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/css/CSSLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/css/CSSLanguageServer.java @@ -21,8 +21,7 @@ import java.util.Map; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.css.ui.preferences.CSSPreferenceServerConstants; import org.eclipse.wildwebdeveloper.css.ui.preferences.less.LESSPreferenceServerConstants; @@ -48,9 +47,8 @@ public CSSLanguageServer() { 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); + } } @Override diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractDebugAdapterLaunchShortcut.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractDebugAdapterLaunchShortcut.java index 019f752c8a..274046145d 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractDebugAdapterLaunchShortcut.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractDebugAdapterLaunchShortcut.java @@ -23,10 +23,9 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationType; @@ -44,7 +43,6 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.wildwebdeveloper.Activator; public abstract class AbstractDebugAdapterLaunchShortcut implements ILaunchShortcut2 { @@ -163,7 +161,7 @@ private void launch(String mode, ILaunchConfiguration[] configurations, File lau } }); } catch (CoreException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } } else if (configurations.length == 1) { Display.getDefault().asyncExec(() -> DebugUITools.launch(configurations[0], mode)); @@ -195,7 +193,7 @@ private ILaunchConfiguration[] getLaunchConfigurations(File file) { return new ILaunchConfiguration[0]; } catch (CoreException e) { ErrorDialog.openError(Display.getDefault().getActiveShell(), "error", e.getMessage(), e.getStatus()); //$NON-NLS-1$ - Activator.getDefault().getLog().log(e.getStatus()); + ILog.get().log(e.getStatus()); } return new ILaunchConfiguration[0]; } @@ -241,7 +239,7 @@ private boolean match(ILaunchConfiguration launchConfig, File selectedFile) { } return validValues.contains(program); } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); + ILog.get().log(e.getStatus()); return false; } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java index 7d47bccad9..eeb3ef57d3 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractHTMLDebugDelegate.java @@ -15,6 +15,7 @@ import java.util.Map; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -25,7 +26,6 @@ import org.eclipse.lsp4e.debug.DSPPlugin; import org.eclipse.lsp4e.debug.launcher.DSPLaunchDelegate; import org.eclipse.swt.widgets.Display; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; public class AbstractHTMLDebugDelegate extends DSPLaunchDelegate { @@ -52,16 +52,12 @@ public void launchWithParameters(ILaunchConfiguration configuration, String mode super.launch(builder); } catch (Exception e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - ErrorDialog.openError(Display.getDefault().getActiveShell(), "Debug error", e.getMessage(), errorStatus); //$NON-NLS-1$ - } - }); + IStatus errorStatus = Status.error(e.getMessage(), e); + ILog.get().log(errorStatus); + Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), + "Debug error", e.getMessage(), errorStatus)); - } + } } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java index 29af1210bf..6898cfe9c4 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/AbstractRunHTMLDebugTab.java @@ -27,6 +27,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; @@ -341,7 +342,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { validateProgramPathAndURL(); } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); + ILog.get().log(e.getStatus()); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/MessageUtils.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/MessageUtils.java index 0b0c72d945..c8df81317b 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/MessageUtils.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/MessageUtils.java @@ -11,6 +11,7 @@ import java.text.MessageFormat; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; @@ -33,7 +34,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.browser.WebBrowserPreferencePage; -import org.eclipse.wildwebdeveloper.Activator; @SuppressWarnings("restriction") public class MessageUtils { @@ -61,8 +61,8 @@ public static int showBrowserLocationsConfigurationError(Shell parentShell, ILau String browserTabMessage = suggestEditLaunch ? MessageFormat.format(Messages.RuntimeExecutable_NotDefinedError_Message_1, browserName) : ""; //$NON-NLS-1$ String webBrowsersMessage = MessageFormat.format(Messages.RuntimeExecutable_NotDefinedError_Message_2, browserName); String message = MessageFormat.format(Messages.RuntimeExecutable_NotDefinedError_Message, browserName, browserTabMessage, webBrowsersMessage); - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, title); - Activator.getDefault().getLog().log(errorStatus); + IStatus errorStatus = Status.error(title); + ILog.get().log(errorStatus); int[] result = {Window.CANCEL}; Display.getDefault().syncExec(() -> { diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java index 8ec7069d8d..96da4e7322 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java @@ -15,8 +15,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.Adapters; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -28,7 +27,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wildwebdeveloper.Activator; public class SelectionUtils { @@ -43,7 +41,7 @@ private static IFile getSelectedIFile() { return Adapters.adapt(structuredSelection.getFirstElement(), IFile.class); } } catch (Exception e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (editor != null) { diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeAttachTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeAttachTab.java index 76dcb8ba78..656f23dc33 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeAttachTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeAttachTab.java @@ -10,6 +10,7 @@ package org.eclipse.wildwebdeveloper.debug.chrome; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.swt.SWT; @@ -17,7 +18,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.Messages; import org.eclipse.wildwebdeveloper.debug.node.AttachTab; @@ -49,7 +49,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { try { urlText.setText(configuration.getAttribute(ChromeRunDAPDebugDelegate.URL, "")); } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); + ILog.get().log(e.getStatus()); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeExecutableTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeExecutableTab.java index 65cf150cc0..a1ec3070a5 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeExecutableTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeExecutableTab.java @@ -16,6 +16,7 @@ import java.util.Optional; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; @@ -37,7 +38,6 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.internal.browser.BrowserManager; import org.eclipse.ui.internal.browser.IBrowserDescriptor; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.Messages; import org.eclipse.wildwebdeveloper.debug.node.VSCodeJSDebugDelegate; @@ -51,7 +51,7 @@ public ChromeExecutableTab() { try (InputStream imageResource = getClass().getResourceAsStream("/icons/ChromeIcon.png")) { image = new Image(Display.getDefault(), imageResource); } catch (IOException e) { - Activator.getDefault().getLog().error(e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } } @@ -132,7 +132,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { } } } catch (CoreException ex) { - Activator.getDefault().getLog().log(ex.getStatus()); + ILog.get().log(ex.getStatus()); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeRunDAPDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeRunDAPDebugDelegate.java index 33dccab94e..c272e56870 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeRunDAPDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/chrome/ChromeRunDAPDebugDelegate.java @@ -17,12 +17,10 @@ import java.util.Map; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.ui.internal.browser.BrowserManager; import org.eclipse.ui.internal.browser.IBrowserDescriptor; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.LaunchConstants; import org.eclipse.wildwebdeveloper.debug.node.VSCodeJSDebugDelegate; @@ -52,8 +50,7 @@ public File computeRuntimeExecutable(ILaunchConfiguration configuration) { try { res = configuration.getAttribute(RUNTIME_EXECUTABLE, res); } catch (CoreException e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); + ILog.get().error(e.getMessage(), e); } File executable = new File(res); if (executable.isAbsolute() && executable.canExecute()) { diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java index b18e9f06f4..925be9ede3 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/FirefoxRunDABDebugDelegate.java @@ -23,6 +23,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -100,8 +101,8 @@ static File findDebugAdapter() { .getResource("/node_modules/firefox-debugadapter/adapter.bundle.js")); return new File(fileURL.toURI()); } catch (IOException | URISyntaxException e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); + IStatus errorStatus = Status.error(e.getMessage(), e); + ILog.get().log(errorStatus); Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), "Debug error", e.getMessage(), errorStatus)); //$NON-NLS-1$ } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/RunFirefoxDebugTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/RunFirefoxDebugTab.java index 8f6904ed72..5908d30391 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/RunFirefoxDebugTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/firefox/RunFirefoxDebugTab.java @@ -13,13 +13,13 @@ package org.eclipse.wildwebdeveloper.debug.firefox; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.AbstractRunHTMLDebugTab; import org.eclipse.wildwebdeveloper.debug.Messages; @@ -48,7 +48,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { boolean reloadOnChangeValue = configuration.getAttribute(FirefoxRunDABDebugDelegate.RELOAD_ON_CHANGE, false); reloadOnChange.setSelection(reloadOnChangeValue); } catch (CoreException ex) { - Activator.getDefault().getLog().log(ex.getStatus()); + ILog.get().log(ex.getStatus()); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/AttachTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/AttachTab.java index 5ae55b16df..deca2c3dd8 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/AttachTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/AttachTab.java @@ -13,6 +13,7 @@ package org.eclipse.wildwebdeveloper.debug.node; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; @@ -23,7 +24,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Spinner; import org.eclipse.swt.widgets.Text; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.LaunchConstants; import org.eclipse.wildwebdeveloper.debug.Messages; @@ -75,7 +75,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { this.addressText.setText(configuration.getAttribute(NodeAttachDebugDelegate.ADDRESS, DEFAULT_ADDRESS)); this.portSpinner.setSelection(configuration.getAttribute(LaunchConstants.PORT, defaultPort)); } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); + ILog.get().log(e.getStatus()); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugDelegate.java index a568d4f9b6..377fdac424 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugDelegate.java @@ -28,6 +28,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -43,7 +44,6 @@ import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.lsp4e.debug.DSPPlugin; import org.eclipse.swt.widgets.Display; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.LaunchConstants; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; @@ -88,7 +88,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun port = serverSocket.getLocalPort(); serverSocket.close(); } catch (IOException ex) { - Activator.getDefault().getLog().log(Status.error(ex.getMessage(), ex)); + ILog.get().error(ex.getMessage(), ex); } Process vscodeJsDebugExec = DebugPlugin.exec(new String[] { runtimeExecutable.getAbsolutePath(), file.getAbsolutePath(), Integer.toString(port) }, new File(System.getProperty("user.dir")), new String[] { "DA_TEST_DISABLE_TELEMETRY=true"}, false); IProcess vscodeJsDebugIProcess = DebugPlugin.newProcess(launch, vscodeJsDebugExec, "debug adapter"); @@ -133,8 +133,8 @@ public void handleDebugEvents(DebugEvent[] events) { }; DebugPlugin.getDefault().addDebugEventListener(shutdownParentOnCompletion); } catch (IOException e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); + IStatus errorStatus = Status.error(e.getMessage(), e); + ILog.get().log(errorStatus); Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), "Debug error", e.getMessage(), errorStatus)); //$NON-NLS-1$ } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugTab.java index aba5f0839c..5991a5d483 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeAttachDebugTab.java @@ -14,8 +14,7 @@ import java.util.Map; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.fieldassist.ControlDecoration; @@ -31,7 +30,6 @@ import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.Messages; import com.google.gson.Gson; @@ -121,7 +119,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { } } } catch (CoreException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeRunDebugLaunchShortcut.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeRunDebugLaunchShortcut.java index 2525b7c872..fa5b6f641f 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeRunDebugLaunchShortcut.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/NodeRunDebugLaunchShortcut.java @@ -17,9 +17,7 @@ import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.wildwebdeveloper.Activator; +import org.eclipse.core.runtime.ILog; import org.eclipse.wildwebdeveloper.debug.AbstractDebugAdapterLaunchShortcut; public class NodeRunDebugLaunchShortcut extends AbstractDebugAdapterLaunchShortcut { @@ -39,7 +37,7 @@ protected IResource getLaunchableResource(IContainer container) { return jsFiles[0]; } } catch (CoreException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } return null; diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/RunProgramTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/RunProgramTab.java index 506e938b82..3f77a0edf8 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/RunProgramTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/RunProgramTab.java @@ -20,6 +20,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; @@ -34,7 +35,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.LaunchConstants; import org.eclipse.wildwebdeveloper.debug.Messages; @@ -117,7 +117,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { this.argumentsText.setText(configuration.getAttribute(NodeRunDAPDebugDelegate.ARGUMENTS, "")); //$NON-NLS-1$ this.workingDirectoryText.setText(configuration.getAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, pathOrEmpty(getSelectedProject()))); //$NON-NLS-1$ } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); + ILog.get().log(e.getStatus()); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/VSCodeJSDebugDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/VSCodeJSDebugDelegate.java index 9bb2804ae1..05fe928279 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/VSCodeJSDebugDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/node/VSCodeJSDebugDelegate.java @@ -44,11 +44,10 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; @@ -69,7 +68,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.LaunchConstants; import org.eclipse.wildwebdeveloper.debug.Messages; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; @@ -128,8 +126,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun try { return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(s); } catch (CoreException e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); + ILog.get().error(e.getMessage(), e); return s; } }) @@ -173,7 +170,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun port = serverSocket.getLocalPort(); serverSocket.close(); } catch (IOException ex) { - Activator.getDefault().getLog().log(Status.error(ex.getMessage(), ex)); + ILog.get().error(ex.getMessage(), ex); } File cwdFile = cwd == null || cwd.isBlank() ? new File(System.getProperty("user.dir")) : new File(cwd); //$NON-NLS-1$ Map processEnv = new HashMap<>(System.getenv()); @@ -339,7 +336,7 @@ public void run() { "org.eclipse.ui.genericeditor.GenericEditor", true); } catch (PartInitException e1) { - Activator.getDefault().getLog().error(e1.getMessage(), e1); + ILog.get().error(e1.getMessage(), e1); } } } @@ -359,11 +356,11 @@ private IFile createNewEmptyFile(File fsFile) { file.refreshLocal(IResource.DEPTH_ZERO, null); result[0] = file; } catch (CoreException | IOException e) { - Activator.getDefault().getLog().error(e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } }, null); } catch (CoreException e) { - Activator.getDefault().getLog().error(e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } return result[0]; } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchDelegate.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchDelegate.java index 37bd41e66d..802902dd75 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchDelegate.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchDelegate.java @@ -21,6 +21,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; @@ -36,7 +37,6 @@ import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.MessageConsole; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.LaunchConstants; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; @@ -78,8 +78,8 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun try { value = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value); } catch (CoreException ex) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex); - Activator.getDefault().getLog().log(errorStatus); + IStatus errorStatus = Status.error(ex.getMessage(), ex); + ILog.get().log(errorStatus); } env.put(e.getKey(), value); }); @@ -91,8 +91,8 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun try { npmProcess.waitFor(); } catch (InterruptedException e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); + IStatus errorStatus = Status.error(e.getMessage(), e); + ILog.get().log(errorStatus); Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.NpmLaunchDelegate_npmError, e.getMessage(), errorStatus)); // $NON-NLS-1$ } @@ -101,8 +101,8 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun try { project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); + IStatus errorStatus = Status.error(e.getMessage(), e); + ILog.get().log(errorStatus); Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.NpmLaunchDelegate_npmError, e.getMessage(), errorStatus)); // $NON-NLS-1$ } @@ -110,8 +110,8 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun monitor.done(); }); } catch (IOException e) { - IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); - Activator.getDefault().getLog().log(errorStatus); + IStatus errorStatus = Status.error(e.getMessage(), e); + ILog.get().log(errorStatus); Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.NpmLaunchDelegate_npmError, e.getMessage(), errorStatus)); // $NON-NLS-1$ } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchTab.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchTab.java index 4455e26a0b..933e0ceb0b 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchTab.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/npm/NpmLaunchTab.java @@ -17,6 +17,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; @@ -35,7 +36,6 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.debug.AbstractDebugAdapterLaunchShortcut; import org.eclipse.wildwebdeveloper.debug.AbstractHTMLDebugDelegate; import org.eclipse.wildwebdeveloper.debug.LaunchConstants; @@ -151,7 +151,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { .setText(configuration.getAttribute(LaunchConstants.PROGRAM, defaultSelectedFilePath)); this.argumentsCombo.setText(configuration.getAttribute(AbstractHTMLDebugDelegate.ARGUMENTS, "install")); //$NON-NLS-1$ } catch (CoreException e) { - Activator.getDefault().getLog().log(e.getStatus()); + ILog.get().log(e.getStatus()); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintClientImpl.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintClientImpl.java index e9c9234d0f..b85d734fe4 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintClientImpl.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintClientImpl.java @@ -22,8 +22,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.lsp4e.LanguageClientImpl; import org.eclipse.lsp4j.ConfigurationItem; import org.eclipse.lsp4j.ConfigurationParams; @@ -32,7 +31,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.browser.IWorkbenchBrowserSupport; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.jsts.ui.preferences.JSTSPreferenceServerConstants; public class ESLintClientImpl extends LanguageClientImpl implements ESLintLanguageServerExtension { @@ -123,7 +121,7 @@ public CompletableFuture openDoc(Map data) { try { browserSupport.createBrowser("openDoc").openURL(new URL(data.get("url"))); } catch (Exception e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } }); } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintLanguageServer.java index 8b4bcf3bc4..b2491535c0 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/eslint/ESLintLanguageServer.java @@ -15,10 +15,8 @@ import java.util.List; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; public class ESLintLanguageServer extends ProcessStreamConnectionProvider { @@ -35,7 +33,7 @@ public ESLintLanguageServer() { 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); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/html/HTMLLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/html/HTMLLanguageServer.java index 656cdb13cc..83727fd809 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/html/HTMLLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/html/HTMLLanguageServer.java @@ -22,8 +22,7 @@ import java.util.Map; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; import org.eclipse.wildwebdeveloper.ui.preferences.ProcessStreamConnectionProviderWithPreference; @@ -50,8 +49,7 @@ public HTMLLanguageServer() { 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); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/json/JSonLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/json/JSonLanguageServer.java index f5a4f2975f..f27457de92 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/json/JSonLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/json/JSonLanguageServer.java @@ -27,9 +27,8 @@ 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.Platform; -import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.jface.preference.IPreferenceStore; @@ -85,8 +84,7 @@ public JSonLanguageServer() { 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); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java index 6493a94352..5842b0bd4d 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/jsts/JSTSLanguageServer.java @@ -27,8 +27,7 @@ import java.util.Map; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.lsp4j.DidChangeConfigurationParams; import org.eclipse.lsp4j.InitializeResult; import org.eclipse.lsp4j.jsonrpc.messages.Message; @@ -65,8 +64,7 @@ public JSTSLanguageServer() { // it's dependencies } catch (IOException e) { - Activator.getDefault().getLog().log( - new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } } @@ -89,8 +87,7 @@ public Object getInitializationOptions(URI rootUri) { options.put("tsserver", tsServer); } } catch (IOException e) { - Activator.getDefault().getLog().log( - new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e)); + ILog.get().error(e.getMessage(), e); } String maxTsServerMemory = System.getProperty("org.eclipse.wildwebdeveloper.maxTsServerMemory"); if (maxTsServerMemory != null) { diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/VueLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/VueLanguageServer.java index 5d310c6d3a..28d1d56fa1 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/VueLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/VueLanguageServer.java @@ -26,10 +26,8 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager; public class VueLanguageServer extends ProcessStreamConnectionProvider implements IExecutableExtension { @@ -50,8 +48,7 @@ public VueLanguageServer() { 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); } } diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/autoinsert/VueAutoInsertReconciler.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/autoinsert/VueAutoInsertReconciler.java index 0406783171..289510462a 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/autoinsert/VueAutoInsertReconciler.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/vue/autoinsert/VueAutoInsertReconciler.java @@ -16,6 +16,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Function; +import org.eclipse.core.runtime.ILog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; @@ -29,7 +30,6 @@ import org.eclipse.lsp4j.Range; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.swt.widgets.Display; -import org.eclipse.wildwebdeveloper.Activator; import org.eclipse.wildwebdeveloper.vue.VueLanguageServerAPI; /** @@ -115,7 +115,7 @@ private void autoInsert(DocumentEvent event) { } // viewer.setSelectedRange(offset, c) } catch (BadLocationException e) { - Activator.getDefault().getLog().error(e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } }); @@ -123,7 +123,7 @@ private void autoInsert(DocumentEvent event) { }); } catch (BadLocationException e) { // Do nothing - Activator.getDefault().getLog().error(e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } return null; }); diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/yaml/YAMLLanguageServer.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/yaml/YAMLLanguageServer.java index 0b3dc5e080..8a4924f44b 100644 --- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/yaml/YAMLLanguageServer.java +++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/yaml/YAMLLanguageServer.java @@ -16,8 +16,7 @@ import java.util.List; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.ILog; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.lsp4j.DidChangeConfigurationParams; import org.eclipse.lsp4j.InitializeResult; @@ -52,8 +51,7 @@ public YAMLLanguageServer() { 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); } }