diff --git a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java index 6f0b59d..adda005 100644 --- a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java +++ b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java @@ -58,8 +58,41 @@ * @param e ExtractedStructure to be merged into the field. */ public void merge(ExtractedStructure e) { - references.addAll(e.getDelta().getSrcSide()); - references.addAll(e.getDelta().getDstSide()); +// references.addAll(e.getDelta().getSrcSide()); +// references.addAll(e.getDelta().getDstSide()); + // Prefer isCreatioin() = true references, if references are equal, but isCreation() is different. + for (Reference srcSideRef: e.getDelta().getSrcSide()) { + if (references.contains(srcSideRef)) { + List refs = getReferences(); // Convert to List from Set. + int idx = refs.indexOf(srcSideRef); + Reference ref = refs.get(idx); + if (srcSideRef.isCreation() != ref.isCreation()) { + if (srcSideRef.isCreation()) { + references.remove(ref); + references.add(srcSideRef); + } + } + + } else { + references.add(srcSideRef); + } + } + for (Reference dstSideRef: e.getDelta().getDstSide()) { + if (references.contains(dstSideRef)) { + List refs = getReferences(); // Convert to List from Set. + int idx = refs.indexOf(dstSideRef); + Reference ref = refs.get(idx); + if (dstSideRef.isCreation() != ref.isCreation()) { + if (dstSideRef.isCreation()) { + references.remove(ref); + references.add(dstSideRef); + } + } + + } else { + references.add(dstSideRef); + } + } // There may be bug. (Two object has each coordinator like JHotDraw Transform) MethodExecution thisStartPoint = startPoints.get(0); @@ -149,7 +182,7 @@ } System.out.println("replaceCollectionChains: "); for (Reference ref: references) { - System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + "): " + ref.isCollection()); + System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + "): " + ref.isCollection() + ", " + ref.isCreation()); } }