diff --git a/src/org/ntlab/traceDebugger/VariableViewRelatedDelta.java b/src/org/ntlab/traceDebugger/VariableViewRelatedDelta.java index 7a92308..78b0af8 100644 --- a/src/org/ntlab/traceDebugger/VariableViewRelatedDelta.java +++ b/src/org/ntlab/traceDebugger/VariableViewRelatedDelta.java @@ -59,30 +59,11 @@ super.createActions(); jumpAction = new Action() { public void run() { - TracePoint tp = null; TracePoint before = DebuggingController.getInstance().getCurrentTp(); - VariableType variableType = selectedVariable.getVariableType(); - if (variableType.equals(VariableType.USE_VALUE)) { - String containerId = selectedVariable.getContainerId(); - String fieldName = selectedVariable.getFullyQualifiedVariableName(); - tp = VariableUpdatePointFinder.getInstance().getPoint(containerId, fieldName, before); - } else if (variableType.equals(VariableType.USE_RETURN)) { - String receiverId = selectedVariable.getContainerId(); - String valueId = selectedVariable.getValueId(); - String receiverClassName = selectedVariable.getContainerClassName(); - VariableUpdatePointFinder finder = VariableUpdatePointFinder.getInstance(); - if (receiverClassName.contains("Iterator") || receiverClassName.contains("Itr") - || receiverClassName.contains("Collections$UnmodifiableCollection$1")) { - tp = finder.getIteratorPoint(receiverId); - if (tp == null) return; - MethodInvocation mi = ((MethodInvocation)tp.getStatement()); - receiverId = mi.getCalledMethodExecution().getThisObjId(); - } - tp = finder.getDefinitionInvocationPoint(receiverId, valueId, before); - } - if (tp == null) return; + TracePoint jumpPoint = findJumpPoint(selectedVariable, before); + if (jumpPoint == null) return; DebuggingController controller = DebuggingController.getInstance(); - controller.jumpToTheTracePoint(tp, false); + controller.jumpToTheTracePoint(jumpPoint, false); } }; jumpAction.setText("Jump to Definition"); @@ -121,6 +102,54 @@ deltaActionForThisToAnother.setToolTipText("Extract Delta"); } + private TracePoint findJumpPoint(Variable variable, TracePoint before) { + VariableType variableType = selectedVariable.getVariableType(); + if (variableType.equals(VariableType.USE_VALUE)) { + String containerId = selectedVariable.getContainerId(); + String fieldName = selectedVariable.getFullyQualifiedVariableName(); + return VariableUpdatePointFinder.getInstance().getPoint(containerId, fieldName, before); + } else if (variableType.equals(VariableType.USE_RETURN)) { + return findJumpPointWithReturnValue(variable, before); + } + return null; + } + + private TracePoint findJumpPointWithReturnValue(Variable variable, TracePoint before) { + TracePoint tp = null; + String receiverId = selectedVariable.getContainerId(); + String valueId = selectedVariable.getValueId(); + String receiverClassName = selectedVariable.getContainerClassName(); + VariableUpdatePointFinder finder = VariableUpdatePointFinder.getInstance(); + + // note: �C�e���[�^�̏ꍇ�͂��̃C�e���[�^�̎擾���̃R���N�V������ID�����ɂ��� + if (receiverClassName.contains("Iterator") || receiverClassName.contains("Itr") + || receiverClassName.contains("Collections$UnmodifiableCollection$1")) { + tp = finder.getIteratorPoint(receiverId); // �C�e���[�^�擾���̃|�C���g���擾 + if (tp == null) return null; + MethodInvocation mi = ((MethodInvocation)tp.getStatement()); + receiverId = mi.getCalledMethodExecution().getThisObjId(); // �C�e���[�^�̎擾���̃R���N�V������ID + receiverClassName = mi.getCalledMethodExecution().getThisClassName(); // �C�e���[�^�̎擾���̃R���N�V�����̃N���X�� + } + + // note: �W�����v��ƂȂ� �I�u�W�F�N�g�̑���|�C���g�������̓R���N�V�����ւ̒lj��|�C���g���擾 + tp = finder.getDefinitionInvocationPoint(receiverId, valueId, before); + + // note: �W�����v��̃|�C���g�����‚���Ȃ������ꍇ�ŁA���ƒR���N�V�����ւ̒lj��|�C���g��T���Ă���ꍇ�̓R���N�V�����̏悹�������Œlj����Ă��Ȃ�����T���ɍs�� + if (tp == null && receiverClassName.startsWith("java.util.")) { + String afterCollectionId = receiverId; + while (true) { + tp = finder.getTransferCollectionPoint(afterCollectionId, before); + if (tp == null) break; // �R���N�V�����̏悹������������ȏ�Ȃ��ꍇ + MethodInvocation mi = ((MethodInvocation)tp.getStatement()); + String fromCollectionId = mi.getCalledMethodExecution().getArguments().get(0).getId(); + tp = finder.getDefinitionInvocationPoint(fromCollectionId, valueId, before); + if (tp != null) break; // �R���N�V�����̏悹�������ŃI�u�W�F�N�g�̒lj������‚������ꍇ + afterCollectionId = fromCollectionId; + } + } + return tp; + } + @Override protected void createPopupMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); @@ -183,20 +212,6 @@ deltaActionForContainerToComponent.setText(""); deltaActionForContainerToComponent.setToolTipText(""); return false; - -// String containerId = selectedVariable.getContainerId(); -// String containerClassName = selectedVariable.getContainerClassName(); -// if (containerId != null && containerClassName != null) { -// containerClassName = containerClassName.substring(containerClassName.lastIndexOf(".") + 1); -// String textForContainerToComponent = String.format("Extract Delta [ %s (id = %s) -> %s (id = %s) ]", containerClassName, containerId, valueClassName, valueId); -// deltaActionForContainerToComponent.setText(textForContainerToComponent); -// deltaActionForContainerToComponent.setToolTipText(textForContainerToComponent); -// return true; -// } else { -// deltaActionForContainerToComponent.setText(""); -// deltaActionForContainerToComponent.setToolTipText(""); -// return false; -// } } private boolean updateDeltaActionForThisToAnotherTexts(Variable variable) {