use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class JavaModelManager method initializeContainer.
private IClasspathContainer initializeContainer(IJavaProject project, IPath containerPath) throws JavaModelException {
ClasspathContainerInitializer initializer = containerInitializersCache.get(containerPath.segment(0));
IClasspathContainer container = null;
if (initializer != null) {
// avoid initialization cycles
containerPut(project, containerPath, CONTAINER_INITIALIZATION_IN_PROGRESS);
try {
initializer.initialize(containerPath, project);
// if (monitor != null)
// monitor.subTask(""); //$NON-NLS-1$
// retrieve value (if initialization was successful)
container = containerBeingInitializedGet(project, containerPath);
if (container == null && containerGet(project, containerPath) == null) {
// initializer failed to do its job: redirect to the failure container
container = initializer.getFailureContainer(containerPath, project);
// if (container == null) {
// if (CP_RESOLVE_VERBOSE || CP_RESOLVE_VERBOSE_FAILURE)
// verbose_container_null_failure_container(project, containerPath, initializer);
// return null; // break cycle
// }
// if (CP_RESOLVE_VERBOSE || CP_RESOLVE_VERBOSE_FAILURE)
// verbose_container_using_failure_container(project, containerPath, initializer);
containerPut(project, containerPath, container);
}
} catch (CoreException e) {
if (e instanceof JavaModelException) {
throw (JavaModelException) e;
} else {
throw new JavaModelException(e);
}
}
} else {
// create a dummy initializer and get the default failure container
container = (new ClasspathContainerInitializer() {
public void initialize(IPath path, IJavaProject javaProject) throws CoreException {
// not used
}
}).getFailureContainer(containerPath, project);
}
return container;
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class JavaModelManager method createClassFileFrom.
/**
* Creates and returns a class file element for the given <code>.class</code> file,
* its project being the given project. Returns <code>null</code> if unable
* to recognize the class file.
*/
public static IClassFile createClassFileFrom(IFile file, IJavaProject project) {
if (file == null) {
return null;
}
if (project == null) {
project = JavaCore.create(file.getProject());
}
IPackageFragment pkg = (IPackageFragment) determineIfOnClasspath(file, (JavaProject) project);
if (pkg == null) {
// fix for 1FVS7WE
// not on classpath - make the root its folder, and a default package
PackageFragmentRoot root = (PackageFragmentRoot) project.getPackageFragmentRoot(file.getParent());
pkg = root.getPackageFragment(CharOperation.NO_STRINGS);
}
return pkg.getClassFile(file.getName());
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class JavaModel method getJavaProjects.
/**
* @see org.eclipse.jdt.core.IJavaModel
*/
public IJavaProject[] getJavaProjects() throws JavaModelException {
// ArrayList list = getChildrenOfType(IJavaElement.JAVA_PROJECT);
// determine my children
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
int length = projects.length;
IJavaProject[] children = new IJavaProject[length];
int index = 0;
for (int i = 0; i < length; i++) {
IProject project = projects[i];
if (org.eclipse.jdt.internal.core.JavaProject.hasJavaNature(project)) {
children[index++] = getJavaProject(project);
}
}
if (index < length)
System.arraycopy(children, 0, children = new IJavaProject[index], 0, index);
// list.toArray(array);
return children;
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class SetContainerOperation method verbose_set_container.
private void verbose_set_container() {
Util.verbose(//$NON-NLS-1$
"CPContainer SET - setting container\n" + " container path: " + this.containerPath + //$NON-NLS-1$
'\n' + //$NON-NLS-1$
" projects: {" + org.eclipse.jdt.internal.compiler.util.Util.toString(this.affectedProjects, new org.eclipse.jdt.internal.compiler.util.Util.Displayable() {
public String displayString(Object o) {
return ((IJavaProject) o).getElementName();
}
}) + //$NON-NLS-1$
"}\n values: {\n" + org.eclipse.jdt.internal.compiler.util.Util.toString(this.respectiveContainers, new org.eclipse.jdt.internal.compiler.util.Util.Displayable() {
public String displayString(Object o) {
//$NON-NLS-1$
StringBuffer buffer = new StringBuffer(" ");
if (o == null) {
//$NON-NLS-1$
buffer.append("<null>");
return buffer.toString();
}
IClasspathContainer container = (IClasspathContainer) o;
buffer.append(container.getDescription());
//$NON-NLS-1$
buffer.append(" {\n");
IClasspathEntry[] entries = container.getClasspathEntries();
if (entries != null) {
for (int i = 0; i < entries.length; i++) {
//$NON-NLS-1$
buffer.append(" ");
buffer.append(entries[i]);
buffer.append('\n');
}
}
//$NON-NLS-1$
buffer.append(" }");
return buffer.toString();
}
}) + //$NON-NLS-1$
"\n }");
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class DeltaProcessor method addDependentProjects.
/*
* Adds the dependents of the given project to the list of the projects
* to update.
*/
private void addDependentProjects(IJavaProject project, HashMap projectDependencies, HashSet result) {
IJavaProject[] dependents = (IJavaProject[]) projectDependencies.get(project);
if (dependents == null)
return;
for (int i = 0, length = dependents.length; i < length; i++) {
IJavaProject dependent = dependents[i];
if (result.contains(dependent))
// no need to go further as the project is already known
continue;
result.add(dependent);
addDependentProjects(dependent, projectDependencies, result);
}
}
Aggregations