Bug 395421 - Update to Ant 1.9.2 (2nd try)
diff --git a/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF
index 8b91a3d..dc4436f 100644
--- a/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF
+++ b/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF
@@ -15,8 +15,7 @@
org.eclipse.ant.internal.core.ant;x-friends:="org.eclipse.ant.launching",
org.eclipse.ant.internal.core.contentDescriber;x-internal:=true
Require-Bundle: org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.apache.ant;bundle-version="1.8.4"
+ org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.ant.internal.core.contentDescriber"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .
diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/EclipseAntMain.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/EclipseAntMain.java
index 92fb588..614a15c 100644
--- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/EclipseAntMain.java
+++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/EclipseAntMain.java
@@ -11,9 +11,6 @@
package org.eclipse.ant.internal.core.ant;
-import java.util.Iterator;
-import java.util.Vector;
-
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Main;
import org.apache.tools.ant.Project;
@@ -31,22 +28,22 @@
Main projectHelpMain = new EclipseAntMain(eclipseAntProject);
projectHelpMain.startAnt(args, null, null);
}
-
+
/*
* @see org.apache.tools.ant.Main#exit(int)
*/
+ @Override
protected void exit(int exitCode) {
- //disallow system exit
+ // disallow system exit
}
-
+
/*
* @see org.apache.tools.ant.Main#addBuildListeners(org.apache.tools.ant.Project)
*/
+ @Override
protected void addBuildListeners(Project project) {
- //TODO ANT-1.9.1 API USE
- Vector<?> list = fEclipseAntProject.getBuildListeners();
- for (Iterator<?> i = list.iterator(); i.hasNext();) {
- project.addBuildListener((BuildListener) i.next());
+ for (BuildListener listener : fEclipseAntProject.getBuildListeners()) {
+ project.addBuildListener(listener);
}
}
}
diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
index b86234c..66aa3ae 100644
--- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
+++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
@@ -11,7 +11,7 @@
*******************************************************************************/
package org.eclipse.ant.internal.core.ant;
-
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -24,6 +24,7 @@
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -71,8 +72,8 @@
import org.osgi.framework.Bundle;
/**
- * Eclipse application entry point into Ant. Derived from the original Ant Main class
- * to ensure that the functionality is equivalent when running in the platform.
+ * Eclipse application entry point into Ant. Derived from the original Ant Main class to ensure that the functionality is equivalent when running in
+ * the platform.
*/
public class InternalAntRunner {
@@ -80,24 +81,24 @@
private ArrayList<String> buildListeners;
private String buildFileLocation;
- /**
+ /**
* Targets we want to run.
*/
private Vector<String> targets;
private Map<String, String> userProperties;
- private boolean noExplicitUserProperties= true;
-
+ private boolean noExplicitUserProperties = true;
+
private Project currentProject;
-
+
private String defaultTarget;
-
- private BuildLogger buildLogger= null;
-
+
+ private BuildLogger buildLogger = null;
+
/**
* Cache of the Ant version number when it has been loaded
*/
- private String antVersionNumber= null;
+ private String antVersionNumber = null;
/** Current message output status. Follows Project.MSG_XXX */
private int messageOutputLevel = Project.MSG_INFO;
@@ -115,50 +116,51 @@
private PrintStream err = System.err;
/**
- * The Ant logger class. There may be only one logger. It will have the
- * right to use the 'out' PrintStream. The class must implement the BuildLogger
- * interface. An empty String indicates that no logger is to be used. A <code>null</code>
- * name indicates that the <code>org.apache.tools.ant.DefaultLogger</code> will be used.
+ * The Ant logger class. There may be only one logger. It will have the right to use the 'out' PrintStream. The class must implement the
+ * BuildLogger interface. An empty String indicates that no logger is to be used. A <code>null</code> name indicates that the
+ * <code>org.apache.tools.ant.DefaultLogger</code> will be used.
*/
private String loggerClassname = null;
/** Extra arguments to be parsed as command line arguments. */
private String[] extraArguments = null;
-
- private boolean executed = false;
-
- private ArrayList<String> propertyFiles= new ArrayList<String>();
-
- private URL[] customClasspath= null;
-
- /**
- * The Ant InputHandler class. There may be only one input handler.
- */
- private String inputHandlerClassname = null;
-
- private String buildAntHome= null;
-
- /**
- * Indicates whether to execute all targets that
- * do not depend on failed targets
- * @since Ant 1.6.0
- */
- private boolean keepGoing= false;
- /**
- * Indicates whether this build is to support interactive input
- * @since Ant 1.6.0
- */
- private boolean allowInput = true;
-
- private String fEarlyErrorMessage= null;
+ private boolean executed = false;
+
+ private ArrayList<String> propertyFiles = new ArrayList<String>();
+
+ private URL[] customClasspath = null;
+
+ /**
+ * The Ant InputHandler class. There may be only one input handler.
+ */
+ private String inputHandlerClassname = null;
+
+ private String buildAntHome = null;
+
+ /**
+ * Indicates whether to execute all targets that do not depend on failed targets
+ *
+ * @since Ant 1.6.0
+ */
+ private boolean keepGoing = false;
+
+ /**
+ * Indicates whether this build is to support interactive input
+ *
+ * @since Ant 1.6.0
+ */
+ private boolean allowInput = true;
+
+ private String fEarlyErrorMessage = null;
private boolean unknownTargetsFound = false;
-
+
/**
* Adds a build listener.
*
- * @param classNames the fully qualified names of the build listeners to be added
+ * @param classNames
+ * the fully qualified names of the build listeners to be added
*/
public void addBuildListeners(List<String> classNames) {
if (buildListeners == null) {
@@ -168,15 +170,17 @@
}
protected void addBuildListener(String clazz) {
- if(buildListeners == null) {
+ if (buildListeners == null) {
buildListeners = new ArrayList<String>();
}
buildListeners.add(clazz);
}
-
+
/**
* Adds a build logger. There can be only one build logger.
- * @param className The fully qualified name of the build logger to add
+ *
+ * @param className
+ * The fully qualified name of the build logger to add
*/
public void addBuildLogger(String className) {
loggerClassname = className;
@@ -184,7 +188,9 @@
/**
* Adds user properties to the current collection of user properties.
- * @param properties The user properties to be added
+ *
+ * @param properties
+ * The user properties to be added
*/
public void addUserProperties(Map<String, String> properties) {
if (userProperties == null) {
@@ -194,10 +200,12 @@
}
noExplicitUserProperties = false;
}
-
+
/**
* Adds user property files.
- * @param additionalPropertyFiles The property files to add
+ *
+ * @param additionalPropertyFiles
+ * The property files to add
* @since 2.1
*/
public void addPropertyFiles(String[] additionalPropertyFiles) {
@@ -207,13 +215,15 @@
/**
* Tries to add the build listeners to the backing {@link Project}
*
- * @param project the project to add the listeners to
- * @param log if we should be logging {@link ClassCastException}s here or not.
+ * @param project
+ * the project to add the listeners to
+ * @param log
+ * if we should be logging {@link ClassCastException}s here or not.
*/
protected void addBuildListeners(Project project, boolean log) {
- String className= null;
+ String className = null;
try {
- BuildLogger logger= createLogger();
+ BuildLogger logger = createLogger();
if (logger != null) {
project.addBuildListener(logger);
}
@@ -224,15 +234,18 @@
project.addBuildListener((BuildListener) listener.newInstance());
}
}
- } catch (ClassCastException e) {
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildListener, new Object[]{className});
- if(log) {
+ }
+ catch (ClassCastException e) {
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildListener, new Object[] { className });
+ if (log) {
logMessage(null, message, Project.MSG_ERR);
}
throw new BuildException(message, e);
- } catch (BuildException e) {
+ }
+ catch (BuildException e) {
throw e;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new BuildException(e);
}
}
@@ -246,15 +259,16 @@
if (substituteVariables && value != null) {
try {
value = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value);
- } catch (CoreException e) {
- //do nothing
+ }
+ catch (CoreException e) {
+ // do nothing
}
}
project.setUserProperty(entry.getKey(), value);
}
- //may have properties set (always have the Ant process ID)
- //using the Arguments and not the Properties page
- //if set using the arguments, still include the global properties
+ // may have properties set (always have the Ant process ID)
+ // using the Arguments and not the Properties page
+ // if set using the arguments, still include the global properties
if (noExplicitUserProperties) {
setGlobalProperties(project, substituteVariables);
}
@@ -264,23 +278,22 @@
}
/**
- * Sets the default <code>ant.file</code> and <code>ant.version</code>
- * properties in the given {@link Project}
+ * Sets the default <code>ant.file</code> and <code>ant.version</code> properties in the given {@link Project}
*
* @param project
*/
protected void setBuiltInProperties(Project project) {
- //note also see processAntHome for system properties that are set
+ // note also see processAntHome for system properties that are set
project.setUserProperty("ant.file", getBuildFileLocation()); //$NON-NLS-1$
project.setUserProperty("ant.version", Main.getAntVersion()); //$NON-NLS-1$
}
-
+
private void setGlobalProperties(Project project, boolean substituteVariables) {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
List<Property> properties = prefs.getProperties();
if (properties != null) {
for (Property property : properties) {
- String value= property.getValue(substituteVariables);
+ String value = property.getValue(substituteVariables);
if (value != null) {
project.setUserProperty(property.getName(), value);
}
@@ -292,29 +305,32 @@
List<Task> tasks = AntCorePlugin.getPlugin().getPreferences().getTasks();
for (Task task : tasks) {
if (isVersionCompatible("1.6")) { //$NON-NLS-1$
- AntTypeDefinition def= new AntTypeDefinition();
- String name = ProjectHelper.genComponentName(task.getURI(),task.getTaskName());
+ AntTypeDefinition def = new AntTypeDefinition();
+ String name = ProjectHelper.genComponentName(task.getURI(), task.getTaskName());
def.setName(name);
- def.setClassName(task.getClassName());
- def.setClassLoader(this.getClass().getClassLoader());
- def.setAdaptToClass(org.apache.tools.ant.Task.class);
- def.setAdapterClass(TaskAdapter.class);
- ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def);
+ def.setClassName(task.getClassName());
+ def.setClassLoader(this.getClass().getClassLoader());
+ def.setAdaptToClass(org.apache.tools.ant.Task.class);
+ def.setAdapterClass(TaskAdapter.class);
+ ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def);
} else {
try {
Class<?> taskClass = Class.forName(task.getClassName());
if (isVersionCompatible("1.5")) { //$NON-NLS-1$
try {
project.checkTaskClass(taskClass);
- } catch (BuildException e) {
- IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Error_setting_Ant_task, new Object[]{task.getTaskName()}), e);
+ }
+ catch (BuildException e) {
+ IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Error_setting_Ant_task, new Object[] { task.getTaskName() }), e);
AntCorePlugin.getPlugin().getLog().log(status);
continue;
}
}
project.addTaskDefinition(task.getTaskName(), taskClass);
- } catch (ClassNotFoundException e) {
- IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Class_not_found_for_task, new Object[]{task.getClassName(), task.getTaskName()}), e);
+ }
+ catch (ClassNotFoundException e) {
+ IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Class_not_found_for_task, new Object[] {
+ task.getClassName(), task.getTaskName() }), e);
AntCorePlugin.getPlugin().getLog().log(status);
}
}
@@ -327,17 +343,19 @@
Type type = iterator.next();
if (isVersionCompatible("1.6")) { //$NON-NLS-1$
AntTypeDefinition def = new AntTypeDefinition();
- String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName());
- def.setName(name);
- def.setClassName(type.getClassName());
- def.setClassLoader(this.getClass().getClassLoader());
- ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def);
+ String name = ProjectHelper.genComponentName(type.getURI(), type.getTypeName());
+ def.setName(name);
+ def.setClassName(type.getClassName());
+ def.setClassLoader(this.getClass().getClassLoader());
+ ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def);
} else {
try {
Class<?> typeClass = Class.forName(type.getClassName());
project.addDataTypeDefinition(type.getTypeName(), typeClass);
- } catch (ClassNotFoundException e) {
- IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Class_not_found_for_type, new Object[]{type.getClassName(), type.getTypeName()}), e);
+ }
+ catch (ClassNotFoundException e) {
+ IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Class_not_found_for_type, new Object[] {
+ type.getClassName(), type.getTypeName() }), e);
AntCorePlugin.getPlugin().getLog().log(status);
}
}
@@ -345,86 +363,81 @@
}
/**
- * Parses the build file and adds necessary information into
- * the given project.
- * @param project The project to configure
+ * Parses the build file and adds necessary information into the given project.
+ *
+ * @param project
+ * The project to configure
*/
protected void parseBuildFile(Project project) {
File buildFile = new File(getBuildFileLocation());
if (!buildFile.exists()) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_does_not_exist,
- new Object[]{buildFile.getAbsolutePath()}));
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_does_not_exist, new Object[] { buildFile.getAbsolutePath() }));
}
if (!buildFile.isFile()) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_is_not_a_file,
- new Object[]{buildFile.getAbsolutePath()}));
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_is_not_a_file, new Object[] { buildFile.getAbsolutePath() }));
}
-
- if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
- parseBuildFile(project, buildFile);
- } else {
- ProjectHelper helper = ProjectHelper.getProjectHelper();
- project.addReference("ant.projectHelper", helper); //$NON-NLS-1$
- helper.parse(project, buildFile);
- }
+
+ if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
+ parseBuildFile(project, buildFile);
+ } else {
+ ProjectHelper helper = ProjectHelper.getProjectHelper();
+ project.addReference("ant.projectHelper", helper); //$NON-NLS-1$
+ helper.parse(project, buildFile);
+ }
}
-
- /**
- * @deprecated support for Ant older than 1.5
- */
- private void parseBuildFile(Project project, File buildFile) {
- ProjectHelper.configureProject(project, buildFile);
- }
/**
- * Gets all the target information from the build script.
- * Returns a list of lists. Each item in the enclosing list represents a
- * target, where the first element is the name, the
- * second element is the description, the third element is the
- * project name, and the last elements is an array of dependencies.
+ * @deprecated support for Ant older than 1.5
+ */
+ @Deprecated
+ private void parseBuildFile(Project project, File buildFile) {
+ ProjectHelper.configureProject(project, buildFile);
+ }
+
+ /**
+ * Gets all the target information from the build script. Returns a list of lists. Each item in the enclosing list represents a target, where the
+ * first element is the name, the second element is the description, the third element is the project name, and the last elements is an array of
+ * dependencies.
+ *
* @return a list of {@link TargetInfo} objects
*/
public List<TargetInfo> getTargets() {
try {
- setJavaClassPath();
+ setJavaClassPath();
Project antProject = getProject();
processAntHome(false);
antProject.init();
setTypes(antProject);
- boolean exceptionState= processProperties(AntCoreUtil.getArrayList(extraArguments));
- if (fEarlyErrorMessage != null) {
- if (exceptionState) {
- throw new BuildException(fEarlyErrorMessage);
- }
- }
-
+ boolean exceptionState = processProperties(AntCoreUtil.getArrayList(extraArguments));
+ if (fEarlyErrorMessage != null) {
+ if (exceptionState) {
+ throw new BuildException(fEarlyErrorMessage);
+ }
+ }
+
setProperties(antProject, false);
if (isVersionCompatible("1.5")) { //$NON-NLS-1$
new InputHandlerSetter().setInputHandler(antProject, "org.eclipse.ant.internal.core.ant.NullInputHandler"); //$NON-NLS-1$
}
parseBuildFile(antProject);
defaultTarget = antProject.getDefaultTarget();
- //TODO ANT-1.9.1 API USE
- Enumeration<?> projectTargets = antProject.getTargets().elements();
- ArrayList<TargetInfo> infos= new ArrayList<TargetInfo>();
+ Hashtable<String, Target> projectTargets = antProject.getTargets();
+ ArrayList<TargetInfo> infos = new ArrayList<TargetInfo>();
ProjectInfo pinfo = new ProjectInfo(antProject.getName(), antProject.getDescription());
- Target target;
- boolean defaultFound= false;
- while (projectTargets.hasMoreElements()) {
- target = (Target) projectTargets.nextElement();
- String name= target.getName();
+ boolean defaultFound = false;
+ for (Target target : projectTargets.values()) {
+ String name = target.getName();
if (name.length() == 0) {
- //"no name" implicit target of Ant 1.6
+ // "no name" implicit target of Ant 1.6
continue;
}
if (target.getName().equals(defaultTarget)) {
- defaultFound= true;
+ defaultFound = true;
}
ArrayList<String> dependencies = new ArrayList<String>();
- //TODO ANT-1.9.1 API USE
- Enumeration<?> enumeration = target.getDependencies();
+ Enumeration<String> enumeration = target.getDependencies();
while (enumeration.hasMoreElements()) {
- dependencies.add((String) enumeration.nextElement());
+ dependencies.add(enumeration.nextElement());
}
String[] dependencyArray = new String[dependencies.size()];
dependencies.toArray(dependencyArray);
@@ -432,15 +445,17 @@
infos.add(info);
}
if (!defaultFound) {
- //default target must exist
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Default_target_does_not_exist, new Object[]{"'", defaultTarget, "'"})); //$NON-NLS-1$ //$NON-NLS-2$
+ // default target must exist
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Default_target_does_not_exist, new Object[] {
+ "'", defaultTarget, "'" })); //$NON-NLS-1$ //$NON-NLS-2$
}
return infos;
- } finally {
+ }
+ finally {
processAntHome(true);
}
}
-
+
/**
* Returns a list of target names in the build script.
*
@@ -448,56 +463,55 @@
*/
private List<String> getTargetNames() {
try {
- setJavaClassPath();
+ setJavaClassPath();
Project antProject;
-
+
antProject = getProject();
processAntHome(false);
antProject.init();
setTypes(antProject);
processProperties(AntCoreUtil.getArrayList(extraArguments));
-
+
setProperties(antProject, false);
if (isVersionCompatible("1.5")) { //$NON-NLS-1$
new InputHandlerSetter().setInputHandler(antProject, "org.eclipse.ant.internal.core.ant.NullInputHandler"); //$NON-NLS-1$
}
parseBuildFile(antProject);
- Enumeration<?> projectTargets = antProject.getTargets().elements();
+ Hashtable<String, Target> projectTargets = antProject.getTargets();
ArrayList<String> names = new ArrayList<String>();
- Target target;
- while (projectTargets.hasMoreElements()) {
- target = (Target) projectTargets.nextElement();
- String name= target.getName();
+ for (Target target : projectTargets.values()) {
+ String name = target.getName();
if (name.length() == 0) {
- //"no name" implicit target of Ant 1.6
+ // "no name" implicit target of Ant 1.6
continue;
}
names.add(name);
}
return names;
- } finally {
+ }
+ finally {
processAntHome(true);
}
- }
+ }
private Project getProject() {
Project antProject;
if (isVersionCompatible("1.6")) { //$NON-NLS-1$
- //in Ant version 1.6 or greater all tasks can exist outside the scope of a target
+ // in Ant version 1.6 or greater all tasks can exist outside the scope of a target
if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$
- antProject= new InternalProject2();
+ antProject = new InternalProject2();
} else {
- antProject= new Project();
+ antProject = new Project();
}
} else {
- antProject= new InternalProject();
+ antProject = new InternalProject();
}
return antProject;
}
-
+
/**
- * Returns the default target name that was last computed or <code>null</code>
- * if no default target has been computed.
+ * Returns the default target name that was last computed or <code>null</code> if no default target has been computed.
+ *
* @return the default target name
*/
public String getDefaultTarget() {
@@ -520,7 +534,7 @@
sb.append(extraArguments[i]);
sb.append(' ');
}
- project.log(MessageFormat.format(InternalAntMessages.InternalAntRunner_Arguments, new Object[]{sb.toString().trim()}));
+ project.log(MessageFormat.format(InternalAntMessages.InternalAntRunner_Arguments, new Object[] { sb.toString().trim() }));
}
private void createMonitorBuildListener(Project project) {
@@ -530,7 +544,7 @@
Vector<String> chosenTargets = targets;
if (chosenTargets == null || chosenTargets.isEmpty()) {
chosenTargets = new Vector<String>(1);
- String defltTarget= project.getDefaultTarget();
+ String defltTarget = project.getDefaultTarget();
if (defltTarget != null) {
chosenTargets.add(defltTarget);
}
@@ -539,38 +553,41 @@
}
/**
- * Invokes the building of a project object and executes a build using either a given
- * target or the default target. This method is called if running in
- * headless mode.
+ * Invokes the building of a project object and executes a build using either a given target or the default target. This method is called if
+ * running in headless mode.
+ *
* @see org.eclipse.ant.core.AntRunner#run(Object)
- * @param argArray the command line arguments
- * @exception Exception execution exceptions
+ * @param argArray
+ * the command line arguments
+ * @exception Exception
+ * execution exceptions
*/
public void run(Object argArray) throws Exception {
run(AntCoreUtil.getArrayList((String[]) argArray));
}
/**
- * Attempts to run the given list of command line arguments. Note that the list passed to this method must support
- * {@link List#remove(Object)}.
- * <br><br>
+ * Attempts to run the given list of command line arguments. Note that the list passed to this method must support {@link List#remove(Object)}. <br>
+ * <br>
* This method directly processes the following arguments:
* <ul>
* <li><b>-projecthelp</b>, <b>-p</b> - print project help information</li>
* </ul>
- * @param argList the raw list of command line arguments
+ *
+ * @param argList
+ * the raw list of command line arguments
*/
private void run(List<String> argList) {
setCurrentProject(new Project());
- if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$
- new ExecutorSetter().setExecutor(currentProject);
- }
+ if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$
+ new ExecutorSetter().setExecutor(currentProject);
+ }
Throwable error = null;
PrintStream originalErr = System.err;
PrintStream originalOut = System.out;
- InputStream originalIn= System.in;
-
- SecurityManager originalSM= System.getSecurityManager();
+ InputStream originalIn = System.in;
+
+ SecurityManager originalSM = System.getSecurityManager();
setJavaClassPath();
executed = true;
processAntHome(false);
@@ -585,39 +602,40 @@
return;
}
}
-
- boolean exceptionState= processProperties(argList);
-
+
+ boolean exceptionState = processProperties(argList);
+
addBuildListeners(getCurrentProject(), true);
-
+
addInputHandler(getCurrentProject());
-
+
remapSystemIn();
System.setOut(new PrintStream(new DemuxOutputStream(getCurrentProject(), false)));
System.setErr(new PrintStream(new DemuxOutputStream(getCurrentProject(), true)));
-
+
if (!projectHelp) {
fireBuildStarted(getCurrentProject());
}
-
- if (fEarlyErrorMessage != null) {
- //an error occurred processing the properties
- //build started has fired and we have
- //listeners/loggers to report the error
- logMessage(getCurrentProject(), fEarlyErrorMessage, Project.MSG_ERR);
- if (exceptionState) {
- throw new BuildException(fEarlyErrorMessage);
- }
- }
-
- //properties can only be set after buildStarted as some listeners/loggers
- //depend on this (e.g. XMLLogger)
- setProperties(getCurrentProject(), true);
-
+
+ if (fEarlyErrorMessage != null) {
+ // an error occurred processing the properties
+ // build started has fired and we have
+ // listeners/loggers to report the error
+ logMessage(getCurrentProject(), fEarlyErrorMessage, Project.MSG_ERR);
+ if (exceptionState) {
+ throw new BuildException(fEarlyErrorMessage);
+ }
+ }
+
+ // properties can only be set after buildStarted as some listeners/loggers
+ // depend on this (e.g. XMLLogger)
+ setProperties(getCurrentProject(), true);
+
if (argList != null && !argList.isEmpty()) {
try {
executed = processCommandLine(argList);
- } catch (BuildException e) {
+ }
+ catch (BuildException e) {
executed = false;
throw e;
}
@@ -625,26 +643,26 @@
if (!executed) {
return;
}
-
- //needs to occur after processCommandLine(List)
+
+ // needs to occur after processCommandLine(List)
if (allowInput && (inputHandlerClassname != null && inputHandlerClassname.length() > 0)) {
if (isVersionCompatible("1.6")) { //$NON-NLS-1$
- //https://bugs.eclipse.org/bugs/show_bug.cgi?id=182577
- //getCurrentProject().setDefaultInputStream(originalIn);
- System.getProperties().remove("eclipse.ant.noInput"); //$NON-NLS-1$
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=182577
+ // getCurrentProject().setDefaultInputStream(originalIn);
+ System.getProperties().remove("eclipse.ant.noInput"); //$NON-NLS-1$
}
} else {
- //set the system property that any input handler
- //can check to see if handling input is allowed
- System.setProperty("eclipse.ant.noInput", "true"); //$NON-NLS-1$//$NON-NLS-2$
+ // set the system property that any input handler
+ // can check to see if handling input is allowed
+ System.setProperty("eclipse.ant.noInput", "true"); //$NON-NLS-1$//$NON-NLS-2$
if (isVersionCompatible("1.5") && (inputHandlerClassname == null || inputHandlerClassname.length() == 0)) { //$NON-NLS-1$
- InputHandlerSetter setter= new InputHandlerSetter();
+ InputHandlerSetter setter = new InputHandlerSetter();
setter.setInputHandler(getCurrentProject(), "org.eclipse.ant.internal.core.ant.FailInputHandler"); //$NON-NLS-1$
}
}
- if(!projectHelp) {
- logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Build_file, new Object[]{getBuildFileLocation()}), Project.MSG_INFO);
+ if (!projectHelp) {
+ logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Build_file, new Object[] { getBuildFileLocation() }), Project.MSG_INFO);
setTasks(getCurrentProject());
setTypes(getCurrentProject());
@@ -654,77 +672,82 @@
}
parseBuildFile(getCurrentProject());
}
-
+
createMonitorBuildListener(getCurrentProject());
-
+
if (projectHelp) {
if (isVersionCompatible("1.7")) { //$NON-NLS-1$
new EclipseMainHelper().runProjectHelp(getBuildFileLocation(), getCurrentProject());
return;
- }
+ }
logMessage(currentProject, InternalAntMessages.InternalAntRunner_ant_1_7_needed_for_help_info, Project.MSG_ERR);
executed = false;
return;
}
-
+
if (extraArguments != null) {
printArguments(getCurrentProject());
}
System.setSecurityManager(new AntSecurityManager(originalSM, Thread.currentThread()));
-
+
if (targets == null) {
- targets = new Vector<String>(1);
- }
+ targets = new Vector<String>(1);
+ }
String dtarget = currentProject.getDefaultTarget();
- if (targets.isEmpty() && dtarget != null) {
- targets.add(dtarget);
- }
- if (!isVersionCompatible("1.6.3")) { //$NON-NLS-1$
- getCurrentProject().addReference("eclipse.ant.targetVector", targets); //$NON-NLS-1$
+ if (targets.isEmpty() && dtarget != null) {
+ targets.add(dtarget);
+ }
+ if (!isVersionCompatible("1.6.3")) { //$NON-NLS-1$
+ getCurrentProject().addReference("eclipse.ant.targetVector", targets); //$NON-NLS-1$
}
getCurrentProject().executeTargets(targets);
- } catch (OperationCanceledException e) {
+ }
+ catch (OperationCanceledException e) {
executed = false;
logMessage(currentProject, e.getMessage(), Project.MSG_INFO);
throw e;
- } catch (AntSecurityException e) {
- //expected
- } catch (RuntimeException e) {
+ }
+ catch (AntSecurityException e) {
+ // expected
+ }
+ catch (RuntimeException e) {
error = e;
throw e;
- } catch (Error e) {
+ }
+ catch (Error e) {
error = e;
throw e;
- } finally {
+ }
+ finally {
System.setErr(originalErr);
System.setOut(originalOut);
System.setIn(originalIn);
if (System.getSecurityManager() instanceof AntSecurityManager) {
System.setSecurityManager(originalSM);
}
-
- if (!projectHelp) {
+
+ if (!projectHelp) {
if (AntCorePlugin.getPlugin().getBundle().getState() != Bundle.ACTIVE) {
return;
}
fireBuildFinished(getCurrentProject(), error);
}
-
- //close any user specified build log
+
+ // close any user specified build log
if (err != originalErr) {
err.close();
}
if (out != originalOut) {
out.close();
}
-
+
processAntHome(true);
if (!allowInput) {
- System.getProperties().remove("eclipse.ant.noInput"); //$NON-NLS-1$
+ System.getProperties().remove("eclipse.ant.noInput"); //$NON-NLS-1$
}
}
}
-
+
/**
* Re-maps {@link System.in} to the Ant input stream setter
*/
@@ -732,81 +755,79 @@
if (!isVersionCompatible("1.6")) { //$NON-NLS-1$
return;
}
- DemuxInputStreamSetter setter= new DemuxInputStreamSetter();
+ DemuxInputStreamSetter setter = new DemuxInputStreamSetter();
setter.remapSystemIn(currentProject);
}
private void processAntHome(boolean finished) {
- AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
- String antHome= prefs.getAntHome();
+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
+ String antHome = prefs.getAntHome();
if (buildAntHome != null && !finished) {
- antHome= buildAntHome;
+ antHome = buildAntHome;
}
if (antHome == null || antHome.length() == 0) {
System.getProperties().remove("ant.home"); //$NON-NLS-1$
System.getProperties().remove("ant.library.dir"); //$NON-NLS-1$
} else {
System.setProperty("ant.home", antHome); //$NON-NLS-1$
- File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$
+ File antLibDir = new File(antHome, "lib"); //$NON-NLS-1$
System.setProperty("ant.library.dir", antLibDir.getAbsolutePath()); //$NON-NLS-1$
}
}
-
+
public void setAntHome(String antHome) {
- this.buildAntHome= antHome;
+ this.buildAntHome = antHome;
}
/**
* Creates and returns the default build logger for logging build events to the ant log.
*
- * @return the default build logger for logging build events to the ant log
- * can return <code>null</code> if no logging is to occur
+ * @return the default build logger for logging build events to the ant log can return <code>null</code> if no logging is to occur
*/
protected BuildLogger createLogger() {
if (loggerClassname == null) {
- buildLogger= new DefaultLogger();
+ buildLogger = new DefaultLogger();
} else if (!IAntCoreConstants.EMPTY_STRING.equals(loggerClassname)) {
try {
buildLogger = (BuildLogger) (Class.forName(loggerClassname).newInstance());
- } catch (ClassCastException e) {
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildLogger, new Object[]{loggerClassname});
- logMessage(null, message, Project.MSG_ERR);
- throw new BuildException(message, e);
- } catch (Exception e) {
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_Unable_to_instantiate_logger, new Object[]{loggerClassname});
+ }
+ catch (ClassCastException e) {
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildLogger, new Object[] { loggerClassname });
logMessage(null, message, Project.MSG_ERR);
throw new BuildException(message, e);
}
- }
-
+ catch (Exception e) {
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_Unable_to_instantiate_logger, new Object[] { loggerClassname });
+ logMessage(null, message, Project.MSG_ERR);
+ throw new BuildException(message, e);
+ }
+ }
+
if (buildLogger != null) {
buildLogger.setMessageOutputLevel(messageOutputLevel);
buildLogger.setOutputPrintStream(out);
buildLogger.setErrorPrintStream(err);
buildLogger.setEmacsMode(emacsMode);
- if (buildLogger instanceof AbstractEclipseBuildLogger) {
- ((AbstractEclipseBuildLogger) buildLogger).configure(userProperties);
- }
+ if (buildLogger instanceof AbstractEclipseBuildLogger) {
+ ((AbstractEclipseBuildLogger) buildLogger).configure(userProperties);
+ }
}
return buildLogger;
}
/**
- * Project.fireBuildStarted is protected in Ant earlier than 1.5.*.
- * Provides backwards compatibility with old Ant installs.
+ * Project.fireBuildStarted is protected in Ant earlier than 1.5.*. Provides backwards compatibility with old Ant installs.
*/
protected void fireBuildStarted(Project project) {
- if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
- BuildEvent event = new BuildEvent(project);
- //TODO ANT-1.9.1 API USE
- Vector<?> listeners = project.getBuildListeners();
- for (Iterator<?> iterator = listeners.iterator(); iterator.hasNext();) {
- ((BuildListener) iterator.next()).buildStarted(event);
- }
- } else {
- project.fireBuildStarted();
- }
+ if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
+ BuildEvent event = new BuildEvent(project);
+ for (BuildListener listener : project.getBuildListeners()) {
+ listener.buildStarted(event);
+ }
+ } else {
+ project.fireBuildStarted();
+ }
}
/**
@@ -816,35 +837,32 @@
* @param error
*/
protected void fireBuildFinished(Project project, Throwable error) {
- if(usingXmlLogger()) {
- //generate the log file in the correct location
- String fileName= project.getProperty("XmlLogger.file"); //$NON-NLS-1$
+ if (usingXmlLogger()) {
+ // generate the log file in the correct location
+ String fileName = project.getProperty("XmlLogger.file"); //$NON-NLS-1$
if (fileName == null) {
- fileName= "log.xml"; //$NON-NLS-1$
+ fileName = "log.xml"; //$NON-NLS-1$
}
- String realPath= new Path(getBuildFileLocation()).toFile().getAbsolutePath();
- IPath path= new Path(realPath);
- path= path.removeLastSegments(1);
- path= path.addTrailingSeparator();
- path= path.append(fileName);
-
+ String realPath = new Path(getBuildFileLocation()).toFile().getAbsolutePath();
+ IPath path = new Path(realPath);
+ path = path.removeLastSegments(1);
+ path = path.addTrailingSeparator();
+ path = path.append(fileName);
+
project.setProperty("XmlLogger.file", path.toOSString()); //$NON-NLS-1$
}
if (error == null && executed) {
logMessage(project, InternalAntMessages.InternalAntRunner_BUILD_SUCCESSFUL_1, messageOutputLevel);
- }
- if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
- BuildEvent event = new BuildEvent(project);
- event.setException(error);
- //TODO ANT-1.9.1 API USE
- Vector<?> listeners = project.getBuildListeners();
- Iterator<?> iter = listeners.iterator();
- while (iter.hasNext()) {
- ((BuildListener) iter.next()).buildFinished(event);
- }
- } else {
- project.fireBuildFinished(error);
- }
+ }
+ if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
+ BuildEvent event = new BuildEvent(project);
+ event.setException(error);
+ for (BuildListener listener : project.getBuildListeners()) {
+ listener.buildFinished(event);
+ }
+ } else {
+ project.fireBuildFinished(error);
+ }
}
private boolean usingXmlLogger() {
@@ -852,23 +870,18 @@
return true;
}
if (buildListeners != null) {
- //TODO ANT-1.9.1 API USE
- Vector<?> listeners = currentProject.getBuildListeners();
- Enumeration<?> e = listeners.elements();
- while (e.hasMoreElements()) {
- BuildListener element = (BuildListener) e.nextElement();
- if (element instanceof XmlLogger) {
+ for (BuildListener listener : currentProject.getBuildListeners()) {
+ if (listener instanceof XmlLogger) {
return true;
}
}
}
-
return false;
}
protected void logMessage(Project project, String message, int priority) {
if (project != null) {
- project.log(message, priority);
+ project.log(message, priority);
} else {
if (buildListeners != null) {
Project p = new Project();
@@ -884,7 +897,8 @@
/**
* Sets the buildFileLocation.
*
- * @param buildFileLocation the file system location of the build file
+ * @param buildFileLocation
+ * the file system location of the build file
*/
public void setBuildFileLocation(String buildFileLocation) {
this.buildFileLocation = buildFileLocation;
@@ -892,14 +906,15 @@
currentProject.setUserProperty("ant.file", buildFileLocation); //$NON-NLS-1$
}
}
-
+
/**
* Sets the input handler class name.
*
- * @param inputHandlerClassname the name of the class to use for the input handler
+ * @param inputHandlerClassname
+ * the name of the class to use for the input handler
*/
public void setInputHandler(String inputHandlerClassname) {
- this.inputHandlerClassname= inputHandlerClassname;
+ this.inputHandlerClassname = inputHandlerClassname;
}
/**
@@ -910,14 +925,13 @@
protected String getInputHandler() {
return this.inputHandlerClassname;
}
-
+
protected String getBuildLogger() {
return this.loggerClassname;
}
-
+
/**
- * Returns the location of the buildfile. If one has not been supplied
- * the default location of <code>build.xml</code> will be returned
+ * Returns the location of the buildfile. If one has not been supplied the default location of <code>build.xml</code> will be returned
*
* @return the absolute location of the build file
*/
@@ -930,7 +944,9 @@
/**
* Sets the message output level. Use -1 for none.
- * @param level The message output level
+ *
+ * @param level
+ * The message output level
*/
public void setMessageOutputLevel(int level) {
messageOutputLevel = level;
@@ -941,7 +957,9 @@
/**
* Sets the extra user arguments
- * @param args The extra user arguments
+ *
+ * @param args
+ * The extra user arguments
*/
public void setArguments(String[] args) {
extraArguments = args;
@@ -949,7 +967,9 @@
/**
* Sets the execution targets.
- * @param executionTargets The targets to execute for the build
+ *
+ * @param executionTargets
+ * The targets to execute for the build
*/
public void setExecutionTargets(String[] executionTargets) {
targets = new Vector<String>(executionTargets.length);
@@ -957,10 +977,9 @@
targets.add(executionTargets[i]);
}
}
-
+
/*
- * Returns a String representation of the Ant version number as specified
- * in the version.txt file.
+ * Returns a String representation of the Ant version number as specified in the version.txt file.
*/
protected String getAntVersionNumber() throws BuildException {
if (antVersionNumber == null) {
@@ -969,37 +988,40 @@
InputStream in = Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); //$NON-NLS-1$
props.load(in);
in.close();
- String versionNumber= props.getProperty("VERSION"); //$NON-NLS-1$
- antVersionNumber= versionNumber;
- } catch (IOException ioe) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[]{ioe.getMessage()}));
- } catch (NullPointerException npe) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[] {npe.getMessage()}));
+ String versionNumber = props.getProperty("VERSION"); //$NON-NLS-1$
+ antVersionNumber = versionNumber;
+ }
+ catch (IOException ioe) {
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[] { ioe.getMessage() }));
+ }
+ catch (NullPointerException npe) {
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[] { npe.getMessage() }));
}
}
return antVersionNumber;
}
-
+
/*
- * Returns whether the given version is compatible with the
- * current Ant version. A version is compatible if it is less
- * than or equal to the current version.
+ * Returns whether the given version is compatible with the current Ant version. A version is compatible if it is less than or equal to the
+ * current version.
*/
protected boolean isVersionCompatible(String comparison) {
String version = getAntVersionNumber();
return version.compareTo(comparison) >= 0;
}
-
+
/**
- * Pre-processes the raw command line to set up input handling and logging.
- * <br><br>
+ * Pre-processes the raw command line to set up input handling and logging. <br>
+ * <br>
* This method checks for the following command line arguments:
* <ul>
* <li><b>-inputhandler</b> <em><class></em> - the class which will handle input requests</li>
* <li><b>-logger</b> <em><classname></em> - the class which is to perform logging</li>
* <li><b>-listener</b> <em><classname></em> - add an instance of class as a project listener</li>
* </ul>
- * @param commands the raw command line arguments passed in from the application
+ *
+ * @param commands
+ * the raw command line arguments passed in from the application
* @return <code>true</code> if it is OK to run with the given list of arguments <code>false</code> otherwise
*/
protected boolean preprocessCommandLine(List<String> commands) {
@@ -1007,9 +1029,9 @@
while (arg != null) {
if (arg.length() == 0) {
throw new BuildException(InternalAntMessages.InternalAntRunner_specify_a_classname_using_the_listener_argument);
- }
+ }
if (buildListeners == null) {
- buildListeners= new ArrayList<String>(1);
+ buildListeners = new ArrayList<String>(1);
}
buildListeners.add(arg);
arg = AntCoreUtil.getArgument(commands, "-listener"); //$NON-NLS-1$
@@ -1019,14 +1041,14 @@
if (arg != null) {
if (arg.length() == 0) {
throw new BuildException(InternalAntMessages.InternalAntRunner_specify_a_classname_using_the_logger_argument);
- }
+ }
loggerClassname = arg;
}
arg = AntCoreUtil.getArgument(commands, "-logger"); //$NON-NLS-1$
if (arg != null) {
throw new BuildException(InternalAntMessages.InternalAntRunner_Only_one_logger_class_may_be_specified);
}
-
+
arg = AntCoreUtil.getArgument(commands, "-inputhandler"); //$NON-NLS-1$
if (arg != null) {
if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
@@ -1034,7 +1056,7 @@
}
if (arg.length() == 0) {
throw new BuildException(InternalAntMessages.InternalAntRunner_specify_a_classname_the_inputhandler_argument);
- }
+ }
inputHandlerClassname = arg;
}
arg = AntCoreUtil.getArgument(commands, "-inputhandler"); //$NON-NLS-1$
@@ -1043,10 +1065,10 @@
}
return true;
}
-
+
/**
- * Process the command line arguments.
- * <br><br>
+ * Process the command line arguments. <br>
+ * <br>
* The listing of supported Ant command line arguments is:
* <ul>
* <li><b>-buildfile</b>, <b>-file</b>, <b>-f</b> <em><file></em> - use given buildfile</li>
@@ -1065,13 +1087,15 @@
* </ul>
* The list of other Ant command line arguments that we currently do not support:
* <ul>
- * <li><b>-nice</b> <em><number></em> - A niceness value for the main thread - 1 (lowest) to 10 (highest); 5 is the default</li>
+ * <li><b>-nice</b> <em><number></em> - A niceness value for the main thread - 1 (lowest) to 10 (highest); 5 is the default</li>
* <li><b>-nouserlib</b> - Run ant without using the jar files from ${user.home}/.ant/lib</li>
* <li><b>-noclasspath</b> - Run ant without using CLASSPATH</li>
* <li><b>-autoproxy</b> - Java 1.5+ : use the OS proxies</li>
* <li><b>-main</b> <em><class></em> - override Ant's normal entry point</li>
* </ul>
- * @param list the raw command line arguments passed in from the application
+ *
+ * @param list
+ * the raw command line arguments passed in from the application
* @return <code>true</code> if it is OK to run with the given list of arguments <code>false</code> otherwise
*/
private boolean processCommandLine(List<String> commands) {
@@ -1083,22 +1107,22 @@
}
return false;
}
-
+
if (commands.remove("-version")) { //$NON-NLS-1$
printVersion();
return false;
}
-
+
if (commands.remove("-verbose") || commands.remove("-v")) { //$NON-NLS-1$ //$NON-NLS-2$
printVersion();
setMessageOutputLevel(Project.MSG_VERBOSE);
}
-
+
if (commands.remove("-debug") || commands.remove("-d")) { //$NON-NLS-1$ //$NON-NLS-2$
printVersion();
setMessageOutputLevel(Project.MSG_DEBUG);
}
-
+
if (commands.remove("-quiet") || commands.remove("-q")) { //$NON-NLS-1$ //$NON-NLS-2$
setMessageOutputLevel(Project.MSG_WARN);
}
@@ -1109,37 +1133,39 @@
buildLogger.setEmacsMode(true);
}
}
-
+
if (commands.remove("-diagnostics")) { //$NON-NLS-1$
if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
throw new BuildException(InternalAntMessages.InternalAntRunner_The_diagnositics_options_is_an_Ant_1_5_feature);
}
try {
Diagnostics.doReport(System.out);
- } catch (NullPointerException e) {
+ }
+ catch (NullPointerException e) {
logMessage(currentProject, InternalAntMessages.InternalAntRunner_anthome_must_be_set_to_use_ant_diagnostics, Project.MSG_ERR);
}
return false;
}
-
+
String arg = AntCoreUtil.getArgument(commands, "-logfile"); //$NON-NLS-1$
if (arg == null) {
arg = AntCoreUtil.getArgument(commands, "-l"); //$NON-NLS-1$
}
if (arg != null) {
if (arg.length() == 0) {
- String message= InternalAntMessages.InternalAntRunner_specify_a_log_file_using_the_log_argument;
- logMessage(currentProject, message, Project.MSG_ERR);
+ String message = InternalAntMessages.InternalAntRunner_specify_a_log_file_using_the_log_argument;
+ logMessage(currentProject, message, Project.MSG_ERR);
throw new BuildException(message);
- }
+ }
try {
createLogFile(arg);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
// just log message and ignore exception
- logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_write_to_log_file, new Object[]{arg}), Project.MSG_ERR);
+ logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_write_to_log_file, new Object[] { arg }), Project.MSG_ERR);
return false;
}
-
+
}
arg = AntCoreUtil.getArgument(commands, "-buildfile"); //$NON-NLS-1$
if (arg == null) {
@@ -1150,29 +1176,29 @@
}
if (arg != null) {
if (arg.length() == 0) {
- String message= InternalAntMessages.InternalAntRunner_specify_a_buildfile_using_the_buildfile_argument;
- logMessage(currentProject, message, Project.MSG_ERR);
+ String message = InternalAntMessages.InternalAntRunner_specify_a_buildfile_using_the_buildfile_argument;
+ logMessage(currentProject, message, Project.MSG_ERR);
throw new BuildException(message);
- }
+ }
setBuildFileLocation(arg);
}
if (isVersionCompatible("1.6")) { //$NON-NLS-1$
if (commands.remove("-k") || commands.remove("-keep-going")) { //$NON-NLS-1$ //$NON-NLS-2$
- keepGoing= true;
+ keepGoing = true;
}
if (commands.remove("-noinput")) { //$NON-NLS-1$
- allowInput= false;
+ allowInput = false;
}
- arg= AntCoreUtil.getArgument(commands, "-lib"); //$NON-NLS-1$
+ arg = AntCoreUtil.getArgument(commands, "-lib"); //$NON-NLS-1$
if (arg != null) {
logMessage(currentProject, InternalAntMessages.InternalAntRunner_157, Project.MSG_ERR);
return false;
}
}
-
- arg= AntCoreUtil.getArgument(commands, "-find"); //$NON-NLS-1$
+
+ arg = AntCoreUtil.getArgument(commands, "-find"); //$NON-NLS-1$
if (arg == null) {
- arg= AntCoreUtil.getArgument(commands, "-s"); //$NON-NLS-1$
+ arg = AntCoreUtil.getArgument(commands, "-s"); //$NON-NLS-1$
}
if (arg != null) {
logMessage(currentProject, InternalAntMessages.InternalAntRunner_find_not_supported, Project.MSG_ERR);
@@ -1183,15 +1209,15 @@
processUnrecognizedCommands(commands);
}
- if(!commands.isEmpty()) {
+ if (!commands.isEmpty()) {
processUnrecognizedTargets(commands);
}
-
+
if (!commands.isEmpty()) {
processTargets(commands);
}
-
- if (unknownTargetsFound && (targets == null || targets.isEmpty())) {
+
+ if (unknownTargetsFound && (targets == null || targets.isEmpty())) {
// Some targets are specified but none of them are good. Hence quit
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352536
logMessage(currentProject, InternalAntMessages.InternalAntRunner_no_known_target, Project.MSG_ERR);
@@ -1199,10 +1225,9 @@
}
return true;
}
-
+
/**
- * Checks for unrecognized targets on the command line and
- * removes them.
+ * Checks for unrecognized targets on the command line and removes them.
*
* @since 3.6
*/
@@ -1213,23 +1238,17 @@
String target = iterator.next();
if (!names.contains(target)) {
iterator.remove();
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_unknown_target, new Object[]{target});
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_unknown_target, new Object[] { target });
logMessage(currentProject, message, Project.MSG_WARN);
unknownTargetsFound = true;
}
}
}
-
/**
- * Checks for unrecognized arguments on the command line.
- * Since there is no syntactic way to distinguish between
- * ant -foo target1 target2
- * ant -foo fooarg target
- * we remove everything up to the last argument that
- * begins with a '-'. In the latter case, above, that
- * means that there will be an extra target, 'fooarg',
- * left lying around.
+ * Checks for unrecognized arguments on the command line. Since there is no syntactic way to distinguish between ant -foo target1 target2 ant -foo
+ * fooarg target we remove everything up to the last argument that begins with a '-'. In the latter case, above, that means that there will be an
+ * extra target, 'fooarg', left lying around.
*/
protected void processUnrecognizedCommands(List<String> commands) {
int p = -1;
@@ -1241,7 +1260,9 @@
break;
}
}
- if (p < 0) { return; }
+ if (p < 0) {
+ return;
+ }
// remove everything preceding that last '-arg'
String s = IAntCoreConstants.EMPTY_STRING;
@@ -1249,12 +1270,11 @@
s += " " + (commands.get(0)); //$NON-NLS-1$
commands.remove(0);
}
-
+
// warn of ignored commands
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_Unknown_argument, new Object[]{ s.substring(1) });
- logMessage(currentProject, message, Project.MSG_WARN);
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_Unknown_argument, new Object[] { s.substring(1) });
+ logMessage(currentProject, message, Project.MSG_WARN);
}
-
/**
* Checks for targets specified at the command line.
@@ -1269,17 +1289,15 @@
}
/**
- * Creates the log file with the name specified by the user.
- * If the fileName is not absolute, the file will be created in the
- * working directory if specified or in the same directory as the location
- * of the build file.
+ * Creates the log file with the name specified by the user. If the fileName is not absolute, the file will be created in the working directory if
+ * specified or in the same directory as the location of the build file.
*/
protected void createLogFile(String fileName) throws FileNotFoundException, IOException {
File logFile = AntCoreUtil.getFileRelativeToBaseDir(fileName, currentProject.getUserProperty("basedir"), getBuildFileLocation()); //$NON-NLS-1$
- //this stream is closed in the finally block of run(list)
+ // this stream is closed in the finally block of run(list)
out = new PrintStream(new FileOutputStream(logFile));
err = out;
- logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Using_file_as_build_log, new Object[]{logFile.getCanonicalPath()}), Project.MSG_INFO);
+ logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Using_file_as_build_log, new Object[] { logFile.getCanonicalPath() }), Project.MSG_INFO);
if (buildLogger != null) {
buildLogger.setErrorPrintStream(err);
buildLogger.setOutputPrintStream(out);
@@ -1287,11 +1305,10 @@
}
/**
- * Processes the command line properties and adds the user properties.
- * <br><br>
- * Any user properties that have been explicitly set are set as well.
- * Ensures that -D properties take precedence.
- * <br><br>
+ * Processes the command line properties and adds the user properties. <br>
+ * <br>
+ * Any user properties that have been explicitly set are set as well. Ensures that -D properties take precedence. <br>
+ * <br>
* This command lie arguments used are:
* <ul>
* <li><b>-D</b> <em><property>=<value></em> - use value for given property</li>
@@ -1299,44 +1316,44 @@
* </ul>
*/
private boolean processProperties(List<String> commands) {
- boolean exceptionToBeThrown= false;
- //MULTIPLE property files are allowed
- String arg= AntCoreUtil.getArgument(commands, "-propertyfile"); //$NON-NLS-1$
+ boolean exceptionToBeThrown = false;
+ // MULTIPLE property files are allowed
+ String arg = AntCoreUtil.getArgument(commands, "-propertyfile"); //$NON-NLS-1$
while (arg != null) {
if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
- fEarlyErrorMessage= InternalAntMessages.InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature;
+ fEarlyErrorMessage = InternalAntMessages.InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature;
break;
}
if (arg.length() == 0) {
- fEarlyErrorMessage= InternalAntMessages.InternalAntRunner_specify_a_property_filename_when_using_propertyfile_argument;
- exceptionToBeThrown= true;
- break;
- }
-
+ fEarlyErrorMessage = InternalAntMessages.InternalAntRunner_specify_a_property_filename_when_using_propertyfile_argument;
+ exceptionToBeThrown = true;
+ break;
+ }
+
propertyFiles.add(arg);
- arg= AntCoreUtil.getArgument(commands, "-propertyfile"); //$NON-NLS-1$
+ arg = AntCoreUtil.getArgument(commands, "-propertyfile"); //$NON-NLS-1$
}
-
- String[] globalPropertyFiles= AntCorePlugin.getPlugin().getPreferences().getCustomPropertyFiles();
+
+ String[] globalPropertyFiles = AntCorePlugin.getPlugin().getPreferences().getCustomPropertyFiles();
if (globalPropertyFiles.length > 0) {
- if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
- fEarlyErrorMessage= InternalAntMessages.InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature;
- } else {
- if (propertyFiles == null) {
- propertyFiles = new ArrayList<String>(globalPropertyFiles.length);
- }
- propertyFiles.addAll(Arrays.asList(globalPropertyFiles));
- }
+ if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
+ fEarlyErrorMessage = InternalAntMessages.InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature;
+ } else {
+ if (propertyFiles == null) {
+ propertyFiles = new ArrayList<String>(globalPropertyFiles.length);
+ }
+ propertyFiles.addAll(Arrays.asList(globalPropertyFiles));
+ }
}
-
+
if (propertyFiles != null && !propertyFiles.isEmpty()) {
- loadPropertyFiles();
+ loadPropertyFiles();
}
-
+
if (commands != null) {
processMinusDProperties(commands);
- }
- return exceptionToBeThrown;
+ }
+ return exceptionToBeThrown;
}
/**
@@ -1345,24 +1362,24 @@
* @param commands
*/
protected void processMinusDProperties(List<String> commands) {
- if (!commands.isEmpty() && userProperties == null) {
+ if (!commands.isEmpty() && userProperties == null) {
userProperties = new HashMap<String, String>();
}
AntCoreUtil.processMinusDProperties(commands, userProperties);
}
/**
- * Logs a message with the client indicating the version of <b>Ant</b> that this class
- * fronts.
+ * Logs a message with the client indicating the version of <b>Ant</b> that this class fronts.
*/
protected void printVersion() {
logMessage(currentProject, Main.getAntVersion(), Project.MSG_INFO);
}
-
/**
* Sets the build progress monitor.
- * @param monitor The progress monitor to use
+ *
+ * @param monitor
+ * The progress monitor to use
*/
public void setProgressMonitor(IProgressMonitor monitor) {
this.monitor = monitor;
@@ -1380,96 +1397,100 @@
/**
* Sets the current {@link Project} context
*
- * @param currentProject the new {@link Project}
+ * @param currentProject
+ * the new {@link Project}
*/
protected void setCurrentProject(Project currentProject) {
this.currentProject = currentProject;
}
-
+
public String getBuildExceptionErrorMessage(Throwable t) {
if (t instanceof BuildException) {
return t.toString();
}
return null;
}
-
+
/**
- * Load all properties from the files
- * specified by -propertyfile.
+ * Load all properties from the files specified by -propertyfile.
*/
protected void loadPropertyFiles() {
- if (userProperties == null) {
- userProperties = new HashMap<String, String>();
- }
- try {
- List<Properties> allProperties = AntCoreUtil.loadPropertyFiles(propertyFiles, currentProject.getUserProperty("basedir"), getBuildFileLocation()); //$NON-NLS-1$
- Iterator<Properties> iter= allProperties.iterator();
- while (iter.hasNext()) {
- Properties props = iter.next();
- Enumeration<?> propertyNames = props.propertyNames();
- while (propertyNames.hasMoreElements()) {
- String name = (String) propertyNames.nextElement();
- //most specific to global
- //do not overwrite specific with a global property
- if (userProperties.get(name) == null) {
- userProperties.put(name, props.getProperty(name));
- }
- }
- }
- } catch (IOException e) {
- fEarlyErrorMessage = MessageFormat.format(InternalAntMessages.InternalAntRunner_could_not_load_property_file, new Object[]{e.getMessage()});
- }
+ if (userProperties == null) {
+ userProperties = new HashMap<String, String>();
+ }
+ try {
+ List<Properties> allProperties = AntCoreUtil.loadPropertyFiles(propertyFiles, currentProject.getUserProperty("basedir"), getBuildFileLocation()); //$NON-NLS-1$
+ Iterator<Properties> iter = allProperties.iterator();
+ while (iter.hasNext()) {
+ Properties props = iter.next();
+ Enumeration<?> propertyNames = props.propertyNames();
+ while (propertyNames.hasMoreElements()) {
+ String name = (String) propertyNames.nextElement();
+ // most specific to global
+ // do not overwrite specific with a global property
+ if (userProperties.get(name) == null) {
+ userProperties.put(name, props.getProperty(name));
+ }
+ }
+ }
+ }
+ catch (IOException e) {
+ fEarlyErrorMessage = MessageFormat.format(InternalAntMessages.InternalAntRunner_could_not_load_property_file, new Object[] { e.getMessage() });
+ }
}
-
+
/**
- * Creates the InputHandler and adds it to the project.
- *
- * @exception BuildException if a specified InputHandler
- * implementation could not be loaded.
- */
- protected void addInputHandler(Project project) {
- if (!isVersionCompatible("1.5") || (inputHandlerClassname != null && inputHandlerClassname.length() == 0)) { //$NON-NLS-1$
+ * Creates the InputHandler and adds it to the project.
+ *
+ * @exception BuildException
+ * if a specified InputHandler implementation could not be loaded.
+ */
+ protected void addInputHandler(Project project) {
+ if (!isVersionCompatible("1.5") || (inputHandlerClassname != null && inputHandlerClassname.length() == 0)) { //$NON-NLS-1$
return;
}
- InputHandlerSetter setter= new InputHandlerSetter();
+ InputHandlerSetter setter = new InputHandlerSetter();
setter.setInputHandler(project, inputHandlerClassname);
- }
+ }
/*
* Sets the Java class path in org.apache.tools.ant.types.Path
*/
private void setJavaClassPath() {
- URL[] antClasspath= null;
- AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
+ URL[] antClasspath = null;
+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
if (customClasspath == null) {
- antClasspath= prefs.getURLs();
+ antClasspath = prefs.getURLs();
} else {
- URL[] extraClasspath= prefs.getExtraClasspathURLs();
- antClasspath= new URL[customClasspath.length + extraClasspath.length];
+ URL[] extraClasspath = prefs.getExtraClasspathURLs();
+ antClasspath = new URL[customClasspath.length + extraClasspath.length];
System.arraycopy(customClasspath, 0, antClasspath, 0, customClasspath.length);
System.arraycopy(extraClasspath, 0, antClasspath, customClasspath.length, extraClasspath.length);
}
- StringBuffer buff= new StringBuffer();
- File file= null;
+ StringBuffer buff = new StringBuffer();
+ File file = null;
for (int i = 0; i < antClasspath.length; i++) {
try {
file = new File(FileLocator.toFileURL(antClasspath[i]).getPath());
- } catch (IOException e) {
+ }
+ catch (IOException e) {
continue;
}
buff.append(file.getAbsolutePath());
buff.append("; "); //$NON-NLS-1$
}
- org.apache.tools.ant.types.Path systemClasspath= new org.apache.tools.ant.types.Path(null, buff.substring(0, buff.length() - 2));
- org.apache.tools.ant.types.Path.systemClasspath= systemClasspath;
+ org.apache.tools.ant.types.Path systemClasspath = new org.apache.tools.ant.types.Path(null, buff.substring(0, buff.length() - 2));
+ org.apache.tools.ant.types.Path.systemClasspath = systemClasspath;
}
-
+
/**
* Sets the custom classpath to be included when setting the Java classpath for this build.
- * @param classpath The custom classpath for this build.
+ *
+ * @param classpath
+ * The custom classpath for this build.
*/
public void setCustomClasspath(URL[] classpath) {
- customClasspath= classpath;
+ customClasspath = classpath;
}
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalProject.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalProject.java
index b79292d..c213683 100644
--- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalProject.java
+++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalProject.java
@@ -25,13 +25,11 @@
import org.apache.tools.ant.ProjectComponent;
/**
- * A subclass of Project to facilitate "faster" parsing with
- * less garbage generated. This class is not used on Ant 1.6 and newer
- * due to the improvements in lazy loading of these Ant versions.
+ * A subclass of Project to facilitate "faster" parsing with less garbage generated. This class is not used on Ant 1.6 and newer due to the
+ * improvements in lazy loading of these Ant versions.
*
- * Only three tasks are loaded (property, taskdef and
- * typedef: three tasks that can be defined outside of a target on Ant 1.5.1 or older).
- *
+ * Only three tasks are loaded (property, taskdef and typedef: three tasks that can be defined outside of a target on Ant 1.5.1 or older).
+ *
* Datatypes are loaded if requested.
*
* Derived from the original Ant Project class
@@ -39,14 +37,17 @@
public class InternalProject extends Project {
private Hashtable<String, Class<?>> typeNameToClass = null;
-
+
public InternalProject() {
super();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.Project#init()
*/
+ @Override
public void init() throws BuildException {
setJavaVersionProperty();
@@ -57,18 +58,23 @@
addTaskDefinition("typedef", taskClass); //$NON-NLS-1$
taskClass = Class.forName("org.apache.tools.ant.taskdefs.Taskdef"); //$NON-NLS-1$
addTaskDefinition("taskdef", taskClass); //$NON-NLS-1$
- } catch (NoClassDefFoundError e) {
+ }
+ catch (NoClassDefFoundError e) {
throw new BuildException(InternalAntMessages.InternalAntRunner_Missing_Class, e);
- } catch (ClassNotFoundException c) {
+ }
+ catch (ClassNotFoundException c) {
throw new BuildException(InternalAntMessages.InternalAntRunner_Missing_Class, c);
}
setSystemProperties();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.Project#createDataType(java.lang.String)
*/
+ @Override
public Object createDataType(String typeName) throws BuildException {
if (typeNameToClass == null) {
initializeTypes();
@@ -88,7 +94,8 @@
try {
ctor = typeClass.getConstructor(new Class[0]);
noArg = true;
- } catch (NoSuchMethodException nse) {
+ }
+ catch (NoSuchMethodException nse) {
ctor = typeClass.getConstructor(new Class[] { Project.class });
noArg = false;
}
@@ -103,21 +110,28 @@
((ProjectComponent) o).setProject(this);
}
return o;
- } catch (InvocationTargetException ite) {
+ }
+ catch (InvocationTargetException ite) {
thrown = ite.getTargetException();
- } catch (IllegalArgumentException e) {
+ }
+ catch (IllegalArgumentException e) {
thrown = e;
- } catch (InstantiationException e) {
+ }
+ catch (InstantiationException e) {
thrown = e;
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e) {
thrown = e;
- } catch (NoSuchMethodException nse) {
+ }
+ catch (NoSuchMethodException nse) {
thrown = nse;
- } catch (NoClassDefFoundError ncdfe) {
+ }
+ catch (NoClassDefFoundError ncdfe) {
thrown = ncdfe;
}
if (thrown != null) {
- String message= MessageFormat.format(InternalAntMessages.InternalProject_could_not_create_type, new Object[]{typeName, thrown.toString()});
+ String message = MessageFormat.format(InternalAntMessages.InternalProject_could_not_create_type, new Object[] { typeName,
+ thrown.toString() });
throw new BuildException(message, thrown);
}
// this line is actually unreachable
@@ -144,21 +158,26 @@
String typeName = (String) enumeration.nextElement();
String className = props.getProperty(typeName);
try {
- Class<?> typeClass= Class.forName(className);
+ Class<?> typeClass = Class.forName(className);
typeNameToClass.put(typeName, typeClass);
- } catch (NoClassDefFoundError e) {
- //ignore
- } catch (ClassNotFoundException c) {
- //ignore
+ }
+ catch (NoClassDefFoundError e) {
+ // ignore
+ }
+ catch (ClassNotFoundException c) {
+ // ignore
}
}
- } catch (IOException ioe) {
+ }
+ catch (IOException ioe) {
return;
}
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.Project#getDataTypeDefinitions()
*/
@Override
@@ -168,13 +187,14 @@
}
return typeNameToClass;
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.Project#addDataTypeDefinition(java.lang.String, java.lang.Class)
*/
@Override
- public void addDataTypeDefinition(String typeName, Class typeClass) {
- //TODO ANT-1.9.1 API USE
+ public void addDataTypeDefinition(String typeName, Class<?> typeClass) {
getDataTypeDefinitions();
typeNameToClass.put(typeName, typeClass);
}
diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/ProgressBuildListener.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/ProgressBuildListener.java
index 9481139..5fb0c9d 100644
--- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/ProgressBuildListener.java
+++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/ProgressBuildListener.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.ant.internal.core.ant;
-
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -35,7 +34,7 @@
import org.eclipse.core.runtime.SubProgressMonitor;
/**
- * Reports progress and checks for cancelation of a script execution.
+ * Reports progress and checks for cancellation of a script execution.
*/
public class ProgressBuildListener implements BuildListener {
@@ -45,18 +44,17 @@
private Thread currentTaskThread;
/**
- * Contains the progress monitor instances for the various
- * projects in a chain.
+ * Contains the progress monitor instances for the various projects in a chain.
*/
protected class ProjectMonitors {
/**
- * This field is null for the main project
+ * This field is null for the main project
*/
private Target mainTarget;
private IProgressMonitor mainMonitor;
private IProgressMonitor targetMonitor;
private IProgressMonitor taskMonitor;
-
+
protected IProgressMonitor getMainMonitor() {
return mainMonitor;
}
@@ -97,13 +95,13 @@
ProjectMonitors monitors = new ProjectMonitors();
IProgressMonitor localmonitor = monitor;
if (localmonitor == null) {
- localmonitor= new NullProgressMonitor();
+ localmonitor = new NullProgressMonitor();
}
monitors.setMainMonitor(localmonitor);
projects.put(mainProject, monitors);
- ArrayList<Target> targets= new ArrayList<Target>(targetNames.size());
+ ArrayList<Target> targets = new ArrayList<Target>(targetNames.size());
for (String targetName : targetNames) {
- Target target = (Target) mainProject.getTargets().get(targetName);
+ Target target = mainProject.getTargets().get(targetName);
if (target != null) {
targets.add(target);
}
@@ -112,9 +110,12 @@
monitors.getMainMonitor().beginTask(IAntCoreConstants.EMPTY_STRING, work);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void buildStarted(BuildEvent event) {
checkCanceled();
}
@@ -130,17 +131,16 @@
protected int countTarget(Target target, List<String> alreadySeen) {
int result = 1;
Project project = target.getProject();
- //TODO ANT-1.9.1 API USE
- Hashtable<?, ?> targets = project.getTargets();
- String targetName;
- Target dependency;
- for (Enumeration<?> dependencies = target.getDependencies(); dependencies.hasMoreElements();) {
- targetName = (String) dependencies.nextElement();
- if (alreadySeen.contains(targetName)) { //circular dependency or common dependency
+ Hashtable<String, Target> targets = project.getTargets();
+ String targetName;
+ Target dependency;
+ for (Enumeration<String> dependencies = target.getDependencies(); dependencies.hasMoreElements();) {
+ targetName = dependencies.nextElement();
+ if (alreadySeen.contains(targetName)) { // circular dependency or common dependency
return result;
- }
- alreadySeen.add(targetName);
- dependency = (Target) targets.get(targetName);
+ }
+ alreadySeen.add(targetName);
+ dependency = targets.get(targetName);
if (dependency != null) {
result = result + countTarget(dependency, alreadySeen);
}
@@ -158,14 +158,17 @@
return result;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void buildFinished(BuildEvent event) {
ProjectMonitors monitors = projects.get(mainProject);
monitors.getMainMonitor().done();
- Set<Project> keys= projects.keySet();
- Iterator<Project> itr= keys.iterator();
+ Set<Project> keys = projects.keySet();
+ Iterator<Project> itr = keys.iterator();
while (itr.hasNext()) {
Project project = itr.next();
project.removeBuildListener(this);
@@ -173,9 +176,12 @@
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void targetStarted(BuildEvent event) {
checkCanceled();
Project currentProject = event.getProject();
@@ -199,7 +205,7 @@
ProjectMonitors monitors = new ProjectMonitors();
// remember the target so we can remove this monitors object later
monitors.setMainTarget(target);
- ArrayList<Target> targets= new ArrayList<Target>(1);
+ ArrayList<Target> targets = new ArrayList<Target>(1);
targets.add(target);
int work = computeWork(targets);
ProjectMonitors parentMonitors = null;
@@ -216,9 +222,12 @@
return monitors;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void targetFinished(BuildEvent event) {
checkCanceled();
Project currentProject = event.getProject();
@@ -237,9 +246,12 @@
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void taskStarted(BuildEvent event) {
checkCanceled();
Project currentProject = event.getProject();
@@ -255,7 +267,7 @@
if (task == null) {
return;
}
- currentTaskThread= Thread.currentThread();
+ currentTaskThread = Thread.currentThread();
monitors.setTaskMonitor(subMonitorFor(monitors.getTargetMonitor(), 1));
monitors.getTaskMonitor().beginTask(IAntCoreConstants.EMPTY_STRING, 1);
// If this script is calling another one, track the project chain.
@@ -266,9 +278,12 @@
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void taskFinished(BuildEvent event) {
checkCanceled();
Project project = event.getProject();
@@ -281,26 +296,29 @@
return;
}
monitors.getTaskMonitor().done();
- currentTaskThread= null;
+ currentTaskThread = null;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void messageLogged(BuildEvent event) {
checkCanceled();
}
protected void checkCanceled() {
- //only cancel if the current task thread matches the current thread
- //do not want to throw an exception in a separate thread or process
- //see bug 32657
+ // only cancel if the current task thread matches the current thread
+ // do not want to throw an exception in a separate thread or process
+ // see bug 32657
if (currentTaskThread != null && currentTaskThread != Thread.currentThread()) {
return;
}
ProjectMonitors monitors = projects.get(mainProject);
if (monitors.getMainMonitor().isCanceled()) {
- currentTaskThread= null;
+ currentTaskThread = null;
throw new OperationCanceledException(InternalAntMessages.ProgressBuildListener_Build_cancelled);
}
}
diff --git a/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF
index cfc993f..525ee2c 100644
--- a/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF
+++ b/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF
@@ -10,7 +10,7 @@
org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)",
- org.apache.ant;bundle-version="1.7.1",
+ org.apache.ant;bundle-version="1.9.2",
org.eclipse.core.externaltools;bundle-version="[1.0.0,2.0.0)",
org.eclipse.text;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.5.0,4.0.0)",
diff --git a/ant/org.eclipse.ant.launching/common/org/eclipse/ant/internal/launching/debug/AntDebugState.java b/ant/org.eclipse.ant.launching/common/org/eclipse/ant/internal/launching/debug/AntDebugState.java
index c758410..280986f 100644
--- a/ant/org.eclipse.ant.launching/common/org/eclipse/ant/internal/launching/debug/AntDebugState.java
+++ b/ant/org.eclipse.ant.launching/common/org/eclipse/ant/internal/launching/debug/AntDebugState.java
@@ -28,72 +28,70 @@
import org.eclipse.ant.internal.launching.debug.model.DebugMessageIds;
public class AntDebugState {
-
- private static final String fgAntTaskName= "ant"; //$NON-NLS-1$
- private static final String fgAntCallTaskName= "antcall"; //$NON-NLS-1$
-
+
+ private static final String fgAntTaskName = "ant"; //$NON-NLS-1$
+ private static final String fgAntCallTaskName = "antcall"; //$NON-NLS-1$
+
private IDebugBuildLogger fLogger;
- private Stack<Task> fTasks= new Stack<Task>();
- private Map<Task, Object> fTaskToProxies= new HashMap<Task, Object>();
+ private Stack<Task> fTasks = new Stack<Task>();
+ private Map<Task, Object> fTaskToProxies = new HashMap<Task, Object>();
private Task fCurrentTask;
private Task fStepOverTask;
private Task fStepIntoTask;
private Task fLastTaskFinished;
-
- //properties set before execution
- //TODO ANT-1.9.1 API USE
- private Map<?, ?> fInitialProperties= null;
- private Map<?, ?> fProperties= null;
-
- private Map<Project, Vector<?>> fProjectToTargetNames= null;
- private Map<Project, Map<Target, Vector<?>>> fProjectToMapOfTargetToBuildSequence= null;
- private Stack<Target> fTargetsToExecute= new Stack<Target>();
- private Stack<Target> fTargetsExecuting= new Stack<Target>();
-
- private boolean fConsiderTargetBreakpoints= false;
+
+ // properties set before execution
+ private Map<String, Object> fInitialProperties = null;
+ private Map<String, Object> fProperties = null;
+
+ private Map<Project, Vector<?>> fProjectToTargetNames = null;
+ private Map<Project, Map<Target, Vector<Target>>> fProjectToMapOfTargetToBuildSequence = null;
+ private Stack<Target> fTargetsToExecute = new Stack<Target>();
+ private Stack<Target> fTargetsExecuting = new Stack<Target>();
+
+ private boolean fConsiderTargetBreakpoints = false;
private boolean fShouldSuspend;
- private boolean fClientSuspend= false;
- private boolean fStepIntoSuspend= false;
- private boolean fIsAfterTaskEvent= false;
-
-
+ private boolean fClientSuspend = false;
+ private boolean fStepIntoSuspend = false;
+ private boolean fIsAfterTaskEvent = false;
+
public AntDebugState(IDebugBuildLogger logger) {
- fLogger= logger;
+ fLogger = logger;
}
public void buildStarted() {
- fProjectToTargetNames= new HashMap<Project, Vector<?>>();
- fProjectToMapOfTargetToBuildSequence= new HashMap<Project, Map<Target, Vector<?>>>();
- }
-
- /**
- * Call-back from {@link org.eclipse.ant.internal.launching.runtime.logger.AntProcessDebugBuildLogger}
- * when the build has finished
- * @since 1.0.1
- */
- public void buildFinished() {
- if(fProjectToTargetNames != null) {
- fProjectToTargetNames.clear();
- }
- if(fProjectToMapOfTargetToBuildSequence != null) {
- fProjectToMapOfTargetToBuildSequence.clear();
- }
- fTargetsExecuting.clear();
- fTargetsToExecute.clear();
- if(fInitialProperties != null) {
- fInitialProperties.clear();
- }
- if(fProperties != null) {
- fProperties.clear();
- }
- if(fTaskToProxies != null) {
- fTaskToProxies.clear();
- }
- if(fTasks != null) {
- fTasks.clear();
- }
- }
-
+ fProjectToTargetNames = new HashMap<Project, Vector<?>>();
+ fProjectToMapOfTargetToBuildSequence = new HashMap<Project, Map<Target, Vector<Target>>>();
+ }
+
+ /**
+ * Call-back from {@link org.eclipse.ant.internal.launching.runtime.logger.AntProcessDebugBuildLogger} when the build has finished
+ *
+ * @since 1.0.1
+ */
+ public void buildFinished() {
+ if (fProjectToTargetNames != null) {
+ fProjectToTargetNames.clear();
+ }
+ if (fProjectToMapOfTargetToBuildSequence != null) {
+ fProjectToMapOfTargetToBuildSequence.clear();
+ }
+ fTargetsExecuting.clear();
+ fTargetsToExecute.clear();
+ if (fInitialProperties != null) {
+ fInitialProperties.clear();
+ }
+ if (fProperties != null) {
+ fProperties.clear();
+ }
+ if (fTaskToProxies != null) {
+ fTaskToProxies.clear();
+ }
+ if (fTasks != null) {
+ fTasks.clear();
+ }
+ }
+
public void waitIfSuspended() {
fLogger.waitIfSuspended();
}
@@ -103,7 +101,7 @@
}
private void setLastTaskFinished(Task lastTaskFinished) {
- fLastTaskFinished= lastTaskFinished;
+ fLastTaskFinished = lastTaskFinished;
}
@@ -112,11 +110,11 @@
}
public void setCurrentTask(Task currentTask) {
- fCurrentTask= currentTask;
+ fCurrentTask = currentTask;
}
- private Map<?, ?> getInitialProperties() {
+ private Map<String, Object> getInitialProperties() {
return fInitialProperties;
}
@@ -125,7 +123,7 @@
}
public void setStepOverTask(Task stepOverTask) {
- fStepOverTask= stepOverTask;
+ fStepOverTask = stepOverTask;
}
@@ -134,54 +132,54 @@
}
private void setConsiderTargetBreakpoints(boolean considerTargetBreakpoints) {
- fConsiderTargetBreakpoints= considerTargetBreakpoints;
+ fConsiderTargetBreakpoints = considerTargetBreakpoints;
}
private Stack<Task> getTasks() {
return fTasks;
}
-
+
public void setShouldSuspend(boolean shouldSuspend) {
- fShouldSuspend= shouldSuspend;
+ fShouldSuspend = shouldSuspend;
}
public boolean shouldSuspend() {
return fShouldSuspend;
}
- private Map<Target, Vector<?>> getTargetToBuildSequence(Project project) {
+ private Map<Target, Vector<Target>> getTargetToBuildSequence(Project project) {
return fProjectToMapOfTargetToBuildSequence.get(project);
}
public void setTargetToExecute(Target target) {
- if (target == null) {
- fTargetsToExecute.pop();
- } else {
- fTargetsToExecute.push(target);
- }
+ if (target == null) {
+ fTargetsToExecute.pop();
+ } else {
+ fTargetsToExecute.push(target);
+ }
}
public void setTargetExecuting(Target target) {
- if (target == null) {
- if(!fTargetsExecuting.isEmpty()) {
- fTargetsExecuting.pop();
- }
- } else {
- fTargetsExecuting.push(target);
- }
+ if (target == null) {
+ if (!fTargetsExecuting.isEmpty()) {
+ fTargetsExecuting.pop();
+ }
+ } else {
+ fTargetsExecuting.push(target);
+ }
}
private Target getTargetToExecute() {
- if (fTargetsToExecute.isEmpty()) {
- return null;
- }
+ if (fTargetsToExecute.isEmpty()) {
+ return null;
+ }
return fTargetsToExecute.peek();
}
-
+
private Target getTargetExecuting() {
- if (fTargetsExecuting.isEmpty()) {
- return null;
- }
+ if (fTargetsExecuting.isEmpty()) {
+ return null;
+ }
return fTargetsExecuting.peek();
}
@@ -208,24 +206,24 @@
public void setStepIntoTask(Task stepIntoTask) {
fStepIntoTask = stepIntoTask;
}
-
+
public void resume() {
fLogger.notifyAll();
}
- public Map<?, ?> getProperties() {
+ public Map<String, Object> getProperties() {
return fProperties;
}
-
+
public Location getBreakpointLocation() {
if (isAfterTaskEvent() && getCurrentTask() != null) {
return getCurrentTask().getLocation();
}
if (considerTargetBreakpoints()) {
- Target targetExecuting= getTargetExecuting();
- if (targetExecuting != null) {
- return getLocation(targetExecuting);
- }
+ Target targetExecuting = getTargetExecuting();
+ if (targetExecuting != null) {
+ return getLocation(targetExecuting);
+ }
}
return null;
}
@@ -237,19 +235,19 @@
private void setAfterTaskEvent(boolean isAfterTaskEvent) {
fIsAfterTaskEvent = isAfterTaskEvent;
}
-
+
public void taskStarted(BuildEvent event) {
setAfterTaskEvent(true);
- if (getInitialProperties() == null) {//implicit or top level target does not fire targetStarted()
- fInitialProperties= event.getProject().getProperties();
+ if (getInitialProperties() == null) {// implicit or top level target does not fire targetStarted()
+ fInitialProperties = event.getProject().getProperties();
}
-
+
setCurrentTask(event.getTask());
setConsiderTargetBreakpoints(false);
Stack<Task> tasks = getTasks();
if (!tasks.isEmpty()) {
- //cache the parent task proxy as when that task is started or finished the
- //proxy is not yet available or is nulled out
+ // cache the parent task proxy as when that task is started or finished the
+ // proxy is not yet available or is nulled out
Task parentTask = tasks.peek();
Object proxy = parentTask.getRuntimeConfigurableWrapper().getProxy();
if (proxy != null) {
@@ -259,262 +257,261 @@
tasks.push(getCurrentTask());
waitIfSuspended();
}
-
- public void taskFinished() {
- Stack<Task> tasks = getTasks();
- if(!tasks.empty()) {
- Task lastTask= tasks.pop();
- setLastTaskFinished(lastTask);
- setCurrentTask(null);
- String taskName= lastTask.getTaskName();
-
- if (getStepOverTask() != null) {
- if ((fgAntCallTaskName.equals(taskName) || fgAntTaskName.equals(taskName)) && (!fgAntCallTaskName.equals(getStepOverTask().getTaskName()) && !fgAntTaskName.equals(getStepOverTask().getTaskName()))) {
- setShouldSuspend(true);
- } else if (fTaskToProxies.remove(lastTask) instanceof MacroInstance) {
- setShouldSuspend(true);
- }
- }
- }
- waitIfSuspended();
- }
+ public void taskFinished() {
+ Stack<Task> tasks = getTasks();
+ if (!tasks.empty()) {
+ Task lastTask = tasks.pop();
+ setLastTaskFinished(lastTask);
+ setCurrentTask(null);
+ String taskName = lastTask.getTaskName();
- public void stepOver() {
- setStepOverTask(getCurrentTask());
- if (getCurrentTask() == null) {
- //stepping over target breakpoint
- setShouldSuspend(true);
- }
- resume();
- }
+ if (getStepOverTask() != null) {
+ if ((fgAntCallTaskName.equals(taskName) || fgAntTaskName.equals(taskName))
+ && (!fgAntCallTaskName.equals(getStepOverTask().getTaskName()) && !fgAntTaskName.equals(getStepOverTask().getTaskName()))) {
+ setShouldSuspend(true);
+ } else if (fTaskToProxies.remove(lastTask) instanceof MacroInstance) {
+ setShouldSuspend(true);
+ }
+ }
+ }
+ waitIfSuspended();
+ }
- public void targetStarted(BuildEvent event) {
+ public void stepOver() {
+ setStepOverTask(getCurrentTask());
+ if (getCurrentTask() == null) {
+ // stepping over target breakpoint
+ setShouldSuspend(true);
+ }
+ resume();
+ }
+
+ public void targetStarted(BuildEvent event) {
setAfterTaskEvent(false);
- Project eventProject = event.getProject();
- if (getInitialProperties() == null) {
- fInitialProperties= eventProject.getProperties();
- }
- if (fProjectToTargetNames.get(eventProject) == null) {
- Object ref= eventProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
- if (ref != null) {
- fProjectToTargetNames.put(eventProject, (Vector<?>) ref);
- HashMap<Target, Vector<?>> targetToBuildSequence = new HashMap<Target, Vector<?>>();
- setTargetToExecute(initializeBuildSequenceInformation(event, targetToBuildSequence));
- fProjectToMapOfTargetToBuildSequence.put(eventProject, targetToBuildSequence);
- }
- }
-
- setTargetExecuting(event.getTarget());
- if (event.getTarget().equals(getTargetToExecute())) {
- //the dependencies of the target to execute have been met
- //prepare for the next target
- Vector<?> targets= fProjectToTargetNames.get(eventProject);
- if (!targets.isEmpty()) {
- setTargetToExecute((Target) eventProject.getTargets().get(targets.remove(0)));
- } else {
- setTargetToExecute(null);
- }
- }
- setConsiderTargetBreakpoints(true);
- }
+ Project eventProject = event.getProject();
+ if (getInitialProperties() == null) {
+ fInitialProperties = eventProject.getProperties();
+ }
+ if (fProjectToTargetNames.get(eventProject) == null) {
+ Object ref = eventProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
+ if (ref != null) {
+ fProjectToTargetNames.put(eventProject, (Vector<?>) ref);
+ HashMap<Target, Vector<Target>> targetToBuildSequence = new HashMap<Target, Vector<Target>>();
+ setTargetToExecute(initializeBuildSequenceInformation(event, targetToBuildSequence));
+ fProjectToMapOfTargetToBuildSequence.put(eventProject, targetToBuildSequence);
+ }
+ }
+
+ setTargetExecuting(event.getTarget());
+ if (event.getTarget().equals(getTargetToExecute())) {
+ // the dependencies of the target to execute have been met
+ // prepare for the next target
+ Vector<?> targets = fProjectToTargetNames.get(eventProject);
+ if (!targets.isEmpty()) {
+ setTargetToExecute(eventProject.getTargets().get(targets.remove(0)));
+ } else {
+ setTargetToExecute(null);
+ }
+ }
+ setConsiderTargetBreakpoints(true);
+ }
public int getLineNumber(Location location) {
- try { //succeeds with Ant newer than 1.6
- return location.getLineNumber();
- } catch (NoSuchMethodError e) {
- //Ant before 1.6
- String locationString= location.toString();
- if (locationString.length() == 0) {
- return 0;
- }
- //filename: lineNumber: ("c:\buildfile.xml: 12: ")
- int lastIndex= locationString.lastIndexOf(':');
- int index =locationString.lastIndexOf(':', lastIndex - 1);
- if (index != -1) {
- try {
- return Integer.parseInt(locationString.substring(index+1, lastIndex));
- } catch (NumberFormatException nfe) {
- return 0;
- }
- }
- return 0;
- }
+ try { // succeeds with Ant newer than 1.6
+ return location.getLineNumber();
+ }
+ catch (NoSuchMethodError e) {
+ // Ant before 1.6
+ String locationString = location.toString();
+ if (locationString.length() == 0) {
+ return 0;
+ }
+ // filename: lineNumber: ("c:\buildfile.xml: 12: ")
+ int lastIndex = locationString.lastIndexOf(':');
+ int index = locationString.lastIndexOf(':', lastIndex - 1);
+ if (index != -1) {
+ try {
+ return Integer.parseInt(locationString.substring(index + 1, lastIndex));
+ }
+ catch (NumberFormatException nfe) {
+ return 0;
+ }
+ }
+ return 0;
+ }
}
public static Location getLocation(Target target) {
- try {//succeeds with Ant newer than 1.6.2
- return target.getLocation();
- } catch (NoSuchMethodError e) {
- return Location.UNKNOWN_LOCATION;
- }
+ try {// succeeds with Ant newer than 1.6.2
+ return target.getLocation();
+ }
+ catch (NoSuchMethodError e) {
+ return Location.UNKNOWN_LOCATION;
+ }
}
public String getFileName(Location location) {
- try {//succeeds with Ant newer than 1.6
- return location.getFileName();
- } catch (NoSuchMethodError e) {
- //Ant before 1.6
- String locationString= location.toString();
- if (locationString.length() == 0) {
- return null;
- }
- //filename: lineNumber: ("c:\buildfile.xml: 12: ")
- int lastIndex= locationString.lastIndexOf(':');
- int index =locationString.lastIndexOf(':', lastIndex-1);
- if (index == -1) {
- index= lastIndex; //only the filename is known
- }
- if (index != -1) {
- //bug 84403
- //if (locationString.startsWith("file:")) {
- // return FileUtils.newFileUtils().fromURI(locationString);
- //}
- //remove file:
- return locationString.substring(5, index);
- }
- return null;
- }
+ try {// succeeds with Ant newer than 1.6
+ return location.getFileName();
+ }
+ catch (NoSuchMethodError e) {
+ // Ant before 1.6
+ String locationString = location.toString();
+ if (locationString.length() == 0) {
+ return null;
+ }
+ // filename: lineNumber: ("c:\buildfile.xml: 12: ")
+ int lastIndex = locationString.lastIndexOf(':');
+ int index = locationString.lastIndexOf(':', lastIndex - 1);
+ if (index == -1) {
+ index = lastIndex; // only the filename is known
+ }
+ if (index != -1) {
+ // bug 84403
+ // if (locationString.startsWith("file:")) {
+ // return FileUtils.newFileUtils().fromURI(locationString);
+ // }
+ // remove file:
+ return locationString.substring(5, index);
+ }
+ return null;
+ }
}
private void appendToStack(StringBuffer stackRepresentation, String targetName, String taskName, Location location) {
- stackRepresentation.append(targetName);
- stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
- stackRepresentation.append(taskName);
- stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
-
- stackRepresentation.append(getFileName(location));
- stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
- stackRepresentation.append(getLineNumber(location));
- stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ stackRepresentation.append(targetName);
+ stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ stackRepresentation.append(taskName);
+ stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+
+ stackRepresentation.append(getFileName(location));
+ stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ stackRepresentation.append(getLineNumber(location));
+ stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
}
public void marshalStack(StringBuffer stackRepresentation) {
- Stack<Task> tasks= getTasks();
-
- stackRepresentation.append(DebugMessageIds.STACK);
- stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
-
- Target targetToExecute= getTargetToExecute();
- Target targetExecuting= getTargetExecuting();
-
- Project projectExecuting= null;
- if (targetExecuting != null) {
- projectExecuting= targetExecuting.getProject();
- } else if(!tasks.empty()) { //no target...must be a task
- Task task= tasks.peek();
- projectExecuting= task.getProject();
- }
-
+ Stack<Task> tasks = getTasks();
+
+ stackRepresentation.append(DebugMessageIds.STACK);
+ stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+
+ Target targetToExecute = getTargetToExecute();
+ Target targetExecuting = getTargetExecuting();
+
+ Project projectExecuting = null;
+ if (targetExecuting != null) {
+ projectExecuting = targetExecuting.getProject();
+ } else if (!tasks.empty()) { // no target...must be a task
+ Task task = tasks.peek();
+ projectExecuting = task.getProject();
+ }
+
if (!isAfterTaskEvent()) {
appendToStack(stackRepresentation, targetExecuting.getName(), IAntCoreConstants.EMPTY_STRING, getLocation(targetExecuting));
}
- for (int i = tasks.size() - 1; i >= 0 ; i--) {
- Task task= tasks.get(i);
- if (task.getProject() == projectExecuting) {
- appendToStack(stackRepresentation, task.getOwningTarget().getName(), task.getTaskName(), task.getLocation());
- } else {
- //sub build target dependencies
- String targetName= task.getOwningTarget().getName();
- if (targetName != null && targetName.length() != 0) { //skip for implicit target
- Iterator<Target> itr= fTargetsToExecute.iterator();
- while (itr.hasNext()) {
- Target target= itr.next();
- if (target.getProject() != projectExecuting) {
- targetToExecute= target;
- continue;
- }
- marshalTargetDependancyStack(stackRepresentation, target, targetExecuting);
- }
- }
- projectExecuting= task.getProject();
- targetExecuting= task.getOwningTarget();
- appendToStack(stackRepresentation, targetExecuting.getName(), task.getTaskName(), task.getLocation());
- }
+ for (int i = tasks.size() - 1; i >= 0; i--) {
+ Task task = tasks.get(i);
+ if (task.getProject() == projectExecuting) {
+ appendToStack(stackRepresentation, task.getOwningTarget().getName(), task.getTaskName(), task.getLocation());
+ } else {
+ // sub build target dependencies
+ String targetName = task.getOwningTarget().getName();
+ if (targetName != null && targetName.length() != 0) { // skip for implicit target
+ Iterator<Target> itr = fTargetsToExecute.iterator();
+ while (itr.hasNext()) {
+ Target target = itr.next();
+ if (target.getProject() != projectExecuting) {
+ targetToExecute = target;
+ continue;
+ }
+ marshalTargetDependancyStack(stackRepresentation, target, targetExecuting);
+ }
+ }
+ projectExecuting = task.getProject();
+ targetExecuting = task.getOwningTarget();
+ appendToStack(stackRepresentation, targetExecuting.getName(), task.getTaskName(), task.getLocation());
+ }
}
- //target dependency stack
+ // target dependency stack
marshalTargetDependancyStack(stackRepresentation, targetToExecute, targetExecuting);
}
- private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Target targetToExecute, Target targetExecuting) {
- if (targetToExecute != null) {
- Vector<?> buildSequence= getTargetToBuildSequence(targetToExecute.getProject()).get(targetToExecute);
- int startIndex= buildSequence.indexOf(targetExecuting) + 1;
- int dependancyStackDepth= buildSequence.indexOf(targetToExecute);
-
- Target stackTarget;
- for (int i = startIndex; i <= dependancyStackDepth; i++) {
- stackTarget= (Target) buildSequence.get(i);
- if (stackTarget.dependsOn(targetExecuting.getName())) {
- appendToStack(stackRepresentation, stackTarget.getName(), IAntCoreConstants.EMPTY_STRING, getLocation(stackTarget));
- }
- }
- }
- }
+ private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Target targetToExecute, Target targetExecuting) {
+ if (targetToExecute != null) {
+ Vector<Target> buildSequence = getTargetToBuildSequence(targetToExecute.getProject()).get(targetToExecute);
+ int startIndex = buildSequence.indexOf(targetExecuting) + 1;
+ int dependancyStackDepth = buildSequence.indexOf(targetToExecute);
+
+ Target stackTarget;
+ for (int i = startIndex; i <= dependancyStackDepth; i++) {
+ stackTarget = buildSequence.get(i);
+ if (stackTarget.dependsOn(targetExecuting.getName())) {
+ appendToStack(stackRepresentation, stackTarget.getName(), IAntCoreConstants.EMPTY_STRING, getLocation(stackTarget));
+ }
+ }
+ }
+ }
public void marshallProperties(StringBuffer propertiesRepresentation, boolean escapeLineSep) {
Stack<Task> tasks = getTasks();
if (tasks.isEmpty()) {
return;
}
- propertiesRepresentation.append(DebugMessageIds.PROPERTIES);
- propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
-
- Project project= tasks.peek().getProject();
- Map<?, ?> lastProperties= getProperties();
-
- //TODO ANT-1.9.1 API USE
- Map<?, ?> currentProperties= project.getProperties();
- if (lastProperties != null && currentProperties.size() == lastProperties.size()) {
- //no new properties
- return;
- }
-
- Map<?, ?> initialProperties= getInitialProperties();
- Map<?, ?> currentUserProperties= project.getUserProperties();
- Iterator<?> iter= currentProperties.keySet().iterator();
- String propertyName;
+ propertiesRepresentation.append(DebugMessageIds.PROPERTIES);
+ propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+
+ Project project = tasks.peek().getProject();
+ Map<String, Object> lastProperties = getProperties();
+
+ Map<String, Object> currentProperties = project.getProperties();
+ if (lastProperties != null && currentProperties.size() == lastProperties.size()) {
+ // no new properties
+ return;
+ }
+
+ Map<String, Object> initialProperties = getInitialProperties();
+ Map<String, Object> currentUserProperties = project.getUserProperties();
String originalPropertyName;
- String propertyValue;
- while (iter.hasNext()) {
- propertyName = (String) iter.next();
- originalPropertyName= propertyName;
- if (lastProperties == null || lastProperties.get(propertyName) == null) { //new property
+ String propertyValue;
+ for (String propertyName : currentProperties.keySet()) {
+ originalPropertyName = propertyName;
+ if (lastProperties == null || lastProperties.get(propertyName) == null) { // new property
if (escapeLineSep) {
- propertyName= escapeLineSeparator(propertyName);
+ propertyName = escapeLineSeparator(propertyName);
}
- propertiesRepresentation.append(propertyName.length());
- propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
- propertiesRepresentation.append(propertyName);
- propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
- propertyValue= (String) currentProperties.get(originalPropertyName);
+ propertiesRepresentation.append(propertyName.length());
+ propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ propertiesRepresentation.append(propertyName);
+ propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ propertyValue = (String) currentProperties.get(originalPropertyName);
if (escapeLineSep) {
- propertyValue= escapeLineSeparator(propertyValue);
+ propertyValue = escapeLineSeparator(propertyValue);
}
- propertiesRepresentation.append(propertyValue.length());
- propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ propertiesRepresentation.append(propertyValue.length());
+ propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
propertiesRepresentation.append(propertyValue);
- propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
- propertiesRepresentation.append(getPropertyType(initialProperties, currentUserProperties, originalPropertyName));
- propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
- }
- }
-
- propertiesRepresentation.deleteCharAt(propertiesRepresentation.length() - 1);
- fProperties= currentProperties;
+ propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ propertiesRepresentation.append(getPropertyType(initialProperties, currentUserProperties, originalPropertyName));
+ propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
+ }
+ }
+ propertiesRepresentation.deleteCharAt(propertiesRepresentation.length() - 1);
+ fProperties = currentProperties;
}
- private int getPropertyType(Map<?, ?> initialProperties, Map<?, ?> currentUserProperties, String propertyName) {
- if (initialProperties.get(propertyName) != null) { //properties set before the start of the build
- if (currentUserProperties.get(propertyName) == null) {
- return DebugMessageIds.PROPERTY_SYSTEM;
- }
+ private int getPropertyType(Map<String, Object> initialProperties, Map<String, Object> currentUserProperties, String propertyName) {
+ if (initialProperties.get(propertyName) != null) { // properties set before the start of the build
+ if (currentUserProperties.get(propertyName) == null) {
+ return DebugMessageIds.PROPERTY_SYSTEM;
+ }
return DebugMessageIds.PROPERTY_USER;
- } else if (currentUserProperties.get(propertyName) == null){
- return DebugMessageIds.PROPERTY_RUNTIME;
+ } else if (currentUserProperties.get(propertyName) == null) {
+ return DebugMessageIds.PROPERTY_RUNTIME;
} else {
- return DebugMessageIds.PROPERTY_USER;
+ return DebugMessageIds.PROPERTY_USER;
}
}
@@ -522,48 +519,44 @@
if (!(stringToEscape.indexOf('\r') != -1 || stringToEscape.indexOf('\n') != -1 || stringToEscape.indexOf("\\r") != -1 || stringToEscape.indexOf("\\n") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$
return stringToEscape;
}
- StringBuffer escapedValue= new StringBuffer(stringToEscape);
- for (int i= 0; i < escapedValue.length(); i++) {
+ StringBuffer escapedValue = new StringBuffer(stringToEscape);
+ for (int i = 0; i < escapedValue.length(); i++) {
switch (escapedValue.charAt(i)) {
- case '\r':
- escapedValue.replace(i, i+1, "\\r"); //$NON-NLS-1$
- i++;
- break;
- case '\n':
- escapedValue.replace(i, i+1, "\\n"); //$NON-NLS-1$
- i++;
- break;
- case '\\':
- if (escapedValue.charAt(i + 1) == 'r' || escapedValue.charAt(i + 1) == 'n') {
- escapedValue.replace(i, i+1, "\\\\"); //$NON-NLS-1$
+ case '\r':
+ escapedValue.replace(i, i + 1, "\\r"); //$NON-NLS-1$
i++;
- }
- break;
- default:
- break;
+ break;
+ case '\n':
+ escapedValue.replace(i, i + 1, "\\n"); //$NON-NLS-1$
+ i++;
+ break;
+ case '\\':
+ if (escapedValue.charAt(i + 1) == 'r' || escapedValue.charAt(i + 1) == 'n') {
+ escapedValue.replace(i, i + 1, "\\\\"); //$NON-NLS-1$
+ i++;
+ }
+ break;
+ default:
+ break;
}
}
return escapedValue.toString();
}
- private Target initializeBuildSequenceInformation(BuildEvent event, Map<Target, Vector<?>> targetToBuildSequence) {
- Project antProject= event.getProject();
- Vector<?> targets= (Vector<?>) antProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
- if (targets == null) {
- return null;
- }
- Iterator<?> itr= targets.iterator();
- //TODO ANT-1.9.1 API USE
- Hashtable<?, ?> allTargets = antProject.getTargets();
- String targetName;
- Vector<?> sortedTargets;
- while (itr.hasNext()) {
- targetName= (String) itr.next();
- sortedTargets= antProject.topoSort(targetName, allTargets);
- targetToBuildSequence.put((Target) allTargets.get(targetName), sortedTargets);
- }
- //the target to execute
- return (Target) allTargets.get(targets.remove(0));
+ private Target initializeBuildSequenceInformation(BuildEvent event, Map<Target, Vector<Target>> targetToBuildSequence) {
+ Project antProject = event.getProject();
+ Vector<String> targets = (Vector<String>) antProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
+ if (targets == null) {
+ return null;
+ }
+ Hashtable<String, Target> allTargets = antProject.getTargets();
+ Vector<Target> sortedTargets;
+ for (String targetName : targets) {
+ sortedTargets = antProject.topoSort(targetName, allTargets);
+ targetToBuildSequence.put(allTargets.get(targetName), sortedTargets);
+ }
+ // the target to execute
+ return allTargets.get(targets.remove(0));
}
}
diff --git a/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF
index cc3bd08..d330e15 100644
--- a/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF
+++ b/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF
@@ -11,7 +11,7 @@
org.eclipse.ant.tests.core.testplugin,
org.eclipse.ant.tests.core.tests
Require-Bundle: org.eclipse.ui.ide;resolution:=optional,
- org.apache.ant;bundle-version="1.8.4",
+ org.apache.ant;bundle-version="1.9.2",
org.junit,
org.eclipse.core.resources,
org.eclipse.ui,
diff --git a/ant/org.eclipse.ant.tests.core/buildfiles/buildAntTestsSupportJAR.xml b/ant/org.eclipse.ant.tests.core/buildfiles/buildAntTestsSupportJAR.xml
index 8b57ae7..7dac400 100644
--- a/ant/org.eclipse.ant.tests.core/buildfiles/buildAntTestsSupportJAR.xml
+++ b/ant/org.eclipse.ant.tests.core/buildfiles/buildAntTestsSupportJAR.xml
Binary files differ
diff --git a/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/AntTestChecker.java b/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/AntTestChecker.java
index e1e5509..1f55391 100644
--- a/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/AntTestChecker.java
+++ b/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/AntTestChecker.java
@@ -10,52 +10,51 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.testplugin;
-
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
public class AntTestChecker {
-
- private static AntTestChecker deflt= null;
-
+
+ private static AntTestChecker deflt = null;
+
private int taskStartedCount;
-
+
private int taskFinishedCount;
-
+
private int targetsStartedCount;
-
+
private int targetsFinishedCount;
-
+
private int buildsStartedCount;
-
+
private int buildsFinishedCount;
-
- private List<String> messages= new ArrayList<String>();
-
- private List<String> targets= new ArrayList<String>();
-
- private List<String> tasks= new ArrayList<String>();
-
- private List<String> projects= new ArrayList<String>();
-
- private Hashtable<String, String> userProperties;
-
- private List<String> nameOfListeners= new ArrayList<String>();
-
- private AntTestChecker() {
+
+ private List<String> messages = new ArrayList<String>();
+
+ private List<String> targets = new ArrayList<String>();
+
+ private List<String> tasks = new ArrayList<String>();
+
+ private List<String> projects = new ArrayList<String>();
+
+ private Hashtable<String, Object> userProperties;
+
+ private List<String> nameOfListeners = new ArrayList<String>();
+
+ private AntTestChecker() {
}
-
+
/**
* Returns the singleton AntTestChecker
*/
public static AntTestChecker getDefault() {
if (deflt == null) {
- deflt= new AntTestChecker();
+ deflt = new AntTestChecker();
}
return deflt;
}
-
+
/**
* Resets the singleton AntTestChecker
*/
@@ -64,6 +63,7 @@
deflt.resetState();
}
}
+
/**
* @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
*/
@@ -71,13 +71,11 @@
buildsFinishedCount++;
}
-
public void buildStarted(String projectName) {
buildsStartedCount++;
projects.add(projectName);
}
-
public void messageLogged(String message) {
messages.add(message);
}
@@ -111,9 +109,10 @@
taskStartedCount++;
tasks.add(taskName);
}
-
+
/**
* Returns the buildsFinishedCount.
+ *
* @return int
*/
public int getBuildsFinishedCount() {
@@ -122,6 +121,7 @@
/**
* Returns the buildsStartedCount.
+ *
* @return int
*/
public int getBuildsStartedCount() {
@@ -130,6 +130,7 @@
/**
* Returns the messagesLoggedCount.
+ *
* @return int
*/
public int getMessagesLoggedCount() {
@@ -138,6 +139,7 @@
/**
* Returns the targetsFinishedCount.
+ *
* @return int
*/
public int getTargetsFinishedCount() {
@@ -146,6 +148,7 @@
/**
* Returns the targetsStartedCount.
+ *
* @return int
*/
public int getTargetsStartedCount() {
@@ -154,6 +157,7 @@
/**
* Returns the taskFinishedCount.
+ *
* @return int
*/
public int getTaskFinishedCount() {
@@ -162,67 +166,67 @@
/**
* Returns the taskStartedCount.
+ *
* @return int
*/
public int getTaskStartedCount() {
return taskStartedCount;
}
-
+
protected void resetState() {
- taskStartedCount= 0;
- taskFinishedCount= 0;
- targetsStartedCount= 0;
- targetsFinishedCount= 0;
- buildsStartedCount= 0;
- buildsFinishedCount= 0;
- messages= new ArrayList<String>();
- tasks= new ArrayList<String>();
- targets= new ArrayList<String>();
- projects= new ArrayList<String>();
- userProperties= null;
- nameOfListeners= new ArrayList<String>();
+ taskStartedCount = 0;
+ taskFinishedCount = 0;
+ targetsStartedCount = 0;
+ targetsFinishedCount = 0;
+ buildsStartedCount = 0;
+ buildsFinishedCount = 0;
+ messages = new ArrayList<String>();
+ tasks = new ArrayList<String>();
+ targets = new ArrayList<String>();
+ projects = new ArrayList<String>();
+ userProperties = null;
+ nameOfListeners = new ArrayList<String>();
}
-
+
/**
- * Return the message n from the last:
- * e.g. getLoggedMessage(0) returns the most recent message
- *
- * @param n message index
+ * Return the message n from the last: e.g. getLoggedMessage(0) returns the most recent message
+ *
+ * @param n
+ * message index
* @return the nth last message
*/
- public String getLoggedMessage(int n) {
- int idx = messages.size() - (n + 1);
- if ((idx < 0) || (idx >= messages.size())) {
- return null;
- }
- return messages.get(idx);
- }
+ public String getLoggedMessage(int n) {
+ int idx = messages.size() - (n + 1);
+ if ((idx < 0) || (idx >= messages.size())) {
+ return null;
+ }
+ return messages.get(idx);
+ }
- public String getLastMessageLogged() {
- return getLoggedMessage(0);
- }
-
- public void setUserProperties(Hashtable<String, String> userProperties) {
- this.userProperties= userProperties;
+ public String getLastMessageLogged() {
+ return getLoggedMessage(0);
+ }
+
+ public void setUserProperties(Hashtable<String, Object> userProperties) {
+ this.userProperties = userProperties;
}
public String getUserProperty(String name) {
- return userProperties.get(name);
+ return (String) userProperties.get(name);
}
-
+
public List<String> getMessages() {
return messages;
}
-
+
public List<String> getListeners() {
return nameOfListeners;
}
-
+
public String getLastListener() {
return nameOfListeners.get(nameOfListeners.size() - 1);
}
-
public void addNameOfListener(String nameOfListener) {
this.nameOfListeners.add(nameOfListener);
}
diff --git a/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java b/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java
index 112b3c7..6af6f19 100644
--- a/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java
+++ b/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.support.testloggers;
-
import java.io.PrintStream;
import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.BuildLogger;
import org.apache.tools.ant.Project;
import org.eclipse.ant.core.AntSecurityException;
@@ -22,27 +22,27 @@
public class TestBuildLogger implements BuildLogger {
- private int fMessageOutputLevel= Project.MSG_INFO;
- private PrintStream fErr= null;
- private PrintStream fOut= null;
- private boolean fSetProperties= true;
-
+ private int fMessageOutputLevel = Project.MSG_INFO;
+ private PrintStream fErr = null;
+ private PrintStream fOut = null;
+ private boolean fSetProperties = true;
+
/**
* An exception that has already been logged.
*/
- private Throwable fHandledException= null;
-
-
+ private Throwable fHandledException = null;
+
public TestBuildLogger() {
}
-
+
/**
* @see org.apache.tools.ant.BuildLogger#setMessageOutputLevel(int)
*/
+ @Override
public void setMessageOutputLevel(int level) {
- fMessageOutputLevel= level;
+ fMessageOutputLevel = level;
}
-
+
protected int getMessageOutputLevel() {
return fMessageOutputLevel;
}
@@ -50,13 +50,15 @@
/**
* @see org.apache.tools.ant.BuildLogger#setEmacsMode(boolean)
*/
+ @Override
public void setEmacsMode(boolean emacsMode) {
- //do nothing
+ // do nothing
}
/**
* @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void buildStarted(BuildEvent event) {
AntTestChecker.getDefault().buildStarted(event.getProject().getName());
}
@@ -64,27 +66,29 @@
/**
* @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void buildFinished(BuildEvent event) {
handleException(event);
- fHandledException= null;
+ fHandledException = null;
AntTestChecker.getDefault().buildFinished();
}
/**
* @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void targetStarted(BuildEvent event) {
AntTestChecker.getDefault().targetStarted(event.getTarget().getName());
- if (fSetProperties) {
- fSetProperties= false;
- //TODO ANT-1.9.1 API USE
- AntTestChecker.getDefault().setUserProperties(event.getProject().getProperties());
- }
+ if (fSetProperties) {
+ fSetProperties = false;
+ AntTestChecker.getDefault().setUserProperties(event.getProject().getProperties());
+ }
}
/**
* @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void targetFinished(BuildEvent event) {
handleException(event);
AntTestChecker.getDefault().targetFinished();
@@ -93,6 +97,7 @@
/**
* @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void taskStarted(BuildEvent event) {
AntTestChecker.getDefault().taskStarted(event.getTask().getTaskName());
}
@@ -100,6 +105,7 @@
/**
* @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
*/
+ @Override
public void taskFinished(BuildEvent event) {
handleException(event);
AntTestChecker.getDefault().targetFinished();
@@ -108,6 +114,7 @@
/**
* @see BuildListener#messageLogged(BuildEvent)
*/
+ @Override
public void messageLogged(BuildEvent event) {
if (event.getPriority() > getMessageOutputLevel()) {
return;
@@ -119,62 +126,63 @@
protected PrintStream getErrorPrintStream() {
return fErr;
}
-
+
protected PrintStream getOutputPrintStream() {
return fOut;
}
-
+
/**
* @see org.apache.tools.ant.BuildLogger#setErrorPrintStream(java.io.PrintStream)
*/
+ @Override
public void setErrorPrintStream(PrintStream err) {
- //this build logger logs to "null" unless
- //the user has explicitly set a logfile to use
+ // this build logger logs to "null" unless
+ // the user has explicitly set a logfile to use
if (err == System.err) {
- fErr= null;
+ fErr = null;
} else {
- fErr= err;
+ fErr = err;
}
}
/**
* @see org.apache.tools.ant.BuildLogger#setOutputPrintStream(java.io.PrintStream)
*/
+ @Override
public void setOutputPrintStream(PrintStream output) {
- //this build logger logs to "null" unless
- //the user has explicitly set a logfile to use
+ // this build logger logs to "null" unless
+ // the user has explicitly set a logfile to use
if (output == System.out) {
- fOut= null;
+ fOut = null;
} else {
- fOut= output;
+ fOut = output;
}
}
-
+
protected void logMessage(String message, int priority) {
if (priority > getMessageOutputLevel()) {
return;
}
-
+
if (priority == Project.MSG_ERR) {
if (getErrorPrintStream() != null && getErrorPrintStream() != System.err) {
- //user has designated to log to a logfile
+ // user has designated to log to a logfile
getErrorPrintStream().println(message);
}
} else {
if (getOutputPrintStream() != null && getOutputPrintStream() != System.out) {
- //user has designated to log to a logfile
+ // user has designated to log to a logfile
getOutputPrintStream().println(message);
- }
+ }
}
}
-
+
protected void handleException(BuildEvent event) {
Throwable exception = event.getException();
- if (exception == null || exception == fHandledException
- || exception instanceof OperationCanceledException
- || exception instanceof AntSecurityException) {
+ if (exception == null || exception == fHandledException || exception instanceof OperationCanceledException
+ || exception instanceof AntSecurityException) {
return;
}
- fHandledException= exception;
+ fHandledException = exception;
}
}
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java
index e04ead1..2e9e967 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
-
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -24,605 +23,615 @@
import org.eclipse.core.runtime.CoreException;
public class OptionTests extends AbstractAntTest {
-
+
protected static final String UNKNOWN_ARG = "Unknown argument: "; //$NON-NLS-1$
protected static final String START_OF_HELP = "ant [options] [target [target2 [target3] ...]]"; //$NON-NLS-1$
- protected static final String VERSION = "Apache Ant(TM) version 1.8.4 compiled on May 22 2012"; //$NON-NLS-1$
- protected static final String PLUGIN_VERSION = "org.apache.ant_1.8.4"; //$NON-NLS-1$
-
+ protected static final String VERSION = "Apache Ant(TM) version 1.9.2 compiled on July 8 2013"; //$NON-NLS-1$
+ protected static final String PLUGIN_VERSION = "org.apache.ant_1.9.2"; //$NON-NLS-1$
+
public OptionTests(String name) {
super(name);
}
-
+
/**
* Tests the "-help" option
*/
public void testHelp() throws CoreException {
- run("TestForEcho.xml", new String[]{"-help"}); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("incorrect message number logged", 35, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
+ run("TestForEcho.xml", new String[] { "-help" }); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("incorrect message number logged", 34, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
assertTrue("Help is incorrect", getLastMessageLogged() != null && AntTestChecker.getDefault().getMessages().get(0).startsWith(START_OF_HELP)); //$NON-NLS-1$
}
-
+
/**
* Tests the "-h" option (help)
*/
public void testMinusH() throws CoreException {
- run("TestForEcho.xml", new String[]{"-h"}); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("incorrect message number logged", 35, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
+ run("TestForEcho.xml", new String[] { "-h" }); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("incorrect message number logged", 34, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
assertTrue("Help is incorrect", getLastMessageLogged() != null && AntTestChecker.getDefault().getMessages().get(0).startsWith(START_OF_HELP)); //$NON-NLS-1$
}
-
+
/**
* Tests the "-version" option
*/
public void testVersion() throws CoreException {
- run("TestForEcho.xml", new String[]{"-version"}); //$NON-NLS-1$ //$NON-NLS-2$
+ run("TestForEcho.xml", new String[] { "-version" }); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("One message should have been logged", AntTestChecker.getDefault().getMessagesLoggedCount() == 1); //$NON-NLS-1$
assertEquals("Version is incorrect: ", VERSION, getLastMessageLogged()); //$NON-NLS-1$
}
-
+
/**
* Tests the "-projecthelp" option
*/
public void testProjecthelp() throws CoreException {
- run("TestForEcho.xml", new String[]{"-projecthelp"}); //$NON-NLS-1$ //$NON-NLS-2$
+ run("TestForEcho.xml", new String[] { "-projecthelp" }); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Incorrect number of messages", 4, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
assertTrue("Project help is incorrect", getLastMessageLogged().startsWith("Default target:")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
* Tests the "-p" option (project help)
*/
public void testMinusP() throws CoreException {
- run("TestForEcho.xml", new String[]{"-p"}); //$NON-NLS-1$ //$NON-NLS-2$
+ run("TestForEcho.xml", new String[] { "-p" }); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Incorrect number of messages", 4, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
assertTrue("Project help is incorrect", getLastMessageLogged().startsWith("Default target:")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
* Tests the "-projecthelp" option when it will not show as much (quite mode)
*/
public void testProjecthelpQuiet() throws CoreException {
- run("TestForEcho.xml", new String[]{"-projecthelp", "-q"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("TestForEcho.xml", new String[] { "-projecthelp", "-q" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertEquals(1, AntTestChecker.getDefault().getMessagesLoggedCount());
}
-
+
/**
* Tests the "-listener" option with a listener that is not an instance of BuildListener
*/
public void testListenerBad() {
try {
- run("TestForEcho.xml", new String[]{"-listener", "java.lang.String"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (CoreException ce) {
- String msg= ce.getMessage();
+ run("TestForEcho.xml", new String[] { "-listener", "java.lang.String" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ catch (CoreException ce) {
+ String msg = ce.getMessage();
assertTrue("Message incorrect!: " + msg, msg.equals("java.lang.String which was specified to be a build listener is not an instance of org.apache.tools.ant.BuildListener.")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
assertTrue("A core exception should have occurred wrappering a class cast exception", false); //$NON-NLS-1$
}
-
+
/**
* Tests passing an unrecognized argument
*/
- public void testUnknownArg() throws CoreException {
- run("TestForEcho.xml", new String[]{"-listenr"}); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Unrecognized option message should have been logged before successful build", //$NON-NLS-1$
- (AntTestChecker.getDefault().getMessagesLoggedCount() == 6)
- && (getLoggedMessage(5).startsWith(UNKNOWN_ARG))
- && (getLastMessageLogged().startsWith(BUILD_SUCCESSFUL)));
+ public void testUnknownArg() throws CoreException {
+ run("TestForEcho.xml", new String[] { "-listenr" }); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Unrecognized option message should have been logged before successful build", //$NON-NLS-1$
+ (AntTestChecker.getDefault().getMessagesLoggedCount() == 6) && (getLoggedMessage(5).startsWith(UNKNOWN_ARG))
+ && (getLastMessageLogged().startsWith(BUILD_SUCCESSFUL)));
}
-
+
/**
* Tests specifying the -logfile with no arg
*/
public void testLogFileWithNoArg() {
try {
- run("TestForEcho.xml", new String[]{"-logfile"}); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException ce) {
+ run("TestForEcho.xml", new String[] { "-logfile" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException ce) {
return;
}
assertTrue("You must specify a log file when using the -log argument", false); //$NON-NLS-1$
}
-
+
/**
* Tests specifying the -logfile
*/
public void testLogFile() throws CoreException, IOException {
- run("TestForEcho.xml", new String[]{"-logfile", "TestLogFile.txt"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IFile file= checkFileExists("TestLogFile.txt"); //$NON-NLS-1$
- InputStream stream =file.getContents();
-
- InputStreamReader in= null;
- try {
- in= new InputStreamReader(new BufferedInputStream(stream));
- StringBuffer buffer= new StringBuffer();
- char[] readBuffer= new char[2048];
- int n= in.read(readBuffer);
+ run("TestForEcho.xml", new String[] { "-logfile", "TestLogFile.txt" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ IFile file = checkFileExists("TestLogFile.txt"); //$NON-NLS-1$
+ InputStream stream = file.getContents();
+
+ InputStreamReader in = null;
+ try {
+ in = new InputStreamReader(new BufferedInputStream(stream));
+ StringBuffer buffer = new StringBuffer();
+ char[] readBuffer = new char[2048];
+ int n = in.read(readBuffer);
while (n > 0) {
buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
+ n = in.read(readBuffer);
}
assertTrue("File should have started with Buildfile", buffer.toString().startsWith("Buildfile")); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
- if (in != null) {
- in.close();
- }
+ }
+ finally {
+ if (in != null) {
+ in.close();
+ }
stream.close();
}
-
+
}
-
+
/**
* Tests specifying the -logger with no arg
*/
public void testLoggerWithNoArg() {
try {
- run("TestForEcho.xml", new String[]{"-logger"}); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException ce) {
+ run("TestForEcho.xml", new String[] { "-logger" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException ce) {
return;
}
assertTrue("You must specify a classname when using the -logger argument", false); //$NON-NLS-1$
}
-
+
/**
* Tests the "-logger" option with a logger that is not an instance of BuildLogger
*/
public void testLoggerBad() {
try {
- run("TestForEcho.xml", new String[]{"-logger", "java.lang.String"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (CoreException ce) {
+ run("TestForEcho.xml", new String[] { "-logger", "java.lang.String" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ catch (CoreException ce) {
return;
}
assertTrue("A core exception should have occurred wrappering a class cast exception", false); //$NON-NLS-1$
}
-
+
/**
* Tests the "-logger" option with two loggers specified...only one is allowed
*/
public void testTwoLoggers() {
try {
- run("TestForEcho.xml", new String[]{"-logger", "java.lang.String", "-q", "-logger", "java.lang.String"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- } catch (CoreException ce) {
+ run("TestForEcho.xml", new String[] { "-logger", "java.lang.String", "-q", "-logger", "java.lang.String" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ }
+ catch (CoreException ce) {
return;
}
assertTrue("As only one logger can be specified", false); //$NON-NLS-1$
}
-
+
/**
* Tests specifying the -listener with no arg
*/
public void testListenerWithNoArg() {
try {
- run("TestForEcho.xml", new String[]{"-listener"}); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException ce) {
+ run("TestForEcho.xml", new String[] { "-listener" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException ce) {
return;
}
assertTrue("You must specify a listeners when using the -listener argument ", false); //$NON-NLS-1$
}
-
+
/**
* Tests specifying the -listener with a class that will not be found
*/
public void testListenerClassNotFound() {
try {
- run("TestForEcho.xml", new String[]{"-listener", "TestBuildListener"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (CoreException e) {
- String message= e.getStatus().getException().getMessage();
+ run("TestForEcho.xml", new String[] { "-listener", "TestBuildListener" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ catch (CoreException e) {
+ String message = e.getStatus().getException().getMessage();
assertTrue("Should be ClassNotFoundException", "java.lang.ClassNotFoundException: TestBuildListener".equals(message)); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
assertTrue("A CoreException should have occurred as the listener class will not be found", false); //$NON-NLS-1$
-
+
}
-
+
/**
* Tests specifying the -listener option
*/
public void testListener() throws CoreException {
- run("TestForEcho.xml", new String[]{"-listener", ANT_TEST_BUILD_LISTENER}); //$NON-NLS-1$ //$NON-NLS-2$
+ run("TestForEcho.xml", new String[] { "-listener", ANT_TEST_BUILD_LISTENER }); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
assertTrue("A listener should have been added named: " + ANT_TEST_BUILD_LISTENER, ANT_TEST_BUILD_LISTENER.equals(AntTestChecker.getDefault().getLastListener())); //$NON-NLS-1$
}
-
+
/**
* Tests specifying the XmlLogger as a listener (bug 80435)
*/
public void testXmlLoggerListener() throws CoreException {
- run("TestForEcho.xml", new String[]{"-listener", "org.apache.tools.ant.XmlLogger"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("TestForEcho.xml", new String[] { "-listener", "org.apache.tools.ant.XmlLogger" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
-
- //find the log file generated by the xml logger
- IFile file= checkFileExists("log.xml"); //$NON-NLS-1$
- InputStream stream= file.getContents();
+
+ // find the log file generated by the xml logger
+ IFile file = checkFileExists("log.xml"); //$NON-NLS-1$
+ InputStream stream = file.getContents();
try {
assertTrue(stream.available() != 0);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
assertTrue(false);
}
}
-
+
/**
* Tests specifying the -listener option multiple times...which is allowed
*/
public void testListenerMultiple() throws CoreException {
- run("TestForEcho.xml", new String[]{"-listener", ANT_TEST_BUILD_LISTENER, "-listener", ANT_TEST_BUILD_LISTENER}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("TestForEcho.xml", new String[] { "-listener", ANT_TEST_BUILD_LISTENER, "-listener", ANT_TEST_BUILD_LISTENER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
assertTrue("A listener should have been added named: " + ANT_TEST_BUILD_LISTENER, ANT_TEST_BUILD_LISTENER.equals(AntTestChecker.getDefault().getLastListener())); //$NON-NLS-1$
assertTrue("Two listeners should have been added", AntTestChecker.getDefault().getListeners().size() == 2); //$NON-NLS-1$
}
-
+
/**
* Tests specifying the -listener option multiple times, with one missing the arg
*/
public void testListenerMultipleWithBad() {
try {
- run("TestForEcho.xml", new String[]{"-listener", ANT_TEST_BUILD_LISTENER, "-q", "-listener", "-verbose"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- } catch(CoreException e) {
- //You must specify a listener for all -listener arguments
+ run("TestForEcho.xml", new String[] { "-listener", ANT_TEST_BUILD_LISTENER, "-q", "-listener", "-verbose" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+ catch (CoreException e) {
+ // You must specify a listener for all -listener arguments
return;
}
assertTrue("You must specify a listener for all -listener arguments ", false); //$NON-NLS-1$
}
-
+
/**
* Tests specifying the -buildfile with no arg
*/
public void testBuildFileWithNoArg() {
try {
- run("TestForEcho.xml", new String[]{"-buildfile"}); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException ce) {
- //You must specify a buildfile when using the -buildfile argument
+ run("TestForEcho.xml", new String[] { "-buildfile" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException ce) {
+ // You must specify a buildfile when using the -buildfile argument
return;
}
assertTrue("You must specify a buildfile when using the -buildfile argument", false); //$NON-NLS-1$
}
-
+
/**
* Tests specifying the -buildfile
*/
public void testBuildFile() throws CoreException {
- String buildFileName= getProject().getFolder("buildfiles").getFile("echoing.xml").getLocation().toFile().getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$
- run("TestForEcho.xml", new String[]{"-buildfile", buildFileName}, false, "buildfiles"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+ String buildFileName = getProject().getFolder("buildfiles").getFile("echoing.xml").getLocation().toFile().getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$
+ run("TestForEcho.xml", new String[] { "-buildfile", buildFileName }, false, "buildfiles"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
assertTrue("Should have been 1 tasks, was: " + AntTestChecker.getDefault().getTaskStartedCount(), AntTestChecker.getDefault().getTaskStartedCount() == 1); //$NON-NLS-1$
}
-
+
/**
* Tests specifying a target at the command line that does not exist.
*
- * @since 3.6 this will not fail - the default target will be run instead
- * @since 3.8 this will fail as there are no more known targets
+ * @since 3.6 this will not fail - the default target will be run instead
+ * @since 3.8 this will fail as there are no more known targets
*/
public void testSpecifyBadTargetAsArg() throws CoreException {
- run("TestForEcho.xml", new String[]{"echo2"}, false); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Should be an unknown target message", AntTestChecker.getDefault().getLoggedMessage(1).indexOf("Unknown target") >= 0); //$NON-NLS-1$//$NON-NLS-2$
+ run("TestForEcho.xml", new String[] { "echo2" }, false); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Should be an unknown target message", AntTestChecker.getDefault().getLoggedMessage(1).indexOf("Unknown target") >= 0); //$NON-NLS-1$//$NON-NLS-2$
assertTrue("Should be an unknown target message", AntTestChecker.getDefault().getLoggedMessage(1).indexOf("echo2") >= 0); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Should be a no known target message", AntTestChecker.getDefault().getLoggedMessage(0).indexOf("No known target specified.") >= 0); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Should not have run any targets", 0, AntTestChecker.getDefault().getTargetsStartedCount()); //$NON-NLS-1$
}
-
+
/**
- * Tests specifying both a non-existent target and an existent target in the command line
+ * Tests specifying both a non-existent target and an existent target in the command line
*
*/
public void testSpecifyBothBadAndGoodTargetsAsArg() throws CoreException {
- run("TestForEcho.xml", new String[]{"echo2", "Test for Echo"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("TestForEcho.xml", new String[] { "echo2", "Test for Echo" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("Should be an unknown target message", AntTestChecker.getDefault().getLoggedMessage(5).indexOf("Unknown target") >= 0); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Should be an unknown target message", AntTestChecker.getDefault().getLoggedMessage(5).indexOf("echo2") >= 0); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Should have run the Test for Echo target", 5, AntTestChecker.getDefault().getTargetsStartedCount()); //$NON-NLS-1$
}
-
+
/**
* Tests specifying a target at the command line
*/
public void testSpecifyTargetAsArg() throws CoreException {
- run("echoing.xml", new String[]{"echo3"}, false); //$NON-NLS-1$ //$NON-NLS-2$
+ run("echoing.xml", new String[] { "echo3" }, false); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("3 messages should have been logged; was " + AntTestChecker.getDefault().getMessagesLoggedCount(), AntTestChecker.getDefault().getMessagesLoggedCount() == 3); //$NON-NLS-1$
assertSuccessful();
}
-
+
/**
* Tests specifying a target at the command line with other options
*/
public void testSpecifyTargetAsArgWithOtherOptions() throws CoreException {
- run("echoing.xml", new String[]{"-logfile", "TestLogFile.txt", "echo3"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ run("echoing.xml", new String[] { "-logfile", "TestLogFile.txt", "echo3" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertTrue("4 messages should have been logged; was " + AntTestChecker.getDefault().getMessagesLoggedCount(), AntTestChecker.getDefault().getMessagesLoggedCount() == 4); //$NON-NLS-1$
- List<String> messages= AntTestChecker.getDefault().getMessages();
- //ensure that echo3 target executed and only that target
+ List<String> messages = AntTestChecker.getDefault().getMessages();
+ // ensure that echo3 target executed and only that target
assertTrue("echo3 target not executed", messages.get(2).equals("echo3")); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
}
-
+
/**
* Tests specifying targets at the command line with other options
*/
public void testSpecifyTargetsAsArgWithOtherOptions() throws CoreException {
- run("echoing.xml", new String[]{"-logfile", "TestLogFile.txt", "echo2", "echo3"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ run("echoing.xml", new String[] { "-logfile", "TestLogFile.txt", "echo2", "echo3" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
assertTrue("5 messages should have been logged; was " + AntTestChecker.getDefault().getMessagesLoggedCount(), AntTestChecker.getDefault().getMessagesLoggedCount() == 5); //$NON-NLS-1$
- List<String> messages= AntTestChecker.getDefault().getMessages();
- //ensure that echo2 target executed
+ List<String> messages = AntTestChecker.getDefault().getMessages();
+ // ensure that echo2 target executed
assertTrue("echo2 target not executed", messages.get(2).equals("echo2")); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
}
-
+
/**
* Tests specifying a target at the command line and quiet reporting
*/
public void testSpecifyTargetAsArgAndQuiet() throws CoreException {
- run("echoing.xml", new String[]{"-logfile", "TestLogFile.txt", "echo3", "-quiet"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ run("echoing.xml", new String[] { "-logfile", "TestLogFile.txt", "echo3", "-quiet" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
assertTrue("2 messages should have been logged; was " + AntTestChecker.getDefault().getMessagesLoggedCount(), AntTestChecker.getDefault().getMessagesLoggedCount() == 2); //$NON-NLS-1$
}
-
+
/**
* Tests properties using "-D"
*/
public void testMinusD() throws CoreException {
- run("echoing.xml", new String[]{"-DAntTests=testing", "-Declipse.is.cool=true"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("echoing.xml", new String[] { "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
assertTrue("eclipse.is.cool should have been set as true", "true".equals(AntTestChecker.getDefault().getUserProperty("eclipse.is.cool"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("AntTests should have a value of testing", "testing".equals(AntTestChecker.getDefault().getUserProperty("AntTests"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
-
+
}
-
+
/**
* Tests properties using "-D" and "-d" to specify debug
*/
public void testMinusDMinusd() throws CoreException {
- run("echoing.xml", new String[]{"-d", "-DAntTests=testing", "-Declipse.is.cool=true"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ run("echoing.xml", new String[] { "-d", "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertSuccessful();
assertTrue("eclipse.is.cool should have been set as true", "true".equals(AntTestChecker.getDefault().getUserProperty("eclipse.is.cool"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("AntTests should have a value of testing", "testing".equals(AntTestChecker.getDefault().getUserProperty("AntTests"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
-
+
}
-
+
public void testMinusDAndGlobalProperties() throws CoreException {
- run("echoing.xml", new String[]{"-DAntTests=testing", "-Declipse.is.cool=true"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("echoing.xml", new String[] { "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
assertTrue("eclipse.running should have been set as true", "true".equals(AntTestChecker.getDefault().getUserProperty("eclipse.running"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNotNull("eclipse.home should have been set", AntTestChecker.getDefault().getUserProperty("eclipse.home")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
- * Tests specifying a property such as "-D=emptyStringIsMyName
- * Bug 37007
+ * Tests specifying a property such as "-D=emptyStringIsMyName Bug 37007
*/
public void testMinusDEmpty() throws CoreException {
- run("echoing.xml", new String[]{"-D=emptyStringIsMyName", "-Declipse.is.cool=true"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("echoing.xml", new String[] { "-D=emptyStringIsMyName", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
assertTrue("eclipse.is.cool should have been set as true", "true".equals(AntTestChecker.getDefault().getUserProperty("eclipse.is.cool"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("\"\" should have a value of emptyStringIsMyName", "emptyStringIsMyName".equals(AntTestChecker.getDefault().getUserProperty(""))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
- * Tests specifying properties that contain spaces
- * Bug 37094
+ * Tests specifying properties that contain spaces Bug 37094
*/
public void testMinusDWithSpaces() throws CoreException {
- run("echoing.xml", new String[]{"-DAntTests= testing", "-Declipse.is.cool= true"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ run("echoing.xml", new String[] { "-DAntTests= testing", "-Declipse.is.cool= true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
assertTrue("eclipse.is.cool should have been set as true", "true".equals(AntTestChecker.getDefault().getUserProperty("eclipse.is.cool"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("AntTests should have a value of testing", "testing".equals(AntTestChecker.getDefault().getUserProperty("AntTests"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
- * Tests specifying properties when the user has incorrectly specified "-Debug"
- * Bug 40935
+ * Tests specifying properties when the user has incorrectly specified "-Debug" Bug 40935
*/
public void testPropertiesWithMinusDebug() throws CoreException {
- run("echoing.xml", new String[]{"-Debug", "-DAntTests= testing", "-Declipse.is.cool= true"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ run("echoing.xml", new String[] { "-Debug", "-DAntTests= testing", "-Declipse.is.cool= true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertTrue("\"-Debug\" should be flagged as an unknown argument", "Unknown argument: -Debug".equals(AntTestChecker.getDefault().getMessages().get(0))); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
assertTrue("eclipse.is.cool should have been set as true", "true".equals(AntTestChecker.getDefault().getUserProperty("eclipse.is.cool"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("AntTests should have a value of testing", "testing".equals(AntTestChecker.getDefault().getUserProperty("AntTests"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
- * Tests when the user has incorrectly specified "-Debug"
- * Bug 40935
+ * Tests when the user has incorrectly specified "-Debug" Bug 40935
*/
public void testMinusDebug() throws CoreException {
- run("echoing.xml", new String[]{"-Debug"}); //$NON-NLS-1$ //$NON-NLS-2$
+ run("echoing.xml", new String[] { "-Debug" }); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("\"-Debug\" should be flagged as an unknown argument", "Unknown argument: -Debug".equals(AntTestChecker.getDefault().getMessages().get(0))); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
}
-
+
public void testPropertyFileWithNoArg() {
try {
- run("TestForEcho.xml", new String[]{"-propertyfile"}); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException ce) {
- String msg= AntTestChecker.getDefault().getMessages().get(0);
+ run("TestForEcho.xml", new String[] { "-propertyfile" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException ce) {
+ String msg = AntTestChecker.getDefault().getMessages().get(0);
assertTrue("Message incorrect!: " + msg, msg.equals("You must specify a property filename when using the -propertyfile argument")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
assertTrue("You must specify a property filename when using the -propertyfile argument", false); //$NON-NLS-1$
}
-
+
/**
- * A build should succeed when a property file is not found.
- * The error is reported and the build continues.
+ * A build should succeed when a property file is not found. The error is reported and the build continues.
*/
public void testPropertyFileFileNotFound() throws CoreException {
-
- run("TestForEcho.xml", new String[]{"-propertyfile", "qq.txt"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ run("TestForEcho.xml", new String[] { "-propertyfile", "qq.txt" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
- String msg= AntTestChecker.getDefault().getMessages().get(0);
+ String msg = AntTestChecker.getDefault().getMessages().get(0);
assertTrue("Message incorrect!: " + msg, msg.startsWith("Could not load property file:")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
public void testPropertyFile() throws CoreException {
- run("TestForEcho.xml", new String[]{"-propertyfile", getPropertyFileName()}); //$NON-NLS-1$ //$NON-NLS-2$
+ run("TestForEcho.xml", new String[] { "-propertyfile", getPropertyFileName() }); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
assertTrue("eclipse.is.cool should have been set as Yep", "Yep".equals(AntTestChecker.getDefault().getUserProperty("eclipse.is.cool"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("AntTests should have a value of testing", "testing from properties file".equals(AntTestChecker.getDefault().getUserProperty("AntTests"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
public void testPropertyFileWithMinusDTakingPrecedence() throws CoreException {
- run("echoing.xml", new String[]{"-propertyfile", getPropertyFileName(), "-DAntTests=testing", "-Declipse.is.cool=true"}, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ run("echoing.xml", new String[] { "-propertyfile", getPropertyFileName(), "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertSuccessful();
assertTrue("eclipse.is.cool should have been set as true", "true".equals(AntTestChecker.getDefault().getUserProperty("eclipse.is.cool"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("AntTests should have a value of testing", "testing".equals(AntTestChecker.getDefault().getUserProperty("AntTests"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
public void testInputHandlerWithNoArg() {
try {
- run("TestForEcho.xml", new String[]{"-inputhandler"}); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException ce) {
- String msg= ce.getMessage();
+ run("TestForEcho.xml", new String[] { "-inputhandler" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException ce) {
+ String msg = ce.getMessage();
assertTrue("Message incorrect!: " + msg, msg.equals("You must specify a classname when using the -inputhandler argument")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
assertTrue("You must specify a classname when using the -inputhandler argument", false); //$NON-NLS-1$
}
-
+
/**
* Tests the "-inputhandler" option with two handlers specified...only one is allowed
*/
public void testInputHandlerMultiple() {
try {
- run("TestForEcho.xml", new String[]{"-inputhandler", "org.apache.tools.ant.input.DefaultInputHandler", "-q", "-inputhandler", "org.apache.tools.ant.input.DefaultInputHandler"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- } catch (CoreException ce) {
- String msg= ce.getMessage();
+ run("TestForEcho.xml", new String[] { "-inputhandler", "org.apache.tools.ant.input.DefaultInputHandler", "-q", "-inputhandler", "org.apache.tools.ant.input.DefaultInputHandler" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ }
+ catch (CoreException ce) {
+ String msg = ce.getMessage();
assertTrue("Message incorrect!: " + msg, msg.equals("Only one input handler class may be specified.")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
assertTrue("As only one input handler can be specified", false); //$NON-NLS-1$
}
-
+
/**
* Tests the "-inputhandler" option with a input handler that is not an instance of InputHandler
*/
public void testInputHandlerBad() {
try {
- run("TestForEcho.xml", new String[]{"-inputhandler", "java.lang.StringBuffer"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (CoreException ce) {
- String msg= ce.getMessage();
+ run("TestForEcho.xml", new String[] { "-inputhandler", "java.lang.StringBuffer" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ catch (CoreException ce) {
+ String msg = ce.getMessage();
assertTrue("Message incorrect!: " + msg, msg.equals("The specified input handler class java.lang.StringBuffer does not implement the org.apache.tools.ant.input.InputHandler interface")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
assertTrue("Incorrect inputhandler", false); //$NON-NLS-1$
}
-
+
/**
* Tests the "-inputhandler" option with a input handler that is not a defined class
*/
public void testInputHandlerBad2() {
try {
- run("TestForEcho.xml", new String[]{"-inputhandler", "ja.lang.StringBuffer"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (CoreException ce) {
- String msg= ce.getMessage();
+ run("TestForEcho.xml", new String[] { "-inputhandler", "ja.lang.StringBuffer" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ catch (CoreException ce) {
+ String msg = ce.getMessage();
assertTrue("Message incorrect!: " + msg, msg.startsWith("Unable to instantiate specified input handler class ja.lang.StringBuffer")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
assertTrue("Incorrect inputhandler", false); //$NON-NLS-1$
}
-
+
/**
* Tests the "-inputhandler" option with a test input handler and the -noinput option
*/
public void testInputHandlerWithMinusNoInput() {
try {
- run("input.xml", new String[]{"-inputhandler", "org.eclipse.ant.tests.core.support.inputHandlers.AntTestInputHandler", "-noinput"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- } catch (CoreException ce) {
+ run("input.xml", new String[] { "-inputhandler", "org.eclipse.ant.tests.core.support.inputHandlers.AntTestInputHandler", "-noinput" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ catch (CoreException ce) {
assertTrue("Message incorrect: " + ce.getMessage(), ce.getMessage().endsWith("Unable to respond to input request likely as a result of specifying the -noinput command")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
-
+
assertTrue("Build should have failed", false); //$NON-NLS-1$
}
-
+
/**
* Tests the -noinput option with the default input handler
*/
public void testMinusNoInput() {
try {
- run("input.xml", new String[]{"-noinput"}); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException ce) {
+ run("input.xml", new String[] { "-noinput" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException ce) {
assertTrue("Message incorrect: " + ce.getMessage(), ce.getMessage().endsWith("Failed to read input from Console.")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
-
+
assertTrue("Build should have failed", false); //$NON-NLS-1$
}
-
+
/**
- * Tests the "-inputhandler" option with a test input handler
- * Order after the noinput tests so that we test we are resetting the system property
+ * Tests the "-inputhandler" option with a test input handler Order after the noinput tests so that we test we are resetting the system property
*/
public void testInputHandler() throws CoreException {
-
- run("input.xml", new String[]{"-inputhandler", "org.eclipse.ant.tests.core.support.inputHandlers.AntTestInputHandler"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ run("input.xml", new String[] { "-inputhandler", "org.eclipse.ant.tests.core.support.inputHandlers.AntTestInputHandler" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
- String msg= AntTestChecker.getDefault().getMessages().get(1);
+ String msg = AntTestChecker.getDefault().getMessages().get(1);
assertTrue("Message incorrect: " + msg, msg.equals("testing handling input requests")); //$NON-NLS-1$ //$NON-NLS-2$
-
+
}
-
+
/**
- * Tests the "-diagnostics" option with no ANT_HOME set
- * bug 25693
+ * Tests the "-diagnostics" option with no ANT_HOME set bug 25693
*/
public void testDiagnosticsWithNoAntHome() throws CoreException {
try {
AntCorePlugin.getPlugin().getPreferences().setAntHome(null);
- run("input.xml", new String[]{"-diagnostics"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- String msg= AntTestChecker.getDefault().getMessages().get(0);
+ run("input.xml", new String[] { "-diagnostics" }); //$NON-NLS-1$ //$NON-NLS-2$
+
+ String msg = AntTestChecker.getDefault().getMessages().get(0);
assertTrue("Message incorrect: " + msg, msg.equals("------- Ant diagnostics report -------")); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
+ }
+ finally {
restorePreferenceDefaults();
}
}
-
+
/**
- * Tests the "-diagnostics" option with ANT_HOME set
- * bug 25693
+ * Tests the "-diagnostics" option with ANT_HOME set bug 25693
*/
public void testDiagnostics() throws CoreException {
-
+
try {
- run("input.xml", new String[]{"-diagnostics"}); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
+ run("input.xml", new String[] { "-diagnostics" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ finally {
restorePreferenceDefaults();
}
- //we are looking for the ant.home entry
+ // we are looking for the ant.home entry
List<String> messages = AntTestChecker.getDefault().getMessages();
String msg = messages.get(17);
- //msg depends on whether self hosting testing or build testing
+ // msg depends on whether self hosting testing or build testing
assertTrue("Message incorrect: " + msg, checkAntHomeMessage(msg)); //$NON-NLS-1$
}
-
+
private boolean checkAntHomeMessage(String message) {
String msg = message;
if (msg.endsWith("org.apache.ant")) { //$NON-NLS-1$
return true;
}
-
+
if (msg.endsWith(PLUGIN_VERSION)) {
return true;
}
-
- //org.apache.ant_1.7.1.v200704241635
+
+ // org.apache.ant_1.7.1.v200704241635
int index = msg.lastIndexOf('.');
if (index > 0) {
msg = msg.substring(0, index);
}
return msg.endsWith(PLUGIN_VERSION);
}
-
+
/**
- * Tests the "-quiet" still reports build successful
- * bug 34488
+ * Tests the "-quiet" still reports build successful bug 34488
*/
public void testMinusQuiet() throws CoreException {
- run("TestForEcho.xml", new String[]{"-quiet"}); //$NON-NLS-1$ //$NON-NLS-2$
- assertSuccessful();
+ run("TestForEcho.xml", new String[] { "-quiet" }); //$NON-NLS-1$ //$NON-NLS-2$
+ assertSuccessful();
}
/**
@@ -630,28 +639,30 @@
*/
public void testMinusKeepGoing() {
try {
- run("failingTarget.xml", new String[]{"-keep-going"}, false); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException be) {
+ run("failingTarget.xml", new String[] { "-keep-going" }, false); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException be) {
assertTrue("4 messages should have been logged; was " + AntTestChecker.getDefault().getMessagesLoggedCount(), AntTestChecker.getDefault().getMessagesLoggedCount() == 4); //$NON-NLS-1$
- assertTrue("Incorrect message:" + AntTestChecker.getDefault().getLoggedMessage(1), "Still echo on failure".equals(AntTestChecker.getDefault().getLoggedMessage(1))); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Incorrect message:" + AntTestChecker.getDefault().getLoggedMessage(1), "Still echo on failure".equals(AntTestChecker.getDefault().getLoggedMessage(1))); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
-
+
assertTrue("The build should have failed", false); //$NON-NLS-1$
}
-
+
/**
* Tests the "-k" option
*/
public void testMinusK() {
try {
- run("failingTarget.xml", new String[]{"-k"}, false); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException be) {
+ run("failingTarget.xml", new String[] { "-k" }, false); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (CoreException be) {
assertTrue("4 messages should have been logged; was " + AntTestChecker.getDefault().getMessagesLoggedCount(), AntTestChecker.getDefault().getMessagesLoggedCount() == 4); //$NON-NLS-1$
- assertTrue("Incorrect message:" + AntTestChecker.getDefault().getLoggedMessage(1), "Still echo on failure".equals(AntTestChecker.getDefault().getLoggedMessage(1))); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Incorrect message:" + AntTestChecker.getDefault().getLoggedMessage(1), "Still echo on failure".equals(AntTestChecker.getDefault().getLoggedMessage(1))); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
-
+
assertTrue("The build should have failed", false); //$NON-NLS-1$
}
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java
index 648eb8c..8141370 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,10 +23,10 @@
import org.eclipse.debug.core.model.IVariable;
public class PropertyTests extends AbstractAntDebugTest {
-
- private static final String ANT_VERSION = "Apache Ant(TM) version 1.8.4 compiled on May 22 2012"; //$NON-NLS-1$
- public PropertyTests(String name) {
+ private static final String ANT_VERSION = "Apache Ant(TM) version 1.9.2 compiled on July 8 2013"; //$NON-NLS-1$
+
+ public PropertyTests(String name) {
super(name);
}
@@ -41,112 +41,115 @@
private void systemProperties(boolean sepVM) throws Exception, CoreException {
String fileName = "breakpoints"; //$NON-NLS-1$
ILineBreakpoint bp = createLineBreakpoint(30, "breakpoints" + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
- AntThread thread= null;
+ AntThread thread = null;
try {
if (sepVM) {
- fileName+= "SepVM"; //$NON-NLS-1$
+ fileName += "SepVM"; //$NON-NLS-1$
}
- ILaunchConfiguration config= getLaunchConfiguration(fileName);
- ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
+ ILaunchConfiguration config = getLaunchConfiguration(fileName);
+ ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "properties"); //$NON-NLS-1$
- thread= launchToLineBreakpoint(copy, bp);
+ thread = launchToLineBreakpoint(copy, bp);
- AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
+ AntStackFrame frame = (AntStackFrame) thread.getTopStackFrame();
IVariable[] vars = frame.getVariables();
assertTrue("Should be a bunch of properties", 0 < vars.length); //$NON-NLS-1$
- AntProperty property= frame.findProperty("ant.library.dir"); //$NON-NLS-1$
+ AntProperty property = frame.findProperty("ant.library.dir"); //$NON-NLS-1$
assertNotNull(property);
-
+
assertProperty(thread, "ant.project.name", "debugEcho"); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
+ }
+ finally {
terminateAndRemove(thread);
removeAllBreakpoints();
}
}
-
+
public void testUserProperties() throws Exception {
- userProperties(false);
+ userProperties(false);
}
-
+
public void testUserPropertiesSepVM() throws Exception {
userProperties(true);
}
- private void userProperties(boolean sepVM) throws Exception{
+ private void userProperties(boolean sepVM) throws Exception {
String fileName = "breakpoints"; //$NON-NLS-1$
ILineBreakpoint bp = createLineBreakpoint(30, "breakpoints" + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
- AntThread thread= null;
+ AntThread thread = null;
try {
if (sepVM) {
- fileName+= "SepVM"; //$NON-NLS-1$
+ fileName += "SepVM"; //$NON-NLS-1$
}
- ILaunchConfiguration config= getLaunchConfiguration(fileName);
- ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
+ ILaunchConfiguration config = getLaunchConfiguration(fileName);
+ ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "properties"); //$NON-NLS-1$
- thread= launchToLineBreakpoint(copy, bp);
+ thread = launchToLineBreakpoint(copy, bp);
- AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
+ AntStackFrame frame = (AntStackFrame) thread.getTopStackFrame();
IVariable[] vars = frame.getVariables();
assertTrue("Should be a bunch of properties", 0 < vars.length); //$NON-NLS-1$
- AntProperty property= frame.findProperty("ant.home"); //$NON-NLS-1$
+ AntProperty property = frame.findProperty("ant.home"); //$NON-NLS-1$
assertNotNull(property);
-
+
assertProperty(thread, "ant.version", ANT_VERSION); //$NON-NLS-1$
assertProperty(thread, "ant.project.name", "debugEcho"); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
+ }
+ finally {
terminateAndRemove(thread);
removeAllBreakpoints();
}
}
-
+
public void testRuntimeProperties() throws Exception {
- runtimeProperties(false);
+ runtimeProperties(false);
}
- //TODO timing issues with retrieving properties
-// public void testRuntimePropertiesSepVM() throws Exception {
-// runtimeProperties(true);
-// }
+ // TODO timing issues with retrieving properties
+ // public void testRuntimePropertiesSepVM() throws Exception {
+ // runtimeProperties(true);
+ // }
private void runtimeProperties(boolean sepVM) throws Exception, CoreException {
String fileName = "breakpoints"; //$NON-NLS-1$
ILineBreakpoint bp = createLineBreakpoint(30, fileName + ".xml"); //$NON-NLS-1$
- AntThread thread= null;
+ AntThread thread = null;
try {
if (sepVM) {
- fileName+="SepVM"; //$NON-NLS-1$
+ fileName += "SepVM"; //$NON-NLS-1$
}
- ILaunchConfiguration config= getLaunchConfiguration(fileName);
- ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
+ ILaunchConfiguration config = getLaunchConfiguration(fileName);
+ ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "properties"); //$NON-NLS-1$
- thread= launchToLineBreakpoint(copy, bp);
+ thread = launchToLineBreakpoint(copy, bp);
- AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
+ AntStackFrame frame = (AntStackFrame) thread.getTopStackFrame();
IVariable[] vars = frame.getVariables();
assertTrue("Should be a bunch of properties", 0 < vars.length); //$NON-NLS-1$
- AntProperty property= frame.findProperty("ant.home"); //$NON-NLS-1$
+ AntProperty property = frame.findProperty("ant.home"); //$NON-NLS-1$
assertNotNull(property);
-
+
stepOver(frame);
frame = assertProperty(thread, "AAA", "aaa"); //$NON-NLS-1$ //$NON-NLS-2$
-
+
stepOver(frame);
frame = assertProperty(thread, "BBB", "bbb"); //$NON-NLS-1$ //$NON-NLS-2$
-
+
stepOver(frame);
assertProperty(thread, "CCC", "ccc"); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
+ }
+ finally {
terminateAndRemove(thread);
removeAllBreakpoints();
}
}
private AntStackFrame assertProperty(AntThread thread, String propertyName, String propertyValue) throws DebugException {
- AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
- AntProperty property= frame.findProperty(propertyName);
+ AntStackFrame frame = (AntStackFrame) thread.getTopStackFrame();
+ AntProperty property = frame.findProperty(propertyName);
assertNotNull("Did not find property: " + propertyName, property); //$NON-NLS-1$
- AntValue value= (AntValue) property.getValue();
- assertEquals("Value of property "+propertyName+ " incorrect", propertyValue, value.getValueString()); //$NON-NLS-1$ //$NON-NLS-2$
+ AntValue value = (AntValue) property.getValue();
+ assertEquals("Value of property " + propertyName + " incorrect", propertyValue, value.getValueString()); //$NON-NLS-1$ //$NON-NLS-2$
return frame;
}
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java
index 223ed07..cf3c216 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2011 GEBIT Gesellschaft fuer EDV-Beratung
+ * Copyright (c) 2002, 2013 GEBIT Gesellschaft fuer EDV-Beratung
* und Informatik-Technologien mbH,
* Berlin, Duesseldorf, Frankfurt (Germany) and others.
* All rights reserved. This program and the accompanying materials
@@ -51,427 +51,429 @@
*/
public class CodeCompletionTest extends AbstractAntUITest {
- /**
- * Constructor for CodeCompletionTest.
- * @param name
- */
- public CodeCompletionTest(String name) {
- super(name);
- }
-
+ /**
+ * Constructor for CodeCompletionTest.
+ *
+ * @param name
+ */
+ public CodeCompletionTest(String name) {
+ super(name);
+ }
+
public static Test suite() {
return new TestSuite(CodeCompletionTest.class);
}
- /**
- * Tests the code completion for attributes of tasks.
- */
- public void testAttributeProposals() {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+ /**
+ * Tests the code completion for attributes of tasks.
+ */
+ public void testAttributeProposals() {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
- ICompletionProposal[] proposals = processor.getAttributeProposals("contains", "ca"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(1, proposals.length);
- assertEquals("casesensitive - (true | false | on | off | yes | no)", proposals[0].getDisplayString()); //$NON-NLS-1$
+ ICompletionProposal[] proposals = processor.getAttributeProposals("contains", "ca"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(1, proposals.length);
+ assertEquals("casesensitive - (true | false | on | off | yes | no)", proposals[0].getDisplayString()); //$NON-NLS-1$
- proposals = processor.getAttributeProposals("move", ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(17, proposals.length);
- ICompletionProposal proposal = proposals[0];
- String displayString = proposal.getDisplayString();
- assertTrue(displayString.equals("id") //$NON-NLS-1$
- || displayString.equals("taskname") //$NON-NLS-1$
- || displayString.equals(IAntCoreConstants.DESCRIPTION)
- || displayString.equals(IAntCoreConstants.FILE)
- || displayString.equals("preservelastmodified - (true | false | on | off | yes | no)") //$NON-NLS-1$
- || displayString.equals("tofile") //$NON-NLS-1$
- || displayString.equals("todir") //$NON-NLS-1$
- || displayString.equals("overwrite - (true | false | on | off | yes | no)") //$NON-NLS-1$
- || displayString.equals("filtering - (true | false | on | off | yes | no)") //$NON-NLS-1$
- || displayString.equals("flatten - (true | false | on | off | yes | no)") //$NON-NLS-1$
- || displayString.equals("includeemptydirs") //$NON-NLS-1$
- || displayString.equals("failonerror - (true | false | on | off | yes | no)") //$NON-NLS-1$
- || displayString.equals("verbose - (true | false | on | off | yes | no)") //$NON-NLS-1$
- || displayString.equals("encoding") //$NON-NLS-1$
- || displayString.equals("outputencoding") //$NON-NLS-1$
- || displayString.equals("enablemultiplemapping - (true | false | on | off | yes | no)") //$NON-NLS-1$
- || displayString.equals("granularity")); //$NON-NLS-1$
-
- proposals = processor.getAttributeProposals("move", "to"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(2, proposals.length);
+ proposals = processor.getAttributeProposals("move", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(17, proposals.length);
+ ICompletionProposal proposal = proposals[0];
+ String displayString = proposal.getDisplayString();
+ assertTrue(displayString.equals("id") //$NON-NLS-1$
+ || displayString.equals("taskname") //$NON-NLS-1$
+ || displayString.equals(IAntCoreConstants.DESCRIPTION)
+ || displayString.equals(IAntCoreConstants.FILE)
+ || displayString.equals("preservelastmodified - (true | false | on | off | yes | no)") //$NON-NLS-1$
+ || displayString.equals("tofile") //$NON-NLS-1$
+ || displayString.equals("todir") //$NON-NLS-1$
+ || displayString.equals("overwrite - (true | false | on | off | yes | no)") //$NON-NLS-1$
+ || displayString.equals("filtering - (true | false | on | off | yes | no)") //$NON-NLS-1$
+ || displayString.equals("flatten - (true | false | on | off | yes | no)") //$NON-NLS-1$
+ || displayString.equals("includeemptydirs") //$NON-NLS-1$
+ || displayString.equals("failonerror - (true | false | on | off | yes | no)") //$NON-NLS-1$
+ || displayString.equals("verbose - (true | false | on | off | yes | no)") //$NON-NLS-1$
+ || displayString.equals("encoding") //$NON-NLS-1$
+ || displayString.equals("outputencoding") //$NON-NLS-1$
+ || displayString.equals("enablemultiplemapping - (true | false | on | off | yes | no)") //$NON-NLS-1$
+ || displayString.equals("granularity")); //$NON-NLS-1$
- proposals = processor.getAttributeProposals("reference", "idl"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(0, proposals.length);
+ proposals = processor.getAttributeProposals("move", "to"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(2, proposals.length);
- proposals = processor.getAttributeProposals("reference", "id"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(1, proposals.length);
- assertEquals("id", proposals[0].getDisplayString()); //$NON-NLS-1$
+ proposals = processor.getAttributeProposals("reference", "idl"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(0, proposals.length);
- proposals = processor.getAttributeProposals("reference", "i"); //$NON-NLS-1$ //$NON-NLS-2$
- //id includesfile includes
- assertEquals(3, proposals.length);
- displayString= proposals[0].getDisplayString();
- assertTrue(displayString.equals("id") //$NON-NLS-1$
- || displayString.equals("includesfile") //$NON-NLS-1$
+ proposals = processor.getAttributeProposals("reference", "id"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(1, proposals.length);
+ assertEquals("id", proposals[0].getDisplayString()); //$NON-NLS-1$
+
+ proposals = processor.getAttributeProposals("reference", "i"); //$NON-NLS-1$ //$NON-NLS-2$
+ // id includesfile includes
+ assertEquals(3, proposals.length);
+ displayString = proposals[0].getDisplayString();
+ assertTrue(displayString.equals("id") //$NON-NLS-1$
+ || displayString.equals("includesfile") //$NON-NLS-1$
|| displayString.equals("includes")); //$NON-NLS-1$
- proposals = processor.getAttributeProposals("project", "de"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(1, proposals.length);
- }
-
- /**
- * Test the code completion for properties, including unquoted (bug 40871)
- */
- public void testPropertyProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
+ proposals = processor.getAttributeProposals("project", "de"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(1, proposals.length);
+ }
- int lineNumber= 7;
- int columnNumber= 16;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
- assertTrue(proposals.length >= 1);
- assertContains("prop1", proposals); //$NON-NLS-1$
-
- lineNumber= 18;
- columnNumber= 25;
- lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
- assertTrue(proposals.length >= 1);
- assertContains("prop2", proposals); //$NON-NLS-1$
- }
-
- /**
- * Tests the code completion for nested elements that no templates are presented
- * Bug 76414
- */
+ /**
+ * Test the code completion for properties, including unquoted (bug 40871)
+ */
+ public void testPropertyProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
+
+ int lineNumber = 7;
+ int columnNumber = 16;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
+ assertTrue(proposals.length >= 1);
+ assertContains("prop1", proposals); //$NON-NLS-1$
+
+ lineNumber = 18;
+ columnNumber = 25;
+ lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
+ assertTrue(proposals.length >= 1);
+ assertContains("prop2", proposals); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests the code completion for nested elements that no templates are presented Bug 76414
+ */
public void testPropertyTemplateProposals() throws BadLocationException, PartInitException {
try {
- IFile file= getIFile("buildtest1.xml"); //$NON-NLS-1$
- AntEditor editor= (AntEditor)EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
- TestTextCompletionProcessor processor= new TestTextCompletionProcessor(editor);
- int lineNumber= 7;
- int columnNumber= 16;
- int lineOffset= editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
-
- ICompletionProposal[] proposals= processor.determineTemplateProposals();
- assertTrue("No templates are relevant at the current position. Found: " + proposals.length, proposals.length == 0); //$NON-NLS-1$
- } finally {
+ IFile file = getIFile("buildtest1.xml"); //$NON-NLS-1$
+ AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(editor);
+ int lineNumber = 7;
+ int columnNumber = 16;
+ int lineOffset = editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+
+ ICompletionProposal[] proposals = processor.determineTemplateProposals();
+ assertTrue("No templates are relevant at the current position. Found: " + proposals.length, proposals.length == 0); //$NON-NLS-1$
+ }
+ finally {
EditorTestHelper.closeAllEditors();
}
}
-
- /**
- * Test the code completion for "system" properties
- */
- public void testSystemPropertyProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
-
- int lineNumber= 18;
- int columnNumber= 25;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
- assertTrue(proposals.length >= 1);
- assertContains("java.home", proposals); //$NON-NLS-1$
- }
-
- /**
- * Test the code completion for "built-in" properties
- */
- public void testBuiltInPropertyProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
-
- int lineNumber= 18;
- int columnNumber= 25;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
- assertTrue(proposals.length >= 1);
- assertContains("ant.file", proposals); //$NON-NLS-1$
- assertContains("ant.version", proposals); //$NON-NLS-1$
- assertContains("ant.project.name", proposals); //$NON-NLS-1$
- assertContains("basedir", proposals); //$NON-NLS-1$
- assertContains("ant.home", proposals); //$NON-NLS-1$
- assertContains("ant.library.dir", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Test the code completion for extension point / preference properties
- */
- public void testPreferencePropertyProposals() throws BadLocationException {
- AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
- try {
-
- prefs.setCustomProperties(new Property[] {new Property("test", "result")}); //$NON-NLS-1$ //$NON-NLS-2$
- prefs.updatePluginPreferences();
-
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
-
- int lineNumber= 18;
- int columnNumber= 25;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
- assertTrue(proposals.length >= 3);
- assertContains("eclipse.home", proposals); //contributed //$NON-NLS-1$
- assertContains("property.ui.testing2", proposals); //contributed //$NON-NLS-1$
- assertContains("test", proposals); //$NON-NLS-1$
- } finally {
- prefs.setCustomProperties(new Property[]{});
- prefs.updatePluginPreferences();
- }
- }
-
- /**
- * Test the code completion for the depend attribute of a target.
- */
- public void testTargetDependProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
- //simple depends
- int lineNumber= 10;
- int columnNumber= 34;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset + columnNumber), "", "depends"); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(proposals.length == 7);
- assertContains("pretest", proposals); //$NON-NLS-1$
- assertContains("testMoreDepends", proposals); //$NON-NLS-1$
- //comma separated depends
- lineNumber= 17;
- columnNumber= 53;
- lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset + columnNumber), "", "depends"); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(proposals.length == 7);
- assertContains("main", proposals); //$NON-NLS-1$
- //XXX why do we not want a valid proposal?
- /*assertDoesNotContain("pretest", proposals);*/
- }
-
- /**
- * Test the image for a code completion proposal for the depend attribute of a target.
- */
- public void testTargetDependProposalImages() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest3.xml")); //$NON-NLS-1$
- //simple depends
- int lineNumber= 5;
- int columnNumber= 34;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertEquals(3, proposals.length);
- assertContains("main", proposals); //$NON-NLS-1$
- assertContains("pretest", proposals); //$NON-NLS-1$
- assertContains("test2", proposals); //$NON-NLS-1$
-
- for (int i = 0; i < proposals.length; i++) {
- String displayString = proposals[i].getDisplayString();
+
+ /**
+ * Test the code completion for "system" properties
+ */
+ public void testSystemPropertyProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
+
+ int lineNumber = 18;
+ int columnNumber = 25;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
+ assertTrue(proposals.length >= 1);
+ assertContains("java.home", proposals); //$NON-NLS-1$
+ }
+
+ /**
+ * Test the code completion for "built-in" properties
+ */
+ public void testBuiltInPropertyProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
+
+ int lineNumber = 18;
+ int columnNumber = 25;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
+ assertTrue(proposals.length >= 1);
+ assertContains("ant.file", proposals); //$NON-NLS-1$
+ assertContains("ant.version", proposals); //$NON-NLS-1$
+ assertContains("ant.project.name", proposals); //$NON-NLS-1$
+ assertContains("basedir", proposals); //$NON-NLS-1$
+ assertContains("ant.home", proposals); //$NON-NLS-1$
+ assertContains("ant.library.dir", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Test the code completion for extension point / preference properties
+ */
+ public void testPreferencePropertyProposals() throws BadLocationException {
+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
+ try {
+
+ prefs.setCustomProperties(new Property[] { new Property("test", "result") }); //$NON-NLS-1$ //$NON-NLS-2$
+ prefs.updatePluginPreferences();
+
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
+
+ int lineNumber = 18;
+ int columnNumber = 25;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getPropertyProposals(getCurrentDocument(), "", lineOffset + columnNumber); //$NON-NLS-1$
+ assertTrue(proposals.length >= 3);
+ assertContains("eclipse.home", proposals); //contributed //$NON-NLS-1$
+ assertContains("property.ui.testing2", proposals); //contributed //$NON-NLS-1$
+ assertContains("test", proposals); //$NON-NLS-1$
+ }
+ finally {
+ prefs.setCustomProperties(new Property[] {});
+ prefs.updatePluginPreferences();
+ }
+ }
+
+ /**
+ * Test the code completion for the depend attribute of a target.
+ */
+ public void testTargetDependProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
+ // simple depends
+ int lineNumber = 10;
+ int columnNumber = 34;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset
+ + columnNumber), "", "depends"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(proposals.length == 7);
+ assertContains("pretest", proposals); //$NON-NLS-1$
+ assertContains("testMoreDepends", proposals); //$NON-NLS-1$
+ // comma separated depends
+ lineNumber = 17;
+ columnNumber = 53;
+ lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset + columnNumber), "", "depends"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(proposals.length == 7);
+ assertContains("main", proposals); //$NON-NLS-1$
+ // XXX why do we not want a valid proposal?
+ /* assertDoesNotContain("pretest", proposals); */
+ }
+
+ /**
+ * Test the image for a code completion proposal for the depend attribute of a target.
+ */
+ public void testTargetDependProposalImages() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest3.xml")); //$NON-NLS-1$
+ // simple depends
+ int lineNumber = 5;
+ int columnNumber = 34;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertEquals(3, proposals.length);
+ assertContains("main", proposals); //$NON-NLS-1$
+ assertContains("pretest", proposals); //$NON-NLS-1$
+ assertContains("test2", proposals); //$NON-NLS-1$
+
+ for (int i = 0; i < proposals.length; i++) {
+ String displayString = proposals[i].getDisplayString();
if (displayString.equals("main")) { //$NON-NLS-1$
assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposals[i].getImage());
} else if (displayString.equals("pretest")) { //$NON-NLS-1$
assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposals[i].getImage());
} else if (displayString.equals("test2")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposals[i].getImage());
} else {
fail("Unknown completion proposal detected: " + displayString); //$NON-NLS-1$
}
}
- }
-
- /**
- * Test the image for a code completion proposal for the default attribute of a project.
- */
- public void testProjectDefaultProposalImages() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest4.xml")); //$NON-NLS-1$
- //simple depends
- int lineNumber= 1;
- int columnNumber= 18;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertEquals(3, proposals.length);
- assertContains("task", proposals); //$NON-NLS-1$
- assertContains("task2", proposals); //$NON-NLS-1$
- assertContains("task3", proposals); //$NON-NLS-1$
-
- for (int i = 0; i < proposals.length; i++) {
- String displayString = proposals[i].getDisplayString();
+ }
+
+ /**
+ * Test the image for a code completion proposal for the default attribute of a project.
+ */
+ public void testProjectDefaultProposalImages() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest4.xml")); //$NON-NLS-1$
+ // simple depends
+ int lineNumber = 1;
+ int columnNumber = 18;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertEquals(3, proposals.length);
+ assertContains("task", proposals); //$NON-NLS-1$
+ assertContains("task2", proposals); //$NON-NLS-1$
+ assertContains("task3", proposals); //$NON-NLS-1$
+
+ for (int i = 0; i < proposals.length; i++) {
+ String displayString = proposals[i].getDisplayString();
if (displayString.equals("task3")) { //$NON-NLS-1$
assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposals[i].getImage());
} else if (displayString.equals("task")) { //$NON-NLS-1$
assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposals[i].getImage());
} else if (displayString.equals("task2")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposals[i].getImage());
} else {
fail("Unknown completion proposal detected: " + displayString); //$NON-NLS-1$
}
}
- }
-
- /**
- * Test the image for a code completion proposal for the target attribute of an antcall task.
- */
- public void testAntcallTargetProposalImages() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest4.xml")); //$NON-NLS-1$
- int lineNumber= 4;
- int columnNumber= 25;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertEquals(2, proposals.length);
- assertContains("task", proposals); //$NON-NLS-1$
- assertContains("task3", proposals); //$NON-NLS-1$
-
- for (int i = 0; i < proposals.length; i++) {
- String displayString = proposals[i].getDisplayString();
+ }
+
+ /**
+ * Test the image for a code completion proposal for the target attribute of an antcall task.
+ */
+ public void testAntcallTargetProposalImages() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest4.xml")); //$NON-NLS-1$
+ int lineNumber = 4;
+ int columnNumber = 25;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertEquals(2, proposals.length);
+ assertContains("task", proposals); //$NON-NLS-1$
+ assertContains("task3", proposals); //$NON-NLS-1$
+
+ for (int i = 0; i < proposals.length; i++) {
+ String displayString = proposals[i].getDisplayString();
if (displayString.equals("task3")) { //$NON-NLS-1$
assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposals[i].getImage());
} else if (displayString.equals("task")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposals[i].getImage());
} else {
fail("Unknown completion proposal detected: " + displayString); //$NON-NLS-1$
}
}
- }
-
- /**
- * Test the code completion for the if attribute of a target.
- */
- public void testTargetIfProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
-
- int lineNumber= 15;
- int columnNumber= 31;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset + columnNumber), "", "if"); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(proposals.length >= 1);
- assertContains("prop1", proposals); //$NON-NLS-1$
- }
-
- /**
- * Test the code completion for the unless attribute of a target.
- */
- public void testTargetUnlessProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
-
- int lineNumber= 16;
- int columnNumber= 43;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset + columnNumber), "prop", "unless"); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(proposals.length >= 1);
- assertContains("prop1", proposals); //$NON-NLS-1$
-
- }
-
- /**
- * Test the code completion for the target attribute of antcall.
- */
- public void testAntCallTargetProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("debugAntCall.xml")); //$NON-NLS-1$
- int lineNumber= 4;
- int columnNumber= 25;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getAntCallAttributeValueProposals(getCurrentDocument(), "", "target"); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(proposals.length == 2);
- assertContains("call", proposals); //$NON-NLS-1$
- assertContains("pre-call", proposals); //$NON-NLS-1$
- }
-
- /**
- * Asserts that <code>displayString</code> is in one of the
- * completion proposals.
- */
- private void assertContains(String displayString, ICompletionProposal[] proposalArray) {
- boolean found = false;
- for (int i = 0; i < proposalArray.length; i++) {
- ICompletionProposal proposal = proposalArray[i];
- String proposalDisplayString = proposal.getDisplayString();
- if(displayString.equals(proposalDisplayString)) {
- found = true;
- break;
- }
- }
- assertTrue("Did not find displayString: " + displayString, found); //$NON-NLS-1$
- }
-
- /**
- * Asserts that <code>displayString</code> is not in one of the
- * completion proposals.
- */
- private void assertDoesNotContain(String displayString, ICompletionProposal[] proposalArray) {
- boolean found = false;
- for (int i = 0; i < proposalArray.length; i++) {
- ICompletionProposal proposal = proposalArray[i];
- String proposalDisplayString = proposal.getDisplayString();
- if(displayString.equals(proposalDisplayString)) {
- found = true;
- break;
- }
- }
- assertFalse("Found displayString: " + displayString, found); //$NON-NLS-1$
- }
+ }
/**
- * Tests the property proposals for the case that they are defined in
- * a dependent targets.
+ * Test the code completion for the if attribute of a target.
*/
- public void testPropertyProposalDefinedInDependantTargets() throws FileNotFoundException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("dependencytest.xml")); //$NON-NLS-1$
+ public void testTargetIfProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
- File file= getBuildFile("dependencytest.xml"); //$NON-NLS-1$
- processor.setEditedFile(file);
+ int lineNumber = 15;
+ int columnNumber = 31;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset
+ + columnNumber), "", "if"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(proposals.length >= 1);
+ assertContains("prop1", proposals); //$NON-NLS-1$
+ }
+
+ /**
+ * Test the code completion for the unless attribute of a target.
+ */
+ public void testTargetUnlessProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
+
+ int lineNumber = 16;
+ int columnNumber = 43;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getTargetAttributeValueProposals(getCurrentDocument(), getCurrentDocument().get(0, lineOffset
+ + columnNumber), "prop", "unless"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(proposals.length >= 1);
+ assertContains("prop1", proposals); //$NON-NLS-1$
+
+ }
+
+ /**
+ * Test the code completion for the target attribute of antcall.
+ */
+ public void testAntCallTargetProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("debugAntCall.xml")); //$NON-NLS-1$
+ int lineNumber = 4;
+ int columnNumber = 25;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getAntCallAttributeValueProposals(getCurrentDocument(), "", "target"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(proposals.length == 2);
+ assertContains("call", proposals); //$NON-NLS-1$
+ assertContains("pre-call", proposals); //$NON-NLS-1$
+ }
+
+ /**
+ * Asserts that <code>displayString</code> is in one of the completion proposals.
+ */
+ private void assertContains(String displayString, ICompletionProposal[] proposalArray) {
+ boolean found = false;
+ for (int i = 0; i < proposalArray.length; i++) {
+ ICompletionProposal proposal = proposalArray[i];
+ String proposalDisplayString = proposal.getDisplayString();
+ if (displayString.equals(proposalDisplayString)) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Did not find displayString: " + displayString, found); //$NON-NLS-1$
+ }
+
+ /**
+ * Asserts that <code>displayString</code> is not in one of the completion proposals.
+ */
+ private void assertDoesNotContain(String displayString, ICompletionProposal[] proposalArray) {
+ boolean found = false;
+ for (int i = 0; i < proposalArray.length; i++) {
+ ICompletionProposal proposal = proposalArray[i];
+ String proposalDisplayString = proposal.getDisplayString();
+ if (displayString.equals(proposalDisplayString)) {
+ found = true;
+ break;
+ }
+ }
+ assertFalse("Found displayString: " + displayString, found); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests the property proposals for the case that they are defined in a dependent targets.
+ */
+ public void testPropertyProposalDefinedInDependantTargets() throws FileNotFoundException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("dependencytest.xml")); //$NON-NLS-1$
+
+ File file = getBuildFile("dependencytest.xml"); //$NON-NLS-1$
+ processor.setEditedFile(file);
String documentText = getFileContentAsString(file);
processor.setLineNumber(35);
processor.setColumnNumber(41);
int cursorPosition = documentText.lastIndexOf("${"); //$NON-NLS-1$
assertTrue(cursorPosition != -1);
- ICompletionProposal[] proposals = processor.getPropertyProposals(new org.eclipse.jface.text.Document(documentText), "", cursorPosition+2); //$NON-NLS-1$
+ ICompletionProposal[] proposals = processor.getPropertyProposals(new org.eclipse.jface.text.Document(documentText), "", cursorPosition + 2); //$NON-NLS-1$
assertContains("init_prop", proposals); //$NON-NLS-1$
assertContains("main_prop", proposals); //$NON-NLS-1$
assertContains("prop_prop", proposals); //$NON-NLS-1$
assertContains("do_not_compile", proposals); //$NON-NLS-1$
assertContains("adit_prop", proposals); //$NON-NLS-1$
assertContains("compile_prop", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Tests the code completion for tasks that have been defined in the buildfile
- */
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for tasks that have been defined in the buildfile
+ */
public void testCustomTaskProposals() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("taskdef.xml")); //$NON-NLS-1$
@@ -479,23 +481,23 @@
assertEquals(1, proposals.length);
ICompletionProposal proposal = proposals[0];
assertEquals("mine", proposal.getDisplayString()); //$NON-NLS-1$
- processor.dispose();
+ processor.dispose();
}
-
- /**
- * Tests the code completion for tasks that have been defined via the task extension point
- */
+
+ /**
+ * Tests the code completion for tasks that have been defined via the task extension point
+ */
public void testExtensionPointTaskProposals() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("taskdef.xml")); //$NON-NLS-1$
ICompletionProposal[] proposals = processor.getTaskProposals(getCurrentDocument(), "target", "cool"); //$NON-NLS-1$ //$NON-NLS-2$
assertContains("coolUITask", proposals); //$NON-NLS-1$
assertContains("coolUIType", proposals); //$NON-NLS-1$
- processor.dispose();
+ processor.dispose();
}
-
- /**
- * Tests the code completion for tasks that have been defined via macrodef in the buildfile
- */
+
+ /**
+ * Tests the code completion for tasks that have been defined via macrodef in the buildfile
+ */
public void testMacrodefProposals() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("macrodef.xml")); //$NON-NLS-1$
@@ -503,276 +505,277 @@
assertEquals(1, proposals.length);
ICompletionProposal proposal = proposals[0];
assertEquals("eclipseMacro", proposal.getDisplayString()); //$NON-NLS-1$
-
- }
-
- /**
- * Tests the code completion for tasks that have been defined via macrodef with uri in the buildfile
- */
- public void testNamespacedMacrodefProposals() {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("98853.xml")); //$NON-NLS-1$
- ICompletionProposal[] proposals = processor.getTaskProposals(getCurrentDocument(), "target", "xyz"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(2, proposals.length);
- ICompletionProposal proposal= proposals[0];
- assertEquals("xyz:echo-macro", proposal.getDisplayString()); //$NON-NLS-1$
- processor.dispose();
- }
-
+ }
+
/**
- * Tests the code completion for nested element attributes
- */
+ * Tests the code completion for tasks that have been defined via macrodef with uri in the buildfile
+ */
+ public void testNamespacedMacrodefProposals() {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("98853.xml")); //$NON-NLS-1$
+
+ ICompletionProposal[] proposals = processor.getTaskProposals(getCurrentDocument(), "target", "xyz"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(2, proposals.length);
+ ICompletionProposal proposal = proposals[0];
+ assertEquals("xyz:echo-macro", proposal.getDisplayString()); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for nested element attributes
+ */
public void testMacrodefNestedElementAttributeProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("macrodef.xml")); //$NON-NLS-1$
- int lineNumber= 5;
- int columnNumber= 11;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertEquals(proposals.length, 5);
- assertContains(IAntCoreConstants.DESCRIPTION, proposals);
- assertContains("implicit - (true | false | on | off | yes | no)", proposals); //$NON-NLS-1$
- assertContains(IAntCoreConstants.NAME, proposals);
- processor.dispose();
+ int lineNumber = 5;
+ int columnNumber = 11;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertEquals(proposals.length, 5);
+ assertContains(IAntCoreConstants.DESCRIPTION, proposals);
+ assertContains("implicit - (true | false | on | off | yes | no)", proposals); //$NON-NLS-1$
+ assertContains(IAntCoreConstants.NAME, proposals);
+ processor.dispose();
}
-
+
/**
- * Tests the code completion for tasks that have been defined via macrodef in the buildfile
- */
+ * Tests the code completion for tasks that have been defined via macrodef in the buildfile
+ */
public void testMacrodefAttributeProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("macrodef.xml")); //$NON-NLS-1$
- int lineNumber= 12;
- int columnNumber= 16;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 2);
- assertContains("v", proposals); //$NON-NLS-1$
- assertContains("eclipse", proposals); //$NON-NLS-1$
- assertTrue("Additional proposal information not correct", proposals[1].getAdditionalProposalInfo().startsWith("Testing Eclipse")); //$NON-NLS-1$ //$NON-NLS-2$
- processor.dispose();
+ int lineNumber = 12;
+ int columnNumber = 16;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertTrue(proposals.length == 2);
+ assertContains("v", proposals); //$NON-NLS-1$
+ assertContains("eclipse", proposals); //$NON-NLS-1$
+ assertTrue("Additional proposal information not correct", proposals[1].getAdditionalProposalInfo().startsWith("Testing Eclipse")); //$NON-NLS-1$ //$NON-NLS-2$
+ processor.dispose();
}
-
- /**
- * Tests the code completion for tasks that have been defined via macrodef in the buildfile
- */
- public void testNamespacedMacrodefAttributeProposals() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("98853.xml")); //$NON-NLS-1$
- int lineNumber= 16;
- int columnNumber= 18;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertEquals(proposals.length, 1);
- assertContains("str", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
+
/**
- * Tests the code completion for elements that have been defined via macrodef in the buildfile
- */
+ * Tests the code completion for tasks that have been defined via macrodef in the buildfile
+ */
+ public void testNamespacedMacrodefAttributeProposals() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("98853.xml")); //$NON-NLS-1$
+ int lineNumber = 16;
+ int columnNumber = 18;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertEquals("There should be one completion proposal", proposals.length, 1); //$NON-NLS-1$
+ assertContains("str", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for elements that have been defined via macrodef in the buildfile
+ */
public void testMacrodefElementProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("macrodef.xml")); //$NON-NLS-1$
- int lineNumber= 13;
- int columnNumber= 3;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 1);
- assertTrue("Proposal not correct", proposals[0].getDisplayString().equals("some-tasks")); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Additional proposal information not correct", proposals[0].getAdditionalProposalInfo().endsWith("Not required")); //$NON-NLS-1$ //$NON-NLS-2$
- processor.dispose();
+ int lineNumber = 13;
+ int columnNumber = 3;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertEquals("There should be 1 completion proposal", proposals.length, 1); //$NON-NLS-1$
+ assertTrue("Proposal not correct", proposals[0].getDisplayString().equals("some-tasks")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Additional proposal information not correct", proposals[0].getAdditionalProposalInfo().endsWith("Not required")); //$NON-NLS-1$ //$NON-NLS-2$
+ processor.dispose();
}
- /**
- * Tests the code completion for tasks having parent tasks.
- */
- public void testTaskProposals() {
+ /**
+ * Tests the code completion for tasks having parent tasks.
+ */
+ public void testTaskProposals() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
-
- ICompletionProposal[] proposals = processor.getTaskProposals(" <", "rename", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals(0, proposals.length);
- proposals = processor.getTaskProposals(" <cl", "property", "cl"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals(1, proposals.length);
- ICompletionProposal proposal = proposals[0];
- assertEquals("classpath", proposal.getDisplayString()); //$NON-NLS-1$
+ ICompletionProposal[] proposals = processor.getTaskProposals(" <", "rename", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals(0, proposals.length);
- proposals = processor.getTaskProposals(" <pr", "property", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals(1, proposals.length);
- proposal = proposals[0];
- assertEquals("classpath", proposal.getDisplayString()); //$NON-NLS-1$
-
- // "<project><target><mk"
- proposals = processor.getTaskProposals("<project><target><mk", "target", "mk"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals(1, proposals.length);
- proposal = proposals[0];
- assertEquals("mkdir", proposal.getDisplayString()); //$NON-NLS-1$
- processor.dispose();
- }
-
- public void testTargetTemplateProposals() throws BadLocationException, PartInitException {
- try {
- IFile file= getIFile("buildtest1.xml"); //$NON-NLS-1$
- AntEditor editor= (AntEditor)EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
- TestTextCompletionProcessor processor= new TestTextCompletionProcessor(editor);
- int lineNumber= 7;
- int columnNumber= 6;
- int lineOffset= editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
-
- //complete inside a target
- ICompletionProposal[] proposals= processor.determineTemplateProposals();
- assertDoesNotContain("target - public target", proposals); //$NON-NLS-1$
-
- //complete outside of a target
- lineNumber= 8;
- columnNumber= 13;
- lineOffset= editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
-
- proposals= processor.determineTemplateProposals();
- assertContains("target - public target", proposals); //$NON-NLS-1$
- //ensure all the tasks are still there
- proposals = processor.getProposalsFromDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput()), ""); //$NON-NLS-1$
- assertContains("ant", proposals); //$NON-NLS-1$
- } finally {
+ proposals = processor.getTaskProposals(" <cl", "property", "cl"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals(1, proposals.length);
+ ICompletionProposal proposal = proposals[0];
+ assertEquals("classpath", proposal.getDisplayString()); //$NON-NLS-1$
+
+ proposals = processor.getTaskProposals(" <pr", "property", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals(1, proposals.length);
+ proposal = proposals[0];
+ assertEquals("classpath", proposal.getDisplayString()); //$NON-NLS-1$
+
+ // "<project><target><mk"
+ proposals = processor.getTaskProposals("<project><target><mk", "target", "mk"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals(1, proposals.length);
+ proposal = proposals[0];
+ assertEquals("mkdir", proposal.getDisplayString()); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ public void testTargetTemplateProposals() throws BadLocationException, PartInitException {
+ try {
+ IFile file = getIFile("buildtest1.xml"); //$NON-NLS-1$
+ AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(editor);
+ int lineNumber = 7;
+ int columnNumber = 6;
+ int lineOffset = editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+
+ // complete inside a target
+ ICompletionProposal[] proposals = processor.determineTemplateProposals();
+ assertDoesNotContain("target - public target", proposals); //$NON-NLS-1$
+
+ // complete outside of a target
+ lineNumber = 8;
+ columnNumber = 13;
+ lineOffset = editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+
+ proposals = processor.determineTemplateProposals();
+ assertContains("target - public target", proposals); //$NON-NLS-1$
+ // ensure all the tasks are still there
+ proposals = processor.getProposalsFromDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput()), ""); //$NON-NLS-1$
+ assertContains("ant", proposals); //$NON-NLS-1$
+ }
+ finally {
EditorTestHelper.closeAllEditors();
}
-
- }
- /**
- * Tests the code completion for the fail task
- * bug 73637
- */
- public void testFailProposals() {
+
+ }
+
+ /**
+ * Tests the code completion for the fail task bug 73637
+ */
+ public void testFailProposals() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
ICompletionProposal[] proposals = processor.getAttributeProposals("fail", ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(6, proposals.length);
-
- assertContains("message", proposals); //$NON-NLS-1$
- assertContains("if", proposals); //$NON-NLS-1$
- assertContains("unless", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
+ assertEquals(6, proposals.length);
+
+ assertContains("message", proposals); //$NON-NLS-1$
+ assertContains("if", proposals); //$NON-NLS-1$
+ assertContains("unless", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
/**
* Test for bug 40951
*/
public void testMixedElements() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("mixed.xml")); //$NON-NLS-1$
- //String string = "<project><target><sql driver=\"\" password=\"\" url=\"\" userid=\"\"></sql><concat></concat>";
+ // String string = "<project><target><sql driver=\"\" password=\"\" url=\"\" userid=\"\"></sql><concat></concat>";
ICompletionProposal[] proposals = processor.getTaskProposals(getCurrentDocument(), processor.getParentName(getCurrentDocument(), 0, 62), "t"); //$NON-NLS-1$
assertEquals(1, proposals.length);
ICompletionProposal proposal = proposals[0];
assertEquals("transaction", proposal.getDisplayString()); //$NON-NLS-1$
-
+
proposals = processor.getTaskProposals(getCurrentDocument(), processor.getParentName(getCurrentDocument(), 0, 76), ""); //$NON-NLS-1$
- //filelist fileset filterchain footer header path
+ // filelist fileset filterchain footer header path
assertEquals(6, proposals.length);
proposal = proposals[0];
assertEquals("filelist", proposal.getDisplayString()); //$NON-NLS-1$
- processor.dispose();
+ processor.dispose();
}
-
- /**
- * Tests the algorithm for finding a child as used by the processor.
- */
- public void testFindChildElement() throws ParserConfigurationException {
-
- // Create the test data
- DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = docBuilder.newDocument();
- Element parentElement = doc.createElement("parent"); //$NON-NLS-1$
- Attr attribute = doc.createAttribute("att1"); //$NON-NLS-1$
- parentElement.setAttributeNode(attribute);
- Comment comment = doc.createComment("lakjjflsakdfj"); //$NON-NLS-1$
- parentElement.appendChild(comment);
- Element childElement = doc.createElement("child"); //$NON-NLS-1$
- parentElement.appendChild(childElement);
- childElement = doc.createElement("secondchild"); //$NON-NLS-1$
- parentElement.appendChild(childElement);
-
- // Create the processor
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
-
- // Test it!
- childElement = processor.findChildElementNamedOf(parentElement, "jkl"); //$NON-NLS-1$
- assertNull(childElement);
- childElement = processor.findChildElementNamedOf(parentElement, "secondchild"); //$NON-NLS-1$
- assertNotNull(childElement);
- assertEquals("secondchild", childElement.getTagName()); //$NON-NLS-1$
- }
-
- /**
- * Tests that the processor correctly determines the attribute proposal mode
- */
- public void testDeterminingAttributeProposalMode() {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
- int mode = processor.determineProposalMode("<project><property ta", 21, "ta"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<project><property ", 19, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<project><property ", 21, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<property id=\"hu\" ", 18, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<property id=\"hu\" \r\n ", 21, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<property\n", 10, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
- }
-
- /**
- * Tests that the processor correctly determines the attribute value proposal mode
- */
- public void testDeterminingAttributeValueProposalMode() {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
- int mode = processor.determineProposalMode("<project><property take=\"", 25, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<property id=\"hu\" ", 14, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<property id=\"hu\" \r\n ", 16, "hu"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
- mode = processor.determineProposalMode("<property \n\t\tid=\"hu\" \r\n ", 19, "hu"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
- }
-
+
/**
- * Tests how the processor determines the proposal mode.
- */
- public void testDeterminingPropertyProposalMode() {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
- int mode =processor.determineProposalMode("<project><target name=\"$\"", 24, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_PROPERTY_PROPOSAL, mode);
- mode = processor.determineProposalMode("<project><target name=\"${\"", 25, ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_PROPERTY_PROPOSAL, mode);
- mode = processor.determineProposalMode("<project><target name=\"${ja.bl\"", 30, "ja.bl"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_PROPERTY_PROPOSAL, mode);
-
+ * Tests the algorithm for finding a child as used by the processor.
+ */
+ public void testFindChildElement() throws ParserConfigurationException {
+
+ // Create the test data
+ DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+ Element parentElement = doc.createElement("parent"); //$NON-NLS-1$
+ Attr attribute = doc.createAttribute("att1"); //$NON-NLS-1$
+ parentElement.setAttributeNode(attribute);
+ Comment comment = doc.createComment("lakjjflsakdfj"); //$NON-NLS-1$
+ parentElement.appendChild(comment);
+ Element childElement = doc.createElement("child"); //$NON-NLS-1$
+ parentElement.appendChild(childElement);
+ childElement = doc.createElement("secondchild"); //$NON-NLS-1$
+ parentElement.appendChild(childElement);
+
+ // Create the processor
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+
+ // Test it!
+ childElement = processor.findChildElementNamedOf(parentElement, "jkl"); //$NON-NLS-1$
+ assertNull(childElement);
+ childElement = processor.findChildElementNamedOf(parentElement, "secondchild"); //$NON-NLS-1$
+ assertNotNull(childElement);
+ assertEquals("secondchild", childElement.getTagName()); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests that the processor correctly determines the attribute proposal mode
+ */
+ public void testDeterminingAttributeProposalMode() {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+ int mode = processor.determineProposalMode("<project><property ta", 21, "ta"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<project><property ", 19, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<project><property ", 21, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<property id=\"hu\" ", 18, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<property id=\"hu\" \r\n ", 21, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<property\n", 10, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_PROPOSAL, mode);
+ }
+
+ /**
+ * Tests that the processor correctly determines the attribute value proposal mode
+ */
+ public void testDeterminingAttributeValueProposalMode() {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+ int mode = processor.determineProposalMode("<project><property take=\"", 25, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<property id=\"hu\" ", 14, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<property id=\"hu\" \r\n ", 16, "hu"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<property \n\t\tid=\"hu\" \r\n ", 19, "hu"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_ATTRIBUTE_VALUE_PROPOSAL, mode);
+ }
+
+ /**
+ * Tests how the processor determines the proposal mode.
+ */
+ public void testDeterminingPropertyProposalMode() {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+ int mode = processor.determineProposalMode("<project><target name=\"$\"", 24, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_PROPERTY_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<project><target name=\"${\"", 25, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_PROPERTY_PROPOSAL, mode);
+ mode = processor.determineProposalMode("<project><target name=\"${ja.bl\"", 30, "ja.bl"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_PROPERTY_PROPOSAL, mode);
+
mode = processor.determineProposalMode("<project><target><echo>${", 25, ""); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_PROPERTY_PROPOSAL, mode);
- }
-
+ }
+
/**
* Tests how the processor determines the proposal mode.
*/
public void testDeterminingTaskProposalMode() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
-
+
int mode = processor.determineProposalMode("<project><prop", 14, "prop"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_TASK_PROPOSAL, mode);
mode = processor.determineProposalMode("<project> hjk", 13, ""); //$NON-NLS-1$ //$NON-NLS-2$
@@ -797,429 +800,429 @@
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_TASK_PROPOSAL_CLOSING, mode);
mode = processor.determineProposalMode("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_BUILDFILE, mode);
- mode= processor.determineProposalMode("<project default=\"hey\"><target name=\"hey\"><javac>a</javac></target></project>", 51, "a"); //$NON-NLS-1$ //$NON-NLS-2$
+ mode = processor.determineProposalMode("<project default=\"hey\"><target name=\"hey\"><javac>a</javac></target></project>", 51, "a"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_TASK_PROPOSAL, mode);
mode = processor.determineProposalMode("<project> hjk", 13, ""); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_TASK_PROPOSAL, mode);
}
-
+
/**
* Tests how the processor determines the proposal mode.
*/
public void testDeterminingTaskClosingProposalMode() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
-
+
int mode = processor.determineProposalMode("<target name=\"main\"><zip><size></size></zip></", 46, ""); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_TASK_PROPOSAL_CLOSING, mode);
}
- /**
- * Tests how the prefix will be determined.
- */
- public void testDeterminingPrefix() {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+ /**
+ * Tests how the prefix will be determined.
+ */
+ public void testDeterminingPrefix() {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
- // cursor after ${
- String prefix = processor.getPrefixFromDocument("<project><target name=\"${}\"", 25); //$NON-NLS-1$
- assertEquals("", prefix); //$NON-NLS-1$
+ // cursor after ${
+ String prefix = processor.getPrefixFromDocument("<project><target name=\"${}\"", 25); //$NON-NLS-1$
+ assertEquals("", prefix); //$NON-NLS-1$
- // cursor after $
- prefix = processor.getPrefixFromDocument("<project><target name=\"${\"", 24); //$NON-NLS-1$
- assertEquals("", prefix); //$NON-NLS-1$
+ // cursor after $
+ prefix = processor.getPrefixFromDocument("<project><target name=\"${\"", 24); //$NON-NLS-1$
+ assertEquals("", prefix); //$NON-NLS-1$
- // cursor after ${ja.
- prefix = processor.getPrefixFromDocument("<project><target name=\"${ja.\"", 28); //$NON-NLS-1$
- assertEquals("ja.", prefix); //$NON-NLS-1$
-
- // cursor after <
+ // cursor after ${ja.
+ prefix = processor.getPrefixFromDocument("<project><target name=\"${ja.\"", 28); //$NON-NLS-1$
+ assertEquals("ja.", prefix); //$NON-NLS-1$
+
+ // cursor after <
prefix = processor.getPrefixFromDocument("<project><", 10); //$NON-NLS-1$
assertEquals("", prefix); //$NON-NLS-1$
-
+
prefix = processor.getPrefixFromDocument("<project name= \"test\"><tar", 26); //$NON-NLS-1$
assertEquals("tar", prefix); //$NON-NLS-1$
-
+
prefix = processor.getPrefixFromDocument("pro", 3); //$NON-NLS-1$
assertEquals("pro", prefix); //$NON-NLS-1$
- }
-
- /**
- * Tests how the processor determines the proposal mode.
- */
- public void testDeterminingNoneProposalMode() {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+ }
- int mode = processor.determineProposalMode("<project><prop bla", 18, "bla"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_NONE, mode);
- mode= processor.determineProposalMode("<project default=\"hey\"><target name=", 37, "name="); //$NON-NLS-1$ //$NON-NLS-2$
+ /**
+ * Tests how the processor determines the proposal mode.
+ */
+ public void testDeterminingNoneProposalMode() {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor();
+
+ int mode = processor.determineProposalMode("<project><prop bla", 18, "bla"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_NONE, mode);
+ mode = processor.determineProposalMode("<project default=\"hey\"><target name=", 37, "name="); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(TestTextCompletionProcessor.TEST_PROPOSAL_MODE_NONE, mode);
}
-
- /**
- * Tests the code completion for tasks in an empty build file (no parent).
- */
- public void testTaskProposalsForEmptyBuildFile() {
+
+ /**
+ * Tests the code completion for tasks in an empty build file (no parent).
+ */
+ public void testTaskProposalsForEmptyBuildFile() {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("empty.xml")); //$NON-NLS-1$
- ICompletionProposal[] proposals = processor.getBuildFileProposals("", ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(1, proposals.length);
- assertEquals("project", proposals[0].getDisplayString()); //$NON-NLS-1$
-
- proposals = processor.getBuildFileProposals(" jl", "jl"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(0, proposals.length);
-
- proposals = processor.getBuildFileProposals(" \n<project></project>", ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(1, proposals.length);
- processor.dispose();
- }
-
- /**
- * Tests the code completion for refids (Bug 49830)
- */
- public void testRefidProposals() throws BadLocationException {
+ ICompletionProposal[] proposals = processor.getBuildFileProposals("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(1, proposals.length);
+ assertEquals("project", proposals[0].getDisplayString()); //$NON-NLS-1$
+
+ proposals = processor.getBuildFileProposals(" jl", "jl"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(0, proposals.length);
+
+ proposals = processor.getBuildFileProposals(" \n<project></project>", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(1, proposals.length);
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for refids (Bug 49830)
+ */
+ public void testRefidProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("refid.xml")); //$NON-NLS-1$
- int lineNumber= 9;
- int columnNumber= 16;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- //for sure should have project.class.path and project.class.path2 but project.class.path2
- //should not present itself as a possible reference
- assertTrue(proposals.length >= 2);
- assertContains("project.class.path", proposals); //$NON-NLS-1$
- assertDoesNotContain("project.class.path2", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Tests the code completion for custom task that has a boolean attribute
- */
- public void testCustomBooleanProposals() throws BadLocationException {
+ int lineNumber = 9;
+ int columnNumber = 16;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ // for sure should have project.class.path and project.class.path2 but project.class.path2
+ // should not present itself as a possible reference
+ assertTrue(proposals.length >= 2);
+ assertContains("project.class.path", proposals); //$NON-NLS-1$
+ assertDoesNotContain("project.class.path2", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for custom task that has a boolean attribute
+ */
+ public void testCustomBooleanProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("customBoolean.xml")); //$NON-NLS-1$
- int lineNumber= 2;
- int columnNumber= 44;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- //true false yes no on off
- assertTrue(proposals.length == 6);
- assertContains("true", proposals); //$NON-NLS-1$
- assertContains("no", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Tests the code completion for custom task that has an enumerated attribute
- */
- public void testCustomEnumeratedProposals() throws BadLocationException {
+ int lineNumber = 2;
+ int columnNumber = 44;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ // true false yes no on off
+ assertTrue(proposals.length == 6);
+ assertContains("true", proposals); //$NON-NLS-1$
+ assertContains("no", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for custom task that has an enumerated attribute
+ */
+ public void testCustomEnumeratedProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("extensionPointTaskSepVM.xml")); //$NON-NLS-1$
- int lineNumber= 2;
- int columnNumber= 24;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "c"); //$NON-NLS-1$
- assertEquals("Incorrect number of proposals", 2, proposals.length); //$NON-NLS-1$
- assertContains("cool", proposals); //$NON-NLS-1$
- assertContains("chillin", proposals); //$NON-NLS-1$
- assertDoesNotContain("awesome", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Tests the code completion for custom task that have a reference attribute
- */
- public void testCustomReferenceProposals() throws BadLocationException {
+ int lineNumber = 2;
+ int columnNumber = 24;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "c"); //$NON-NLS-1$
+ assertEquals("Incorrect number of proposals", 2, proposals.length); //$NON-NLS-1$
+ assertContains("cool", proposals); //$NON-NLS-1$
+ assertContains("chillin", proposals); //$NON-NLS-1$
+ assertDoesNotContain("awesome", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for custom task that have a reference attribute
+ */
+ public void testCustomReferenceProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("extensionPointTaskSepVM.xml")); //$NON-NLS-1$
- int lineNumber= 2;
- int columnNumber= 41;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "e"); //$NON-NLS-1$
- assertEquals("Incorrect number of proposals", 1, proposals.length); //$NON-NLS-1$
- //the reference to the project by name
- assertContains("Extension Point Task", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Tests the code completion for nested element attributes of custom tasks
- */
+ int lineNumber = 2;
+ int columnNumber = 41;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "e"); //$NON-NLS-1$
+ assertEquals("Incorrect number of proposals", 1, proposals.length); //$NON-NLS-1$
+ // the reference to the project by name
+ assertContains("Extension Point Task", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for nested element attributes of custom tasks
+ */
public void testNestedElementAttributeProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("nestedElementAttributes.xml")); //$NON-NLS-1$
- int lineNumber= 4;
- int columnNumber= 18;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 1);
- assertContains("works", proposals); //$NON-NLS-1$
- processor.dispose();
+ int lineNumber = 4;
+ int columnNumber = 18;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertTrue(proposals.length == 1);
+ assertContains("works", proposals); //$NON-NLS-1$
+ processor.dispose();
}
-
+
/**
- * Tests the code completion for nested elements
- */
+ * Tests the code completion for nested elements
+ */
public void testNestedElementProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("nestedElementAttributes.xml")); //$NON-NLS-1$
- int lineNumber= 4;
- int columnNumber= 3;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 1);
- assertContains("nestedelement", proposals); //$NON-NLS-1$
- processor.dispose();
+ int lineNumber = 4;
+ int columnNumber = 3;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertTrue(proposals.length == 1);
+ assertContains("nestedelement", proposals); //$NON-NLS-1$
+ processor.dispose();
}
-
+
/**
- * Tests the code completion for nested elements that no templates are presented
- * Bug 76414
- */
+ * Tests the code completion for nested elements that no templates are presented Bug 76414
+ */
public void testNestedElementTemplateProposals() throws BadLocationException, PartInitException {
try {
- IFile file= getIFile("nestedElementAttributes.xml"); //$NON-NLS-1$
- AntEditor editor= (AntEditor)EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
- TestTextCompletionProcessor processor= new TestTextCompletionProcessor(editor);
- int lineNumber= 4;
- int lineOffset= editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
-
- editor.getSelectionProvider().setSelection(new TextSelection(lineOffset, 0));
-
- ICompletionProposal[] proposals= processor.computeCompletionProposals(lineOffset);
-
- assertTrue("No templates are relevant at the current position. Found: " + proposals.length, proposals.length == 1); //$NON-NLS-1$
- } finally {
+ IFile file = getIFile("nestedElementAttributes.xml"); //$NON-NLS-1$
+ AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(editor);
+ int lineNumber = 4;
+ int lineOffset = editor.getDocumentProvider().getDocument(editor.getEditorInput()).getLineOffset(lineNumber);
+
+ editor.getSelectionProvider().setSelection(new TextSelection(lineOffset, 0));
+
+ ICompletionProposal[] proposals = processor.computeCompletionProposals(lineOffset);
+
+ assertTrue("No templates are relevant at the current position. Found: " + proposals.length, proposals.length == 1); //$NON-NLS-1$
+ }
+ finally {
EditorTestHelper.closeAllEditors();
}
}
-
+
/**
- * Tests the code completion for nested element attribute values of custom tasks
- */
+ * Tests the code completion for nested element attribute values of custom tasks
+ */
public void testNestedElementAttributeValueProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("nestedElementAttributes.xml")); //$NON-NLS-1$
- int lineNumber= 4;
- int columnNumber= 25;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 6); //the boolean proposals
- assertContains("true", proposals); //$NON-NLS-1$
- processor.dispose();
+ int lineNumber = 4;
+ int columnNumber = 25;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertEquals("There should be 6 completion proposals", proposals.length, 6); //$NON-NLS-1$
+ assertContains("true", proposals); //$NON-NLS-1$
+ processor.dispose();
}
-
+
/**
- * Tests the code completion when a parse error occurs in the project definition
- * bug 63151
- */
+ * Tests the code completion when a parse error occurs in the project definition bug 63151
+ */
public void testBadProjectProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("badproject.xml")); //$NON-NLS-1$
- int lineNumber= 0;
- int columnNumber= 10;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "n"); //$NON-NLS-1$
- assertTrue(proposals.length == 1);
- assertContains(IAntCoreConstants.NAME, proposals);
- processor.dispose();
+ int lineNumber = 0;
+ int columnNumber = 10;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "n"); //$NON-NLS-1$
+ assertTrue(proposals.length == 1);
+ assertContains(IAntCoreConstants.NAME, proposals);
+ processor.dispose();
}
-
+
/**
- * Tests the code completion for attribute value proposals both with and without leading whitespace
- */
+ * Tests the code completion for attribute value proposals both with and without leading whitespace
+ */
public void testAttributeValueProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("javac.xml")); //$NON-NLS-1$
- int lineNumber= 2;
- int columnNumber= 29;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 6); //boolean proposals
- assertContains("false", proposals); //$NON-NLS-1$
-
- lineNumber= 3;
- columnNumber= 19;
- lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 6); //boolean proposals
- assertContains("true", proposals); //$NON-NLS-1$
-
- lineNumber= 4;
- columnNumber= 22;
- lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 6); //boolean proposals
- assertContains("no", proposals); //$NON-NLS-1$
- processor.dispose();
+ int lineNumber = 2;
+ int columnNumber = 29;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertTrue(proposals.length == 6); // boolean proposals
+ assertContains("false", proposals); //$NON-NLS-1$
+
+ lineNumber = 3;
+ columnNumber = 19;
+ lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertTrue(proposals.length == 6); // boolean proposals
+ assertContains("true", proposals); //$NON-NLS-1$
+
+ lineNumber = 4;
+ columnNumber = 22;
+ lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertTrue(proposals.length == 6); // boolean proposals
+ assertContains("no", proposals); //$NON-NLS-1$
+ processor.dispose();
}
-
+
/**
- * Tests the code completion for an empty buildfile
- */
+ * Tests the code completion for an empty buildfile
+ */
public void testEmptyBuildfileProposals() throws PartInitException {
try {
- IFile file= getIFile("empty.xml"); //$NON-NLS-1$
- AntEditor editor= (AntEditor)EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
- TestTextCompletionProcessor processor= new TestTextCompletionProcessor(editor);
-
- editor.getSelectionProvider().setSelection(TextSelection.emptySelection());
-
- ICompletionProposal[] proposals= processor.computeCompletionProposals(0);
- assertTrue("Four proposals are relevant at the current position. Found: " + proposals.length, proposals.length == 4); //$NON-NLS-1$
- assertContains("project", proposals); //$NON-NLS-1$
- assertContains("Buildfile template - simple buildfile with two targets", proposals); //$NON-NLS-1$
- processor.dispose();
- } finally {
+ IFile file = getIFile("empty.xml"); //$NON-NLS-1$
+ AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, ANT_EDITOR_ID, true);
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(editor);
+
+ editor.getSelectionProvider().setSelection(TextSelection.emptySelection());
+
+ ICompletionProposal[] proposals = processor.computeCompletionProposals(0);
+ assertTrue("Four proposals are relevant at the current position. Found: " + proposals.length, proposals.length == 4); //$NON-NLS-1$
+ assertContains("project", proposals); //$NON-NLS-1$
+ assertContains("Buildfile template - simple buildfile with two targets", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+ finally {
EditorTestHelper.closeAllEditors();
}
}
-
- /**
- * Tests the code completion for refids (Bug 65480)
- */
- public void testJavacReferencesProposals() throws BadLocationException {
+
+ /**
+ * Tests the code completion for refids (Bug 65480)
+ */
+ public void testJavacReferencesProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("refid.xml")); //$NON-NLS-1$
- int lineNumber= 16;
- int columnNumber= 24;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- //for sure should have project.class.path and project.class.path2
- assertTrue(proposals.length >= 2);
- assertContains("project.class.path", proposals); //$NON-NLS-1$
- assertContains("project.class.path2", proposals); //$NON-NLS-1$
-
- lineNumber= 17;
- columnNumber= 25;
- lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- //for sure should have project.class.path and project.class.path2
- assertTrue(proposals.length >= 2);
- assertContains("project.class.path", proposals); //$NON-NLS-1$
- assertContains("project.class.path2", proposals); //$NON-NLS-1$
-
- lineNumber= 18;
- columnNumber= 26;
- lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- //for sure should have project.class.path and project.class.path2
- assertTrue(proposals.length >= 2);
- assertContains("project.class.path", proposals); //$NON-NLS-1$
- assertContains("project.class.path2", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Tests the code completion for the default target of a project (Bug 78030)
- */
- public void testProjectDefaultProposals() throws BadLocationException {
+ int lineNumber = 16;
+ int columnNumber = 24;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ // for sure should have project.class.path and project.class.path2
+ assertTrue(proposals.length >= 2);
+ assertContains("project.class.path", proposals); //$NON-NLS-1$
+ assertContains("project.class.path2", proposals); //$NON-NLS-1$
+
+ lineNumber = 17;
+ columnNumber = 25;
+ lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ // for sure should have project.class.path and project.class.path2
+ assertTrue(proposals.length >= 2);
+ assertContains("project.class.path", proposals); //$NON-NLS-1$
+ assertContains("project.class.path2", proposals); //$NON-NLS-1$
+
+ lineNumber = 18;
+ columnNumber = 26;
+ lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ // for sure should have project.class.path and project.class.path2
+ assertTrue(proposals.length >= 2);
+ assertContains("project.class.path", proposals); //$NON-NLS-1$
+ assertContains("project.class.path2", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for the default target of a project (Bug 78030)
+ */
+ public void testProjectDefaultProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
- int lineNumber= 1;
- int columnNumber= 49;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- //includes all the public targets
- assertTrue(proposals.length == 8);
- assertContains("main", proposals); //$NON-NLS-1$
- assertContains("testUnless", proposals); //$NON-NLS-1$
- processor.dispose();
- }
-
- /**
- * Tests the code completion for project attributes (bug 82031)
- */
- public void testProjectAttributeProposals() throws BadLocationException {
+ int lineNumber = 1;
+ int columnNumber = 49;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ // includes all the public targets
+ assertTrue(proposals.length == 8);
+ assertContains("main", proposals); //$NON-NLS-1$
+ assertContains("testUnless", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ /**
+ * Tests the code completion for project attributes (bug 82031)
+ */
+ public void testProjectAttributeProposals() throws BadLocationException {
TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("buildtest1.xml")); //$NON-NLS-1$
- int lineNumber= 1;
- int columnNumber= 9;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- //includes all the project attributes
- assertTrue(proposals.length == 3);
- assertContains(IAntCoreConstants.NAME, proposals);
- assertContains("default", proposals); //$NON-NLS-1$
- assertContains("basedir", proposals); //$NON-NLS-1$
-
- columnNumber= 10;
- lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- proposals = processor.getProposalsFromDocument(getCurrentDocument(), "n"); //$NON-NLS-1$
- assertTrue(proposals.length == 1);
- assertContains(IAntCoreConstants.NAME, proposals);
- processor.dispose();
- }
-
- public void testExtensionPoint() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("antextpoint1.xml")); //$NON-NLS-1$
+ int lineNumber = 1;
+ int columnNumber = 9;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ // includes all the project attributes
+ assertTrue(proposals.length == 3);
+ assertContains(IAntCoreConstants.NAME, proposals);
+ assertContains("default", proposals); //$NON-NLS-1$
+ assertContains("basedir", proposals); //$NON-NLS-1$
- int lineNumber= 2;
- int columnNumber= 3;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "ext"); //$NON-NLS-1$
- assertTrue(proposals.length == 3);
- assertContains("extension-point", proposals); //$NON-NLS-1$
- processor.dispose();
- }
+ columnNumber = 10;
+ lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ proposals = processor.getProposalsFromDocument(getCurrentDocument(), "n"); //$NON-NLS-1$
+ assertTrue(proposals.length == 1);
+ assertContains(IAntCoreConstants.NAME, proposals);
+ processor.dispose();
+ }
- public void testExtensionOf() throws BadLocationException {
- TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("antextpoint2.xml")); //$NON-NLS-1$
+ public void testExtensionPoint() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("antextpoint1.xml")); //$NON-NLS-1$
- int lineNumber= 3;
- int columnNumber= 38;
- int lineOffset= getCurrentDocument().getLineOffset(lineNumber);
- processor.setLineNumber(lineNumber);
- processor.setColumnNumber(columnNumber);
- processor.setCursorPosition(lineOffset + columnNumber);
- ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
- assertTrue(proposals.length == 1);
- assertContains("ep-B", proposals); //$NON-NLS-1$
- processor.dispose();
- }
+ int lineNumber = 2;
+ int columnNumber = 3;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), "ext"); //$NON-NLS-1$
+ assertTrue(proposals.length == 3);
+ assertContains("extension-point", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
+
+ public void testExtensionOf() throws BadLocationException {
+ TestTextCompletionProcessor processor = new TestTextCompletionProcessor(getAntModel("antextpoint2.xml")); //$NON-NLS-1$
+
+ int lineNumber = 3;
+ int columnNumber = 38;
+ int lineOffset = getCurrentDocument().getLineOffset(lineNumber);
+ processor.setLineNumber(lineNumber);
+ processor.setColumnNumber(columnNumber);
+ processor.setCursorPosition(lineOffset + columnNumber);
+ ICompletionProposal[] proposals = processor.getProposalsFromDocument(getCurrentDocument(), ""); //$NON-NLS-1$
+ assertTrue(proposals.length == 1);
+ assertContains("ep-B", proposals); //$NON-NLS-1$
+ processor.dispose();
+ }
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java
index 85ed28e..3d30dd4 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java
@@ -13,363 +13,334 @@
import java.util.List;
-import org.eclipse.ant.internal.ui.editor.formatter.XmlTagFormatter;
import org.eclipse.ant.internal.ui.editor.formatter.FormattingPreferences;
+import org.eclipse.ant.internal.ui.editor.formatter.XmlTagFormatter;
import org.eclipse.ant.internal.ui.editor.formatter.XmlTagFormatter.AttributePair;
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
public class XmlTagFormatterTest extends AbstractAntUITest {
- // TODO This test is too low level and too tightly coupled to internals.
+ // TODO This test is too low level and too tightly coupled to internals.
- /* ---------------- Test Fixture ---------------- */
- // In case anyone wonders why many people recommend against testing
- // privates, I produce this example...
- private static class InnerClassFactory extends XmlTagFormatter {
+ /* ---------------- Test Fixture ---------------- */
+ // In case anyone wonders why many people recommend against testing
+ // privates, I produce this example...
+ private static class InnerClassFactory extends XmlTagFormatter {
- public static class ParseException extends XmlTagFormatter.ParseException {
+ public static class ParseException extends XmlTagFormatter.ParseException {
private static final long serialVersionUID = 1L;
public ParseException(String message) {
- super(message);
- }
- }
+ super(message);
+ }
+ }
- public static class Tag extends XmlTagFormatter.Tag {
- //do nothing
- }
+ public static class Tag extends XmlTagFormatter.Tag {
+ // do nothing
+ }
- public static class TagFormatter extends XmlTagFormatter.TagFormatter {
+ public static class TagFormatter extends XmlTagFormatter.TagFormatter {
- public boolean lineRequiresWrap(String line, int lineWidth,
- int tabWidth) {
- return super.lineRequiresWrap(line, lineWidth, tabWidth);
- }
+ @Override
+ public boolean lineRequiresWrap(String line, int lineWidth, int tabWidth) {
+ return super.lineRequiresWrap(line, lineWidth, tabWidth);
+ }
- public int tabExpandedLineWidth(String line, int tabWidth) {
- return super.tabExpandedLineWidth(line, tabWidth);
- }
+ @Override
+ public int tabExpandedLineWidth(String line, int tabWidth) {
+ return super.tabExpandedLineWidth(line, tabWidth);
+ }
- public String wrapTag(Tag tag, FormattingPreferences prefs,
- String indent, String lineDelimiter) {
- return super.wrapTag(tag, prefs, indent, lineDelimiter);
- }
- }
+ public String wrapTag(Tag tag, FormattingPreferences prefs, String indent, String lineDelimiter) {
+ return super.wrapTag(tag, prefs, indent, lineDelimiter);
+ }
+ }
- public static class TagParser extends XmlTagFormatter.TagParser {
+ public static class TagParser extends XmlTagFormatter.TagParser {
- public String getElementName(String tagText)
- throws XmlTagFormatter.ParseException {
- return super.getElementName(tagText);
- }
+ @Override
+ public String getElementName(String tagText) throws XmlTagFormatter.ParseException {
+ return super.getElementName(tagText);
+ }
- public List<AttributePair> getAttibutes(String elementText)
- throws XmlTagFormatter.ParseException {
- return super.getAttibutes(elementText);
- }
- }
+ @Override
+ public List<AttributePair> getAttibutes(String elementText) throws XmlTagFormatter.ParseException {
+ return super.getAttibutes(elementText);
+ }
+ }
- public static Tag createTag() {
- return new Tag();
- }
+ public static Tag createTag() {
+ return new Tag();
+ }
- public static TagFormatter createTagFormatter() {
- return new TagFormatter();
- }
+ public static TagFormatter createTagFormatter() {
+ return new TagFormatter();
+ }
- public static TagParser createTagParser() {
- return new TagParser();
- }
+ public static TagParser createTagParser() {
+ return new TagParser();
+ }
- public static void validateAttributePair(Object attributePair, String attribute, String value) {
- XmlTagFormatter.AttributePair pair = (XmlTagFormatter.AttributePair) attributePair;
- assertEquals(attribute, pair.getAttribute());
- assertEquals(value, pair.getValue());
- }
- }
+ public static void validateAttributePair(Object attributePair, String attribute, String value) {
+ XmlTagFormatter.AttributePair pair = (XmlTagFormatter.AttributePair) attributePair;
+ assertEquals(attribute, pair.getAttribute());
+ assertEquals(value, pair.getValue());
+ }
+ }
- public XmlTagFormatterTest(String name) {
- super(name);
- }
+ public XmlTagFormatterTest(String name) {
+ super(name);
+ }
- private FormattingPreferences getPreferences(final boolean wrapLongTags,
- final boolean alignCloseChar, final int maxLineWidth) {
+ private FormattingPreferences getPreferences(final boolean wrapLongTags, final boolean alignCloseChar, final int maxLineWidth) {
- return new FormattingPreferences() {
+ return new FormattingPreferences() {
- public boolean alignElementCloseChar() {
- return alignCloseChar;
- }
+ @Override
+ public boolean alignElementCloseChar() {
+ return alignCloseChar;
+ }
- public boolean wrapLongTags() {
- return wrapLongTags;
- }
+ @Override
+ public boolean wrapLongTags() {
+ return wrapLongTags;
+ }
- public int getMaximumLineWidth() {
- return maxLineWidth;
- }
- };
- }
+ @Override
+ public int getMaximumLineWidth() {
+ return maxLineWidth;
+ }
+ };
+ }
- private void simpleTest(String source, String target,
- FormattingPreferences prefs, String indent, String lineDelimiter) throws Exception {
-
- String result = XmlTagFormatter.format(source, prefs, indent, lineDelimiter);
- assertEquals(target, result);
- }
+ private void simpleTest(String source, String target, FormattingPreferences prefs, String indent, String lineDelimiter) throws Exception {
- /* ---------------- Test Methods ---------------- */
+ String result = XmlTagFormatter.format(source, prefs, indent, lineDelimiter);
+ assertEquals(target, result);
+ }
- public void testParserGetElementName() throws Exception {
+ /* ---------------- Test Methods ---------------- */
- InnerClassFactory.TagParser tagParser = InnerClassFactory
- .createTagParser();
+ public void testParserGetElementName() throws Exception {
- String elementFixture1 = "<myElement attribute1=\"value1\" attribute2=\"value2\" />"; //$NON-NLS-1$
- assertEquals("myElement", tagParser.getElementName(elementFixture1)); //$NON-NLS-1$
+ InnerClassFactory.TagParser tagParser = InnerClassFactory.createTagParser();
- String elementFixture2 = "<myElement\t\nattribute1=\"value1\" attribute2=\"value2\" />"; //$NON-NLS-1$
- assertEquals("myElement", tagParser.getElementName(elementFixture2)); //$NON-NLS-1$
+ String elementFixture1 = "<myElement attribute1=\"value1\" attribute2=\"value2\" />"; //$NON-NLS-1$
+ assertEquals("myElement", tagParser.getElementName(elementFixture1)); //$NON-NLS-1$
- assertEquals("x", tagParser.getElementName("<x/>")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("x", tagParser.getElementName("<x>")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("x:y", tagParser.getElementName("<x:y/>")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("x:y", tagParser.getElementName("<x:y abc/>")); //$NON-NLS-1$ //$NON-NLS-2$
+ String elementFixture2 = "<myElement\t\nattribute1=\"value1\" attribute2=\"value2\" />"; //$NON-NLS-1$
+ assertEquals("myElement", tagParser.getElementName(elementFixture2)); //$NON-NLS-1$
- Exception e1 = null;
- try {
- tagParser.getElementName("<>"); //$NON-NLS-1$
- } catch (Exception e) {
- e1 = e;
- }
- assertNotNull(e1);
- assertTrue(e1.getClass().isAssignableFrom(
- InnerClassFactory.ParseException.class));
+ assertEquals("x", tagParser.getElementName("<x/>")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("x", tagParser.getElementName("<x>")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("x:y", tagParser.getElementName("<x:y/>")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("x:y", tagParser.getElementName("<x:y abc/>")); //$NON-NLS-1$ //$NON-NLS-2$
- Exception e2 = null;
- try {
- tagParser.getElementName("<>"); //$NON-NLS-1$
- } catch (Exception e) {
- e2 = e;
- }
- assertNotNull(e2);
- assertTrue(e2.getClass().isAssignableFrom(
- InnerClassFactory.ParseException.class));
+ Exception e1 = null;
+ try {
+ tagParser.getElementName("<>"); //$NON-NLS-1$
+ }
+ catch (Exception e) {
+ e1 = e;
+ }
+ assertNotNull(e1);
+ assertTrue(e1.getClass().isAssignableFrom(InnerClassFactory.ParseException.class));
- }
+ Exception e2 = null;
+ try {
+ tagParser.getElementName("<>"); //$NON-NLS-1$
+ }
+ catch (Exception e) {
+ e2 = e;
+ }
+ assertNotNull(e2);
+ assertTrue(e2.getClass().isAssignableFrom(InnerClassFactory.ParseException.class));
- public void testParserGetAttributes() throws Exception {
- InnerClassFactory.TagParser tagParser = InnerClassFactory.createTagParser();
+ }
- List<AttributePair> attributePairs;
+ public void testParserGetAttributes() throws Exception {
+ InnerClassFactory.TagParser tagParser = InnerClassFactory.createTagParser();
- // test normal situation
- attributePairs = tagParser.getAttibutes("<myElement attribute1=\"value1\" attribute2=\"value2\" />"); //$NON-NLS-1$
+ List<AttributePair> attributePairs;
- assertEquals(2, attributePairs.size());
- InnerClassFactory.validateAttributePair(attributePairs.get(0),
- "attribute1", "value1"); //$NON-NLS-1$ //$NON-NLS-2$
- InnerClassFactory.validateAttributePair(attributePairs.get(1),
- "attribute2", "value2"); //$NON-NLS-1$ //$NON-NLS-2$
+ // test normal situation
+ attributePairs = tagParser.getAttibutes("<myElement attribute1=\"value1\" attribute2=\"value2\" />"); //$NON-NLS-1$
-
- // test with extra whitespace and funny quotes
- attributePairs = tagParser.getAttibutes("<myElement \nattribute1 = 'value1\"'\nattribute2\t=\"value2'\" />"); //$NON-NLS-1$
+ assertEquals(2, attributePairs.size());
+ InnerClassFactory.validateAttributePair(attributePairs.get(0), "attribute1", "value1"); //$NON-NLS-1$ //$NON-NLS-2$
+ InnerClassFactory.validateAttributePair(attributePairs.get(1), "attribute2", "value2"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(2, attributePairs.size());
- InnerClassFactory.validateAttributePair(attributePairs.get(0),
- "attribute1", "value1\""); //$NON-NLS-1$ //$NON-NLS-2$
- InnerClassFactory.validateAttributePair(attributePairs.get(1),
- "attribute2", "value2'"); //$NON-NLS-1$ //$NON-NLS-2$
+ // test with extra whitespace and funny quotes
+ attributePairs = tagParser.getAttibutes("<myElement \nattribute1 = 'value1\"'\nattribute2\t=\"value2'\" />"); //$NON-NLS-1$
+
+ assertEquals(2, attributePairs.size());
+ InnerClassFactory.validateAttributePair(attributePairs.get(0), "attribute1", "value1\""); //$NON-NLS-1$ //$NON-NLS-2$
+ InnerClassFactory.validateAttributePair(attributePairs.get(1), "attribute2", "value2'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // test parse errors - equals in the wrong place
+ Exception e2 = null;
+ try {
+ attributePairs = tagParser.getAttibutes("<myElement attribute1=\"value1\" = attribute2=\"value2\" />"); //$NON-NLS-1$
+ }
+ catch (Exception e) {
+ e2 = e;
+ }
+ assertNotNull(e2);
+ assertTrue(e2.getClass().isAssignableFrom(InnerClassFactory.ParseException.class));
+
+ // test parse errors - quotes in the wrong place
+ Exception e3 = null;
+ try {
+ attributePairs = tagParser.getAttibutes("<myElement attribute1=\"\"value1\" attribute2=\"value2\" />"); //$NON-NLS-1$
+ }
+ catch (Exception e) {
+ e3 = e;
+ }
+ assertNotNull(e3);
+ assertTrue(e3.getClass().isAssignableFrom(InnerClassFactory.ParseException.class));
+ }
+
+ public void testFormat01() throws Exception {
+ String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$
+ String indent = "\t"; //$NON-NLS-1$
+ String source = "<target name=\"myTargetName\" depends=\"a,b,c,d,e,f,g\" description=\"This is a very long element which ought to be wrapped.\">"; //$NON-NLS-1$
+ String target = "<target name=\"myTargetName\"" + lineSep //$NON-NLS-1$
+ + indent + " depends=\"a,b,c,d,e,f,g\"" + lineSep //$NON-NLS-1$
+ + indent + " description=\"This is a very long element which ought to be wrapped.\">"; //$NON-NLS-1$
-// TODO attributes which contain whitespace should throw a parse error
-//
-// // test parse errors - whitespace in attribute name
-// Exception e1 = null;
-// try {
-// attributePairs = tagParser
-// .getAttibutes("<myElement at tribute1 = \"value1\" attribute2=\"value2\" />");
-// } catch (Exception e) {
-// e1 = e;
-// }
-// assertNotNull(e1);
-// assertTrue(e1.getClass().isAssignableFrom(
-// InnerClassFactory.ParseException.class));
-
-
- // test parse errors - equals in the wrong place
- Exception e2 = null;
- try {
- attributePairs = tagParser.getAttibutes("<myElement attribute1=\"value1\" = attribute2=\"value2\" />"); //$NON-NLS-1$
- } catch (Exception e) {
- e2 = e;
- }
- assertNotNull(e2);
- assertTrue(e2.getClass().isAssignableFrom(
- InnerClassFactory.ParseException.class));
-
-
- // test parse errors - quotes in the wrong place
- Exception e3 = null;
- try {
- attributePairs = tagParser
- .getAttibutes("<myElement attribute1=\"\"value1\" attribute2=\"value2\" />"); //$NON-NLS-1$
- } catch (Exception e) {
- e3 = e;
- }
- assertNotNull(e3);
- assertTrue(e3.getClass().isAssignableFrom(InnerClassFactory.ParseException.class));
- }
+ simpleTest(source, target, getPreferences(true, false, 60), indent, lineSep);
+ }
- public void testFormat01() throws Exception {
- String lineSep= System.getProperty("line.separator"); //$NON-NLS-1$
- String indent = "\t"; //$NON-NLS-1$
- String source = "<target name=\"myTargetName\" depends=\"a,b,c,d,e,f,g\" description=\"This is a very long element which ought to be wrapped.\">"; //$NON-NLS-1$
- String target = "<target name=\"myTargetName\"" + lineSep //$NON-NLS-1$
- + indent
- + " depends=\"a,b,c,d,e,f,g\"" + lineSep //$NON-NLS-1$
- + indent
- + " description=\"This is a very long element which ought to be wrapped.\">"; //$NON-NLS-1$
+ public void testFormat02() throws Exception {
+ String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$
+ String indent = "\t"; //$NON-NLS-1$
+ String source = "<target name=\"myTargetName\" depends=\"a,b,c,d,e,f,g\" description=\"This is a very long element which ought to be wrapped.\">"; //$NON-NLS-1$
+ String target = "<target name=\"myTargetName\"" + lineSep //$NON-NLS-1$
+ + indent + " depends=\"a,b,c,d,e,f,g\"" + lineSep //$NON-NLS-1$
+ + indent + " description=\"This is a very long element which ought to be wrapped.\"" + lineSep //$NON-NLS-1$
+ + indent + ">"; //$NON-NLS-1$
- simpleTest(source, target, getPreferences(true, false, 60), indent, lineSep);
- }
+ simpleTest(source, target, getPreferences(true, true, 60), indent, lineSep);
+ }
- public void testFormat02() throws Exception {
- String lineSep= System.getProperty("line.separator"); //$NON-NLS-1$
- String indent = "\t"; //$NON-NLS-1$
- String source = "<target name=\"myTargetName\" depends=\"a,b,c,d,e,f,g\" description=\"This is a very long element which ought to be wrapped.\">"; //$NON-NLS-1$
- String target = "<target name=\"myTargetName\"" + lineSep //$NON-NLS-1$
- + indent
- + " depends=\"a,b,c,d,e,f,g\"" + lineSep //$NON-NLS-1$
- + indent
- + " description=\"This is a very long element which ought to be wrapped.\"" + lineSep //$NON-NLS-1$
- + indent + ">"; //$NON-NLS-1$
+ public void testBug73411() throws Exception {
+ String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$
+ String indent = "\t"; //$NON-NLS-1$
+ String source = "<target name='myTargetName' depends=\"a,b,c,d,e,f,g\" description=\'This is a very long element which ought to be \"wrapped\".'>"; //$NON-NLS-1$
+ String target = "<target name='myTargetName'" + lineSep //$NON-NLS-1$
+ + indent + " depends=\"a,b,c,d,e,f,g\"" + lineSep //$NON-NLS-1$
+ + indent + " description='This is a very long element which ought to be \"wrapped\".'" + lineSep //$NON-NLS-1$
+ + indent + ">"; //$NON-NLS-1$
- simpleTest(source, target, getPreferences(true, true, 60), indent, lineSep);
- }
-
- public void testBug73411() throws Exception {
- String lineSep= System.getProperty("line.separator"); //$NON-NLS-1$
- String indent = "\t"; //$NON-NLS-1$
- String source = "<target name='myTargetName' depends=\"a,b,c,d,e,f,g\" description=\'This is a very long element which ought to be \"wrapped\".'>"; //$NON-NLS-1$
- String target = "<target name='myTargetName'" + lineSep //$NON-NLS-1$
- + indent
- + " depends=\"a,b,c,d,e,f,g\"" + lineSep //$NON-NLS-1$
- + indent
- + " description='This is a very long element which ought to be \"wrapped\".'" + lineSep //$NON-NLS-1$
- + indent + ">"; //$NON-NLS-1$
+ simpleTest(source, target, getPreferences(true, true, 60), indent, lineSep);
+ }
- simpleTest(source, target, getPreferences(true, true, 60), indent, lineSep);
- }
+ public void testLineRequiresWrap() throws Exception {
- public void testLineRequiresWrap() throws Exception {
+ InnerClassFactory.TagFormatter tagFormatter = InnerClassFactory.createTagFormatter();
- InnerClassFactory.TagFormatter tagFormatter = InnerClassFactory.createTagFormatter();
+ boolean shouldWrap = tagFormatter.lineRequiresWrap("\t\t <myElement attribute1=\"value1\" attribute2=\"value2\" />", //$NON-NLS-1$
+ 70, 8);
+ boolean shouldNotWrap = tagFormatter.lineRequiresWrap("\t\t <myElement attribute1=\"value1\" attribute2=\"value2\" />", //$NON-NLS-1$
+ 70, 8);
+ assertTrue(shouldWrap);
+ assertTrue(!shouldNotWrap);
- boolean shouldWrap = tagFormatter.lineRequiresWrap(
- "\t\t <myElement attribute1=\"value1\" attribute2=\"value2\" />", //$NON-NLS-1$
- 70, 8);
- boolean shouldNotWrap = tagFormatter.lineRequiresWrap(
- "\t\t <myElement attribute1=\"value1\" attribute2=\"value2\" />", //$NON-NLS-1$
- 70, 8);
- assertTrue(shouldWrap);
- assertTrue(!shouldNotWrap);
+ }
- }
+ public void testTabExpandedLineWidth() throws Exception {
- public void testTabExpandedLineWidth() throws Exception {
+ InnerClassFactory.TagFormatter tagFormatter = InnerClassFactory.createTagFormatter();
- InnerClassFactory.TagFormatter tagFormatter = InnerClassFactory.createTagFormatter();
+ assertEquals(20, tagFormatter.tabExpandedLineWidth("\t 1234567890", 8)); //$NON-NLS-1$
+ assertEquals(10, tagFormatter.tabExpandedLineWidth("1234567890", 8)); //$NON-NLS-1$
+ assertEquals(19, tagFormatter.tabExpandedLineWidth("\t1\t2 34567890", 3)); //$NON-NLS-1$
+ }
- assertEquals(20, tagFormatter.tabExpandedLineWidth("\t 1234567890", 8)); //$NON-NLS-1$
- assertEquals(10, tagFormatter.tabExpandedLineWidth("1234567890", 8)); //$NON-NLS-1$
- assertEquals(19, tagFormatter.tabExpandedLineWidth("\t1\t2 34567890", 3)); //$NON-NLS-1$
- }
+ public void testTabToStringAndMinimumLength() throws Exception {
+ InnerClassFactory.Tag tag = InnerClassFactory.createTag();
- public void testTabToStringAndMinimumLength() throws Exception {
- InnerClassFactory.Tag tag = InnerClassFactory.createTag();
+ tag.setElementName("myElement"); //$NON-NLS-1$
+ tag.setClosed(false);
+ assertEquals("<myElement>", tag.toString()); //$NON-NLS-1$
+ assertEquals(tag.toString().length(), tag.minimumLength());
- tag.setElementName("myElement"); //$NON-NLS-1$
- tag.setClosed(false);
- assertEquals("<myElement>", tag.toString()); //$NON-NLS-1$
- assertEquals(tag.toString().length(), tag.minimumLength());
+ tag.setClosed(true);
+ assertEquals("<myElement />", tag.toString()); //$NON-NLS-1$
+ assertEquals(tag.toString().length(), tag.minimumLength());
- tag.setClosed(true);
- assertEquals("<myElement />", tag.toString()); //$NON-NLS-1$
- assertEquals(tag.toString().length(), tag.minimumLength());
+ tag.addAttribute("attribute1", "value1", '"'); //$NON-NLS-1$ //$NON-NLS-2$
+ tag.addAttribute("attribute2", "value2", '"'); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("<myElement attribute1=\"value1\" attribute2=\"value2\" />", //$NON-NLS-1$
+ tag.toString());
+ assertEquals(tag.toString().length(), tag.minimumLength());
- tag.addAttribute("attribute1", "value1", '"'); //$NON-NLS-1$ //$NON-NLS-2$
- tag.addAttribute("attribute2", "value2", '"'); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(
- "<myElement attribute1=\"value1\" attribute2=\"value2\" />", //$NON-NLS-1$
- tag.toString());
- assertEquals(tag.toString().length(), tag.minimumLength());
+ tag.setClosed(false);
+ assertEquals("<myElement attribute1=\"value1\" attribute2=\"value2\">", //$NON-NLS-1$
+ tag.toString());
+ assertEquals(tag.toString().length(), tag.minimumLength());
+ }
- tag.setClosed(false);
- assertEquals("<myElement attribute1=\"value1\" attribute2=\"value2\">", //$NON-NLS-1$
- tag.toString());
- assertEquals(tag.toString().length(), tag.minimumLength());
- }
+ public void testWrapTag() throws Exception {
- public void testWrapTag() throws Exception {
+ InnerClassFactory.Tag tag = InnerClassFactory.createTag();
- InnerClassFactory.Tag tag = InnerClassFactory.createTag();
+ InnerClassFactory.TagFormatter tagFormatter = InnerClassFactory.createTagFormatter();
- InnerClassFactory.TagFormatter tagFormatter = InnerClassFactory
- .createTagFormatter();
+ FormattingPreferences dontAlignCloseChar = new FormattingPreferences() {
- FormattingPreferences dontAlignCloseChar = new FormattingPreferences() {
+ @Override
+ public boolean alignElementCloseChar() {
+ return false;
+ }
+ };
+ FormattingPreferences doAlignCloseChar = new FormattingPreferences() {
- public boolean alignElementCloseChar() {
- return false;
- }
- };
- FormattingPreferences doAlignCloseChar = new FormattingPreferences() {
+ @Override
+ public boolean alignElementCloseChar() {
+ return true;
+ }
+ };
- public boolean alignElementCloseChar() {
- return true;
- }
- };
+ tag.setElementName("myElement"); //$NON-NLS-1$
+ tag.addAttribute("attribute1", "value1", '"'); //$NON-NLS-1$ //$NON-NLS-2$
+ tag.addAttribute("attribute2", "value2", '"'); //$NON-NLS-1$ //$NON-NLS-2$
- tag.setElementName("myElement"); //$NON-NLS-1$
- tag.addAttribute("attribute1", "value1", '"'); //$NON-NLS-1$ //$NON-NLS-2$
- tag.addAttribute("attribute2", "value2", '"'); //$NON-NLS-1$ //$NON-NLS-2$
+ tag.setClosed(true);
- tag.setClosed(true);
+ String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$
+ assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
+ + "\t\t attribute2=\"value2\" />", tagFormatter //$NON-NLS-1$
+ .wrapTag(tag, dontAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
- String lineSep= System.getProperty("line.separator"); //$NON-NLS-1$
- assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
- + "\t\t attribute2=\"value2\" />", tagFormatter //$NON-NLS-1$
- .wrapTag(tag, dontAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
+ assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
+ + "\t\t attribute2=\"value2\"" + lineSep + "\t\t />", //$NON-NLS-1$ //$NON-NLS-2$
+ tagFormatter.wrapTag(tag, doAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
- assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
- + "\t\t attribute2=\"value2\"" + lineSep + "\t\t />", //$NON-NLS-1$ //$NON-NLS-2$
- tagFormatter.wrapTag(tag, doAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
+ tag.setClosed(false);
- tag.setClosed(false);
+ assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
+ + "\t\t attribute2=\"value2\">", tagFormatter //$NON-NLS-1$
+ .wrapTag(tag, dontAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
- assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
- + "\t\t attribute2=\"value2\">", tagFormatter //$NON-NLS-1$
- .wrapTag(tag, dontAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
+ assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
+ + "\t\t attribute2=\"value2\"" + lineSep + "\t\t >", //$NON-NLS-1$ //$NON-NLS-2$
+ tagFormatter.wrapTag(tag, doAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
- assertEquals("<myElement attribute1=\"value1\"" + lineSep //$NON-NLS-1$
- + "\t\t attribute2=\"value2\"" + lineSep + "\t\t >", //$NON-NLS-1$ //$NON-NLS-2$
- tagFormatter.wrapTag(tag, doAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$
+ }
- }
+ public void testBug63558() throws Exception {
- public void testBug63558() throws Exception {
-
// Ordinarily the double space after the element name would be repaired
// but if the formatter is working correctly these examples will be
// considered malformed and will be passed through untouched.
- String lineSep= System.getProperty("line.separator"); //$NON-NLS-1$
+ String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$
String source1 = "<echo file=\"foo\">" + lineSep + "<html><body><pre>" //$NON-NLS-1$ //$NON-NLS-2$
+ "${compilelog}</pre></body></html>"; //$NON-NLS-1$
- FormattingPreferences prefs = getPreferences(true, false, 60);
+ FormattingPreferences prefs = getPreferences(true, false, 60);
simpleTest(source1, source1, prefs, "\t", lineSep); //$NON-NLS-1$
-
+
String source2 = "<echo file=\"foo\"/bar/baz></echo>"; //$NON-NLS-1$
simpleTest(source2, source2, prefs, "\t", lineSep); //$NON-NLS-1$
}
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/ModelProjectTests.java b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/ModelProjectTests.java
index 914b9a6..4479a12 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/ModelProjectTests.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/ModelProjectTests.java
@@ -42,7 +42,7 @@
assertNotNull("getProperty() did not return 'p1'", p.getProperty("p1")); //$NON-NLS-1$ //$NON-NLS-2$
assertNotNull("the property help must have 'p1'", PropertyHelper.getProperty(p, "p1")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
* Tests {@link AntModelProject#reset()}
*
@@ -60,9 +60,9 @@
assertNull("the description must be null", p.getDescription()); //$NON-NLS-1$
assertEquals("The target list must be of size zero", p.getTargets().size(), 0); //$NON-NLS-1$
}
-
+
/**
- * Tests {@link AntModelProject#getProperty(String)} where the property we want has been set using
+ * Tests {@link AntModelProject#getProperty(String)} where the property we want has been set using
* {@link AntModelProject#setNewProperty(String, String)}
*
* @throws Exception
@@ -72,7 +72,7 @@
p.setNewProperty("testGetProprty1", "p1_value"); //$NON-NLS-1$ //$NON-NLS-2$
assertNotNull("getProperty() did not return 'testGetProprty1'", p.getProperty("testGetProprty1")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
* Tests {@link AntModelProject#getProperty(String)} where the property has been set into the user properties
*
@@ -83,10 +83,10 @@
p.setUserProperty("testGetProprty2", "p2_value"); //$NON-NLS-1$ //$NON-NLS-2$
assertNotNull("getProperty() did not return 'testGetProprty2'", p.getProperty("testGetProprty2")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
- * Tests {@link AntModelProject#getReference(String)} where the desired ref has been placed in the primary reference map
- * using {@link AntModelProject#addReference(String, Object)}
+ * Tests {@link AntModelProject#getReference(String)} where the desired ref has been placed in the primary reference map using
+ * {@link AntModelProject#addReference(String, Object)}
*
* @throws Exception
*/
@@ -95,10 +95,10 @@
p.addReference("testGetReference1", new Object()); //$NON-NLS-1$
assertNotNull("The reference 'testGetReference1' must exist", p.getReference("testGetReference1")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
- * Tests {@link AntModelProject#getReference(String)} where the desired ref has been placed in the
- * secondary 'idrefs' map using {@link AntModelProject#addIdReference(String, Object)}
+ * Tests {@link AntModelProject#getReference(String)} where the desired ref has been placed in the secondary 'idrefs' map using
+ * {@link AntModelProject#addIdReference(String, Object)}
*
* @throws Exception
*/
@@ -107,11 +107,10 @@
p.addIdReference("testGetReference2", new Object()); //$NON-NLS-1$
assertNotNull("the reference 'testGetReference2' must exist", p.getReference("testGetReference2")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/**
- * Tests {@link AntModelProject#getReference(String)} where the desired ref is in the secondary 'idrefs' map
- * and is an {@link UnknownElement}
- *
+ * Tests {@link AntModelProject#getReference(String)} where the desired ref is in the secondary 'idrefs' map and is an {@link UnknownElement}
+ *
* @throws Exception
*/
public void testGetReference3() throws Exception {
@@ -125,10 +124,10 @@
assertNotNull("the reference 'testGetReference3' must exist", ref); //$NON-NLS-1$
assertTrue("the reference must be a String", ref instanceof String); //$NON-NLS-1$
}
-
+
/**
- * Tests {@link AntModelProject#getProperties()} such that all properties (user and 'normal') are returned
- * in one call to {@link AntModelProject#getProperties()}
+ * Tests {@link AntModelProject#getProperties()} such that all properties (user and 'normal') are returned in one call to
+ * {@link AntModelProject#getProperties()}
*
* @throws Exception
*/
@@ -137,13 +136,13 @@
p.setProperty("p1", "p1v"); //$NON-NLS-1$ //$NON-NLS-2$
p.setProperty("p2", "p2v"); //$NON-NLS-1$ //$NON-NLS-2$
p.setUserProperty("p3", "p3v"); //$NON-NLS-1$ //$NON-NLS-2$
- //3 above and 'basedir'
+ // 3 above and 'basedir'
assertEquals("there must be 4 properties returned", p.getProperties().size(), 4); //$NON-NLS-1$
}
-
+
/**
- * Tests {@link AntModelProject#createClassLoader(org.apache.tools.ant.types.Path)} such that only one
- * classloader is created for a given path - classloaders are cached per-Path
+ * Tests {@link AntModelProject#createClassLoader(org.apache.tools.ant.types.Path)} such that only one classloader is created for a given path -
+ * classloaders are cached per-Path
*
* @throws Exception
*/
@@ -152,39 +151,38 @@
Path path = new Path(p);
AntClassLoader loader = p.createClassLoader(path);
assertNotNull("A classloader should have been created", loader); //$NON-NLS-1$
- //create a 'new' one, where passing null causes the classloader for the project path to be returned
+ // create a 'new' one, where passing null causes the classloader for the project path to be returned
AntClassLoader loader2 = p.createClassLoader(null);
assertNotNull("A classloader for a null path should return the project classloader", loader2); //$NON-NLS-1$
- //pointer compare, they should reference the same class loader
+ // pointer compare, they should reference the same class loader
assertTrue("The class loaders should be the same object", loader == loader2); //$NON-NLS-1$
}
-
+
/**
- * Tests {@link AntModelProject#getReferences()} to ensure the map returned is the live map
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=336936
+ * Tests {@link AntModelProject#getReferences()} to ensure the map returned is the live map https://bugs.eclipse.org/bugs/show_bug.cgi?id=336936
+ *
* @throws Exception
*/
- public void testGetReferences1() throws Exception {
+ public void testGetReferences1() throws Exception {
AntModelProject p = new AntModelProject();
p.addReference("testGetReferences1", new Object()); //$NON-NLS-1$
- //2 refs, ant.propertyHelper is auto-added
+ // 2 refs, ant.propertyHelper is auto-added
assertEquals("there should be one reference", p.getReferences().size(), 2); //$NON-NLS-1$
- //TODO ANT-1.9.1 API USE
Hashtable<String, Object> ht = p.getReferences();
ht.clear();
assertEquals("The references table should be empty", p.getReferences().size(), 0); //$NON-NLS-1$
}
-
+
/**
* Tests {@link AntModelProject#getCopyOfReferences()}
+ *
* @throws Exception
*/
public void testGetCopyOfReferences1() throws Exception {
AntModelProject p = new AntModelProject();
- //2 refs, ant.propertyHelper is auto-added
+ // 2 refs, ant.propertyHelper is auto-added
p.addReference("testGetCopyOfReferences1", new Object()); //$NON-NLS-1$
assertEquals("there should be one reference", p.getReferences().size(), 2); //$NON-NLS-1$
- //TODO ANT-1.9.1 API USE
Map<String, Object> ht = p.getCopyOfReferences();
ht.clear();
assertEquals("There should be one reference", p.getReferences().size(), 2); //$NON-NLS-1$
diff --git a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF
index 4f0e679..15ead11 100644
--- a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF
+++ b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF
@@ -22,7 +22,7 @@
org.eclipse.jface.text;resolution:=optional,
org.eclipse.ui.workbench.texteditor;resolution:=optional,
org.eclipse.ui.editors;resolution:=optional,
- org.apache.ant;bundle-version="1.8.4",
+ org.apache.ant;bundle-version="1.9.2",
org.junit,
org.eclipse.core.resources,
org.eclipse.jdt.core,
diff --git a/ant/org.eclipse.ant.tests.ui/buildfiles/buildAntTestsSupportJAR.xml b/ant/org.eclipse.ant.tests.ui/buildfiles/buildAntTestsSupportJAR.xml
index bde5127..7080733 100644
--- a/ant/org.eclipse.ant.tests.ui/buildfiles/buildAntTestsSupportJAR.xml
+++ b/ant/org.eclipse.ant.tests.ui/buildfiles/buildAntTestsSupportJAR.xml
Binary files differ
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
index 99f608f..798835c 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
@@ -35,6 +35,7 @@
import java.util.Map.Entry;
import java.util.Set;
+import org.apache.tools.ant.AntTypeDefinition;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ComponentHelper;
import org.apache.tools.ant.ExtensionPoint;
@@ -154,6 +155,13 @@
private final static ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
/**
+ * The fully qualified name of the {@link MacroInstance} class
+ *
+ * @since 3.5.500
+ */
+ private static final String MACROINSTANCE_NAME = "org.apache.tools.ant.taskdefs.MacroInstance"; //$NON-NLS-1$
+
+ /**
* The line where the cursor sits now.
* <P>
* The first line has index '1'.
@@ -714,9 +722,9 @@
}
}
} else { // possibly a user defined task or type
- Class<?> taskClass = getTaskClass(taskName);
+ AntTypeDefinition taskClass = getTaskClass(taskName);
if (taskClass != null) {
- if (taskClass == MacroInstance.class) {
+ if (MACROINSTANCE_NAME.equals(taskClass.getClassName())) {
addMacroDefAttributeProposals(taskName, prefix, proposals);
} else {
IntrospectionHelper helper = getIntrospectionHelper(taskClass);
@@ -725,7 +733,7 @@
}
}
} else { // nested user defined element
- Class<?> nestedType = getNestedType();
+ AntTypeDefinition nestedType = getNestedType();
if (nestedType != null) {
IntrospectionHelper helper = getIntrospectionHelper(nestedType);
if (helper != null) {
@@ -748,7 +756,7 @@
}
}
- private Class<?> getNestedType() {
+ private AntTypeDefinition getNestedType() {
AntElementNode currentNode = antModel.getNode(cursorPosition, false);
if (currentNode == null) {
return null;
@@ -757,18 +765,21 @@
if (parent instanceof AntTaskNode) {
String parentName = parent.getName();
if (hasNestedElements(parentName)) {
- Class<?> taskClass = getTaskClass(parentName);
+ AntTypeDefinition taskClass = getTaskClass(parentName);
if (taskClass != null) {
IntrospectionHelper helper = getIntrospectionHelper(taskClass);
if (helper != null) {
- Class<?> nestedType = null;
try {
- nestedType = helper.getElementType(currentNode.getName());
+ Class<?> nestedType = helper.getElementType(currentNode.getName());
+ // TODO probably a much better way to find the definition of a nested type than this
+ AntTypeDefinition def = new AntTypeDefinition();
+ def.setClass(nestedType);
+ def.setClassName(nestedType.getName());
+ return def;
}
catch (BuildException be) {
// do nothing
}
- return nestedType;
}
}
}
@@ -776,15 +787,20 @@
return null;
}
- private IntrospectionHelper getIntrospectionHelper(Class<?> taskClass) {
- IntrospectionHelper helper = null;
- try {
- helper = IntrospectionHelper.getHelper(antModel.getProjectNode().getProject(), taskClass);
+ private IntrospectionHelper getIntrospectionHelper(AntTypeDefinition taskClass) {
+ Project p = antModel.getProjectNode().getProject();
+ Class<?> clazz = taskClass.getExposedClass(p);
+ if (clazz != null) {
+ IntrospectionHelper helper = null;
+ try {
+ helper = IntrospectionHelper.getHelper(antModel.getProjectNode().getProject(), clazz);
+ }
+ catch (NoClassDefFoundError e) {
+ // ignore as a task may require additional classpath components
+ }
+ return helper;
}
- catch (NoClassDefFoundError e) {
- // ignore as a task may require additional classpath components
- }
- return helper;
+ return null;
}
private void addMacroDefAttributeProposals(String taskName, String prefix, List<ICompletionProposal> proposals) {
@@ -906,14 +922,14 @@
}
}
} else { // possibly a user defined task or type
- Class<?> taskClass = getTaskClass(taskName);
+ AntTypeDefinition taskClass = getTaskClass(taskName);
if (taskClass != null) {
IntrospectionHelper helper = getIntrospectionHelper(taskClass);
if (helper != null) {
addAttributeValueProposals(helper, attributeName, prefix, proposals);
}
} else { // nested user defined element
- Class<?> nestedType = getNestedType();
+ AntTypeDefinition nestedType = getNestedType();
if (nestedType != null) {
IntrospectionHelper helper = getIntrospectionHelper(nestedType);
if (helper != null) {
@@ -986,8 +1002,7 @@
protected ICompletionProposal[] getPropertyProposals(IDocument document, String prefix, int aCursorPosition) {
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
Map<String, ICompletionProposal> displayStringToProposals = new HashMap<String, ICompletionProposal>();
- // TODO ANT-1.9.1 API USE
- Map<String, ?> properties = findPropertiesFromDocument();
+ Map<String, Object> properties = findPropertiesFromDocument();
Image image = AntUIImages.getImage(IAntUIConstants.IMG_PROPERTY);
// Determine replacement length and offset
@@ -1057,7 +1072,7 @@
if (areTasksOrTypesValidChildren(parentName)) {
// use the definitions in the project as that includes more than what is defined in the DTD
Project project = antModel.getProjectNode().getProject();
- Map<String, Class<?>> tasksAndTypes = ComponentHelper.getComponentHelper(project).getAntTypeTable();
+ Map<String, AntTypeDefinition> tasksAndTypes = ComponentHelper.getComponentHelper(project).getAntTypeTable();
createProposals(document, prefix, proposals, tasksAndTypes);
if (parentName.equals("project")) { //$NON-NLS-1$
if ("target".startsWith(prefix)) { //$NON-NLS-1$
@@ -1085,9 +1100,9 @@
}
} else {
// a nested element of a user defined task/type?
- Class<?> taskClass = getTaskClass(parentName);
+ AntTypeDefinition taskClass = getTaskClass(parentName);
if (taskClass != null) {
- if (taskClass == MacroInstance.class) {
+ if (MACROINSTANCE_NAME.equals(taskClass.getClassName())) {
currentProposalMode = PROPOSAL_MODE_ATTRIBUTE_PROPOSAL;
addMacroDefElementProposals(parentName, prefix, proposals);
} else {
@@ -1145,7 +1160,7 @@
return NO_PROPOSALS;
}
- private void createProposals(IDocument document, String prefix, List<ICompletionProposal> proposals, Map<String, Class<?>> tasks) {
+ private void createProposals(IDocument document, String prefix, List<ICompletionProposal> proposals, Map<String, AntTypeDefinition> tasks) {
Iterator<String> keys = tasks.keySet().iterator();
ICompletionProposal proposal;
String key;
@@ -1281,7 +1296,7 @@
if (element != null) {
return !element.isEmpty();
}
- Class<?> taskClass = getTaskClass(elementName);
+ AntTypeDefinition taskClass = getTaskClass(elementName);
if (taskClass != null) {
IntrospectionHelper helper = getIntrospectionHelper(taskClass);
if (helper != null) {
@@ -1559,12 +1574,12 @@
return false;
}
- private Class<?> getTaskClass(String taskName) {
- Class<?> clss = null;
+ private AntTypeDefinition getTaskClass(String taskName) {
+ AntTypeDefinition clss = null;
AntProjectNode node = antModel.getProjectNode();
if (node != null) {
Project antProject = node.getProject();
- Map<String, Class<?>> tasksAndTypes = ComponentHelper.getComponentHelper(antProject).getAntTypeTable();
+ Map<String, AntTypeDefinition> tasksAndTypes = ComponentHelper.getComponentHelper(antProject).getAntTypeTable();
clss = tasksAndTypes.get(taskName);
if (clss == null) {
clss = tasksAndTypes.get(antModel.getNamespaceCorrectName(taskName));
@@ -1619,7 +1634,7 @@
*
* @return a map with all the found properties
*/
- private Map<String, String> findPropertiesFromDocument() {
+ private Map<String, Object> findPropertiesFromDocument() {
Project project = antModel.getProjectNode().getProject();
return project.getProperties();
}
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java
index 4a75fe9..8248e37 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java
@@ -22,61 +22,66 @@
import org.eclipse.jface.text.formatter.IFormattingContext;
public class XmlDocumentFormattingStrategy extends ContextBasedFormattingStrategy {
-
+
/** Documents to be formatted by this strategy */
- private final LinkedList<IDocument> fDocuments= new LinkedList<IDocument>();
-
+ private final LinkedList<IDocument> fDocuments = new LinkedList<IDocument>();
+
/** access to the preferences store * */
- private FormattingPreferences prefs;
-
- private int indent= -1;
-
+ private FormattingPreferences prefs;
+
+ private int indent = -1;
+
public XmlDocumentFormattingStrategy() {
- this.prefs = new FormattingPreferences();
- }
-
- public XmlDocumentFormattingStrategy(FormattingPreferences prefs, int indent) {
- Assert.isNotNull(prefs);
- this.prefs = prefs;
- this.indent= indent;
+ this.prefs = new FormattingPreferences();
}
-
- /* (non-Javadoc)
+
+ public XmlDocumentFormattingStrategy(FormattingPreferences prefs, int indent) {
+ Assert.isNotNull(prefs);
+ this.prefs = prefs;
+ this.indent = indent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.text.formatter.IFormattingStrategyExtension#format()
*/
+ @Override
public void format() {
-
- super.format();
- final IDocument document= fDocuments.removeFirst();
+
+ super.format();
+ final IDocument document = fDocuments.removeFirst();
if (document != null) {
- // TODO allow formatting of regions, not just the entire document; bug 75611
- String documentText = document.get();
- XmlDocumentFormatter formatter = new XmlDocumentFormatter();
- if (indent != -1) {
- formatter.setInitialIndent(indent);
- }
- formatter.setDefaultLineDelimiter(TextUtilities.getDefaultLineDelimiter(document));
- String formattedText = formatter.format(documentText, this.prefs);
- if (formattedText != null && !formattedText.equals(documentText)) {
- document.set(formattedText);
- }
+ // allow formatting of regions, not just the entire document; bug 75611
+ String documentText = document.get();
+ XmlDocumentFormatter formatter = new XmlDocumentFormatter();
+ if (indent != -1) {
+ formatter.setInitialIndent(indent);
+ }
+ formatter.setDefaultLineDelimiter(TextUtilities.getDefaultLineDelimiter(document));
+ String formattedText = formatter.format(documentText, this.prefs);
+ if (formattedText != null && !formattedText.equals(documentText)) {
+ document.set(formattedText);
+ }
}
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
- */
- public void formatterStarts(final IFormattingContext context) {
- super.formatterStarts(context);
- fDocuments.addLast((IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
- }
+ }
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops()
- */
- public void formatterStops() {
- super.formatterStops();
+ /*
+ * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
+ */
+ @Override
+ public void formatterStarts(final IFormattingContext context) {
+ super.formatterStarts(context);
+ fDocuments.addLast((IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
+ }
- fDocuments.clear();
- }
+ /*
+ * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops()
+ */
+ @Override
+ public void formatterStops() {
+ super.formatterStops();
+
+ fDocuments.clear();
+ }
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java
index f78f74b..aeb2b34 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java
@@ -160,7 +160,7 @@
private void initializeAsGlobal(boolean separateVM) {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
- List<?> prefProperties;
+ List<Property> prefProperties;
if (separateVM) {
prefProperties = prefs.getRemoteAntProperties();
} else {
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntDefiningTaskNode.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntDefiningTaskNode.java
index 4ac466a..1ee42d2 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntDefiningTaskNode.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntDefiningTaskNode.java
@@ -19,6 +19,7 @@
import java.util.Iterator;
import java.util.List;
+import org.apache.tools.ant.AntTypeDefinition;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ComponentHelper;
import org.apache.tools.ant.Task;
@@ -37,155 +38,163 @@
import org.xml.sax.Attributes;
public class AntDefiningTaskNode extends AntTaskNode {
- private String fIdentifier= null;
-
- public AntDefiningTaskNode(Task task, Attributes attributes) {
- super(task);
- String label= attributes.getValue(IAntCoreConstants.NAME);
- if (label == null) {
- label= task.getTaskName();
-
- String file= attributes.getValue(IAntCoreConstants.FILE);
- if(file != null) {
- label= label + " " + file; //$NON-NLS-1$
- fIdentifier= file;
- } else {
- String resource= attributes.getValue(IAntModelConstants.ATTR_RESOURCE);
- if (resource != null) {
- label= label + " " + resource; //$NON-NLS-1$
- fIdentifier= resource;
- }
- }
- } else {
- fIdentifier= label;
- }
-
- setBaseLabel(label);
- }
-
- protected ImageDescriptor getBaseImageDescriptor() {
- String taskName= getTask().getTaskName();
- if ("taskdef".equalsIgnoreCase(taskName) || "typedef".equalsIgnoreCase(taskName)) { //$NON-NLS-1$//$NON-NLS-2$
- return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_TASKDEF);
+ private String fIdentifier = null;
+
+ public AntDefiningTaskNode(Task task, Attributes attributes) {
+ super(task);
+ String label = attributes.getValue(IAntCoreConstants.NAME);
+ if (label == null) {
+ label = task.getTaskName();
+
+ String file = attributes.getValue(IAntCoreConstants.FILE);
+ if (file != null) {
+ label = label + " " + file; //$NON-NLS-1$
+ fIdentifier = file;
+ } else {
+ String resource = attributes.getValue(IAntModelConstants.ATTR_RESOURCE);
+ if (resource != null) {
+ label = label + " " + resource; //$NON-NLS-1$
+ fIdentifier = resource;
+ }
+ }
+ } else {
+ fIdentifier = label;
}
- return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_MACRODEF);
+
+ setBaseLabel(label);
}
-
+
+ @Override
+ protected ImageDescriptor getBaseImageDescriptor() {
+ String taskName = getTask().getTaskName();
+ if ("taskdef".equalsIgnoreCase(taskName) || "typedef".equalsIgnoreCase(taskName)) { //$NON-NLS-1$//$NON-NLS-2$
+ return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_TASKDEF);
+ }
+ return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_MACRODEF);
+ }
+
/**
* Execute the defining task.
*/
+ @Override
public boolean configure(boolean validateFully) {
- if (fConfigured) {
- return false;
- }
+ if (fConfigured) {
+ return false;
+ }
if (shouldConfigure()) {
try {
- ComponentHelper helper= ComponentHelper.getComponentHelper(getProjectNode().getProject());
- ((AntModel) getAntModel()).removeDefinerTasks(getIdentifier(), helper.getAntTypeTable());
- Hashtable<String, Class<?>> old= new Hashtable<String, Class<?>>(helper.getAntTypeTable());
+ ComponentHelper helper = ComponentHelper.getComponentHelper(getProjectNode().getProject());
+ ((AntModel) getAntModel()).removeDefinerTasks(getIdentifier(), helper.getAntTypeTable());
+ Hashtable<String, AntTypeDefinition> old = new Hashtable<String, AntTypeDefinition>(helper.getAntTypeTable());
getTask().maybeConfigure();
getTask().execute();
- Iterator<String> newNames= helper.getAntTypeTable().keySet().iterator();
- List<String> defined= new ArrayList<String>();
- while (newNames.hasNext()) {
- String name = newNames.next();
- if (old.get(name) == null) {
- defined.add(name);
- }
- }
- ((AntModel) getAntModel()).addDefinedTasks(defined, this);
+ Iterator<String> newNames = helper.getAntTypeTable().keySet().iterator();
+ List<String> defined = new ArrayList<String>();
+ while (newNames.hasNext()) {
+ String name = newNames.next();
+ if (old.get(name) == null) {
+ defined.add(name);
+ }
+ }
+ ((AntModel) getAntModel()).addDefinedTasks(defined, this);
return false;
- } catch (BuildException be) {
- ((AntModel)getAntModel()).removeDefiningTaskNodeInfo(this);
+ }
+ catch (BuildException be) {
+ ((AntModel) getAntModel()).removeDefiningTaskNodeInfo(this);
handleBuildException(be, AntEditorPreferenceConstants.PROBLEM_CLASSPATH);
- } catch (LinkageError e) {
- //A classpath problem with the definer. Possible causes are having multiple
- //versions of the same JAR on the Ant runtime classpath (either explicitly or via the plugin
- //classloaders. See bug 71888
- ((AntModel)getAntModel()).removeDefiningTaskNodeInfo(this);
- handleBuildException(new BuildException(AntModelMessages.AntDefiningTaskNode_0), AntEditorPreferenceConstants.PROBLEM_CLASSPATH);
- } catch (AntSecurityException se) {
- //either a system exit or setting of system property was attempted
- ((AntModel)getAntModel()).removeDefiningTaskNodeInfo(this);
- handleBuildException(new BuildException(AntModelMessages.AntDefiningTaskNode_1), AntEditorPreferenceConstants.PROBLEM_SECURITY);
+ }
+ catch (LinkageError e) {
+ // A classpath problem with the definer. Possible causes are having multiple
+ // versions of the same JAR on the Ant runtime classpath (either explicitly or via the plugin
+ // classloaders. See bug 71888
+ ((AntModel) getAntModel()).removeDefiningTaskNodeInfo(this);
+ handleBuildException(new BuildException(AntModelMessages.AntDefiningTaskNode_0), AntEditorPreferenceConstants.PROBLEM_CLASSPATH);
+ }
+ catch (AntSecurityException se) {
+ // either a system exit or setting of system property was attempted
+ ((AntModel) getAntModel()).removeDefiningTaskNodeInfo(this);
+ handleBuildException(new BuildException(AntModelMessages.AntDefiningTaskNode_1), AntEditorPreferenceConstants.PROBLEM_SECURITY);
}
}
return false;
}
-
+
public Object getRealTask() {
- Task task= getTask();
+ Task task = getTask();
if (task instanceof UnknownElement) {
task.maybeConfigure();
- return ((UnknownElement)task).getRealThing();
+ return ((UnknownElement) task).getRealThing();
}
return task;
}
-
- protected String getIdentifier() {
- return fIdentifier;
- }
-
+
+ protected String getIdentifier() {
+ return fIdentifier;
+ }
+
/*
- * Sets the Java class path in org.apache.tools.ant.types.Path
- * so that the classloaders defined by these "definer" tasks will have the
- * correct classpath.
+ * Sets the Java class path in org.apache.tools.ant.types.Path so that the classloaders defined by these "definer" tasks will have the correct
+ * classpath.
*/
public static void setJavaClassPath() {
-
- AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
- URL[] antClasspath= prefs.getURLs();
-
+
+ AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
+ URL[] antClasspath = prefs.getURLs();
+
setJavaClassPath(antClasspath);
}
-
+
/*
- * Sets the Java class path in org.apache.tools.ant.types.Path
- * so that the classloaders defined by these "definer" tasks will have the
- * correct classpath.
+ * Sets the Java class path in org.apache.tools.ant.types.Path so that the classloaders defined by these "definer" tasks will have the correct
+ * classpath.
*/
public static void setJavaClassPath(URL[] antClasspath) {
-
- StringBuffer buff= new StringBuffer();
- File file= null;
+
+ StringBuffer buff = new StringBuffer();
+ File file = null;
for (int i = 0; i < antClasspath.length; i++) {
try {
file = new File(FileLocator.toFileURL(antClasspath[i]).getPath());
- } catch (IOException e) {
+ }
+ catch (IOException e) {
continue;
}
buff.append(file.getAbsolutePath());
buff.append("; "); //$NON-NLS-1$
}
- org.apache.tools.ant.types.Path systemClasspath= new org.apache.tools.ant.types.Path(null, buff.substring(0, buff.length() - 2));
- org.apache.tools.ant.types.Path.systemClasspath= systemClasspath;
+ org.apache.tools.ant.types.Path systemClasspath = new org.apache.tools.ant.types.Path(null, buff.substring(0, buff.length() - 2));
+ org.apache.tools.ant.types.Path.systemClasspath = systemClasspath;
}
-
+
+ @Override
public boolean collapseProjection() {
- IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = AntUIPlugin.getDefault().getPreferenceStore();
if (store.getBoolean(AntEditorPreferenceConstants.EDITOR_FOLDING_DEFINING)) {
return true;
}
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.ant.internal.ui.model.AntElementNode#setLength(int)
- */
- public void setLength(int length) {
- super.setLength(length);
- if (shouldConfigure()) {
- getAntModel().setDefiningTaskNodeText(this);
- }
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ant.internal.ui.model.AntElementNode#setLength(int)
+ */
+ @Override
+ public void setLength(int length) {
+ super.setLength(length);
+ if (shouldConfigure()) {
+ getAntModel().setDefiningTaskNodeText(this);
+ }
+ }
- private boolean shouldConfigure() {
- IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(AntEditorPreferenceConstants.CODEASSIST_USER_DEFINED_TASKS);
- }
+ private boolean shouldConfigure() {
+ IPreferenceStore store = AntUIPlugin.getDefault().getPreferenceStore();
+ return store.getBoolean(AntEditorPreferenceConstants.CODEASSIST_USER_DEFINED_TASKS);
+ }
- protected void setNeedsToBeConfigured(boolean configure) {
- fConfigured= !configure;
- }
+ protected void setNeedsToBeConfigured(boolean configure) {
+ fConfigured = !configure;
+ }
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java
index b75d9fe..dfbf9f9 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java
@@ -507,9 +507,7 @@
}
private void setPropertiesFromFiles(Project project, List<Properties> allProperties) {
- Iterator<Properties> iter = allProperties.iterator();
- while (iter.hasNext()) {
- Properties props = iter.next();
+ for (Properties props : allProperties) {
Enumeration<?> propertyNames = props.propertyNames();
while (propertyNames.hasMoreElements()) {
String name = (String) propertyNames.nextElement();
@@ -1552,7 +1550,7 @@
}
}
- protected void removeDefinerTasks(String definerIdentifier, Hashtable<String, Class<?>> typeTable) {
+ protected void removeDefinerTasks(String definerIdentifier, Hashtable<String, AntTypeDefinition> typeTable) {
if (fDefinerNodeIdentifierToDefinedTasks == null) {
return;
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java
index 3e5a311..0d11caf 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java
@@ -46,6 +46,7 @@
*
* @see org.apache.tools.ant.PropertyHelper.PropertySetter#setNew(java.lang.String, java.lang.Object, org.apache.tools.ant.PropertyHelper)
*/
+ @Override
public boolean setNew(String property, Object value, PropertyHelper propertyHelper) {
setNewProperty(property, value.toString());
return false;
@@ -56,6 +57,7 @@
*
* @see org.apache.tools.ant.PropertyHelper.PropertySetter#set(java.lang.String, java.lang.Object, org.apache.tools.ant.PropertyHelper)
*/
+ @Override
public boolean set(String property, Object value, PropertyHelper propertyHelper) {
return false;
}
@@ -167,14 +169,14 @@
* @see org.apache.tools.ant.Project#getReference(java.lang.String)
*/
@Override
- public Object getReference(String key) {
- Object ref = super.getReference(key);/* references.get(key); */
+ public <T> T getReference(String key) {
+ T ref = super.getReference(key);/* references.get(key); */
if (ref == null) {
- ref = idrefs.get(key);
+ ref = (T) idrefs.get(key);
if (ref instanceof UnknownElement) {
UnknownElement ue = (UnknownElement) ref;
ue.maybeConfigure();
- return ue.getRealThing();
+ return (T) ue.getRealThing();
}
}
return ref;
@@ -186,9 +188,9 @@
* @see org.apache.tools.ant.Project#getProperties()
*/
@Override
- public Hashtable getProperties() {
+ public Hashtable<String, Object> getProperties() {
// override as we cannot remove properties from the Apache Ant project
- Hashtable<String, String> allProps = super.getProperties();
+ Hashtable<String, Object> allProps = super.getProperties();
allProps.putAll(getUserProperties());
allProps.put("basedir", getBaseDir().getPath()); //$NON-NLS-1$
return allProps;
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTargetNode.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTargetNode.java
index f7de446..4106554 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTargetNode.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTargetNode.java
@@ -116,7 +116,7 @@
@Override
public void reset() {
super.reset();
- Map<String, Object> currentTargets = fTarget.getProject().getTargets();
+ Map<String, Target> currentTargets = fTarget.getProject().getTargets();
if (currentTargets.get(fTarget.getName()) != null) {
currentTargets.remove(fTarget.getName());
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java
index 5f5efeb..41fb0c9 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java
@@ -155,12 +155,12 @@
@Override
public boolean containsOccurrence(String identifier) {
RuntimeConfigurable wrapper = getTask().getRuntimeConfigurableWrapper();
- Map<String, String> attributeMap = wrapper.getAttributeMap();
+ Map<String, Object> attributeMap = wrapper.getAttributeMap();
Set<String> keys = attributeMap.keySet();
boolean lookingForProperty = identifier.startsWith("${") && identifier.endsWith("}"); //$NON-NLS-1$ //$NON-NLS-2$
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
String key = iter.next();
- String value = attributeMap.get(key);
+ String value = (String) attributeMap.get(key);
if (lookingForProperty && (key.equals("if") || key.equals("unless"))) { //$NON-NLS-1$ //$NON-NLS-2$
if (value.indexOf(identifier.substring(2, identifier.length() - 1)) != -1) {
return true;
@@ -187,12 +187,12 @@
}
List<Integer> results = new ArrayList<Integer>();
RuntimeConfigurable wrapper = getTask().getRuntimeConfigurableWrapper();
- Map<String, String> attributeMap = wrapper.getAttributeMap();
+ Map<String, Object> attributeMap = wrapper.getAttributeMap();
Set<String> keys = attributeMap.keySet();
String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
String key = iter.next();
- String value = attributeMap.get(key);
+ String value = (String) attributeMap.get(key);
int identifierCorrection = 1;
if (value.indexOf(identifier) != -1) {
int keyOffset = textToSearch.indexOf(key);
diff --git a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF
index d829059..7e04a28 100644
--- a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF
+++ b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF
@@ -32,7 +32,7 @@
org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.eclipse.ui.editors;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
- org.apache.ant;bundle-version="1.8.4",
+ org.apache.ant;bundle-version="1.9.2",
org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.0.0,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
diff --git a/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/inputhandler/SWTInputHandler.java b/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/inputhandler/SWTInputHandler.java
index 650fe6d..feacb86 100644
--- a/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/inputhandler/SWTInputHandler.java
+++ b/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/inputhandler/SWTInputHandler.java
@@ -12,8 +12,6 @@
package org.eclipse.ant.internal.ui.antsupport.inputhandler;
-import java.util.Iterator;
-
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.input.DefaultInputHandler;
import org.apache.tools.ant.input.InputRequest;
@@ -125,9 +123,8 @@
if (fRequest instanceof MultipleChoiceInputRequest) {
fCombo = new Combo(fDialog, SWT.BORDER | SWT.READ_ONLY);
fCombo.add(""); //$NON-NLS-1$
- // TODO ANT-1.9.1 API USE
- for (Iterator<?> i = ((MultipleChoiceInputRequest) fRequest).getChoices().iterator(); i.hasNext();) {
- fCombo.add((String) i.next());
+ for (String text : ((MultipleChoiceInputRequest) fRequest).getChoices()) {
+ fCombo.add(text);
fCombo.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
fCombo.addSelectionListener(new SelectionAdapter() {
@Override