Index: api/apichanges.xml =================================================================== RCS file: /shared/data/ccvs/repository/debuggerjpda/api/apichanges.xml,v retrieving revision 1.18 diff -u -r1.18 apichanges.xml --- api/apichanges.xml 9 Feb 2007 15:55:30 -0000 1.18 +++ api/apichanges.xml 28 Mar 2007 16:24:42 -0000 @@ -14,7 +14,7 @@ "Portions Copyrighted [year] [name of copyright owner]" The Original Software is NetBeans. The Initial Developer of the Original -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. --> @@ -465,6 +465,31 @@ + + + API for retrieval of method arguments. + + + + + +

+ An access to method arguments in source code is necessary + for cases where we do not have full debug information. +

+

+ Added methods:
+ EditorContext.getArguments() +

+

+ Added classes:
+ EditorContext.MethodArgument +

+
+ + +
+ Index: api/manifest.mf =================================================================== RCS file: /shared/data/ccvs/repository/debuggerjpda/api/manifest.mf,v retrieving revision 1.20 diff -u -r1.20 manifest.mf --- api/manifest.mf 9 Feb 2007 15:55:30 -0000 1.20 +++ api/manifest.mf 28 Mar 2007 16:24:42 -0000 @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.debugger.jpda/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/jpda/Bundle.properties -OpenIDE-Module-Specification-Version: 2.9 +OpenIDE-Module-Specification-Version: 2.10 OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager] Index: api/src/org/netbeans/spi/debugger/jpda/EditorContext.java =================================================================== RCS file: /shared/data/ccvs/repository/debuggerjpda/api/src/org/netbeans/spi/debugger/jpda/EditorContext.java,v retrieving revision 1.10 diff -u -r1.10 EditorContext.java --- api/src/org/netbeans/spi/debugger/jpda/EditorContext.java 9 Feb 2007 15:55:32 -0000 1.10 +++ api/src/org/netbeans/spi/debugger/jpda/EditorContext.java 28 Mar 2007 16:24:42 -0000 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Micro//S ystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Micro//S ystems, Inc. Portions Copyright 1997-2007 Sun * Micro//S ystems, Inc. All Rights Reserved. */ package org.netbeans.spi.debugger.jpda; @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import org.netbeans.api.debugger.jpda.LineBreakpoint; +import org.netbeans.api.debugger.jpda.LocalVariable; import org.netbeans.api.debugger.jpda.Variable; /** @@ -306,6 +307,24 @@ } /** + * Get a list of arguments to the given operation. + * @param url The URL of the source file with the operation + * @param operation The operation + */ + public MethodArgument[] getArguments(String url, Operation operation) { + throw new UnsupportedOperationException("This method is not implemented."); + } + + /** + * Get a list of arguments passed to method located at the given line. + * @param url The URL of the source file + * @param methodLineNumber The line number of the method header + */ + public MethodArgument[] getArguments(String url, int methodLineNumber) { + throw new UnsupportedOperationException("This method is not implemented."); + } + + /** * Adds a property change listener. * * @param l the listener to add @@ -557,6 +576,64 @@ public int hashCode() { return offset; + } + + } + + /** + * Representation of an argument to a method. + */ + public static final class MethodArgument { + + private String name; + private String type; + private Position startPos; + private Position endPos; + + /** + * Creates a new argument. + * @param name The argument name + * @param type The declared type of the argument + * @param startPos Starting position of the argument in the source code + * @param endPos Ending position of the argument in the source code + */ + public MethodArgument(String name, String type, Position startPos, Position endPos) { + this.name = name; + this.type = type; + startPos = startPos; + endPos = endPos; + } + + /** + * Get the name of this argument. + * @return The name. + */ + public String getName() { + return name; + } + + /** + * Get the declared type of this argument. + * @return The declared type. + */ + public String getType() { + return type; + } + + /** + * Get the starting position of this argument in the source code. + * @return The starting position. + */ + public Position getStartPosition() { + return startPos; + } + + /** + * Get the ending position of this argument in the source code. + * @return The ending position. + */ + public Position getEndPosition() { + return endPos; } } Index: test/unit/src/org/netbeans/api/debugger/jpda/ExpressionStepTest.java =================================================================== RCS file: /shared/data/ccvs/repository/debuggerjpda/test/unit/src/org/netbeans/api/debugger/jpda/ExpressionStepTest.java,v retrieving revision 1.2 diff -u -r1.2 ExpressionStepTest.java --- test/unit/src/org/netbeans/api/debugger/jpda/ExpressionStepTest.java 9 Feb 2007 15:55:43 -0000 1.2 +++ test/unit/src/org/netbeans/api/debugger/jpda/ExpressionStepTest.java 28 Mar 2007 16:24:44 -0000 @@ -23,6 +23,8 @@ import org.netbeans.api.debugger.ActionsManager; import org.netbeans.api.debugger.DebuggerManager; import org.netbeans.junit.NbTestCase; +import org.netbeans.spi.debugger.jpda.EditorContext; +import org.netbeans.spi.debugger.jpda.EditorContext.MethodArgument; import org.netbeans.spi.debugger.jpda.EditorContext.Operation; @@ -70,21 +72,25 @@ ActionsManager.ACTION_STEP_OPERATION, "org.netbeans.api.debugger.jpda.testapps.ExpressionStepApp", 30, 14, - "factorial" + "factorial", + null, + new Object[] { "10" } ); stepCheck ( ActionsManager.ACTION_STEP_OPERATION, "org.netbeans.api.debugger.jpda.testapps.ExpressionStepApp", 31, 14, "factorial", - new Object[] {"3628800"} + new Object[] {"3628800"}, + new Object[] { "20" } ); stepCheck ( ActionsManager.ACTION_STEP_OPERATION, "org.netbeans.api.debugger.jpda.testapps.ExpressionStepApp", 31, 30, "factorial", - new Object[] {"2432902008176640000"} + new Object[] {"2432902008176640000"}, + new Object[] { "30" } ); stepCheck ( ActionsManager.ACTION_STEP_OPERATION, @@ -111,14 +117,17 @@ ActionsManager.ACTION_STEP_OPERATION, "org.netbeans.api.debugger.jpda.testapps.ExpressionStepApp", 34, 20, - "m2" + "m2", + null, + new Object[] { "(int) x" } ); stepCheck ( ActionsManager.ACTION_STEP_OPERATION, "org.netbeans.api.debugger.jpda.testapps.ExpressionStepApp", 34, 13, "m1", - new Object[] {"-899453552"} + new Object[] {"-899453552"}, + new Object[] { "exs.m2((int) x)" } ); stepCheck ( @@ -211,14 +220,42 @@ Object[] returnValues ) { stepCheck(stepType, clsExpected, lineExpected, column, methodName); - List ops = support.getDebugger ().getCurrentThread().getLastOperations(); - assertEquals("Different count of last operations and expected return values.", returnValues.length, ops.size()); - for (int i = 0; i < returnValues.length; i++) { - Variable rv = ops.get(i).getReturnValue(); - if (rv != null) { - assertEquals("Bad return value", returnValues[i], rv.getValue()); + if (returnValues != null) { + List ops = support.getDebugger ().getCurrentThread().getLastOperations(); + assertEquals("Different count of last operations and expected return values.", returnValues.length, ops.size()); + for (int i = 0; i < returnValues.length; i++) { + Variable rv = ops.get(i).getReturnValue(); + if (rv != null) { + assertEquals("Bad return value", returnValues[i], rv.getValue()); + } } } } + private void stepCheck ( + Object stepType, + String clsExpected, + int lineExpected, + int column, + String methodName, + Object[] returnValues, + Object[] opArguments + ) { + stepCheck(stepType, clsExpected, lineExpected, column, methodName, returnValues); + Operation currentOp = support.getDebugger ().getCurrentThread().getCurrentOperation(); + MethodArgument[] arguments = getContext().getArguments( + Utils.getURL(sourceRoot + "org/netbeans/api/debugger/jpda/testapps/ExpressionStepApp.java"), + currentOp); + assertEquals("Different count of operation arguments.", opArguments.length, arguments.length); + for (int i = 0; i < opArguments.length; i++) { + assertEquals("Bad method argument", opArguments[i], arguments[i].getName()); + } + } + + private static EditorContext getContext () { + List l = DebuggerManager.getDebuggerManager ().lookup + (null, EditorContext.class); + EditorContext context = (EditorContext) l.get (0); + return context; + } }