com.ibm.jdg2e.jdt
Class AddTraceStatementsAction

java.lang.Object
  extended bycom.ibm.jdg2e.jdt.AddTraceStatementsAction
All Implemented Interfaces:
org.eclipse.ui.IActionDelegate
Direct Known Subclasses:
AddTraceStatementsEditorAction, AddTraceStatementToMemberAction

public abstract class AddTraceStatementsAction
extends java.lang.Object
implements org.eclipse.ui.IActionDelegate

The purpose of AddTraceStatementsAction is to demonstrate how to add simple code modifications ("refactoring") to the Java editor. This action is an abstract implementation for those subclasses wishing to add trace statements for each method, including all parameters, one or more methods.

See Also:
IBuffer, JavaCore, IWorkingCopyManager, ICompilationUnit

Constructor Summary
AddTraceStatementsAction()
           
 
Method Summary
protected  void addTraceStatement(org.eclipse.jdt.core.dom.MethodDeclaration md, org.eclipse.jdt.core.IBuffer buffer)
          Adds a garden-variety trace statement to the given method, using System.out.println.
 java.lang.String createTraceStatement(org.eclipse.jdt.core.dom.MethodDeclaration md, java.lang.String source, boolean format)
          Given a MethodDeclaration, return a source System.out.println listing the method name and parameters.
 void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection)
          Selection has changed, the default is to do nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IActionDelegate
run
 

Constructor Detail

AddTraceStatementsAction

public AddTraceStatementsAction()
Method Detail

addTraceStatement

protected void addTraceStatement(org.eclipse.jdt.core.dom.MethodDeclaration md,
                                 org.eclipse.jdt.core.IBuffer buffer)
Adds a garden-variety trace statement to the given method, using System.out.println. Subclasses may override to add more sophisticated trace statements.


createTraceStatement

public java.lang.String createTraceStatement(org.eclipse.jdt.core.dom.MethodDeclaration md,
                                             java.lang.String source,
                                             boolean format)
Given a MethodDeclaration, return a source System.out.println listing the method name and parameters.
 System.out.println("Start " + method + "<" p1 + ">");
 

This method handles the cases where the parameter doesn't understand the toString (or at least tries).


selectionChanged

public void selectionChanged(org.eclipse.jface.action.IAction action,
                             org.eclipse.jface.viewers.ISelection selection)
Selection has changed, the default is to do nothing. Subclasses can override to fit their needs, e.g., test for the type of selection or singularity.

Specified by:
selectionChanged in interface org.eclipse.ui.IActionDelegate