/** Compute the non-java resources contained in this java project. */ private Object[] computeNonJavaResources(JavaProject project) { // determine if src == project and/or if bin == project IPath projectPath = project.getProject().getFullPath(); boolean srcIsProject = false; boolean binIsProject = false; char[][] inclusionPatterns = null; char[][] exclusionPatterns = null; IPath projectOutput = null; boolean isClasspathResolved = true; try { IClasspathEntry entry = project.getClasspathEntryFor(projectPath); if (entry != null) { srcIsProject = true; inclusionPatterns = ((ClasspathEntry) entry).fullInclusionPatternChars(); exclusionPatterns = ((ClasspathEntry) entry).fullExclusionPatternChars(); } projectOutput = project.getOutputLocation(); binIsProject = projectPath.equals(projectOutput); } catch (JavaModelException e) { isClasspathResolved = false; } Object[] resources = new IResource[5]; int resourcesCounter = 0; try { IResource[] members = ((IContainer) project.getResource()).members(); int length = members.length; if (length > 0) { String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true); String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true); IClasspathEntry[] classpath = project.getResolvedClasspath(); for (int i = 0; i < length; i++) { IResource res = members[i]; switch (res.getType()) { case IResource.FILE: IPath resFullPath = res.getFullPath(); String resName = res.getName(); // ignore a jar file on the classpath if (isClasspathResolved && isClasspathEntryOrOutputLocation( resFullPath, res.getLocation() /* see https://bugs.eclipse .org/bugs/show_bug.cgi?id=244406 */, classpath, projectOutput)) { break; } // ignore .java file if src == project if (srcIsProject && Util.isValidCompilationUnitName(resName, sourceLevel, complianceLevel) && !Util.isExcluded(res, inclusionPatterns, exclusionPatterns)) { break; } // ignore .class file if bin == project if (binIsProject && Util.isValidClassFileName(resName, sourceLevel, complianceLevel)) { break; } // else add non java resource if (resources.length == resourcesCounter) { // resize System.arraycopy( resources, 0, (resources = new IResource[resourcesCounter * 2]), 0, resourcesCounter); } resources[resourcesCounter++] = res; break; case IResource.FOLDER: resFullPath = res.getFullPath(); // ignore non-excluded folders on the classpath or that correspond to an output // location if ((srcIsProject && !Util.isExcluded(res, inclusionPatterns, exclusionPatterns) && Util.isValidFolderNameForPackage( res.getName(), sourceLevel, complianceLevel)) || (isClasspathResolved && isClasspathEntryOrOutputLocation( resFullPath, res.getLocation(), classpath, projectOutput))) { break; } // else add non java resource if (resources.length == resourcesCounter) { // resize System.arraycopy( resources, 0, (resources = new IResource[resourcesCounter * 2]), 0, resourcesCounter); } resources[resourcesCounter++] = res; } } } if (resources.length != resourcesCounter) { System.arraycopy( resources, 0, (resources = new IResource[resourcesCounter]), 0, resourcesCounter); } } catch (CoreException e) { resources = NO_NON_JAVA_RESOURCES; resourcesCounter = 0; } return resources; }