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 464508c..025200d 100644 --- a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/handlers/InstrumentationHandler.java +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/handlers/InstrumentationHandler.java @@ -9,6 +9,7 @@ import org.eclipse.core.internal.localstore.FileSystemResourceManager; import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -63,29 +64,7 @@ e.printStackTrace(); } // Javassist �� ClassPool �� �Ώۃv���O�������̃N���X�����‚�����悤�ɂ��� - 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); - } - } - } - 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); - } + String classPath = addProjectClassPathsToClassPool(javaProject, cp); // �C���X�g�D�������e�[�V�������s�� final String CLASS_PATH = classPath; @@ -110,6 +89,60 @@ return null; } + private String addProjectClassPathsToClassPool(IJavaProject javaProject, ClassPool cp) + throws JavaModelException, NotFoundException { + String outputClassPath = null; + Workspace workspace = (Workspace) javaProject.getProject().getWorkspace(); + FileSystemResourceManager fsm = workspace.getFileSystemManager(); + for (IClasspathEntry entry : javaProject.getResolvedClasspath(true)) { + switch (entry.getEntryKind()) { + case IClasspathEntry.CPE_SOURCE: + // �Ώ�Java�v���W�F�N�g�̃\�[�X�t�H���_ + IPath outputLocation = entry.getOutputLocation(); + if (outputLocation != null) { + // If the output folder is specified individually. + URI path = fsm.locationURIFor(workspace.getRoot().getFolder(outputLocation)); + outputClassPath = path.getPath().substring(1); + System.out.println(outputClassPath); + cp.appendClassPath(outputClassPath); + } + break; + case IClasspathEntry.CPE_LIBRARY: + // �Ώ�Java�v���W�F�N�g�ɎQ�Ƃ���Ă��郉�C�u���� + if (entry.getPath().getDevice() != null) { + // ���Ԃ�AJRE�V�X�e�����C�u���� + System.out.println(entry.getPath().toString()); + cp.appendClassPath(entry.getPath().toString()); + } else { + URI path = fsm.locationURIFor(workspace.getRoot().getFolder(entry.getPath())); + System.out.println(path.getPath()); + try { + cp.appendClassPath(path.getPath().substring(1)); + } catch (NotFoundException e) { + e.printStackTrace(); + } + } + break; + case IClasspathEntry.CPE_PROJECT: + // �Ώ�Java�v���W�F�N�g�ɎQ�Ƃ���Ă���O��Java�v���W�F�N�g + IResource refProject = workspace.getRoot().findMember(entry.getPath()); + IJavaProject refJavaProject = (IJavaProject) JavaCore.create(refProject); + if (refJavaProject != null) { + addProjectClassPathsToClassPool(refJavaProject, cp); + } + break; + } + } + if (outputClassPath == null) { + // �Ώ�Java�v���W�F�N�g�̏o�͐�t�H���_���N���X�p�X�Ɏw�肷�� + URI path = fsm.locationURIFor(workspace.getRoot().getFolder(javaProject.getOutputLocation())); + outputClassPath = path.getPath().substring(1); + System.out.println(outputClassPath); + cp.appendClassPath(outputClassPath); + } + return outputClassPath; + } + public abstract ITraceGenerator getGenerator(); private String getPath(String location) {