<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IInitializer ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . ISearchRequestor ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; class SearchableEnvironmentRequestor extends JavaElementRequestor { protected ISearchRequestor requestor ; protected ICompilationUnit unitToSkip ; protected IJavaProject project ; protected NameLookup nameLookup ; protected boolean checkAccessRestrictions ; public SearchableEnvironmentRequestor ( ISearchRequestor requestor ) { this . requestor = requestor ; this . unitToSkip = null ; this . project = null ; this . nameLookup = null ; this . checkAccessRestrictions = false ; } public SearchableEnvironmentRequestor ( ISearchRequestor requestor , ICompilationUnit unitToSkip , IJavaProject project , NameLookup nameLookup ) { this . requestor = requestor ; this . unitToSkip = unitToSkip ; this . project = project ; this . nameLookup = nameLookup ; this . checkAccessRestrictions = ! JavaCore . IGNORE . equals ( project . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) || ! JavaCore . IGNORE . equals ( project . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ; } public void acceptInitializer ( IInitializer initializer ) { } public void acceptPackageFragment ( IPackageFragment packageFragment ) { this . requestor . acceptPackage ( packageFragment . getElementName ( ) . toCharArray ( ) ) ; } public void acceptType ( IType type ) { try { if ( this . unitToSkip != null && this . unitToSkip . equals ( type . getCompilationUnit ( ) ) ) { return ; } char [ ] packageName = type . getPackageFragment ( ) . getElementName ( ) . toCharArray ( ) ; boolean isBinary = type instanceof BinaryType ; AccessRestriction accessRestriction = null ; if ( this . checkAccessRestrictions && ( isBinary || ! type . getJavaProject ( ) . equals ( this . project ) ) ) { PackageFragmentRoot root = ( PackageFragmentRoot ) type . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; ClasspathEntry entry = ( ClasspathEntry ) this . nameLookup . rootToResolvedEntries . get ( root ) ; if ( entry != null ) { AccessRuleSet accessRuleSet = entry . getAccessRuleSet ( ) ; if ( accessRuleSet != null ) { char [ ] [ ] packageChars = CharOperation . splitOn ( '.' , packageName ) ; char [ ] fileWithoutExtension = type . getElementName ( ) . toCharArray ( ) ; accessRestriction = accessRuleSet . getViolatedRestriction ( CharOperation . concatWith ( packageChars , fileWithoutExtension , '/' ) ) ; } } } this . requestor . acceptType ( packageName , type . getElementName ( ) . toCharArray ( ) , null , type . getFlags ( ) , accessRestriction ) ; } catch ( JavaModelException jme ) { } } } </s>