diff --git a/org.ntlab.traceCollector/META-INF/MANIFEST.MF b/org.ntlab.traceCollector/META-INF/MANIFEST.MF index 25e1def..96ebacd 100644 --- a/org.ntlab.traceCollector/META-INF/MANIFEST.MF +++ b/org.ntlab.traceCollector/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ org.eclipse.debug.ui, org.eclipse.jdt.debug.ui, org.eclipse.jdt.core, - com.ibm.icu + com.ibm.icu, + org.eclipse.core.resources Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ClassPath: javassist.jar, diff --git a/org.ntlab.traceCollector/bin/.gitignore b/org.ntlab.traceCollector/bin/.gitignore deleted file mode 100644 index cf1db2e..0000000 --- a/org.ntlab.traceCollector/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/org/ diff --git a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/handlers/InstrumentationHandler.java b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/handlers/InstrumentationHandler.java index d642d45..70edd97 100644 --- a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/handlers/InstrumentationHandler.java +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/handlers/InstrumentationHandler.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.net.URI; import javassist.ClassPool; import javassist.CodeConverter; @@ -10,9 +11,14 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.internal.localstore.FileSystemResourceManager; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.core.JavaProject; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.handlers.HandlerUtil; @@ -39,7 +45,7 @@ IJavaProject javaProject = (IJavaProject)project; try { // Javassist �� ClassPool �� Javassist ���C�u�������A����т��̃v���O�C�����̃N���X�����‚�����悤�ɂ��� - ClassPool cp = ClassPool.getDefault(); + ClassPool cp = new ClassPool(true); // String bundlePath = Activator.getDefault().getBundle().getLocation(); try { String bundlePath = FileLocator.resolve(Activator.getDefault().getBundle().getEntry("/")).getPath(); @@ -50,14 +56,29 @@ e.printStackTrace(); } // Javassist �� ClassPool �� �Ώۃv���O�������̃N���X�����‚�����悤�ɂ��� - String projectLocation = javaProject.getProject().getLocation().toString(); - String projectPath = javaProject.getPath().toString(); - String outputPath = javaProject.getOutputLocation().toString(); - if (outputPath.startsWith(projectPath)) { - outputPath = outputPath.substring(projectPath.length()); + String classPath = null; + for (IClasspathEntry entry : javaProject.getResolvedClasspath(true)) { + if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE){ + // �v���W�F�N�g���̃\�[�X�t�H���_ + IPath outputLocation = entry.getOutputLocation(); + if (outputLocation != null) { + // �o�͐�t�H���_���•ʂɎw�肳��Ă����ꍇ + Workspace workspace = (Workspace) javaProject.getProject().getWorkspace(); + FileSystemResourceManager fsm = workspace.getFileSystemManager(); + URI path = fsm.locationURIFor(workspace.getRoot().getFolder(outputLocation)); + classPath = path.getPath().substring(1); + cp.appendClassPath(classPath); + } + } } - String classPath = projectLocation + outputPath; - cp.appendClassPath(classPath); + if (classPath == null) { + // �f�t�H���g�̏o�͐�t�H���_ + Workspace workspace = (Workspace) javaProject.getProject().getWorkspace(); + FileSystemResourceManager fsm = workspace.getFileSystemManager(); + URI path = fsm.locationURIFor(workspace.getRoot().getFolder(javaProject.getOutputLocation())); + classPath = path.getPath().substring(1); + cp.appendClassPath(classPath); + } // �C���X�g�D�������e�[�V�������s�� // Tracer.initialize(new OutputStatementsGenerator(new JSONTraceGenerator()), cp); // �����ŏo�̓t�H�[�}�b�g���w�肷��