use of org.eclipse.core.resources.IProject in project che by eclipse.
the class JavaModelManager method removePerProjectInfo.
public void removePerProjectInfo(JavaProject javaProject, boolean removeExtJarInfo) {
synchronized (this.perProjectInfos) {
// use the perProjectInfo collection as its own lock
IProject project = javaProject.getProject();
PerProjectInfo info = (PerProjectInfo) this.perProjectInfos.get(project);
if (info != null) {
this.perProjectInfos.remove(project);
// if (removeExtJarInfo) {
// info.forgetExternalTimestampsAndIndexes();
// }
}
}
resetClasspathListCache();
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class JavaModelManager method resetProjectOptions.
/*
* Reset project options stored in info cache.
*/
public void resetProjectOptions(JavaProject javaProject) {
synchronized (this.perProjectInfos) {
// use the perProjectInfo collection as its own lock
IProject project = javaProject.getProject();
PerProjectInfo info = (PerProjectInfo) this.perProjectInfos.get(project);
if (info != null) {
info.options = null;
}
}
}
use of org.eclipse.core.resources.IProject 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.core.resources.IProject in project che by eclipse.
the class JavaProject method computePackageFragmentRoots.
/**
* Returns the package fragment roots identified by the given entry. In case it refers to
* a project, it will follow its classpath so as to find exported roots as well.
* Only works with resolved entry
*
* @param resolvedEntry
* IClasspathEntry
* @param accumulatedRoots
* ObjectVector
* @param rootIDs
* HashSet
* @param referringEntry
* the CP entry (project) referring to this entry, or null if initial project
* @param retrieveExportedRoots
* boolean
* @throws JavaModelException
*/
public void computePackageFragmentRoots(IClasspathEntry resolvedEntry, ObjectVector accumulatedRoots, HashSet rootIDs, IClasspathEntry referringEntry, boolean retrieveExportedRoots, Map rootToResolvedEntries) throws JavaModelException {
String rootID = ((ClasspathEntry) resolvedEntry).rootID();
if (rootIDs.contains(rootID))
return;
IPath projectPath = this.project.getFullPath();
IPath entryPath = resolvedEntry.getPath();
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IPackageFragmentRoot root = null;
switch(resolvedEntry.getEntryKind()) {
// source folder
case IClasspathEntry.CPE_SOURCE:
if (projectPath.isPrefixOf(entryPath)) {
Object target = getTarget(entryPath, true);
if (target == null)
return;
if (target instanceof IFolder || target instanceof IProject) {
root = getPackageFragmentRoot((IResource) target);
}
}
break;
// internal/external JAR or folder
case IClasspathEntry.CPE_LIBRARY:
if (referringEntry != null && !resolvedEntry.isExported())
return;
Object target = getTarget(entryPath, true);
if (target == null)
return;
if (target instanceof IResource) {
// // internal target
root = getPackageFragmentRoot((IResource) target, entryPath);
} else if (target instanceof File) {
// external target
if (isFile(target)) {
root = new JarPackageFragmentRoot(entryPath, this);
} else if (((File) target).isDirectory()) {
// root = new ExternalPackageFragmentRoot(entryPath, this);
throw new UnsupportedOperationException();
}
}
break;
// recurse into required project
case IClasspathEntry.CPE_PROJECT:
if (!retrieveExportedRoots)
return;
if (referringEntry != null && !resolvedEntry.isExported())
return;
IResource member = workspaceRoot.findMember(entryPath);
if (member != null && member.getType() == IResource.PROJECT) {
// double check if bound to project (23977)
IProject requiredProjectRsc = (IProject) member;
if (org.eclipse.jdt.internal.core.JavaProject.hasJavaNature(requiredProjectRsc)) {
// special builder binary output
rootIDs.add(rootID);
org.eclipse.jdt.internal.core.JavaProject requiredProject = (org.eclipse.jdt.internal.core.JavaProject) JavaCore.create(requiredProjectRsc);
requiredProject.computePackageFragmentRoots(requiredProject.getResolvedClasspath(), accumulatedRoots, rootIDs, rootToResolvedEntries == null ? resolvedEntry : ((ClasspathEntry) resolvedEntry).combineWith((ClasspathEntry) referringEntry), // only combine if need to build the reverse map
retrieveExportedRoots, rootToResolvedEntries);
}
break;
}
}
if (root != null) {
accumulatedRoots.add(root);
rootIDs.add(rootID);
if (rootToResolvedEntries != null)
rootToResolvedEntries.put(root, ((ClasspathEntry) resolvedEntry).combineWith((ClasspathEntry) referringEntry));
}
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class DeltaProcessor method traverseDelta.
/*
* Converts an <code>IResourceDelta</code> and its children into
* the corresponding <code>IJavaElementDelta</code>s.
*/
private void traverseDelta(IResourceDelta delta, int elementType, RootInfo rootInfo, OutputsInfo outputsInfo) {
IResource res = delta.getResource();
// set stack of elements
if (this.currentElement == null && rootInfo != null) {
this.currentElement = rootInfo.project;
}
// process current delta
boolean processChildren = true;
if (res instanceof IProject) {
// reset source element parser cache
this.sourceElementParserCache = null;
processChildren = updateCurrentDeltaAndIndex(delta, elementType == IJavaElement.PACKAGE_FRAGMENT_ROOT ? // case of prj=src
IJavaElement.JAVA_PROJECT : elementType, rootInfo);
} else if (rootInfo != null) {
processChildren = updateCurrentDeltaAndIndex(delta, elementType, rootInfo);
} else {
// not yet inside a package fragment root
processChildren = true;
}
// process children if needed
if (processChildren) {
IResourceDelta[] children = (IResourceDelta[]) delta.getAffectedChildren();
boolean oneChildOnClasspath = false;
int length = children.length;
IResourceDelta[] orphanChildren = null;
Openable parent = null;
boolean isValidParent = true;
for (int i = 0; i < length; i++) {
IResourceDelta child = children[i];
IResource childRes = child.getResource();
// check source attachment change
checkSourceAttachmentChange(child, childRes);
// find out whether the child is a package fragment root of the current project
IPath childPath = externalPath(childRes);
int childKind = child.getKind();
RootInfo childRootInfo = rootInfo(childPath, childKind);
RootInfo originalChildRootInfo = childRootInfo;
if (childRootInfo != null && !childRootInfo.isRootOfProject(childPath)) {
// package fragment root of another project (dealt with later)
childRootInfo = null;
}
// compute child type
int childType = elementType(childRes, childKind, elementType, rootInfo == null ? childRootInfo : rootInfo);
// is childRes in the output folder and is it filtered out ?
boolean isResFilteredFromOutput = isResFilteredFromOutput(rootInfo, outputsInfo, childRes, childType);
boolean isNestedRoot = rootInfo != null && childRootInfo != null;
if (!isResFilteredFromOutput && !isNestedRoot) {
// do not treat as non-java rsc if nested root
traverseDelta(child, childType, rootInfo == null ? childRootInfo : rootInfo, // traverse delta for child in the same project
outputsInfo);
if (childType == NON_JAVA_RESOURCE) {
if (rootInfo != null) {
// if inside a package fragment root
if (!isValidParent)
continue;
if (parent == null) {
// find the parent of the non-java resource to attach to
if (this.currentElement == null || !rootInfo.project.equals(this.currentElement.getJavaProject())) {
// note if currentElement is the
// IJavaModel, getJavaProject() is null
// force the currentProject to be used
this.currentElement = rootInfo.project;
}
if (elementType == IJavaElement.JAVA_PROJECT || (elementType == IJavaElement.PACKAGE_FRAGMENT_ROOT && res instanceof IProject)) {
// NB: attach non-java resource to project (not to its package fragment root)
parent = rootInfo.project;
} else {
parent = createElement(res, elementType, rootInfo);
}
if (parent == null) {
isValidParent = false;
continue;
}
}
// add child as non java resource
try {
nonJavaResourcesChanged(parent, child);
} catch (JavaModelException e) {
// ignore
}
} else {
// the non-java resource (or its parent folder) will be attached to the java project
if (orphanChildren == null)
orphanChildren = new IResourceDelta[length];
orphanChildren[i] = child;
}
} else {
if (rootInfo == null && childRootInfo == null) {
// the non-java resource (or its parent folder) will be attached to the java project
if (orphanChildren == null)
orphanChildren = new IResourceDelta[length];
orphanChildren[i] = child;
}
}
} else {
// to avoid reporting child delta as non-java resource delta
oneChildOnClasspath = true;
}
// but it is a package fragment root of another project, traverse delta too
if (isNestedRoot || (childRootInfo == null && originalChildRootInfo != null)) {
traverseDelta(child, IJavaElement.PACKAGE_FRAGMENT_ROOT, originalChildRootInfo, // binary output of childRootInfo.project cannot be this root
null);
}
// if the child is a package fragment root of one or several other projects
ArrayList rootList;
if ((rootList = otherRootsInfo(childPath, childKind)) != null) {
Iterator iterator = rootList.iterator();
while (iterator.hasNext()) {
originalChildRootInfo = (RootInfo) iterator.next();
this.currentElement = // ensure that 2 roots refering to the same resource don't share the current element (see
null;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210746 )
traverseDelta(child, IJavaElement.PACKAGE_FRAGMENT_ROOT, originalChildRootInfo, // binary output of childRootInfo.project cannot be this root
null);
}
}
}
if (orphanChildren != null && (// orphan children are siblings of a package fragment root
oneChildOnClasspath || res instanceof IProject)) {
// non-java resource directly under a project
// // attach orphan children
// IProject rscProject = res.getProject();
// JavaProject adoptiveProject = (JavaProject)JavaCore.create(rscProject);
// if (adoptiveProject != null
// && JavaProject.hasJavaNature(rscProject)) { // delta iff Java project (18698)
// for (int i = 0; i < length; i++) {
// if (orphanChildren[i] != null) {
// try {
// nonJavaResourcesChanged(adoptiveProject, orphanChildren[i]);
// } catch (JavaModelException e) {
// // ignore
// }
// }
// }
// }
}
// else resource delta will be added by parent
}
// else resource delta will be added by parent
}
Aggregations