<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import java . util . Map ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaModelMarker ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . util . CompilerUtils ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . Compiler ; import org . eclipse . jdt . internal . compiler . DefaultErrorHandlingPolicies ; import org . eclipse . jdt . internal . compiler . ICompilerRequestor ; import org . eclipse . jdt . internal . compiler . IErrorHandlingPolicy ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . PackageBinding ; import org . eclipse . jdt . internal . compiler . parser . SourceTypeConverter ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . core . util . Util ; public class CompilationUnitProblemFinder extends Compiler { protected CompilationUnitProblemFinder ( INameEnvironment environment , IErrorHandlingPolicy policy , CompilerOptions compilerOptions , ICompilerRequestor requestor , IProblemFactory problemFactory ) { super ( environment , policy , compilerOptions , requestor , problemFactory ) ; } public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding , AccessRestriction accessRestriction ) { CompilationResult result = new CompilationResult ( sourceTypes [ 0 ] . getFileName ( ) , 1 , 1 , this . options . maxProblemsPerUnit ) ; CompilationUnitDeclaration unit = SourceTypeConverter . buildCompilationUnit ( sourceTypes , SourceTypeConverter . FIELD_AND_METHOD | SourceTypeConverter . MEMBER_TYPE | SourceTypeConverter . FIELD_INITIALIZATION , this . lookupEnvironment . problemReporter , result ) ; if ( unit != null ) { this . lookupEnvironment . buildTypeBindings ( unit , accessRestriction ) ; this . lookupEnvironment . completeTypeBindings ( unit ) ; } } protected static CompilerOptions getCompilerOptions ( Map settings , boolean creatingAST , boolean statementsRecovery ) { CompilerOptions compilerOptions = new CompilerOptions ( settings ) ; compilerOptions . performMethodsFullRecovery = statementsRecovery ; compilerOptions . performStatementsRecovery = statementsRecovery ; compilerOptions . parseLiteralExpressionsAsConstants = ! creatingAST ; compilerOptions . storeAnnotations = creatingAST ; return compilerOptions ; } protected static IErrorHandlingPolicy getHandlingPolicy ( ) { return DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) ; } protected static ICompilerRequestor getRequestor ( ) { return new ICompilerRequestor ( ) { public void acceptResult ( CompilationResult compilationResult ) { } } ; } public static CompilationUnitDeclaration process ( CompilationUnit unitElement , SourceElementParser parser , WorkingCopyOwner workingCopyOwner , HashMap problems , boolean creatingAST , int reconcileFlags , IProgressMonitor monitor ) throws JavaModelException { JavaProject project = ( JavaProject ) unitElement . getJavaProject ( ) ; CancelableNameEnvironment environment = null ; CancelableProblemFactory problemFactory = null ; CompilationUnitProblemFinder problemFinder = null ; CompilationUnitDeclaration unit = null ; try { environment = new CancelableNameEnvironment ( project , workingCopyOwner , monitor ) ; problemFactory = new CancelableProblemFactory ( monitor ) ; CompilerOptions compilerOptions = getCompilerOptions ( project . getOptions ( true ) , creatingAST , ( ( reconcileFlags & ICompilationUnit . ENABLE_STATEMENTS_RECOVERY ) != 0 ) ) ; boolean ignoreMethodBodies = ( reconcileFlags & ICompilationUnit . IGNORE_METHOD_BODIES ) != 0 ; compilerOptions . ignoreMethodBodies = ignoreMethodBodies ; CompilerUtils . configureOptionsBasedOnNature ( compilerOptions , project ) ; problemFinder = new CompilationUnitProblemFinder ( environment , getHandlingPolicy ( ) , compilerOptions , getRequestor ( ) , problemFactory ) ; boolean analyzeAndGenerateCode = true ; if ( ignoreMethodBodies ) { analyzeAndGenerateCode = false ; } try { if ( parser != null ) { problemFinder . parser = parser ; unit = parser . parseCompilationUnit ( unitElement , true , monitor ) ; problemFinder . resolve ( unit , unitElement , true , analyzeAndGenerateCode , analyzeAndGenerateCode ) ; } else { unit = problemFinder . resolve ( unitElement , true , analyzeAndGenerateCode , analyzeAndGenerateCode ) ; } } catch ( AbortCompilation e ) { problemFinder . handleInternalException ( e , unit ) ; } if ( unit != null ) { CompilationResult unitResult = unit . compilationResult ; CategorizedProblem [ ] unitProblems = unitResult . getProblems ( ) ; int length = unitProblems == null ? 0 : unitProblems . length ; if ( length > 0 ) { CategorizedProblem [ ] categorizedProblems = new CategorizedProblem [ length ] ; System . arraycopy ( unitProblems , 0 , categorizedProblems , 0 , length ) ; problems . put ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , categorizedProblems ) ; } unitProblems = unitResult . getTasks ( ) ; length = unitProblems == null ? 0 : unitProblems . length ; if ( length > 0 ) { CategorizedProblem [ ] categorizedProblems = new CategorizedProblem [ length ] ; System . arraycopy ( unitProblems , 0 , categorizedProblems , 0 , length ) ; problems . put ( IJavaModelMarker . TASK_MARKER , categorizedProblems ) ; } if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "ms" ) ; System . out . println ( Thread . currentThread ( ) + "" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "ms" ) ; } } } catch ( OperationCanceledException e ) { throw e ; } catch ( RuntimeException e ) { String lineDelimiter = unitElement . findRecommendedLineSeparator ( ) ; StringBuffer message = new StringBuffer ( "" ) ; message . append ( lineDelimiter ) ; message . append ( "" ) ; message . append ( lineDelimiter ) ; message . append ( unitElement . getSource ( ) ) ; message . append ( lineDelimiter ) ; message . append ( "" ) ; Util . log ( e , message . toString ( ) ) ; throw new JavaModelException ( e , IJavaModelStatusConstants . COMPILER_FAILURE ) ; } finally { if ( environment != null ) environment . setMonitor ( null ) ; if ( problemFactory != null ) problemFactory . monitor = null ; if ( problemFinder != null && ! creatingAST ) problemFinder . lookupEnvironment . reset ( ) ; } return unit ; } public static CompilationUnitDeclaration process ( CompilationUnit unitElement , WorkingCopyOwner workingCopyOwner , HashMap problems , boolean creatingAST , int reconcileFlags , IProgressMonitor monitor ) throws JavaModelException { return process ( unitElement , null , workingCopyOwner , problems , creatingAST , reconcileFlags , monitor ) ; } public void initializeParser ( ) { this . parser = LanguageSupportFactory . getParser ( this , this . lookupEnvironment == null ? null : this . lookupEnvironment . globalOptions , this . problemReporter , this . options . parseLiteralExpressionsAsConstants , 3 ) ; } } </s>