incubator-easyant-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kpsiddha...@apache.org
Subject svn commit: r1135994 - in /incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache: ant/debugger/ tools/ant/ tools/ant/listener/
Date Wed, 15 Jun 2011 11:03:55 GMT
Author: kpsiddharth
Date: Wed Jun 15 11:03:55 2011
New Revision: 1135994

URL: http://svn.apache.org/viewvc?rev=1135994&view=rev
Log:
Some formatting, message and command name changes.

Modified:
    incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugCommandSet.java
    incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugSupport.java
    incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DefaultAuditor.java
    incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/Inspector.java
    incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/Locator.java
    incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/listener/DebuggerListener.java

Modified: incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugCommandSet.java
URL: http://svn.apache.org/viewvc/incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugCommandSet.java?rev=1135994&r1=1135993&r2=1135994&view=diff
==============================================================================
--- incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugCommandSet.java
(original)
+++ incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugCommandSet.java
Wed Jun 15 11:03:55 2011
@@ -4,13 +4,19 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 
 /**
- * Handles all debug support functionality.
+ * Handles all debug support functionality. This is initialized by the
+ * {@link #init(Map)} method which accepts a set of {@link DebugSupport}
+ * instances. Additionally, it reads and initializes a set of commands from
+ * debug-support.properties for further support. New commands may be added by
+ * making entries in the said file.
  */
 public class DebugCommandSet {
 
@@ -66,7 +72,8 @@ public class DebugCommandSet {
 		} catch (IOException ioe) {
 			// if the resource could not be located, then initialize with what
 			// is known
-			throw new RuntimeException(ioe);
+			throw new BuildException(
+					"Could not locate debug-support.properties");
 		}
 	}
 
@@ -85,6 +92,7 @@ public class DebugCommandSet {
 		if (selected != null) {
 			selected.execute(project, tokens);
 		} else {
+			project.log("'" + command + "' not a recognized command.");
 			printUsage();
 		}
 	}
@@ -92,9 +100,12 @@ public class DebugCommandSet {
 	protected void printUsage() {
 		// log all help stuff here
 		project
-				.log("You may use one of the following commands: locate, inspect, return");
-		project
-				.log("Type the command followed by /? for more information. Eg. inspect /?");
+				.log("Use one of the following commands. Type the command followed by /? for further
help on the command.");
+		Iterator it = commandSupport.keySet().iterator();
+		while (it.hasNext()) {
+			String command = (String) it.next();
+			project.log("  - " + command);
+		}
 	}
 
 }

Modified: incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugSupport.java
URL: http://svn.apache.org/viewvc/incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugSupport.java?rev=1135994&r1=1135993&r2=1135994&view=diff
==============================================================================
--- incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugSupport.java
(original)
+++ incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DebugSupport.java
Wed Jun 15 11:03:55 2011
@@ -3,19 +3,11 @@ package org.apache.ant.debugger;
 import org.apache.tools.ant.Project;
 
 /**
- * An interface for supporting debug commands.
+ * An interface for supporting debug commands. All debug commands MUST implement this interface.
  */
 public interface DebugSupport {
 
 	/**
-	 * Check if this command is supported.
-	 * 
-	 * @param command
-	 * @return
-	 */
-	public boolean commandSupported(String command);
-
-	/**
 	 * Main execution body of the class. Pass all command parameters.
 	 * 
 	 * @param project

Modified: incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DefaultAuditor.java
URL: http://svn.apache.org/viewvc/incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DefaultAuditor.java?rev=1135994&r1=1135993&r2=1135994&view=diff
==============================================================================
--- incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DefaultAuditor.java
(original)
+++ incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/DefaultAuditor.java
Wed Jun 15 11:03:55 2011
@@ -14,9 +14,9 @@ import org.apache.tools.ant.PropertyHelp
  * acts as a Debug command permitting the recorded audits to be available on
  * user commands.
  * <p />
- * Optionally, this class allows a {@link DebugPrompt} instance to attach itself to
- * this auditor, so that if change to a certain property is attempted, then the
- * debugger may be chosen to be transferred the control to.
+ * Optionally, this class allows a {@link DebugPrompt} instance to attach itself
+ * to this auditor, so that if change to a certain property is attempted, then
+ * the debugger may be chosen to be transferred the control to.
  */
 public class DefaultAuditor implements Auditor, DebugSupport {
 
@@ -67,13 +67,15 @@ public class DefaultAuditor implements A
 		return (List) propertyaudits.get(key);
 	}
 
-	public boolean commandSupported(String command) {
-		return "trace".equals(command);
-	}
-
 	public void execute(Project project, String[] params) {
+		if (params.length > 1 && "/?".equals(params[1])) {
+			printUsage(project);
+			return;
+		}
 		if (params.length != 2) {
+			project.log("Incorrect Parameters");
 			printUsage(project);
+			return;
 		}
 
 		String property = params[1];
@@ -92,7 +94,9 @@ public class DefaultAuditor implements A
 	}
 
 	public void printUsage(Project project) {
-		project.log("Some HelpFul Message here");
+		project.log("Usage: trace some.property");
+		project
+				.log("The above command will return all modification attempts on the specified property.");
 	}
 
 }

Modified: incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/Inspector.java
URL: http://svn.apache.org/viewvc/incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/Inspector.java?rev=1135994&r1=1135993&r2=1135994&view=diff
==============================================================================
--- incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/Inspector.java
(original)
+++ incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/ant/debugger/Inspector.java
Wed Jun 15 11:03:55 2011
@@ -7,17 +7,19 @@ import org.apache.tools.ant.types.Resour
 import org.apache.tools.ant.util.StringUtils;
 
 /**
- * Inspects the current value of a property, path or some reference.
+ * Inspects the current value of a property or path.
  */
 public class Inspector implements DebugSupport {
 
-	public boolean commandSupported(String command) {
-		return "inspect".equalsIgnoreCase(command);
-	}
-
 	public void execute(Project project, String[] params) {
-		if (params.length < 3 || "/?".equals(params[1])) {
+		if (params.length > 1 && "/?".equals(params[1])) {
+			printUsage(project);
+			return;
+		}
+		if (params.length < 3) {
+			project.log("Incorrect Parameters");
 			printUsage(project);
+			return;
 		}
 
 		if ("property".equalsIgnoreCase(params[1])) {
@@ -53,7 +55,6 @@ public class Inspector implements DebugS
 	}
 
 	public void printUsage(Project project) {
-		project.log("Incorrect Parameters");
 		project.log("Usage: inspect property some.property");
 		project.log("       inspect path path.id");
 	}

Modified: incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/Locator.java
URL: http://svn.apache.org/viewvc/incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/Locator.java?rev=1135994&r1=1135993&r2=1135994&view=diff
==============================================================================
--- incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/Locator.java
(original)
+++ incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/Locator.java
Wed Jun 15 11:03:55 2011
@@ -6,23 +6,24 @@ import java.util.Map;
 
 import org.apache.ant.debugger.DebugSupport;
 import org.apache.ant.debugger.DebugUtils;
-
 import org.apache.tools.ant.taskdefs.Property;
-import org.apache.tools.ant.types.Path;
 
 /**
- * Locates properties / paths in static build sources
+ * Locates properties in static build sources.
+ * 
+ * TODO: See how this can be augmented to support other Tasks.
  */
 public class Locator implements DebugSupport {
 
-	public boolean commandSupported(String command) {
-		return "locate".equalsIgnoreCase(command);
-	}
-
 	public void execute(Project project, String[] params) {
 		// the command syntax is 'locate property some.property'
 		// or 'locate path some.path
-		if (params.length != 3 || "/?".equals(params[1])) {
+		if (params.length > 1 && "/?".equals(params[1])) {
+			printUsage(project);
+			return;
+		}
+		if (params.length != 3) {
+			project.log("Incorrect Parameters");
 			printUsage(project);
 			return;
 		}
@@ -33,10 +34,6 @@ public class Locator implements DebugSup
 			// locate and publish the property
 			matches = DebugUtils.searchTask(Property.class, project);
 			key = "name";
-		} else if ("path".equalsIgnoreCase(params[1])) {
-			// locate and publish the path
-			matches = DebugUtils.searchTask(Path.class, project);
-			key = "id";
 		} else {
 			// see if any other component may be supported
 			project.log("Unexpected component: " + params[1]);
@@ -69,7 +66,6 @@ public class Locator implements DebugSup
 	}
 
 	public void printUsage(Project project) {
-		project.log("Incorrect Parameters");
-		project.log("Usage: locate property/path propertyname/pathname");
+		project.log("Usage: locate property some.property");
 	}
 }
\ No newline at end of file

Modified: incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/listener/DebuggerListener.java
URL: http://svn.apache.org/viewvc/incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/listener/DebuggerListener.java?rev=1135994&r1=1135993&r2=1135994&view=diff
==============================================================================
--- incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/listener/DebuggerListener.java
(original)
+++ incubator/easyant/tasks/trunk/command-line-debugger/src/main/org/apache/tools/ant/listener/DebuggerListener.java
Wed Jun 15 11:03:55 2011
@@ -51,12 +51,18 @@ public class DebuggerListener implements
 
 	/**
 	 * Contains the current target being executed.
+	 * 
+	 * TODO: This is not being used now but there is a possibility for its use.
 	 */
 	protected Target currentTarget = null;
 
 	/**
 	 * An Auditor instance that keeps track of all changes to properties
 	 * identified by the user.
+	 * 
+	 * 
+	 * TODO: The auditor instance itself should be pluggable, I think to allow
+	 * different PropertyHelpers to be used.
 	 */
 	protected Auditor auditor = null;
 
@@ -111,7 +117,8 @@ public class DebuggerListener implements
 		if (auditor instanceof DebugSupport) {
 			Map defaults = new HashMap();
 			defaults.put("trace", auditor);
-			defaults.put("add", this);
+			defaults.put("break", this);
+			defaults.put("watch", this);
 			return defaults;
 		}
 		return null;
@@ -165,41 +172,46 @@ public class DebuggerListener implements
 	 * target/property break points at runtime.
 	 */
 
-	/**
-	 * The current listener as a {@link DebugSupport} command only supports add
-	 * new breakpoints.
+	/*
+	 * TODO INFO command is yet to be implemented. The idea is to output a list
+	 * of all target break points and properties being monitored with their
+	 * statuses (Pending / Done etc).
 	 */
-	public boolean commandSupported(String command) {
-		return "add".equals(command);
-	}
-
 	public void execute(Project project, String[] params) {
-		if (params.length < 3) {
+		if (params.length > 1 && "/?".equals(params[1])) {
 			printUsage(project);
 			return;
 		}
-
-		if (!"property".equals(params[1]) && !"target".equals(params[1])) {
+		if (params.length < 2) {
+			project.log("Incorrect Parameters");
 			printUsage(project);
 			return;
 		}
 
-		boolean isproperty = "property".equals(params[1]);
-		for (int i = 2; i < params.length; i++) {
-			if (isproperty) {
-				// add as a property to be audited
-				auditor.addPropertyForAudits(params[i], project);
-				project.log("Added BreakPoint at Property: " + params[2]);
-			} else {
+		String command = params[0];
+		if ("break".equalsIgnoreCase(command)) {
+			for (int i = 1; i < params.length; i++) {
 				debugtargets.add(params[i]);
-				project.log("Added BreakPoint at Target: " + params[2]);
+				project.log("Added BreakPoint at Target: " + params[i]);
+			}
+		} else if ("watch".equalsIgnoreCase(command)) {
+			/*
+			 * watch points for properties
+			 */
+			for (int i = 1; i < params.length; i++) {
+				auditor.addPropertyForAudits(params[i], project);
+				project.log("Added BreakPoint at Property: " + params[i]);
 			}
+		} else if ("info".equalsIgnoreCase(command)) {
+			// TODO show all break points and watch points here
 		}
 	}
 
 	public void printUsage(Project project) {
+		project.log("Usage: break property some.property.1 some.property.2");
+		project.log("       break target some.target.1 some.target.2");
 		project
-				.log("Some Helpful Message to add debug/property break points at runtime.");
+				.log("The above command will add all properties/targets as breakpoints.");
 	}
 
 }



Mime
View raw message