/** * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) { if (this.nonJavaResources == null) { try { this.nonJavaResources = PackageFragmentRootInfo.computeFolderNonJavaResources( rootHandle, (IContainer)underlyingResource, rootHandle.fullInclusionPatternChars(), rootHandle.fullExclusionPatternChars()); } catch (JavaModelException e) { // root doesn't exist: consider package has no nonJavaResources this.nonJavaResources = NO_NON_JAVA_RESOURCES; } } return this.nonJavaResources; } /**
/** * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) { if (this.nonJavaResources == null) { try { this.nonJavaResources = PackageFragmentRootInfo.computeFolderNonJavaResources( rootHandle, (IContainer)underlyingResource, rootHandle.fullInclusionPatternChars(), rootHandle.fullExclusionPatternChars()); } catch (JavaModelException e) { // root doesn't exist: consider package has no nonJavaResources this.nonJavaResources = NO_NON_JAVA_RESOURCES; } } return this.nonJavaResources; } /**
/** * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) { if (this.nonJavaResources == null) { try { this.nonJavaResources = PackageFragmentRootInfo.computeFolderNonJavaResources( rootHandle, (IContainer)underlyingResource, rootHandle.fullInclusionPatternChars(), rootHandle.fullExclusionPatternChars()); } catch (JavaModelException e) { // root doesn't exist: consider package has no nonJavaResources this.nonJavaResources = NO_NON_JAVA_RESOURCES; } } return this.nonJavaResources; } /**
/** * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) { if (this.nonJavaResources == null) { try { this.nonJavaResources = PackageFragmentRootInfo.computeFolderNonJavaResources( rootHandle, (IContainer)underlyingResource, rootHandle.fullInclusionPatternChars(), rootHandle.fullExclusionPatternChars()); } catch (JavaModelException e) { // root doesn't exist: consider package has no nonJavaResources this.nonJavaResources = NO_NON_JAVA_RESOURCES; } } return this.nonJavaResources; } /**
/** * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) { Object[] resources = this.nonJavaResources; if (resources == null) { try { resources = PackageFragmentRootInfo.computeFolderNonJavaResources( rootHandle, (IContainer)underlyingResource, rootHandle.fullInclusionPatternChars(), rootHandle.fullExclusionPatternChars()); } catch (JavaModelException e) { // root doesn't exist: consider package has no nonJavaResources resources = NO_NON_JAVA_RESOURCES; } this.nonJavaResources = resources; } return resources; } }
/** * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) { Object[] resources = this.nonJavaResources; if (resources == null) { try { resources = PackageFragmentRootInfo.computeFolderNonJavaResources( rootHandle, (IContainer)underlyingResource, rootHandle.fullInclusionPatternChars(), rootHandle.fullExclusionPatternChars()); } catch (JavaModelException e) { // root doesn't exist: consider package has no nonJavaResources resources = NO_NON_JAVA_RESOURCES; } this.nonJavaResources = resources; } return resources; } }
/** * Compute the non-package resources of this package fragment root. */ private Object[] computeNonJavaResources(IResource underlyingResource, PackageFragmentRoot handle) { Object[] resources = NO_NON_JAVA_RESOURCES; try { // the underlying resource may be a folder or a project (in the case that the project folder // is actually the package fragment root) if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) { resources = computeFolderNonJavaResources( handle, (IContainer) underlyingResource, handle.fullInclusionPatternChars(), handle.fullExclusionPatternChars()); } } catch (JavaModelException e) { // ignore } return resources; } /**
/** * Compute the non-package resources of this package fragment root. */ private Object[] computeNonJavaResources(IResource underlyingResource, PackageFragmentRoot handle) { Object[] resources = NO_NON_JAVA_RESOURCES; try { // the underlying resource may be a folder or a project (in the case that the project folder // is actually the package fragment root) if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) { resources = computeFolderNonJavaResources( handle, (IContainer) underlyingResource, handle.fullInclusionPatternChars(), handle.fullExclusionPatternChars()); } } catch (JavaModelException e) { // ignore } return resources; } /**
/** * Compute the non-package resources of this package fragment root. */ private Object[] computeNonJavaResources(IResource underlyingResource, PackageFragmentRoot handle) { Object[] resources = NO_NON_JAVA_RESOURCES; try { // the underlying resource may be a folder or a project (in the case that the project folder // is actually the package fragment root) if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) { resources = computeFolderNonJavaResources( handle, (IContainer) underlyingResource, handle.fullInclusionPatternChars(), handle.fullExclusionPatternChars()); } } catch (JavaModelException e) { // ignore } return resources; } /**
/** * Compute the non-package resources of this package fragment root. */ private Object[] computeNonJavaResources(IResource underlyingResource, PackageFragmentRoot handle) { Object[] resources = NO_NON_JAVA_RESOURCES; try { // the underlying resource may be a folder or a project (in the case that the project folder // is actually the package fragment root) if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) { resources = computeFolderNonJavaResources( handle, (IContainer) underlyingResource, handle.fullInclusionPatternChars(), handle.fullExclusionPatternChars()); } } catch (JavaModelException e) { // ignore } return resources; } /**
/** * Compute the non-package resources of this package fragment root. */ private Object[] computeNonJavaResources(IResource underlyingResource, PackageFragmentRoot handle) { Object[] resources = NO_NON_JAVA_RESOURCES; try { // the underlying resource may be a folder or a project (in the case that the project folder // is actually the package fragment root) if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) { resources = computeFolderNonJavaResources( handle, (IContainer) underlyingResource, handle.fullInclusionPatternChars(), handle.fullExclusionPatternChars()); } } catch (JavaModelException e) { // ignore } return resources; } /**
public static final boolean isExcluded(IJavaElement element) { int elementType = element.getElementType(); switch (elementType) { case IJavaElement.JAVA_MODEL: case IJavaElement.JAVA_PROJECT: case IJavaElement.PACKAGE_FRAGMENT_ROOT: return false; case IJavaElement.PACKAGE_FRAGMENT: PackageFragmentRoot root = (PackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IResource resource = ((PackageFragment) element).resource(); return resource != null && isExcluded(resource, root.fullInclusionPatternChars(), root.fullExclusionPatternChars()); case IJavaElement.COMPILATION_UNIT: root = (PackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); resource = element.getResource(); if (resource == null) return false; if (isExcluded(resource, root.fullInclusionPatternChars(), root.fullExclusionPatternChars())) return true; return isExcluded(element.getParent()); default: IJavaElement cu = element.getAncestor(IJavaElement.COMPILATION_UNIT); return cu != null && isExcluded(cu); } } /*
public static final boolean isExcluded(IJavaElement element) { int elementType = element.getElementType(); switch (elementType) { case IJavaElement.JAVA_MODEL: case IJavaElement.JAVA_PROJECT: case IJavaElement.PACKAGE_FRAGMENT_ROOT: return false; case IJavaElement.PACKAGE_FRAGMENT: PackageFragmentRoot root = (PackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IResource resource = ((PackageFragment) element).resource(); return resource != null && isExcluded(resource, root.fullInclusionPatternChars(), root.fullExclusionPatternChars()); case IJavaElement.COMPILATION_UNIT: root = (PackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); resource = element.getResource(); if (resource == null) return false; if (isExcluded(resource, root.fullInclusionPatternChars(), root.fullExclusionPatternChars())) return true; return isExcluded(element.getParent()); default: IJavaElement cu = element.getAncestor(IJavaElement.COMPILATION_UNIT); return cu != null && isExcluded(cu); } } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); }
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
private ClasspathLocation mapToClassPathLocation( JavaModelManager manager, PackageFragmentRoot root) { ClasspathLocation cp = null; IPath path = root.getPath(); try { if (root.isArchive()) { ClasspathEntry rawClasspathEntry = (ClasspathEntry) root.getRawClasspathEntry(); cp = new ClasspathJar(manager.getZipFile(path), rawClasspathEntry.getAccessRuleSet(), ClasspathEntry.getExternalAnnotationPath(rawClasspathEntry, ((IJavaProject)root.getParent()).getProject(), true)); } else { Object target = JavaModel.getTarget(path, true); if (target != null) { if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { cp = new ClasspathSourceDirectory((IContainer)target, root.fullExclusionPatternChars(), root.fullInclusionPatternChars()); } else { ClasspathEntry rawClasspathEntry = (ClasspathEntry) root.getRawClasspathEntry(); cp = ClasspathLocation.forBinaryFolder((IContainer) target, false, rawClasspathEntry.getAccessRuleSet(), ClasspathEntry.getExternalAnnotationPath(rawClasspathEntry, ((IJavaProject)root.getParent()).getProject(), true)); } } } } catch (CoreException e1) { // problem opening zip file or getting root kind // consider root corrupt and ignore } return cp; }