diff --git a/src/org/ntlab/deltaViewer/CollaborationViewer.java b/src/org/ntlab/deltaViewer/CollaborationViewer.java index 3fc4a99..1150557 100644 --- a/src/org/ntlab/deltaViewer/CollaborationViewer.java +++ b/src/org/ntlab/deltaViewer/CollaborationViewer.java @@ -523,25 +523,37 @@ // Search for objectReference srcClassName, fieldName between curAlias and nexAlias. if (curAlias.getAliasType() == AliasType.THIS) { + Statement statement = nextAlias.getOccurrencePoint().getStatement(); if (nextAlias.getAliasType() == AliasType.RETURN_VALUE) { MethodExecution nextMethodExec = nextAlias.getMethodExecution(); //Array��List�̂Ƃ��������x����t����i�m���ɕ������Ă�����̂Ƃ�)getSignature->contains("List.get(") || "Map.get(") <�z���C�g���X�g> - if (nextMethodExec.getSignature().contains("List.get(") || - nextMethodExec.getSignature().contains("Map.get(")) { + if (nextMethodExec.getSignature().contains("List.get(")) { srcClassName = nextMethodExec.getThisClassName(); fieldName = nextMethodExec.getArguments().get(0).getId(); System.out.println("rTHIS " + srcClassName + ", " + nextMethodExec.getArguments().get(0).getId()); + } else if (nextMethodExec.getSignature().contains("Map.get(")) { + srcClassName = nextMethodExec.getThisClassName(); + fieldName = ""; + System.out.println("rTHIS " + srcClassName + ", " + nextMethodExec.getArguments().get(0).getId()); } } else { - Statement statement = nextAlias.getOccurrencePoint().getStatement(); - if(statement instanceof FieldAccess && curAliasObjId.equals(((FieldAccess)statement).getContainerObjId())) { - if (((FieldAccess)statement).getFieldName() != null) { - String fieldNames[] = formatFieldName(((FieldAccess)statement).getFieldName()); + if (nextAlias.getAliasType() == AliasType.FIELD) { // When final local. + if (statement != null && statement instanceof MethodInvocation && curAliasObjId.equals(((MethodInvocation)statement).getThisObjId())) { + MethodInvocation methodInvocation = (MethodInvocation)statement; + srcClassName = methodInvocation.getThisClassName(); + fieldName = nextAliasObjId; + } + } + if(statement != null && statement instanceof FieldAccess + && curAliasObjId.equals(((FieldAccess)statement).getContainerObjId())) { // Contains alias type of nextAlias is FIELD. + FieldAccess fieldAccess = (FieldAccess)statement; + if (fieldAccess.getFieldName() != null) { + String fieldNames[] = formatFieldName(fieldAccess.getFieldName()); srcClassName = fieldNames[0]; fieldName = fieldNames[1]; } else { - srcClassName = ((FieldAccess)statement).getContainerClassName(); - fieldName = ""; + srcClassName = fieldAccess.getContainerClassName(); + fieldName = nextAliasObjId; } } } @@ -577,8 +589,13 @@ Object dstCell = objectToVertexMap.get(nextAliasObjId).getCell(); if (srcCell != null && dstCell != null) { // isCreation() System.out.println("makeEdgeObject: " + fieldName + ", " + srcClassName + " (" + srcCell.hashCode() + "), " + " (" + dstCell.hashCode() + ")"/* + ", " + dstClassName*/); - // BUG:NullPointerException - Object edge = mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldName, fieldName, srcCell, dstCell); + // TODO: Fix bug of NullPointerException. + mxICell edge = null; + if (fieldName.equals(nextAliasObjId)) { // If fieldName is objectId. + edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), "", "", srcCell, dstCell); + } else { + edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldName, fieldName, srcCell, dstCell); + } Point2D absPtSrcCell = getAbsolutePointforCell((mxICell)srcCell); Point2D absPtDstCell = getAbsolutePointforCell((mxICell)dstCell); setEdgePoint((mxICell)edge, absPtSrcCell, absPtDstCell);