<s> package org . eclipse . jdt . internal . core ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJarEntryResource ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . util . Util ; class PackageFragmentRootInfo extends OpenableElementInfo { protected SourceMapper sourceMapper = null ; protected int rootKind = IPackageFragmentRoot . K_SOURCE ; protected Object [ ] nonJavaResources ; public PackageFragmentRootInfo ( ) { this . nonJavaResources = null ; } static Object [ ] computeFolderNonJavaResources ( IPackageFragmentRoot root , IContainer folder , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns ) throws JavaModelException { IResource [ ] nonJavaResources = new IResource [ 5 ] ; int nonJavaResourcesCounter = 0 ; JavaProject project = ( JavaProject ) root . getJavaProject ( ) ; try { boolean isInterestingPackageRoot = LanguageSupportFactory . isInterestingProject ( project . getProject ( ) ) && root . getRawClasspathEntry ( ) . getEntryKind ( ) != IClasspathEntry . CPE_SOURCE ; IClasspathEntry [ ] classpath = project . getResolvedClasspath ( ) ; IResource [ ] members = folder . members ( ) ; int length = members . length ; if ( length > 0 ) { String sourceLevel = project . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; nextResource : for ( int i = 0 ; i < length ; i ++ ) { IResource member = members [ i ] ; switch ( member . getType ( ) ) { case IResource . FILE : String fileName = member . getName ( ) ; if ( ( Util . isValidCompilationUnitName ( fileName , sourceLevel , complianceLevel ) && ! Util . isExcluded ( member , inclusionPatterns , exclusionPatterns ) ) && ! ( isInterestingPackageRoot && LanguageSupportFactory . isInterestingSourceFile ( fileName ) ) ) continue nextResource ; if ( Util . isValidClassFileName ( fileName , sourceLevel , complianceLevel ) ) continue nextResource ; if ( isClasspathEntry ( member . getFullPath ( ) , classpath ) ) continue nextResource ; break ; case IResource . FOLDER : if ( Util . isValidFolderNameForPackage ( member . getName ( ) , sourceLevel , complianceLevel ) && ( ! Util . isExcluded ( member , inclusionPatterns , exclusionPatterns ) || isClasspathEntry ( member . getFullPath ( ) , classpath ) ) ) continue nextResource ; break ; } if ( nonJavaResources . length == nonJavaResourcesCounter ) { System . arraycopy ( nonJavaResources , 0 , ( nonJavaResources = new IResource [ nonJavaResourcesCounter * 2 ] ) , 0 , nonJavaResourcesCounter ) ; } nonJavaResources [ nonJavaResourcesCounter ++ ] = member ; } } if ( ExternalFoldersManager . isInternalPathForExternalFolder ( folder . getFullPath ( ) ) ) { IJarEntryResource [ ] jarEntryResources = new IJarEntryResource [ nonJavaResourcesCounter ] ; for ( int i = 0 ; i < nonJavaResourcesCounter ; i ++ ) { jarEntryResources [ i ] = new NonJavaResource ( root , nonJavaResources [ i ] ) ; } return jarEntryResources ; } else if ( nonJavaResources . length != nonJavaResourcesCounter ) { System . arraycopy ( nonJavaResources , 0 , ( nonJavaResources = new IResource [ nonJavaResourcesCounter ] ) , 0 , nonJavaResourcesCounter ) ; } return nonJavaResources ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } private Object [ ] computeNonJavaResources ( IResource underlyingResource , PackageFragmentRoot handle ) { Object [ ] resources = NO_NON_JAVA_RESOURCES ; try { if ( underlyingResource . getType ( ) == IResource . FOLDER || underlyingResource . getType ( ) == IResource . PROJECT ) { resources = computeFolderNonJavaResources ( handle , ( IContainer ) underlyingResource , handle . fullInclusionPatternChars ( ) , handle . fullExclusionPatternChars ( ) ) ; } } catch ( JavaModelException e ) { } return resources ; } synchronized Object [ ] getNonJavaResources ( IJavaProject project , IResource underlyingResource , PackageFragmentRoot handle ) { Object [ ] resources = this . nonJavaResources ; if ( resources == null ) { resources = computeNonJavaResources ( underlyingResource , handle ) ; this . nonJavaResources = resources ; } return resources ; } public int getRootKind ( ) { return this . rootKind ; } protected SourceMapper getSourceMapper ( ) { return this . sourceMapper ; } private static boolean isClasspathEntry ( IPath path , IClasspathEntry [ ] resolvedClasspath ) { for ( int i = 0 , length = resolvedClasspath . length ; i < length ; i ++ ) { IClasspathEntry entry = resolvedClasspath [ i ] ; if ( entry . getPath ( ) . equals ( path ) ) { return true ; } } return false ; } void setNonJavaResources ( Object [ ] resources ) { this . nonJavaResources = resources ; } protected void setRootKind ( int newRootKind ) { this . rootKind = newRootKind ; } protected void setSourceMapper ( SourceMapper mapper ) { this . sourceMapper = mapper ; } } </s>