diff --git a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java index 6f3a808..779192a 100644 --- a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java +++ b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java @@ -201,7 +201,7 @@ public void shrinkAll(Map> newToOldMethodExecutionMap) { List refs = getReferences(); List collectionReferences = collectCollectionReferences(refs); - List> collectionChains = collectCollectionChains(collectionReferences); + List> collectionChains = collectCollectionChains(collectionReferences, newToOldMethodExecutionMap); refs = replaceCollectionChains(refs, collectionChains); refs = replaceStaticObjectIds(refs); references = new HashSet<>(refs); // Convert to Set from List. @@ -237,7 +237,7 @@ return collectionRefs; } - private List> collectCollectionChains(List collectionReferences) { + private List> collectCollectionChains(List collectionReferences, Map> newToOldMethodExecutionMap) { // Collect follow references. List collectionRefs = new ArrayList<>(collectionReferences); // Create new instance of coping collectionReference. List> collectionChains = new ArrayList<>(); @@ -247,21 +247,30 @@ Reference ref = collectionRefs.get(i); String srcClassName = ref.getSrcClassName(); String srcObjId = ref.getSrcObjectId(); - boolean isFirstRef = true; - // If dstClassName matches "$[1-9]" and don't shrink References too much(JHotDrawTransform). - if (!ref.getDstClassName().matches(".*\\$[0-9]+.*")) { - for (int j = 0; j < collectionReferences.size(); j++) { - if (collectionReferences.indexOf(ref) != j) { - Reference compareRef = collectionReferences.get(j); - if (srcClassName.equals(compareRef.getDstClassName()) - && srcObjId.equals(compareRef.getDstObjectId())) { - isFirstRef = false; - break; - } - } - } + boolean isShrinked = false; + for (MethodExecution me: newToOldMethodExecutionMap.keySet()) { + if (srcObjId.equals(me.getThisObjId())) { + isShrinked = true; + break; + } } - if (isFirstRef) { + boolean isFirstRef = true; + if (isShrinked) { + // If dstClassName matches "$[1-9]" and don't shrink References too much(JHotDrawTransform). + if (!ref.getDstClassName().matches(".*\\$[0-9]+.*")) { + for (int j = 0; j < collectionReferences.size(); j++) { + if (collectionReferences.indexOf(ref) != j) { + Reference compareRef = collectionReferences.get(j); + if (srcClassName.equals(compareRef.getDstClassName()) + && srcObjId.equals(compareRef.getDstObjectId())) { + isFirstRef = false; + break; + } + } + } + } + } + if (isShrinked && isFirstRef) { List collectionChain = new ArrayList<>(); collectionChain.add(ref); collectionChains.add(collectionChain);