diff --git a/plugin.xml b/plugin.xml index 670aa14..252a1c2 100644 --- a/plugin.xml +++ b/plugin.xml @@ -11,21 +11,21 @@ category="org.ntlab.traceDebugger.category" class="org.ntlab.traceDebugger.CallStackView" id="org.ntlab.traceDebugger.callStackView" - name="CallStack (Offline)" + name="CallStack" restorable="true"> "); + simpleObjectTypeName.append(simpleNames[0].substring(simpleNames[0].lastIndexOf(".") + 1)); + if (simpleNames.length == 2) { + simpleObjectTypeName.append(" -> "); + simpleObjectTypeName.append(simpleNames[1].substring(simpleNames[1].lastIndexOf(".") + 1)); + } + return simpleObjectTypeName.toString(); case 3: - Object obj = marker.getAttribute("aliasType"); + Object obj = marker.getAttribute(DeltaMarkerManager.DELTA_MARKER_ATR_ALIAS_TYPE); if (obj == null) return null; // note: �X�l�[�N�P�[�X���p�X�J���P�[�X(�������P��Ԃ��󔒂ŋ�؂�)�ɕς��� String aliasType = obj.toString(); diff --git a/src/org/ntlab/traceDebugger/DeltaMarkerView.java b/src/org/ntlab/traceDebugger/DeltaMarkerView.java index 03ee013..a7c5893 100644 --- a/src/org/ntlab/traceDebugger/DeltaMarkerView.java +++ b/src/org/ntlab/traceDebugger/DeltaMarkerView.java @@ -49,7 +49,7 @@ // �e�[�u���̃J�������쐬 String[] tableColumnTexts = {"Description", "Object ID", "Object Type", "Alias Type", "Source", "Line"}; - int[] tableColumnWidth = {120, 100, 80, 120, 100, 50}; + int[] tableColumnWidth = {120, 100, 120, 120, 100, 80}; TreeColumn[] tableColumns = new TreeColumn[tableColumnTexts.length]; for (int i = 0; i < tableColumns.length; i++) { tableColumns[i] = new TreeColumn(tree, SWT.NULL); @@ -69,7 +69,7 @@ IMarker selectionMarker = (IMarker)value; try { DebuggingController controller = DebuggingController.getInstance(); - Object obj = selectionMarker.getAttribute("data"); + Object obj = selectionMarker.getAttribute(DeltaMarkerManager.DELTA_MARKER_ATR_DATA); TracePoint jumpPoint; MethodExecution selectionME; boolean isReturned = false; @@ -94,7 +94,7 @@ CallStackView callStackView = (CallStackView)getOtherView(CallStackView.ID, null); callStackView.highlight(coordinatorPoint.getMethodExecution()); VariableView variableView = (VariableView)getOtherView(VariableView.ID, null); - variableView.markAndExpandVariablesByDeltaMarker(deltaMarkerManager.getMarkers()); + variableView.markAndExpandVariablesByDeltaMarkers(deltaMarkerManager.getMarkers()); CallTreeView callTreeView = ((CallTreeView)getOtherView(CallTreeView.ID, null)); // CallTreeView callTreeView = ((CallTreeView)getOtherView(CallTreeView.ID, subId)); callTreeView.highlight(selectionME); diff --git a/src/org/ntlab/traceDebugger/JavaEditorOperator.java b/src/org/ntlab/traceDebugger/JavaEditorOperator.java index 0f1dcf7..fd43d03 100644 --- a/src/org/ntlab/traceDebugger/JavaEditorOperator.java +++ b/src/org/ntlab/traceDebugger/JavaEditorOperator.java @@ -1,14 +1,19 @@ package org.ntlab.traceDebugger; +import java.net.URI; import java.util.ArrayList; import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMethod; @@ -28,6 +33,7 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; +import org.ntlab.traceAnalysisPlatform.PathUtility; import org.ntlab.traceAnalysisPlatform.tracer.trace.ClassInfo; import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; import org.ntlab.traceAnalysisPlatform.tracer.trace.TraceJSON; @@ -174,14 +180,35 @@ String declaringClassName = methodExecution.getDeclaringClassName(); declaringClassName = declaringClassName.replace(".", ""); String tmp = trace.getClassInfo(declaringClassName).getPath(); - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProject[] projects = workspace.getRoot().getProjects(); String projectName = ""; for (IProject project : projects) { projectName = project.getFullPath().toString(); if (tmp.contains(projectName + "/")) break; +// IJavaProject javaProject = JavaCore.create(project); +// javaProject.getAllPackageFragmentRoots(); +// try { +// for (IClasspathEntry entry : javaProject.getResolvedClasspath(true)) { +// switch (entry.getEntryKind()) { +// case IClasspathEntry.CPE_SOURCE: +// IPath outputLocation = entry.getOutputLocation(); +// if (outputLocation != null) { +// // If the output folder is specified individually. +// URI path = PathUtility.workspaceRelativePathToAbsoluteURI(outputLocation, workspace); +// String outputClassPath = PathUtility.URIPathToPath(path.getPath()); +// System.out.println(outputClassPath); +// } +// break; +// } +// } +// } catch (JavaModelException e) { +// e.printStackTrace(); +// } } tmp = tmp.replace(tmp.substring(0, tmp.lastIndexOf(projectName)), ""); - tmp = tmp.replace("/bin/", "/src/"); +// tmp = tmp.replace("/bin/", "/src/"); + tmp = tmp.replace("/bin/", "/java/"); tmp = tmp.replace(".class", ".java"); String filePath = tmp; IPath path = new Path(filePath); diff --git a/src/org/ntlab/traceDebugger/TraceDebuggerPerspective.java b/src/org/ntlab/traceDebugger/TraceDebuggerPerspective.java index f96cd55..fdb48de 100644 --- a/src/org/ntlab/traceDebugger/TraceDebuggerPerspective.java +++ b/src/org/ntlab/traceDebugger/TraceDebuggerPerspective.java @@ -11,16 +11,32 @@ // �G�f�B�^�̏ꏊ���擾 String editorArea = layout.getEditorArea(); - // ����ɃR�[���X�^�b�N�̃r���[��z�u - IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.TOP, 0.35f, editorArea); - topLeft.addView(CallStackView.ID); - - // �E��Ƀu���[�N�|�C���g�̃r���[��z�u - IFolderLayout topRight = layout.createFolder("topRight", IPageLayout.RIGHT, 0.5f, "topLeft"); - topRight.addView(BreakPointView.ID); +// // ����ɃR�[���X�^�b�N�̃r���[��z�u +// IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.TOP, 0.35f, editorArea); +// topLeft.addView(CallStackView.ID); +// +// // �E��Ƀu���[�N�|�C���g�̃r���[��z�u +// IFolderLayout topRight = layout.createFolder("topRight", IPageLayout.RIGHT, 0.5f, "topLeft"); +// topRight.addView(BreakPointView.ID); +// +// // �E��ɕϐ��̃r���[��z�u +// IFolderLayout topRight2 = layout.createFolder("topRight2", IPageLayout.RIGHT, 0.5f, "topLeft"); +// topRight2.addView(VariableView.ID); + + // �E�Ƀu���[�N�|�C���g�̃r���[��z�u + IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, 0.5f, editorArea); + right.addView(BreakPointView.ID); // �E��ɕϐ��̃r���[��z�u - IFolderLayout topRight2 = layout.createFolder("topRight2", IPageLayout.RIGHT, 0.5f, "topLeft"); - topRight2.addView(VariableView.ID); + IFolderLayout topRight = layout.createFolder("topRight", IPageLayout.TOP, 0.25f, editorArea); + topRight.addView(VariableView.ID); + + // ����ɃR�[���c���[�̃r���[��z�u + IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f, "topRight"); + topLeft.addView(CallTreeView.ID); + + // ����ɃR�[���X�^�b�N�̃r���[��z�u + IFolderLayout topLeft2 = layout.createFolder("topLeft2", IPageLayout.TOP, 0.25f, "topLeft"); + topLeft2.addView(CallStackView.ID); } } diff --git a/src/org/ntlab/traceDebugger/VariableLabelProvider.java b/src/org/ntlab/traceDebugger/VariableLabelProvider.java index d70d776..ab259c6 100644 --- a/src/org/ntlab/traceDebugger/VariableLabelProvider.java +++ b/src/org/ntlab/traceDebugger/VariableLabelProvider.java @@ -29,7 +29,10 @@ } return variableName; case 1: - return variableData.getClassName() + " (" + "id = " + variableData.getId() + ")"; + String simpleName = variableData.getClassName(); + simpleName = simpleName.substring(simpleName.lastIndexOf(".") + 1); +// return variableData.getClassName() + " (" + "id = " + variableData.getId() + ")"; + return simpleName + " (" + "id = " + variableData.getId() + ")"; } } } diff --git a/src/org/ntlab/traceDebugger/VariableView.java b/src/org/ntlab/traceDebugger/VariableView.java index e596a89..7def009 100644 --- a/src/org/ntlab/traceDebugger/VariableView.java +++ b/src/org/ntlab/traceDebugger/VariableView.java @@ -162,7 +162,7 @@ controller.jumpToTheTracePoint(coordinatorPoint, false); DeltaMarkerManager deltaMarkerManager = newDeltaMarkerView.getDeltaMarkerManager(); - markAndExpandVariablesByDeltaMarker(deltaMarkerManager.getMarkers()); + markAndExpandVariablesByDeltaMarkers(deltaMarkerManager.getMarkers()); MethodExecution coordinatorME = coordinatorPoint.getMethodExecution(); MethodExecution bottomME = newDeltaMarkerView.getBottomPoint().getMethodExecution(); CallStackView callStackView = (CallStackView)getOtherView(CallStackView.ID); @@ -216,7 +216,7 @@ viewer.setInput(variables.getVariablesTreeNodes()); } - public void markAndExpandVariablesByDeltaMarker(Map> markers) { + public void markAndExpandVariablesByDeltaMarkers(Map> markers) { List srcSideDeltaMarkers = markers.get(DeltaMarkerManager.SRC_SIDE_DELTA_MARKER); List dstSideDeltaMarkers = markers.get(DeltaMarkerManager.DST_SIDE_DELTA_MARKER); List coordinatorMarker = markers.get(DeltaMarkerManager.COORDINATOR_DELTA_MARKER); @@ -233,7 +233,7 @@ additionalAttributesForVariables.put("markerId", markerId); for (IMarker marker : markerList) { try { - Object data = marker.getAttribute("data"); + Object data = marker.getAttribute(DeltaMarkerManager.DELTA_MARKER_ATR_DATA); if (data instanceof Alias) { idSet.add(((Alias)data).getObjectId()); } else if (data instanceof MethodExecution) { @@ -251,12 +251,12 @@ for (TreeItem item : viewer.getTree().getItems()) { Object obj = item.getData(); if (!(obj instanceof TreeNode)) continue; - expandMarkedNodes((TreeNode)obj, expandedNodes); + collectNodes((TreeNode)obj, expandedNodes); } viewer.setExpandedElements(expandedNodes.toArray(new Object[expandedNodes.size()])); } - private void expandMarkedNodes(TreeNode node, final Set expandedNodes) { + private void collectNodes(TreeNode node, final Set expandedNodes) { Object value = node.getValue(); if (!(value instanceof Variable)) return; Variable variable = (Variable)value; @@ -269,7 +269,7 @@ TreeNode[] children = node.getChildren(); if (children == null) return; for (TreeNode child : children) { - expandMarkedNodes(child, expandedNodes); + collectNodes(child, expandedNodes); } } diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java index 04b0a59..13e9877 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaExtractionAnalyzer.java @@ -107,7 +107,7 @@ dstSideCnt++; } } - mgr.markAndOpenJavaFile(bottomPoint, "Bottom", DeltaMarkerManager.BOTTOM_DELTA_MARKER); + mgr.markAndOpenJavaFile(bottomPoint, "CreationPoint", DeltaMarkerManager.BOTTOM_DELTA_MARKER); } private void reset() { diff --git a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java index 22ca279..71fe5ef 100644 --- a/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java +++ b/src/org/ntlab/traceDebugger/analyzerProvider/DeltaMarkerManager.java @@ -18,6 +18,7 @@ import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.Expression; +import org.eclipse.jdt.core.dom.Javadoc; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jface.text.BadLocationException; @@ -43,6 +44,10 @@ public static final String COORDINATOR_DELTA_MARKER = "org.ntlab.traceDebugger.coordinatorDeltaMarker"; public static final String SRC_SIDE_DELTA_MARKER = "org.ntlab.traceDebugger.srcSideDeltaMarker"; public static final String DST_SIDE_DELTA_MARKER = "org.ntlab.traceDebugger.dstSideDeltaMarker"; + public static final String DELTA_MARKER_ATR_DATA = "data"; + public static final String DELTA_MARKER_ATR_OBJECT_ID = "objectId"; + public static final String DELTA_MARKER_ATR_OBJECT_TYPE = "objectType"; + public static final String DELTA_MARKER_ATR_ALIAS_TYPE = "aliasType"; public Map> getMarkers() { return markerIdToMarkers; @@ -52,7 +57,7 @@ TreeNode[] roots = new TreeNode[] { new TreeNode("Coordinator"), new TreeNode("Related Aliases"), - new TreeNode("Creation Point (Bottom)") + new TreeNode("Creation Point") }; List treeNodeList = new ArrayList<>(); for (IMarker marker : allMarkers) { @@ -128,10 +133,10 @@ setAttributesForAlias(attributes, alias, file, markerId); attributes.put(IMarker.MESSAGE, message); attributes.put(IMarker.TRANSIENT, true); - attributes.put("data", alias); - attributes.put("objectId", alias.getObjectId()); - attributes.put("objectType", alias.getObjectType()); - attributes.put("aliasType", alias.getAliasType()); + attributes.put(DELTA_MARKER_ATR_DATA, alias); + attributes.put(DELTA_MARKER_ATR_OBJECT_ID, alias.getObjectId()); + attributes.put(DELTA_MARKER_ATR_OBJECT_TYPE, alias.getObjectType()); + attributes.put(DELTA_MARKER_ATR_ALIAS_TYPE, alias.getAliasType()); marker.setAttributes(attributes); addMarker(markerId, marker); return marker; @@ -150,9 +155,9 @@ setAttributesForMethodExecution(attributes, me, file, lineNo, markerId); attributes.put(IMarker.MESSAGE, message); attributes.put(IMarker.TRANSIENT, true); - attributes.put("data", tp); - attributes.put("objectId", objectId); - attributes.put("objectType", objectType); + attributes.put(DELTA_MARKER_ATR_DATA, tp); + attributes.put(DELTA_MARKER_ATR_OBJECT_ID, objectId); + attributes.put(DELTA_MARKER_ATR_OBJECT_TYPE, objectType); marker.setAttributes(attributes); addMarker(markerId, marker); return marker; @@ -227,7 +232,8 @@ String src1 = node.toString().replaceAll(" ", ""); src1 = src1.substring(0, src1.lastIndexOf("\n")); String src1Head = src1.substring(0, src1.indexOf(")") + 1); - String src2 = method.getSource().replaceAll(" |\t|\r", ""); + src1Head = src1Head.replaceAll(" |\t|\r|\n", ""); + String src2 = method.getSource().replaceAll(" |\t|\r|\n", ""); return src2.contains(src1Head); } catch (JavaModelException e) { e.printStackTrace(); @@ -276,12 +282,12 @@ name2 = name2.substring(name2.lastIndexOf(".") + 1); if (!(name1.equals(name2))) return true; int start = node.getStartPosition(); - attributes.put(IMarker.CHAR_START, start); + int end = start; if (source.startsWith("this.", start)) { - attributes.put(IMarker.CHAR_END, start + "this".length()); - } else { - attributes.put(IMarker.CHAR_END, start + node.getLength()); + end = start + "this".length(); } + attributes.put(IMarker.CHAR_START, start); + attributes.put(IMarker.CHAR_END, end); attributes.put(IMarker.LINE_NUMBER, lineNo); return false; } @@ -290,12 +296,12 @@ int lineNo = cUnit.getLineNumber(node.getStartPosition()); if (lineNo != alias.getLineNo()) return true; int start = node.getStartPosition(); - attributes.put(IMarker.CHAR_START, start); + int end = start; if (source.startsWith("this.", start)) { - attributes.put(IMarker.CHAR_END, start + "this".length()); - } else { - attributes.put(IMarker.CHAR_END, start + node.getLength()); + end = start + "this".length(); } + attributes.put(IMarker.CHAR_START, start); + attributes.put(IMarker.CHAR_END, end); attributes.put(IMarker.LINE_NUMBER, lineNo); return true; } @@ -310,12 +316,12 @@ name2 = name2.substring(name2.lastIndexOf(".") + 1); if (!(name1.equals(name2))) return true; int start = node.getStartPosition(); - attributes.put(IMarker.CHAR_START, start); + int end = start; if (source.startsWith("this.", start)) { - attributes.put(IMarker.CHAR_END, start + "this".length()); - } else { - attributes.put(IMarker.CHAR_END, start + node.getLength()); + end = start + "this".length(); } + attributes.put(IMarker.CHAR_START, start); + attributes.put(IMarker.CHAR_END, end); attributes.put(IMarker.LINE_NUMBER, lineNo); return false; } @@ -323,12 +329,12 @@ public boolean visit(org.eclipse.jdt.core.dom.ReturnStatement node) { int lineNo = cUnit.getLineNumber(node.getStartPosition()); int start = node.getExpression().getStartPosition(); - attributes.put(IMarker.CHAR_START, start); + int end = start; if (source.startsWith("this.", start)) { - attributes.put(IMarker.CHAR_END, start + "this".length()); - } else { - attributes.put(IMarker.CHAR_END, start + node.getExpression().getLength()); + end = start + "this".length(); } + attributes.put(IMarker.CHAR_START, start); + attributes.put(IMarker.CHAR_END, end); attributes.put(IMarker.LINE_NUMBER, lineNo); return false; } @@ -364,10 +370,10 @@ String name1 = node.toString(); name1 = name1.substring("new ".length(), name1.indexOf("(") + 1); String name2 = calledMe.getCallerSideSignature(); - name2 = name2.substring(0, name2.indexOf("(") + 1); + name2 = name2.substring(name2.lastIndexOf(".") + 1, name2.indexOf("(") + 1); if (!(name1.equals(name2))) return true; int start = node.getStartPosition(); - int end = start + node.getLength(); + int end = start; // note: �R���X�g���N�^�Ăяo���ɑΉ�����this�̓R�[�h���ɂ͏o�Ă��Ȃ����ߒ���0�̃}�[�J�[�ɂ��� attributes.put(IMarker.CHAR_START, start); attributes.put(IMarker.CHAR_END, end); attributes.put(IMarker.LINE_NUMBER, lineNo); @@ -411,7 +417,7 @@ String name1 = node.toString(); name1 = name1.substring("new ".length(), name1.indexOf("(") + 1); String name2 = calledMe.getCallerSideSignature(); - name2 = name2.substring(0, name2.indexOf("(") + 1); + name2 = name2.substring(name2.lastIndexOf(".") + 1, name2.indexOf("(") + 1); if (!(name1.equals(name2))) return true; int start = node.getStartPosition(); int end = start + node.getLength(); @@ -425,7 +431,6 @@ return visitor; } case CONSTRACTOR_INVOCATION: { - // note: �R���X�g���N�^�Ăяo���̍ۂ��G�C���A�X�^�C�v��METHOD_INVOCATION�ɂȂ��Ă���? if (statement instanceof MethodInvocation) { final MethodInvocation mi = (MethodInvocation)statement; final MethodExecution calledMe = mi.getCalledMethodExecution(); @@ -437,7 +442,7 @@ String name1 = node.toString(); name1 = name1.substring("new ".length(), name1.indexOf("(") + 1); String name2 = calledMe.getCallerSideSignature(); - name2 = name2.substring(0, name2.indexOf("(") + 1); + name2 = name2.substring(name2.lastIndexOf(".") + 1, name2.indexOf("(") + 1); if (!(name1.equals(name2))) return true; int start = node.getStartPosition(); int end = start + node.getLength(); @@ -538,7 +543,6 @@ if (!(name1.equals(name2))) return true; int start = node.getStartPosition(); int end = start + node.getLength(); - // end = start + source.substring(start, end).lastIndexOf("."); attributes.put(IMarker.CHAR_START, start); attributes.put(IMarker.CHAR_END, end); attributes.put(IMarker.LINE_NUMBER, lineNo); @@ -663,9 +667,13 @@ name2 = name2.substring(0, name2.indexOf("(")); name2 = name2.substring(name2.lastIndexOf(".") + 1); if (!(name1.equals(name2))) return true; - String receiverName = node.getExpression().toString(); int start = node.getStartPosition(); - int end = start + (receiverName).length(); + int end = start; + Expression expression = node.getExpression(); // note: ���\�b�h�Ăяo���̃��V�[�o�����擾 + if (expression != null) { + String receiverName = expression.toString(); // note: ���\�b�h�Ăяo���̃��V�[�o���܂� + end = start + receiverName.length(); + } attributes.put(IMarker.CHAR_START, start); attributes.put(IMarker.CHAR_END, end); attributes.put(IMarker.LINE_NUMBER, lineNo); @@ -727,9 +735,16 @@ src1 = src1.substring(0, src1.lastIndexOf("\n")); String src1Head = src1.substring(0, src1.indexOf(")") + 1); String src2 = method.getSource().replaceAll(" |\t|\r", ""); - if (!(src2.contains(src1Head))) return false; + if (!(src2.contains(src1Head))) return false; int start = node.getStartPosition(); int end = start + node.toString().indexOf(")") + 1; + Javadoc javadoc = node.getJavadoc(); + if (javadoc != null) { + start += javadoc.getLength(); + start += 5; // note: node.toString()�Ǝ��ۂ̃R�[�h�̃X�y�[�X���̍��������l�߂鉼���� + String tmp = node.toString().replace(javadoc.toString(), ""); + end = start + tmp.indexOf(")") + 1; + } int lineNo = cUnit.getLineNumber(node.getStartPosition()); attributes.put(IMarker.CHAR_START, start); attributes.put(IMarker.CHAR_END, end);