diff --git a/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF index 701a5b50f82..9c9a10f1a42 100644 --- a/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.launching;singleton:=true -Bundle-Version: 1.4.700.qualifier +Bundle-Version: 1.4.800.qualifier Bundle-Activator: org.eclipse.ant.internal.launching.AntLaunching Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.12.0,4.0.0)", diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java index 765c07f2953..1bd60d566fb 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2016 IBM Corporation and others. + * Copyright (c) 2004, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.ant.internal.launching.debug.model; @@ -22,7 +23,6 @@ import org.eclipse.core.externaltools.internal.IExternalToolConstants; import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; @@ -108,13 +108,7 @@ public boolean hasThreads() throws DebugException { @Override public String getName() throws DebugException { if (fName == null) { - try { - fName = getLaunch().getLaunchConfiguration().getAttribute(IExternalToolConstants.ATTR_LOCATION, DebugModelMessages.AntDebugTarget_0); - fName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fName); - } - catch (CoreException e) { - fName = DebugModelMessages.AntDebugTarget_0; - } + fName = IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION.probe(getLaunch().getLaunchConfiguration()).orElse(DebugModelMessages.AntDebugTarget_0); } return fName; } diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java index e9f34782f34..2c335fa7303 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.ant.internal.launching.launchConfigurations; @@ -18,8 +19,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.variables.IStringVariableManager; -import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -40,23 +39,7 @@ public class AntMigrationDelegate implements ILaunchConfigurationMigrationDelega * @return the buildfile or null if not in the workspace */ protected IFile getFileForCandidate(ILaunchConfiguration candidate) { - IFile file = null; - String expandedLocation = null; - String location = null; - IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); - try { - location = candidate.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); - if (location != null) { - expandedLocation = manager.performStringSubstitution(location); - if (expandedLocation != null) { - file = AntLaunchingUtil.getFileForLocation(expandedLocation, null); - } - } - } - catch (CoreException e) { - // do nothing - } - return file; + return IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION.probe(candidate).map(l -> AntLaunchingUtil.getFileForLocation(l, null)).orElse(null); } @Override diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java index 0c3cb274e37..8c67adb9a66 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.ant.internal.ui; @@ -20,7 +21,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -100,7 +100,7 @@ private AntUtil() { /** * Returns a single-string of the strings for storage. - * + * * @param strings * the array of strings * @return a single-string representation of the strings or null if the array is empty. @@ -112,7 +112,7 @@ public static String combineStrings(String[] strings) { /** * Returns an array of targets to be run, or null if none are specified (indicating the default target or implicit target should be * run). - * + * * @param configuration * launch configuration * @return array of target names, or null @@ -126,7 +126,7 @@ public static String[] getTargetNames(ILaunchConfiguration configuration) throws /** * Returns a map of properties to be defined for the build, or null if none are specified (indicating no additional properties * specified for the build). - * + * * @param configuration * launch configuration * @return map of properties (name --> value), or null @@ -139,7 +139,7 @@ public static Map getProperties(ILaunchConfiguration configurati /** * Returns a String specifying the Ant home to use for the build. - * + * * @param configuration * launch configuration * @return String specifying Ant home to use or null @@ -153,7 +153,7 @@ public static String getAntHome(ILaunchConfiguration configuration) throws CoreE /** * Returns an array of property files to be used for the build, or null if none are specified (indicating no additional property * files specified for the build). - * + * * @param configuration * launch configuration * @return array of property file names, or null @@ -195,7 +195,7 @@ public static AntTargetNode[] getTargets(String path, ILaunchConfiguration confi } private static Map getAllProperties(ILaunchConfiguration config) throws CoreException { - String allArgs = config.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null); + String allArgs = IExternalToolConstants.LAUNCH_ATTRIBUTE_ARGUMENTS.read(config); Map properties = new HashMap<>(); if (allArgs != null) { // filter arguments to avoid resolving variables that will prompt the user @@ -213,9 +213,7 @@ private static Map getAllProperties(ILaunchConfiguration config) } Map configProperties = getProperties(config); if (configProperties != null) { - Iterator keys = configProperties.keySet().iterator(); - while (keys.hasNext()) { - String name = keys.next(); + for (String name : configProperties.keySet()) { if (properties.get(name) == null) { properties.put(name, configProperties.get(name)); } @@ -349,11 +347,11 @@ private static IDocument getDocument(File buildFile) { /** * Returns the list of URLs that define the custom classpath for the Ant build, or null if the global classpath is to be used. - * + * * @param config * launch configuration * @return a list of URL - * + * * @throws CoreException * if file does not exist, IO problems, or invalid format. */ @@ -373,7 +371,7 @@ private static String expandVariableString(String variableString, String invalid /** * Returns the list of target names to run - * + * * @param extraAttibuteValue * the external tool's extra attribute value for the run targets key. * @return a list of target names @@ -384,7 +382,7 @@ public static String[] parseRunTargets(String extraAttibuteValue) { /** * Returns the list of Strings that were delimiter separated. - * + * * @param delimString * the String to be tokenized based on the delimiter * @param delim @@ -397,7 +395,7 @@ public static String[] parseString(String delimString, String delim) { /** * Returns an IFile with the given fully qualified path (relative to the workspace root). The returned IFile may or may not exist. - * + * * @param fullPath * the path to look up * @return the {@link IFile} which may or may not exist @@ -446,9 +444,9 @@ public static IHyperlink getLocationLink(String path, File buildFileParent) { /** * Returns the workspace file associated with the given path in the local file system, or null if none. If the path happens to be a * relative path, then the path is interpreted as relative to the specified parent file. - * + * * Attempts to handle linked files; the first found linked file with the correct path is returned. - * + * * @return file or null * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath) */ @@ -459,7 +457,7 @@ public static IFile getFileForLocation(String path, File buildFileParent) { /** * Migrates the classpath in the given configuration from the old format to the new format. The old format is not preserved. Instead, the default * classpath will be used. However, ANT_HOME settings are preserved. - * + * * @param configuration * a configuration to migrate * @throws CoreException @@ -500,7 +498,7 @@ private static int getOffset(int line, int column, ITextEditor editor) { /** * Opens the given editor on the buildfile of the provided node and selects that node in the editor. - * + * * @param page * the page to open the editor in * @param editorDescriptor @@ -540,7 +538,7 @@ public static void openInEditor(IWorkbenchPage page, IEditorDescriptor editorDes /** * Opens an editor on the buildfile of the provided node and selects that node in the editor. - * + * * @param page * the page to open the editor in * @param node @@ -639,9 +637,9 @@ public static boolean isKnownAntFile(IResource resource) { /** * Returns if the given extension is a known extension to Ant i.e. a supported content type extension. - * + * * @return true if the file extension is supported false otherwise - * + * * @since 3.8 */ public static boolean isKnownAntFile(File file) { @@ -666,7 +664,7 @@ public static boolean isKnownAntFile(File file) { /** * Returns an array of build file names from the ant preference store - * + * * @return an array of build file names * @since 3.6 */ @@ -682,7 +680,7 @@ public static String[] getKnownBuildfileNames() { /** * Returns if the given file is a known build file name, based on the given names from the Ant > Names preference - * + * * @return true if the name of the file is given in the Ant > Names preference, false otherwise * @since 3.6 */ @@ -698,7 +696,7 @@ public static boolean isKnownBuildfileName(String filename) { /** * A helper method to extract the build filename extensions as defined in the extender of the content-types extension-point. - * + * * @return An empty array or list of filename extensions as specified in the content-types extension * @since 3.8 */ @@ -719,7 +717,7 @@ public static String[] getKnownBuildFileExtensions() { /** * A helper method to construct a RegEx pattern out of the extensions - * + * * @return A String that is a RegEx pattern representing the extensions * @since 3.8 */ @@ -734,7 +732,7 @@ public static String getKnownBuildFileExtensionsAsPattern() { /** * Returns if the given file name is known as a build file. This method consults all of the known file extensions from the Ant-defined content * types - * + * * @return true if the file name matches an Ant build file pattern false otherwise * @since 3.8 */ diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java index 95bac0f450a..99a6316071d 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,9 +10,12 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.ant.internal.ui.launchConfigurations; +import java.util.Optional; + import org.eclipse.ant.internal.core.IAntCoreConstants; import org.eclipse.ant.internal.ui.AntUIPlugin; import org.eclipse.ant.internal.ui.AntUtil; @@ -24,7 +27,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -45,44 +47,27 @@ public class AntMainTab extends ExternalToolsMainTab { - private String fCurrentLocation = null; + private Optional fCurrentLocation; private Button fSetInputHandlerButton; private IFile fNewFile; @Override public void initializeFrom(ILaunchConfiguration configuration) { super.initializeFrom(configuration); - try { - fCurrentLocation = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); - } - catch (CoreException e) { - // do nothing - } + fCurrentLocation = IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION.probe(configuration); updateCheckButtons(configuration); } @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { super.performApply(configuration); - try { - // has the location changed - String newLocation = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); - if (newLocation != null) { - if (!newLocation.equals(fCurrentLocation)) { - updateTargetsTab(); - fCurrentLocation = newLocation; - updateProjectName(configuration); - } - } else if (fCurrentLocation != null) { - updateTargetsTab(); - fCurrentLocation = newLocation; - updateProjectName(configuration); - } - } - catch (CoreException e) { - // do nothing + // has the location changed + Optional newLocation = IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION.probe(configuration); + if (!newLocation.equals(fCurrentLocation)) { + updateTargetsTab(); + fCurrentLocation = newLocation; + updateProjectName(configuration); } - setMappedResources(configuration); setAttribute(IAntUIConstants.SET_INPUTHANDLER, configuration, fSetInputHandlerButton.getSelection(), true); } @@ -110,26 +95,12 @@ private void updateProjectName(ILaunchConfigurationWorkingCopy configuration) { } private IFile getIFile(ILaunchConfigurationWorkingCopy configuration) { - IFile file = null; if (fNewFile != null) { - file = fNewFile; + IFile file = fNewFile; fNewFile = null; - } else { - IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); - try { - String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); - if (location != null) { - String expandedLocation = manager.performStringSubstitution(location); - if (expandedLocation != null) { - file = AntUtil.getFileForLocation(expandedLocation, null); - } - } - } - catch (CoreException e) { - // do nothing - } + return file; } - return file; + return IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION.probe(configuration).map(exp -> AntUtil.getFileForLocation(exp, null)).orElse(null); } @Override @@ -153,7 +124,7 @@ public void createControl(Composite parent) { /** * Creates the controls needed to edit the set input handler attribute of an Ant build - * + * * @param parent * the composite to create the controls in */ diff --git a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF index 14d67d91bc9..d9d8d92c9a7 100644 --- a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.ui; singleton:=true -Bundle-Version: 3.10.0.qualifier +Bundle-Version: 3.10.100.qualifier Bundle-Activator: org.eclipse.ant.internal.ui.AntUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF b/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF index 169587e22ed..2be9d48ae29 100644 --- a/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.core.externaltools;singleton:=true -Bundle-Version: 1.3.400.qualifier +Bundle-Version: 1.3.500.qualifier Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.9.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.2.800,4.0.0)" diff --git a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/IExternalToolConstants.java b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/IExternalToolConstants.java index 86cad5dce44..33bd16daf7b 100644 --- a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/IExternalToolConstants.java +++ b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/IExternalToolConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,9 +11,15 @@ * Contributors: * IBM Corporation - initial API and implementation * dakshinamurthy.karra@gmail.com - bug 165371 + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.core.externaltools.internal; + +import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsProgramMessages; +import org.eclipse.debug.core.ILaunchAttribute; +import org.eclipse.debug.core.ILaunchAttributeIdentity; + /** * Defines the constants available for client use. *

@@ -30,26 +36,31 @@ public interface IExternalToolConstants { String EMPTY_STRING = ""; //$NON-NLS-1$ /** - * Plug-in identifier for external tools UI (value org.eclipse.ui.externaltools). + * Plug-in identifier for external tools UI (value + * org.eclipse.ui.externaltools). */ - String UI_PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$; + String UI_PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$ ; /** - * Plug-in identifier for external tools core (value org.eclipse.core.externaltools). + * Plug-in identifier for external tools core (value + * org.eclipse.core.externaltools). */ - String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$; + String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$ ; // ------- Refresh Variables ------- /** - * Variable that expands to the workspace root object (value workspace). + * Variable that expands to the workspace root object (value + * workspace). */ String VAR_WORKSPACE = "workspace"; //$NON-NLS-1$ /** - * Variable that expands to the project resource (value project). + * Variable that expands to the project resource (value + * project). */ String VAR_PROJECT = "project"; //$NON-NLS-1$ /** - * Variable that expands to the container resource (value container). + * Variable that expands to the container resource (value + * container). */ String VAR_CONTAINER = "container"; //$NON-NLS-1$ /** @@ -57,44 +68,45 @@ public interface IExternalToolConstants { */ String VAR_RESOURCE = "resource"; //$NON-NLS-1$ /** - * Variable that expands to the working set object (value working_set). + * Variable that expands to the working set object (value + * working_set). */ String VAR_WORKING_SET = "working_set"; //$NON-NLS-1$ // ------- Tool Types ------- /** - * External tool type for programs such as executables, batch files, - * shell scripts, etc (value programType). + * External tool type for programs such as executables, batch files, shell + * scripts, etc (value programType). */ - String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$; + String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$ ; // ------- Build Types ------- /** - * Build type indicating an incremental project build request for - * the external tool running as a builder (value incremental). + * Build type indicating an incremental project build request for the + * external tool running as a builder (value incremental). */ String BUILD_TYPE_INCREMENTAL = "incremental"; //$NON-NLS-1$ /** - * Build type indicating a full project build request for - * the external tool running as a builder (value full). + * Build type indicating a full project build request for the external tool + * running as a builder (value full). */ String BUILD_TYPE_FULL = "full"; //$NON-NLS-1$ /** - * Build type indicating an automatic project build request for - * the external tool running as a builder (value auto). + * Build type indicating an automatic project build request for the external + * tool running as a builder (value auto). */ String BUILD_TYPE_AUTO = "auto"; //$NON-NLS-1$ /** - * Build type indicating a clean project build request for - * the external tool running as a builder (value clean). + * Build type indicating a clean project build request for the external tool + * running as a builder (value clean). */ String BUILD_TYPE_CLEAN = "clean"; //$NON-NLS-1$ /** - * Build type indicating no project build request for - * the external tool running as a builder (value none). + * Build type indicating no project build request for the external tool + * running as a builder (value none). */ String BUILD_TYPE_NONE = "none"; //$NON-NLS-1$ @@ -129,9 +141,12 @@ public interface IExternalToolConstants { /** * Boolean attribute indicating if external tool output should be captured. * Default value is false. - * @deprecated since 3.1 Replaced by org.eclipse.debug.core.DebugPlugin.ATTR_CAPTURE_OUTPUT + * + * @deprecated since 3.1 Replaced by + * org.eclipse.debug.core.DebugPlugin.ATTR_CAPTURE_OUTPUT */ - @Deprecated String ATTR_CAPTURE_OUTPUT = UI_PLUGIN_ID + ".ATTR_CAPTURE_OUTPUT"; //$NON-NLS-1$ + @Deprecated + String ATTR_CAPTURE_OUTPUT = UI_PLUGIN_ID + ".ATTR_CAPTURE_OUTPUT"; //$NON-NLS-1$ /** * String attribute identifying the location of an external. Default value * is null. Encoding is tool specific. @@ -139,22 +154,37 @@ public interface IExternalToolConstants { String ATTR_LOCATION = UI_PLUGIN_ID + ".ATTR_LOCATION"; //$NON-NLS-1$ /** - * Boolean attribute indicating if the user should be prompted for - * arguments before running a tool. Default value is false. - * THIS ATTRIBUTE IS NOT USED. + * {@link ILaunchAttributeIdentity} identifying the location of an external. + * + * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_LOCATION + */ + ILaunchAttributeIdentity LAUNCH_ATTRIBUTE_IDENTITY_LOCATION = ILaunchAttributeIdentity.of(ATTR_LOCATION); + + /** + * {@link ILaunchAttribute} identifying the location of an external. + * Default value is null. Encoding is tool specific. + * + * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_LOCATION + */ + ILaunchAttribute LAUNCH_ATTRIBUTE_LOCATION = ILaunchAttribute.of(LAUNCH_ATTRIBUTE_IDENTITY_LOCATION, String.class, lc -> null, ExternalToolsProgramMessages.LaunchAttributeLocation_name); + + /** + * Boolean attribute indicating if the user should be prompted for arguments + * before running a tool. Default value is false. THIS + * ATTRIBUTE IS NOT USED. */ String ATTR_PROMPT_FOR_ARGUMENTS = UI_PLUGIN_ID + ".ATTR_PROMPT_FOR_ARGUMENTS"; //$NON-NLS-1$ /** - * String attribute identifying the scope of resources that should trigger an - * external tool to run. Default value is null - * indicating that the builder will be triggered for all changes. + * String attribute identifying the scope of resources that should trigger + * an external tool to run. Default value is null indicating + * that the builder will be triggered for all changes. */ String ATTR_BUILDER_SCOPE = UI_PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$ /** - * String attribute containing an array of build kinds for which an - * external tool builder should be run. + * String attribute containing an array of build kinds for which an external + * tool builder should be run. */ String ATTR_RUN_BUILD_KINDS = UI_PLUGIN_ID + ".ATTR_RUN_BUILD_KINDS"; //$NON-NLS-1$ @@ -170,6 +200,23 @@ public interface IExternalToolConstants { */ String ATTR_TOOL_ARGUMENTS = UI_PLUGIN_ID + ".ATTR_TOOL_ARGUMENTS"; //$NON-NLS-1$ + /** + * {@link ILaunchAttributeIdentity} containing the arguments that should be + * passed to the tool + * + * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_ARGUMENTS + */ + ILaunchAttributeIdentity LAUNCH_ATTRIBUTE_IDENTITY_ARGUMENTS = ILaunchAttributeIdentity.of(ATTR_TOOL_ARGUMENTS); + + /** + * {@link ILaunchAttribute} containing the arguments that should be + * passed to the tool. Default value is null, and encoding is + * tool specific. + * + * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_ARGUMENTS + */ + ILaunchAttribute LAUNCH_ATTRIBUTE_ARGUMENTS = ILaunchAttribute.of(LAUNCH_ATTRIBUTE_IDENTITY_ARGUMENTS, String.class, lc -> null, ExternalToolsProgramMessages.LaunchAttributeArguments_name); + /** * String attribute identifying the working directory of an external tool. * Default value is null, which indicates a default working @@ -178,16 +225,34 @@ public interface IExternalToolConstants { String ATTR_WORKING_DIRECTORY = UI_PLUGIN_ID + ".ATTR_WORKING_DIRECTORY"; //$NON-NLS-1$ /** - * String attribute identifying whether an external tool builder configuration - * is enabled. The default value is true, which indicates - * that the configuration will be executed as appropriate by the builder. + * {@link ILaunchAttributeIdentity} identifying the working directory of an + * external tool. + * + * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_WORKING_DIRECTORY + */ + ILaunchAttributeIdentity LAUNCH_ATTRIBUTE_IDENTITY_WORKING_DIRECTORY = ILaunchAttributeIdentity.of(ATTR_WORKING_DIRECTORY); + + /** + * {@link ILaunchAttribute} identifying the working directory of an + * external tool. Default value is null, which indicates a + * default working directory, which is tool specific. + * + * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_WORKING_DIRECTORY + */ + ILaunchAttribute LAUNCH_ATTRIBUTE_WORKING_DIRECTORY = ILaunchAttribute.of(LAUNCH_ATTRIBUTE_IDENTITY_WORKING_DIRECTORY, String.class, lc -> null, ExternalToolsProgramMessages.LaunchAttributeWorkingDirectory_name); + + /** + * String attribute identifying whether an external tool builder + * configuration is enabled. The default value is true, which + * indicates that the configuration will be executed as appropriate by the + * builder. */ String ATTR_BUILDER_ENABLED = UI_PLUGIN_ID + ".ATTR_BUILDER_ENABLED"; //$NON-NLS-1$ /** - * Boolean attribute identifying whether an external tool launcher should execute - * synchronously (value false) or asynchronously (value true). - * Default value is + * Boolean attribute identifying whether an external tool launcher should + * execute synchronously (value false) or asynchronously (value + * true). Default value is */ String ATTR_LAUNCH_IN_BACKGROUND = "org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND"; //$NON-NLS-1$ @@ -197,17 +262,20 @@ public interface IExternalToolConstants { int ERR_INTERNAL_ERROR = 150; /** - * String attribute identifying a non-external tool builder launch configuration that is disabled - * The value is the name of the disabled builder. + * String attribute identifying a non-external tool builder launch + * configuration that is disabled The value is the name of the disabled + * builder. */ - String ATTR_DISABLED_BUILDER = UI_PLUGIN_ID + ".ATTR_DISABLED_BUILDER"; //$NON-NLS-1$ + String ATTR_DISABLED_BUILDER = UI_PLUGIN_ID + ".ATTR_DISABLED_BUILDER"; //$NON-NLS-1$ /** - * boolean attribute identifying that an external tool builder has been configured for triggering - * using the ICommand.setBuilding(int) mechanism + * boolean attribute identifying that an external tool builder has been + * configured for triggering using the + * ICommand.setBuilding(int) mechanism + * * @since 3.1 */ - String ATTR_TRIGGERS_CONFIGURED = UI_PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED"; //$NON-NLS-1$ + String ATTR_TRIGGERS_CONFIGURED = UI_PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED"; //$NON-NLS-1$ /** * String attribute identifying the build scope for a launch configuration. @@ -221,4 +289,5 @@ public interface IExternalToolConstants { * true. */ String ATTR_INCLUDE_REFERENCED_PROJECTS = UI_PLUGIN_ID + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$ + } diff --git a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java index 33f4daeb853..090d6f6e41f 100644 --- a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java +++ b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -12,11 +12,13 @@ * IBM Corporation - initial API and implementation * Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution) * dakshinamurthy.karra@gmail.com - bug 165371 + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.core.externaltools.internal.launchConfigurations; import java.io.File; +import java.util.Optional; import org.eclipse.core.externaltools.internal.IExternalToolConstants; import org.eclipse.core.resources.IProject; @@ -144,12 +146,7 @@ public static IPath getWorkingDirectory(ILaunchConfiguration configuration) thro * configuration attribute, or if unable to resolve any variables */ public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException { - String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null); - if (args != null) { - String expanded = getStringVariableManager().performStringSubstitution(args); - return parseStringIntoList(expanded); - } - return null; + return Optional.of(IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION.read(configuration)).map(ExternalToolsCoreUtil::parseStringIntoList).orElse(null); } private static IStringVariableManager getStringVariableManager() { diff --git a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java index b733eb9ed02..53c80a794fc 100644 --- a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java +++ b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.core.externaltools.internal.launchConfigurations; @@ -29,6 +30,15 @@ public class ExternalToolsProgramMessages extends NLS { public static String ExternalToolsUtil_invalidLocation__0_; public static String ExternalToolsUtil_invalidDirectory__0_; + + public static String LaunchAttributeArguments_name; + + + public static String LaunchAttributeLocation_name; + + + public static String LaunchAttributeWorkingDirectory_name; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, ExternalToolsProgramMessages.class); diff --git a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties index 7d91899381d..01e01b6fe2c 100644 --- a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties +++ b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2009 IBM Corporation and others. +# Copyright (c) 2000, 2025 IBM Corporation and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Alexander Fedorov (ArSysOp) - API to process launch configuration attributes ############################################################################### BackgroundResourceRefresher_0=Refreshing resources... @@ -20,4 +21,7 @@ ProgramLaunchDelegate_5=[pid: {0}] ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0} ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}. -ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}. \ No newline at end of file +ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}. +LaunchAttributeArguments_name=Arguments +LaunchAttributeLocation_name=Location +LaunchAttributeWorkingDirectory_name=Working Directory diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchAttribute.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchAttribute.java new file mode 100644 index 00000000000..1cd99eaedfd --- /dev/null +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchAttribute.java @@ -0,0 +1,170 @@ +/******************************************************************************* + * Copyright (c) 2024, 2025 ArSysOp. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Alexander Fedorov (ArSysOp) - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.core; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; + +/** + * + * The definition of {@link ILaunchConfiguration} attribute convenience to: + *

    + *
  • {@link ILaunchConfiguration#getAttribute(String, String)} and similar + * operations
  • + *
  • {@link ILaunchConfigurationWorkingCopy#setAttribute(String, String)} and + * similar operations
  • + *
  • Connecting {@link ILaunchConfiguration} attributes with preferences
  • + *
  • Representing {@link ILaunchConfiguration} attributes in UI
  • + *
+ * + * @since 3.23 + */ +public interface ILaunchAttribute { + + /** + * + * @return identity for defined attribute + */ + ILaunchAttributeIdentity identity(); + + /** + * Reads the value of launch configuration attribute and tries to substitute + * variables for String values.
+ * Returns the attribute value or fails with {@link CoreException}, may + * return null value + * + * @param configuration the launch configuration to read attribute from, + * must not be null + * @return the attribute value, may return null + */ + V read(ILaunchConfiguration configuration) throws CoreException; + + /** + * "Probes" the value of launch configuration attribute.
+ * Returns {@link Optional} in case of read failure or null + * value to let caller decide how to proceed + * + * @param configuration the launch configuration to read attribute from, + * must not be null + * @return the {@link Optional} with attribute value + */ + Optional probe(ILaunchConfiguration configuration); + + /** + * Writes the supplied value to the launch configuration working copy + * + * @param working the launch configuration working copy to write value to, + * must not be null + * @param value the value, may be null + */ + void write(ILaunchConfigurationWorkingCopy working, V value); + + /** + * creates an instance of {@link ILaunchAttribute} using primitives (useful + * for existing code) + * + * @param the value type for the launch attribute + * @param identity the id of the attribute, must not be null + * @param type the value type of the attribute, must not be + * null + * @param value the {@link Function} to calculate of default value of the + * attribute from {@link ILaunchConfiguration}, must not be + * null + * @param name the name of the attribute, must not be null + * @return created instance of {@link ILaunchAttribute} + */ + static ILaunchAttribute of(ILaunchAttributeIdentity identity, Class type, Function value, String name) { + return new ConsiderStringVariables<>(identity, type, value, name, name); + } + + /** + * Default implementation for {@link ILaunchAttribute} that tries to + * substitute variables for launch attributes with {@link String} type + * + * @see IStringVariableManager + */ + record ConsiderStringVariables(ILaunchAttributeIdentity identity, Class type, Function defaults, String name, String description) implements ILaunchAttribute { + + @Override + public ILaunchAttributeIdentity identity() { + return identity; + } + + @Override + public V read(ILaunchConfiguration configuration) throws CoreException { + return readInternal(configuration); + } + + @Override + public Optional probe(ILaunchConfiguration configuration) { + try { + return Optional.ofNullable(read(configuration)); + } catch (CoreException e) { + Platform.getLog(getClass()).log(e.getStatus()); + return Optional.empty(); + } + } + + private V readInternal(ILaunchConfiguration configuration) throws CoreException { + if (String.class.equals(type)) { + return type.cast(VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(configuration.getAttribute(identity.id(), String.class.cast(defaults.apply(configuration))))); + } + if (Boolean.class.equals(type)) { + return type.cast(configuration.getAttribute(identity.id(), Boolean.class.cast(defaults.apply(configuration)))); + } + if (Integer.class.equals(type)) { + return type.cast(configuration.getAttribute(identity.id(), Integer.class.cast(defaults.apply(configuration)))); + } + if (List.class.equals(type)) { + return type.cast(configuration.getAttribute(identity.id(), List.class.cast(defaults.apply(configuration)))); + } + if (Map.class.equals(type)) { + return type.cast(configuration.getAttribute(identity.id(), Map.class.cast(defaults.apply(configuration)))); + } + if (Set.class.equals(type)) { + return type.cast(configuration.getAttribute(identity.id(), Set.class.cast(defaults.apply(configuration)))); + } + throw new CoreException(Status.error(identity.id(), new ClassCastException())); + } + + @Override + public void write(ILaunchConfigurationWorkingCopy working, V value) { + if (String.class.equals(type)) { + working.setAttribute(identity.id(), String.class.cast(value)); + } else if (Integer.class.equals(type)) { + working.setAttribute(identity.id(), Integer.class.cast(value).intValue()); + } else if (Boolean.class.equals(type)) { + working.setAttribute(identity.id(), Boolean.class.cast(value).booleanValue()); + } else if (List.class.equals(type)) { + working.setAttribute(identity.id(), List.class.cast(value)); + } else if (Map.class.equals(type)) { + working.setAttribute(identity.id(), Map.class.cast(value)); + } else if (Set.class.equals(type)) { + working.setAttribute(identity.id(), Set.class.cast(value)); + } else { + working.setAttribute(identity.id(), value); + } + } + } + +} diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchAttributeIdentity.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchAttributeIdentity.java new file mode 100644 index 00000000000..cc87b5711b0 --- /dev/null +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchAttributeIdentity.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2024, 2025 ArSysOp. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Alexander Fedorov (ArSysOp) - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.core; + +/** + * Identifies an attribute in {@link ILaunchConfiguration} + * + * @since 3.23 + */ +public interface ILaunchAttributeIdentity { + + /** + * String id of {@link ILaunchConfiguration} attribute for "low-level" + * operations + * + * @return id of launch attribute + */ + String id(); + + /** + * creates an instance of {@link ILaunchAttributeIdentity} + * + * @param id an id of launch attribute + * @return created instance of {@link ILaunchAttributeIdentity} + */ + static ILaunchAttributeIdentity of(String id) { + return new Record(id); + } + + /** + * Default implementation for {@link ILaunchAttributeIdentity} + * + */ + record Record(String id) implements ILaunchAttributeIdentity { + + } + +} diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java index e1237be4220..0d974aaa458 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation * dakshinamurthy.karra@gmail.com - bug 165371 + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.ui.externaltools.internal.launchConfigurations; @@ -25,7 +26,6 @@ public class ExternalToolsLaunchConfigurationMessages extends NLS { public static String ExternalToolsMainTab_Working__Directory__5; public static String ExternalToolsMainTab_Browse_Wor_kspace____6; public static String ExternalToolsMainTab_Browse_F_ile_System____7; - public static String ExternalToolsMainTab_Error_reading_configuration_10; public static String ExternalToolsMainTab__Main_17; public static String ExternalToolsMainTab_External_tool_location_cannot_be_empty_18; public static String ExternalToolsMainTab_External_tool_location_does_not_exist_19; @@ -36,7 +36,6 @@ public class ExternalToolsLaunchConfigurationMessages extends NLS { public static String ExternalToolsMainTab__Arguments___1; public static String ExternalToolsMainTab_Varia_bles____2; public static String ExternalToolsMainTab_3; - public static String ExternalToolsMainTab_Error_reading_configuration_7; public static String ExternalToolsMainTab_Not_a_directory; public static String ExternalToolsMainTab_30; public static String ExternalToolsMainTab_31; diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties index be127c1207f..707dbd347c1 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2010 IBM Corporation and others. +# Copyright (c) 2000, 2025 IBM Corporation and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ # Contributors: # IBM Corporation - initial API and implementation # dakshinamurthy.karra@gmail.com - bug 165371 +# Alexander Fedorov (ArSysOp) - API to process launch configuration attributes ############################################################################### ExternalToolsMainTab__Location___2=&Location: @@ -19,7 +20,6 @@ ExternalToolsMainTab_Brows_e_File_System____4=Brows&e File System... ExternalToolsMainTab_Working__Directory__5=Working &Directory: ExternalToolsMainTab_Browse_Wor_kspace____6=Browse Wor&kspace... ExternalToolsMainTab_Browse_F_ile_System____7=Browse File Syste&m... -ExternalToolsMainTab_Error_reading_configuration_10=Error reading configuration ExternalToolsMainTab__Main_17=Main ExternalToolsMainTab_External_tool_location_cannot_be_empty_18=External tool location cannot be empty ExternalToolsMainTab_External_tool_location_does_not_exist_19=External tool location does not exist @@ -30,7 +30,6 @@ ExternalToolsMainTab_23=Select a working directory: ExternalToolsMainTab__Arguments___1=&Arguments: ExternalToolsMainTab_Varia_bles____2=Variable&s... ExternalToolsMainTab_3=Note: Enclose an argument containing spaces using double-quotes (\"). -ExternalToolsMainTab_Error_reading_configuration_7=Error reading configuration ExternalToolsMainTab_Not_a_directory=The specified location is not a directory ExternalToolsMainTab_30=Please specify the location of the external tool you would like to configure. ExternalToolsMainTab_31=Var&iables... diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java index b6cadb9a189..9340c48c46a 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,11 +10,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.ui.externaltools.internal.launchConfigurations; import java.io.File; +import java.util.Optional; +import java.util.function.Predicate; import org.eclipse.core.externaltools.internal.IExternalToolConstants; import org.eclipse.core.resources.IResource; @@ -23,6 +26,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.debug.core.ILaunchAttribute; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; @@ -50,7 +54,6 @@ import org.eclipse.ui.dialogs.ContainerSelectionDialog; import org.eclipse.ui.dialogs.ResourceSelectionDialog; import org.eclipse.ui.externaltools.internal.model.ExternalToolsImages; -import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin; /** * The external tools main tab allows the user to configure primary attributes @@ -312,13 +315,7 @@ public void initializeFrom(ILaunchConfiguration configuration) { * configuration. */ protected void updateWorkingDirectory(ILaunchConfiguration configuration) { - String workingDir= IExternalToolConstants.EMPTY_STRING; - try { - workingDir= configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, IExternalToolConstants.EMPTY_STRING); - } catch (CoreException ce) { - ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.ExternalToolsMainTab_Error_reading_configuration_10, ce); - } - workDirectoryField.setText(workingDir); + updateTextField(workDirectoryField, IExternalToolConstants.LAUNCH_ATTRIBUTE_WORKING_DIRECTORY, configuration); } /** @@ -326,13 +323,7 @@ protected void updateWorkingDirectory(ILaunchConfiguration configuration) { * configuration. */ protected void updateLocation(ILaunchConfiguration configuration) { - String location= IExternalToolConstants.EMPTY_STRING; - try { - location= configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, IExternalToolConstants.EMPTY_STRING); - } catch (CoreException ce) { - ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.ExternalToolsMainTab_Error_reading_configuration_10, ce); - } - locationField.setText(location); + updateTextField(locationField, IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION, configuration); } /** @@ -340,43 +331,31 @@ protected void updateLocation(ILaunchConfiguration configuration) { * configuration. */ protected void updateArgument(ILaunchConfiguration configuration) { - String arguments= IExternalToolConstants.EMPTY_STRING; - try { - arguments= configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, IExternalToolConstants.EMPTY_STRING); - } catch (CoreException ce) { - ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.ExternalToolsMainTab_Error_reading_configuration_7, ce); - } - argumentField.setText(arguments); + updateTextField(argumentField, IExternalToolConstants.LAUNCH_ATTRIBUTE_ARGUMENTS, configuration); + } + + private void updateTextField(Text text, ILaunchAttribute defined, ILaunchConfiguration configuration) { + text.setText(defined.probe(configuration).orElse(IExternalToolConstants.EMPTY_STRING)); } @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { - String location= locationField.getText().trim(); - if (location.length() == 0) { - configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null); - } else { - configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, location); - } - - String workingDirectory= workDirectoryField.getText().trim(); - if (workingDirectory.length() == 0) { - configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String)null); - } else { - configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, workingDirectory); - } - - String arguments= argumentField.getText().trim(); - if (arguments.length() == 0) { - configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String)null); - } else { - configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments); - } - + applyText(locationField, IExternalToolConstants.LAUNCH_ATTRIBUTE_LOCATION, configuration); + applyText(workDirectoryField, IExternalToolConstants.LAUNCH_ATTRIBUTE_WORKING_DIRECTORY, configuration); + applyText(argumentField, IExternalToolConstants.LAUNCH_ATTRIBUTE_ARGUMENTS, configuration); if(userEdited) { configuration.setAttribute(FIRST_EDIT, (String)null); } } + private void applyText(Text text, ILaunchAttribute defined, ILaunchConfigurationWorkingCopy configuration) { + defined.write(configuration, nullIfEmpty(text)); + } + + private String nullIfEmpty(Text text) { + return Optional.of(text.getText().trim()).filter(Predicate.not(String::isEmpty)).orElse(null); + } + @Override public String getName() { return ExternalToolsLaunchConfigurationMessages.ExternalToolsMainTab__Main_17; diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java index 02810c69e64..18b96a2ea76 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation * dakshinamurthy.karra@gmail.com - bug 165371 + * Alexander Fedorov (ArSysOp) - API to process launch configuration attributes *******************************************************************************/ package org.eclipse.ui.externaltools.internal.model; @@ -167,7 +168,9 @@ public interface IExternalToolConstants { /** * String attribute identifying the location of an external. Default value * is null. Encoding is tool specific. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_LOCATION} + * + * @deprecated use + * {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_LOCATION} */ @Deprecated String ATTR_LOCATION = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_LOCATION; @@ -204,7 +207,9 @@ public interface IExternalToolConstants { /** * String attribute containing the arguments that should be passed to the * tool. Default value is null, and encoding is tool specific. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_TOOL_ARGUMENTS} + * + * @deprecated use + * {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_ARGUMENTS} */ @Deprecated String ATTR_TOOL_ARGUMENTS = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_TOOL_ARGUMENTS; @@ -212,9 +217,12 @@ public interface IExternalToolConstants { * String attribute identifying the working directory of an external tool. * Default value is null, which indicates a default working * directory, which is tool specific. - * @deprecated use {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#ATTR_WORKING_DIRECTORY} + * + * @deprecated use + * {@link org.eclipse.core.externaltools.internal.IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_WORKING_DIRECTORY} */ - @Deprecated String ATTR_WORKING_DIRECTORY = org.eclipse.core.externaltools.internal.IExternalToolConstants.ATTR_WORKING_DIRECTORY; + @Deprecated + String ATTR_WORKING_DIRECTORY = org.eclipse.core.externaltools.internal.IExternalToolConstants.LAUNCH_ATTRIBUTE_IDENTITY_WORKING_DIRECTORY.id(); /** * String attribute identifying whether an external tool builder configuration diff --git a/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF b/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF index 3d7bc00b7cc..40216b2a147 100644 --- a/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.ui.externaltools; singleton:=true -Bundle-Version: 3.6.500.qualifier +Bundle-Version: 3.6.600.qualifier Bundle-Activator: org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin