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. diff --git a/src/org/ntlab/deltaViewer/CollaborationViewer.java b/src/org/ntlab/deltaViewer/CollaborationViewer.java index 2483043..3fc4a99 100644 --- a/src/org/ntlab/deltaViewer/CollaborationViewer.java +++ b/src/org/ntlab/deltaViewer/CollaborationViewer.java @@ -138,96 +138,14 @@ // Make ObjectEdge and reset position of vertexObject, remove vertexMethodExecution. Statement statement = relatedPoint.getStatement(); MethodExecution prevMethodExec = prevAlias.getMethodExecution(); - if(statement instanceof FieldUpdate) { - // Format fieldName. - FieldUpdate fieldUpdateStatement = (FieldUpdate) statement; - String fieldName; - if (fieldUpdateStatement.getFieldName() != null) { - String fieldNames[] = formatFieldName(fieldUpdateStatement.getFieldName()); - fieldName = fieldNames[fieldNames.length-1]; - } else { - fieldName = ""; - } - String sourceObjectId = fieldUpdateStatement.getContainerObjId(); - - createObjectRefrence(fieldUpdateStatement, fieldName); - - // Change! - String targetObjectId = fieldUpdateStatement.getValueObjId(); - ObjectVertex targetObjectVertex = objectToVertexMap.get(targetObjectId); - - if (methodExecToVertexMap.containsKey(prevMethodExec)) { - if (methodExecToVertexMap.get(prevMethodExec).getLocals().contains(targetObjectVertex)) { - methodExecToVertexMap.get(prevMethodExec).getLocals().remove(targetObjectVertex); - System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); - } else if (methodExecToVertexMap.get(prevMethodExec).getArguments().contains(targetObjectVertex)) { - methodExecToVertexMap.get(prevMethodExec).getArguments().remove(targetObjectVertex); - System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); - } - } - if (nextAlias == null || (nextAlias != null && !prevMethodExec.getSignature().equals(nextAlias.getMethodSignature()))) { - removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), prevMethodExec.getCallerMethodExecution(), prevMethodExec); - updateObjectVertices(); - } - } - - if(statement instanceof MethodInvocation) { - 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(")) { - if (calledMethodExec.isCollectionType() - && (methodSignature.contains("add(") - || methodSignature.contains("set(") - || methodSignature.contains("put(") - || methodSignature.contains("push(") - || methodSignature.contains("addElement("))) { - - srcClassName = calledMethodExec.getThisClassName(); - srcObjId = calledMethodExec.getThisObjId(); - tgtObjId = calledMethodExec.getArguments().get(0).getId(); - ObjectVertex tgtObjectVertex = objectToVertexMap.get(tgtObjId); - - if (!methodExecToVertexMap.containsKey(calledMethodExec)) { - createMethodExecutionVertex(calledMethodExec.getThisObjId(), methodInvStatement.getCallerSideMethodName(), calledMethodExec); - update(); - moveArgumentObjectVertex(calledMethodExec, tgtObjectVertex, methodExecToVertexMap.get(calledMethodExec)); - update(); - createObjectRefrence(srcClassName, srcObjId, tgtObjId); - removeCalledMethodExecutionVertex(null, prevMethodExec, calledMethodExec); - } else { - createObjectRefrence(srcClassName, srcObjId, tgtObjId); - } - if (methodExecToVertexMap.containsKey(prevMethodExec)) { - if (methodExecToVertexMap.get(prevMethodExec).getLocals().contains(tgtObjectVertex)) { - methodExecToVertexMap.get(prevMethodExec).getLocals().remove(tgtObjectVertex); - System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeLocal: " + tgtObjectVertex.getLabel()); - } else if (methodExecToVertexMap.get(prevMethodExec).getArguments().contains(tgtObjectVertex)) { - methodExecToVertexMap.get(prevMethodExec).getArguments().remove(tgtObjectVertex); - System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeArgument: " + tgtObjectVertex.getLabel()); - } - } - List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); - System.out.println(methodExecList.size()); - if (nextAlias == null || (nextAlias != null && !prevMethodExec.getSignature().equals(nextAlias.getMethodSignature()))) { - if (methodExecList.size() > 1) { - removeCalledMethodExecutionVertex(null, prevMethodExec.getCallerMethodExecution(), prevMethodExec); - } else { - removeCalledMethodExecutionVertex(null, null, prevMethodExec); - } - } - updateObjectVertices(); - } else { - // this to another - srcClassName = methodInvStatement.getThisClassName(); - srcObjId = methodInvStatement.getThisObjId(); - tgtObjId = calledMethodExec.getReturnValue().getId(); + boolean fThisAnotherParameter = false; + if (relatedPoint.isMethodEntry()) { + if (prevAlias.getAliasType() == Alias.AliasType.FORMAL_PARAMETER) { + // this to another (parameter) + MethodExecution calledMethodExec = relatedPoint.getMethodExecution(); + String srcClassName = calledMethodExec.getThisClassName(); + String srcObjId = calledMethodExec.getThisObjId(); + String tgtObjId = prevAlias.getObjectId(); ObjectVertex tgtObjectVertex = objectToVertexMap.get(tgtObjId); createObjectRefrence(srcClassName, srcObjId, tgtObjId); @@ -244,8 +162,119 @@ removeCalledMethodExecutionVertex(objectToVertexMap.get(srcObjId), prevMethodExec, calledMethodExec); updateObjectVertices(); } + fThisAnotherParameter = true; } - + } + if (!fThisAnotherParameter) { + if (statement instanceof FieldUpdate) { + // Format fieldName. + FieldUpdate fieldUpdateStatement = (FieldUpdate) statement; + String fieldName; + if (fieldUpdateStatement.getFieldName() != null) { + String fieldNames[] = formatFieldName(fieldUpdateStatement.getFieldName()); + fieldName = fieldNames[fieldNames.length-1]; + } else { + fieldName = ""; + } + String sourceObjectId = fieldUpdateStatement.getContainerObjId(); + + createObjectRefrence(fieldUpdateStatement, fieldName); + + // Change! + String targetObjectId = fieldUpdateStatement.getValueObjId(); + ObjectVertex targetObjectVertex = objectToVertexMap.get(targetObjectId); + + if (methodExecToVertexMap.containsKey(prevMethodExec)) { + if (methodExecToVertexMap.get(prevMethodExec).getLocals().contains(targetObjectVertex)) { + methodExecToVertexMap.get(prevMethodExec).getLocals().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(prevMethodExec).getArguments().contains(targetObjectVertex)) { + methodExecToVertexMap.get(prevMethodExec).getArguments().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); + } + } + if (nextAlias == null || (nextAlias != null && !prevMethodExec.getSignature().equals(nextAlias.getMethodSignature()))) { + removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), prevMethodExec.getCallerMethodExecution(), prevMethodExec); + updateObjectVertices(); + } + } + + if(statement instanceof MethodInvocation) { + 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(")) { + if (calledMethodExec.isCollectionType() + && (methodSignature.contains("add(") + || methodSignature.contains("set(") + || methodSignature.contains("put(") + || methodSignature.contains("push(") + || methodSignature.contains("addElement("))) { + + srcClassName = calledMethodExec.getThisClassName(); + srcObjId = calledMethodExec.getThisObjId(); + tgtObjId = calledMethodExec.getArguments().get(0).getId(); + ObjectVertex tgtObjectVertex = objectToVertexMap.get(tgtObjId); + + if (!methodExecToVertexMap.containsKey(calledMethodExec)) { + createMethodExecutionVertex(calledMethodExec.getThisObjId(), methodInvStatement.getCallerSideMethodName(), calledMethodExec); + update(); + moveArgumentObjectVertex(calledMethodExec, tgtObjectVertex, methodExecToVertexMap.get(calledMethodExec)); + update(); + createObjectRefrence(srcClassName, srcObjId, tgtObjId); + removeCalledMethodExecutionVertex(null, prevMethodExec, calledMethodExec); + } else { + createObjectRefrence(srcClassName, srcObjId, tgtObjId); + } + if (methodExecToVertexMap.containsKey(prevMethodExec)) { + if (methodExecToVertexMap.get(prevMethodExec).getLocals().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(prevMethodExec).getLocals().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeLocal: " + tgtObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(prevMethodExec).getArguments().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(prevMethodExec).getArguments().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeArgument: " + tgtObjectVertex.getLabel()); + } + } + List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); + System.out.println(methodExecList.size()); + if (nextAlias == null || (nextAlias != null && !prevMethodExec.getSignature().equals(nextAlias.getMethodSignature()))) { + if (methodExecList.size() > 1) { + removeCalledMethodExecutionVertex(null, prevMethodExec.getCallerMethodExecution(), prevMethodExec); + } else { + removeCalledMethodExecutionVertex(null, null, prevMethodExec); + } + } + updateObjectVertices(); + } else { + // this to another + srcClassName = methodInvStatement.getThisClassName(); + srcObjId = methodInvStatement.getThisObjId(); + tgtObjId = calledMethodExec.getReturnValue().getId(); + ObjectVertex tgtObjectVertex = objectToVertexMap.get(tgtObjId); + + createObjectRefrence(srcClassName, srcObjId, tgtObjId); + if (methodExecToVertexMap.containsKey(prevMethodExec)) { + if (methodExecToVertexMap.get(prevMethodExec).getLocals().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(prevMethodExec).getLocals().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeLocal: " + tgtObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(prevMethodExec).getArguments().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(prevMethodExec).getArguments().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(prevMethodExec).getLabel() + " :removeArgument: " + tgtObjectVertex.getLabel()); + } + } + if (nextAlias == null || (nextAlias != null && !calledMethodExec.getSignature().equals(nextAlias.getMethodSignature()))) { + removeCalledMethodExecutionVertex(objectToVertexMap.get(srcObjId), prevMethodExec, calledMethodExec); + updateObjectVertices(); + } + } + + } } // MethodExecution tempMethodExec = alias.getMethodExecution(); @@ -534,7 +563,7 @@ // Judge AliasList contains relatedPoint. (If contains not to create edge.) if (rpIndex < relatedPoints.size() - 1) { TracePoint rp = relatedPoints.get(rpIndex); - Map.Entry rpInf = getRelatedInformation(rp); + Map.Entry rpInf = getRelatedInformation(rp, ac); if (srcClassName.equals(rpInf.getKey().getSrcClassName()) && fieldName.equals(rpInf.getValue()) && curAliasObjId.equals(rpInf.getKey().getSrcObjectId()) && nextAliasObjId.equals(rpInf.getKey().getDstObjectId())) { rpIndex++; continue; diff --git a/src/org/ntlab/deltaViewer/MagnetRONFrame.java b/src/org/ntlab/deltaViewer/MagnetRONFrame.java index 25b5126..fa86c7f 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONFrame.java +++ b/src/org/ntlab/deltaViewer/MagnetRONFrame.java @@ -565,7 +565,7 @@ if (objectCallGraph != null && aliasCollector != null) { List relatedPoints = objectCallGraph.getRelatedPoints(); TracePoint lastRP = relatedPoints.get(relatedPoints.size() - 1); - Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP); + Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP, aliasCollector); if (WINDOW_TITLE.contains("extract delta of")) { String[] splits = WINDOW_TITLE.split("extract delta of"); String featureName = splits[0]; @@ -631,7 +631,7 @@ if (ocg != null) { List relatedPoints = ocg.getRelatedPoints(); TracePoint lastRP = relatedPoints.get(relatedPoints.size() - 1); - Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP); + Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP, ac); WINDOW_TITLE = "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; setTitle(WINDOW_TITLE); } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 743b3e9..0480dd2 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -33,6 +33,7 @@ import org.ntlab.trace.FieldUpdate; import org.ntlab.trace.MethodExecution; import org.ntlab.trace.MethodInvocation; +import org.ntlab.trace.ObjectReference; import org.ntlab.trace.Reference; import org.ntlab.trace.Statement; import org.ntlab.trace.TracePoint; @@ -1549,7 +1550,7 @@ // TODO Auto-generated method stub } - public static Map.Entry getRelatedInformation(TracePoint relatedPoint) { + public static Map.Entry getRelatedInformation(TracePoint relatedPoint, IAliasCollector ac) { Statement rpStatement = relatedPoint.getStatement(); String rpSrcObjId = null; String rpDstObjId = null; @@ -1558,53 +1559,71 @@ String rpFieldName = null; // Search for relatedPoint objectReference srcClassName, fieldName. - if(rpStatement instanceof FieldUpdate) { - // Format fieldName. - FieldUpdate rpFieldUpdateStatement = (FieldUpdate) rpStatement; - rpSrcObjId = rpFieldUpdateStatement.getContainerObjId(); - rpDstObjId = rpFieldUpdateStatement.getValueObjId(); - if (rpFieldUpdateStatement.getFieldName() != null) { - String rpFieldNames[] = formatFieldName(rpFieldUpdateStatement.getFieldName()); - rpSrcClassName = rpFieldNames[0]; - rpFieldName = rpFieldNames[rpFieldNames.length-1]; - } else { - rpSrcClassName = rpFieldUpdateStatement.getContainerClassName(); + if (relatedPoint.isMethodEntry()) { + // this to another (parameter) + Alias lastAlias = ac.getAliasList().get(ac.getAliasList().size() - 1); + if (lastAlias.getAliasType() == Alias.AliasType.FORMAL_PARAMETER) { + rpSrcObjId = relatedPoint.getMethodExecution().getThisObjId(); + rpDstObjId = lastAlias.getObjectId(); rpFieldName = ""; - } - rpDstClassName = rpFieldUpdateStatement.getValueClassName(); - } else if (rpStatement instanceof ArrayUpdate) { - // container to component - ArrayUpdate rpArrayUpdateStatement = (ArrayUpdate) rpStatement; - rpSrcObjId = rpArrayUpdateStatement.getArrayObjectId(); - rpDstObjId = rpArrayUpdateStatement.getValueObjectId(); - rpSrcClassName = rpArrayUpdateStatement.getArrayClassName(); - rpDstClassName = rpArrayUpdateStatement.getValueClassName(); - rpFieldName = "[" + rpArrayUpdateStatement.getIndex() + "]"; - } else if(rpStatement instanceof MethodInvocation) { - MethodInvocation rpMethodInvStatement = (MethodInvocation) rpStatement; - MethodExecution rpCalledMethodExec = rpMethodInvStatement.getCalledMethodExecution(); - String rpMethodSig = rpCalledMethodExec.getSignature(); - - //Array��List�̂Ƃ��������x����t����i�m���ɕ������Ă�����̂Ƃ�)getSignature->contains("List.get(") || "Map.get(") <�z���C�g���X�g> -// if (rpMethodExec.getSignature().contains("List.add(") || -// rpMethodExec.getSignature().contains("Map.put(")) { - if (rpCalledMethodExec.isCollectionType() - && (rpMethodSig.contains("add(") - || rpMethodSig.contains("set(") - || rpMethodSig.contains("put(") - || rpMethodSig.contains("push(") - || rpMethodSig.contains("addElement("))) { - - rpSrcClassName = rpCalledMethodExec.getThisClassName(); - rpDstClassName = rpCalledMethodExec.getArguments().get(0).getActualType(); - rpSrcObjId = rpCalledMethodExec.getThisObjId(); - rpDstObjId = rpCalledMethodExec.getArguments().get(0).getId(); - } else { - // this to another - rpSrcClassName = rpMethodInvStatement.getThisClassName(); - rpDstClassName = rpCalledMethodExec.getReturnValue().getActualType(); - rpSrcObjId = rpMethodInvStatement.getThisObjId(); - rpDstObjId = rpCalledMethodExec.getReturnValue().getId(); + rpSrcClassName = relatedPoint.getMethodExecution().getThisClassName(); + for (ObjectReference r: lastAlias.getMethodExecution().getArguments()) { + if (r.getId().equals(rpDstObjId)) { + rpDstClassName = r.getActualType(); + break; + } + } + } + } + if (rpSrcObjId == null || rpDstObjId == null) { + if (rpStatement instanceof FieldUpdate) { + // Format fieldName. + FieldUpdate rpFieldUpdateStatement = (FieldUpdate) rpStatement; + rpSrcObjId = rpFieldUpdateStatement.getContainerObjId(); + rpDstObjId = rpFieldUpdateStatement.getValueObjId(); + if (rpFieldUpdateStatement.getFieldName() != null) { + String rpFieldNames[] = formatFieldName(rpFieldUpdateStatement.getFieldName()); + rpSrcClassName = rpFieldNames[0]; + rpFieldName = rpFieldNames[rpFieldNames.length-1]; + } else { + rpSrcClassName = rpFieldUpdateStatement.getContainerClassName(); + rpFieldName = ""; + } + rpDstClassName = rpFieldUpdateStatement.getValueClassName(); + } else if (rpStatement instanceof ArrayUpdate) { + // container to component + ArrayUpdate rpArrayUpdateStatement = (ArrayUpdate) rpStatement; + rpSrcObjId = rpArrayUpdateStatement.getArrayObjectId(); + rpDstObjId = rpArrayUpdateStatement.getValueObjectId(); + rpSrcClassName = rpArrayUpdateStatement.getArrayClassName(); + rpDstClassName = rpArrayUpdateStatement.getValueClassName(); + rpFieldName = "[" + rpArrayUpdateStatement.getIndex() + "]"; + } else if(rpStatement instanceof MethodInvocation) { + MethodInvocation rpMethodInvStatement = (MethodInvocation) rpStatement; + MethodExecution rpCalledMethodExec = rpMethodInvStatement.getCalledMethodExecution(); + String rpMethodSig = rpCalledMethodExec.getSignature(); + + //Array��List�̂Ƃ��������x����t����i�m���ɕ������Ă�����̂Ƃ�)getSignature->contains("List.get(") || "Map.get(") <�z���C�g���X�g> +// if (rpMethodExec.getSignature().contains("List.add(") || +// rpMethodExec.getSignature().contains("Map.put(")) { + if (rpCalledMethodExec.isCollectionType() + && (rpMethodSig.contains("add(") + || rpMethodSig.contains("set(") + || rpMethodSig.contains("put(") + || rpMethodSig.contains("push(") + || rpMethodSig.contains("addElement("))) { + + rpSrcClassName = rpCalledMethodExec.getThisClassName(); + rpDstClassName = rpCalledMethodExec.getArguments().get(0).getActualType(); + rpSrcObjId = rpCalledMethodExec.getThisObjId(); + rpDstObjId = rpCalledMethodExec.getArguments().get(0).getId(); + } else { + // this to another + rpSrcClassName = rpMethodInvStatement.getThisClassName(); + rpDstClassName = rpCalledMethodExec.getReturnValue().getActualType(); + rpSrcObjId = rpMethodInvStatement.getThisObjId(); + rpDstObjId = rpCalledMethodExec.getReturnValue().getId(); + } } } return new AbstractMap.SimpleEntry<>(new Reference(rpSrcObjId, rpDstObjId, rpSrcClassName, rpDstClassName), rpFieldName);