use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class ParentChecker method removeResourcesDescendantsOfJavaElements.
private void removeResourcesDescendantsOfJavaElements() {
List<IResource> subResources = new ArrayList<IResource>(3);
for (int i = 0; i < fResources.length; i++) {
IResource subResource = fResources[i];
for (int j = 0; j < fJavaElements.length; j++) {
IJavaElement superElements = fJavaElements[j];
if (isDescendantOf(subResource, superElements))
subResources.add(subResource);
}
}
removeFromSetToDelete(subResources.toArray(new IResource[subResources.size()]));
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class ParentChecker method removeJavaElementsDescendantsOfJavaElements.
private void removeJavaElementsDescendantsOfJavaElements() {
List<IJavaElement> subElements = new ArrayList<IJavaElement>(3);
for (int i = 0; i < fJavaElements.length; i++) {
IJavaElement subElement = fJavaElements[i];
for (int j = 0; j < fJavaElements.length; j++) {
IJavaElement superElement = fJavaElements[j];
if (isDescendantOf(subElement, superElement))
subElements.add(subElement);
}
}
removeFromSetToDelete(subElements.toArray(new IJavaElement[subElements.size()]));
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class StandardJavaElementContentProvider method internalGetParent.
/**
* Note: This method is for internal use only. Clients should not call this method.
*
* @param element the element
* @return the parent of the element
*
* @noreference This method is not intended to be referenced by clients.
*/
protected Object internalGetParent(Object element) {
// try to map resources to the containing package fragment
if (element instanceof IResource) {
IResource parent = ((IResource) element).getParent();
IJavaElement jParent = JavaCore.create(parent);
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=31374
if (jParent != null && jParent.exists())
return jParent;
return parent;
} else if (element instanceof IJavaElement) {
IJavaElement parent = ((IJavaElement) element).getParent();
// we have to skip the package fragment root as the parent.
if (element instanceof IPackageFragment) {
return skipProjectPackageFragmentRoot((IPackageFragmentRoot) parent);
}
return parent;
} else if (element instanceof IJarEntryResource) {
return ((IJarEntryResource) element).getParent();
}
return null;
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class StandardJavaElementContentProvider method getFolderContent.
/**
* Evaluates all children of a given {@link IFolder}. Clients can override this method.
* @param folder The folder to evaluate the children for.
* @return The children of the given folder.
* @exception CoreException if the folder does not exist.
*
* @since 3.3
*/
protected Object[] getFolderContent(IFolder folder) throws CoreException {
IResource[] members = folder.members();
IJavaProject javaProject = JavaCore.create(folder.getProject());
if (javaProject == null || !javaProject.exists())
return members;
boolean isFolderOnClasspath = javaProject.isOnClasspath(folder);
List<IResource> nonJavaResources = new ArrayList<IResource>();
// Can be on classpath but as a member of non-java resource folder
for (int i = 0; i < members.length; i++) {
IResource member = members[i];
// of non-Java resources.
if (isFolderOnClasspath) {
if (javaProject.findPackageFragmentRoot(member.getFullPath()) == null) {
nonJavaResources.add(member);
}
} else if (!javaProject.isOnClasspath(member)) {
nonJavaResources.add(member);
} else {
IJavaElement element = JavaCore.create(member, javaProject);
if (element instanceof IPackageFragmentRoot && javaProject.equals(element.getJavaProject()) && ((IPackageFragmentRoot) element).getKind() != IPackageFragmentRoot.K_SOURCE) {
// don't skip libs and class folders on the classpath of their project
nonJavaResources.add(member);
}
}
}
return nonJavaResources.toArray();
}
use of org.eclipse.jdt.core.IJavaElement in project che by eclipse.
the class CompilationUnitChangeNode method getChangeElement.
private JavaLanguageNode getChangeElement(Map<IJavaElement, JavaLanguageNode> map, IJavaElement element, List<ChildNode> children, TextEditChangeNode cunitChange) {
JavaLanguageNode result = map.get(element);
if (result != null)
return result;
IJavaElement parent = element.getParent();
if (parent instanceof ICompilationUnit) {
result = new JavaLanguageNode(cunitChange, element);
children.add(result);
map.put(element, result);
} else {
JavaLanguageNode parentChange = getChangeElement(map, parent, children, cunitChange);
result = new JavaLanguageNode(parentChange, element);
parentChange.addChild(result);
map.put(element, result);
}
return result;
}
Aggregations