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 b8163b69a11..6ee774ef14f 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;
@@ -195,7 +195,7 @@ public static AntTargetNode[] getTargets(String path, ILaunchConfiguration confi
}
private static Map
@@ -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 ILaunchAttributenull
. Encoding is tool specific.
+ *
+ * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_LOCATION
+ */
+ ILaunchAttributefalse
. 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 ILaunchAttributenull
, and encoding is
+ * tool specific.
+ *
+ * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_ARGUMENTS
+ */
+ ILaunchAttributenull
, 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 ILaunchAttributenull
, which indicates a
+ * default working directory, which is tool specific.
+ *
+ * @see IExternalToolConstants#LAUNCH_ATTRIBUTE_IDENTITY_WORKING_DIRECTORY
+ */
+ ILaunchAttributetrue
, 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 eb402a8e265..a053f66c271 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:
+ *
+ *
+ *
+ * @since 3.23
+ */
+public interface ILaunchAttribute
+ * 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
+ */
+ Optionalnull
+ * @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 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 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