diff --git a/src/org/ntlab/deltaViewer/CollaborationViewer.java b/src/org/ntlab/deltaViewer/CollaborationViewer.java index 9b9ef31..671fce7 100644 --- a/src/org/ntlab/deltaViewer/CollaborationViewer.java +++ b/src/org/ntlab/deltaViewer/CollaborationViewer.java @@ -48,7 +48,7 @@ public void init(IObjectCallGraph objectCallGraph, IAliasCollector aliasCollector, IObjectLayout layout) { this.objectCallGraph = objectCallGraph; this.aliasCollector = aliasCollector; - createObjectVertices(this.objectCallGraph); + createObjectVertices(this.objectCallGraph, aliasCollector); layout.execute(objectCallGraph, aliasCollector, objectToVertexMap); createEdgeToObject(this.objectCallGraph, this.aliasCollector); } @@ -345,8 +345,9 @@ * Create vertices(mxGraph) and OvjectVerticies in {@code objectToVertexMap}. Vertices(mxGraph) coordinate are appropriate. * * @param objectCallGraph + * @param aliasCollector */ - private void createObjectVertices(IObjectCallGraph objectCallGraph) { + private void createObjectVertices(IObjectCallGraph objectCallGraph, IAliasCollector aliasCollector) { //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); try { @@ -408,6 +409,17 @@ } } } + for (Alias alias: aliasCollector.getAliasList()) { + if (alias.getAliasType() == Alias.AliasType.THIS) { + if (!objectToVertexMap.containsKey(alias.getObjectId())) { + // When both of the calling and called method are static. + String thisObjId = alias.getObjectId(); + String thisClassName = alias.getMethodExecution().getThisClassName(); + mxICell vertex = (mxICell) mxgraph.insertDeltaVertex(getMxDefaultParent(), thisObjId, thisClassName, 0, 0, objecVertexWidth, ObjectVertexHeight, "fillColor=white"); //creates a white vertex. + objectToVertexMap.put(thisObjId, new ObjectVertex(thisClassName, vertex, 0, 0)); + } + } + } } finally { mxgraph.getModel().endUpdate(); } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index e46c165..c05b330 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -36,6 +36,7 @@ import org.ntlab.trace.ObjectReference; import org.ntlab.trace.Reference; import org.ntlab.trace.Statement; +import org.ntlab.trace.Trace; import org.ntlab.trace.TracePoint; import com.mxgraph.canvas.mxGraphics2DCanvas; @@ -233,6 +234,9 @@ ObjectVertex objectVertex = objectToVertexMap.get(alias.getObjectId()); MethodExecution methodExec = alias.getMethodExecution(); String srcObjId = alias.getMethodExecution().getThisObjId(); + if (Trace.isNull(srcObjId)) { + srcObjId += ":" + alias.getMethodExecution().getThisClassName(); + } mxICell srcCell = (mxICell)objectToVertexMap.get(srcObjId).getCell(); double srcWidth = srcCell.getGeometry().getWidth(); double srcHeight = srcCell.getGeometry().getHeight(); @@ -878,8 +882,12 @@ methodSignature = formatMethodSignature(methodSignature, methodExecution.getThisClassName()); } + //�@Why is the following code needed? if (methodExecution.isStatic() && !objectId.equals("0")) { objectId = methodExecution.getCallerMethodExecution().getThisObjId(); + if (objectId.matches("0")) { + objectId += ":" + methodExecution.getCallerMethodExecution().getThisClassName(); + } } mxICell parentCell = (mxICell) objectToVertexMap.get(objectId).getCell(); @@ -1196,7 +1204,12 @@ if (!calledMethodExecution.isStatic()) { objectToVertexMap.get(calledMethodExecution.getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExecution)); } else { - objectToVertexMap.get(calledMethodExecution.getCallerMethodExecution().getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExecution)); + // Why is this object id of the caller method used? + String objId = calledMethodExecution.getCallerMethodExecution().getThisObjId(); + if (objId.matches("0")) { + objId += ":" + calledMethodExecution.getCallerMethodExecution().getThisClassName(); + } + objectToVertexMap.get(objId).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExecution)); } methodExecToVertexMap.get(calledMethodExecution).getLocals().remove(sourceObjectVertex); methodExecToVertexMap.remove(calledMethodExecution);