diff --git a/src/org/ntlab/deltaViewer/CollaborationLayout.java b/src/org/ntlab/deltaViewer/CollaborationLayout.java index 6b428c8..bf3aad3 100644 --- a/src/org/ntlab/deltaViewer/CollaborationLayout.java +++ b/src/org/ntlab/deltaViewer/CollaborationLayout.java @@ -21,6 +21,7 @@ import org.ntlab.trace.MethodInvocation; import org.ntlab.trace.Reference; import org.ntlab.trace.Statement; +import org.ntlab.trace.TracePoint; import com.mxgraph.model.mxICell; import com.mxgraph.util.mxPoint; @@ -37,37 +38,48 @@ padding = 200; // Extract the bottom reference. - Statement relatedSt = objectCallGraph.getRelatedPoints().get(objectCallGraph.getRelatedPoints().size() - 1).getStatement(); + TracePoint relatedPt = objectCallGraph.getRelatedPoints().get(objectCallGraph.getRelatedPoints().size() - 1); + Statement relatedSt = relatedPt.getStatement(); String bottomSrcObjId = null; String bottomDstObjId = null; - if (relatedSt instanceof FieldUpdate) { - // container to component - bottomSrcObjId = ((FieldUpdate) relatedSt).getContainerObjId(); - bottomDstObjId = ((FieldUpdate) relatedSt).getValueObjId(); - } else if (relatedSt instanceof ArrayUpdate) { - // container to component - bottomSrcObjId = ((ArrayUpdate) relatedSt).getArrayObjectId(); - bottomDstObjId = ((ArrayUpdate) relatedSt).getValueObjectId(); - } else if (relatedSt instanceof MethodInvocation) { - MethodInvocation methodInvStatement = (MethodInvocation) relatedSt; - MethodExecution calledMethodExec = methodInvStatement.getCalledMethodExecution(); - String methodSignature = calledMethodExec.getSignature(); - if (calledMethodExec.isCollectionType() - && (methodSignature.contains("add(") - || methodSignature.contains("set(") - || methodSignature.contains("put(") - || methodSignature.contains("push(") - || methodSignature.contains("addElement("))) { - // container to component - bottomSrcObjId = calledMethodExec.getThisObjId(); - bottomDstObjId = calledMethodExec.getArguments().get(0).getId(); - } else { - // this to another - bottomSrcObjId = methodInvStatement.getThisObjId(); - bottomDstObjId = calledMethodExec.getReturnValue().getId(); + if (relatedPt.isMethodEntry()) { + // this to another (parameter) + Alias lastAlias = aliasCollector.getAliasList().get(aliasCollector.getAliasList().size() - 1); + if (lastAlias.getAliasType() == Alias.AliasType.FORMAL_PARAMETER) { + bottomSrcObjId = relatedPt.getMethodExecution().getThisObjId(); + bottomDstObjId = lastAlias.getObjectId(); } - } else { - return; + } + if (bottomSrcObjId == null || bottomDstObjId == null) { + if (relatedSt instanceof FieldUpdate) { + // container to component + bottomSrcObjId = ((FieldUpdate) relatedSt).getContainerObjId(); + bottomDstObjId = ((FieldUpdate) relatedSt).getValueObjId(); + } else if (relatedSt instanceof ArrayUpdate) { + // container to component + bottomSrcObjId = ((ArrayUpdate) relatedSt).getArrayObjectId(); + bottomDstObjId = ((ArrayUpdate) relatedSt).getValueObjectId(); + } else if (relatedSt instanceof MethodInvocation) { + MethodInvocation methodInvStatement = (MethodInvocation) relatedSt; + MethodExecution calledMethodExec = methodInvStatement.getCalledMethodExecution(); + String methodSignature = calledMethodExec.getSignature(); + if (calledMethodExec.isCollectionType() + && (methodSignature.contains("add(") + || methodSignature.contains("set(") + || methodSignature.contains("put(") + || methodSignature.contains("push(") + || methodSignature.contains("addElement("))) { + // container to component + bottomSrcObjId = calledMethodExec.getThisObjId(); + bottomDstObjId = calledMethodExec.getArguments().get(0).getId(); + } else { + // this to another + bottomSrcObjId = methodInvStatement.getThisObjId(); + bottomDstObjId = calledMethodExec.getReturnValue().getId(); + } + } else { + return; + } } // Extract the reference access history.