use of org.eclipse.core.resources.IProject in project che by eclipse.
the class QualifiedNameFinder method createScope.
private static TextSearchScope createScope(String filePatterns, IProject root) {
HashSet<IProject> res = new HashSet<IProject>();
res.add(root);
addReferencingProjects(root, res);
IResource[] resArr = res.toArray(new IResource[res.size()]);
Pattern filePattern = getFilePattern(filePatterns);
return TextSearchScope.newSearchScope(resArr, filePattern, false);
}
use of org.eclipse.core.resources.IProject in project generator by mybatis.
the class RunGeneratorThread method getJavaProject.
private IJavaProject getJavaProject() {
IJavaProject answer = null;
IProject project = inputFile.getProject();
try {
if (project.hasNature(JavaCore.NATURE_ID)) {
answer = JavaCore.create(project);
}
} catch (CoreException e) {
// ignore - something is wrong
;
}
return answer;
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class ClasspathBuilderTest method rawClasspathShouldBeContained3Arguments.
@Test
public void rawClasspathShouldBeContained3Arguments() throws Exception {
createTestProject();
library.add("/lib");
sourceFolders.add("/src");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("/project");
IJavaProject iJavaProject = JavaCore.create(project);
classpathBuilder.generateClasspath(iJavaProject, sourceFolders, library);
List<IClasspathEntry> classpathEntries = Arrays.asList(iJavaProject.getRawClasspath());
assertThat(classpathEntries).onProperty("path").containsOnly(new Path(JREContainerInitializer.JRE_CONTAINER), new Path("/project/src"), new Path(root + "/project/lib/a.jar"));
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class JavaProjectHelper method addClassFolder.
/**
* Creates and adds a class folder to the class path.
* @param jproject The parent project
* @param containerName
* @param sourceAttachPath The source attachment path
* @param sourceAttachRoot The source attachment root path
* @return The handle of the created root
* @throws CoreException
*/
public static IPackageFragmentRoot addClassFolder(IJavaProject jproject, String containerName, IPath sourceAttachPath, IPath sourceAttachRoot) throws CoreException {
IProject project = jproject.getProject();
IContainer container = null;
if (containerName == null || containerName.length() == 0) {
container = project;
} else {
IFolder folder = project.getFolder(containerName);
if (!folder.exists()) {
CoreUtility.createFolder(folder, false, true, null);
}
container = folder;
}
IClasspathEntry cpe = JavaCore.newLibraryEntry(container.getFullPath(), sourceAttachPath, sourceAttachRoot);
addToClasspath(jproject, cpe);
return jproject.getPackageFragmentRoot(container);
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class JavaSearchScope method packageFragmentRoot.
/**
* @see AbstractJavaSearchScope#packageFragmentRoot(String, int, String)
*/
public IPackageFragmentRoot packageFragmentRoot(String resourcePathString, int jarSeparatorIndex, String jarPath) {
int index = -1;
boolean isJarFile = jarSeparatorIndex != -1;
if (isJarFile) {
// internal or external jar (case 3, 4, or 5)
String relativePath = resourcePathString.substring(jarSeparatorIndex + 1);
index = indexOf(jarPath, relativePath);
} else {
// resource in workspace (case 1 or 2)
index = indexOf(resourcePathString);
}
if (index >= 0) {
int idx = this.projectIndexes[index];
String projectPath = idx == -1 ? null : (String) this.projectPaths.get(idx);
if (projectPath != null) {
IJavaProject project = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject(projectPath));
if (isJarFile) {
IResource resource = JavaModel.getWorkspaceTarget(new Path(jarPath));
if (resource != null)
return project.getPackageFragmentRoot(resource);
return project.getPackageFragmentRoot(jarPath);
}
Object target = JavaModel.getWorkspaceTarget(new Path(this.containerPaths[index] + '/' + this.relativePaths[index]));
if (target != null) {
if (target instanceof IProject) {
return project.getPackageFragmentRoot((IProject) target);
}
IJavaElement element = JavaModelManager.create((IResource) target, project);
return (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
}
}
}
return null;
}
Aggregations