Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.eclipse.jdt.graph
Class DependGraphAction  view DependGraphAction download DependGraphAction.java

java.lang.Object
  extended bycom.port80.eclipse.jdt.graph.DependGraphAction
All Implemented Interfaces:
org.eclipse.ui.IActionDelegate, org.eclipse.ui.IWorkbenchWindowActionDelegate

public class DependGraphAction
extends java.lang.Object
implements org.eclipse.ui.IWorkbenchWindowActionDelegate

Extract an method call graph in UML like format for a given set of classes ('selected' objects). Each vertex represent either a caller or a callee. Caller is a method or a class labelled with method that calls external methods. Callee is method that is called by a caller. Edges of type '-hasCalls' represent calls from the caller vertex to the callee vertex. Edges of type '-typehier' represent type herierhical from superclass to derived classes. Edges of type '-implemented' represent that the head vertex (method) implements tail vertex (interface).


Nested Class Summary
(package private)  class DependGraphAction.ClassCallGraphBuilder
          Find type references in a compiled AST.
private  class DependGraphAction.DependGraphRunnable
           
(package private)  class DependGraphAction.MethodCallGraphBuilder
          Find method references in a compiled AST.
(package private) static class DependGraphAction.Options
           
(package private)  class DependGraphAction.ReferenceGraphBuilder
           
 
Field Summary
private static java.lang.String COLOR_CALLEE
           
private static java.awt.Color COLOR_CALLEE_CLASS
           
private static java.awt.Color COLOR_CALLEE_INTERFACE
           
private static java.awt.Color COLOR_CALLEE_METHOD
           
private static java.lang.String COLOR_CALLEE_PARAMS
           
private static java.awt.Color COLOR_CLASS
           
private static java.awt.Color COLOR_CONSTRUCTOR
           
private static java.awt.Color COLOR_IMPLEMENTED
           
private static java.awt.Color COLOR_INTERFACE
           
private static java.awt.Color COLOR_METHOD
           
private static java.awt.Color COLOR_NESTED_CLASS
           
private static java.awt.Color COLOR_OVERRIDEN
           
private static java.lang.String COLOR_PACKAGE
           
private static java.lang.String COLOR_PRIVATE
           
private static java.lang.String COLOR_PROTECTED
           
private static java.lang.String COLOR_PUBLIC
           
private static java.awt.Color COLOR_SUPERCLASS
           
private static java.awt.Color COLOR_SUPERINTERFACE
           
private static java.awt.Color COLOR_TOP
           
private static java.awt.Color COLOR_UNCONNECTED
           
private static boolean DEBUG
           
(package private)  com.port80.graph.IGraph fGraph
           
(package private)  DependGraphAction.Options fOptions
           
(package private)  java.lang.String fOutDir
           
(package private)  org.eclipse.jdt.core.ISourceRange fParsingErrorRange
           
(package private)  java.lang.Object[] fSelected
           
private static int MAX_LABELWIDTH
           
private static java.lang.String NAME
           
private static java.lang.String STYLE
           
private static java.lang.String STYLE_CALLEE
           
private static java.lang.String STYLE_IMPLEMENTED
           
private static java.lang.String STYLE_OVERRIDEN
           
private static java.lang.String STYLE_SUPERCLASS
           
private static java.lang.String STYLE_SUPERINTERFACE
           
private static java.lang.String STYLE_TOP
           
private static java.lang.String STYLE_UNCONNECTED
           
private static boolean VERBOSE
           
 
Constructor Summary
DependGraphAction()
           
 
Method Summary
private  void addCallees(java.util.Set callees, java.lang.StringBuffer label, com.port80.graph.IVertex v)
           
(package private)  void addSyntheticMethod(MethodWrapper method, com.port80.graph.IGraph graph, java.util.Map filemap)
          Reference to method of selected classes.
(package private)  com.port80.graph.IGraph classCallGraph(java.lang.Object[] selected, org.eclipse.core.runtime.IProgressMonitor monitor)
          Construct class dependency graph between classes in given objects base on method calls.
private  void connectImplemented(java.util.Set implemented, com.port80.graph.IVertex src, com.port80.graph.IGraph graph)
          Connect method to interfaces that it implements.
private  void connectInheritance(com.port80.graph.IVertex src, com.port80.graph.IGraph graph)
          Create edge to superclass and superinterfaces.
(package private)  void createSuperVertices(java.util.Set types, com.port80.graph.IGraph graph)
          Create vertices for each superclass and superinterface.
(package private)  com.port80.graph.IVertex createVertex(java.lang.Object wrapper, com.port80.graph.IGraph graph)
          Create a vertex for the caller (type/method) if not exists, otherwise return existing vertex.
 void dispose()
          We can use this method to dispose of any system resources we previously allocated.
(package private)  java.lang.String filterType(java.lang.String typename)
          Filter out references to predefined packages.
(package private)  void findImplemented(MethodWrapper method, com.port80.graph.IVertex vertex, com.port80.graph.IGraph graph)
          Find all interfaces that the method implement.
private  void findSuperConnected(com.port80.graph.IVertex vertex, com.port80.graph.IGraph graph, java.util.Set ret)
          Find all vertices that can be reached by the super classes of the given vertices.
(package private)  java.util.Set findSupers(TypeWrapper type, com.port80.graph.IVertex v)
          Find superclass and super interfaces for the given type and added them to the given vertex.
private  java.util.Set getDeclaredMethodSignatures(org.eclipse.jdt.core.dom.ITypeBinding type, java.util.Set ret)
           
 void init(org.eclipse.ui.IWorkbenchWindow window)
          We will cache window object in order to be able to provide parent shell for the message dialog.
(package private)  com.port80.graph.IGraph methodCallGraph(java.lang.Object[] selected, org.eclipse.core.runtime.IProgressMonitor monitor)
           
(package private)  com.port80.graph.IGraph referenceGraph(java.lang.Object[] selected, org.eclipse.core.runtime.IProgressMonitor monitor)
          Construct class dependency graph between classes in given objects base on type references.
private  void removeInheritedDepends(com.port80.graph.IVertex vertex, com.port80.graph.IGraph graph, java.util.Map filemap)
          Remove self edge and dependency that are already present in super classes.
 void run(org.eclipse.jface.action.IAction action)
          The action has been activated.
private  void saveGraph(com.port80.graph.IGraph graph)
           
 void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection)
          Selection in the workbench has been changed.
private  void setCalleeStyle(com.port80.graph.IVertex v)
           
private  java.lang.String wrapParam(java.lang.String params, int max)
          Breakup param string to fit in given line width.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

VERBOSE

private static final boolean VERBOSE
See Also:
Constant Field Values

COLOR_TOP

private static final java.awt.Color COLOR_TOP

COLOR_UNCONNECTED

private static final java.awt.Color COLOR_UNCONNECTED

COLOR_NESTED_CLASS

private static final java.awt.Color COLOR_NESTED_CLASS

COLOR_CLASS

private static final java.awt.Color COLOR_CLASS

COLOR_INTERFACE

private static final java.awt.Color COLOR_INTERFACE

COLOR_METHOD

private static final java.awt.Color COLOR_METHOD

COLOR_CONSTRUCTOR

private static final java.awt.Color COLOR_CONSTRUCTOR

COLOR_CALLEE_CLASS

private static final java.awt.Color COLOR_CALLEE_CLASS

COLOR_CALLEE_INTERFACE

private static final java.awt.Color COLOR_CALLEE_INTERFACE

COLOR_CALLEE_METHOD

private static final java.awt.Color COLOR_CALLEE_METHOD

COLOR_SUPERCLASS

private static final java.awt.Color COLOR_SUPERCLASS

COLOR_SUPERINTERFACE

private static final java.awt.Color COLOR_SUPERINTERFACE

COLOR_OVERRIDEN

private static final java.awt.Color COLOR_OVERRIDEN

COLOR_IMPLEMENTED

private static final java.awt.Color COLOR_IMPLEMENTED

STYLE_UNCONNECTED

private static final java.lang.String STYLE_UNCONNECTED
See Also:
Constant Field Values

STYLE_SUPERCLASS

private static final java.lang.String STYLE_SUPERCLASS
See Also:
Constant Field Values

STYLE_SUPERINTERFACE

private static final java.lang.String STYLE_SUPERINTERFACE
See Also:
Constant Field Values

STYLE_OVERRIDEN

private static final java.lang.String STYLE_OVERRIDEN
See Also:
Constant Field Values

STYLE_IMPLEMENTED

private static final java.lang.String STYLE_IMPLEMENTED
See Also:
Constant Field Values

STYLE

private static final java.lang.String STYLE
See Also:
Constant Field Values

STYLE_CALLEE

private static final java.lang.String STYLE_CALLEE
See Also:
Constant Field Values

STYLE_TOP

private static final java.lang.String STYLE_TOP
See Also:
Constant Field Values

MAX_LABELWIDTH

private static final int MAX_LABELWIDTH
See Also:
Constant Field Values

COLOR_CALLEE

private static final java.lang.String COLOR_CALLEE
See Also:
Constant Field Values

COLOR_CALLEE_PARAMS

private static final java.lang.String COLOR_CALLEE_PARAMS
See Also:
Constant Field Values

COLOR_PUBLIC

private static final java.lang.String COLOR_PUBLIC
See Also:
Constant Field Values

COLOR_PROTECTED

private static final java.lang.String COLOR_PROTECTED
See Also:
Constant Field Values

COLOR_PACKAGE

private static final java.lang.String COLOR_PACKAGE
See Also:
Constant Field Values

COLOR_PRIVATE

private static final java.lang.String COLOR_PRIVATE
See Also:
Constant Field Values

fGraph

com.port80.graph.IGraph fGraph

fSelected

java.lang.Object[] fSelected

fOptions

DependGraphAction.Options fOptions

fParsingErrorRange

org.eclipse.jdt.core.ISourceRange fParsingErrorRange

fOutDir

java.lang.String fOutDir
Constructor Detail

DependGraphAction

public DependGraphAction()
Method Detail

run

public void run(org.eclipse.jface.action.IAction action)
The action has been activated. The argument of the method represents the 'real' action sitting in the workbench UI.

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

saveGraph

private void saveGraph(com.port80.graph.IGraph graph)

selectionChanged

public void selectionChanged(org.eclipse.jface.action.IAction action,
                             org.eclipse.jface.viewers.ISelection selection)
Selection in the workbench has been changed. We can change the state of the 'real' action here if we want, but this can only happen after the delegate has been created.

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

dispose

public void dispose()
We can use this method to dispose of any system resources we previously allocated.

Specified by:
dispose in interface org.eclipse.ui.IWorkbenchWindowActionDelegate

init

public void init(org.eclipse.ui.IWorkbenchWindow window)
We will cache window object in order to be able to provide parent shell for the message dialog.

Specified by:
init in interface org.eclipse.ui.IWorkbenchWindowActionDelegate

referenceGraph

com.port80.graph.IGraph referenceGraph(java.lang.Object[] selected,
                                       org.eclipse.core.runtime.IProgressMonitor monitor)
Construct class dependency graph between classes in given objects base on type references.


classCallGraph

com.port80.graph.IGraph classCallGraph(java.lang.Object[] selected,
                                       org.eclipse.core.runtime.IProgressMonitor monitor)
Construct class dependency graph between classes in given objects base on method calls.


methodCallGraph

com.port80.graph.IGraph methodCallGraph(java.lang.Object[] selected,
                                        org.eclipse.core.runtime.IProgressMonitor monitor)

findSupers

java.util.Set findSupers(TypeWrapper type,
                         com.port80.graph.IVertex v)
Find superclass and super interfaces for the given type and added them to the given vertex. v.getAttr("-superClasses")=Set of full typename of all super classes. v.getAttr("-superInterfaces")=Set of full typename of all super interfaces.


findImplemented

void findImplemented(MethodWrapper method,
                     com.port80.graph.IVertex vertex,
                     com.port80.graph.IGraph graph)
Find all interfaces that the method implement.


createSuperVertices

void createSuperVertices(java.util.Set types,
                         com.port80.graph.IGraph graph)
Create vertices for each superclass and superinterface.


addSyntheticMethod

void addSyntheticMethod(MethodWrapper method,
                        com.port80.graph.IGraph graph,
                        java.util.Map filemap)
Reference to method of selected classes. . Any such methods should be added when processing the declared methods so should be ignored where referenced except for methods that are synthetic. Synthetic methods are not declared and so we need to create the method vertex for them when they are being referenced.


createVertex

com.port80.graph.IVertex createVertex(java.lang.Object wrapper,
                                      com.port80.graph.IGraph graph)
Create a vertex for the caller (type/method) if not exists, otherwise return existing vertex.


filterType

java.lang.String filterType(java.lang.String typename)
Filter out references to predefined packages.


findSuperConnected

private void findSuperConnected(com.port80.graph.IVertex vertex,
                                com.port80.graph.IGraph graph,
                                java.util.Set ret)
Find all vertices that can be reached by the super classes of the given vertices.


getDeclaredMethodSignatures

private java.util.Set getDeclaredMethodSignatures(org.eclipse.jdt.core.dom.ITypeBinding type,
                                                  java.util.Set ret)

setCalleeStyle

private void setCalleeStyle(com.port80.graph.IVertex v)

wrapParam

private java.lang.String wrapParam(java.lang.String params,
                                   int max)
Breakup param string to fit in given line width.


removeInheritedDepends

private void removeInheritedDepends(com.port80.graph.IVertex vertex,
                                    com.port80.graph.IGraph graph,
                                    java.util.Map filemap)
Remove self edge and dependency that are already present in super classes. Color the edges that involve inheritance.


connectInheritance

private void connectInheritance(com.port80.graph.IVertex src,
                                com.port80.graph.IGraph graph)
Create edge to superclass and superinterfaces.


connectImplemented

private void connectImplemented(java.util.Set implemented,
                                com.port80.graph.IVertex src,
                                com.port80.graph.IGraph graph)
Connect method to interfaces that it implements.


addCallees

private void addCallees(java.util.Set callees,
                        java.lang.StringBuffer label,
                        com.port80.graph.IVertex v)