diff --git a/src/org/ntlab/deltaExtractor/DeltaExtractor.java b/src/org/ntlab/deltaExtractor/DeltaExtractor.java index 47cb66d..d9b0f78 100644 --- a/src/org/ntlab/deltaExtractor/DeltaExtractor.java +++ b/src/org/ntlab/deltaExtractor/DeltaExtractor.java @@ -858,6 +858,7 @@ private ExtractedStructure extractSub(TracePoint creationTracePoint, Reference targetRef, IAliasCollector aliasCollector) { eStructure = new ExtractedStructure(); + eStructure.setRelatedTracePoint(creationTracePoint); ArrayList objList = new ArrayList(); srcObject = targetRef.getSrcObject(); dstObject = targetRef.getDstObject(); @@ -915,11 +916,12 @@ * @return ���o���� */ public ExtractedStructure extract(TracePoint thisTracePoint, ObjectReference anotherObj, IAliasCollector aliasCollector) { + eStructure = new ExtractedStructure(); + eStructure.setRelatedTracePoint(thisTracePoint); MethodExecution methodExecution = thisTracePoint.getMethodExecution(); if (!thisTracePoint.isMethodEntry()) { thisTracePoint.stepNext(); } - eStructure = new ExtractedStructure(); ArrayList objList = new ArrayList(); String thisObjectId = methodExecution.getThisObjId(); objList.add(thisObjectId); diff --git a/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java b/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java index ff9da6a..940e0e5 100644 --- a/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java +++ b/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java @@ -605,6 +605,7 @@ if (objectId.equals(srcObject.getId())) { r = new Reference(arguments.get(0), srcObject); r.setCollection(true); + r.setCreation(true); // �߂�l�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addSrcSide(r); srcObject = arguments.get(0); aliasCollector.changeTrackingObject(objectId, arguments.get(0).getId(), true); @@ -612,6 +613,7 @@ } else if(objectId.equals(dstObject.getId())) { r = new Reference(arguments.get(0), dstObject); r.setCollection(true); + r.setCreation(true); // �߂�l�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addDstSide(r); dstObject =arguments.get(0); aliasCollector.changeTrackingObject(objectId, arguments.get(0).getId(), false); @@ -624,6 +626,8 @@ if (objectId.equals(srcObject.getId())) { r = new Reference(thisObj, srcObject); r.setCollection(true); + if (methodExecution.getSignature().contains(".iterator()") || + methodExecution.getSignature().contains(".listIterator()")) r.setCreation(true); // �C�e���[�^�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addSrcSide(r); srcObject = thisObj; aliasCollector.changeTrackingObject(objectId, thisObjectId, true); @@ -631,6 +635,8 @@ } else if(objectId.equals(dstObject.getId())) { r = new Reference(thisObj, dstObject); r.setCollection(true); + if (methodExecution.getSignature().contains(".iterator()") || + methodExecution.getSignature().contains(".listIterator()")) r.setCreation(true); // �C�e���[�^�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addDstSide(r); dstObject =thisObj; aliasCollector.changeTrackingObject(objectId, thisObjectId, false); diff --git a/src/org/ntlab/deltaExtractor/ExtractedStructure.java b/src/org/ntlab/deltaExtractor/ExtractedStructure.java index 6e47f75..54d74e1 100644 --- a/src/org/ntlab/deltaExtractor/ExtractedStructure.java +++ b/src/org/ntlab/deltaExtractor/ExtractedStructure.java @@ -2,6 +2,7 @@ import org.ntlab.trace.MethodExecution; import org.ntlab.trace.Reference; +import org.ntlab.trace.TracePoint; public class ExtractedStructure { @@ -10,6 +11,7 @@ private MethodExecution coordinator = null; private MethodExecution parent = null; private MethodExecution creationCallTree; + private TracePoint relatedTracePoint = null; public Delta getDelta() { return delta; @@ -64,5 +66,13 @@ public MethodExecution getCreationCallTree() { return creationCallTree; } + + public void setRelatedTracePoint(TracePoint relatedTracePoint) { + this.relatedTracePoint = relatedTracePoint; + } + + public TracePoint getRelatedTracePoint() { + return relatedTracePoint; + } } diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 82a1c21..997b2df 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -428,10 +428,12 @@ outputLog(); curFrame = numFrame; Alias alias = deltaAliasCollector.getAliasList().get(numFrame - 1); + // Make ObjectEdge and reset position of vertexObject, remove vertexMethodExecution. - for(Statement statement: alias.getMethodExecution().getStatements()) +// for(Statement statement: alias.getMethodExecution().getStatements()) { -// Statement statement = alias.getOccurrencePoint().getStatement(); + Statement statement = eStructure.getRelatedTracePoint().getStatement(); + MethodExecution methodExec = alias.getMethodExecution(); if(statement instanceof FieldUpdate) { // Format fieldName. FieldUpdate fieldUpdateStatement = (FieldUpdate) statement; @@ -444,53 +446,66 @@ // Change! String targetObjectId = fieldUpdateStatement.getValueObjId(); ObjectVertex targetObjectVertex = objectToVertexMap.get(targetObjectId); - MethodExecution calledMethodExec = alias.getMethodExecution(); - if (methodExecToVertexMap.containsKey(calledMethodExec)) { - if (methodExecToVertexMap.get(calledMethodExec).getLocals().contains(targetObjectVertex)) { - methodExecToVertexMap.get(calledMethodExec).getLocals().remove(targetObjectVertex); - System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); - } else if (methodExecToVertexMap.get(calledMethodExec).getArguments().contains(targetObjectVertex)) { - methodExecToVertexMap.get(calledMethodExec).getArguments().remove(targetObjectVertex); - System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); + if (methodExecToVertexMap.containsKey(methodExec)) { + if (methodExecToVertexMap.get(methodExec).getLocals().contains(targetObjectVertex)) { + methodExecToVertexMap.get(methodExec).getLocals().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(methodExec).getArguments().contains(targetObjectVertex)) { + methodExecToVertexMap.get(methodExec).getArguments().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); } } - removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); + removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), methodExec.getCallerMethodExecution(), methodExec); updateObjectVertices(); -// ObjectVertex targetParentObjVertex = objectToVertexMap.get(calledMethodExec.getThisObjId()); -// deltaAnimation.setVertexAnimation((mxCell)targetParentObjVertex.getCell(), new mxPoint(targetParentObjVertex.getInitialX(), targetParentObjVertex.getInitialY())); -// deltaAnimation.startVertexAnimation(); } if(statement instanceof MethodInvocation) { - MethodInvocation methodInvocationStatement = (MethodInvocation) statement; - MethodExecution methodExec = methodInvocationStatement.getCalledMethodExecution(); + MethodInvocation methodInvStatement = (MethodInvocation) statement; + MethodExecution calledMethodExec = methodInvStatement.getCalledMethodExecution(); + String methodSignature = calledMethodExec.getSignature(); + String srcClassName = null; + String srcObjId = null; + String tgtObjId = null; //Array��List�̂Ƃ��������x����t����i�m���ɕ������Ă�����̂Ƃ�)getSignature->contains("List.get(") || "Map.get(") <�z���C�g���X�g> - if (methodExec.getSignature().contains("List.add(") || - methodExec.getSignature().contains("Map.put(")) { - String sourceObjectId = methodExec.getThisObjId(); +// if (methodExec.getSignature().contains("List.add(") || +// methodExec.getSignature().contains("Map.put(")) { + if (calledMethodExec.isCollectionType() + && (methodSignature.contains("add(") + || methodSignature.contains("set(") + || methodSignature.contains("put(") + || methodSignature.contains("push(") + || methodSignature.contains("addElement("))) { - createObjectRefrence(methodExec); - - // Change! - String targetObjectId = methodExec.getArguments().get(0).getId(); - ObjectVertex targetObjectVertex = objectToVertexMap.get(targetObjectId); - MethodExecution calledMethodExec = alias.getMethodExecution(); - - if (methodExecToVertexMap.containsKey(calledMethodExec)) { - if (methodExecToVertexMap.get(calledMethodExec).getLocals().contains(targetObjectVertex)) { - methodExecToVertexMap.get(calledMethodExec).getLocals().remove(targetObjectVertex); - System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); - } else if (methodExecToVertexMap.get(calledMethodExec).getArguments().contains(targetObjectVertex)) { - methodExecToVertexMap.get(calledMethodExec).getArguments().remove(targetObjectVertex); - System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); - } - } - removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); - updateObjectVertices(); + srcClassName = calledMethodExec.getThisClassName(); + srcObjId = calledMethodExec.getThisObjId(); + tgtObjId = calledMethodExec.getArguments().get(0).getId(); + } else { + // this to another + srcClassName = methodInvStatement.getThisClassName(); + srcObjId = methodInvStatement.getThisObjId(); + tgtObjId = calledMethodExec.getReturnValue().getId(); } + + + createObjectRefrence(srcClassName, srcObjId, tgtObjId); + + // Change! + ObjectVertex tgtObjectVertex = objectToVertexMap.get(tgtObjId); + + if (methodExecToVertexMap.containsKey(methodExec)) { + if (methodExecToVertexMap.get(methodExec).getLocals().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(methodExec).getLocals().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeLocal: " + tgtObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(methodExec).getArguments().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(methodExec).getArguments().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeArgument: " + tgtObjectVertex.getLabel()); + } + } + removeCalledMethodExecutionVertex(objectToVertexMap.get(srcObjId), methodExec.getCallerMethodExecution(), methodExec); + updateObjectVertices(); } } @@ -750,13 +765,10 @@ targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); } - private void createObjectRefrence(MethodExecution methodExec) { - String srcObjId = methodExec.getThisObjId(); - String srcClassName = methodExec.getThisClassName(); - String targetObjId = methodExec.getArguments().get(0).getId(); + private void createObjectRefrence(String srcClassName, String srcObjId, String tgtObjId) { mxICell targetCell; // if (objectToVertexMap.containsKey(targetObjId)) { - targetCell = (mxICell)objectToVertexMap.get(targetObjId).getCell(); + targetCell = (mxICell)objectToVertexMap.get(tgtObjId).getCell(); // } else { // targetObjId = methodExec.getCallerMethodExecution().getArguments().get(0).getId(); // targetCell = (mxICell)objectToVertexMap.get(targetObjId).getCell(); @@ -770,19 +782,19 @@ targetCell.setParent(mxDefaultParent); targetCell.getGeometry().setX(absolutePointTargetCell.getX()); targetCell.getGeometry().setY(absolutePointTargetCell.getY()); - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, targetObjId, null, objectToVertexMap.get(srcObjId).getCell(), objectToVertexMap.get(targetObjId).getCell()); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, tgtObjId, null, objectToVertexMap.get(srcObjId).getCell(), objectToVertexMap.get(tgtObjId).getCell()); ((mxCell)edge).setStyle("exitX=0;exitY=0.5;exitPerimeter=1;entryX=1;entryY=0.5;entryPerimeter=1;"); - edgeMap.put(targetObjId, new Edge(null, TypeName.Reference, edge)); + edgeMap.put(tgtObjId, new Edge(null, TypeName.Reference, edge)); // System.out.println("last" + objectToVertexMap.get(targetObjectId).getInitialX() + ", " + objectToVertexMap.get(targetObjectId).getInitialY()); - deltaAnimation.setVertexAnimation(targetCell, new mxPoint(objectToVertexMap.get(targetObjId).getInitialX(), objectToVertexMap.get(targetObjId).getInitialY())); + deltaAnimation.setVertexAnimation(targetCell, new mxPoint(objectToVertexMap.get(tgtObjId).getInitialX(), objectToVertexMap.get(tgtObjId).getInitialY())); deltaAnimation.startVertexAnimation(); - targetCell.getGeometry().setX(objectToVertexMap.get(targetObjId).getInitialX()); - targetCell.getGeometry().setY(objectToVertexMap.get(targetObjId).getInitialY()); + targetCell.getGeometry().setX(objectToVertexMap.get(tgtObjId).getInitialX()); + targetCell.getGeometry().setY(objectToVertexMap.get(tgtObjId).getInitialY()); } finally { mxgraph.getModel().endUpdate(); } - System.out.println("rTHIS " + srcClassName + ", " + targetObjId); + System.out.println("rTHIS " + srcClassName + ", " + tgtObjId); } /** @@ -1243,32 +1255,32 @@ Object object = objectToVertexMap.get(objId).getCell(); // if (object != null) { - double xCor = VERTEX_OBJECT_SIZE.getWidth() * 0.1; - double yCor = VERTEX_OBJECT_SIZE.getHeight() * 0.5; - double standardX = xCor; - double standardY = 0; - int time = objectToVertexMap.get(objId).getVertexMethodExecutions().size(); - System.out.println(time); - if (time >= 1) { - mxICell standardCell = (mxICell) objectToVertexMap.get(objId).getVertexMethodExecutions().get(0).getCell(); - standardX = standardCell.getGeometry().getX(); - standardY = standardCell.getGeometry().getY(); - time-=1; - } + double xCor = VERTEX_OBJECT_SIZE.getWidth() * 0.1; + double yCor = VERTEX_OBJECT_SIZE.getHeight() * 0.5; + double standardX = xCor; + double standardY = 0; + int time = objectToVertexMap.get(objId).getVertexMethodExecutions().size(); + System.out.println(time); + if (time >= 1) { + mxICell standardCell = (mxICell) objectToVertexMap.get(objId).getVertexMethodExecutions().get(0).getCell(); + standardX = standardCell.getGeometry().getX(); + standardY = standardCell.getGeometry().getY(); + time-=1; + } - Object vertex = mxgraph.insertDeltaVertex(object, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. - System.out.println("makeVertexMethodExecution: " + ((mxICell)vertex).getId() + " in " + objId + " (" + standardX + ", " + yCor * (time + 1) + standardY + ")"); + Object vertex = mxgraph.insertDeltaVertex(object, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. + System.out.println("makeVertexMethodExecution: " + ((mxICell)vertex).getId() + " in " + objId + " (" + standardX + ", " + yCor * (time + 1) + standardY + ")"); - MethodExecutionVertex vertexMethodExecution = new MethodExecutionVertex(methodSignature, vertex, standardX , yCor * (time + 1) + standardY, VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); - // Object vertex = mxgraph.insertVertex(object, methodSignature, methodSignature, 0, 0, 0, 0, "fillColor=white", true); //creates a white vertex. - // Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. - // VertexMethodExecution vertexMethodExecution = new VertexMethodExecution(methodSignature, vertex, getXForCell(objectId) + (xCor * (time + 1)), getYForCell(objectId) + (yCor * (time + 1)), VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); - methodExecToVertexMap.put(methodExec, vertexMethodExecution); - if(methodExecToVertexMap.size() > 1) { - ((mxICell)vertex).setVisible(false); - createEdgeToMethodExecution(); - } - objectToVertexMap.get(objId).addMethodExecution(vertexMethodExecution); + MethodExecutionVertex vertexMethodExecution = new MethodExecutionVertex(methodSignature, vertex, standardX , yCor * (time + 1) + standardY, VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); + // Object vertex = mxgraph.insertVertex(object, methodSignature, methodSignature, 0, 0, 0, 0, "fillColor=white", true); //creates a white vertex. + // Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. + // VertexMethodExecution vertexMethodExecution = new VertexMethodExecution(methodSignature, vertex, getXForCell(objectId) + (xCor * (time + 1)), getYForCell(objectId) + (yCor * (time + 1)), VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); + methodExecToVertexMap.put(methodExec, vertexMethodExecution); + if(methodExecToVertexMap.size() > 1) { + ((mxICell)vertex).setVisible(false); + createEdgeToMethodExecution(); + } + objectToVertexMap.get(objId).addMethodExecution(vertexMethodExecution); // } } finally { mxgraph.getModel().endUpdate();