text
stringlengths
30
1.67M
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . * ; import java . io . * ; import java . util . * ; public class NameEnvironment implements INameEnvironment , SuffixConstants { boolean isIncrementalBuild ; ClasspathMultiDirectory [ ] sourceLocations ; ClasspathLocation [ ] binaryLocations ; BuildNotifier notifier ; SimpleSet initialTypeNames ; SimpleLookupTable additionalUnits ; NameEnvironment ( IWorkspaceRoot root , JavaProject javaProject , SimpleLookupTable binaryLocationsPerProject , BuildNotifier notifier ) throws CoreException { this . isIncrementalBuild = false ; this . notifier = notifier ; computeClasspathLocations ( root , javaProject , binaryLocationsPerProject ) ; setNames ( null , null ) ; } public NameEnvironment ( IJavaProject javaProject ) { this . isIncrementalBuild = false ; try { computeClasspathLocations ( javaProject . getProject ( ) . getWorkspace ( ) . getRoot ( ) , ( JavaProject ) javaProject , null ) ; } catch ( CoreException e ) { this . sourceLocations = new ClasspathMultiDirectory [ <NUM_LIT:0> ] ; this . binaryLocations = new ClasspathLocation [ <NUM_LIT:0> ] ; } setNames ( null , null ) ; } private void computeClasspathLocations ( IWorkspaceRoot root , JavaProject javaProject , SimpleLookupTable binaryLocationsPerProject ) throws CoreException { IMarker cycleMarker = javaProject . getCycleMarker ( ) ; if ( cycleMarker != null ) { int severity = JavaCore . ERROR . equals ( javaProject . getOption ( JavaCore . CORE_CIRCULAR_CLASSPATH , true ) ) ? IMarker . SEVERITY_ERROR : IMarker . SEVERITY_WARNING ; if ( severity != cycleMarker . getAttribute ( IMarker . SEVERITY , severity ) ) cycleMarker . setAttribute ( IMarker . SEVERITY , severity ) ; } IClasspathEntry [ ] classpathEntries = javaProject . getExpandedClasspath ( ) ; ArrayList sLocations = new ArrayList ( classpathEntries . length ) ; ArrayList bLocations = new ArrayList ( classpathEntries . length ) ; nextEntry : for ( int i = <NUM_LIT:0> , l = classpathEntries . length ; i < l ; i ++ ) { ClasspathEntry entry = ( ClasspathEntry ) classpathEntries [ i ] ; IPath path = entry . getPath ( ) ; Object target = JavaModel . getTarget ( path , true ) ; if ( target == null ) continue nextEntry ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_SOURCE : if ( ! ( target instanceof IContainer ) ) continue nextEntry ; IPath outputPath = entry . getOutputLocation ( ) != null ? entry . getOutputLocation ( ) : javaProject . getOutputLocation ( ) ; IContainer outputFolder ; if ( outputPath . segmentCount ( ) == <NUM_LIT:1> ) { outputFolder = javaProject . getProject ( ) ; } else { outputFolder = root . getFolder ( outputPath ) ; if ( ! outputFolder . exists ( ) ) createOutputFolder ( outputFolder ) ; } sLocations . add ( ClasspathLocation . forSourceFolder ( ( IContainer ) target , outputFolder , entry . fullInclusionPatternChars ( ) , entry . fullExclusionPatternChars ( ) ) ) ; continue nextEntry ; case IClasspathEntry . CPE_PROJECT : if ( ! ( target instanceof IProject ) ) continue nextEntry ; IProject prereqProject = ( IProject ) target ; if ( ! JavaProject . hasJavaNature ( prereqProject ) ) continue nextEntry ; JavaProject prereqJavaProject = ( JavaProject ) JavaCore . create ( prereqProject ) ; IClasspathEntry [ ] prereqClasspathEntries = prereqJavaProject . getRawClasspath ( ) ; ArrayList seen = new ArrayList ( ) ; nextPrereqEntry : for ( int j = <NUM_LIT:0> , m = prereqClasspathEntries . length ; j < m ; j ++ ) { IClasspathEntry prereqEntry = prereqClasspathEntries [ j ] ; if ( prereqEntry . getEntryKind ( ) == IClasspathEntry . CPE_SOURCE ) { Object prereqTarget = JavaModel . getTarget ( prereqEntry . getPath ( ) , true ) ; if ( ! ( prereqTarget instanceof IContainer ) ) continue nextPrereqEntry ; IPath prereqOutputPath = prereqEntry . getOutputLocation ( ) != null ? prereqEntry . getOutputLocation ( ) : prereqJavaProject . getOutputLocation ( ) ; IContainer binaryFolder = prereqOutputPath . segmentCount ( ) == <NUM_LIT:1> ? ( IContainer ) prereqProject : ( IContainer ) root . getFolder ( prereqOutputPath ) ; if ( binaryFolder . exists ( ) && ! seen . contains ( binaryFolder ) ) { seen . add ( binaryFolder ) ; ClasspathLocation bLocation = ClasspathLocation . forBinaryFolder ( binaryFolder , true , entry . getAccessRuleSet ( ) ) ; bLocations . add ( bLocation ) ; if ( binaryLocationsPerProject != null ) { ClasspathLocation [ ] existingLocations = ( ClasspathLocation [ ] ) binaryLocationsPerProject . get ( prereqProject ) ; if ( existingLocations == null ) { existingLocations = new ClasspathLocation [ ] { bLocation } ; } else { int size = existingLocations . length ; System . arraycopy ( existingLocations , <NUM_LIT:0> , existingLocations = new ClasspathLocation [ size + <NUM_LIT:1> ] , <NUM_LIT:0> , size ) ; existingLocations [ size ] = bLocation ; } binaryLocationsPerProject . put ( prereqProject , existingLocations ) ; } } } } continue nextEntry ; case IClasspathEntry . CPE_LIBRARY : if ( target instanceof IResource ) { IResource resource = ( IResource ) target ; ClasspathLocation bLocation = null ; if ( resource instanceof IFile ) { AccessRuleSet accessRuleSet = ( JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) && JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ) ? null : entry . getAccessRuleSet ( ) ; bLocation = ClasspathLocation . forLibrary ( ( IFile ) resource , accessRuleSet ) ; } else if ( resource instanceof IContainer ) { AccessRuleSet accessRuleSet = ( JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) && JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ) ? null : entry . getAccessRuleSet ( ) ; bLocation = ClasspathLocation . forBinaryFolder ( ( IContainer ) target , false , accessRuleSet ) ; } bLocations . add ( bLocation ) ; if ( binaryLocationsPerProject != null ) { IProject p = resource . getProject ( ) ; ClasspathLocation [ ] existingLocations = ( ClasspathLocation [ ] ) binaryLocationsPerProject . get ( p ) ; if ( existingLocations == null ) { existingLocations = new ClasspathLocation [ ] { bLocation } ; } else { int size = existingLocations . length ; System . arraycopy ( existingLocations , <NUM_LIT:0> , existingLocations = new ClasspathLocation [ size + <NUM_LIT:1> ] , <NUM_LIT:0> , size ) ; existingLocations [ size ] = bLocation ; } binaryLocationsPerProject . put ( p , existingLocations ) ; } } else if ( target instanceof File ) { AccessRuleSet accessRuleSet = ( JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) && JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ) ? null : entry . getAccessRuleSet ( ) ; bLocations . add ( ClasspathLocation . forLibrary ( path . toString ( ) , accessRuleSet ) ) ; } continue nextEntry ; } } ArrayList outputFolders = new ArrayList ( <NUM_LIT:1> ) ; this . sourceLocations = new ClasspathMultiDirectory [ sLocations . size ( ) ] ; if ( ! sLocations . isEmpty ( ) ) { sLocations . toArray ( this . sourceLocations ) ; next : for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { ClasspathMultiDirectory md = this . sourceLocations [ i ] ; IPath outputPath = md . binaryFolder . getFullPath ( ) ; for ( int j = <NUM_LIT:0> ; j < i ; j ++ ) { if ( outputPath . equals ( this . sourceLocations [ j ] . binaryFolder . getFullPath ( ) ) ) { md . hasIndependentOutputFolder = this . sourceLocations [ j ] . hasIndependentOutputFolder ; continue next ; } } outputFolders . add ( md ) ; for ( int j = <NUM_LIT:0> , m = this . sourceLocations . length ; j < m ; j ++ ) if ( outputPath . equals ( this . sourceLocations [ j ] . sourceFolder . getFullPath ( ) ) ) continue next ; md . hasIndependentOutputFolder = true ; } } this . binaryLocations = new ClasspathLocation [ outputFolders . size ( ) + bLocations . size ( ) ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , l = outputFolders . size ( ) ; i < l ; i ++ ) this . binaryLocations [ index ++ ] = ( ClasspathLocation ) outputFolders . get ( i ) ; for ( int i = <NUM_LIT:0> , l = bLocations . size ( ) ; i < l ; i ++ ) this . binaryLocations [ index ++ ] = ( ClasspathLocation ) bLocations . get ( i ) ; } public void cleanup ( ) { this . initialTypeNames = null ; this . additionalUnits = null ; for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) this . sourceLocations [ i ] . cleanup ( ) ; for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) this . binaryLocations [ i ] . cleanup ( ) ; } private void createOutputFolder ( IContainer outputFolder ) throws CoreException { createParentFolder ( outputFolder . getParent ( ) ) ; ( ( IFolder ) outputFolder ) . create ( IResource . FORCE | IResource . DERIVED , true , null ) ; } private void createParentFolder ( IContainer parent ) throws CoreException { if ( ! parent . exists ( ) ) { createParentFolder ( parent . getParent ( ) ) ; ( ( IFolder ) parent ) . create ( true , true , null ) ; } } private NameEnvironmentAnswer findClass ( String qualifiedTypeName , char [ ] typeName ) { if ( this . notifier != null ) this . notifier . checkCancelWithinCompiler ( ) ; if ( this . initialTypeNames != null && this . initialTypeNames . includes ( qualifiedTypeName ) ) { if ( this . isIncrementalBuild ) throw new AbortCompilation ( true , new AbortIncrementalBuildException ( qualifiedTypeName ) ) ; return null ; } if ( this . additionalUnits != null && this . sourceLocations . length > <NUM_LIT:0> ) { SourceFile unit = ( SourceFile ) this . additionalUnits . get ( qualifiedTypeName ) ; if ( unit != null ) return new NameEnvironmentAnswer ( unit , null ) ; } String qBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class ; String binaryFileName = qBinaryFileName ; String qPackageName = "<STR_LIT>" ; if ( qualifiedTypeName . length ( ) > typeName . length ) { int typeNameStart = qBinaryFileName . length ( ) - typeName . length - <NUM_LIT:6> ; qPackageName = qBinaryFileName . substring ( <NUM_LIT:0> , typeNameStart - <NUM_LIT:1> ) ; binaryFileName = qBinaryFileName . substring ( typeNameStart ) ; } NameEnvironmentAnswer suggestedAnswer = null ; for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) { NameEnvironmentAnswer answer = this . binaryLocations [ i ] . findClass ( binaryFileName , qPackageName , qBinaryFileName ) ; if ( answer != null ) { if ( ! answer . ignoreIfBetter ( ) ) { if ( answer . isBetter ( suggestedAnswer ) ) return answer ; } else if ( answer . isBetter ( suggestedAnswer ) ) suggestedAnswer = answer ; } } if ( suggestedAnswer != null ) return suggestedAnswer ; return null ; } public NameEnvironmentAnswer findType ( char [ ] [ ] compoundName ) { if ( compoundName != null ) return findClass ( new String ( CharOperation . concatWith ( compoundName , '<CHAR_LIT:/>' ) ) , compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; return null ; } public NameEnvironmentAnswer findType ( char [ ] typeName , char [ ] [ ] packageName ) { if ( typeName != null ) return findClass ( new String ( CharOperation . concatWith ( packageName , typeName , '<CHAR_LIT:/>' ) ) , typeName ) ; return null ; } public boolean isPackage ( char [ ] [ ] compoundName , char [ ] packageName ) { return isPackage ( new String ( CharOperation . concatWith ( compoundName , packageName , '<CHAR_LIT:/>' ) ) ) ; } public boolean isPackage ( String qualifiedPackageName ) { for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) if ( this . binaryLocations [ i ] . isPackage ( qualifiedPackageName ) ) return true ; return false ; } void setNames ( String [ ] typeNames , SourceFile [ ] additionalFiles ) { if ( typeNames == null ) { this . initialTypeNames = null ; } else { this . initialTypeNames = new SimpleSet ( typeNames . length ) ; for ( int i = <NUM_LIT:0> , l = typeNames . length ; i < l ; i ++ ) this . initialTypeNames . add ( typeNames [ i ] ) ; } if ( additionalFiles == null ) { this . additionalUnits = null ; } else { this . additionalUnits = new SimpleLookupTable ( additionalFiles . length ) ; for ( int i = <NUM_LIT:0> , l = additionalFiles . length ; i < l ; i ++ ) { SourceFile additionalUnit = additionalFiles [ i ] ; if ( additionalUnit != null ) this . additionalUnits . put ( additionalUnit . initialTypeName , additionalFiles [ i ] ) ; } } for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) this . sourceLocations [ i ] . reset ( ) ; for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) this . binaryLocations [ i ] . reset ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import java . io . ByteArrayInputStream ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . Locale ; import java . util . Map ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IResourceProxy ; import org . eclipse . core . resources . IResourceProxyVisitor ; import org . eclipse . core . resources . IResourceStatus ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IJavaModelMarker ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaConventions ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . core . util . CompilerUtils ; import org . eclipse . jdt . internal . compiler . AbstractAnnotationProcessorManager ; import org . eclipse . jdt . internal . compiler . ClassFile ; 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 . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class AbstractImageBuilder implements ICompilerRequestor , ICompilationUnitLocator { protected JavaBuilder javaBuilder ; protected State newState ; protected NameEnvironment nameEnvironment ; protected ClasspathMultiDirectory [ ] sourceLocations ; public BuildNotifier notifier ; protected Compiler compiler ; protected WorkQueue workQueue ; protected ArrayList problemSourceFiles ; protected boolean compiledAllAtOnce ; private boolean inCompiler ; protected boolean keepStoringProblemMarkers ; protected SimpleSet filesWithAnnotations = null ; public static int MAX_AT_ONCE = <NUM_LIT> ; public final static String [ ] JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES = { IMarker . MESSAGE , IMarker . SEVERITY , IJavaModelMarker . ID , IMarker . CHAR_START , IMarker . CHAR_END , IMarker . LINE_NUMBER , IJavaModelMarker . ARGUMENTS , IJavaModelMarker . CATEGORY_ID , } ; public final static String [ ] JAVA_TASK_MARKER_ATTRIBUTE_NAMES = { IMarker . MESSAGE , IMarker . PRIORITY , IJavaModelMarker . ID , IMarker . CHAR_START , IMarker . CHAR_END , IMarker . LINE_NUMBER , IMarker . USER_EDITABLE , IMarker . SOURCE_ID , } ; public final static Integer S_ERROR = new Integer ( IMarker . SEVERITY_ERROR ) ; public final static Integer S_WARNING = new Integer ( IMarker . SEVERITY_WARNING ) ; public final static Integer P_HIGH = new Integer ( IMarker . PRIORITY_HIGH ) ; public final static Integer P_NORMAL = new Integer ( IMarker . PRIORITY_NORMAL ) ; public final static Integer P_LOW = new Integer ( IMarker . PRIORITY_LOW ) ; protected AbstractImageBuilder ( JavaBuilder javaBuilder , boolean buildStarting , State newState ) { this . javaBuilder = javaBuilder ; this . nameEnvironment = javaBuilder . nameEnvironment ; this . sourceLocations = this . nameEnvironment . sourceLocations ; this . notifier = javaBuilder . notifier ; this . keepStoringProblemMarkers = true ; if ( buildStarting ) { this . newState = newState == null ? new State ( javaBuilder ) : newState ; this . compiler = newCompiler ( ) ; this . workQueue = new WorkQueue ( ) ; this . problemSourceFiles = new ArrayList ( <NUM_LIT:3> ) ; if ( this . javaBuilder . participants != null ) { for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; i < l ; i ++ ) { if ( this . javaBuilder . participants [ i ] . isAnnotationProcessor ( ) ) { this . filesWithAnnotations = new SimpleSet ( <NUM_LIT:1> ) ; break ; } } } } } public void acceptResult ( CompilationResult result ) { SourceFile compilationUnit = ( SourceFile ) result . getCompilationUnit ( ) ; if ( ! this . workQueue . isCompiled ( compilationUnit ) ) { this . workQueue . finished ( compilationUnit ) ; try { updateProblemsFor ( compilationUnit , result ) ; updateTasksFor ( compilationUnit , result ) ; } catch ( CoreException e ) { throw internalException ( e ) ; } if ( result . hasInconsistentToplevelHierarchies ) if ( ! this . problemSourceFiles . contains ( compilationUnit ) ) this . problemSourceFiles . add ( compilationUnit ) ; IType mainType = null ; String mainTypeName = null ; String typeLocator = compilationUnit . typeLocator ( ) ; ClassFile [ ] classFiles = result . getClassFiles ( ) ; int length = classFiles . length ; ArrayList duplicateTypeNames = null ; ArrayList definedTypeNames = new ArrayList ( length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ClassFile classFile = classFiles [ i ] ; char [ ] [ ] compoundName = classFile . getCompoundName ( ) ; char [ ] typeName = compoundName [ compoundName . length - <NUM_LIT:1> ] ; boolean isNestedType = classFile . isNestedType ; if ( isNestedType ) { String qualifiedTypeName = new String ( classFile . outerMostEnclosingClassFile ( ) . fileName ( ) ) ; if ( this . newState . isDuplicateLocator ( qualifiedTypeName , typeLocator ) ) continue ; } else { String qualifiedTypeName = new String ( classFile . fileName ( ) ) ; if ( this . newState . isDuplicateLocator ( qualifiedTypeName , typeLocator ) ) { if ( duplicateTypeNames == null ) duplicateTypeNames = new ArrayList ( ) ; duplicateTypeNames . add ( compoundName ) ; if ( mainType == null ) { try { mainTypeName = compilationUnit . initialTypeName ; mainType = this . javaBuilder . javaProject . findType ( mainTypeName . replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) ; } catch ( JavaModelException e ) { } } IType type ; if ( qualifiedTypeName . equals ( mainTypeName ) ) { type = mainType ; } else { String simpleName = qualifiedTypeName . substring ( qualifiedTypeName . lastIndexOf ( '<CHAR_LIT:/>' ) + <NUM_LIT:1> ) ; type = mainType == null ? null : mainType . getCompilationUnit ( ) . getType ( simpleName ) ; } createProblemFor ( compilationUnit . resource , type , Messages . bind ( Messages . build_duplicateClassFile , new String ( typeName ) ) , JavaCore . ERROR ) ; continue ; } this . newState . recordLocatorForType ( qualifiedTypeName , typeLocator ) ; if ( result . checkSecondaryTypes && ! qualifiedTypeName . equals ( compilationUnit . initialTypeName ) ) acceptSecondaryType ( classFile ) ; } try { definedTypeNames . add ( writeClassFile ( classFile , compilationUnit , ! isNestedType ) ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; if ( e . getStatus ( ) . getCode ( ) == IResourceStatus . CASE_VARIANT_EXISTS ) createProblemFor ( compilationUnit . resource , null , Messages . bind ( Messages . build_classFileCollision , e . getMessage ( ) ) , JavaCore . ERROR ) ; else createProblemFor ( compilationUnit . resource , null , Messages . build_inconsistentClassFile , JavaCore . ERROR ) ; } } if ( result . hasAnnotations && this . filesWithAnnotations != null ) this . filesWithAnnotations . add ( compilationUnit ) ; this . compiler . lookupEnvironment . releaseClassFiles ( classFiles ) ; finishedWith ( typeLocator , result , compilationUnit . getMainTypeName ( ) , definedTypeNames , duplicateTypeNames ) ; this . notifier . compiled ( compilationUnit ) ; } } protected void acceptSecondaryType ( ClassFile classFile ) { } protected void addAllSourceFiles ( final ArrayList sourceFiles ) throws CoreException { final boolean isInterestingProject = LanguageSupportFactory . isInterestingProject ( this . javaBuilder . getProject ( ) ) ; for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { final ClasspathMultiDirectory sourceLocation = this . sourceLocations [ i ] ; final char [ ] [ ] exclusionPatterns = sourceLocation . exclusionPatterns ; final char [ ] [ ] inclusionPatterns = sourceLocation . inclusionPatterns ; final boolean isAlsoProject = sourceLocation . sourceFolder . equals ( this . javaBuilder . currentProject ) ; final int segmentCount = sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; final IContainer outputFolder = sourceLocation . binaryFolder ; final boolean isOutputFolder = sourceLocation . sourceFolder . equals ( outputFolder ) ; sourceLocation . sourceFolder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { switch ( proxy . getType ( ) ) { case IResource . FILE : String resourceName = proxy . getName ( ) ; if ( ( ! isInterestingProject && org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( resourceName ) && ! LanguageSupportFactory . isInterestingSourceFile ( resourceName ) ) || ( isInterestingProject && LanguageSupportFactory . isSourceFile ( resourceName , isInterestingProject ) ) ) { IResource resource = proxy . requestResource ( ) ; if ( exclusionPatterns != null || inclusionPatterns != null ) if ( Util . isExcluded ( resource . getFullPath ( ) , inclusionPatterns , exclusionPatterns , false ) ) return false ; sourceFiles . add ( new SourceFile ( ( IFile ) resource , sourceLocation ) ) ; } return false ; case IResource . FOLDER : IPath folderPath = null ; if ( isAlsoProject ) if ( isExcludedFromProject ( folderPath = proxy . requestFullPath ( ) ) ) return false ; if ( exclusionPatterns != null ) { if ( folderPath == null ) folderPath = proxy . requestFullPath ( ) ; if ( Util . isExcluded ( folderPath , inclusionPatterns , exclusionPatterns , true ) ) { return inclusionPatterns != null ; } } if ( ! isOutputFolder ) { if ( folderPath == null ) folderPath = proxy . requestFullPath ( ) ; String packageName = folderPath . lastSegment ( ) ; if ( packageName . length ( ) > <NUM_LIT:0> ) { String sourceLevel = AbstractImageBuilder . this . javaBuilder . javaProject . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = AbstractImageBuilder . this . javaBuilder . javaProject . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; if ( JavaConventions . validatePackageName ( packageName , sourceLevel , complianceLevel ) . getSeverity ( ) != IStatus . ERROR ) createFolder ( folderPath . removeFirstSegments ( segmentCount ) , outputFolder ) ; } } } return true ; } } , IResource . NONE ) ; this . notifier . checkCancel ( ) ; } } protected void cleanUp ( ) { this . nameEnvironment . cleanup ( ) ; this . javaBuilder = null ; this . nameEnvironment = null ; this . sourceLocations = null ; this . notifier = null ; this . compiler = null ; this . workQueue = null ; this . problemSourceFiles = null ; } protected void compile ( SourceFile [ ] units ) { if ( this . filesWithAnnotations != null && this . filesWithAnnotations . elementSize > <NUM_LIT:0> ) this . filesWithAnnotations . clear ( ) ; CompilationParticipantResult [ ] participantResults = this . javaBuilder . participants == null ? null : notifyParticipants ( units ) ; if ( participantResults != null && participantResults . length > units . length ) { units = new SourceFile [ participantResults . length ] ; for ( int i = participantResults . length ; -- i >= <NUM_LIT:0> ; ) units [ i ] = participantResults [ i ] . sourceFile ; } int unitsLength = units . length ; this . compiledAllAtOnce = unitsLength <= MAX_AT_ONCE ; if ( this . compiler != null && this . compiler . options != null && this . compiler . options . buildGroovyFiles == <NUM_LIT:2> ) { this . compiledAllAtOnce = true ; } if ( this . compiledAllAtOnce ) { if ( JavaBuilder . DEBUG ) for ( int i = <NUM_LIT:0> ; i < unitsLength ; i ++ ) System . out . println ( "<STR_LIT>" + units [ i ] . typeLocator ( ) ) ; compile ( units , null , true ) ; } else { SourceFile [ ] remainingUnits = new SourceFile [ unitsLength ] ; System . arraycopy ( units , <NUM_LIT:0> , remainingUnits , <NUM_LIT:0> , unitsLength ) ; int doNow = unitsLength < MAX_AT_ONCE ? unitsLength : MAX_AT_ONCE ; SourceFile [ ] toCompile = new SourceFile [ doNow ] ; int remainingIndex = <NUM_LIT:0> ; boolean compilingFirstGroup = true ; while ( remainingIndex < unitsLength ) { int count = <NUM_LIT:0> ; while ( remainingIndex < unitsLength && count < doNow ) { SourceFile unit = remainingUnits [ remainingIndex ] ; if ( unit != null && ( compilingFirstGroup || this . workQueue . isWaiting ( unit ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + remainingIndex + "<STR_LIT:U+0020:U+0020>" + unit . typeLocator ( ) ) ; toCompile [ count ++ ] = unit ; } remainingUnits [ remainingIndex ++ ] = null ; } if ( count < doNow ) System . arraycopy ( toCompile , <NUM_LIT:0> , toCompile = new SourceFile [ count ] , <NUM_LIT:0> , count ) ; if ( ! compilingFirstGroup ) for ( int a = remainingIndex ; a < unitsLength ; a ++ ) if ( remainingUnits [ a ] != null && this . workQueue . isCompiled ( remainingUnits [ a ] ) ) remainingUnits [ a ] = null ; compile ( toCompile , remainingUnits , compilingFirstGroup ) ; compilingFirstGroup = false ; } } if ( participantResults != null ) { for ( int i = participantResults . length ; -- i >= <NUM_LIT:0> ; ) if ( participantResults [ i ] != null ) recordParticipantResult ( participantResults [ i ] ) ; processAnnotations ( participantResults ) ; } } protected void compile ( SourceFile [ ] units , SourceFile [ ] additionalUnits , boolean compilingFirstGroup ) { if ( units . length == <NUM_LIT:0> ) return ; this . notifier . aboutToCompile ( units [ <NUM_LIT:0> ] ) ; if ( ! this . problemSourceFiles . isEmpty ( ) ) { int toAdd = this . problemSourceFiles . size ( ) ; int length = additionalUnits == null ? <NUM_LIT:0> : additionalUnits . length ; if ( length == <NUM_LIT:0> ) additionalUnits = new SourceFile [ toAdd ] ; else System . arraycopy ( additionalUnits , <NUM_LIT:0> , additionalUnits = new SourceFile [ length + toAdd ] , <NUM_LIT:0> , length ) ; for ( int i = <NUM_LIT:0> ; i < toAdd ; i ++ ) additionalUnits [ length + i ] = ( SourceFile ) this . problemSourceFiles . get ( i ) ; } String [ ] initialTypeNames = new String [ units . length ] ; for ( int i = <NUM_LIT:0> , l = units . length ; i < l ; i ++ ) initialTypeNames [ i ] = units [ i ] . initialTypeName ; this . nameEnvironment . setNames ( initialTypeNames , additionalUnits ) ; this . notifier . checkCancel ( ) ; try { this . inCompiler = true ; this . compiler . compile ( units ) ; } catch ( AbortCompilation ignored ) { } finally { this . inCompiler = false ; } this . notifier . checkCancel ( ) ; } protected void copyResource ( IResource source , IResource destination ) throws CoreException { IPath destPath = destination . getFullPath ( ) ; try { source . copy ( destPath , IResource . FORCE | IResource . DERIVED , null ) ; } catch ( CoreException e ) { source . refreshLocal ( <NUM_LIT:0> , null ) ; if ( ! source . exists ( ) ) return ; throw e ; } Util . setReadOnly ( destination , false ) ; } protected void createProblemFor ( IResource resource , IMember javaElement , String message , String problemSeverity ) { try { IMarker marker = resource . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; int severity = problemSeverity . equals ( JavaCore . WARNING ) ? IMarker . SEVERITY_WARNING : IMarker . SEVERITY_ERROR ; ISourceRange range = null ; if ( javaElement != null ) { try { range = javaElement . getNameRange ( ) ; } catch ( JavaModelException e ) { if ( e . getJavaModelStatus ( ) . getCode ( ) != IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST ) { throw e ; } if ( ! CharOperation . equals ( javaElement . getElementName ( ) . toCharArray ( ) , TypeConstants . PACKAGE_INFO_NAME ) ) { throw e ; } } } int start = range == null ? <NUM_LIT:0> : range . getOffset ( ) ; int end = range == null ? <NUM_LIT:1> : start + range . getLength ( ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IMarker . CHAR_START , IMarker . CHAR_END , IMarker . SOURCE_ID } , new Object [ ] { message , new Integer ( severity ) , new Integer ( start ) , new Integer ( end ) , JavaBuilder . SOURCE_ID } ) ; } catch ( CoreException e ) { throw internalException ( e ) ; } } protected void deleteGeneratedFiles ( IFile [ ] deletedGeneratedFiles ) { } protected SourceFile findSourceFile ( IFile file , boolean mustExist ) { if ( mustExist && ! file . exists ( ) ) return null ; ClasspathMultiDirectory md = this . sourceLocations [ <NUM_LIT:0> ] ; if ( this . sourceLocations . length > <NUM_LIT:1> ) { IPath sourceFileFullPath = file . getFullPath ( ) ; for ( int j = <NUM_LIT:0> , m = this . sourceLocations . length ; j < m ; j ++ ) { if ( this . sourceLocations [ j ] . sourceFolder . getFullPath ( ) . isPrefixOf ( sourceFileFullPath ) ) { md = this . sourceLocations [ j ] ; if ( md . exclusionPatterns == null && md . inclusionPatterns == null ) break ; if ( ! Util . isExcluded ( file , md . inclusionPatterns , md . exclusionPatterns ) ) break ; } } } return new SourceFile ( file , md ) ; } protected void finishedWith ( String sourceLocator , CompilationResult result , char [ ] mainTypeName , ArrayList definedTypeNames , ArrayList duplicateTypeNames ) { if ( duplicateTypeNames == null ) { this . newState . record ( sourceLocator , result . qualifiedReferences , result . simpleNameReferences , result . rootReferences , mainTypeName , definedTypeNames ) ; return ; } char [ ] [ ] simpleRefs = result . simpleNameReferences ; next : for ( int i = <NUM_LIT:0> , l = duplicateTypeNames . size ( ) ; i < l ; i ++ ) { char [ ] [ ] compoundName = ( char [ ] [ ] ) duplicateTypeNames . get ( i ) ; char [ ] typeName = compoundName [ compoundName . length - <NUM_LIT:1> ] ; int sLength = simpleRefs . length ; for ( int j = <NUM_LIT:0> ; j < sLength ; j ++ ) if ( CharOperation . equals ( simpleRefs [ j ] , typeName ) ) continue next ; System . arraycopy ( simpleRefs , <NUM_LIT:0> , simpleRefs = new char [ sLength + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , sLength ) ; simpleRefs [ sLength ] = typeName ; } this . newState . record ( sourceLocator , result . qualifiedReferences , simpleRefs , result . rootReferences , mainTypeName , definedTypeNames ) ; } protected IContainer createFolder ( IPath packagePath , IContainer outputFolder ) throws CoreException { if ( packagePath . isEmpty ( ) ) return outputFolder ; IFolder folder = outputFolder . getFolder ( packagePath ) ; if ( ! folder . exists ( ) ) { createFolder ( packagePath . removeLastSegments ( <NUM_LIT:1> ) , outputFolder ) ; folder . create ( IResource . FORCE | IResource . DERIVED , true , null ) ; } return folder ; } public ICompilationUnit fromIFile ( IFile file ) { return findSourceFile ( file , true ) ; } protected void initializeAnnotationProcessorManager ( Compiler newCompiler ) { AbstractAnnotationProcessorManager annotationManager = JavaModelManager . getJavaModelManager ( ) . createAnnotationProcessorManager ( ) ; if ( annotationManager != null ) { annotationManager . configureFromPlatform ( newCompiler , this , this . javaBuilder . javaProject ) ; annotationManager . setErr ( new PrintWriter ( System . err ) ) ; annotationManager . setOut ( new PrintWriter ( System . out ) ) ; } newCompiler . annotationProcessorManager = annotationManager ; } protected RuntimeException internalException ( CoreException t ) { ImageBuilderInternalException imageBuilderException = new ImageBuilderInternalException ( t ) ; if ( this . inCompiler ) return new AbortCompilation ( true , imageBuilderException ) ; return imageBuilderException ; } protected boolean isExcludedFromProject ( IPath childPath ) throws JavaModelException { if ( childPath . segmentCount ( ) > <NUM_LIT:2> ) return false ; for ( int j = <NUM_LIT:0> , k = this . sourceLocations . length ; j < k ; j ++ ) { if ( childPath . equals ( this . sourceLocations [ j ] . binaryFolder . getFullPath ( ) ) ) return true ; if ( childPath . equals ( this . sourceLocations [ j ] . sourceFolder . getFullPath ( ) ) ) return true ; } return childPath . equals ( this . javaBuilder . javaProject . getOutputLocation ( ) ) ; } protected Compiler newCompiler ( ) { Map projectOptions = this . javaBuilder . javaProject . getOptions ( true ) ; String option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_INVALID_JAVADOC ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_MISSING_JAVADOC_TAGS ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_MISSING_JAVADOC_COMMENTS ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_UNUSED_IMPORT ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { projectOptions . put ( JavaCore . COMPILER_DOC_COMMENT_SUPPORT , JavaCore . DISABLED ) ; } } } } CompilerOptions compilerOptions = new CompilerOptions ( projectOptions ) ; compilerOptions . performMethodsFullRecovery = true ; compilerOptions . performStatementsRecovery = true ; CompilerUtils . configureOptionsBasedOnNature ( compilerOptions , this . javaBuilder . javaProject ) ; Compiler newCompiler = new Compiler ( this . nameEnvironment , DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , compilerOptions , this , ProblemFactory . getProblemFactory ( Locale . getDefault ( ) ) ) ; CompilerOptions options = newCompiler . options ; String setting = System . getProperty ( "<STR_LIT>" ) ; newCompiler . useSingleThread = setting != null && setting . equals ( "<STR_LIT:true>" ) ; options . produceReferenceInfo = true ; if ( options . complianceLevel >= ClassFileConstants . JDK1_6 && options . processAnnotations ) { initializeAnnotationProcessorManager ( newCompiler ) ; } return newCompiler ; } protected CompilationParticipantResult [ ] notifyParticipants ( SourceFile [ ] unitsAboutToCompile ) { CompilationParticipantResult [ ] results = new CompilationParticipantResult [ unitsAboutToCompile . length ] ; for ( int i = unitsAboutToCompile . length ; -- i >= <NUM_LIT:0> ; ) results [ i ] = new CompilationParticipantResult ( unitsAboutToCompile [ i ] ) ; for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; i < l ; i ++ ) this . javaBuilder . participants [ i ] . buildStarting ( results , this instanceof BatchImageBuilder ) ; SimpleSet uniqueFiles = null ; CompilationParticipantResult [ ] toAdd = null ; int added = <NUM_LIT:0> ; for ( int i = results . length ; -- i >= <NUM_LIT:0> ; ) { CompilationParticipantResult result = results [ i ] ; if ( result == null ) continue ; IFile [ ] deletedGeneratedFiles = result . deletedFiles ; if ( deletedGeneratedFiles != null ) deleteGeneratedFiles ( deletedGeneratedFiles ) ; IFile [ ] addedGeneratedFiles = result . addedFiles ; if ( addedGeneratedFiles != null ) { for ( int j = addedGeneratedFiles . length ; -- j >= <NUM_LIT:0> ; ) { SourceFile sourceFile = findSourceFile ( addedGeneratedFiles [ j ] , true ) ; if ( sourceFile == null ) continue ; if ( uniqueFiles == null ) { uniqueFiles = new SimpleSet ( unitsAboutToCompile . length + <NUM_LIT:3> ) ; for ( int f = unitsAboutToCompile . length ; -- f >= <NUM_LIT:0> ; ) uniqueFiles . add ( unitsAboutToCompile [ f ] ) ; } if ( uniqueFiles . addIfNotIncluded ( sourceFile ) == sourceFile ) { CompilationParticipantResult newResult = new CompilationParticipantResult ( sourceFile ) ; if ( toAdd == null ) { toAdd = new CompilationParticipantResult [ addedGeneratedFiles . length ] ; } else { int length = toAdd . length ; if ( added == length ) System . arraycopy ( toAdd , <NUM_LIT:0> , toAdd = new CompilationParticipantResult [ length + addedGeneratedFiles . length ] , <NUM_LIT:0> , length ) ; } toAdd [ added ++ ] = newResult ; } } } } if ( added > <NUM_LIT:0> ) { int length = results . length ; System . arraycopy ( results , <NUM_LIT:0> , results = new CompilationParticipantResult [ length + added ] , <NUM_LIT:0> , length ) ; System . arraycopy ( toAdd , <NUM_LIT:0> , results , length , added ) ; } return results ; } protected abstract void processAnnotationResults ( CompilationParticipantResult [ ] results ) ; protected void processAnnotations ( CompilationParticipantResult [ ] results ) { boolean hasAnnotationProcessor = false ; for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; ! hasAnnotationProcessor && i < l ; i ++ ) hasAnnotationProcessor = this . javaBuilder . participants [ i ] . isAnnotationProcessor ( ) ; if ( ! hasAnnotationProcessor ) return ; boolean foundAnnotations = this . filesWithAnnotations != null && this . filesWithAnnotations . elementSize > <NUM_LIT:0> ; for ( int i = results . length ; -- i >= <NUM_LIT:0> ; ) results [ i ] . reset ( foundAnnotations && this . filesWithAnnotations . includes ( results [ i ] . sourceFile ) ) ; for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; i < l ; i ++ ) if ( this . javaBuilder . participants [ i ] . isAnnotationProcessor ( ) ) this . javaBuilder . participants [ i ] . processAnnotations ( results ) ; processAnnotationResults ( results ) ; } protected void recordParticipantResult ( CompilationParticipantResult result ) { CategorizedProblem [ ] problems = result . problems ; if ( problems != null && problems . length > <NUM_LIT:0> ) { this . notifier . updateProblemCounts ( problems ) ; try { storeProblemsFor ( result . sourceFile , problems ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } } String [ ] dependencies = result . dependencies ; if ( dependencies != null ) { ReferenceCollection refs = ( ReferenceCollection ) this . newState . references . get ( result . sourceFile . typeLocator ( ) ) ; if ( refs != null ) refs . addDependencies ( dependencies ) ; } } protected void storeProblemsFor ( SourceFile sourceFile , CategorizedProblem [ ] problems ) throws CoreException { if ( sourceFile == null || problems == null || problems . length == <NUM_LIT:0> ) return ; if ( ! this . keepStoringProblemMarkers ) return ; IResource resource = sourceFile . resource ; HashSet managedMarkerTypes = JavaModelManager . getJavaModelManager ( ) . compilationParticipants . managedMarkerTypes ( ) ; for ( int i = <NUM_LIT:0> , l = problems . length ; i < l ; i ++ ) { CategorizedProblem problem = problems [ i ] ; int id = problem . getID ( ) ; if ( id == IProblem . IsClassPathCorrect ) { String missingClassfileName = problem . getArguments ( ) [ <NUM_LIT:0> ] ; if ( JavaBuilder . DEBUG ) System . out . println ( Messages . bind ( Messages . build_incompleteClassPath , missingClassfileName ) ) ; boolean isInvalidClasspathError = JavaCore . ERROR . equals ( this . javaBuilder . javaProject . getOption ( JavaCore . CORE_INCOMPLETE_CLASSPATH , true ) ) ; if ( isInvalidClasspathError && JavaCore . ABORT . equals ( this . javaBuilder . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , true ) ) ) { JavaBuilder . removeProblemsAndTasksFor ( this . javaBuilder . currentProject ) ; this . keepStoringProblemMarkers = false ; } IMarker marker = this . javaBuilder . currentProject . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IJavaModelMarker . CATEGORY_ID , IMarker . SOURCE_ID } , new Object [ ] { Messages . bind ( Messages . build_incompleteClassPath , missingClassfileName ) , new Integer ( isInvalidClasspathError ? IMarker . SEVERITY_ERROR : IMarker . SEVERITY_WARNING ) , new Integer ( CategorizedProblem . CAT_BUILDPATH ) , JavaBuilder . SOURCE_ID } ) ; } String markerType = problem . getMarkerType ( ) ; boolean managedProblem = false ; if ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER . equals ( markerType ) || ( managedProblem = managedMarkerTypes . contains ( markerType ) ) ) { IMarker marker = resource . createMarker ( markerType ) ; String [ ] attributeNames = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES ; int standardLength = attributeNames . length ; String [ ] allNames = attributeNames ; int managedLength = managedProblem ? <NUM_LIT:0> : <NUM_LIT:1> ; String [ ] extraAttributeNames = problem . getExtraMarkerAttributeNames ( ) ; int extraLength = extraAttributeNames == null ? <NUM_LIT:0> : extraAttributeNames . length ; if ( managedLength > <NUM_LIT:0> || extraLength > <NUM_LIT:0> ) { allNames = new String [ standardLength + managedLength + extraLength ] ; System . arraycopy ( attributeNames , <NUM_LIT:0> , allNames , <NUM_LIT:0> , standardLength ) ; if ( managedLength > <NUM_LIT:0> ) allNames [ standardLength ] = IMarker . SOURCE_ID ; System . arraycopy ( extraAttributeNames , <NUM_LIT:0> , allNames , standardLength + managedLength , extraLength ) ; } Object [ ] allValues = new Object [ allNames . length ] ; int index = <NUM_LIT:0> ; allValues [ index ++ ] = problem . getMessage ( ) ; allValues [ index ++ ] = problem . isError ( ) ? S_ERROR : S_WARNING ; allValues [ index ++ ] = new Integer ( id ) ; allValues [ index ++ ] = new Integer ( problem . getSourceStart ( ) ) ; int end = problem . getSourceEnd ( ) ; allValues [ index ++ ] = new Integer ( end > <NUM_LIT:0> ? end + <NUM_LIT:1> : end ) ; allValues [ index ++ ] = new Integer ( problem . getSourceLineNumber ( ) ) ; allValues [ index ++ ] = Util . getProblemArgumentsForMarker ( problem . getArguments ( ) ) ; allValues [ index ++ ] = new Integer ( problem . getCategoryID ( ) ) ; if ( managedLength > <NUM_LIT:0> ) allValues [ index ++ ] = JavaBuilder . SOURCE_ID ; if ( extraLength > <NUM_LIT:0> ) System . arraycopy ( problem . getExtraMarkerAttributeValues ( ) , <NUM_LIT:0> , allValues , index , extraLength ) ; marker . setAttributes ( allNames , allValues ) ; if ( ! this . keepStoringProblemMarkers ) return ; } } } protected void storeTasksFor ( SourceFile sourceFile , CategorizedProblem [ ] tasks ) throws CoreException { if ( sourceFile == null || tasks == null || tasks . length == <NUM_LIT:0> ) return ; IResource resource = sourceFile . resource ; for ( int i = <NUM_LIT:0> , l = tasks . length ; i < l ; i ++ ) { CategorizedProblem task = tasks [ i ] ; if ( task . getID ( ) == IProblem . Task ) { IMarker marker = resource . createMarker ( IJavaModelMarker . TASK_MARKER ) ; Integer priority = P_NORMAL ; String compilerPriority = task . getArguments ( ) [ <NUM_LIT:2> ] ; if ( JavaCore . COMPILER_TASK_PRIORITY_HIGH . equals ( compilerPriority ) ) priority = P_HIGH ; else if ( JavaCore . COMPILER_TASK_PRIORITY_LOW . equals ( compilerPriority ) ) priority = P_LOW ; String [ ] attributeNames = JAVA_TASK_MARKER_ATTRIBUTE_NAMES ; int standardLength = attributeNames . length ; String [ ] allNames = attributeNames ; String [ ] extraAttributeNames = task . getExtraMarkerAttributeNames ( ) ; int extraLength = extraAttributeNames == null ? <NUM_LIT:0> : extraAttributeNames . length ; if ( extraLength > <NUM_LIT:0> ) { allNames = new String [ standardLength + extraLength ] ; System . arraycopy ( attributeNames , <NUM_LIT:0> , allNames , <NUM_LIT:0> , standardLength ) ; System . arraycopy ( extraAttributeNames , <NUM_LIT:0> , allNames , standardLength , extraLength ) ; } Object [ ] allValues = new Object [ allNames . length ] ; int index = <NUM_LIT:0> ; allValues [ index ++ ] = task . getMessage ( ) ; allValues [ index ++ ] = priority ; allValues [ index ++ ] = new Integer ( task . getID ( ) ) ; allValues [ index ++ ] = new Integer ( task . getSourceStart ( ) ) ; allValues [ index ++ ] = new Integer ( task . getSourceEnd ( ) + <NUM_LIT:1> ) ; allValues [ index ++ ] = new Integer ( task . getSourceLineNumber ( ) ) ; allValues [ index ++ ] = Boolean . FALSE ; allValues [ index ++ ] = JavaBuilder . SOURCE_ID ; if ( extraLength > <NUM_LIT:0> ) System . arraycopy ( task . getExtraMarkerAttributeValues ( ) , <NUM_LIT:0> , allValues , index , extraLength ) ; marker . setAttributes ( allNames , allValues ) ; } } } protected void updateProblemsFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { CategorizedProblem [ ] problems = result . getProblems ( ) ; if ( problems == null || problems . length == <NUM_LIT:0> ) return ; this . notifier . updateProblemCounts ( problems ) ; storeProblemsFor ( sourceFile , problems ) ; } protected void updateTasksFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { CategorizedProblem [ ] tasks = result . getTasks ( ) ; if ( tasks == null || tasks . length == <NUM_LIT:0> ) return ; storeTasksFor ( sourceFile , tasks ) ; } protected char [ ] writeClassFile ( ClassFile classFile , SourceFile compilationUnit , boolean isTopLevelType ) throws CoreException { String fileName = new String ( classFile . fileName ( ) ) ; IPath filePath = new Path ( fileName ) ; IContainer outputFolder = compilationUnit . sourceLocation . binaryFolder ; IContainer container = outputFolder ; if ( filePath . segmentCount ( ) > <NUM_LIT:1> ) { container = createFolder ( filePath . removeLastSegments ( <NUM_LIT:1> ) , outputFolder ) ; filePath = new Path ( filePath . lastSegment ( ) ) ; } IFile file = container . getFile ( filePath . addFileExtension ( SuffixConstants . EXTENSION_class ) ) ; writeClassFileContents ( classFile , file , fileName , isTopLevelType , compilationUnit ) ; return filePath . lastSegment ( ) . toCharArray ( ) ; } protected void writeClassFileContents ( ClassFile classFile , IFile file , String qualifiedFileName , boolean isTopLevelType , SourceFile compilationUnit ) throws CoreException { InputStream input = new ByteArrayInputStream ( classFile . getBytes ( ) ) ; if ( file . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; if ( ! file . isDerived ( ) ) file . setDerived ( true , null ) ; file . setContents ( input , true , false , null ) ; } else { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; file . create ( input , IResource . FORCE | IResource . DERIVED , null ) ; } } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; public class MissingSourceFileException extends RuntimeException { protected String missingSourceFile ; private static final long serialVersionUID = - <NUM_LIT> ; public MissingSourceFileException ( String missingSourceFile ) { this . missingSourceFile = missingSourceFile ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . jdt . core . compiler . CharOperation ; public class QualifiedNameSet { public char [ ] [ ] [ ] qualifiedNames ; public int elementSize ; public int threshold ; public QualifiedNameSet ( int size ) { this . elementSize = <NUM_LIT:0> ; this . threshold = size ; int extraRoom = ( int ) ( size * <NUM_LIT> ) ; if ( this . threshold == extraRoom ) extraRoom ++ ; this . qualifiedNames = new char [ extraRoom ] [ ] [ ] ; } public char [ ] [ ] add ( char [ ] [ ] qualifiedName ) { int qLength = qualifiedName . length ; if ( qLength == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; int length = this . qualifiedNames . length ; int index = CharOperation . hashCode ( qualifiedName [ qLength - <NUM_LIT:1> ] ) % length ; char [ ] [ ] current ; while ( ( current = this . qualifiedNames [ index ] ) != null ) { if ( CharOperation . equals ( current , qualifiedName ) ) return current ; if ( ++ index == length ) index = <NUM_LIT:0> ; } this . qualifiedNames [ index ] = qualifiedName ; if ( ++ this . elementSize > this . threshold ) rehash ( ) ; return qualifiedName ; } private void rehash ( ) { QualifiedNameSet newSet = new QualifiedNameSet ( this . elementSize * <NUM_LIT:2> ) ; char [ ] [ ] current ; for ( int i = this . qualifiedNames . length ; -- i >= <NUM_LIT:0> ; ) if ( ( current = this . qualifiedNames [ i ] ) != null ) newSet . add ( current ) ; this . qualifiedNames = newSet . qualifiedNames ; this . elementSize = newSet . elementSize ; this . threshold = newSet . threshold ; } public String toString ( ) { String s = "<STR_LIT>" ; char [ ] [ ] qualifiedName ; for ( int i = <NUM_LIT:0> , l = this . qualifiedNames . length ; i < l ; i ++ ) if ( ( qualifiedName = this . qualifiedNames [ i ] ) != null ) s += CharOperation . toString ( qualifiedName ) + "<STR_LIT:n>" ; return s ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . AccessRule ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . core . ClasspathAccessRule ; import org . eclipse . jdt . internal . core . JavaModelManager ; import java . io . * ; import java . util . * ; public class State { String javaProjectName ; ClasspathMultiDirectory [ ] sourceLocations ; ClasspathLocation [ ] binaryLocations ; SimpleLookupTable references ; public SimpleLookupTable typeLocators ; int buildNumber ; long lastStructuralBuildTime ; SimpleLookupTable structuralBuildTimes ; private String [ ] knownPackageNames ; private long previousStructuralBuildTime ; private StringSet structurallyChangedTypes ; public static int MaxStructurallyChangedTypes = <NUM_LIT:100> ; public static final byte VERSION = <NUM_LIT> ; static final byte SOURCE_FOLDER = <NUM_LIT:1> ; static final byte BINARY_FOLDER = <NUM_LIT:2> ; static final byte EXTERNAL_JAR = <NUM_LIT:3> ; static final byte INTERNAL_JAR = <NUM_LIT:4> ; State ( ) { } protected State ( JavaBuilder javaBuilder ) { this . knownPackageNames = null ; this . previousStructuralBuildTime = - <NUM_LIT:1> ; this . structurallyChangedTypes = null ; this . javaProjectName = javaBuilder . currentProject . getName ( ) ; this . sourceLocations = javaBuilder . nameEnvironment . sourceLocations ; this . binaryLocations = javaBuilder . nameEnvironment . binaryLocations ; this . references = new SimpleLookupTable ( <NUM_LIT:7> ) ; this . typeLocators = new SimpleLookupTable ( <NUM_LIT:7> ) ; this . buildNumber = <NUM_LIT:0> ; this . lastStructuralBuildTime = computeStructuralBuildTime ( javaBuilder . lastState == null ? <NUM_LIT:0> : javaBuilder . lastState . lastStructuralBuildTime ) ; this . structuralBuildTimes = new SimpleLookupTable ( <NUM_LIT:3> ) ; } long computeStructuralBuildTime ( long previousTime ) { long newTime = System . currentTimeMillis ( ) ; if ( newTime <= previousTime ) newTime = previousTime + <NUM_LIT:1> ; return newTime ; } void copyFrom ( State lastState ) { this . knownPackageNames = null ; this . previousStructuralBuildTime = lastState . previousStructuralBuildTime ; this . structurallyChangedTypes = lastState . structurallyChangedTypes ; this . buildNumber = lastState . buildNumber + <NUM_LIT:1> ; this . lastStructuralBuildTime = lastState . lastStructuralBuildTime ; this . structuralBuildTimes = lastState . structuralBuildTimes ; try { this . references = ( SimpleLookupTable ) lastState . references . clone ( ) ; this . typeLocators = ( SimpleLookupTable ) lastState . typeLocators . clone ( ) ; } catch ( CloneNotSupportedException e ) { this . references = new SimpleLookupTable ( lastState . references . elementSize ) ; Object [ ] keyTable = lastState . references . keyTable ; Object [ ] valueTable = lastState . references . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) if ( keyTable [ i ] != null ) this . references . put ( keyTable [ i ] , valueTable [ i ] ) ; this . typeLocators = new SimpleLookupTable ( lastState . typeLocators . elementSize ) ; keyTable = lastState . typeLocators . keyTable ; valueTable = lastState . typeLocators . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) if ( keyTable [ i ] != null ) this . typeLocators . put ( keyTable [ i ] , valueTable [ i ] ) ; } } public char [ ] [ ] getDefinedTypeNamesFor ( String typeLocator ) { Object c = this . references . get ( typeLocator ) ; if ( c instanceof AdditionalTypeCollection ) return ( ( AdditionalTypeCollection ) c ) . definedTypeNames ; return null ; } public SimpleLookupTable getReferences ( ) { return this . references ; } StringSet getStructurallyChangedTypes ( State prereqState ) { if ( prereqState != null && prereqState . previousStructuralBuildTime > <NUM_LIT:0> ) { Object o = this . structuralBuildTimes . get ( prereqState . javaProjectName ) ; long previous = o == null ? <NUM_LIT:0> : ( ( Long ) o ) . longValue ( ) ; if ( previous == prereqState . previousStructuralBuildTime ) return prereqState . structurallyChangedTypes ; } return null ; } public boolean isDuplicateLocator ( String qualifiedTypeName , String typeLocator ) { String existing = ( String ) this . typeLocators . get ( qualifiedTypeName ) ; return existing != null && ! existing . equals ( typeLocator ) ; } public boolean isKnownPackage ( String qualifiedPackageName ) { if ( this . knownPackageNames == null ) { ArrayList names = new ArrayList ( this . typeLocators . elementSize ) ; Object [ ] keyTable = this . typeLocators . keyTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { String packageName = ( String ) keyTable [ i ] ; int last = packageName . lastIndexOf ( '<CHAR_LIT:/>' ) ; packageName = last == - <NUM_LIT:1> ? null : packageName . substring ( <NUM_LIT:0> , last ) ; while ( packageName != null && ! names . contains ( packageName ) ) { names . add ( packageName ) ; last = packageName . lastIndexOf ( '<CHAR_LIT:/>' ) ; packageName = last == - <NUM_LIT:1> ? null : packageName . substring ( <NUM_LIT:0> , last ) ; } } } this . knownPackageNames = new String [ names . size ( ) ] ; names . toArray ( this . knownPackageNames ) ; } for ( int i = <NUM_LIT:0> , l = this . knownPackageNames . length ; i < l ; i ++ ) if ( this . knownPackageNames [ i ] . equals ( qualifiedPackageName ) ) return true ; return false ; } public boolean isKnownType ( String qualifiedTypeName ) { return this . typeLocators . containsKey ( qualifiedTypeName ) ; } boolean isSourceFolderEmpty ( IContainer sourceFolder ) { String sourceFolderName = sourceFolder . getProjectRelativePath ( ) . addTrailingSeparator ( ) . toString ( ) ; Object [ ] table = this . typeLocators . valueTable ; for ( int i = <NUM_LIT:0> , l = table . length ; i < l ; i ++ ) if ( table [ i ] != null && ( ( String ) table [ i ] ) . startsWith ( sourceFolderName ) ) return false ; return true ; } void record ( String typeLocator , char [ ] [ ] [ ] qualifiedRefs , char [ ] [ ] simpleRefs , char [ ] [ ] rootRefs , char [ ] mainTypeName , ArrayList typeNames ) { if ( typeNames . size ( ) == <NUM_LIT:1> && CharOperation . equals ( mainTypeName , ( char [ ] ) typeNames . get ( <NUM_LIT:0> ) ) ) { this . references . put ( typeLocator , new ReferenceCollection ( qualifiedRefs , simpleRefs , rootRefs ) ) ; } else { char [ ] [ ] definedTypeNames = new char [ typeNames . size ( ) ] [ ] ; typeNames . toArray ( definedTypeNames ) ; this . references . put ( typeLocator , new AdditionalTypeCollection ( definedTypeNames , qualifiedRefs , simpleRefs , rootRefs ) ) ; } } void recordLocatorForType ( String qualifiedTypeName , String typeLocator ) { this . knownPackageNames = null ; int start = typeLocator . indexOf ( qualifiedTypeName , <NUM_LIT:0> ) ; if ( start > <NUM_LIT:0> ) qualifiedTypeName = typeLocator . substring ( start , start + qualifiedTypeName . length ( ) ) ; this . typeLocators . put ( qualifiedTypeName , typeLocator ) ; } void recordStructuralDependency ( IProject prereqProject , State prereqState ) { if ( prereqState != null ) if ( prereqState . lastStructuralBuildTime > <NUM_LIT:0> ) this . structuralBuildTimes . put ( prereqProject . getName ( ) , new Long ( prereqState . lastStructuralBuildTime ) ) ; } void removeLocator ( String typeLocatorToRemove ) { this . knownPackageNames = null ; this . references . removeKey ( typeLocatorToRemove ) ; this . typeLocators . removeValue ( typeLocatorToRemove ) ; } void removePackage ( IResourceDelta sourceDelta ) { IResource resource = sourceDelta . getResource ( ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : IResourceDelta [ ] children = sourceDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) removePackage ( children [ i ] ) ; return ; case IResource . FILE : IPath typeLocatorPath = resource . getProjectRelativePath ( ) ; if ( org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( typeLocatorPath . lastSegment ( ) ) ) removeLocator ( typeLocatorPath . toString ( ) ) ; } } void removeQualifiedTypeName ( String qualifiedTypeNameToRemove ) { this . knownPackageNames = null ; this . typeLocators . removeKey ( qualifiedTypeNameToRemove ) ; } static State read ( IProject project , DataInputStream in ) throws IOException { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + project . getName ( ) ) ; if ( VERSION != in . readByte ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + project . getName ( ) ) ; return null ; } State newState = new State ( ) ; newState . javaProjectName = in . readUTF ( ) ; if ( ! project . getName ( ) . equals ( newState . javaProjectName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return null ; } newState . buildNumber = in . readInt ( ) ; newState . lastStructuralBuildTime = in . readLong ( ) ; int length = in . readInt ( ) ; newState . sourceLocations = new ClasspathMultiDirectory [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IContainer sourceFolder = project , outputFolder = project ; String folderName ; if ( ( folderName = in . readUTF ( ) ) . length ( ) > <NUM_LIT:0> ) sourceFolder = project . getFolder ( folderName ) ; if ( ( folderName = in . readUTF ( ) ) . length ( ) > <NUM_LIT:0> ) outputFolder = project . getFolder ( folderName ) ; ClasspathMultiDirectory md = ( ClasspathMultiDirectory ) ClasspathLocation . forSourceFolder ( sourceFolder , outputFolder , readNames ( in ) , readNames ( in ) ) ; if ( in . readBoolean ( ) ) md . hasIndependentOutputFolder = true ; newState . sourceLocations [ i ] = md ; } length = in . readInt ( ) ; newState . binaryLocations = new ClasspathLocation [ length ] ; IWorkspaceRoot root = project . getWorkspace ( ) . getRoot ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { switch ( in . readByte ( ) ) { case SOURCE_FOLDER : newState . binaryLocations [ i ] = newState . sourceLocations [ in . readInt ( ) ] ; break ; case BINARY_FOLDER : IPath path = new Path ( in . readUTF ( ) ) ; IContainer outputFolder = path . segmentCount ( ) == <NUM_LIT:1> ? ( IContainer ) root . getProject ( path . toString ( ) ) : ( IContainer ) root . getFolder ( path ) ; newState . binaryLocations [ i ] = ClasspathLocation . forBinaryFolder ( outputFolder , in . readBoolean ( ) , readRestriction ( in ) ) ; break ; case EXTERNAL_JAR : newState . binaryLocations [ i ] = ClasspathLocation . forLibrary ( in . readUTF ( ) , in . readLong ( ) , readRestriction ( in ) ) ; break ; case INTERNAL_JAR : newState . binaryLocations [ i ] = ClasspathLocation . forLibrary ( root . getFile ( new Path ( in . readUTF ( ) ) ) , readRestriction ( in ) ) ; } } newState . structuralBuildTimes = new SimpleLookupTable ( length = in . readInt ( ) ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) newState . structuralBuildTimes . put ( in . readUTF ( ) , new Long ( in . readLong ( ) ) ) ; String [ ] internedTypeLocators = new String [ length = in . readInt ( ) ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) internedTypeLocators [ i ] = in . readUTF ( ) ; newState . typeLocators = new SimpleLookupTable ( length = in . readInt ( ) ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) newState . recordLocatorForType ( in . readUTF ( ) , internedTypeLocators [ in . readInt ( ) ] ) ; char [ ] [ ] internedRootNames = ReferenceCollection . internSimpleNames ( readNames ( in ) , false ) ; char [ ] [ ] internedSimpleNames = ReferenceCollection . internSimpleNames ( readNames ( in ) , false ) ; char [ ] [ ] [ ] internedQualifiedNames = new char [ length = in . readInt ( ) ] [ ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { int qLength = in . readInt ( ) ; char [ ] [ ] qName = new char [ qLength ] [ ] ; for ( int j = <NUM_LIT:0> ; j < qLength ; j ++ ) qName [ j ] = internedSimpleNames [ in . readInt ( ) ] ; internedQualifiedNames [ i ] = qName ; } internedQualifiedNames = ReferenceCollection . internQualifiedNames ( internedQualifiedNames , false ) ; newState . references = new SimpleLookupTable ( length = in . readInt ( ) ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { String typeLocator = internedTypeLocators [ in . readInt ( ) ] ; ReferenceCollection collection = null ; switch ( in . readByte ( ) ) { case <NUM_LIT:1> : char [ ] [ ] additionalTypeNames = readNames ( in ) ; char [ ] [ ] [ ] qualifiedNames = new char [ in . readInt ( ) ] [ ] [ ] ; for ( int j = <NUM_LIT:0> , m = qualifiedNames . length ; j < m ; j ++ ) qualifiedNames [ j ] = internedQualifiedNames [ in . readInt ( ) ] ; char [ ] [ ] simpleNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = simpleNames . length ; j < m ; j ++ ) simpleNames [ j ] = internedSimpleNames [ in . readInt ( ) ] ; char [ ] [ ] rootNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = rootNames . length ; j < m ; j ++ ) rootNames [ j ] = internedRootNames [ in . readInt ( ) ] ; collection = new AdditionalTypeCollection ( additionalTypeNames , qualifiedNames , simpleNames , rootNames ) ; break ; case <NUM_LIT:2> : char [ ] [ ] [ ] qNames = new char [ in . readInt ( ) ] [ ] [ ] ; for ( int j = <NUM_LIT:0> , m = qNames . length ; j < m ; j ++ ) qNames [ j ] = internedQualifiedNames [ in . readInt ( ) ] ; char [ ] [ ] sNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = sNames . length ; j < m ; j ++ ) sNames [ j ] = internedSimpleNames [ in . readInt ( ) ] ; char [ ] [ ] rNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = rNames . length ; j < m ; j ++ ) rNames [ j ] = internedRootNames [ in . readInt ( ) ] ; collection = new ReferenceCollection ( qNames , sNames , rNames ) ; } newState . references . put ( typeLocator , collection ) ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + newState . javaProjectName ) ; return newState ; } private static char [ ] readName ( DataInputStream in ) throws IOException { int nLength = in . readInt ( ) ; char [ ] name = new char [ nLength ] ; for ( int j = <NUM_LIT:0> ; j < nLength ; j ++ ) name [ j ] = in . readChar ( ) ; return name ; } private static char [ ] [ ] readNames ( DataInputStream in ) throws IOException { int length = in . readInt ( ) ; char [ ] [ ] names = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) names [ i ] = readName ( in ) ; return names ; } private static AccessRuleSet readRestriction ( DataInputStream in ) throws IOException { int length = in . readInt ( ) ; if ( length == <NUM_LIT:0> ) return null ; AccessRule [ ] accessRules = new AccessRule [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] pattern = readName ( in ) ; int problemId = in . readInt ( ) ; accessRules [ i ] = new ClasspathAccessRule ( pattern , problemId ) ; } JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; return new AccessRuleSet ( accessRules , in . readByte ( ) , manager . intern ( in . readUTF ( ) ) ) ; } void tagAsNoopBuild ( ) { this . buildNumber = - <NUM_LIT:1> ; } boolean wasNoopBuild ( ) { return this . buildNumber == - <NUM_LIT:1> ; } void tagAsStructurallyChanged ( ) { this . previousStructuralBuildTime = this . lastStructuralBuildTime ; this . structurallyChangedTypes = new StringSet ( <NUM_LIT:7> ) ; this . lastStructuralBuildTime = computeStructuralBuildTime ( this . previousStructuralBuildTime ) ; } boolean wasStructurallyChanged ( IProject prereqProject , State prereqState ) { if ( prereqState != null ) { Object o = this . structuralBuildTimes . get ( prereqProject . getName ( ) ) ; long previous = o == null ? <NUM_LIT:0> : ( ( Long ) o ) . longValue ( ) ; if ( previous == prereqState . lastStructuralBuildTime ) return false ; } return true ; } void wasStructurallyChanged ( String typeName ) { if ( this . structurallyChangedTypes != null ) { if ( this . structurallyChangedTypes . elementSize > MaxStructurallyChangedTypes ) this . structurallyChangedTypes = null ; else this . structurallyChangedTypes . add ( typeName ) ; } } void write ( DataOutputStream out ) throws IOException { int length ; Object [ ] keyTable ; Object [ ] valueTable ; out . writeByte ( VERSION ) ; out . writeUTF ( this . javaProjectName ) ; out . writeInt ( this . buildNumber ) ; out . writeLong ( this . lastStructuralBuildTime ) ; out . writeInt ( length = this . sourceLocations . length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ClasspathMultiDirectory md = this . sourceLocations [ i ] ; out . writeUTF ( md . sourceFolder . getProjectRelativePath ( ) . toString ( ) ) ; out . writeUTF ( md . binaryFolder . getProjectRelativePath ( ) . toString ( ) ) ; writeNames ( md . inclusionPatterns , out ) ; writeNames ( md . exclusionPatterns , out ) ; out . writeBoolean ( md . hasIndependentOutputFolder ) ; } out . writeInt ( length = this . binaryLocations . length ) ; next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ClasspathLocation c = this . binaryLocations [ i ] ; if ( c instanceof ClasspathMultiDirectory ) { out . writeByte ( SOURCE_FOLDER ) ; for ( int j = <NUM_LIT:0> , m = this . sourceLocations . length ; j < m ; j ++ ) { if ( this . sourceLocations [ j ] == c ) { out . writeInt ( j ) ; continue next ; } } } else if ( c instanceof ClasspathDirectory ) { out . writeByte ( BINARY_FOLDER ) ; ClasspathDirectory cd = ( ClasspathDirectory ) c ; out . writeUTF ( cd . binaryFolder . getFullPath ( ) . toString ( ) ) ; out . writeBoolean ( cd . isOutputFolder ) ; writeRestriction ( cd . accessRuleSet , out ) ; } else { ClasspathJar jar = ( ClasspathJar ) c ; if ( jar . resource == null ) { out . writeByte ( EXTERNAL_JAR ) ; out . writeUTF ( jar . zipFilename ) ; out . writeLong ( jar . lastModified ( ) ) ; } else { out . writeByte ( INTERNAL_JAR ) ; out . writeUTF ( jar . resource . getFullPath ( ) . toString ( ) ) ; } writeRestriction ( jar . accessRuleSet , out ) ; } } out . writeInt ( length = this . structuralBuildTimes . elementSize ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . structuralBuildTimes . keyTable ; valueTable = this . structuralBuildTimes . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; out . writeUTF ( ( String ) keyTable [ i ] ) ; out . writeLong ( ( ( Long ) valueTable [ i ] ) . longValue ( ) ) ; } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } out . writeInt ( length = this . references . elementSize ) ; SimpleLookupTable internedTypeLocators = new SimpleLookupTable ( length ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . references . keyTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; String key = ( String ) keyTable [ i ] ; out . writeUTF ( key ) ; internedTypeLocators . put ( key , new Integer ( internedTypeLocators . elementSize ) ) ; } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } out . writeInt ( length = this . typeLocators . elementSize ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . typeLocators . keyTable ; valueTable = this . typeLocators . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; out . writeUTF ( ( String ) keyTable [ i ] ) ; Integer index = ( Integer ) internedTypeLocators . get ( valueTable [ i ] ) ; out . writeInt ( index . intValue ( ) ) ; } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } SimpleLookupTable internedRootNames = new SimpleLookupTable ( <NUM_LIT:3> ) ; SimpleLookupTable internedQualifiedNames = new SimpleLookupTable ( <NUM_LIT:31> ) ; SimpleLookupTable internedSimpleNames = new SimpleLookupTable ( <NUM_LIT:31> ) ; valueTable = this . references . valueTable ; for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { if ( valueTable [ i ] != null ) { ReferenceCollection collection = ( ReferenceCollection ) valueTable [ i ] ; char [ ] [ ] rNames = collection . rootReferences ; for ( int j = <NUM_LIT:0> , m = rNames . length ; j < m ; j ++ ) { char [ ] rName = rNames [ j ] ; if ( ! internedRootNames . containsKey ( rName ) ) internedRootNames . put ( rName , new Integer ( internedRootNames . elementSize ) ) ; } char [ ] [ ] [ ] qNames = collection . qualifiedNameReferences ; for ( int j = <NUM_LIT:0> , m = qNames . length ; j < m ; j ++ ) { char [ ] [ ] qName = qNames [ j ] ; if ( ! internedQualifiedNames . containsKey ( qName ) ) { internedQualifiedNames . put ( qName , new Integer ( internedQualifiedNames . elementSize ) ) ; for ( int k = <NUM_LIT:0> , n = qName . length ; k < n ; k ++ ) { char [ ] sName = qName [ k ] ; if ( ! internedSimpleNames . containsKey ( sName ) ) internedSimpleNames . put ( sName , new Integer ( internedSimpleNames . elementSize ) ) ; } } } char [ ] [ ] sNames = collection . simpleNameReferences ; for ( int j = <NUM_LIT:0> , m = sNames . length ; j < m ; j ++ ) { char [ ] sName = sNames [ j ] ; if ( ! internedSimpleNames . containsKey ( sName ) ) internedSimpleNames . put ( sName , new Integer ( internedSimpleNames . elementSize ) ) ; } } } char [ ] [ ] internedArray = new char [ internedRootNames . elementSize ] [ ] ; Object [ ] rootNames = internedRootNames . keyTable ; Object [ ] positions = internedRootNames . valueTable ; for ( int i = positions . length ; -- i >= <NUM_LIT:0> ; ) { if ( positions [ i ] != null ) { int index = ( ( Integer ) positions [ i ] ) . intValue ( ) ; internedArray [ index ] = ( char [ ] ) rootNames [ i ] ; } } writeNames ( internedArray , out ) ; internedArray = new char [ internedSimpleNames . elementSize ] [ ] ; Object [ ] simpleNames = internedSimpleNames . keyTable ; positions = internedSimpleNames . valueTable ; for ( int i = positions . length ; -- i >= <NUM_LIT:0> ; ) { if ( positions [ i ] != null ) { int index = ( ( Integer ) positions [ i ] ) . intValue ( ) ; internedArray [ index ] = ( char [ ] ) simpleNames [ i ] ; } } writeNames ( internedArray , out ) ; char [ ] [ ] [ ] internedQArray = new char [ internedQualifiedNames . elementSize ] [ ] [ ] ; Object [ ] qualifiedNames = internedQualifiedNames . keyTable ; positions = internedQualifiedNames . valueTable ; for ( int i = positions . length ; -- i >= <NUM_LIT:0> ; ) { if ( positions [ i ] != null ) { int index = ( ( Integer ) positions [ i ] ) . intValue ( ) ; internedQArray [ index ] = ( char [ ] [ ] ) qualifiedNames [ i ] ; } } out . writeInt ( length = internedQArray . length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] [ ] qName = internedQArray [ i ] ; int qLength = qName . length ; out . writeInt ( qLength ) ; for ( int j = <NUM_LIT:0> ; j < qLength ; j ++ ) { Integer index = ( Integer ) internedSimpleNames . get ( qName [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } } out . writeInt ( length = this . references . elementSize ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . references . keyTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; Integer index = ( Integer ) internedTypeLocators . get ( keyTable [ i ] ) ; out . writeInt ( index . intValue ( ) ) ; ReferenceCollection collection = ( ReferenceCollection ) valueTable [ i ] ; if ( collection instanceof AdditionalTypeCollection ) { out . writeByte ( <NUM_LIT:1> ) ; AdditionalTypeCollection atc = ( AdditionalTypeCollection ) collection ; writeNames ( atc . definedTypeNames , out ) ; } else { out . writeByte ( <NUM_LIT:2> ) ; } char [ ] [ ] [ ] qNames = collection . qualifiedNameReferences ; int qLength = qNames . length ; out . writeInt ( qLength ) ; for ( int j = <NUM_LIT:0> ; j < qLength ; j ++ ) { index = ( Integer ) internedQualifiedNames . get ( qNames [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } char [ ] [ ] sNames = collection . simpleNameReferences ; int sLength = sNames . length ; out . writeInt ( sLength ) ; for ( int j = <NUM_LIT:0> ; j < sLength ; j ++ ) { index = ( Integer ) internedSimpleNames . get ( sNames [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } char [ ] [ ] rNames = collection . rootReferences ; int rLength = rNames . length ; out . writeInt ( rLength ) ; for ( int j = <NUM_LIT:0> ; j < rLength ; j ++ ) { index = ( Integer ) internedRootNames . get ( rNames [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } } private void writeName ( char [ ] name , DataOutputStream out ) throws IOException { int nLength = name . length ; out . writeInt ( nLength ) ; for ( int j = <NUM_LIT:0> ; j < nLength ; j ++ ) out . writeChar ( name [ j ] ) ; } private void writeNames ( char [ ] [ ] names , DataOutputStream out ) throws IOException { int length = names == null ? <NUM_LIT:0> : names . length ; out . writeInt ( length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) writeName ( names [ i ] , out ) ; } private void writeRestriction ( AccessRuleSet accessRuleSet , DataOutputStream out ) throws IOException { if ( accessRuleSet == null ) { out . writeInt ( <NUM_LIT:0> ) ; } else { AccessRule [ ] accessRules = accessRuleSet . getAccessRules ( ) ; int length = accessRules . length ; out . writeInt ( length ) ; if ( length != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { AccessRule accessRule = accessRules [ i ] ; writeName ( accessRule . pattern , out ) ; out . writeInt ( accessRule . problemId ) ; } out . writeByte ( accessRuleSet . classpathEntryType ) ; out . writeUTF ( accessRuleSet . classpathEntryName ) ; } } } public String toString ( ) { return "<STR_LIT>" + this . javaProjectName + "<STR_LIT>" + this . buildNumber + "<STR_LIT>" + new Date ( this . lastStructuralBuildTime ) + "<STR_LIT:)>" ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; public class WorkQueue { private SimpleSet needsCompileList ; private SimpleSet compiledList ; public WorkQueue ( ) { this . needsCompileList = new SimpleSet ( ) ; this . compiledList = new SimpleSet ( ) ; } public void add ( SourceFile element ) { this . needsCompileList . add ( element ) ; } public void addAll ( SourceFile [ ] elements ) { for ( int i = <NUM_LIT:0> , l = elements . length ; i < l ; i ++ ) add ( elements [ i ] ) ; } public void clear ( ) { this . needsCompileList . clear ( ) ; this . compiledList . clear ( ) ; } public void finished ( SourceFile element ) { this . needsCompileList . remove ( element ) ; this . compiledList . add ( element ) ; } public boolean isCompiled ( SourceFile element ) { return this . compiledList . includes ( element ) ; } public boolean isWaiting ( SourceFile element ) { return this . needsCompileList . includes ( element ) ; } public String toString ( ) { return "<STR_LIT>" + this . needsCompileList ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . core . util . Util ; class ClasspathMultiDirectory extends ClasspathDirectory { IContainer sourceFolder ; char [ ] [ ] inclusionPatterns ; char [ ] [ ] exclusionPatterns ; boolean hasIndependentOutputFolder ; ClasspathMultiDirectory ( IContainer sourceFolder , IContainer binaryFolder , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns ) { super ( binaryFolder , true , null ) ; this . sourceFolder = sourceFolder ; this . inclusionPatterns = inclusionPatterns ; this . exclusionPatterns = exclusionPatterns ; this . hasIndependentOutputFolder = false ; if ( this . inclusionPatterns != null && this . inclusionPatterns . length == <NUM_LIT:0> ) this . inclusionPatterns = null ; if ( this . exclusionPatterns != null && this . exclusionPatterns . length == <NUM_LIT:0> ) this . exclusionPatterns = null ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof ClasspathMultiDirectory ) ) return false ; ClasspathMultiDirectory md = ( ClasspathMultiDirectory ) o ; return this . sourceFolder . equals ( md . sourceFolder ) && this . binaryFolder . equals ( md . binaryFolder ) && CharOperation . equals ( this . inclusionPatterns , md . inclusionPatterns ) && CharOperation . equals ( this . exclusionPatterns , md . exclusionPatterns ) ; } protected boolean isExcluded ( IResource resource ) { if ( this . exclusionPatterns != null || this . inclusionPatterns != null ) if ( this . sourceFolder . equals ( this . binaryFolder ) ) return Util . isExcluded ( resource , this . inclusionPatterns , this . exclusionPatterns ) ; return false ; } public String toString ( ) { return "<STR_LIT>" + this . sourceFolder . getFullPath ( ) . toString ( ) + "<STR_LIT>" + super . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import java . io . IOException ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Util ; public class ClasspathDirectory extends ClasspathLocation { IContainer binaryFolder ; boolean isOutputFolder ; SimpleLookupTable directoryCache ; String [ ] missingPackageHolder = new String [ <NUM_LIT:1> ] ; AccessRuleSet accessRuleSet ; ClasspathDirectory ( IContainer binaryFolder , boolean isOutputFolder , AccessRuleSet accessRuleSet ) { this . binaryFolder = binaryFolder ; this . isOutputFolder = isOutputFolder || binaryFolder . getProjectRelativePath ( ) . isEmpty ( ) ; this . directoryCache = new SimpleLookupTable ( <NUM_LIT:5> ) ; this . accessRuleSet = accessRuleSet ; } public void cleanup ( ) { this . directoryCache = null ; } String [ ] directoryList ( String qualifiedPackageName ) { String [ ] dirList = ( String [ ] ) this . directoryCache . get ( qualifiedPackageName ) ; if ( dirList == this . missingPackageHolder ) return null ; if ( dirList != null ) return dirList ; try { IResource container = this . binaryFolder . findMember ( qualifiedPackageName ) ; if ( container instanceof IContainer ) { IResource [ ] members = ( ( IContainer ) container ) . members ( ) ; dirList = new String [ members . length ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , l = members . length ; i < l ; i ++ ) { IResource m = members [ i ] ; if ( m . getType ( ) == IResource . FILE && org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( m . getName ( ) ) ) dirList [ index ++ ] = m . getName ( ) ; } if ( index < dirList . length ) System . arraycopy ( dirList , <NUM_LIT:0> , dirList = new String [ index ] , <NUM_LIT:0> , index ) ; this . directoryCache . put ( qualifiedPackageName , dirList ) ; return dirList ; } } catch ( CoreException ignored ) { } this . directoryCache . put ( qualifiedPackageName , this . missingPackageHolder ) ; return null ; } boolean doesFileExist ( String fileName , String qualifiedPackageName , String qualifiedFullName ) { String [ ] dirList = directoryList ( qualifiedPackageName ) ; if ( dirList == null ) return false ; for ( int i = dirList . length ; -- i >= <NUM_LIT:0> ; ) if ( fileName . equals ( dirList [ i ] ) ) return true ; return false ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof ClasspathDirectory ) ) return false ; ClasspathDirectory dir = ( ClasspathDirectory ) o ; if ( this . accessRuleSet != dir . accessRuleSet ) if ( this . accessRuleSet == null || ! this . accessRuleSet . equals ( dir . accessRuleSet ) ) return false ; return this . binaryFolder . equals ( dir . binaryFolder ) ; } public NameEnvironmentAnswer findClass ( String binaryFileName , String qualifiedPackageName , String qualifiedBinaryFileName ) { if ( ! doesFileExist ( binaryFileName , qualifiedPackageName , qualifiedBinaryFileName ) ) return null ; ClassFileReader reader = null ; try { reader = Util . newClassFileReader ( this . binaryFolder . getFile ( new Path ( qualifiedBinaryFileName ) ) ) ; } catch ( CoreException e ) { return null ; } catch ( ClassFormatException e ) { return null ; } catch ( IOException e ) { return null ; } if ( reader != null ) { if ( this . accessRuleSet == null ) return new NameEnvironmentAnswer ( reader , null ) ; String fileNameWithoutExtension = qualifiedBinaryFileName . substring ( <NUM_LIT:0> , qualifiedBinaryFileName . length ( ) - SuffixConstants . SUFFIX_CLASS . length ) ; return new NameEnvironmentAnswer ( reader , this . accessRuleSet . getViolatedRestriction ( fileNameWithoutExtension . toCharArray ( ) ) ) ; } return null ; } public IPath getProjectRelativePath ( ) { return this . binaryFolder . getProjectRelativePath ( ) ; } public int hashCode ( ) { return this . binaryFolder == null ? super . hashCode ( ) : this . binaryFolder . hashCode ( ) ; } protected boolean isExcluded ( IResource resource ) { return false ; } public boolean isOutputFolder ( ) { return this . isOutputFolder ; } public boolean isPackage ( String qualifiedPackageName ) { return directoryList ( qualifiedPackageName ) != null ; } public void reset ( ) { this . directoryCache = new SimpleLookupTable ( <NUM_LIT:5> ) ; } public String toString ( ) { String start = "<STR_LIT>" + this . binaryFolder . getFullPath ( ) . toString ( ) ; if ( this . accessRuleSet == null ) return start ; return start + "<STR_LIT>" + this . accessRuleSet ; } public String debugPathString ( ) { return this . binaryFolder . getFullPath ( ) . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . * ; import org . eclipse . jdt . internal . compiler . classfmt . * ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; import java . io . * ; import java . net . URI ; import java . util . * ; public class IncrementalImageBuilder extends AbstractImageBuilder { protected ArrayList sourceFiles ; protected ArrayList previousSourceFiles ; protected StringSet qualifiedStrings ; protected StringSet simpleStrings ; protected StringSet rootStrings ; protected SimpleLookupTable secondaryTypesToRemove ; protected boolean hasStructuralChanges ; protected int compileLoop ; protected boolean makeOutputFolderConsistent ; public static int MaxCompileLoop = <NUM_LIT:5> ; protected IncrementalImageBuilder ( JavaBuilder javaBuilder , State buildState ) { super ( javaBuilder , true , buildState ) ; this . nameEnvironment . isIncrementalBuild = true ; this . makeOutputFolderConsistent = JavaCore . ENABLED . equals ( javaBuilder . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER , true ) ) ; } protected IncrementalImageBuilder ( JavaBuilder javaBuilder ) { this ( javaBuilder , null ) ; this . newState . copyFrom ( javaBuilder . lastState ) ; } protected IncrementalImageBuilder ( BatchImageBuilder batchBuilder ) { this ( batchBuilder . javaBuilder , batchBuilder . newState ) ; resetCollections ( ) ; } public boolean build ( SimpleLookupTable deltas ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; try { resetCollections ( ) ; this . notifier . subTask ( Messages . build_analyzingDeltas ) ; if ( this . javaBuilder . hasBuildpathErrors ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; this . javaBuilder . currentProject . deleteMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_ZERO ) ; addAllSourceFiles ( this . sourceFiles ) ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; } else { IResourceDelta sourceDelta = ( IResourceDelta ) deltas . get ( this . javaBuilder . currentProject ) ; if ( sourceDelta != null ) if ( ! findSourceFiles ( sourceDelta ) ) return false ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; Object [ ] keyTable = deltas . keyTable ; Object [ ] valueTable = deltas . valueTable ; for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { IResourceDelta delta = ( IResourceDelta ) valueTable [ i ] ; if ( delta != null ) { IProject p = ( IProject ) keyTable [ i ] ; ClasspathLocation [ ] classFoldersAndJars = ( ClasspathLocation [ ] ) this . javaBuilder . binaryLocationsPerProject . get ( p ) ; if ( classFoldersAndJars != null ) if ( ! findAffectedSourceFiles ( delta , classFoldersAndJars , p ) ) return false ; } } this . notifier . updateProgressDelta ( <NUM_LIT> ) ; this . notifier . subTask ( Messages . build_analyzingSources ) ; addAffectedSourceFiles ( ) ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; } this . compileLoop = <NUM_LIT:0> ; float increment = <NUM_LIT> ; while ( this . sourceFiles . size ( ) > <NUM_LIT:0> ) { if ( ++ this . compileLoop > MaxCompileLoop ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } this . notifier . checkCancel ( ) ; SourceFile [ ] allSourceFiles = new SourceFile [ this . sourceFiles . size ( ) ] ; this . sourceFiles . toArray ( allSourceFiles ) ; resetCollections ( ) ; this . workQueue . addAll ( allSourceFiles ) ; this . notifier . setProgressPerCompilationUnit ( increment / allSourceFiles . length ) ; increment = increment / <NUM_LIT:2> ; compile ( allSourceFiles ) ; removeSecondaryTypes ( ) ; addAffectedSourceFiles ( ) ; } if ( this . hasStructuralChanges && this . javaBuilder . javaProject . hasCycleMarker ( ) ) this . javaBuilder . mustPropagateStructuralChanges ( ) ; } catch ( AbortIncrementalBuildException e ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + e . qualifiedTypeName + "<STR_LIT>" ) ; return false ; } catch ( CoreException e ) { throw internalException ( e ) ; } finally { cleanUp ( ) ; } return true ; } protected void buildAfterBatchBuild ( ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + new Date ( System . currentTimeMillis ( ) ) ) ; try { addAffectedSourceFiles ( ) ; while ( this . sourceFiles . size ( ) > <NUM_LIT:0> ) { this . notifier . checkCancel ( ) ; SourceFile [ ] allSourceFiles = new SourceFile [ this . sourceFiles . size ( ) ] ; this . sourceFiles . toArray ( allSourceFiles ) ; resetCollections ( ) ; this . notifier . setProgressPerCompilationUnit ( <NUM_LIT> / allSourceFiles . length ) ; this . workQueue . addAll ( allSourceFiles ) ; compile ( allSourceFiles ) ; removeSecondaryTypes ( ) ; addAffectedSourceFiles ( ) ; } } catch ( CoreException e ) { throw internalException ( e ) ; } finally { cleanUp ( ) ; } } protected void addAffectedSourceFiles ( ) { if ( this . qualifiedStrings . elementSize == <NUM_LIT:0> && this . simpleStrings . elementSize == <NUM_LIT:0> ) return ; addAffectedSourceFiles ( this . qualifiedStrings , this . simpleStrings , this . rootStrings , null ) ; } protected void addAffectedSourceFiles ( StringSet qualifiedSet , StringSet simpleSet , StringSet rootSet , StringSet affectedTypes ) { char [ ] [ ] [ ] internedQualifiedNames = ReferenceCollection . internQualifiedNames ( qualifiedSet ) ; if ( internedQualifiedNames . length < qualifiedSet . elementSize ) internedQualifiedNames = null ; char [ ] [ ] internedSimpleNames = ReferenceCollection . internSimpleNames ( simpleSet , true ) ; if ( internedSimpleNames . length < simpleSet . elementSize ) internedSimpleNames = null ; char [ ] [ ] internedRootNames = ReferenceCollection . internSimpleNames ( rootSet , false ) ; Object [ ] keyTable = this . newState . references . keyTable ; Object [ ] valueTable = this . newState . references . valueTable ; next : for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { String typeLocator = ( String ) keyTable [ i ] ; if ( typeLocator != null ) { if ( affectedTypes != null && ! affectedTypes . includes ( typeLocator ) ) continue next ; ReferenceCollection refs = ( ReferenceCollection ) valueTable [ i ] ; if ( refs . includes ( internedQualifiedNames , internedSimpleNames , internedRootNames ) ) { IFile file = this . javaBuilder . currentProject . getFile ( typeLocator ) ; SourceFile sourceFile = findSourceFile ( file , true ) ; if ( sourceFile == null ) continue next ; if ( this . sourceFiles . contains ( sourceFile ) ) continue next ; if ( this . compiledAllAtOnce && this . previousSourceFiles != null && this . previousSourceFiles . contains ( sourceFile ) ) continue next ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeLocator ) ; this . sourceFiles . add ( sourceFile ) ; } } } } protected void addDependentsOf ( IPath path , boolean isStructuralChange ) { addDependentsOf ( path , isStructuralChange , this . qualifiedStrings , this . simpleStrings , this . rootStrings ) ; } protected void addDependentsOf ( IPath path , boolean isStructuralChange , StringSet qualifiedNames , StringSet simpleNames , StringSet rootNames ) { path = path . setDevice ( null ) ; if ( isStructuralChange ) { String last = path . lastSegment ( ) ; if ( last . length ( ) == TypeConstants . PACKAGE_INFO_NAME . length ) if ( CharOperation . equals ( last . toCharArray ( ) , TypeConstants . PACKAGE_INFO_NAME ) ) { path = path . removeLastSegments ( <NUM_LIT:1> ) ; if ( path . isEmpty ( ) ) return ; } } if ( isStructuralChange && ! this . hasStructuralChanges ) { this . newState . tagAsStructurallyChanged ( ) ; this . hasStructuralChanges = true ; } rootNames . add ( path . segment ( <NUM_LIT:0> ) ) ; String packageName = path . removeLastSegments ( <NUM_LIT:1> ) . toString ( ) ; boolean wasNew = qualifiedNames . add ( packageName ) ; String typeName = path . lastSegment ( ) ; int memberIndex = typeName . indexOf ( '<CHAR_LIT>' ) ; if ( memberIndex > <NUM_LIT:0> ) typeName = typeName . substring ( <NUM_LIT:0> , memberIndex ) ; wasNew = simpleNames . add ( typeName ) | wasNew ; if ( wasNew && JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeName + "<STR_LIT>" + packageName ) ; } protected boolean checkForClassFileChanges ( IResourceDelta binaryDelta , ClasspathMultiDirectory md , int segmentCount ) throws CoreException { IResource resource = binaryDelta . getResource ( ) ; boolean isExcluded = ( md . exclusionPatterns != null || md . inclusionPatterns != null ) && Util . isExcluded ( resource , md . inclusionPatterns , md . exclusionPatterns ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : if ( isExcluded && md . inclusionPatterns == null ) return true ; IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) if ( ! checkForClassFileChanges ( children [ i ] , md , segmentCount ) ) return false ; return true ; case IResource . FILE : if ( ! isExcluded && org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( resource . getName ( ) ) ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; if ( this . newState . isKnownType ( typePath . toString ( ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; return false ; } return true ; } } return true ; } protected void cleanUp ( ) { super . cleanUp ( ) ; this . sourceFiles = null ; this . previousSourceFiles = null ; this . qualifiedStrings = null ; this . simpleStrings = null ; this . rootStrings = null ; this . secondaryTypesToRemove = null ; this . hasStructuralChanges = false ; this . compileLoop = <NUM_LIT:0> ; } protected void compile ( SourceFile [ ] units , SourceFile [ ] additionalUnits , boolean compilingFirstGroup ) { if ( compilingFirstGroup && additionalUnits != null ) { ArrayList extras = null ; for ( int i = <NUM_LIT:0> , l = additionalUnits . length ; i < l ; i ++ ) { SourceFile unit = additionalUnits [ i ] ; if ( unit != null && this . newState . getDefinedTypeNamesFor ( unit . typeLocator ( ) ) != null ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + unit . typeLocator ( ) ) ; if ( extras == null ) extras = new ArrayList ( <NUM_LIT:3> ) ; extras . add ( unit ) ; } } if ( extras != null ) { int oldLength = units . length ; int toAdd = extras . size ( ) ; System . arraycopy ( units , <NUM_LIT:0> , units = new SourceFile [ oldLength + toAdd ] , <NUM_LIT:0> , oldLength ) ; for ( int i = <NUM_LIT:0> ; i < toAdd ; i ++ ) units [ oldLength ++ ] = ( SourceFile ) extras . get ( i ) ; } } super . compile ( units , additionalUnits , compilingFirstGroup ) ; } protected void deleteGeneratedFiles ( IFile [ ] deletedGeneratedFiles ) { try { for ( int j = deletedGeneratedFiles . length ; -- j >= <NUM_LIT:0> ; ) { IFile deletedFile = deletedGeneratedFiles [ j ] ; if ( deletedFile . exists ( ) ) continue ; SourceFile sourceFile = findSourceFile ( deletedFile , false ) ; String typeLocator = sourceFile . typeLocator ( ) ; int mdSegmentCount = sourceFile . sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; IPath typePath = sourceFile . resource . getFullPath ( ) . removeFirstSegments ( mdSegmentCount ) . removeFileExtension ( ) ; addDependentsOf ( typePath , true ) ; this . previousSourceFiles = null ; char [ ] [ ] definedTypeNames = this . newState . getDefinedTypeNamesFor ( typeLocator ) ; if ( definedTypeNames == null ) { removeClassFile ( typePath , sourceFile . sourceLocation . binaryFolder ) ; } else { if ( definedTypeNames . length > <NUM_LIT:0> ) { IPath packagePath = typePath . removeLastSegments ( <NUM_LIT:1> ) ; for ( int d = <NUM_LIT:0> , l = definedTypeNames . length ; d < l ; d ++ ) removeClassFile ( packagePath . append ( new String ( definedTypeNames [ d ] ) ) , sourceFile . sourceLocation . binaryFolder ) ; } } this . newState . removeLocator ( typeLocator ) ; } } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } } protected boolean findAffectedSourceFiles ( IResourceDelta delta , ClasspathLocation [ ] classFoldersAndJars , IProject prereqProject ) { for ( int i = <NUM_LIT:0> , l = classFoldersAndJars . length ; i < l ; i ++ ) { ClasspathLocation bLocation = classFoldersAndJars [ i ] ; if ( bLocation != null ) { IPath p = bLocation . getProjectRelativePath ( ) ; if ( p != null ) { IResourceDelta binaryDelta = delta . findMember ( p ) ; if ( binaryDelta != null ) { if ( bLocation instanceof ClasspathJar ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } if ( binaryDelta . getKind ( ) == IResourceDelta . ADDED || binaryDelta . getKind ( ) == IResourceDelta . REMOVED ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } int segmentCount = binaryDelta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; StringSet structurallyChangedTypes = null ; if ( bLocation . isOutputFolder ( ) ) structurallyChangedTypes = this . newState . getStructurallyChangedTypes ( this . javaBuilder . getLastState ( prereqProject ) ) ; for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) findAffectedSourceFiles ( children [ j ] , segmentCount , structurallyChangedTypes ) ; this . notifier . checkCancel ( ) ; } } } } return true ; } protected void findAffectedSourceFiles ( IResourceDelta binaryDelta , int segmentCount , StringSet structurallyChangedTypes ) { IResource resource = binaryDelta . getResource ( ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : switch ( binaryDelta . getKind ( ) ) { case IResourceDelta . ADDED : case IResourceDelta . REMOVED : IPath packagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; String packageName = packagePath . toString ( ) ; if ( binaryDelta . getKind ( ) == IResourceDelta . ADDED ) { if ( ! this . newState . isKnownPackage ( packageName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; addDependentsOf ( packagePath , false ) ; return ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; } else { if ( ! this . nameEnvironment . isPackage ( packageName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; addDependentsOf ( packagePath , false ) ; return ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; } case IResourceDelta . CHANGED : IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) findAffectedSourceFiles ( children [ i ] , segmentCount , structurallyChangedTypes ) ; } return ; case IResource . FILE : if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( resource . getName ( ) ) ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; switch ( binaryDelta . getKind ( ) ) { case IResourceDelta . ADDED : case IResourceDelta . REMOVED : if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; addDependentsOf ( typePath , false ) ; return ; case IResourceDelta . CHANGED : if ( ( binaryDelta . getFlags ( ) & IResourceDelta . CONTENT ) == <NUM_LIT:0> ) return ; if ( structurallyChangedTypes != null && ! structurallyChangedTypes . includes ( typePath . toString ( ) ) ) return ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; addDependentsOf ( typePath , false ) ; } return ; } } } protected boolean findSourceFiles ( IResourceDelta delta ) throws CoreException { ArrayList visited = this . makeOutputFolderConsistent ? new ArrayList ( this . sourceLocations . length ) : null ; for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { ClasspathMultiDirectory md = this . sourceLocations [ i ] ; if ( this . makeOutputFolderConsistent && md . hasIndependentOutputFolder && ! visited . contains ( md . binaryFolder ) ) { visited . add ( md . binaryFolder ) ; IResourceDelta binaryDelta = delta . findMember ( md . binaryFolder . getProjectRelativePath ( ) ) ; if ( binaryDelta != null ) { int segmentCount = binaryDelta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) if ( ! checkForClassFileChanges ( children [ j ] , md , segmentCount ) ) return false ; } } if ( md . sourceFolder . equals ( this . javaBuilder . currentProject ) ) { int segmentCount = delta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = delta . getAffectedChildren ( ) ; for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) if ( ! isExcludedFromProject ( children [ j ] . getFullPath ( ) ) ) if ( ! findSourceFiles ( children [ j ] , md , segmentCount ) ) return false ; } else { IResourceDelta sourceDelta = delta . findMember ( md . sourceFolder . getProjectRelativePath ( ) ) ; if ( sourceDelta != null ) { if ( sourceDelta . getKind ( ) == IResourceDelta . REMOVED ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } int segmentCount = sourceDelta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = sourceDelta . getAffectedChildren ( ) ; try { for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) if ( ! findSourceFiles ( children [ j ] , md , segmentCount ) ) return false ; } catch ( CoreException e ) { if ( e . getStatus ( ) . getCode ( ) == IResourceStatus . CASE_VARIANT_EXISTS ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } throw e ; } } } this . notifier . checkCancel ( ) ; } return true ; } protected boolean findSourceFiles ( IResourceDelta sourceDelta , ClasspathMultiDirectory md , int segmentCount ) throws CoreException { IResource resource = sourceDelta . getResource ( ) ; boolean isExcluded = ( md . exclusionPatterns != null || md . inclusionPatterns != null ) && Util . isExcluded ( resource , md . inclusionPatterns , md . exclusionPatterns ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : if ( isExcluded && md . inclusionPatterns == null ) return true ; switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : if ( ! isExcluded ) { IPath addedPackagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; createFolder ( addedPackagePath , md . binaryFolder ) ; if ( this . sourceLocations . length > <NUM_LIT:1> && this . newState . isKnownPackage ( addedPackagePath . toString ( ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + addedPackagePath ) ; } else { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + addedPackagePath ) ; addDependentsOf ( addedPackagePath , true ) ; } } case IResourceDelta . CHANGED : IResourceDelta [ ] children = sourceDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) if ( ! findSourceFiles ( children [ i ] , md , segmentCount ) ) return false ; return true ; case IResourceDelta . REMOVED : if ( isExcluded ) { children = sourceDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) if ( ! findSourceFiles ( children [ i ] , md , segmentCount ) ) return false ; return true ; } IPath removedPackagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; if ( this . sourceLocations . length > <NUM_LIT:1> ) { for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { if ( this . sourceLocations [ i ] . sourceFolder . getFolder ( removedPackagePath ) . exists ( ) ) { createFolder ( removedPackagePath , md . binaryFolder ) ; IResourceDelta [ ] removedChildren = sourceDelta . getAffectedChildren ( ) ; for ( int j = <NUM_LIT:0> , m = removedChildren . length ; j < m ; j ++ ) if ( ! findSourceFiles ( removedChildren [ j ] , md , segmentCount ) ) return false ; return true ; } } } if ( ( sourceDelta . getFlags ( ) & IResourceDelta . MOVED_TO ) != <NUM_LIT:0> ) { IResource movedFolder = this . javaBuilder . workspaceRoot . getFolder ( sourceDelta . getMovedToPath ( ) ) ; JavaBuilder . removeProblemsAndTasksFor ( movedFolder ) ; } IFolder removedPackageFolder = md . binaryFolder . getFolder ( removedPackagePath ) ; if ( removedPackageFolder . exists ( ) ) removedPackageFolder . delete ( IResource . FORCE , null ) ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + removedPackagePath ) ; addDependentsOf ( removedPackagePath , true ) ; this . newState . removePackage ( sourceDelta ) ; } return true ; case IResource . FILE : if ( isExcluded ) return true ; String resourceName = resource . getName ( ) ; final boolean isInterestingProject = LanguageSupportFactory . isInterestingProject ( this . javaBuilder . getProject ( ) ) ; if ( ( ! isInterestingProject && org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( resourceName ) && ! LanguageSupportFactory . isInterestingSourceFile ( resourceName ) ) || ( isInterestingProject && LanguageSupportFactory . isSourceFile ( resourceName , isInterestingProject ) ) ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; String typeLocator = resource . getProjectRelativePath ( ) . toString ( ) ; switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeLocator ) ; this . sourceFiles . add ( new SourceFile ( ( IFile ) resource , md , true ) ) ; String typeName = typePath . toString ( ) ; if ( ! this . newState . isDuplicateLocator ( typeName , typeLocator ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeName ) ; addDependentsOf ( typePath , true ) ; } return true ; case IResourceDelta . REMOVED : char [ ] [ ] definedTypeNames = this . newState . getDefinedTypeNamesFor ( typeLocator ) ; if ( definedTypeNames == null ) { removeClassFile ( typePath , md . binaryFolder ) ; if ( ( sourceDelta . getFlags ( ) & IResourceDelta . MOVED_TO ) != <NUM_LIT:0> ) { IResource movedFile = this . javaBuilder . workspaceRoot . getFile ( sourceDelta . getMovedToPath ( ) ) ; JavaBuilder . removeProblemsAndTasksFor ( movedFile ) ; } } else { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath . toString ( ) ) ; addDependentsOf ( typePath , true ) ; if ( definedTypeNames . length > <NUM_LIT:0> ) { IPath packagePath = typePath . removeLastSegments ( <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> , l = definedTypeNames . length ; i < l ; i ++ ) removeClassFile ( packagePath . append ( new String ( definedTypeNames [ i ] ) ) , md . binaryFolder ) ; } } this . newState . removeLocator ( typeLocator ) ; return true ; case IResourceDelta . CHANGED : if ( ( sourceDelta . getFlags ( ) & IResourceDelta . CONTENT ) == <NUM_LIT:0> && ( sourceDelta . getFlags ( ) & IResourceDelta . ENCODING ) == <NUM_LIT:0> ) return true ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeLocator ) ; this . sourceFiles . add ( new SourceFile ( ( IFile ) resource , md , true ) ) ; } return true ; } else if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( resourceName ) ) { if ( this . makeOutputFolderConsistent ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; if ( this . newState . isKnownType ( typePath . toString ( ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; return false ; } } return true ; } else if ( md . hasIndependentOutputFolder ) { if ( this . javaBuilder . filterExtraResource ( resource ) ) return true ; IPath resourcePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; IResource outputFile = md . binaryFolder . getFile ( resourcePath ) ; switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : if ( outputFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; outputFile . delete ( IResource . FORCE , null ) ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; createFolder ( resourcePath . removeLastSegments ( <NUM_LIT:1> ) , md . binaryFolder ) ; copyResource ( resource , outputFile ) ; return true ; case IResourceDelta . REMOVED : if ( outputFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; outputFile . delete ( IResource . FORCE , null ) ; } return true ; case IResourceDelta . CHANGED : if ( ( sourceDelta . getFlags ( ) & IResourceDelta . CONTENT ) == <NUM_LIT:0> && ( sourceDelta . getFlags ( ) & IResourceDelta . ENCODING ) == <NUM_LIT:0> ) return true ; if ( outputFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; outputFile . delete ( IResource . FORCE , null ) ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; createFolder ( resourcePath . removeLastSegments ( <NUM_LIT:1> ) , md . binaryFolder ) ; copyResource ( resource , outputFile ) ; } return true ; } } return true ; } protected void finishedWith ( String sourceLocator , CompilationResult result , char [ ] mainTypeName , ArrayList definedTypeNames , ArrayList duplicateTypeNames ) { char [ ] [ ] previousTypeNames = this . newState . getDefinedTypeNamesFor ( sourceLocator ) ; if ( previousTypeNames == null ) previousTypeNames = new char [ ] [ ] { mainTypeName } ; IPath packagePath = null ; next : for ( int i = <NUM_LIT:0> , l = previousTypeNames . length ; i < l ; i ++ ) { char [ ] previous = previousTypeNames [ i ] ; for ( int j = <NUM_LIT:0> , m = definedTypeNames . size ( ) ; j < m ; j ++ ) if ( CharOperation . equals ( previous , ( char [ ] ) definedTypeNames . get ( j ) ) ) continue next ; SourceFile sourceFile = ( SourceFile ) result . getCompilationUnit ( ) ; if ( packagePath == null ) { int count = sourceFile . sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; packagePath = sourceFile . resource . getFullPath ( ) . removeFirstSegments ( count ) . removeLastSegments ( <NUM_LIT:1> ) ; } if ( this . secondaryTypesToRemove == null ) this . secondaryTypesToRemove = new SimpleLookupTable ( ) ; ArrayList types = ( ArrayList ) this . secondaryTypesToRemove . get ( sourceFile . sourceLocation . binaryFolder ) ; if ( types == null ) types = new ArrayList ( definedTypeNames . size ( ) ) ; types . add ( packagePath . append ( new String ( previous ) ) ) ; this . secondaryTypesToRemove . put ( sourceFile . sourceLocation . binaryFolder , types ) ; } super . finishedWith ( sourceLocator , result , mainTypeName , definedTypeNames , duplicateTypeNames ) ; } protected void processAnnotationResults ( CompilationParticipantResult [ ] results ) { for ( int i = results . length ; -- i >= <NUM_LIT:0> ; ) { CompilationParticipantResult result = results [ i ] ; if ( result == null ) continue ; IFile [ ] deletedGeneratedFiles = result . deletedFiles ; if ( deletedGeneratedFiles != null ) deleteGeneratedFiles ( deletedGeneratedFiles ) ; IFile [ ] addedGeneratedFiles = result . addedFiles ; if ( addedGeneratedFiles != null ) { for ( int j = addedGeneratedFiles . length ; -- j >= <NUM_LIT:0> ; ) { SourceFile sourceFile = findSourceFile ( addedGeneratedFiles [ j ] , true ) ; if ( sourceFile != null && ! this . sourceFiles . contains ( sourceFile ) ) this . sourceFiles . add ( sourceFile ) ; } } recordParticipantResult ( result ) ; } } protected void removeClassFile ( IPath typePath , IContainer outputFolder ) throws CoreException { if ( typePath . lastSegment ( ) . indexOf ( '<CHAR_LIT>' ) == - <NUM_LIT:1> ) { this . newState . removeQualifiedTypeName ( typePath . toString ( ) ) ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; addDependentsOf ( typePath , true ) ; } IFile classFile = outputFolder . getFile ( typePath . addFileExtension ( SuffixConstants . EXTENSION_class ) ) ; if ( classFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; classFile . delete ( IResource . FORCE , null ) ; } } protected void removeSecondaryTypes ( ) throws CoreException { if ( this . secondaryTypesToRemove != null ) { Object [ ] keyTable = this . secondaryTypesToRemove . keyTable ; Object [ ] valueTable = this . secondaryTypesToRemove . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { IContainer outputFolder = ( IContainer ) keyTable [ i ] ; if ( outputFolder != null ) { ArrayList paths = ( ArrayList ) valueTable [ i ] ; for ( int j = <NUM_LIT:0> , m = paths . size ( ) ; j < m ; j ++ ) removeClassFile ( ( IPath ) paths . get ( j ) , outputFolder ) ; } } this . secondaryTypesToRemove = null ; if ( this . previousSourceFiles != null ) this . previousSourceFiles = null ; } } protected void resetCollections ( ) { if ( this . sourceFiles == null ) { this . sourceFiles = new ArrayList ( <NUM_LIT> ) ; this . previousSourceFiles = null ; this . qualifiedStrings = new StringSet ( <NUM_LIT:3> ) ; this . simpleStrings = new StringSet ( <NUM_LIT:3> ) ; this . rootStrings = new StringSet ( <NUM_LIT:3> ) ; this . hasStructuralChanges = false ; this . compileLoop = <NUM_LIT:0> ; } else { this . previousSourceFiles = this . sourceFiles . isEmpty ( ) ? null : ( ArrayList ) this . sourceFiles . clone ( ) ; this . sourceFiles . clear ( ) ; this . qualifiedStrings . clear ( ) ; this . simpleStrings . clear ( ) ; this . rootStrings . clear ( ) ; this . workQueue . clear ( ) ; } } protected void updateProblemsFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { IMarker [ ] markers = JavaBuilder . getProblemsFor ( sourceFile . resource ) ; CategorizedProblem [ ] problems = result . getProblems ( ) ; if ( problems == null && markers . length == <NUM_LIT:0> ) return ; this . notifier . updateProblemCounts ( markers , problems ) ; JavaBuilder . removeProblemsFor ( sourceFile . resource ) ; storeProblemsFor ( sourceFile , problems ) ; } protected void updateTasksFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { IMarker [ ] markers = JavaBuilder . getTasksFor ( sourceFile . resource ) ; CategorizedProblem [ ] tasks = result . getTasks ( ) ; if ( tasks == null && markers . length == <NUM_LIT:0> ) return ; JavaBuilder . removeTasksFor ( sourceFile . resource ) ; storeTasksFor ( sourceFile , tasks ) ; } protected void writeClassFileContents ( ClassFile classfile , IFile file , String qualifiedFileName , boolean isTopLevelType , SourceFile compilationUnit ) throws CoreException { byte [ ] bytes = classfile . getBytes ( ) ; if ( file . exists ( ) ) { if ( writeClassFileCheck ( file , qualifiedFileName , bytes ) || compilationUnit . updateClassFile ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; if ( ! file . isDerived ( ) ) file . setDerived ( true , null ) ; file . setContents ( new ByteArrayInputStream ( bytes ) , true , false , null ) ; } else if ( JavaBuilder . DEBUG ) { System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; } } else { if ( isTopLevelType ) addDependentsOf ( new Path ( qualifiedFileName ) , true ) ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; try { file . create ( new ByteArrayInputStream ( bytes ) , IResource . FORCE | IResource . DERIVED , null ) ; } catch ( CoreException e ) { if ( e . getStatus ( ) . getCode ( ) == IResourceStatus . CASE_VARIANT_EXISTS ) { IStatus status = e . getStatus ( ) ; if ( status instanceof IResourceStatus ) { IPath oldFilePath = ( ( IResourceStatus ) status ) . getPath ( ) ; char [ ] oldTypeName = oldFilePath . removeFileExtension ( ) . lastSegment ( ) . toCharArray ( ) ; char [ ] [ ] previousTypeNames = this . newState . getDefinedTypeNamesFor ( compilationUnit . typeLocator ( ) ) ; boolean fromSameFile = false ; if ( previousTypeNames == null ) { fromSameFile = CharOperation . equals ( compilationUnit . getMainTypeName ( ) , oldTypeName ) ; } else { for ( int i = <NUM_LIT:0> , l = previousTypeNames . length ; i < l ; i ++ ) { if ( CharOperation . equals ( previousTypeNames [ i ] , oldTypeName ) ) { fromSameFile = true ; break ; } } } if ( fromSameFile ) { IFile collision = file . getParent ( ) . getFile ( new Path ( oldFilePath . lastSegment ( ) ) ) ; collision . delete ( true , false , null ) ; boolean success = false ; try { file . create ( new ByteArrayInputStream ( bytes ) , IResource . FORCE | IResource . DERIVED , null ) ; success = true ; } catch ( CoreException ignored ) { } if ( success ) return ; } } throw new AbortCompilation ( true , new AbortIncrementalBuildException ( qualifiedFileName ) ) ; } throw e ; } } } protected boolean writeClassFileCheck ( IFile file , String fileName , byte [ ] newBytes ) throws CoreException { try { byte [ ] oldBytes = Util . getResourceContentsAsByteArray ( file ) ; notEqual : if ( newBytes . length == oldBytes . length ) { for ( int i = newBytes . length ; -- i >= <NUM_LIT:0> ; ) if ( newBytes [ i ] != oldBytes [ i ] ) break notEqual ; return false ; } URI location = file . getLocationURI ( ) ; if ( location == null ) return false ; String filePath = location . getSchemeSpecificPart ( ) ; ClassFileReader reader = new ClassFileReader ( oldBytes , filePath . toCharArray ( ) ) ; if ( ! ( reader . isLocal ( ) || reader . isAnonymous ( ) ) && reader . hasStructuralChanges ( newBytes ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + fileName ) ; addDependentsOf ( new Path ( fileName ) , true ) ; this . newState . wasStructurallyChanged ( fileName ) ; } } catch ( ClassFormatException e ) { addDependentsOf ( new Path ( fileName ) , true ) ; this . newState . wasStructurallyChanged ( fileName ) ; } return true ; } public String toString ( ) { return "<STR_LIT>" + this . newState ; } } </s>
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . core . util . Messages ; public class BuildNotifier { protected IProgressMonitor monitor ; protected boolean cancelling ; protected float percentComplete ; protected float progressPerCompilationUnit ; protected int newErrorCount ; protected int fixedErrorCount ; protected int newWarningCount ; protected int fixedWarningCount ; protected int workDone ; protected int totalWork ; protected String previousSubtask ; public static int NewErrorCount = <NUM_LIT:0> ; public static int FixedErrorCount = <NUM_LIT:0> ; public static int NewWarningCount = <NUM_LIT:0> ; public static int FixedWarningCount = <NUM_LIT:0> ; public static void resetProblemCounters ( ) { NewErrorCount = <NUM_LIT:0> ; FixedErrorCount = <NUM_LIT:0> ; NewWarningCount = <NUM_LIT:0> ; FixedWarningCount = <NUM_LIT:0> ; } public BuildNotifier ( IProgressMonitor monitor , IProject project ) { this . monitor = monitor ; this . cancelling = false ; this . newErrorCount = NewErrorCount ; this . fixedErrorCount = FixedErrorCount ; this . newWarningCount = NewWarningCount ; this . fixedWarningCount = FixedWarningCount ; this . workDone = <NUM_LIT:0> ; this . totalWork = <NUM_LIT> ; } public void aboutToCompile ( SourceFile unit ) { String message = Messages . bind ( Messages . build_compiling , unit . resource . getFullPath ( ) . removeLastSegments ( <NUM_LIT:1> ) . makeRelative ( ) . toString ( ) ) ; subTask ( message ) ; } public void begin ( ) { if ( this . monitor != null ) this . monitor . beginTask ( "<STR_LIT>" , this . totalWork ) ; this . previousSubtask = null ; } public void checkCancel ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; } public void checkCancelWithinCompiler ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) && ! this . cancelling ) { setCancelling ( true ) ; throw new AbortCompilation ( true , null ) ; } } public void compiled ( SourceFile unit ) { String message = Messages . bind ( Messages . build_compiling , unit . resource . getFullPath ( ) . removeLastSegments ( <NUM_LIT:1> ) . makeRelative ( ) . toString ( ) ) ; subTask ( message ) ; updateProgressDelta ( this . progressPerCompilationUnit ) ; checkCancelWithinCompiler ( ) ; } public void done ( ) { NewErrorCount = this . newErrorCount ; FixedErrorCount = this . fixedErrorCount ; NewWarningCount = this . newWarningCount ; FixedWarningCount = this . fixedWarningCount ; updateProgress ( <NUM_LIT:1.0f> ) ; subTask ( Messages . build_done ) ; if ( this . monitor != null ) this . monitor . done ( ) ; this . previousSubtask = null ; } protected String problemsMessage ( ) { int numNew = this . newErrorCount + this . newWarningCount ; int numFixed = this . fixedErrorCount + this . fixedWarningCount ; if ( numNew == <NUM_LIT:0> && numFixed == <NUM_LIT:0> ) return "<STR_LIT>" ; boolean displayBoth = numNew > <NUM_LIT:0> && numFixed > <NUM_LIT:0> ; StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( '<CHAR_LIT:(>' ) ; if ( numNew > <NUM_LIT:0> ) { buffer . append ( Messages . build_foundHeader ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; if ( displayBoth || this . newErrorCount > <NUM_LIT:0> ) { if ( this . newErrorCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneError ) ; else buffer . append ( Messages . bind ( Messages . build_multipleErrors , String . valueOf ( this . newErrorCount ) ) ) ; if ( displayBoth || this . newWarningCount > <NUM_LIT:0> ) buffer . append ( "<STR_LIT>" ) ; } if ( displayBoth || this . newWarningCount > <NUM_LIT:0> ) { if ( this . newWarningCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneWarning ) ; else buffer . append ( Messages . bind ( Messages . build_multipleWarnings , String . valueOf ( this . newWarningCount ) ) ) ; } if ( numFixed > <NUM_LIT:0> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } if ( numFixed > <NUM_LIT:0> ) { buffer . append ( Messages . build_fixedHeader ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; if ( displayBoth ) { buffer . append ( String . valueOf ( this . fixedErrorCount ) ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( String . valueOf ( this . fixedWarningCount ) ) ; } else { if ( this . fixedErrorCount > <NUM_LIT:0> ) { if ( this . fixedErrorCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneError ) ; else buffer . append ( Messages . bind ( Messages . build_multipleErrors , String . valueOf ( this . fixedErrorCount ) ) ) ; if ( this . fixedWarningCount > <NUM_LIT:0> ) buffer . append ( "<STR_LIT>" ) ; } if ( this . fixedWarningCount > <NUM_LIT:0> ) { if ( this . fixedWarningCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneWarning ) ; else buffer . append ( Messages . bind ( Messages . build_multipleWarnings , String . valueOf ( this . fixedWarningCount ) ) ) ; } } } buffer . append ( '<CHAR_LIT:)>' ) ; return buffer . toString ( ) ; } public void setCancelling ( boolean cancelling ) { this . cancelling = cancelling ; } public void setProgressPerCompilationUnit ( float progress ) { this . progressPerCompilationUnit = progress ; } public void subTask ( String message ) { String pm = problemsMessage ( ) ; String msg = pm . length ( ) == <NUM_LIT:0> ? message : pm + "<STR_LIT:U+0020>" + message ; if ( msg . equals ( this . previousSubtask ) ) return ; if ( this . monitor != null ) this . monitor . subTask ( msg ) ; this . previousSubtask = msg ; } protected void updateProblemCounts ( CategorizedProblem [ ] newProblems ) { for ( int i = <NUM_LIT:0> , l = newProblems . length ; i < l ; i ++ ) if ( newProblems [ i ] . isError ( ) ) this . newErrorCount ++ ; else this . newWarningCount ++ ; } protected void updateProblemCounts ( IMarker [ ] oldProblems , CategorizedProblem [ ] newProblems ) { if ( newProblems != null ) { next : for ( int i = <NUM_LIT:0> , l = newProblems . length ; i < l ; i ++ ) { CategorizedProblem newProblem = newProblems [ i ] ; if ( newProblem . getID ( ) == IProblem . Task ) continue ; boolean isError = newProblem . isError ( ) ; String message = newProblem . getMessage ( ) ; if ( oldProblems != null ) { for ( int j = <NUM_LIT:0> , m = oldProblems . length ; j < m ; j ++ ) { IMarker pb = oldProblems [ j ] ; if ( pb == null ) continue ; boolean wasError = IMarker . SEVERITY_ERROR == pb . getAttribute ( IMarker . SEVERITY , IMarker . SEVERITY_ERROR ) ; if ( isError == wasError && message . equals ( pb . getAttribute ( IMarker . MESSAGE , "<STR_LIT>" ) ) ) { oldProblems [ j ] = null ; continue next ; } } } if ( isError ) this . newErrorCount ++ ; else this . newWarningCount ++ ; } } if ( oldProblems != null ) { next : for ( int i = <NUM_LIT:0> , l = oldProblems . length ; i < l ; i ++ ) { IMarker oldProblem = oldProblems [ i ] ; if ( oldProblem == null ) continue next ; boolean wasError = IMarker . SEVERITY_ERROR == oldProblem . getAttribute ( IMarker . SEVERITY , IMarker . SEVERITY_ERROR ) ; String message = oldProblem . getAttribute ( IMarker . MESSAGE , "<STR_LIT>" ) ; if ( newProblems != null ) { for ( int j = <NUM_LIT:0> , m = newProblems . length ; j < m ; j ++ ) { CategorizedProblem pb = newProblems [ j ] ; if ( pb . getID ( ) == IProblem . Task ) continue ; if ( wasError == pb . isError ( ) && message . equals ( pb . getMessage ( ) ) ) continue next ; } } if ( wasError ) this . fixedErrorCount ++ ; else this . fixedWarningCount ++ ; } } } public void updateProgress ( float newPercentComplete ) { if ( newPercentComplete > this . percentComplete ) { this . percentComplete = Math . min ( newPercentComplete , <NUM_LIT:1.0f> ) ; int work = Math . round ( this . percentComplete * this . totalWork ) ; if ( work > this . workDone ) { if ( this . monitor != null ) this . monitor . worked ( work - this . workDone ) ; this . workDone = work ; } } } public void updateProgressDelta ( float percentWorked ) { updateProgress ( this . percentComplete + percentWorked ) ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . SourceRange ; class SourceRefElementInfo extends JavaElementInfo { protected int sourceRangeStart , sourceRangeEnd ; public int getDeclarationSourceEnd ( ) { return this . sourceRangeEnd ; } public int getDeclarationSourceStart ( ) { return this . sourceRangeStart ; } protected ISourceRange getSourceRange ( ) { return new SourceRange ( this . sourceRangeStart , this . sourceRangeEnd - this . sourceRangeStart + <NUM_LIT:1> ) ; } protected void setSourceRangeEnd ( int end ) { this . sourceRangeEnd = end ; } protected void setSourceRangeStart ( int start ) { this . sourceRangeStart = start ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . io . BufferedInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . InputStream ; import java . lang . reflect . InvocationTargetException ; import java . lang . reflect . Method ; import java . net . JarURLConnection ; import java . net . MalformedURLException ; import java . net . ProtocolException ; import java . net . SocketException ; import java . net . SocketTimeoutException ; import java . net . URL ; import java . net . URLConnection ; import java . net . UnknownHostException ; import java . util . ArrayList ; import java . util . HashMap ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . * ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class JavaElement extends PlatformObject implements IJavaElement { private static final byte [ ] CLOSING_DOUBLE_QUOTE = new byte [ ] { <NUM_LIT> } ; private static final byte [ ] CHARSET = new byte [ ] { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; private static final byte [ ] CONTENT_TYPE = new byte [ ] { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; private static final byte [ ] CONTENT = new byte [ ] { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; public static final char JEM_ESCAPE = '<STR_LIT:\\>' ; public static final char JEM_JAVAPROJECT = '<CHAR_LIT:=>' ; public static final char JEM_PACKAGEFRAGMENTROOT = '<CHAR_LIT:/>' ; public static final char JEM_PACKAGEFRAGMENT = '<CHAR_LIT>' ; public static final char JEM_FIELD = '<CHAR_LIT>' ; public static final char JEM_METHOD = '<CHAR_LIT>' ; public static final char JEM_INITIALIZER = '<CHAR_LIT>' ; public static final char JEM_COMPILATIONUNIT = '<CHAR_LIT>' ; public static final char JEM_CLASSFILE = '<CHAR_LIT:(>' ; public static final char JEM_TYPE = '<CHAR_LIT:[>' ; public static final char JEM_PACKAGEDECLARATION = '<CHAR_LIT>' ; public static final char JEM_IMPORTDECLARATION = '<CHAR_LIT>' ; public static final char JEM_COUNT = '<CHAR_LIT>' ; public static final char JEM_LOCALVARIABLE = '<CHAR_LIT>' ; public static final char JEM_TYPE_PARAMETER = '<CHAR_LIT:]>' ; public static final char JEM_ANNOTATION = '<CHAR_LIT:}>' ; protected JavaElement parent ; protected static final JavaElement [ ] NO_ELEMENTS = new JavaElement [ <NUM_LIT:0> ] ; protected static final Object NO_INFO = new Object ( ) ; protected JavaElement ( JavaElement parent ) throws IllegalArgumentException { this . parent = parent ; } public void close ( ) throws JavaModelException { JavaModelManager . getJavaModelManager ( ) . removeInfoAndChildren ( this ) ; } protected abstract void closing ( Object info ) throws JavaModelException ; protected abstract Object createElementInfo ( ) ; public boolean equals ( Object o ) { if ( this == o ) return true ; if ( this . parent == null ) return super . equals ( o ) ; JavaElement other = ( JavaElement ) o ; return getElementName ( ) . equals ( other . getElementName ( ) ) && this . parent . equals ( other . parent ) ; } protected void escapeMementoName ( StringBuffer buffer , String mementoName ) { for ( int i = <NUM_LIT:0> , length = mementoName . length ( ) ; i < length ; i ++ ) { char character = mementoName . charAt ( i ) ; switch ( character ) { case JEM_ESCAPE : case JEM_COUNT : case JEM_JAVAPROJECT : case JEM_PACKAGEFRAGMENTROOT : case JEM_PACKAGEFRAGMENT : case JEM_FIELD : case JEM_METHOD : case JEM_INITIALIZER : case JEM_COMPILATIONUNIT : case JEM_CLASSFILE : case JEM_TYPE : case JEM_PACKAGEDECLARATION : case JEM_IMPORTDECLARATION : case JEM_LOCALVARIABLE : case JEM_TYPE_PARAMETER : case JEM_ANNOTATION : buffer . append ( JEM_ESCAPE ) ; } buffer . append ( character ) ; } } public boolean exists ( ) { try { getElementInfo ( ) ; return true ; } catch ( JavaModelException e ) { } return false ; } public ASTNode findNode ( CompilationUnit ast ) { return null ; } protected abstract void generateInfos ( Object info , HashMap newElements , IProgressMonitor pm ) throws JavaModelException ; public IJavaElement getAncestor ( int ancestorType ) { IJavaElement element = this ; while ( element != null ) { if ( element . getElementType ( ) == ancestorType ) return element ; element = element . getParent ( ) ; } return null ; } public IJavaElement [ ] getChildren ( ) throws JavaModelException { Object elementInfo = getElementInfo ( ) ; if ( elementInfo instanceof JavaElementInfo ) { return ( ( JavaElementInfo ) elementInfo ) . getChildren ( ) ; } else { return NO_ELEMENTS ; } } public ArrayList getChildrenOfType ( int type ) throws JavaModelException { IJavaElement [ ] children = getChildren ( ) ; int size = children . length ; ArrayList list = new ArrayList ( size ) ; for ( int i = <NUM_LIT:0> ; i < size ; ++ i ) { JavaElement elt = ( JavaElement ) children [ i ] ; if ( elt . getElementType ( ) == type ) { list . add ( elt ) ; } } return list ; } public IClassFile getClassFile ( ) { return null ; } public ICompilationUnit getCompilationUnit ( ) { return null ; } public Object getElementInfo ( ) throws JavaModelException { return getElementInfo ( null ) ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; Object info = manager . getInfo ( this ) ; if ( info != null ) return info ; return openWhenClosed ( createElementInfo ( ) , monitor ) ; } public String getElementName ( ) { return "<STR_LIT>" ; } public abstract IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner owner ) ; public IJavaElement getHandleFromMemento ( MementoTokenizer memento , WorkingCopyOwner owner ) { if ( ! memento . hasMoreTokens ( ) ) return this ; String token = memento . nextToken ( ) ; return getHandleFromMemento ( token , memento , owner ) ; } public String getHandleIdentifier ( ) { return getHandleMemento ( ) ; } public String getHandleMemento ( ) { StringBuffer buff = new StringBuffer ( ) ; getHandleMemento ( buff ) ; return buff . toString ( ) ; } protected void getHandleMemento ( StringBuffer buff ) { ( ( JavaElement ) getParent ( ) ) . getHandleMemento ( buff ) ; buff . append ( getHandleMementoDelimiter ( ) ) ; escapeMementoName ( buff , getElementName ( ) ) ; } protected abstract char getHandleMementoDelimiter ( ) ; public IJavaModel getJavaModel ( ) { IJavaElement current = this ; do { if ( current instanceof IJavaModel ) return ( IJavaModel ) current ; } while ( ( current = current . getParent ( ) ) != null ) ; return null ; } public IJavaProject getJavaProject ( ) { IJavaElement current = this ; do { if ( current instanceof IJavaProject ) return ( IJavaProject ) current ; } while ( ( current = current . getParent ( ) ) != null ) ; return null ; } public IOpenable getOpenable ( ) { return getOpenableParent ( ) ; } public IOpenable getOpenableParent ( ) { return ( IOpenable ) this . parent ; } public IJavaElement getParent ( ) { return this . parent ; } public IJavaElement getPrimaryElement ( ) { return getPrimaryElement ( true ) ; } public IJavaElement getPrimaryElement ( boolean checkOwner ) { return this ; } public IResource getResource ( ) { return resource ( ) ; } public abstract IResource resource ( ) ; protected IJavaElement getSourceElementAt ( int position ) throws JavaModelException { if ( this instanceof ISourceReference ) { IJavaElement [ ] children = getChildren ( ) ; for ( int i = children . length - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { IJavaElement aChild = children [ i ] ; if ( aChild instanceof SourceRefElement ) { SourceRefElement child = ( SourceRefElement ) children [ i ] ; ISourceRange range = child . getSourceRange ( ) ; int start = range . getOffset ( ) ; int end = start + range . getLength ( ) ; if ( start <= position && position <= end ) { if ( child instanceof IField ) { int declarationStart = start ; SourceRefElement candidate = null ; do { range = ( ( IField ) child ) . getNameRange ( ) ; if ( position <= range . getOffset ( ) + range . getLength ( ) ) { candidate = child ; } else { return candidate == null ? child . getSourceElementAt ( position ) : candidate . getSourceElementAt ( position ) ; } child = -- i >= <NUM_LIT:0> ? ( SourceRefElement ) children [ i ] : null ; } while ( child != null && child . getSourceRange ( ) . getOffset ( ) == declarationStart ) ; return candidate . getSourceElementAt ( position ) ; } else if ( child instanceof IParent ) { return child . getSourceElementAt ( position ) ; } else { return child ; } } } } } else { Assert . isTrue ( false ) ; } return this ; } public SourceMapper getSourceMapper ( ) { return ( ( JavaElement ) getParent ( ) ) . getSourceMapper ( ) ; } public ISchedulingRule getSchedulingRule ( ) { IResource resource = resource ( ) ; if ( resource == null ) { class NoResourceSchedulingRule implements ISchedulingRule { public IPath path ; public NoResourceSchedulingRule ( IPath path ) { this . path = path ; } public boolean contains ( ISchedulingRule rule ) { if ( rule instanceof NoResourceSchedulingRule ) { return this . path . isPrefixOf ( ( ( NoResourceSchedulingRule ) rule ) . path ) ; } else { return false ; } } public boolean isConflicting ( ISchedulingRule rule ) { if ( rule instanceof NoResourceSchedulingRule ) { IPath otherPath = ( ( NoResourceSchedulingRule ) rule ) . path ; return this . path . isPrefixOf ( otherPath ) || otherPath . isPrefixOf ( this . path ) ; } else { return false ; } } } return new NoResourceSchedulingRule ( getPath ( ) ) ; } else { return resource ; } } public boolean hasChildren ( ) throws JavaModelException { Object elementInfo = JavaModelManager . getJavaModelManager ( ) . getInfo ( this ) ; if ( elementInfo instanceof JavaElementInfo ) { return ( ( JavaElementInfo ) elementInfo ) . getChildren ( ) . length > <NUM_LIT:0> ; } else { return true ; } } public int hashCode ( ) { if ( this . parent == null ) return super . hashCode ( ) ; return Util . combineHashCodes ( getElementName ( ) . hashCode ( ) , this . parent . hashCode ( ) ) ; } public boolean isAncestorOf ( IJavaElement e ) { IJavaElement parentElement = e . getParent ( ) ; while ( parentElement != null && ! parentElement . equals ( this ) ) { parentElement = parentElement . getParent ( ) ; } return parentElement != null ; } public boolean isReadOnly ( ) { return false ; } public JavaModelException newNotPresentException ( ) { return new JavaModelException ( newDoesNotExistStatus ( ) ) ; } protected JavaModelStatus newDoesNotExistStatus ( ) { return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , this ) ; } public JavaModelException newJavaModelException ( IStatus status ) { if ( status instanceof IJavaModelStatus ) return new JavaModelException ( ( IJavaModelStatus ) status ) ; else return new JavaModelException ( new JavaModelStatus ( status . getSeverity ( ) , status . getCode ( ) , status . getMessage ( ) ) ) ; } protected Object openWhenClosed ( Object info , boolean b , IProgressMonitor monitor ) throws JavaModelException { return openWhenClosed ( info , monitor ) ; } protected Object openWhenClosed ( Object info , IProgressMonitor monitor ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; boolean hadTemporaryCache = manager . hasTemporaryCache ( ) ; try { HashMap newElements = manager . getTemporaryCache ( ) ; generateInfos ( info , newElements , monitor ) ; if ( info == null ) { info = newElements . get ( this ) ; } if ( info == null ) { Openable openable = ( Openable ) getOpenable ( ) ; if ( newElements . containsKey ( openable ) ) { openable . closeBuffer ( ) ; } throw newNotPresentException ( ) ; } if ( ! hadTemporaryCache ) { manager . putInfos ( this , newElements ) ; } } finally { if ( ! hadTemporaryCache ) { manager . resetTemporaryCache ( ) ; } } return info ; } public String readableName ( ) { return getElementName ( ) ; } public JavaElement resolved ( Binding binding ) { return this ; } public JavaElement unresolved ( ) { return this ; } protected String tabString ( int tab ) { StringBuffer buffer = new StringBuffer ( ) ; for ( int i = tab ; i > <NUM_LIT:0> ; i -- ) buffer . append ( "<STR_LIT:U+0020U+0020>" ) ; return buffer . toString ( ) ; } public String toDebugString ( ) { StringBuffer buffer = new StringBuffer ( ) ; this . toStringInfo ( <NUM_LIT:0> , buffer , NO_INFO , true ) ; return buffer . toString ( ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; toString ( <NUM_LIT:0> , buffer ) ; return buffer . toString ( ) ; } protected void toString ( int tab , StringBuffer buffer ) { Object info = this . toStringInfo ( tab , buffer ) ; if ( tab == <NUM_LIT:0> ) { toStringAncestors ( buffer ) ; } toStringChildren ( tab , buffer , info ) ; } public String toStringWithAncestors ( ) { return toStringWithAncestors ( true ) ; } public String toStringWithAncestors ( boolean showResolvedInfo ) { StringBuffer buffer = new StringBuffer ( ) ; this . toStringInfo ( <NUM_LIT:0> , buffer , NO_INFO , showResolvedInfo ) ; toStringAncestors ( buffer ) ; return buffer . toString ( ) ; } protected void toStringAncestors ( StringBuffer buffer ) { JavaElement parentElement = ( JavaElement ) getParent ( ) ; if ( parentElement != null && parentElement . getParent ( ) != null ) { buffer . append ( "<STR_LIT>" ) ; parentElement . toStringInfo ( <NUM_LIT:0> , buffer , NO_INFO , false ) ; parentElement . toStringAncestors ( buffer ) ; buffer . append ( "<STR_LIT:]>" ) ; } } protected void toStringChildren ( int tab , StringBuffer buffer , Object info ) { if ( info == null || ! ( info instanceof JavaElementInfo ) ) return ; IJavaElement [ ] children = ( ( JavaElementInfo ) info ) . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { buffer . append ( "<STR_LIT:n>" ) ; ( ( JavaElement ) children [ i ] ) . toString ( tab + <NUM_LIT:1> , buffer ) ; } } public Object toStringInfo ( int tab , StringBuffer buffer ) { Object info = JavaModelManager . getJavaModelManager ( ) . peekAtInfo ( this ) ; this . toStringInfo ( tab , buffer , info , true ) ; return info ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; toStringName ( buffer ) ; if ( info == null ) { buffer . append ( "<STR_LIT>" ) ; } } protected void toStringName ( StringBuffer buffer ) { buffer . append ( getElementName ( ) ) ; } protected URL getJavadocBaseLocation ( ) throws JavaModelException { IPackageFragmentRoot root = ( IPackageFragmentRoot ) getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; if ( root == null ) { return null ; } if ( root . getKind ( ) == IPackageFragmentRoot . K_BINARY ) { IClasspathEntry entry = null ; try { entry = root . getResolvedClasspathEntry ( ) ; URL url = getLibraryJavadocLocation ( entry ) ; if ( url != null ) { return url ; } } catch ( JavaModelException jme ) { } entry = root . getRawClasspathEntry ( ) ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_LIBRARY : case IClasspathEntry . CPE_VARIABLE : return getLibraryJavadocLocation ( entry ) ; default : return null ; } } return null ; } protected static URL getLibraryJavadocLocation ( IClasspathEntry entry ) throws JavaModelException { switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_LIBRARY : case IClasspathEntry . CPE_VARIABLE : break ; default : throw new IllegalArgumentException ( "<STR_LIT>" ) ; } IClasspathAttribute [ ] extraAttributes = entry . getExtraAttributes ( ) ; for ( int i = <NUM_LIT:0> ; i < extraAttributes . length ; i ++ ) { IClasspathAttribute attrib = extraAttributes [ i ] ; if ( IClasspathAttribute . JAVADOC_LOCATION_ATTRIBUTE_NAME . equals ( attrib . getName ( ) ) ) { String value = attrib . getValue ( ) ; try { return new URL ( value ) ; } catch ( MalformedURLException e ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC , value ) ) ; } } } return null ; } public String getAttachedJavadoc ( IProgressMonitor monitor ) throws JavaModelException { return null ; } int getIndexOf ( byte [ ] array , byte [ ] toBeFound , int start ) { if ( array == null || toBeFound == null ) return - <NUM_LIT:1> ; final int toBeFoundLength = toBeFound . length ; final int arrayLength = array . length ; if ( arrayLength < toBeFoundLength ) return - <NUM_LIT:1> ; loop : for ( int i = start , max = arrayLength - toBeFoundLength + <NUM_LIT:1> ; i < max ; i ++ ) { if ( array [ i ] == toBeFound [ <NUM_LIT:0> ] ) { for ( int j = <NUM_LIT:1> ; j < toBeFoundLength ; j ++ ) { if ( array [ i + j ] != toBeFound [ j ] ) continue loop ; } return i ; } } return - <NUM_LIT:1> ; } protected String getURLContents ( String docUrlValue ) throws JavaModelException { InputStream stream = null ; JarURLConnection connection2 = null ; try { URL docUrl = new URL ( docUrlValue ) ; URLConnection connection = docUrl . openConnection ( ) ; Class [ ] parameterTypes = new Class [ ] { int . class } ; Integer timeoutVal = new Integer ( <NUM_LIT> ) ; Class URLClass = connection . getClass ( ) ; try { Method connectTimeoutMethod = URLClass . getDeclaredMethod ( "<STR_LIT>" , parameterTypes ) ; Method readTimeoutMethod = URLClass . getDeclaredMethod ( "<STR_LIT>" , parameterTypes ) ; connectTimeoutMethod . invoke ( connection , new Object [ ] { timeoutVal } ) ; readTimeoutMethod . invoke ( connection , new Object [ ] { timeoutVal } ) ; } catch ( SecurityException e ) { } catch ( IllegalArgumentException e ) { } catch ( NoSuchMethodException e ) { } catch ( IllegalAccessException e ) { } catch ( InvocationTargetException e ) { } if ( connection instanceof JarURLConnection ) { connection2 = ( JarURLConnection ) connection ; connection . setUseCaches ( false ) ; } try { stream = new BufferedInputStream ( connection . getInputStream ( ) ) ; } catch ( IllegalArgumentException e ) { return null ; } catch ( NullPointerException e ) { return null ; } String encoding = connection . getContentEncoding ( ) ; byte [ ] contents = org . eclipse . jdt . internal . compiler . util . Util . getInputStreamAsByteArray ( stream , connection . getContentLength ( ) ) ; if ( encoding == null ) { int index = getIndexOf ( contents , CONTENT_TYPE , <NUM_LIT:0> ) ; if ( index != - <NUM_LIT:1> ) { index = getIndexOf ( contents , CONTENT , index ) ; if ( index != - <NUM_LIT:1> ) { int offset = index + CONTENT . length ; int index2 = getIndexOf ( contents , CLOSING_DOUBLE_QUOTE , offset ) ; if ( index2 != - <NUM_LIT:1> ) { final int charsetIndex = getIndexOf ( contents , CHARSET , offset ) ; if ( charsetIndex != - <NUM_LIT:1> ) { int start = charsetIndex + CHARSET . length ; encoding = new String ( contents , start , index2 - start , org . eclipse . jdt . internal . compiler . util . Util . UTF_8 ) ; } } } } } try { if ( encoding == null ) { encoding = getJavaProject ( ) . getProject ( ) . getDefaultCharset ( ) ; } } catch ( CoreException e ) { } if ( contents != null ) { if ( encoding != null ) { return new String ( contents , encoding ) ; } else { return new String ( contents ) ; } } } catch ( SocketTimeoutException e ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT , this ) ) ; } catch ( MalformedURLException e ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC , this ) ) ; } catch ( FileNotFoundException e ) { } catch ( SocketException e ) { } catch ( UnknownHostException e ) { } catch ( ProtocolException e ) { } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { } } if ( connection2 != null ) { try { connection2 . getJarFile ( ) . close ( ) ; } catch ( IOException e ) { } catch ( IllegalStateException e ) { } } } return null ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . io . InputStream ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . PlatformObject ; import org . eclipse . jdt . core . IJarEntryResource ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . internal . core . util . Util ; public class NonJavaResource extends PlatformObject implements IJarEntryResource { private static final IJarEntryResource [ ] NO_CHILDREN = new IJarEntryResource [ <NUM_LIT:0> ] ; protected Object parent ; protected IResource resource ; public NonJavaResource ( Object parent , IResource resource ) { this . parent = parent ; this . resource = resource ; } public boolean equals ( Object obj ) { if ( ! ( obj instanceof NonJavaResource ) ) return false ; NonJavaResource other = ( NonJavaResource ) obj ; return this . parent . equals ( other . parent ) && this . resource . equals ( other . resource ) ; } public IJarEntryResource [ ] getChildren ( ) { if ( this . resource instanceof IContainer ) { IResource [ ] members ; try { members = ( ( IContainer ) this . resource ) . members ( ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" + this . resource . getFullPath ( ) ) ; return NO_CHILDREN ; } int length = members . length ; if ( length == <NUM_LIT:0> ) return NO_CHILDREN ; IJarEntryResource [ ] children = new IJarEntryResource [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { children [ i ] = new NonJavaResource ( this , members [ i ] ) ; } return children ; } return NO_CHILDREN ; } public InputStream getContents ( ) throws CoreException { if ( this . resource instanceof IFile ) return ( ( IFile ) this . resource ) . getContents ( ) ; return null ; } protected String getEntryName ( ) { String parentEntryName ; if ( this . parent instanceof IPackageFragment ) { String elementName = ( ( IPackageFragment ) this . parent ) . getElementName ( ) ; parentEntryName = elementName . length ( ) == <NUM_LIT:0> ? "<STR_LIT>" : elementName . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) + '<CHAR_LIT:/>' ; } else if ( this . parent instanceof IPackageFragmentRoot ) { parentEntryName = "<STR_LIT>" ; } else { parentEntryName = ( ( NonJavaResource ) this . parent ) . getEntryName ( ) + '<CHAR_LIT:/>' ; } return parentEntryName + getName ( ) ; } public IPath getFullPath ( ) { return new Path ( getEntryName ( ) ) . makeAbsolute ( ) ; } public String getName ( ) { return this . resource . getName ( ) ; } public IPackageFragmentRoot getPackageFragmentRoot ( ) { if ( this . parent instanceof IPackageFragment ) { return ( IPackageFragmentRoot ) ( ( IPackageFragment ) this . parent ) . getParent ( ) ; } else if ( this . parent instanceof IPackageFragmentRoot ) { return ( IPackageFragmentRoot ) this . parent ; } else { return ( ( NonJavaResource ) this . parent ) . getPackageFragmentRoot ( ) ; } } public Object getParent ( ) { return this . parent ; } public int hashCode ( ) { return Util . combineHashCodes ( this . resource . hashCode ( ) , this . parent . hashCode ( ) ) ; } public boolean isFile ( ) { return this . resource instanceof IFile ; } public boolean isReadOnly ( ) { return true ; } public String toString ( ) { return "<STR_LIT>" + getEntryName ( ) + "<STR_LIT:]>" ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IFile ; import org . eclipse . jdt . core . IOpenable ; public class NullBuffer extends Buffer { public NullBuffer ( IFile file , IOpenable owner , boolean readOnly ) { super ( file , owner , readOnly ) ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaElementDelta ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaModelException ; public class DiscardWorkingCopyOperation extends JavaModelOperation { public DiscardWorkingCopyOperation ( IJavaElement workingCopy ) { super ( new IJavaElement [ ] { workingCopy } ) ; } protected void executeOperation ( ) throws JavaModelException { CompilationUnit workingCopy = getWorkingCopy ( ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; int useCount = manager . discardPerWorkingCopyInfo ( workingCopy ) ; if ( useCount == <NUM_LIT:0> ) { IJavaProject javaProject = workingCopy . getJavaProject ( ) ; if ( ExternalJavaProject . EXTERNAL_PROJECT_NAME . equals ( javaProject . getElementName ( ) ) ) { manager . removePerProjectInfo ( ( JavaProject ) javaProject , true ) ; manager . containerRemove ( javaProject ) ; } if ( ! workingCopy . isPrimary ( ) ) { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . removed ( workingCopy ) ; addDelta ( delta ) ; removeReconcileDelta ( workingCopy ) ; } else { if ( workingCopy . getResource ( ) . isAccessible ( ) ) { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . changed ( workingCopy , IJavaElementDelta . F_PRIMARY_WORKING_COPY ) ; addDelta ( delta ) ; } else { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . removed ( workingCopy , IJavaElementDelta . F_PRIMARY_WORKING_COPY ) ; addDelta ( delta ) ; } } } } protected CompilationUnit getWorkingCopy ( ) { return ( CompilationUnit ) getElementToProcess ( ) ; } public boolean isReadOnly ( ) { return true ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; public class ImportContainerInfo extends JavaElementInfo { protected IJavaElement [ ] children = JavaElement . NO_ELEMENTS ; public IJavaElement [ ] getChildren ( ) { return this . children ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . ISourceField ; import org . eclipse . jdt . internal . compiler . env . ISourceImport ; import org . eclipse . jdt . internal . compiler . env . ISourceMethod ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; public class SourceTypeElementInfo extends AnnotatableInfo implements ISourceType { protected static final ISourceImport [ ] NO_IMPORTS = new ISourceImport [ <NUM_LIT:0> ] ; protected static final InitializerElementInfo [ ] NO_INITIALIZERS = new InitializerElementInfo [ <NUM_LIT:0> ] ; protected static final SourceField [ ] NO_FIELDS = new SourceField [ <NUM_LIT:0> ] ; protected static final SourceMethod [ ] NO_METHODS = new SourceMethod [ <NUM_LIT:0> ] ; protected static final SourceType [ ] NO_TYPES = new SourceType [ <NUM_LIT:0> ] ; protected IJavaElement [ ] children = JavaElement . NO_ELEMENTS ; protected char [ ] superclassName ; protected char [ ] [ ] superInterfaceNames ; protected IType handle = null ; protected ITypeParameter [ ] typeParameters = TypeParameter . NO_TYPE_PARAMETERS ; protected HashMap categories ; protected void addCategories ( IJavaElement element , char [ ] [ ] elementCategories ) { if ( elementCategories == null ) return ; if ( this . categories == null ) this . categories = new HashMap ( ) ; this . categories . put ( element , CharOperation . toStrings ( elementCategories ) ) ; } public HashMap getCategories ( ) { return this . categories ; } public IJavaElement [ ] getChildren ( ) { return this . children ; } public ISourceType getEnclosingType ( ) { IJavaElement parent = this . handle . getParent ( ) ; if ( parent != null && parent . getElementType ( ) == IJavaElement . TYPE ) { try { return ( ISourceType ) ( ( JavaElement ) parent ) . getElementInfo ( ) ; } catch ( JavaModelException e ) { return null ; } } else { return null ; } } public ISourceField [ ] getFields ( ) { SourceField [ ] fieldHandles = getFieldHandles ( ) ; int length = fieldHandles . length ; ISourceField [ ] fields = new ISourceField [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { ISourceField field = ( ISourceField ) fieldHandles [ i ] . getElementInfo ( ) ; fields [ i ] = field ; } catch ( JavaModelException e ) { } } return fields ; } public SourceField [ ] getFieldHandles ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_FIELDS ; SourceField [ ] fields = new SourceField [ length ] ; int fieldIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceField ) fields [ fieldIndex ++ ] = ( SourceField ) child ; } if ( fieldIndex == <NUM_LIT:0> ) return NO_FIELDS ; if ( fieldIndex < length ) System . arraycopy ( fields , <NUM_LIT:0> , fields = new SourceField [ fieldIndex ] , <NUM_LIT:0> , fieldIndex ) ; return fields ; } public char [ ] getFileName ( ) { return this . handle . getPath ( ) . toString ( ) . toCharArray ( ) ; } public IType getHandle ( ) { return this . handle ; } public InitializerElementInfo [ ] getInitializers ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_INITIALIZERS ; InitializerElementInfo [ ] initializers = new InitializerElementInfo [ length ] ; int initializerIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof Initializer ) { try { InitializerElementInfo initializer = ( InitializerElementInfo ) ( ( Initializer ) child ) . getElementInfo ( ) ; initializers [ initializerIndex ++ ] = initializer ; } catch ( JavaModelException e ) { } } } if ( initializerIndex == <NUM_LIT:0> ) return NO_INITIALIZERS ; System . arraycopy ( initializers , <NUM_LIT:0> , initializers = new InitializerElementInfo [ initializerIndex ] , <NUM_LIT:0> , initializerIndex ) ; return initializers ; } public char [ ] [ ] getInterfaceNames ( ) { if ( this . handle . getElementName ( ) . length ( ) == <NUM_LIT:0> ) { return null ; } return this . superInterfaceNames ; } public ISourceType [ ] getMemberTypes ( ) { SourceType [ ] memberTypeHandles = getMemberTypeHandles ( ) ; int length = memberTypeHandles . length ; ISourceType [ ] memberTypes = new ISourceType [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { ISourceType type = ( ISourceType ) memberTypeHandles [ i ] . getElementInfo ( ) ; memberTypes [ i ] = type ; } catch ( JavaModelException e ) { } } return memberTypes ; } public SourceType [ ] getMemberTypeHandles ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_TYPES ; SourceType [ ] memberTypes = new SourceType [ length ] ; int typeIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceType ) memberTypes [ typeIndex ++ ] = ( SourceType ) child ; } if ( typeIndex == <NUM_LIT:0> ) return NO_TYPES ; if ( typeIndex < length ) System . arraycopy ( memberTypes , <NUM_LIT:0> , memberTypes = new SourceType [ typeIndex ] , <NUM_LIT:0> , typeIndex ) ; return memberTypes ; } public ISourceMethod [ ] getMethods ( ) { SourceMethod [ ] methodHandles = getMethodHandles ( ) ; int length = methodHandles . length ; ISourceMethod [ ] methods = new ISourceMethod [ length ] ; int methodIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { ISourceMethod method = ( ISourceMethod ) methodHandles [ i ] . getElementInfo ( ) ; methods [ methodIndex ++ ] = method ; } catch ( JavaModelException e ) { } } return methods ; } public SourceMethod [ ] getMethodHandles ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_METHODS ; SourceMethod [ ] methods = new SourceMethod [ length ] ; int methodIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceMethod ) methods [ methodIndex ++ ] = ( SourceMethod ) child ; } if ( methodIndex == <NUM_LIT:0> ) return NO_METHODS ; if ( methodIndex < length ) System . arraycopy ( methods , <NUM_LIT:0> , methods = new SourceMethod [ methodIndex ] , <NUM_LIT:0> , methodIndex ) ; return methods ; } public char [ ] getName ( ) { return this . handle . getElementName ( ) . toCharArray ( ) ; } public char [ ] getSuperclassName ( ) { if ( this . handle . getElementName ( ) . length ( ) == <NUM_LIT:0> ) { char [ ] [ ] interfaceNames = this . superInterfaceNames ; if ( interfaceNames != null && interfaceNames . length > <NUM_LIT:0> ) { return interfaceNames [ <NUM_LIT:0> ] ; } } return this . superclassName ; } public char [ ] [ ] [ ] getTypeParameterBounds ( ) { int length = this . typeParameters . length ; char [ ] [ ] [ ] typeParameterBounds = new char [ length ] [ ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { TypeParameterElementInfo info = ( TypeParameterElementInfo ) ( ( JavaElement ) this . typeParameters [ i ] ) . getElementInfo ( ) ; typeParameterBounds [ i ] = info . bounds ; } catch ( JavaModelException e ) { } } return typeParameterBounds ; } public char [ ] [ ] getTypeParameterNames ( ) { int length = this . typeParameters . length ; if ( length == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] [ ] typeParameterNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { typeParameterNames [ i ] = this . typeParameters [ i ] . getElementName ( ) . toCharArray ( ) ; } return typeParameterNames ; } public boolean isBinaryType ( ) { return false ; } public boolean isAnonymousMember ( ) { return false ; } protected void setHandle ( IType handle ) { this . handle = handle ; } protected void setSuperclassName ( char [ ] superclassName ) { this . superclassName = superclassName ; } protected void setSuperInterfaceNames ( char [ ] [ ] superInterfaceNames ) { this . superInterfaceNames = superInterfaceNames ; } public String toString ( ) { return "<STR_LIT>" + this . handle . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . List ; import java . util . Map ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . ASTParser ; import org . eclipse . jdt . core . dom . AnnotationTypeDeclaration ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . EnumDeclaration ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . TypeDeclaration ; import org . eclipse . jdt . core . dom . rewrite . ASTRewrite ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; public abstract class CreateTypeMemberOperation extends CreateElementInCUOperation { protected String source = null ; protected String alteredName ; protected ASTNode createdNode ; public CreateTypeMemberOperation ( IJavaElement parentElement , String source , boolean force ) { super ( parentElement ) ; this . source = source ; this . force = force ; } protected StructuralPropertyDescriptor getChildPropertyDescriptor ( ASTNode parent ) { switch ( parent . getNodeType ( ) ) { case ASTNode . COMPILATION_UNIT : return CompilationUnit . TYPES_PROPERTY ; case ASTNode . ENUM_DECLARATION : return EnumDeclaration . BODY_DECLARATIONS_PROPERTY ; case ASTNode . ANNOTATION_TYPE_DECLARATION : return AnnotationTypeDeclaration . BODY_DECLARATIONS_PROPERTY ; default : return TypeDeclaration . BODY_DECLARATIONS_PROPERTY ; } } protected ASTNode generateElementAST ( ASTRewrite rewriter , ICompilationUnit cu ) throws JavaModelException { if ( this . createdNode == null ) { this . source = removeIndentAndNewLines ( this . source , cu ) ; ASTParser parser = ASTParser . newParser ( AST . JLS4 ) ; parser . setSource ( this . source . toCharArray ( ) ) ; parser . setProject ( getCompilationUnit ( ) . getJavaProject ( ) ) ; parser . setKind ( ASTParser . K_CLASS_BODY_DECLARATIONS ) ; ASTNode node = parser . createAST ( this . progressMonitor ) ; String createdNodeSource ; if ( node . getNodeType ( ) != ASTNode . TYPE_DECLARATION ) { createdNodeSource = generateSyntaxIncorrectAST ( ) ; if ( this . createdNode == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; } else { TypeDeclaration typeDeclaration = ( TypeDeclaration ) node ; if ( ( typeDeclaration . getFlags ( ) & ASTNode . MALFORMED ) != <NUM_LIT:0> ) { createdNodeSource = generateSyntaxIncorrectAST ( ) ; if ( this . createdNode == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; } else { List bodyDeclarations = typeDeclaration . bodyDeclarations ( ) ; if ( bodyDeclarations . size ( ) == <NUM_LIT:0> ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; } this . createdNode = ( ASTNode ) bodyDeclarations . iterator ( ) . next ( ) ; createdNodeSource = this . source ; } } if ( this . alteredName != null ) { SimpleName newName = this . createdNode . getAST ( ) . newSimpleName ( this . alteredName ) ; SimpleName oldName = rename ( this . createdNode , newName ) ; int nameStart = oldName . getStartPosition ( ) ; int nameEnd = nameStart + oldName . getLength ( ) ; StringBuffer newSource = new StringBuffer ( ) ; if ( this . source . equals ( createdNodeSource ) ) { newSource . append ( createdNodeSource . substring ( <NUM_LIT:0> , nameStart ) ) ; newSource . append ( this . alteredName ) ; newSource . append ( createdNodeSource . substring ( nameEnd ) ) ; } else { int createdNodeStart = this . createdNode . getStartPosition ( ) ; int createdNodeEnd = createdNodeStart + this . createdNode . getLength ( ) ; newSource . append ( createdNodeSource . substring ( createdNodeStart , nameStart ) ) ; newSource . append ( this . alteredName ) ; newSource . append ( createdNodeSource . substring ( nameEnd , createdNodeEnd ) ) ; } this . source = newSource . toString ( ) ; } } if ( rewriter == null ) return this . createdNode ; return rewriter . createStringPlaceholder ( this . source , this . createdNode . getNodeType ( ) ) ; } private String removeIndentAndNewLines ( String code , ICompilationUnit cu ) throws JavaModelException { IJavaProject project = cu . getJavaProject ( ) ; Map options = project . getOptions ( true ) ; int tabWidth = IndentManipulation . getTabWidth ( options ) ; int indentWidth = IndentManipulation . getIndentWidth ( options ) ; int indent = IndentManipulation . measureIndentUnits ( code , tabWidth , indentWidth ) ; int firstNonWhiteSpace = - <NUM_LIT:1> ; int length = code . length ( ) ; while ( firstNonWhiteSpace < length - <NUM_LIT:1> ) if ( ! ScannerHelper . isWhitespace ( code . charAt ( ++ firstNonWhiteSpace ) ) ) break ; int lastNonWhiteSpace = length ; while ( lastNonWhiteSpace > <NUM_LIT:0> ) if ( ! ScannerHelper . isWhitespace ( code . charAt ( -- lastNonWhiteSpace ) ) ) break ; String lineDelimiter = cu . findRecommendedLineSeparator ( ) ; return IndentManipulation . changeIndent ( code . substring ( firstNonWhiteSpace , lastNonWhiteSpace + <NUM_LIT:1> ) , indent , tabWidth , indentWidth , "<STR_LIT>" , lineDelimiter ) ; } protected abstract SimpleName rename ( ASTNode node , SimpleName newName ) ; protected String generateSyntaxIncorrectAST ( ) { StringBuffer buff = new StringBuffer ( ) ; IType type = getType ( ) ; String lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( this . source , type == null ? null : type . getJavaProject ( ) ) ; buff . append ( lineSeparator + "<STR_LIT>" + lineSeparator ) ; buff . append ( this . source ) ; buff . append ( lineSeparator ) . append ( '<CHAR_LIT:}>' ) ; ASTParser parser = ASTParser . newParser ( AST . JLS4 ) ; parser . setSource ( buff . toString ( ) . toCharArray ( ) ) ; CompilationUnit compilationUnit = ( CompilationUnit ) parser . createAST ( null ) ; TypeDeclaration typeDeclaration = ( TypeDeclaration ) compilationUnit . types ( ) . iterator ( ) . next ( ) ; List bodyDeclarations = typeDeclaration . bodyDeclarations ( ) ; if ( bodyDeclarations . size ( ) != <NUM_LIT:0> ) this . createdNode = ( ASTNode ) bodyDeclarations . iterator ( ) . next ( ) ; return buff . toString ( ) ; } protected IType getType ( ) { return ( IType ) getParentElement ( ) ; } protected void setAlteredName ( String newName ) { this . alteredName = newName ; } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } if ( this . source == null ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ; } if ( ! this . force ) { try { ICompilationUnit cu = getCompilationUnit ( ) ; generateElementAST ( null , cu ) ; } catch ( JavaModelException jme ) { return jme . getJavaModelStatus ( ) ; } return verifyNameCollision ( ) ; } return JavaModelStatus . VERIFIED_OK ; } protected IJavaModelStatus verifyNameCollision ( ) { return JavaModelStatus . VERIFIED_OK ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; public class ExternalJavaProject extends JavaProject { public static final String EXTERNAL_PROJECT_NAME = "<STR_LIT:U+0020>" ; public ExternalJavaProject ( IClasspathEntry [ ] rawClasspath ) { super ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( EXTERNAL_PROJECT_NAME ) , JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) ) ; try { getPerProjectInfo ( ) . setRawClasspath ( rawClasspath , defaultOutputLocation ( ) , JavaModelStatus . VERIFIED_OK ) ; } catch ( JavaModelException e ) { } } public boolean equals ( Object o ) { return this == o ; } public boolean exists ( ) { return false ; } public String getOption ( String optionName , boolean inheritJavaCoreOptions ) { if ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE . equals ( optionName ) || JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE . equals ( optionName ) ) return JavaCore . IGNORE ; return super . getOption ( optionName , inheritJavaCoreOptions ) ; } public boolean isOnClasspath ( IJavaElement element ) { return false ; } public boolean isOnClasspath ( IResource resource ) { return false ; } protected IStatus validateExistence ( IResource underlyingResource ) { return JavaModelStatus . VERIFIED_OK ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . Iterator ; import java . util . List ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . MethodDeclaration ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . dom . SingleVariableDeclaration ; import org . eclipse . jdt . core . dom . rewrite . ASTRewrite ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class CreateMethodOperation extends CreateTypeMemberOperation { protected String [ ] parameterTypes ; public CreateMethodOperation ( IType parentElement , String source , boolean force ) { super ( parentElement , source , force ) ; } protected String [ ] convertASTMethodTypesToSignatures ( ) { if ( this . parameterTypes == null ) { if ( this . createdNode != null ) { MethodDeclaration methodDeclaration = ( MethodDeclaration ) this . createdNode ; List parameters = methodDeclaration . parameters ( ) ; int size = parameters . size ( ) ; this . parameterTypes = new String [ size ] ; Iterator iterator = parameters . iterator ( ) ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { SingleVariableDeclaration parameter = ( SingleVariableDeclaration ) iterator . next ( ) ; String typeSig = Util . getSignature ( parameter . getType ( ) ) ; int extraDimensions = parameter . getExtraDimensions ( ) ; if ( methodDeclaration . isVarargs ( ) && i == size - <NUM_LIT:1> ) extraDimensions ++ ; this . parameterTypes [ i ] = Signature . createArraySignature ( typeSig , extraDimensions ) ; } } } return this . parameterTypes ; } protected ASTNode generateElementAST ( ASTRewrite rewriter , ICompilationUnit cu ) throws JavaModelException { ASTNode node = super . generateElementAST ( rewriter , cu ) ; if ( node . getNodeType ( ) != ASTNode . METHOD_DECLARATION ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; return node ; } protected IJavaElement generateResultHandle ( ) { String [ ] types = convertASTMethodTypesToSignatures ( ) ; String name = getASTNodeName ( ) ; return getType ( ) . getMethod ( name , types ) ; } private String getASTNodeName ( ) { return ( ( MethodDeclaration ) this . createdNode ) . getName ( ) . getIdentifier ( ) ; } public String getMainTaskName ( ) { return Messages . operation_createMethodProgress ; } protected SimpleName rename ( ASTNode node , SimpleName newName ) { MethodDeclaration method = ( MethodDeclaration ) node ; SimpleName oldName = method . getName ( ) ; method . setName ( newName ) ; return oldName ; } protected IJavaModelStatus verifyNameCollision ( ) { if ( this . createdNode != null ) { IType type = getType ( ) ; String name ; if ( ( ( MethodDeclaration ) this . createdNode ) . isConstructor ( ) ) name = type . getElementName ( ) ; else name = getASTNodeName ( ) ; String [ ] types = convertASTMethodTypesToSignatures ( ) ; if ( type . getMethod ( name , types ) . exists ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION , Messages . bind ( Messages . status_nameCollision , name ) ) ; } } return JavaModelStatus . VERIFIED_OK ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaModelException ; public abstract class ChangeClasspathOperation extends JavaModelOperation { protected boolean canChangeResources ; public ChangeClasspathOperation ( IJavaElement [ ] elements , boolean canChangeResources ) { super ( elements ) ; this . canChangeResources = canChangeResources ; } protected boolean canModifyRoots ( ) { return true ; } protected void classpathChanged ( ClasspathChange change , boolean refreshExternalFolder ) throws JavaModelException { JavaProject project = change . project ; project . resetCaches ( ) ; if ( this . canChangeResources ) { if ( isTopLevelOperation ( ) && ! ResourcesPlugin . getWorkspace ( ) . isTreeLocked ( ) ) { new ClasspathValidation ( project ) . validate ( ) ; } new ProjectReferenceChange ( project , change . oldResolvedClasspath ) . updateProjectReferencesIfNecessary ( ) ; new ExternalFolderChange ( project , change . oldResolvedClasspath ) . updateExternalFoldersIfNecessary ( refreshExternalFolder , null ) ; } else { DeltaProcessingState state = JavaModelManager . getDeltaState ( ) ; JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; int result = change . generateDelta ( delta , true ) ; if ( ( result & ClasspathChange . HAS_DELTA ) != <NUM_LIT:0> ) { addDelta ( delta ) ; state . rootsAreStale = true ; change . requestIndexing ( ) ; state . addClasspathValidation ( project ) ; } if ( ( result & ClasspathChange . HAS_PROJECT_CHANGE ) != <NUM_LIT:0> ) { state . addProjectReferenceChange ( project , change . oldResolvedClasspath ) ; } if ( ( result & ClasspathChange . HAS_LIBRARY_CHANGE ) != <NUM_LIT:0> ) { state . addExternalFolderChange ( project , change . oldResolvedClasspath ) ; } } } protected ISchedulingRule getSchedulingRule ( ) { return null ; } public boolean isReadOnly ( ) { return ! this . canChangeResources ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IMemberValuePair ; public class AnnotationInfo extends SourceRefElementInfo { public int nameStart = - <NUM_LIT:1> ; public int nameEnd = - <NUM_LIT:1> ; public IMemberValuePair [ ] members ; } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IImportDeclaration ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IParent ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Messages ; public class CopyElementsOperation extends MultiOperation implements SuffixConstants { private Map sources = new HashMap ( ) ; public CopyElementsOperation ( IJavaElement [ ] elementsToCopy , IJavaElement [ ] destContainers , boolean force ) { super ( elementsToCopy , destContainers , force ) ; } public CopyElementsOperation ( IJavaElement [ ] elementsToCopy , IJavaElement destContainer , boolean force ) { this ( elementsToCopy , new IJavaElement [ ] { destContainer } , force ) ; } protected String getMainTaskName ( ) { return Messages . operation_copyElementProgress ; } protected JavaModelOperation getNestedOperation ( IJavaElement element ) { try { IJavaElement dest = getDestinationParent ( element ) ; switch ( element . getElementType ( ) ) { case IJavaElement . PACKAGE_DECLARATION : return new CreatePackageDeclarationOperation ( element . getElementName ( ) , ( ICompilationUnit ) dest ) ; case IJavaElement . IMPORT_DECLARATION : IImportDeclaration importDeclaration = ( IImportDeclaration ) element ; return new CreateImportOperation ( element . getElementName ( ) , ( ICompilationUnit ) dest , importDeclaration . getFlags ( ) ) ; case IJavaElement . TYPE : if ( isRenamingMainType ( element , dest ) ) { IPath path = element . getPath ( ) ; String extension = path . getFileExtension ( ) ; return new RenameResourceElementsOperation ( new IJavaElement [ ] { dest } , new IJavaElement [ ] { dest . getParent ( ) } , new String [ ] { getNewNameFor ( element ) + '<CHAR_LIT:.>' + extension } , this . force ) ; } else { String source = getSourceFor ( element ) ; String lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateTypeOperation ( dest , source + lineSeparator , this . force ) ; } case IJavaElement . METHOD : String source = getSourceFor ( element ) ; String lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateMethodOperation ( ( IType ) dest , source + lineSeparator , this . force ) ; case IJavaElement . FIELD : source = getSourceFor ( element ) ; lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateFieldOperation ( ( IType ) dest , source + lineSeparator , this . force ) ; case IJavaElement . INITIALIZER : source = getSourceFor ( element ) ; lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateInitializerOperation ( ( IType ) dest , source + lineSeparator ) ; default : return null ; } } catch ( JavaModelException npe ) { return null ; } } private String getSourceFor ( IJavaElement element ) throws JavaModelException { String source = ( String ) this . sources . get ( element ) ; if ( source == null && element instanceof IMember ) { source = ( ( IMember ) element ) . getSource ( ) ; this . sources . put ( element , source ) ; } return source ; } protected boolean isRenamingMainType ( IJavaElement element , IJavaElement dest ) throws JavaModelException { if ( ( isRename ( ) || getNewNameFor ( element ) != null ) && dest . getElementType ( ) == IJavaElement . COMPILATION_UNIT ) { String typeName = dest . getElementName ( ) ; typeName = org . eclipse . jdt . internal . core . util . Util . getNameWithoutJavaLikeExtension ( typeName ) ; return element . getElementName ( ) . equals ( typeName ) && element . getParent ( ) . equals ( dest ) ; } return false ; } protected void processElement ( IJavaElement element ) throws JavaModelException { JavaModelOperation op = getNestedOperation ( element ) ; boolean createElementInCUOperation = op instanceof CreateElementInCUOperation ; if ( op == null ) { return ; } if ( createElementInCUOperation ) { IJavaElement sibling = ( IJavaElement ) this . insertBeforeElements . get ( element ) ; if ( sibling != null ) { ( ( CreateElementInCUOperation ) op ) . setRelativePosition ( sibling , CreateElementInCUOperation . INSERT_BEFORE ) ; } else if ( isRename ( ) ) { IJavaElement anchor = resolveRenameAnchor ( element ) ; if ( anchor != null ) { ( ( CreateElementInCUOperation ) op ) . setRelativePosition ( anchor , CreateElementInCUOperation . INSERT_AFTER ) ; } } String newName = getNewNameFor ( element ) ; if ( newName != null ) { ( ( CreateElementInCUOperation ) op ) . setAlteredName ( newName ) ; } } executeNestedOperation ( op , <NUM_LIT:1> ) ; JavaElement destination = ( JavaElement ) getDestinationParent ( element ) ; ICompilationUnit unit = destination . getCompilationUnit ( ) ; if ( ! unit . isWorkingCopy ( ) ) { unit . close ( ) ; } if ( createElementInCUOperation && isMove ( ) && ! isRenamingMainType ( element , destination ) ) { JavaModelOperation deleteOp = new DeleteElementsOperation ( new IJavaElement [ ] { element } , this . force ) ; executeNestedOperation ( deleteOp , <NUM_LIT:1> ) ; } } private IJavaElement resolveRenameAnchor ( IJavaElement element ) throws JavaModelException { IParent parent = ( IParent ) element . getParent ( ) ; IJavaElement [ ] children = parent . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { IJavaElement child = children [ i ] ; if ( child . equals ( element ) ) { return child ; } } return null ; } protected IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } if ( this . renamingsList != null && this . renamingsList . length != this . elementsToProcess . length ) { return new JavaModelStatus ( IJavaModelStatusConstants . INDEX_OUT_OF_BOUNDS ) ; } return JavaModelStatus . VERIFIED_OK ; } protected void verify ( IJavaElement element ) throws JavaModelException { if ( element == null || ! element . exists ( ) ) error ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , element ) ; if ( element . getElementType ( ) < IJavaElement . TYPE ) error ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , element ) ; if ( element . isReadOnly ( ) ) error ( IJavaModelStatusConstants . READ_ONLY , element ) ; IJavaElement dest = getDestinationParent ( element ) ; verifyDestination ( element , dest ) ; verifySibling ( element , dest ) ; if ( this . renamingsList != null ) { verifyRenaming ( element ) ; } } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . io . IOException ; import java . io . StringReader ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Map ; import java . util . Set ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . preferences . IEclipsePreferences ; import org . eclipse . jdt . core . IClasspathContainer ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . util . Util ; import org . osgi . service . prefs . BackingStoreException ; public class UserLibraryManager { public final static String CP_USERLIBRARY_PREFERENCES_PREFIX = JavaCore . PLUGIN_ID + "<STR_LIT>" ; private Map userLibraries ; public UserLibraryManager ( ) { initialize ( ) ; } public synchronized UserLibrary getUserLibrary ( String libName ) { return ( UserLibrary ) this . userLibraries . get ( libName ) ; } public synchronized String [ ] getUserLibraryNames ( ) { Set set = this . userLibraries . keySet ( ) ; return ( String [ ] ) set . toArray ( new String [ set . size ( ) ] ) ; } private void initialize ( ) { this . userLibraries = new HashMap ( ) ; IEclipsePreferences instancePreferences = JavaModelManager . getJavaModelManager ( ) . getInstancePreferences ( ) ; String [ ] propertyNames ; try { propertyNames = instancePreferences . keys ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" ) ; return ; } boolean preferencesNeedFlush = false ; for ( int i = <NUM_LIT:0> , length = propertyNames . length ; i < length ; i ++ ) { String propertyName = propertyNames [ i ] ; if ( propertyName . startsWith ( CP_USERLIBRARY_PREFERENCES_PREFIX ) ) { String propertyValue = instancePreferences . get ( propertyName , null ) ; if ( propertyValue != null ) { String libName = propertyName . substring ( CP_USERLIBRARY_PREFERENCES_PREFIX . length ( ) ) ; StringReader reader = new StringReader ( propertyValue ) ; UserLibrary library ; try { library = UserLibrary . createFromString ( reader ) ; } catch ( IOException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; instancePreferences . remove ( propertyName ) ; preferencesNeedFlush = true ; continue ; } catch ( ClasspathEntry . AssertionFailedException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; instancePreferences . remove ( propertyName ) ; preferencesNeedFlush = true ; continue ; } this . userLibraries . put ( libName , library ) ; } } } if ( preferencesNeedFlush ) { try { instancePreferences . flush ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } } } public void updateUserLibrary ( String libName , String encodedUserLibrary ) { try { IPath containerPath = new Path ( JavaCore . USER_LIBRARY_CONTAINER_ID ) . append ( libName ) ; IJavaProject [ ] allJavaProjects = JavaCore . create ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ) . getJavaProjects ( ) ; ArrayList affectedProjects = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < allJavaProjects . length ; i ++ ) { IJavaProject javaProject = allJavaProjects [ i ] ; IClasspathEntry [ ] entries = javaProject . getRawClasspath ( ) ; for ( int j = <NUM_LIT:0> ; j < entries . length ; j ++ ) { IClasspathEntry entry = entries [ j ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_CONTAINER ) { if ( containerPath . equals ( entry . getPath ( ) ) ) { affectedProjects . add ( javaProject ) ; break ; } } } } UserLibrary userLibrary = encodedUserLibrary == null ? null : UserLibrary . createFromString ( new StringReader ( encodedUserLibrary ) ) ; synchronized ( this ) { if ( userLibrary != null ) { this . userLibraries . put ( libName , userLibrary ) ; } else { this . userLibraries . remove ( libName ) ; } } int length = affectedProjects . size ( ) ; if ( length == <NUM_LIT:0> ) return ; IJavaProject [ ] projects = new IJavaProject [ length ] ; affectedProjects . toArray ( projects ) ; IClasspathContainer [ ] containers = new IClasspathContainer [ length ] ; if ( userLibrary != null ) { UserLibraryClasspathContainer container = new UserLibraryClasspathContainer ( libName ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { containers [ i ] = container ; } } JavaCore . setClasspathContainer ( containerPath , projects , containers , null ) ; } catch ( IOException e ) { Util . log ( e , "<STR_LIT>" + libName + "<STR_LIT>" ) ; } catch ( JavaModelException e ) { Util . log ( e , "<STR_LIT>" + libName + "<STR_LIT>" ) ; } catch ( ClasspathEntry . AssertionFailedException ase ) { Util . log ( ase , "<STR_LIT>" + libName + "<STR_LIT>" ) ; } } public void removeUserLibrary ( String libName ) { synchronized ( this . userLibraries ) { IEclipsePreferences instancePreferences = JavaModelManager . getJavaModelManager ( ) . getInstancePreferences ( ) ; String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX + libName ; instancePreferences . remove ( propertyName ) ; try { instancePreferences . flush ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; } } } public void setUserLibrary ( String libName , IClasspathEntry [ ] entries , boolean isSystemLibrary ) { synchronized ( this . userLibraries ) { IEclipsePreferences instancePreferences = JavaModelManager . getJavaModelManager ( ) . getInstancePreferences ( ) ; String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX + libName ; try { String propertyValue = UserLibrary . serialize ( entries , isSystemLibrary ) ; instancePreferences . put ( propertyName , propertyValue ) ; } catch ( IOException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; return ; } try { instancePreferences . flush ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; } } } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Iterator ; import java . util . Map ; import java . util . Stack ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMemberValuePair ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ; import org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . Literal ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; import org . eclipse . jdt . internal . compiler . ast . NullLiteral ; import org . eclipse . jdt . internal . compiler . ast . OperatorIds ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . ast . UnaryExpression ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScanner ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . core . util . ReferenceInfoAdapter ; import org . eclipse . jdt . internal . core . util . Util ; public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter implements ISourceElementRequestor { protected ICompilationUnit unit ; protected CompilationUnitElementInfo unitInfo ; protected ImportContainerInfo importContainerInfo = null ; protected ImportContainer importContainer ; protected Map newElements ; private HashtableOfObjectToInt occurenceCounts ; protected Stack infoStack ; protected HashMap children ; protected Stack handleStack ; protected int referenceCount = <NUM_LIT:0> ; protected boolean hasSyntaxErrors = false ; protected Parser parser ; protected HashtableOfObject fieldRefCache ; protected HashtableOfObject messageRefCache ; protected HashtableOfObject typeRefCache ; protected HashtableOfObject unknownRefCache ; protected CompilationUnitStructureRequestor ( ICompilationUnit unit , CompilationUnitElementInfo unitInfo , Map newElements ) { this . unit = unit ; this . unitInfo = unitInfo ; this . newElements = newElements ; this . occurenceCounts = new HashtableOfObjectToInt ( ) ; } public void acceptImport ( int declarationStart , int declarationEnd , int nameSourceStart , int nameSourceEnd , char [ ] [ ] tokens , boolean onDemand , int modifiers ) { JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; if ( ! ( parentHandle . getElementType ( ) == IJavaElement . COMPILATION_UNIT ) ) { Assert . isTrue ( false ) ; } ICompilationUnit parentCU = ( ICompilationUnit ) parentHandle ; if ( this . importContainer == null ) { this . importContainer = createImportContainer ( parentCU ) ; this . importContainerInfo = new ImportContainerInfo ( ) ; Object parentInfo = this . infoStack . peek ( ) ; addToChildren ( parentInfo , this . importContainer ) ; this . newElements . put ( this . importContainer , this . importContainerInfo ) ; } String elementName = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( CharOperation . concatWith ( tokens , '<CHAR_LIT:.>' ) ) ) ; ImportDeclaration handle = createImportDeclaration ( this . importContainer , elementName , onDemand ) ; resolveDuplicates ( handle ) ; ImportDeclarationElementInfo info = new ImportDeclarationElementInfo ( ) ; info . setSourceRangeStart ( declarationStart ) ; info . setSourceRangeEnd ( declarationEnd ) ; info . setNameSourceStart ( nameSourceStart ) ; info . setNameSourceEnd ( nameSourceEnd ) ; info . setFlags ( modifiers ) ; addToChildren ( this . importContainerInfo , handle ) ; this . newElements . put ( handle , info ) ; } public void acceptLineSeparatorPositions ( int [ ] positions ) { } public void acceptPackage ( ImportReference importReference ) { Object parentInfo = this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; PackageDeclaration handle = null ; if ( parentHandle . getElementType ( ) == IJavaElement . COMPILATION_UNIT ) { char [ ] name = CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) ; handle = createPackageDeclaration ( parentHandle , new String ( name ) ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; AnnotatableInfo info = new AnnotatableInfo ( ) ; info . setSourceRangeStart ( importReference . declarationSourceStart ) ; info . setSourceRangeEnd ( importReference . declarationSourceEnd ) ; info . setNameSourceStart ( importReference . sourceStart ) ; info . setNameSourceEnd ( importReference . sourceEnd ) ; addToChildren ( parentInfo , handle ) ; this . newElements . put ( handle , info ) ; if ( importReference . annotations != null ) { for ( int i = <NUM_LIT:0> , length = importReference . annotations . length ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = importReference . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } } public void acceptProblem ( CategorizedProblem problem ) { if ( ( problem . getID ( ) & IProblem . Syntax ) != <NUM_LIT:0> ) { this . hasSyntaxErrors = true ; } } private void addToChildren ( Object parentInfo , JavaElement handle ) { ArrayList childrenList = ( ArrayList ) this . children . get ( parentInfo ) ; if ( childrenList == null ) this . children . put ( parentInfo , childrenList = new ArrayList ( ) ) ; childrenList . add ( handle ) ; } protected Annotation createAnnotation ( JavaElement parent , String name ) { return new Annotation ( parent , name ) ; } protected SourceField createField ( JavaElement parent , FieldInfo fieldInfo ) { String fieldName = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( fieldInfo . name ) ) ; return new SourceField ( parent , fieldName ) ; } protected ImportContainer createImportContainer ( ICompilationUnit parent ) { return ( ImportContainer ) parent . getImportContainer ( ) ; } protected ImportDeclaration createImportDeclaration ( ImportContainer parent , String name , boolean onDemand ) { return new ImportDeclaration ( parent , name , onDemand ) ; } protected Initializer createInitializer ( JavaElement parent ) { return new Initializer ( parent , <NUM_LIT:1> ) ; } protected SourceMethod createMethodHandle ( JavaElement parent , MethodInfo methodInfo ) { String selector = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( methodInfo . name ) ) ; String [ ] parameterTypeSigs = convertTypeNamesToSigs ( methodInfo . parameterTypes ) ; return new SourceMethod ( parent , selector , parameterTypeSigs ) ; } protected PackageDeclaration createPackageDeclaration ( JavaElement parent , String name ) { return new PackageDeclaration ( ( CompilationUnit ) parent , name ) ; } protected SourceType createTypeHandle ( JavaElement parent , TypeInfo typeInfo ) { String nameString = new String ( typeInfo . name ) ; return new SourceType ( parent , nameString ) ; } protected TypeParameter createTypeParameter ( JavaElement parent , String name ) { return new TypeParameter ( parent , name ) ; } protected static String [ ] convertTypeNamesToSigs ( char [ ] [ ] typeNames ) { if ( typeNames == null ) return CharOperation . NO_STRINGS ; int n = typeNames . length ; if ( n == <NUM_LIT:0> ) return CharOperation . NO_STRINGS ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; String [ ] typeSigs = new String [ n ] ; for ( int i = <NUM_LIT:0> ; i < n ; ++ i ) { typeSigs [ i ] = manager . intern ( Signature . createTypeSignature ( typeNames [ i ] , false ) ) ; } return typeSigs ; } protected IAnnotation acceptAnnotation ( org . eclipse . jdt . internal . compiler . ast . Annotation annotation , AnnotatableInfo parentInfo , JavaElement parentHandle ) { String nameString = new String ( CharOperation . concatWith ( annotation . type . getTypeName ( ) , '<CHAR_LIT:.>' ) ) ; Annotation handle = createAnnotation ( parentHandle , nameString ) ; resolveDuplicates ( handle ) ; AnnotationInfo info = new AnnotationInfo ( ) ; this . newElements . put ( handle , info ) ; this . handleStack . push ( handle ) ; info . setSourceRangeStart ( annotation . sourceStart ( ) ) ; info . nameStart = annotation . type . sourceStart ( ) ; info . nameEnd = annotation . type . sourceEnd ( ) ; MemberValuePair [ ] memberValuePairs = annotation . memberValuePairs ( ) ; int membersLength = memberValuePairs . length ; if ( membersLength == <NUM_LIT:0> ) { info . members = Annotation . NO_MEMBER_VALUE_PAIRS ; } else { info . members = getMemberValuePairs ( memberValuePairs ) ; } if ( parentInfo != null ) { IAnnotation [ ] annotations = parentInfo . annotations ; int length = annotations . length ; System . arraycopy ( annotations , <NUM_LIT:0> , annotations = new IAnnotation [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; annotations [ length ] = handle ; parentInfo . annotations = annotations ; } info . setSourceRangeEnd ( annotation . declarationSourceEnd ) ; this . handleStack . pop ( ) ; return handle ; } public void enterCompilationUnit ( ) { this . infoStack = new Stack ( ) ; this . children = new HashMap ( ) ; this . handleStack = new Stack ( ) ; this . infoStack . push ( this . unitInfo ) ; this . handleStack . push ( this . unit ) ; } public void enterConstructor ( MethodInfo methodInfo ) { enterMethod ( methodInfo ) ; } public void enterField ( FieldInfo fieldInfo ) { TypeInfo parentInfo = ( TypeInfo ) this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; SourceField handle = null ; if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) { handle = createField ( parentHandle , fieldInfo ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; addToChildren ( parentInfo , handle ) ; parentInfo . childrenCategories . put ( handle , fieldInfo . categories ) ; this . infoStack . push ( fieldInfo ) ; this . handleStack . push ( handle ) ; } public void enterInitializer ( int declarationSourceStart , int modifiers ) { Object parentInfo = this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; Initializer handle = null ; if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) { handle = createInitializer ( parentHandle ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; addToChildren ( parentInfo , handle ) ; this . infoStack . push ( new int [ ] { declarationSourceStart , modifiers } ) ; this . handleStack . push ( handle ) ; } public void enterMethod ( MethodInfo methodInfo ) { TypeInfo parentInfo = ( TypeInfo ) this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; SourceMethod handle = null ; if ( methodInfo . parameterTypes == null ) { methodInfo . parameterTypes = CharOperation . NO_CHAR_CHAR ; } if ( methodInfo . parameterNames == null ) { methodInfo . parameterNames = CharOperation . NO_CHAR_CHAR ; } if ( methodInfo . exceptionTypes == null ) { methodInfo . exceptionTypes = CharOperation . NO_CHAR_CHAR ; } if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) { handle = createMethodHandle ( parentHandle , methodInfo ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; this . infoStack . push ( methodInfo ) ; this . handleStack . push ( handle ) ; addToChildren ( parentInfo , handle ) ; parentInfo . childrenCategories . put ( handle , methodInfo . categories ) ; } private SourceMethodElementInfo createMethodInfo ( MethodInfo methodInfo , SourceMethod handle ) { IJavaElement [ ] elements = getChildren ( methodInfo ) ; SourceMethodElementInfo info ; if ( methodInfo . isConstructor ) { info = elements . length == <NUM_LIT:0> ? new SourceConstructorInfo ( ) : new SourceConstructorWithChildrenInfo ( elements ) ; } else if ( methodInfo . isAnnotation ) { info = new SourceAnnotationMethodInfo ( ) ; } else { info = elements . length == <NUM_LIT:0> ? new SourceMethodInfo ( ) : new SourceMethodWithChildrenInfo ( elements ) ; } info . setSourceRangeStart ( methodInfo . declarationStart ) ; int flags = methodInfo . modifiers ; info . setNameSourceStart ( methodInfo . nameSourceStart ) ; info . setNameSourceEnd ( methodInfo . nameSourceEnd ) ; info . setFlags ( flags ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; char [ ] [ ] parameterNames = methodInfo . parameterNames ; for ( int i = <NUM_LIT:0> , length = parameterNames . length ; i < length ; i ++ ) parameterNames [ i ] = manager . intern ( parameterNames [ i ] ) ; info . setArgumentNames ( parameterNames ) ; char [ ] returnType = methodInfo . returnType == null ? new char [ ] { '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' } : methodInfo . returnType ; info . setReturnType ( manager . intern ( returnType ) ) ; char [ ] [ ] exceptionTypes = methodInfo . exceptionTypes ; info . setExceptionTypeNames ( exceptionTypes ) ; for ( int i = <NUM_LIT:0> , length = exceptionTypes . length ; i < length ; i ++ ) exceptionTypes [ i ] = manager . intern ( exceptionTypes [ i ] ) ; this . newElements . put ( handle , info ) ; if ( methodInfo . typeParameters != null ) { for ( int i = <NUM_LIT:0> , length = methodInfo . typeParameters . length ; i < length ; i ++ ) { TypeParameterInfo typeParameterInfo = methodInfo . typeParameters [ i ] ; acceptTypeParameter ( typeParameterInfo , info ) ; } } if ( methodInfo . annotations != null ) { int length = methodInfo . annotations . length ; this . unitInfo . annotationNumber += length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = methodInfo . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } if ( methodInfo . node != null && methodInfo . node . arguments != null ) { info . arguments = acceptMethodParameters ( methodInfo . node . arguments , handle , methodInfo ) ; } return info ; } private LocalVariable [ ] acceptMethodParameters ( Argument [ ] arguments , JavaElement methodHandle , MethodInfo methodInfo ) { if ( arguments == null ) return null ; LocalVariable [ ] result = new LocalVariable [ arguments . length ] ; Annotation [ ] [ ] paramAnnotations = new Annotation [ arguments . length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < arguments . length ; i ++ ) { Argument argument = arguments [ i ] ; AnnotatableInfo localVarInfo = new AnnotatableInfo ( ) ; localVarInfo . setSourceRangeStart ( argument . declarationSourceStart ) ; localVarInfo . setSourceRangeEnd ( argument . declarationSourceStart ) ; localVarInfo . setNameSourceStart ( argument . sourceStart ) ; localVarInfo . setNameSourceEnd ( argument . sourceEnd ) ; String paramTypeSig = JavaModelManager . getJavaModelManager ( ) . intern ( Signature . createTypeSignature ( methodInfo . parameterTypes [ i ] , false ) ) ; result [ i ] = new LocalVariable ( methodHandle , new String ( argument . name ) , argument . declarationSourceStart , argument . declarationSourceEnd , argument . sourceStart , argument . sourceEnd , paramTypeSig , argument . annotations , argument . modifiers , true ) ; this . newElements . put ( result [ i ] , localVarInfo ) ; this . infoStack . push ( localVarInfo ) ; this . handleStack . push ( result [ i ] ) ; if ( argument . annotations != null ) { paramAnnotations [ i ] = new Annotation [ argument . annotations . length ] ; for ( int j = <NUM_LIT:0> ; j < argument . annotations . length ; j ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = argument . annotations [ j ] ; acceptAnnotation ( annotation , localVarInfo , result [ i ] ) ; } } this . infoStack . pop ( ) ; this . handleStack . pop ( ) ; } return result ; } public void enterType ( TypeInfo typeInfo ) { Object parentInfo = this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; SourceType handle = createTypeHandle ( parentHandle , typeInfo ) ; resolveDuplicates ( handle ) ; this . infoStack . push ( typeInfo ) ; this . handleStack . push ( handle ) ; if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) ( ( TypeInfo ) parentInfo ) . childrenCategories . put ( handle , typeInfo . categories ) ; addToChildren ( parentInfo , handle ) ; } private SourceTypeElementInfo createTypeInfo ( TypeInfo typeInfo , SourceType handle ) { SourceTypeElementInfo info = typeInfo . anonymousMember ? new SourceTypeElementInfo ( ) { public boolean isAnonymousMember ( ) { return true ; } } : new SourceTypeElementInfo ( ) ; info . setHandle ( handle ) ; info . setSourceRangeStart ( typeInfo . declarationStart ) ; info . setFlags ( typeInfo . modifiers ) ; info . setNameSourceStart ( typeInfo . nameSourceStart ) ; info . setNameSourceEnd ( typeInfo . nameSourceEnd ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; char [ ] superclass = typeInfo . superclass ; info . setSuperclassName ( superclass == null ? null : manager . intern ( superclass ) ) ; char [ ] [ ] superinterfaces = typeInfo . superinterfaces ; for ( int i = <NUM_LIT:0> , length = superinterfaces == null ? <NUM_LIT:0> : superinterfaces . length ; i < length ; i ++ ) superinterfaces [ i ] = manager . intern ( superinterfaces [ i ] ) ; info . setSuperInterfaceNames ( superinterfaces ) ; info . addCategories ( handle , typeInfo . categories ) ; this . newElements . put ( handle , info ) ; if ( typeInfo . typeParameters != null ) { for ( int i = <NUM_LIT:0> , length = typeInfo . typeParameters . length ; i < length ; i ++ ) { TypeParameterInfo typeParameterInfo = typeInfo . typeParameters [ i ] ; acceptTypeParameter ( typeParameterInfo , info ) ; } } if ( typeInfo . annotations != null ) { int length = typeInfo . annotations . length ; this . unitInfo . annotationNumber += length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = typeInfo . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } if ( typeInfo . childrenCategories != null ) { Iterator iterator = typeInfo . childrenCategories . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iterator . next ( ) ; info . addCategories ( ( IJavaElement ) entry . getKey ( ) , ( char [ ] [ ] ) entry . getValue ( ) ) ; } } return info ; } protected void acceptTypeParameter ( TypeParameterInfo typeParameterInfo , JavaElementInfo parentInfo ) { JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; String nameString = new String ( typeParameterInfo . name ) ; TypeParameter handle = createTypeParameter ( parentHandle , nameString ) ; resolveDuplicates ( handle ) ; TypeParameterElementInfo info = new TypeParameterElementInfo ( ) ; info . setSourceRangeStart ( typeParameterInfo . declarationStart ) ; info . nameStart = typeParameterInfo . nameSourceStart ; info . nameEnd = typeParameterInfo . nameSourceEnd ; info . bounds = typeParameterInfo . bounds ; if ( parentInfo instanceof SourceTypeElementInfo ) { SourceTypeElementInfo elementInfo = ( SourceTypeElementInfo ) parentInfo ; ITypeParameter [ ] typeParameters = elementInfo . typeParameters ; int length = typeParameters . length ; System . arraycopy ( typeParameters , <NUM_LIT:0> , typeParameters = new ITypeParameter [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; typeParameters [ length ] = handle ; elementInfo . typeParameters = typeParameters ; } else { SourceMethodElementInfo elementInfo = ( SourceMethodElementInfo ) parentInfo ; ITypeParameter [ ] typeParameters = elementInfo . typeParameters ; int length = typeParameters . length ; System . arraycopy ( typeParameters , <NUM_LIT:0> , typeParameters = new ITypeParameter [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; typeParameters [ length ] = handle ; elementInfo . typeParameters = typeParameters ; } this . newElements . put ( handle , info ) ; info . setSourceRangeEnd ( typeParameterInfo . declarationEnd ) ; } public void exitCompilationUnit ( int declarationEnd ) { if ( this . importContainerInfo != null ) { this . importContainerInfo . children = getChildren ( this . importContainerInfo ) ; } this . unitInfo . children = getChildren ( this . unitInfo ) ; this . unitInfo . setSourceLength ( declarationEnd + <NUM_LIT:1> ) ; this . unitInfo . setIsStructureKnown ( ! this . hasSyntaxErrors ) ; } public void exitConstructor ( int declarationEnd ) { exitMethod ( declarationEnd , null ) ; } public void exitField ( int initializationStart , int declarationEnd , int declarationSourceEnd ) { JavaElement handle = ( JavaElement ) this . handleStack . peek ( ) ; FieldInfo fieldInfo = ( FieldInfo ) this . infoStack . peek ( ) ; IJavaElement [ ] elements = getChildren ( fieldInfo ) ; SourceFieldElementInfo info = elements . length == <NUM_LIT:0> ? new SourceFieldElementInfo ( ) : new SourceFieldWithChildrenInfo ( elements ) ; info . setNameSourceStart ( fieldInfo . nameSourceStart ) ; info . setNameSourceEnd ( fieldInfo . nameSourceEnd ) ; info . setSourceRangeStart ( fieldInfo . declarationStart ) ; info . setFlags ( fieldInfo . modifiers ) ; char [ ] typeName = JavaModelManager . getJavaModelManager ( ) . intern ( fieldInfo . type ) ; info . setTypeName ( typeName ) ; this . newElements . put ( handle , info ) ; if ( fieldInfo . annotations != null ) { int length = fieldInfo . annotations . length ; this . unitInfo . annotationNumber += length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = fieldInfo . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } info . setSourceRangeEnd ( declarationSourceEnd ) ; this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; if ( initializationStart != - <NUM_LIT:1> ) { int flags = info . flags ; Object typeInfo ; if ( Flags . isStatic ( flags ) && Flags . isFinal ( flags ) || ( ( typeInfo = this . infoStack . peek ( ) ) instanceof TypeInfo && ( Flags . isInterface ( ( ( TypeInfo ) typeInfo ) . modifiers ) ) ) ) { int length = declarationEnd - initializationStart ; if ( length > <NUM_LIT:0> ) { char [ ] initializer = new char [ length ] ; System . arraycopy ( this . parser . scanner . source , initializationStart , initializer , <NUM_LIT:0> , length ) ; info . initializationSource = initializer ; } } } } public void exitInitializer ( int declarationEnd ) { JavaElement handle = ( JavaElement ) this . handleStack . peek ( ) ; int [ ] initializerInfo = ( int [ ] ) this . infoStack . peek ( ) ; IJavaElement [ ] elements = getChildren ( initializerInfo ) ; InitializerElementInfo info = elements . length == <NUM_LIT:0> ? new InitializerElementInfo ( ) : new InitializerWithChildrenInfo ( elements ) ; info . setSourceRangeStart ( initializerInfo [ <NUM_LIT:0> ] ) ; info . setFlags ( initializerInfo [ <NUM_LIT:1> ] ) ; info . setSourceRangeEnd ( declarationEnd ) ; this . newElements . put ( handle , info ) ; this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; } public void exitMethod ( int declarationEnd , Expression defaultValue ) { SourceMethod handle = ( SourceMethod ) this . handleStack . peek ( ) ; MethodInfo methodInfo = ( MethodInfo ) this . infoStack . peek ( ) ; SourceMethodElementInfo info = createMethodInfo ( methodInfo , handle ) ; info . setSourceRangeEnd ( declarationEnd ) ; if ( info . isAnnotationMethod ( ) && defaultValue != null ) { SourceAnnotationMethodInfo annotationMethodInfo = ( SourceAnnotationMethodInfo ) info ; annotationMethodInfo . defaultValueStart = defaultValue . sourceStart ; annotationMethodInfo . defaultValueEnd = defaultValue . sourceEnd ; JavaElement element = ( JavaElement ) this . handleStack . peek ( ) ; org . eclipse . jdt . internal . core . MemberValuePair defaultMemberValuePair = new org . eclipse . jdt . internal . core . MemberValuePair ( element . getElementName ( ) ) ; defaultMemberValuePair . value = getMemberValue ( defaultMemberValuePair , defaultValue ) ; annotationMethodInfo . defaultValue = defaultMemberValuePair ; } this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; } public void exitType ( int declarationEnd ) { SourceType handle = ( SourceType ) this . handleStack . peek ( ) ; TypeInfo typeInfo = ( TypeInfo ) this . infoStack . peek ( ) ; SourceTypeElementInfo info = createTypeInfo ( typeInfo , handle ) ; info . setSourceRangeEnd ( declarationEnd ) ; info . children = getChildren ( typeInfo ) ; this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; } protected void resolveDuplicates ( SourceRefElement handle ) { int occurenceCount = this . occurenceCounts . get ( handle ) ; if ( occurenceCount == - <NUM_LIT:1> ) this . occurenceCounts . put ( handle , <NUM_LIT:1> ) ; else { this . occurenceCounts . put ( handle , ++ occurenceCount ) ; handle . occurrenceCount = occurenceCount ; } } protected IMemberValuePair getMemberValuePair ( MemberValuePair memberValuePair ) { String memberName = new String ( memberValuePair . name ) ; org . eclipse . jdt . internal . core . MemberValuePair result = new org . eclipse . jdt . internal . core . MemberValuePair ( memberName ) ; result . value = getMemberValue ( result , memberValuePair . value ) ; return result ; } protected IMemberValuePair [ ] getMemberValuePairs ( MemberValuePair [ ] memberValuePairs ) { int membersLength = memberValuePairs . length ; IMemberValuePair [ ] members = new IMemberValuePair [ membersLength ] ; for ( int j = <NUM_LIT:0> ; j < membersLength ; j ++ ) { members [ j ] = getMemberValuePair ( memberValuePairs [ j ] ) ; } return members ; } private IJavaElement [ ] getChildren ( Object info ) { ArrayList childrenList = ( ArrayList ) this . children . get ( info ) ; if ( childrenList != null ) { return ( IJavaElement [ ] ) childrenList . toArray ( new IJavaElement [ childrenList . size ( ) ] ) ; } return JavaElement . NO_ELEMENTS ; } protected Object getMemberValue ( org . eclipse . jdt . internal . core . MemberValuePair memberValuePair , Expression expression ) { if ( expression instanceof NullLiteral ) { return null ; } else if ( expression instanceof Literal ) { ( ( Literal ) expression ) . computeConstant ( ) ; return Util . getAnnotationMemberValue ( memberValuePair , expression . constant ) ; } else if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . Annotation ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = ( org . eclipse . jdt . internal . compiler . ast . Annotation ) expression ; Object handle = acceptAnnotation ( annotation , null , ( JavaElement ) this . handleStack . peek ( ) ) ; memberValuePair . valueKind = IMemberValuePair . K_ANNOTATION ; return handle ; } else if ( expression instanceof ClassLiteralAccess ) { ClassLiteralAccess classLiteral = ( ClassLiteralAccess ) expression ; char [ ] name = CharOperation . concatWith ( classLiteral . type . getTypeName ( ) , '<CHAR_LIT:.>' ) ; memberValuePair . valueKind = IMemberValuePair . K_CLASS ; return new String ( name ) ; } else if ( expression instanceof QualifiedNameReference ) { char [ ] qualifiedName = CharOperation . concatWith ( ( ( QualifiedNameReference ) expression ) . tokens , '<CHAR_LIT:.>' ) ; memberValuePair . valueKind = IMemberValuePair . K_QUALIFIED_NAME ; return new String ( qualifiedName ) ; } else if ( expression instanceof SingleNameReference ) { char [ ] simpleName = ( ( SingleNameReference ) expression ) . token ; if ( simpleName == RecoveryScanner . FAKE_IDENTIFIER ) { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } memberValuePair . valueKind = IMemberValuePair . K_SIMPLE_NAME ; return new String ( simpleName ) ; } else if ( expression instanceof ArrayInitializer ) { memberValuePair . valueKind = - <NUM_LIT:1> ; Expression [ ] expressions = ( ( ArrayInitializer ) expression ) . expressions ; int length = expressions == null ? <NUM_LIT:0> : expressions . length ; Object [ ] values = new Object [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { int previousValueKind = memberValuePair . valueKind ; Object value = getMemberValue ( memberValuePair , expressions [ i ] ) ; if ( previousValueKind != - <NUM_LIT:1> && memberValuePair . valueKind != previousValueKind ) { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; } values [ i ] = value ; } if ( memberValuePair . valueKind == - <NUM_LIT:1> ) memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return values ; } else if ( expression instanceof UnaryExpression ) { UnaryExpression unaryExpression = ( UnaryExpression ) expression ; if ( ( unaryExpression . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT == OperatorIds . MINUS ) { if ( unaryExpression . expression instanceof Literal ) { Literal subExpression = ( Literal ) unaryExpression . expression ; subExpression . computeConstant ( ) ; return Util . getNegativeAnnotationMemberValue ( memberValuePair , subExpression . constant ) ; } } memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } else { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . net . URL ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . Map ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . IParent ; import org . eclipse . jdt . core . ISourceManipulation ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . JavaModelManager . PerProjectInfo ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class PackageFragment extends Openable implements IPackageFragment , SuffixConstants { protected static final IClassFile [ ] NO_CLASSFILES = new IClassFile [ ] { } ; protected static final ICompilationUnit [ ] NO_COMPILATION_UNITS = new ICompilationUnit [ ] { } ; public String [ ] names ; protected PackageFragment ( PackageFragmentRoot root , String [ ] names ) { super ( root ) ; this . names = names ; } protected boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException { HashSet vChildren = new HashSet ( ) ; int kind = getKind ( ) ; try { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; char [ ] [ ] inclusionPatterns = root . fullInclusionPatternChars ( ) ; char [ ] [ ] exclusionPatterns = root . fullExclusionPatternChars ( ) ; IResource [ ] members = ( ( IContainer ) underlyingResource ) . members ( ) ; int length = members . length ; if ( length > <NUM_LIT:0> ) { IJavaProject project = getJavaProject ( ) ; String sourceLevel = project . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IResource child = members [ i ] ; if ( child . getType ( ) != IResource . FOLDER && ! Util . isExcluded ( child , inclusionPatterns , exclusionPatterns ) ) { IJavaElement childElement ; if ( kind == IPackageFragmentRoot . K_SOURCE && Util . isValidCompilationUnitName ( child . getName ( ) , sourceLevel , complianceLevel ) ) { childElement = LanguageSupportFactory . newCompilationUnit ( this , child . getName ( ) , DefaultWorkingCopyOwner . PRIMARY ) ; vChildren . add ( childElement ) ; } else if ( kind == IPackageFragmentRoot . K_BINARY && Util . isValidClassFileName ( child . getName ( ) , sourceLevel , complianceLevel ) ) { childElement = getClassFile ( child . getName ( ) ) ; vChildren . add ( childElement ) ; } } } } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } if ( kind == IPackageFragmentRoot . K_SOURCE ) { ICompilationUnit [ ] primaryCompilationUnits = getCompilationUnits ( DefaultWorkingCopyOwner . PRIMARY ) ; for ( int i = <NUM_LIT:0> , length = primaryCompilationUnits . length ; i < length ; i ++ ) { ICompilationUnit primary = primaryCompilationUnits [ i ] ; vChildren . add ( primary ) ; } } IJavaElement [ ] children = new IJavaElement [ vChildren . size ( ) ] ; vChildren . toArray ( children ) ; info . setChildren ( children ) ; return true ; } public boolean containsJavaResources ( ) throws JavaModelException { return ( ( PackageFragmentInfo ) getElementInfo ( ) ) . containsJavaResources ( ) ; } public void copy ( IJavaElement container , IJavaElement sibling , String rename , boolean force , IProgressMonitor monitor ) throws JavaModelException { if ( container == null ) { throw new IllegalArgumentException ( Messages . operation_nullContainer ) ; } IJavaElement [ ] elements = new IJavaElement [ ] { this } ; IJavaElement [ ] containers = new IJavaElement [ ] { container } ; IJavaElement [ ] siblings = null ; if ( sibling != null ) { siblings = new IJavaElement [ ] { sibling } ; } String [ ] renamings = null ; if ( rename != null ) { renamings = new String [ ] { rename } ; } getJavaModel ( ) . copy ( elements , containers , siblings , renamings , force , monitor ) ; } public ICompilationUnit createCompilationUnit ( String cuName , String contents , boolean force , IProgressMonitor monitor ) throws JavaModelException { CreateCompilationUnitOperation op = new CreateCompilationUnitOperation ( this , cuName , contents , force ) ; op . runOperation ( monitor ) ; return LanguageSupportFactory . newCompilationUnit ( this , cuName , DefaultWorkingCopyOwner . PRIMARY ) ; } protected Object createElementInfo ( ) { return new PackageFragmentInfo ( ) ; } public void delete ( boolean force , IProgressMonitor monitor ) throws JavaModelException { IJavaElement [ ] elements = new IJavaElement [ ] { this } ; getJavaModel ( ) . delete ( elements , force , monitor ) ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof PackageFragment ) ) return false ; PackageFragment other = ( PackageFragment ) o ; return Util . equalArraysOrNull ( this . names , other . names ) && this . parent . equals ( other . parent ) ; } public boolean exists ( ) { return super . exists ( ) && ! Util . isExcluded ( this ) && isValidPackageName ( ) ; } public IClassFile getClassFile ( String classFileName ) { if ( ! org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( classFileName ) ) { throw new IllegalArgumentException ( Messages . bind ( Messages . element_invalidClassFileName , classFileName ) ) ; } int length = classFileName . length ( ) - <NUM_LIT:6> ; char [ ] nameWithoutExtension = new char [ length ] ; classFileName . getChars ( <NUM_LIT:0> , length , nameWithoutExtension , <NUM_LIT:0> ) ; return new ClassFile ( this , new String ( nameWithoutExtension ) ) ; } public IClassFile [ ] getClassFiles ( ) throws JavaModelException { if ( getKind ( ) == IPackageFragmentRoot . K_SOURCE ) { return NO_CLASSFILES ; } ArrayList list = getChildrenOfType ( CLASS_FILE ) ; IClassFile [ ] array = new IClassFile [ list . size ( ) ] ; list . toArray ( array ) ; return array ; } public ICompilationUnit getCompilationUnit ( String cuName ) { if ( ! org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( cuName ) ) { throw new IllegalArgumentException ( Messages . convention_unit_notJavaName ) ; } return LanguageSupportFactory . newCompilationUnit ( this , cuName , DefaultWorkingCopyOwner . PRIMARY ) ; } public ICompilationUnit [ ] getCompilationUnits ( ) throws JavaModelException { if ( getKind ( ) == IPackageFragmentRoot . K_BINARY ) { return NO_COMPILATION_UNITS ; } ArrayList list = getChildrenOfType ( COMPILATION_UNIT ) ; ICompilationUnit [ ] array = new ICompilationUnit [ list . size ( ) ] ; list . toArray ( array ) ; return array ; } public ICompilationUnit [ ] getCompilationUnits ( WorkingCopyOwner owner ) { ICompilationUnit [ ] workingCopies = JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( owner , false ) ; if ( workingCopies == null ) return JavaModelManager . NO_WORKING_COPY ; int length = workingCopies . length ; ICompilationUnit [ ] result = new ICompilationUnit [ length ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ICompilationUnit wc = workingCopies [ i ] ; if ( equals ( wc . getParent ( ) ) && ! Util . isExcluded ( wc ) ) { result [ index ++ ] = wc ; } } if ( index != length ) { System . arraycopy ( result , <NUM_LIT:0> , result = new ICompilationUnit [ index ] , <NUM_LIT:0> , index ) ; } return result ; } public String getElementName ( ) { if ( this . names . length == <NUM_LIT:0> ) return DEFAULT_PACKAGE_NAME ; return Util . concatWith ( this . names , '<CHAR_LIT:.>' ) ; } public int getElementType ( ) { return PACKAGE_FRAGMENT ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner owner ) { switch ( token . charAt ( <NUM_LIT:0> ) ) { case JEM_CLASSFILE : if ( ! memento . hasMoreTokens ( ) ) return this ; String classFileName = memento . nextToken ( ) ; JavaElement classFile = ( JavaElement ) getClassFile ( classFileName ) ; return classFile . getHandleFromMemento ( memento , owner ) ; case JEM_COMPILATIONUNIT : if ( ! memento . hasMoreTokens ( ) ) return this ; String cuName = memento . nextToken ( ) ; JavaElement cu = LanguageSupportFactory . newCompilationUnit ( this , cuName , owner ) ; return cu . getHandleFromMemento ( memento , owner ) ; } return null ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_PACKAGEFRAGMENT ; } public int getKind ( ) throws JavaModelException { return ( ( IPackageFragmentRoot ) getParent ( ) ) . getKind ( ) ; } public Object [ ] getNonJavaResources ( ) throws JavaModelException { if ( isDefaultPackage ( ) ) { return JavaElementInfo . NO_NON_JAVA_RESOURCES ; } else { return ( ( PackageFragmentInfo ) getElementInfo ( ) ) . getNonJavaResources ( resource ( ) , getPackageFragmentRoot ( ) ) ; } } public IPath getPath ( ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root . isArchive ( ) ) { return root . getPath ( ) ; } else { IPath path = root . getPath ( ) ; for ( int i = <NUM_LIT:0> , length = this . names . length ; i < length ; i ++ ) { String name = this . names [ i ] ; path = path . append ( name ) ; } return path ; } } public IResource resource ( PackageFragmentRoot root ) { int length = this . names . length ; if ( length == <NUM_LIT:0> ) { return root . resource ( root ) ; } else { IPath path = new Path ( this . names [ <NUM_LIT:0> ] ) ; for ( int i = <NUM_LIT:1> ; i < length ; i ++ ) path = path . append ( this . names [ i ] ) ; return ( ( IContainer ) root . resource ( root ) ) . getFolder ( path ) ; } } public IResource getUnderlyingResource ( ) throws JavaModelException { IResource rootResource = this . parent . getUnderlyingResource ( ) ; if ( rootResource == null ) { return null ; } if ( rootResource . getType ( ) == IResource . FOLDER || rootResource . getType ( ) == IResource . PROJECT ) { IContainer folder = ( IContainer ) rootResource ; String [ ] segs = this . names ; for ( int i = <NUM_LIT:0> ; i < segs . length ; ++ i ) { IResource child = folder . findMember ( segs [ i ] ) ; if ( child == null || child . getType ( ) != IResource . FOLDER ) { throw newNotPresentException ( ) ; } folder = ( IFolder ) child ; } return folder ; } else { return rootResource ; } } public int hashCode ( ) { int hash = this . parent . hashCode ( ) ; for ( int i = <NUM_LIT:0> , length = this . names . length ; i < length ; i ++ ) hash = Util . combineHashCodes ( this . names [ i ] . hashCode ( ) , hash ) ; return hash ; } public boolean hasChildren ( ) throws JavaModelException { return getChildren ( ) . length > <NUM_LIT:0> ; } public boolean hasSubpackages ( ) throws JavaModelException { IJavaElement [ ] packages = ( ( IPackageFragmentRoot ) getParent ( ) ) . getChildren ( ) ; int namesLength = this . names . length ; nextPackage : for ( int i = <NUM_LIT:0> , length = packages . length ; i < length ; i ++ ) { String [ ] otherNames = ( ( PackageFragment ) packages [ i ] ) . names ; if ( otherNames . length <= namesLength ) continue nextPackage ; for ( int j = <NUM_LIT:0> ; j < namesLength ; j ++ ) if ( ! this . names [ j ] . equals ( otherNames [ j ] ) ) continue nextPackage ; return true ; } return false ; } public boolean isDefaultPackage ( ) { return this . names . length == <NUM_LIT:0> ; } private boolean isValidPackageName ( ) { JavaProject javaProject = ( JavaProject ) getJavaProject ( ) ; String sourceLevel = javaProject . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = javaProject . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; for ( int i = <NUM_LIT:0> , length = this . names . length ; i < length ; i ++ ) { if ( ! Util . isValidFolderNameForPackage ( this . names [ i ] , sourceLevel , complianceLevel ) ) return false ; } return true ; } public void move ( IJavaElement container , IJavaElement sibling , String rename , boolean force , IProgressMonitor monitor ) throws JavaModelException { if ( container == null ) { throw new IllegalArgumentException ( Messages . operation_nullContainer ) ; } IJavaElement [ ] elements = new IJavaElement [ ] { this } ; IJavaElement [ ] containers = new IJavaElement [ ] { container } ; IJavaElement [ ] siblings = null ; if ( sibling != null ) { siblings = new IJavaElement [ ] { sibling } ; } String [ ] renamings = null ; if ( rename != null ) { renamings = new String [ ] { rename } ; } getJavaModel ( ) . move ( elements , containers , siblings , renamings , force , monitor ) ; } public void rename ( String newName , boolean force , IProgressMonitor monitor ) throws JavaModelException { if ( newName == null ) { throw new IllegalArgumentException ( Messages . element_nullName ) ; } IJavaElement [ ] elements = new IJavaElement [ ] { this } ; IJavaElement [ ] dests = new IJavaElement [ ] { getParent ( ) } ; String [ ] renamings = new String [ ] { newName } ; getJavaModel ( ) . rename ( elements , dests , renamings , force , monitor ) ; } protected void toStringChildren ( int tab , StringBuffer buffer , Object info ) { if ( tab == <NUM_LIT:0> ) { super . toStringChildren ( tab , buffer , info ) ; } } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; if ( this . names . length == <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; } else { toStringName ( buffer ) ; } if ( info == null ) { buffer . append ( "<STR_LIT>" ) ; } else { if ( tab > <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; } } } public String getAttachedJavadoc ( IProgressMonitor monitor ) throws JavaModelException { PerProjectInfo projectInfo = JavaModelManager . getJavaModelManager ( ) . getPerProjectInfoCheckExistence ( getJavaProject ( ) . getProject ( ) ) ; String cachedJavadoc = null ; synchronized ( projectInfo . javadocCache ) { cachedJavadoc = ( String ) projectInfo . javadocCache . get ( this ) ; } if ( cachedJavadoc != null ) { return cachedJavadoc ; } URL baseLocation = getJavadocBaseLocation ( ) ; if ( baseLocation == null ) { return null ; } StringBuffer pathBuffer = new StringBuffer ( baseLocation . toExternalForm ( ) ) ; if ( ! ( pathBuffer . charAt ( pathBuffer . length ( ) - <NUM_LIT:1> ) == '<CHAR_LIT:/>' ) ) { pathBuffer . append ( '<CHAR_LIT:/>' ) ; } String packPath = getElementName ( ) . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ; pathBuffer . append ( packPath ) . append ( '<CHAR_LIT:/>' ) . append ( JavadocConstants . PACKAGE_FILE_NAME ) ; if ( monitor != null && monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; final String contents = getURLContents ( String . valueOf ( pathBuffer ) ) ; if ( monitor != null && monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; if ( contents == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC , this ) ) ; synchronized ( projectInfo . javadocCache ) { projectInfo . javadocCache . put ( this , contents ) ; } return contents ; } protected IStatus validateExistence ( IResource underlyingResource ) { if ( ! isValidPackageName ( ) ) return newDoesNotExistStatus ( ) ; if ( underlyingResource != null && ! resourceExists ( underlyingResource ) ) return newDoesNotExistStatus ( ) ; int kind ; try { kind = getKind ( ) ; } catch ( JavaModelException e ) { return e . getStatus ( ) ; } if ( kind == IPackageFragmentRoot . K_SOURCE && Util . isExcluded ( this ) ) return newDoesNotExistStatus ( ) ; return JavaModelStatus . VERIFIED_OK ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . Iterator ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IImportDeclaration ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaConventions ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . ImportDeclaration ; import org . eclipse . jdt . core . dom . Name ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . rewrite . ASTRewrite ; import org . eclipse . jdt . internal . core . util . Messages ; public class CreateImportOperation extends CreateElementInCUOperation { protected String importName ; protected int flags ; public CreateImportOperation ( String importName , ICompilationUnit parentElement , int flags ) { super ( parentElement ) ; this . importName = importName ; this . flags = flags ; } protected StructuralPropertyDescriptor getChildPropertyDescriptor ( ASTNode parent ) { return CompilationUnit . IMPORTS_PROPERTY ; } protected ASTNode generateElementAST ( ASTRewrite rewriter , ICompilationUnit cu ) throws JavaModelException { Iterator imports = this . cuAST . imports ( ) . iterator ( ) ; boolean onDemand = this . importName . endsWith ( "<STR_LIT>" ) ; String importActualName = this . importName ; if ( onDemand ) { importActualName = this . importName . substring ( <NUM_LIT:0> , this . importName . length ( ) - <NUM_LIT:2> ) ; } while ( imports . hasNext ( ) ) { ImportDeclaration importDeclaration = ( ImportDeclaration ) imports . next ( ) ; if ( importActualName . equals ( importDeclaration . getName ( ) . getFullyQualifiedName ( ) ) && ( onDemand == importDeclaration . isOnDemand ( ) ) && ( Flags . isStatic ( this . flags ) == importDeclaration . isStatic ( ) ) ) { this . creationOccurred = false ; return null ; } } AST ast = this . cuAST . getAST ( ) ; ImportDeclaration importDeclaration = ast . newImportDeclaration ( ) ; importDeclaration . setStatic ( Flags . isStatic ( this . flags ) ) ; char [ ] [ ] charFragments = CharOperation . splitOn ( '<CHAR_LIT:.>' , importActualName . toCharArray ( ) , <NUM_LIT:0> , importActualName . length ( ) ) ; int length = charFragments . length ; String [ ] strFragments = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { strFragments [ i ] = String . valueOf ( charFragments [ i ] ) ; } Name name = ast . newName ( strFragments ) ; importDeclaration . setName ( name ) ; if ( onDemand ) importDeclaration . setOnDemand ( true ) ; return importDeclaration ; } protected IJavaElement generateResultHandle ( ) { return getCompilationUnit ( ) . getImport ( this . importName ) ; } public String getMainTaskName ( ) { return Messages . operation_createImportsProgress ; } protected void initializeDefaultPosition ( ) { try { ICompilationUnit cu = getCompilationUnit ( ) ; IImportDeclaration [ ] imports = cu . getImports ( ) ; if ( imports . length > <NUM_LIT:0> ) { createAfter ( imports [ imports . length - <NUM_LIT:1> ] ) ; return ; } IType [ ] types = cu . getTypes ( ) ; if ( types . length > <NUM_LIT:0> ) { createBefore ( types [ <NUM_LIT:0> ] ) ; return ; } IJavaElement [ ] children = cu . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { if ( children [ i ] . getElementType ( ) == IJavaElement . PACKAGE_DECLARATION ) { createAfter ( children [ i ] ) ; return ; } } } catch ( JavaModelException e ) { } } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } IJavaProject project = getParentElement ( ) . getJavaProject ( ) ; if ( JavaConventions . validateImportDeclaration ( this . importName , project . getOption ( JavaCore . COMPILER_SOURCE , true ) , project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ) . getSeverity ( ) == IStatus . ERROR ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_NAME , this . importName ) ; } return JavaModelStatus . VERIFIED_OK ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . Map ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IWorkspace ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaElementDelta ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . util . ObjectVector ; import org . eclipse . jdt . internal . core . DeltaProcessor . RootInfo ; import org . eclipse . jdt . internal . core . JavaModelManager . PerProjectInfo ; import org . eclipse . jdt . internal . core . search . indexing . IndexManager ; import org . eclipse . jdt . internal . core . util . Util ; public class ClasspathChange { public static final int NO_DELTA = <NUM_LIT:0x00> ; public static final int HAS_DELTA = <NUM_LIT> ; public static final int HAS_PROJECT_CHANGE = <NUM_LIT> ; public static final int HAS_LIBRARY_CHANGE = <NUM_LIT> ; JavaProject project ; IClasspathEntry [ ] oldRawClasspath ; IPath oldOutputLocation ; IClasspathEntry [ ] oldResolvedClasspath ; public ClasspathChange ( JavaProject project , IClasspathEntry [ ] oldRawClasspath , IPath oldOutputLocation , IClasspathEntry [ ] oldResolvedClasspath ) { this . project = project ; this . oldRawClasspath = oldRawClasspath ; this . oldOutputLocation = oldOutputLocation ; this . oldResolvedClasspath = oldResolvedClasspath ; } private void addClasspathDeltas ( JavaElementDelta delta , IPackageFragmentRoot [ ] roots , int flag ) { for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { IPackageFragmentRoot root = roots [ i ] ; delta . changed ( root , flag ) ; if ( ( flag & IJavaElementDelta . F_REMOVED_FROM_CLASSPATH ) != <NUM_LIT:0> || ( flag & IJavaElementDelta . F_SOURCEATTACHED ) != <NUM_LIT:0> || ( flag & IJavaElementDelta . F_SOURCEDETACHED ) != <NUM_LIT:0> ) { try { root . close ( ) ; } catch ( JavaModelException e ) { } } } } private int classpathContains ( IClasspathEntry [ ] list , IClasspathEntry entry ) { IPath [ ] exclusionPatterns = entry . getExclusionPatterns ( ) ; IPath [ ] inclusionPatterns = entry . getInclusionPatterns ( ) ; int listLen = list == null ? <NUM_LIT:0> : list . length ; nextEntry : for ( int i = <NUM_LIT:0> ; i < listLen ; i ++ ) { IClasspathEntry other = list [ i ] ; if ( other . getContentKind ( ) == entry . getContentKind ( ) && other . getEntryKind ( ) == entry . getEntryKind ( ) && other . isExported ( ) == entry . isExported ( ) && other . getPath ( ) . equals ( entry . getPath ( ) ) ) { IPath entryOutput = entry . getOutputLocation ( ) ; IPath otherOutput = other . getOutputLocation ( ) ; if ( entryOutput == null ) { if ( otherOutput != null ) continue ; } else { if ( ! entryOutput . equals ( otherOutput ) ) continue ; } IPath [ ] otherIncludes = other . getInclusionPatterns ( ) ; if ( inclusionPatterns != otherIncludes ) { if ( inclusionPatterns == null ) continue ; int includeLength = inclusionPatterns . length ; if ( otherIncludes == null || otherIncludes . length != includeLength ) continue ; for ( int j = <NUM_LIT:0> ; j < includeLength ; j ++ ) { if ( ! inclusionPatterns [ j ] . toString ( ) . equals ( otherIncludes [ j ] . toString ( ) ) ) continue nextEntry ; } } IPath [ ] otherExcludes = other . getExclusionPatterns ( ) ; if ( exclusionPatterns != otherExcludes ) { if ( exclusionPatterns == null ) continue ; int excludeLength = exclusionPatterns . length ; if ( otherExcludes == null || otherExcludes . length != excludeLength ) continue ; for ( int j = <NUM_LIT:0> ; j < excludeLength ; j ++ ) { if ( ! exclusionPatterns [ j ] . toString ( ) . equals ( otherExcludes [ j ] . toString ( ) ) ) continue nextEntry ; } } return i ; } } return - <NUM_LIT:1> ; } private void collectAllSubfolders ( IFolder folder , ArrayList collection ) throws JavaModelException { try { IResource [ ] members = folder . members ( ) ; for ( int i = <NUM_LIT:0> , max = members . length ; i < max ; i ++ ) { IResource r = members [ i ] ; if ( r . getType ( ) == IResource . FOLDER ) { collection . add ( r ) ; collectAllSubfolders ( ( IFolder ) r , collection ) ; } } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } private ArrayList determineAffectedPackageFragments ( IPath location ) throws JavaModelException { ArrayList fragments = new ArrayList ( ) ; IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; IResource resource = null ; if ( location != null ) { resource = workspace . getRoot ( ) . findMember ( location ) ; } if ( resource != null && resource . getType ( ) == IResource . FOLDER ) { IFolder folder = ( IFolder ) resource ; IClasspathEntry [ ] classpath = this . project . getExpandedClasspath ( ) ; for ( int i = <NUM_LIT:0> ; i < classpath . length ; i ++ ) { IClasspathEntry entry = classpath [ i ] ; IPath path = classpath [ i ] . getPath ( ) ; if ( entry . getEntryKind ( ) != IClasspathEntry . CPE_PROJECT && path . isPrefixOf ( location ) && ! path . equals ( location ) ) { IPackageFragmentRoot [ ] roots = this . project . computePackageFragmentRoots ( classpath [ i ] ) ; PackageFragmentRoot root = ( PackageFragmentRoot ) roots [ <NUM_LIT:0> ] ; ArrayList folders = new ArrayList ( ) ; folders . add ( folder ) ; collectAllSubfolders ( folder , folders ) ; Iterator elements = folders . iterator ( ) ; int segments = path . segmentCount ( ) ; while ( elements . hasNext ( ) ) { IFolder f = ( IFolder ) elements . next ( ) ; IPath relativePath = f . getFullPath ( ) . removeFirstSegments ( segments ) ; String [ ] pkgName = relativePath . segments ( ) ; IPackageFragment pkg = root . getPackageFragment ( pkgName ) ; if ( ! Util . isExcluded ( pkg ) ) fragments . add ( pkg ) ; } } } } return fragments ; } public boolean equals ( Object obj ) { if ( ! ( obj instanceof ClasspathChange ) ) return false ; return this . project . equals ( ( ( ClasspathChange ) obj ) . project ) ; } public int generateDelta ( JavaElementDelta delta , boolean addClasspathChange ) { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; DeltaProcessingState state = manager . deltaState ; if ( state . findJavaProject ( this . project . getElementName ( ) ) == null ) return NO_DELTA ; DeltaProcessor deltaProcessor = state . getDeltaProcessor ( ) ; IClasspathEntry [ ] newResolvedClasspath = null ; IPath newOutputLocation = null ; int result = NO_DELTA ; try { PerProjectInfo perProjectInfo = this . project . getPerProjectInfo ( ) ; this . project . resolveClasspath ( perProjectInfo , false , addClasspathChange ) ; IClasspathEntry [ ] newRawClasspath ; synchronized ( perProjectInfo ) { newRawClasspath = perProjectInfo . rawClasspath ; newResolvedClasspath = perProjectInfo . getResolvedClasspath ( ) ; newOutputLocation = perProjectInfo . outputLocation ; } if ( newResolvedClasspath == null ) { PerProjectInfo temporaryInfo = this . project . newTemporaryInfo ( ) ; this . project . resolveClasspath ( temporaryInfo , false , addClasspathChange ) ; newRawClasspath = temporaryInfo . rawClasspath ; newResolvedClasspath = temporaryInfo . getResolvedClasspath ( ) ; newOutputLocation = temporaryInfo . outputLocation ; } if ( this . oldRawClasspath != null && ! JavaProject . areClasspathsEqual ( this . oldRawClasspath , newRawClasspath , this . oldOutputLocation , newOutputLocation ) ) { delta . changed ( this . project , IJavaElementDelta . F_CLASSPATH_CHANGED ) ; result |= HAS_DELTA ; for ( int i = <NUM_LIT:0> , length = this . oldRawClasspath . length ; i < length ; i ++ ) { IClasspathEntry entry = this . oldRawClasspath [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_CONTAINER ) { if ( classpathContains ( newRawClasspath , entry ) == - <NUM_LIT:1> ) manager . containerPut ( this . project , entry . getPath ( ) , null ) ; } } } if ( this . oldResolvedClasspath != null && JavaProject . areClasspathsEqual ( this . oldResolvedClasspath , newResolvedClasspath , this . oldOutputLocation , newOutputLocation ) ) return result ; this . project . close ( ) ; deltaProcessor . projectCachesToReset . add ( this . project ) ; } catch ( JavaModelException e ) { if ( DeltaProcessor . VERBOSE ) { e . printStackTrace ( ) ; } return result ; } if ( this . oldResolvedClasspath == null ) return result ; delta . changed ( this . project , IJavaElementDelta . F_RESOLVED_CLASSPATH_CHANGED ) ; result |= HAS_DELTA ; state . addForRefresh ( this . project ) ; Map removedRoots = null ; IPackageFragmentRoot [ ] roots = null ; Map allOldRoots ; if ( ( allOldRoots = deltaProcessor . oldRoots ) != null ) { roots = ( IPackageFragmentRoot [ ] ) allOldRoots . get ( this . project ) ; } if ( roots != null ) { removedRoots = new HashMap ( ) ; for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { IPackageFragmentRoot root = roots [ i ] ; removedRoots . put ( root . getPath ( ) , root ) ; } } int newLength = newResolvedClasspath . length ; int oldLength = this . oldResolvedClasspath . length ; for ( int i = <NUM_LIT:0> ; i < oldLength ; i ++ ) { int index = classpathContains ( newResolvedClasspath , this . oldResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> ) { int entryKind = this . oldResolvedClasspath [ i ] . getEntryKind ( ) ; if ( entryKind == IClasspathEntry . CPE_PROJECT ) { result |= HAS_PROJECT_CHANGE ; continue ; } if ( entryKind == IClasspathEntry . CPE_LIBRARY ) { result |= HAS_LIBRARY_CHANGE ; } IPackageFragmentRoot [ ] pkgFragmentRoots = null ; if ( removedRoots != null ) { PackageFragmentRoot oldRoot = ( PackageFragmentRoot ) removedRoots . get ( this . oldResolvedClasspath [ i ] . getPath ( ) ) ; if ( oldRoot != null ) { pkgFragmentRoots = new PackageFragmentRoot [ ] { oldRoot } ; } } if ( pkgFragmentRoots == null ) { try { ObjectVector accumulatedRoots = new ObjectVector ( ) ; HashSet rootIDs = new HashSet ( <NUM_LIT:5> ) ; rootIDs . add ( this . project . rootID ( ) ) ; this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] , accumulatedRoots , rootIDs , null , false , null ) ; RootInfo rootInfo = ( RootInfo ) state . oldRoots . get ( this . oldResolvedClasspath [ i ] . getPath ( ) ) ; if ( rootInfo != null && rootInfo . cache != null ) { IPackageFragmentRoot oldRoot = rootInfo . cache ; boolean found = false ; for ( int j = <NUM_LIT:0> ; j < accumulatedRoots . size ( ) ; j ++ ) { IPackageFragmentRoot root = ( IPackageFragmentRoot ) accumulatedRoots . elementAt ( j ) ; if ( ! root . getPath ( ) . equals ( oldRoot . getPath ( ) ) ) { found = true ; break ; } } if ( ! found ) accumulatedRoots . add ( oldRoot ) ; } pkgFragmentRoots = new PackageFragmentRoot [ accumulatedRoots . size ( ) ] ; accumulatedRoots . copyInto ( pkgFragmentRoots ) ; } catch ( JavaModelException e ) { pkgFragmentRoots = new PackageFragmentRoot [ ] { } ; } } addClasspathDeltas ( delta , pkgFragmentRoots , IJavaElementDelta . F_REMOVED_FROM_CLASSPATH ) ; } else { if ( this . oldResolvedClasspath [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { result |= HAS_PROJECT_CHANGE ; continue ; } if ( index != i ) { addClasspathDeltas ( delta , this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] ) , IJavaElementDelta . F_REORDER ) ; } IPath newSourcePath = newResolvedClasspath [ index ] . getSourceAttachmentPath ( ) ; int sourceAttachmentFlags = getSourceAttachmentDeltaFlag ( this . oldResolvedClasspath [ i ] . getSourceAttachmentPath ( ) , newSourcePath ) ; IPath oldRootPath = this . oldResolvedClasspath [ i ] . getSourceAttachmentRootPath ( ) ; IPath newRootPath = newResolvedClasspath [ index ] . getSourceAttachmentRootPath ( ) ; int sourceAttachmentRootFlags = getSourceAttachmentDeltaFlag ( oldRootPath , newRootPath ) ; int flags = sourceAttachmentFlags | sourceAttachmentRootFlags ; if ( flags != <NUM_LIT:0> ) { addClasspathDeltas ( delta , this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] ) , flags ) ; } else { if ( oldRootPath == null && newRootPath == null ) { IPackageFragmentRoot [ ] computedRoots = this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] ) ; for ( int j = <NUM_LIT:0> ; j < computedRoots . length ; j ++ ) { IPackageFragmentRoot root = computedRoots [ j ] ; try { root . close ( ) ; } catch ( JavaModelException e ) { } } } } } } for ( int i = <NUM_LIT:0> ; i < newLength ; i ++ ) { int index = classpathContains ( this . oldResolvedClasspath , newResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> ) { int entryKind = newResolvedClasspath [ i ] . getEntryKind ( ) ; if ( entryKind == IClasspathEntry . CPE_PROJECT ) { result |= HAS_PROJECT_CHANGE ; continue ; } if ( entryKind == IClasspathEntry . CPE_LIBRARY ) { result |= HAS_LIBRARY_CHANGE ; } addClasspathDeltas ( delta , this . project . computePackageFragmentRoots ( newResolvedClasspath [ i ] ) , IJavaElementDelta . F_ADDED_TO_CLASSPATH ) ; } } if ( ( newOutputLocation == null && this . oldOutputLocation != null ) || ( newOutputLocation != null && ! newOutputLocation . equals ( this . oldOutputLocation ) ) ) { try { ArrayList added = determineAffectedPackageFragments ( this . oldOutputLocation ) ; Iterator iter = added . iterator ( ) ; while ( iter . hasNext ( ) ) { IPackageFragment frag = ( IPackageFragment ) iter . next ( ) ; ( ( IPackageFragmentRoot ) frag . getParent ( ) ) . close ( ) ; delta . added ( frag ) ; } ArrayList removed = determineAffectedPackageFragments ( newOutputLocation ) ; iter = removed . iterator ( ) ; while ( iter . hasNext ( ) ) { IPackageFragment frag = ( IPackageFragment ) iter . next ( ) ; ( ( IPackageFragmentRoot ) frag . getParent ( ) ) . close ( ) ; delta . removed ( frag ) ; } } catch ( JavaModelException e ) { if ( DeltaProcessor . VERBOSE ) e . printStackTrace ( ) ; } } return result ; } private int getSourceAttachmentDeltaFlag ( IPath oldPath , IPath newPath ) { if ( oldPath == null ) { if ( newPath != null ) { return IJavaElementDelta . F_SOURCEATTACHED ; } else { return <NUM_LIT:0> ; } } else if ( newPath == null ) { return IJavaElementDelta . F_SOURCEDETACHED ; } else if ( ! oldPath . equals ( newPath ) ) { return IJavaElementDelta . F_SOURCEATTACHED | IJavaElementDelta . F_SOURCEDETACHED ; } else { return <NUM_LIT:0> ; } } public int hashCode ( ) { return this . project . hashCode ( ) ; } public void requestIndexing ( ) { IClasspathEntry [ ] newResolvedClasspath = null ; try { newResolvedClasspath = this . project . getResolvedClasspath ( ) ; } catch ( JavaModelException e ) { return ; } JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; IndexManager indexManager = manager . indexManager ; if ( indexManager == null ) return ; DeltaProcessingState state = manager . deltaState ; int newLength = newResolvedClasspath . length ; int oldLength = this . oldResolvedClasspath == null ? <NUM_LIT:0> : this . oldResolvedClasspath . length ; for ( int i = <NUM_LIT:0> ; i < oldLength ; i ++ ) { int index = classpathContains ( newResolvedClasspath , this . oldResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> ) { if ( this . oldResolvedClasspath [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { continue ; } IClasspathEntry oldEntry = this . oldResolvedClasspath [ i ] ; final IPath path = oldEntry . getPath ( ) ; int changeKind = this . oldResolvedClasspath [ i ] . getEntryKind ( ) ; switch ( changeKind ) { case IClasspathEntry . CPE_SOURCE : char [ ] [ ] inclusionPatterns = ( ( ClasspathEntry ) oldEntry ) . fullInclusionPatternChars ( ) ; char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) oldEntry ) . fullExclusionPatternChars ( ) ; indexManager . removeSourceFolderFromIndex ( this . project , path , inclusionPatterns , exclusionPatterns ) ; break ; case IClasspathEntry . CPE_LIBRARY : if ( state . otherRoots . get ( path ) == null ) { indexManager . discardJobs ( path . toString ( ) ) ; indexManager . removeIndex ( path ) ; } break ; } } } for ( int i = <NUM_LIT:0> ; i < newLength ; i ++ ) { int index = classpathContains ( this . oldResolvedClasspath , newResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> ) { if ( newResolvedClasspath [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { continue ; } int entryKind = newResolvedClasspath [ i ] . getEntryKind ( ) ; switch ( entryKind ) { case IClasspathEntry . CPE_LIBRARY : boolean pathHasChanged = true ; IPath newPath = newResolvedClasspath [ i ] . getPath ( ) ; for ( int j = <NUM_LIT:0> ; j < oldLength ; j ++ ) { IClasspathEntry oldEntry = this . oldResolvedClasspath [ j ] ; if ( oldEntry . getPath ( ) . equals ( newPath ) ) { pathHasChanged = false ; break ; } } if ( pathHasChanged ) { indexManager . indexLibrary ( newPath , this . project . getProject ( ) ) ; } break ; case IClasspathEntry . CPE_SOURCE : IClasspathEntry entry = newResolvedClasspath [ i ] ; IPath path = entry . getPath ( ) ; char [ ] [ ] inclusionPatterns = ( ( ClasspathEntry ) entry ) . fullInclusionPatternChars ( ) ; char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) entry ) . fullExclusionPatternChars ( ) ; indexManager . indexSourceFolder ( this . project , path , inclusionPatterns , exclusionPatterns ) ; break ; } } } } public String toString ( ) { return "<STR_LIT>" + this . project . getElementName ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; public class JavaElementInfo implements Cloneable { static Object [ ] NO_NON_JAVA_RESOURCES = new Object [ ] { } ; public Object clone ( ) { try { return super . clone ( ) ; } catch ( CloneNotSupportedException e ) { throw new Error ( ) ; } } public IJavaElement [ ] getChildren ( ) { return JavaElement . NO_ELEMENTS ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import java . util . Enumeration ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . core . runtime . PerformanceStats ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . codeassist . CompletionEngine ; import org . eclipse . jdt . internal . codeassist . SelectionEngine ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class Openable extends JavaElement implements IOpenable , IBufferChangedListener { protected Openable ( JavaElement parent ) { super ( parent ) ; } public void bufferChanged ( BufferChangedEvent event ) { if ( event . getBuffer ( ) . isClosed ( ) ) { JavaModelManager . getJavaModelManager ( ) . getElementsOutOfSynchWithBuffers ( ) . remove ( this ) ; getBufferManager ( ) . removeBuffer ( event . getBuffer ( ) ) ; } else { JavaModelManager . getJavaModelManager ( ) . getElementsOutOfSynchWithBuffers ( ) . add ( this ) ; } } protected abstract boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException ; public boolean canBeRemovedFromCache ( ) { try { return ! hasUnsavedChanges ( ) ; } catch ( JavaModelException e ) { return false ; } } public boolean canBufferBeRemovedFromCache ( IBuffer buffer ) { return ! buffer . hasUnsavedChanges ( ) ; } protected void closeBuffer ( ) { if ( ! hasBuffer ( ) ) return ; IBuffer buffer = getBufferManager ( ) . getBuffer ( this ) ; if ( buffer != null ) { buffer . close ( ) ; buffer . removeBufferChangedListener ( this ) ; } } protected void closing ( Object info ) { closeBuffer ( ) ; } protected void codeComplete ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit cu , org . eclipse . jdt . internal . compiler . env . ICompilationUnit unitToSkip , int position , CompletionRequestor requestor , WorkingCopyOwner owner , ITypeRoot typeRoot , IProgressMonitor monitor ) throws JavaModelException { if ( requestor == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } PerformanceStats performanceStats = CompletionEngine . PERF ? PerformanceStats . getStats ( JavaModelManager . COMPLETION_PERF , this ) : null ; if ( performanceStats != null ) { performanceStats . startRun ( new String ( cu . getFileName ( ) ) + "<STR_LIT>" + position ) ; } IBuffer buffer = getBuffer ( ) ; if ( buffer == null ) { return ; } if ( position < - <NUM_LIT:1> || position > buffer . getLength ( ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INDEX_OUT_OF_BOUNDS ) ) ; } JavaProject project = ( JavaProject ) getJavaProject ( ) ; SearchableEnvironment environment = project . newSearchableNameEnvironment ( owner ) ; environment . unitToSkip = unitToSkip ; CompletionEngine engine = new CompletionEngine ( environment , requestor , project . getOptions ( true ) , project , owner , monitor ) ; engine . complete ( cu , position , <NUM_LIT:0> , typeRoot ) ; if ( performanceStats != null ) { performanceStats . endRun ( ) ; } if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } } protected IJavaElement [ ] codeSelect ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit cu , int offset , int length , WorkingCopyOwner owner ) throws JavaModelException { PerformanceStats performanceStats = SelectionEngine . PERF ? PerformanceStats . getStats ( JavaModelManager . SELECTION_PERF , this ) : null ; if ( performanceStats != null ) { performanceStats . startRun ( new String ( cu . getFileName ( ) ) + "<STR_LIT>" + offset + "<STR_LIT:U+002C>" + length + "<STR_LIT:]>" ) ; } JavaProject project = ( JavaProject ) getJavaProject ( ) ; SearchableEnvironment environment = project . newSearchableNameEnvironment ( owner ) ; SelectionRequestor requestor = new SelectionRequestor ( environment . nameLookup , this ) ; IBuffer buffer = getBuffer ( ) ; if ( buffer == null ) { return requestor . getElements ( ) ; } int end = buffer . getLength ( ) ; if ( offset < <NUM_LIT:0> || length < <NUM_LIT:0> || offset + length > end ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INDEX_OUT_OF_BOUNDS ) ) ; } SelectionEngine engine = new SelectionEngine ( environment , requestor , project . getOptions ( true ) , owner ) ; engine . select ( cu , offset , offset + length - <NUM_LIT:1> ) ; if ( performanceStats != null ) { performanceStats . endRun ( ) ; } if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } return requestor . getElements ( ) ; } protected Object createElementInfo ( ) { return new OpenableElementInfo ( ) ; } public boolean exists ( ) { if ( JavaModelManager . getJavaModelManager ( ) . getInfo ( this ) != null ) return true ; switch ( getElementType ( ) ) { case IJavaElement . PACKAGE_FRAGMENT : PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root . isArchive ( ) ) { JarPackageFragmentRootInfo rootInfo ; try { rootInfo = ( JarPackageFragmentRootInfo ) root . getElementInfo ( ) ; } catch ( JavaModelException e ) { return false ; } return rootInfo . rawPackageInfo . containsKey ( ( ( PackageFragment ) this ) . names ) ; } break ; case IJavaElement . CLASS_FILE : if ( getPackageFragmentRoot ( ) . isArchive ( ) ) { return super . exists ( ) ; } break ; } return validateExistence ( resource ( ) ) . isOK ( ) ; } public String findRecommendedLineSeparator ( ) throws JavaModelException { IBuffer buffer = getBuffer ( ) ; String source = buffer == null ? null : buffer . getContents ( ) ; return Util . getLineSeparator ( source , getJavaProject ( ) ) ; } protected void generateInfos ( Object info , HashMap newElements , IProgressMonitor monitor ) throws JavaModelException { if ( JavaModelCache . VERBOSE ) { String element ; switch ( getElementType ( ) ) { case JAVA_PROJECT : element = "<STR_LIT>" ; break ; case PACKAGE_FRAGMENT_ROOT : element = "<STR_LIT:root>" ; break ; case PACKAGE_FRAGMENT : element = "<STR_LIT>" ; break ; case CLASS_FILE : element = "<STR_LIT>" ; break ; case COMPILATION_UNIT : element = "<STR_LIT>" ; break ; default : element = "<STR_LIT>" ; } System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + element + "<STR_LIT:U+0020>" + this . toStringWithAncestors ( ) ) ; } openAncestors ( newElements , monitor ) ; IResource underlResource = resource ( ) ; IStatus status = validateExistence ( underlResource ) ; if ( ! status . isOK ( ) ) throw newJavaModelException ( status ) ; if ( monitor != null && monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; newElements . put ( this , info ) ; try { OpenableElementInfo openableElementInfo = ( OpenableElementInfo ) info ; boolean isStructureKnown = buildStructure ( openableElementInfo , monitor , newElements , underlResource ) ; openableElementInfo . setIsStructureKnown ( isStructureKnown ) ; } catch ( JavaModelException e ) { newElements . remove ( this ) ; throw e ; } JavaModelManager . getJavaModelManager ( ) . getElementsOutOfSynchWithBuffers ( ) . remove ( this ) ; if ( JavaModelCache . VERBOSE ) { System . out . println ( JavaModelManager . getJavaModelManager ( ) . cacheToString ( "<STR_LIT>" ) ) ; } } public IBuffer getBuffer ( ) throws JavaModelException { if ( hasBuffer ( ) ) { Object info = getElementInfo ( ) ; IBuffer buffer = getBufferManager ( ) . getBuffer ( this ) ; if ( buffer == null ) { buffer = openBuffer ( null , info ) ; } if ( buffer instanceof NullBuffer ) { return null ; } return buffer ; } else { return null ; } } public IBufferFactory getBufferFactory ( ) { return getBufferManager ( ) . getDefaultBufferFactory ( ) ; } protected BufferManager getBufferManager ( ) { return BufferManager . getDefaultBufferManager ( ) ; } public IResource getCorrespondingResource ( ) throws JavaModelException { return getUnderlyingResource ( ) ; } public IOpenable getOpenable ( ) { return this ; } public IResource getUnderlyingResource ( ) throws JavaModelException { IResource parentResource = this . parent . getUnderlyingResource ( ) ; if ( parentResource == null ) { return null ; } int type = parentResource . getType ( ) ; if ( type == IResource . FOLDER || type == IResource . PROJECT ) { IContainer folder = ( IContainer ) parentResource ; IResource resource = folder . findMember ( getElementName ( ) ) ; if ( resource == null ) { throw newNotPresentException ( ) ; } else { return resource ; } } else { return parentResource ; } } protected boolean hasBuffer ( ) { return false ; } public boolean hasUnsavedChanges ( ) throws JavaModelException { if ( isReadOnly ( ) || ! isOpen ( ) ) { return false ; } IBuffer buf = getBuffer ( ) ; if ( buf != null && buf . hasUnsavedChanges ( ) ) { return true ; } int elementType = getElementType ( ) ; if ( elementType == PACKAGE_FRAGMENT || elementType == PACKAGE_FRAGMENT_ROOT || elementType == JAVA_PROJECT || elementType == JAVA_MODEL ) { Enumeration openBuffers = getBufferManager ( ) . getOpenBuffers ( ) ; while ( openBuffers . hasMoreElements ( ) ) { IBuffer buffer = ( IBuffer ) openBuffers . nextElement ( ) ; if ( buffer . hasUnsavedChanges ( ) ) { IJavaElement owner = ( IJavaElement ) buffer . getOwner ( ) ; if ( isAncestorOf ( owner ) ) { return true ; } } } } return false ; } public boolean isConsistent ( ) { return true ; } public boolean isOpen ( ) { return JavaModelManager . getJavaModelManager ( ) . getInfo ( this ) != null ; } protected boolean isSourceElement ( ) { return false ; } public boolean isStructureKnown ( ) throws JavaModelException { return ( ( OpenableElementInfo ) getElementInfo ( ) ) . isStructureKnown ( ) ; } public void makeConsistent ( IProgressMonitor monitor ) throws JavaModelException { } public void open ( IProgressMonitor pm ) throws JavaModelException { getElementInfo ( pm ) ; } protected IBuffer openBuffer ( IProgressMonitor pm , Object info ) throws JavaModelException { return null ; } public IResource getResource ( ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root != null ) { if ( root . isExternal ( ) ) return null ; if ( root . isArchive ( ) ) return root . resource ( root ) ; } return resource ( root ) ; } public IResource resource ( ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root != null && root . isArchive ( ) ) return root . resource ( root ) ; return resource ( root ) ; } protected abstract IResource resource ( PackageFragmentRoot root ) ; protected boolean resourceExists ( IResource underlyingResource ) { return underlyingResource . isAccessible ( ) ; } public void save ( IProgressMonitor pm , boolean force ) throws JavaModelException { if ( isReadOnly ( ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . READ_ONLY , this ) ) ; } IBuffer buf = getBuffer ( ) ; if ( buf != null ) { buf . save ( pm , force ) ; makeConsistent ( pm ) ; } } public PackageFragmentRoot getPackageFragmentRoot ( ) { return ( PackageFragmentRoot ) getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; } abstract protected IStatus validateExistence ( IResource underlyingResource ) ; protected void openAncestors ( HashMap newElements , IProgressMonitor monitor ) throws JavaModelException { Openable openableParent = ( Openable ) getOpenableParent ( ) ; if ( openableParent != null && ! openableParent . isOpen ( ) ) { openableParent . generateInfos ( openableParent . createElementInfo ( ) , newElements , monitor ) ; } } } </s>
<s> package org . eclipse . jdt . internal . core ; public class ResolvedBinaryField extends BinaryField { private String uniqueKey ; public ResolvedBinaryField ( JavaElement parent , String name , String uniqueKey ) { super ( parent , name ) ; this . uniqueKey = uniqueKey ; } public String getKey ( ) { return this . uniqueKey ; } public boolean isResolved ( ) { return true ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { super . toStringInfo ( tab , buffer , info , showResolvedInfo ) ; if ( showResolvedInfo ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . uniqueKey ) ; buffer . append ( "<STR_LIT:}>" ) ; } } public JavaElement unresolved ( ) { SourceRefElement handle = new BinaryField ( this . parent , this . name ) ; handle . occurrenceCount = this . occurrenceCount ; return handle ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . IBinaryMethod ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToIntArray ; import org . eclipse . jdt . internal . core . util . Util ; public class JavadocContents { private static final int [ ] UNKNOWN_FORMAT = new int [ <NUM_LIT:0> ] ; private BinaryType type ; private char [ ] content ; private int childrenStart ; private boolean hasComputedChildrenSections = false ; private int indexOfFieldDetails ; private int indexOfConstructorDetails ; private int indexOfMethodDetails ; private int indexOfEndOfClassData ; private int indexOfFieldsBottom ; private int indexOfAllMethodsTop ; private int indexOfAllMethodsBottom ; private int [ ] typeDocRange ; private HashtableOfObjectToIntArray fieldDocRanges ; private HashtableOfObjectToIntArray methodDocRanges ; private int [ ] fieldAnchorIndexes ; private int fieldAnchorIndexesCount ; private int fieldLastAnchorFoundIndex ; private int [ ] methodAnchorIndexes ; private int methodAnchorIndexesCount ; private int methodLastAnchorFoundIndex ; private int [ ] unknownFormatAnchorIndexes ; private int unknownFormatAnchorIndexesCount ; private int unknownFormatLastAnchorFoundIndex ; private int [ ] tempAnchorIndexes ; private int tempAnchorIndexesCount ; private int tempLastAnchorFoundIndex ; public JavadocContents ( BinaryType type , String content ) { this . type = type ; this . content = content != null ? content . toCharArray ( ) : null ; } public String getTypeDoc ( ) throws JavaModelException { if ( this . content == null ) return null ; synchronized ( this ) { if ( this . typeDocRange == null ) { computeTypeRange ( ) ; } } if ( this . typeDocRange != null ) { if ( this . typeDocRange == UNKNOWN_FORMAT ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , this . type ) ) ; return String . valueOf ( CharOperation . subarray ( this . content , this . typeDocRange [ <NUM_LIT:0> ] , this . typeDocRange [ <NUM_LIT:1> ] ) ) ; } return null ; } public String getFieldDoc ( IField child ) throws JavaModelException { if ( this . content == null ) return null ; int [ ] range = null ; synchronized ( this ) { if ( this . fieldDocRanges == null ) { this . fieldDocRanges = new HashtableOfObjectToIntArray ( ) ; } else { range = this . fieldDocRanges . get ( child ) ; } if ( range == null ) { range = computeFieldRange ( child ) ; this . fieldDocRanges . put ( child , range ) ; } } if ( range != null ) { if ( range == UNKNOWN_FORMAT ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , child ) ) ; return String . valueOf ( CharOperation . subarray ( this . content , range [ <NUM_LIT:0> ] , range [ <NUM_LIT:1> ] ) ) ; } return null ; } public String getMethodDoc ( IMethod child ) throws JavaModelException { if ( this . content == null ) return null ; int [ ] range = null ; synchronized ( this ) { if ( this . methodDocRanges == null ) { this . methodDocRanges = new HashtableOfObjectToIntArray ( ) ; } else { range = this . methodDocRanges . get ( child ) ; } if ( range == null ) { range = computeMethodRange ( child ) ; this . methodDocRanges . put ( child , range ) ; } } if ( range != null ) { if ( range == UNKNOWN_FORMAT ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , child ) ) ; return String . valueOf ( CharOperation . subarray ( this . content , range [ <NUM_LIT:0> ] , range [ <NUM_LIT:1> ] ) ) ; } return null ; } private int [ ] computeChildRange ( char [ ] anchor , int indexOfSectionBottom ) throws JavaModelException { if ( this . tempAnchorIndexesCount > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < this . tempAnchorIndexesCount ; i ++ ) { int anchorEndStart = this . tempAnchorIndexes [ i ] ; if ( anchorEndStart != - <NUM_LIT:1> && CharOperation . prefixEquals ( anchor , this . content , false , anchorEndStart ) ) { this . tempAnchorIndexes [ i ] = - <NUM_LIT:1> ; return computeChildRange ( anchorEndStart , anchor , indexOfSectionBottom ) ; } } } int fromIndex = this . tempLastAnchorFoundIndex ; int index ; while ( ( index = CharOperation . indexOf ( JavadocConstants . ANCHOR_PREFIX_START , this . content , false , fromIndex ) ) != - <NUM_LIT:1> && ( index < indexOfSectionBottom || indexOfSectionBottom == - <NUM_LIT:1> ) ) { fromIndex = index + <NUM_LIT:1> ; int anchorEndStart = index + JavadocConstants . ANCHOR_PREFIX_START_LENGHT ; this . tempLastAnchorFoundIndex = anchorEndStart ; if ( CharOperation . prefixEquals ( anchor , this . content , false , anchorEndStart ) ) { return computeChildRange ( anchorEndStart , anchor , indexOfSectionBottom ) ; } else { if ( this . tempAnchorIndexes . length == this . tempAnchorIndexesCount ) { System . arraycopy ( this . tempAnchorIndexes , <NUM_LIT:0> , this . tempAnchorIndexes = new int [ this . tempAnchorIndexesCount + <NUM_LIT:20> ] , <NUM_LIT:0> , this . tempAnchorIndexesCount ) ; } this . tempAnchorIndexes [ this . tempAnchorIndexesCount ++ ] = anchorEndStart ; } } return null ; } private int [ ] computeChildRange ( int anchorEndStart , char [ ] anchor , int indexOfBottom ) { int [ ] range = null ; if ( indexOfBottom != - <NUM_LIT:1> ) { int indexOfEndLink = CharOperation . indexOf ( JavadocConstants . ANCHOR_SUFFIX , this . content , false , anchorEndStart + anchor . length ) ; if ( indexOfEndLink != - <NUM_LIT:1> ) { int indexOfNextElement = CharOperation . indexOf ( JavadocConstants . ANCHOR_PREFIX_START , this . content , false , indexOfEndLink ) ; int javadocStart = indexOfEndLink + JavadocConstants . ANCHOR_SUFFIX_LENGTH ; int javadocEnd = indexOfNextElement == - <NUM_LIT:1> ? indexOfBottom : Math . min ( indexOfNextElement , indexOfBottom ) ; range = new int [ ] { javadocStart , javadocEnd } ; } else { range = UNKNOWN_FORMAT ; } } else { range = UNKNOWN_FORMAT ; } return range ; } private void computeChildrenSections ( ) { int lastIndex = CharOperation . indexOf ( JavadocConstants . SEPARATOR_START , this . content , false , this . childrenStart ) ; lastIndex = lastIndex == - <NUM_LIT:1> ? this . childrenStart : lastIndex ; this . indexOfFieldDetails = CharOperation . indexOf ( JavadocConstants . FIELD_DETAIL , this . content , false , lastIndex ) ; lastIndex = this . indexOfFieldDetails == - <NUM_LIT:1> ? lastIndex : this . indexOfFieldDetails ; this . indexOfConstructorDetails = CharOperation . indexOf ( JavadocConstants . CONSTRUCTOR_DETAIL , this . content , false , lastIndex ) ; lastIndex = this . indexOfConstructorDetails == - <NUM_LIT:1> ? lastIndex : this . indexOfConstructorDetails ; this . indexOfMethodDetails = CharOperation . indexOf ( JavadocConstants . METHOD_DETAIL , this . content , false , lastIndex ) ; lastIndex = this . indexOfMethodDetails == - <NUM_LIT:1> ? lastIndex : this . indexOfMethodDetails ; this . indexOfEndOfClassData = CharOperation . indexOf ( JavadocConstants . END_OF_CLASS_DATA , this . content , false , lastIndex ) ; this . indexOfFieldsBottom = this . indexOfConstructorDetails != - <NUM_LIT:1> ? this . indexOfConstructorDetails : this . indexOfMethodDetails != - <NUM_LIT:1> ? this . indexOfMethodDetails : this . indexOfEndOfClassData ; this . indexOfAllMethodsTop = this . indexOfConstructorDetails != - <NUM_LIT:1> ? this . indexOfConstructorDetails : this . indexOfMethodDetails ; this . indexOfAllMethodsBottom = this . indexOfEndOfClassData ; this . hasComputedChildrenSections = true ; } private int [ ] computeFieldRange ( IField field ) throws JavaModelException { if ( ! this . hasComputedChildrenSections ) { computeChildrenSections ( ) ; } StringBuffer buffer = new StringBuffer ( field . getElementName ( ) ) ; buffer . append ( JavadocConstants . ANCHOR_PREFIX_END ) ; char [ ] anchor = String . valueOf ( buffer ) . toCharArray ( ) ; int [ ] range = null ; if ( this . indexOfFieldDetails == - <NUM_LIT:1> || this . indexOfFieldsBottom == - <NUM_LIT:1> ) { if ( this . unknownFormatAnchorIndexes == null ) { this . unknownFormatAnchorIndexes = new int [ this . type . getChildren ( ) . length ] ; this . unknownFormatAnchorIndexesCount = <NUM_LIT:0> ; this . unknownFormatLastAnchorFoundIndex = this . childrenStart ; } this . tempAnchorIndexes = this . unknownFormatAnchorIndexes ; this . tempAnchorIndexesCount = this . unknownFormatAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . unknownFormatLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfFieldsBottom ) ; this . unknownFormatLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . unknownFormatAnchorIndexesCount = this . tempAnchorIndexesCount ; this . unknownFormatAnchorIndexes = this . tempAnchorIndexes ; } else { if ( this . fieldAnchorIndexes == null ) { this . fieldAnchorIndexes = new int [ this . type . getFields ( ) . length ] ; this . fieldAnchorIndexesCount = <NUM_LIT:0> ; this . fieldLastAnchorFoundIndex = this . indexOfFieldDetails ; } this . tempAnchorIndexes = this . fieldAnchorIndexes ; this . tempAnchorIndexesCount = this . fieldAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . fieldLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfFieldsBottom ) ; this . fieldLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . fieldAnchorIndexesCount = this . tempAnchorIndexesCount ; this . fieldAnchorIndexes = this . tempAnchorIndexes ; } return range ; } private int [ ] computeMethodRange ( IMethod method ) throws JavaModelException { if ( ! this . hasComputedChildrenSections ) { computeChildrenSections ( ) ; } char [ ] anchor = computeMethodAnchorPrefixEnd ( ( BinaryMethod ) method ) . toCharArray ( ) ; int [ ] range = null ; if ( this . indexOfAllMethodsTop == - <NUM_LIT:1> || this . indexOfAllMethodsBottom == - <NUM_LIT:1> ) { if ( this . unknownFormatAnchorIndexes == null ) { this . unknownFormatAnchorIndexes = new int [ this . type . getChildren ( ) . length ] ; this . unknownFormatAnchorIndexesCount = <NUM_LIT:0> ; this . unknownFormatLastAnchorFoundIndex = this . childrenStart ; } this . tempAnchorIndexes = this . unknownFormatAnchorIndexes ; this . tempAnchorIndexesCount = this . unknownFormatAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . unknownFormatLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfFieldsBottom ) ; this . unknownFormatLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . unknownFormatAnchorIndexesCount = this . tempAnchorIndexesCount ; this . unknownFormatAnchorIndexes = this . tempAnchorIndexes ; } else { if ( this . methodAnchorIndexes == null ) { this . methodAnchorIndexes = new int [ this . type . getFields ( ) . length ] ; this . methodAnchorIndexesCount = <NUM_LIT:0> ; this . methodLastAnchorFoundIndex = this . indexOfAllMethodsTop ; } this . tempAnchorIndexes = this . methodAnchorIndexes ; this . tempAnchorIndexesCount = this . methodAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . methodLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfAllMethodsBottom ) ; this . methodLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . methodAnchorIndexesCount = this . tempAnchorIndexesCount ; this . methodAnchorIndexes = this . tempAnchorIndexes ; } return range ; } private String computeMethodAnchorPrefixEnd ( BinaryMethod method ) throws JavaModelException { String typeQualifiedName = null ; if ( this . type . isMember ( ) ) { IType currentType = this . type ; StringBuffer buffer = new StringBuffer ( ) ; while ( currentType != null ) { buffer . insert ( <NUM_LIT:0> , currentType . getElementName ( ) ) ; currentType = currentType . getDeclaringType ( ) ; if ( currentType != null ) { buffer . insert ( <NUM_LIT:0> , '<CHAR_LIT:.>' ) ; } } typeQualifiedName = new String ( buffer . toString ( ) ) ; } else { typeQualifiedName = this . type . getElementName ( ) ; } String methodName = method . getElementName ( ) ; if ( method . isConstructor ( ) ) { methodName = typeQualifiedName ; } IBinaryMethod info = ( IBinaryMethod ) method . getElementInfo ( ) ; char [ ] genericSignature = info . getGenericSignature ( ) ; String anchor = null ; if ( genericSignature != null ) { genericSignature = CharOperation . replaceOnCopy ( genericSignature , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; anchor = Util . toAnchor ( <NUM_LIT:0> , genericSignature , methodName , Flags . isVarargs ( method . getFlags ( ) ) ) ; if ( anchor == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , method ) ) ; } else { anchor = Signature . toString ( method . getSignature ( ) . replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) , methodName , null , true , false , Flags . isVarargs ( method . getFlags ( ) ) ) ; } IType declaringType = this . type ; if ( declaringType . isMember ( ) ) { if ( ! Flags . isStatic ( declaringType . getFlags ( ) ) ) { int indexOfOpeningParen = anchor . indexOf ( '<CHAR_LIT:(>' ) ; if ( indexOfOpeningParen == - <NUM_LIT:1> ) return null ; int index = indexOfOpeningParen ; indexOfOpeningParen ++ ; int indexOfComma = anchor . indexOf ( '<CHAR_LIT:U+002C>' , index ) ; if ( indexOfComma != - <NUM_LIT:1> ) { index = indexOfComma + <NUM_LIT:2> ; } else { index = anchor . indexOf ( '<CHAR_LIT:)>' , index ) ; } anchor = anchor . substring ( <NUM_LIT:0> , indexOfOpeningParen ) + anchor . substring ( index ) ; } } return anchor + JavadocConstants . ANCHOR_PREFIX_END ; } private void computeTypeRange ( ) throws JavaModelException { final int indexOfStartOfClassData = CharOperation . indexOf ( JavadocConstants . START_OF_CLASS_DATA , this . content , false ) ; if ( indexOfStartOfClassData == - <NUM_LIT:1> ) { this . typeDocRange = UNKNOWN_FORMAT ; return ; } int indexOfNextSeparator = CharOperation . indexOf ( JavadocConstants . SEPARATOR_START , this . content , false , indexOfStartOfClassData ) ; if ( indexOfNextSeparator == - <NUM_LIT:1> ) { this . typeDocRange = UNKNOWN_FORMAT ; return ; } int indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . NESTED_CLASS_SUMMARY , this . content , false , indexOfNextSeparator ) ; if ( indexOfNextSummary == - <NUM_LIT:1> && this . type . isEnum ( ) ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . ENUM_CONSTANT_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> && this . type . isAnnotation ( ) ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY , this . content , false , indexOfNextSeparator ) ; if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY , this . content , false , indexOfNextSeparator ) ; } } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . FIELD_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . CONSTRUCTOR_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . METHOD_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . END_OF_CLASS_DATA , this . content , false , indexOfNextSeparator ) ; } else { this . childrenStart = indexOfNextSummary + <NUM_LIT:1> ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { this . typeDocRange = UNKNOWN_FORMAT ; return ; } int start = indexOfStartOfClassData + JavadocConstants . START_OF_CLASS_DATA_LENGTH ; int indexOfFirstParagraph = CharOperation . indexOf ( "<STR_LIT>" . toCharArray ( ) , this . content , false , start ) ; if ( indexOfFirstParagraph != - <NUM_LIT:1> && indexOfFirstParagraph < indexOfNextSummary ) { start = indexOfFirstParagraph ; } this . typeDocRange = new int [ ] { start , indexOfNextSummary } ; } } </s>
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . BindingKey ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . ISelectionRequestor ; import org . eclipse . jdt . internal . codeassist . SelectionEngine ; public abstract class NamedMember extends Member { protected String name ; public NamedMember ( JavaElement parent , String name ) { super ( parent ) ; this . name = name ; } private void appendTypeParameters ( StringBuffer buffer ) throws JavaModelException { ITypeParameter [ ] typeParameters = getTypeParameters ( ) ; int length = typeParameters . length ; if ( length == <NUM_LIT:0> ) return ; buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; buffer . append ( typeParameter . getElementName ( ) ) ; String [ ] bounds = typeParameter . getBounds ( ) ; int boundsLength = bounds . length ; if ( boundsLength > <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; for ( int j = <NUM_LIT:0> ; j < boundsLength ; j ++ ) { buffer . append ( bounds [ j ] ) ; if ( j < boundsLength - <NUM_LIT:1> ) buffer . append ( "<STR_LIT>" ) ; } } if ( i < length - <NUM_LIT:1> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } public String getElementName ( ) { return this . name ; } protected String getKey ( IField field , boolean forceOpen ) throws JavaModelException { StringBuffer key = new StringBuffer ( ) ; String declaringKey = getKey ( ( IType ) field . getParent ( ) , forceOpen ) ; key . append ( declaringKey ) ; key . append ( '<CHAR_LIT:.>' ) ; key . append ( field . getElementName ( ) ) ; return key . toString ( ) ; } protected String getKey ( IMethod method , boolean forceOpen ) throws JavaModelException { StringBuffer key = new StringBuffer ( ) ; String declaringKey = getKey ( ( IType ) method . getParent ( ) , forceOpen ) ; key . append ( declaringKey ) ; key . append ( '<CHAR_LIT:.>' ) ; String selector = method . getElementName ( ) ; key . append ( selector ) ; if ( forceOpen ) { ITypeParameter [ ] typeParameters = method . getTypeParameters ( ) ; int length = typeParameters . length ; if ( length > <NUM_LIT:0> ) { key . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; String [ ] bounds = typeParameter . getBounds ( ) ; int boundsLength = bounds . length ; char [ ] [ ] boundSignatures = new char [ boundsLength ] [ ] ; for ( int j = <NUM_LIT:0> ; j < boundsLength ; j ++ ) { boundSignatures [ j ] = Signature . createCharArrayTypeSignature ( bounds [ j ] . toCharArray ( ) , method . isBinary ( ) ) ; CharOperation . replace ( boundSignatures [ j ] , '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ; } char [ ] sig = Signature . createTypeParameterSignature ( typeParameter . getElementName ( ) . toCharArray ( ) , boundSignatures ) ; key . append ( sig ) ; } key . append ( '<CHAR_LIT:>>' ) ; } } key . append ( '<CHAR_LIT:(>' ) ; String [ ] parameters = method . getParameterTypes ( ) ; for ( int i = <NUM_LIT:0> , length = parameters . length ; i < length ; i ++ ) key . append ( parameters [ i ] . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ) ; key . append ( '<CHAR_LIT:)>' ) ; if ( forceOpen ) key . append ( method . getReturnType ( ) . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ) ; else key . append ( '<CHAR_LIT>' ) ; return key . toString ( ) ; } protected String getKey ( IType type , boolean forceOpen ) throws JavaModelException { StringBuffer key = new StringBuffer ( ) ; key . append ( '<CHAR_LIT>' ) ; String packageName = type . getPackageFragment ( ) . getElementName ( ) ; key . append ( packageName . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ) ; if ( packageName . length ( ) > <NUM_LIT:0> ) key . append ( '<CHAR_LIT:/>' ) ; String typeQualifiedName = type . getTypeQualifiedName ( '<CHAR_LIT>' ) ; ICompilationUnit cu = ( ICompilationUnit ) type . getAncestor ( IJavaElement . COMPILATION_UNIT ) ; if ( cu != null ) { String cuName = cu . getElementName ( ) ; String mainTypeName = cuName . substring ( <NUM_LIT:0> , cuName . lastIndexOf ( '<CHAR_LIT:.>' ) ) ; int end = typeQualifiedName . indexOf ( '<CHAR_LIT>' ) ; if ( end == - <NUM_LIT:1> ) end = typeQualifiedName . length ( ) ; String topLevelTypeName = typeQualifiedName . substring ( <NUM_LIT:0> , end ) ; if ( ! mainTypeName . equals ( topLevelTypeName ) ) { key . append ( mainTypeName ) ; key . append ( '<CHAR_LIT>' ) ; } } key . append ( typeQualifiedName ) ; key . append ( '<CHAR_LIT:;>' ) ; return key . toString ( ) ; } protected String getFullyQualifiedParameterizedName ( String fullyQualifiedName , String uniqueKey ) throws JavaModelException { String [ ] typeArguments = new BindingKey ( uniqueKey ) . getTypeArguments ( ) ; int length = typeArguments . length ; if ( length == <NUM_LIT:0> ) return fullyQualifiedName ; StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( fullyQualifiedName ) ; buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { String typeArgument = typeArguments [ i ] ; buffer . append ( Signature . toString ( typeArgument ) ) ; if ( i < length - <NUM_LIT:1> ) buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; return buffer . toString ( ) ; } protected IPackageFragment getPackageFragment ( ) { return null ; } public String getFullyQualifiedName ( char enclosingTypeSeparator , boolean showParameters ) throws JavaModelException { String packageName = getPackageFragment ( ) . getElementName ( ) ; if ( packageName . equals ( IPackageFragment . DEFAULT_PACKAGE_NAME ) ) { return getTypeQualifiedName ( enclosingTypeSeparator , showParameters ) ; } return packageName + '<CHAR_LIT:.>' + getTypeQualifiedName ( enclosingTypeSeparator , showParameters ) ; } public String getTypeQualifiedName ( char enclosingTypeSeparator , boolean showParameters ) throws JavaModelException { NamedMember declaringType ; switch ( this . parent . getElementType ( ) ) { case IJavaElement . COMPILATION_UNIT : if ( showParameters ) { StringBuffer buffer = new StringBuffer ( this . name ) ; appendTypeParameters ( buffer ) ; return buffer . toString ( ) ; } return this . name ; case IJavaElement . CLASS_FILE : String classFileName = this . parent . getElementName ( ) ; String typeName ; if ( classFileName . indexOf ( '<CHAR_LIT>' ) == - <NUM_LIT:1> ) { typeName = this . name ; } else { typeName = classFileName . substring ( <NUM_LIT:0> , classFileName . lastIndexOf ( '<CHAR_LIT:.>' ) ) . replace ( '<CHAR_LIT>' , enclosingTypeSeparator ) ; } if ( showParameters ) { StringBuffer buffer = new StringBuffer ( typeName ) ; appendTypeParameters ( buffer ) ; return buffer . toString ( ) ; } return typeName ; case IJavaElement . TYPE : declaringType = ( NamedMember ) this . parent ; break ; case IJavaElement . FIELD : case IJavaElement . INITIALIZER : case IJavaElement . METHOD : declaringType = ( NamedMember ) ( ( IMember ) this . parent ) . getDeclaringType ( ) ; break ; default : return null ; } StringBuffer buffer = new StringBuffer ( declaringType . getTypeQualifiedName ( enclosingTypeSeparator , showParameters ) ) ; buffer . append ( enclosingTypeSeparator ) ; String simpleName = this . name . length ( ) == <NUM_LIT:0> ? Integer . toString ( this . occurrenceCount ) : this . name ; buffer . append ( simpleName ) ; if ( showParameters ) { appendTypeParameters ( buffer ) ; } return buffer . toString ( ) ; } protected ITypeParameter [ ] getTypeParameters ( ) throws JavaModelException { return null ; } public String [ ] [ ] resolveType ( String typeName ) throws JavaModelException { return resolveType ( typeName , DefaultWorkingCopyOwner . PRIMARY ) ; } public String [ ] [ ] resolveType ( String typeName , WorkingCopyOwner owner ) throws JavaModelException { JavaProject project = ( JavaProject ) getJavaProject ( ) ; SearchableEnvironment environment = project . newSearchableNameEnvironment ( owner ) ; class TypeResolveRequestor implements ISelectionRequestor { String [ ] [ ] answers = null ; public void acceptType ( char [ ] packageName , char [ ] tName , int modifiers , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { String [ ] answer = new String [ ] { new String ( packageName ) , new String ( tName ) } ; if ( this . answers == null ) { this . answers = new String [ ] [ ] { answer } ; } else { int length = this . answers . length ; System . arraycopy ( this . answers , <NUM_LIT:0> , this . answers = new String [ length + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , length ) ; this . answers [ length ] = answer ; } } public void acceptError ( CategorizedProblem error ) { } public void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] fieldName , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { } public void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , String enclosingDeclaringTypeSignature , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , String [ ] parameterSignatures , char [ ] [ ] typeParameterNames , char [ ] [ ] [ ] typeParameterBoundNames , boolean isConstructor , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { } public void acceptPackage ( char [ ] packageName ) { } public void acceptTypeParameter ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] typeParameterName , boolean isDeclaration , int start , int end ) { } public void acceptMethodTypeParameter ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , int selectorStart , int selcetorEnd , char [ ] typeParameterName , boolean isDeclaration , int start , int end ) { } } TypeResolveRequestor requestor = new TypeResolveRequestor ( ) ; SelectionEngine engine = new SelectionEngine ( environment , requestor , project . getOptions ( true ) , owner ) ; engine . selectType ( typeName . toCharArray ( ) , ( IType ) this ) ; if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } return requestor . answers ; } } </s>
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; public interface IDocumentElementRequestor { void acceptImport ( int declarationStart , int declarationEnd , int [ ] javaDocPositions , char [ ] name , int nameStartPosition , boolean onDemand , int modifiers ) ; void acceptInitializer ( int declarationStart , int declarationEnd , int [ ] javaDocPositions , int modifiers , int modifiersStart , int bodyStart , int bodyEnd ) ; void acceptLineSeparatorPositions ( int [ ] positions ) ; void acceptPackage ( int declarationStart , int declarationEnd , int [ ] javaDocPositions , char [ ] name , int nameStartPosition ) ; void acceptProblem ( CategorizedProblem problem ) ; void enterClass ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , int classStart , char [ ] name , int nameStart , int nameEnd , char [ ] superclass , int superclassStart , int superclassEnd , char [ ] [ ] superinterfaces , int [ ] superinterfaceStarts , int [ ] superinterfaceEnds , int bodyStart ) ; void enterCompilationUnit ( ) ; void enterConstructor ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , char [ ] name , int nameStart , int nameEnd , char [ ] [ ] parameterTypes , int [ ] parameterTypeStarts , int [ ] parameterTypeEnds , char [ ] [ ] parameterNames , int [ ] parameterNameStarts , int [ ] parameterNameEnds , int parametersEnd , char [ ] [ ] exceptionTypes , int [ ] exceptionTypeStarts , int [ ] exceptionTypeEnds , int bodyStart ) ; void enterField ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , char [ ] type , int typeStart , int typeEnd , int typeDimensionCount , char [ ] name , int nameStart , int nameEnd , int extendedTypeDimensionCount , int extendedTypeDimensionEnd ) ; void enterInterface ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , int interfaceStart , char [ ] name , int nameStart , int nameEnd , char [ ] [ ] superinterfaces , int [ ] superinterfaceStarts , int [ ] superinterfaceEnds , int bodyStart ) ; void enterMethod ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , char [ ] returnType , int returnTypeStart , int returnTypeEnd , int returnTypeDimensionCount , char [ ] name , int nameStart , int nameEnd , char [ ] [ ] parameterTypes , int [ ] parameterTypeStarts , int [ ] parameterTypeEnds , char [ ] [ ] parameterNames , int [ ] parameterNameStarts , int [ ] parameterNameEnds , int parametersEnd , int extendedReturnTypeDimensionCount , int extendedReturnTypeDimensionEnd , char [ ] [ ] exceptionTypes , int [ ] exceptionTypeStarts , int [ ] exceptionTypeEnds , int bodyStart ) ; void exitClass ( int bodyEnd , int declarationEnd ) ; void exitCompilationUnit ( int declarationEnd ) ; void exitConstructor ( int bodyEnd , int declarationEnd ) ; void exitField ( int bodyEnd , int declarationEnd ) ; void exitInterface ( int bodyEnd , int declarationEnd ) ; void exitMethod ( int bodyEnd , int declarationEnd ) ; } </s>
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . parser . JavadocParser ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class SourceJavadocParser extends JavadocParser { int categoriesPtr = - <NUM_LIT:1> ; char [ ] [ ] categories = CharOperation . NO_CHAR_CHAR ; public SourceJavadocParser ( Parser sourceParser ) { super ( sourceParser ) ; this . kind = SOURCE_PARSER | TEXT_VERIF ; } public boolean checkDeprecation ( int commentPtr ) { this . categoriesPtr = - <NUM_LIT:1> ; boolean result = super . checkDeprecation ( commentPtr ) ; if ( this . categoriesPtr > - <NUM_LIT:1> ) { System . arraycopy ( this . categories , <NUM_LIT:0> , this . categories = new char [ this . categoriesPtr + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , this . categoriesPtr + <NUM_LIT:1> ) ; } else { this . categories = CharOperation . NO_CHAR_CHAR ; } return result ; } protected boolean parseIdentifierTag ( boolean report ) { int end = this . lineEnd + <NUM_LIT:1> ; if ( super . parseIdentifierTag ( report ) && this . index <= end ) { if ( this . tagValue == TAG_CATEGORY_VALUE ) { int length = this . categories . length ; if ( ++ this . categoriesPtr >= length ) { System . arraycopy ( this . categories , <NUM_LIT:0> , this . categories = new char [ length + <NUM_LIT:5> ] [ ] , <NUM_LIT:0> , length ) ; length += <NUM_LIT:5> ; } this . categories [ this . categoriesPtr ] = this . identifierStack [ this . identifierPtr -- ] ; consumeToken ( ) ; while ( this . index < end ) { if ( readTokenSafely ( ) == TerminalTokens . TokenNameIdentifier && ( this . scanner . currentCharacter == '<CHAR_LIT:U+0020>' || ScannerHelper . isWhitespace ( this . scanner . currentCharacter ) ) ) { if ( this . index > ( this . lineEnd + <NUM_LIT:1> ) ) break ; if ( ++ this . categoriesPtr >= length ) { System . arraycopy ( this . categories , <NUM_LIT:0> , this . categories = new char [ length + <NUM_LIT:5> ] [ ] , <NUM_LIT:0> , length ) ; length += <NUM_LIT:5> ; } this . categories [ this . categoriesPtr ] = this . scanner . getCurrentIdentifierSource ( ) ; consumeToken ( ) ; } else { break ; } } this . index = end ; this . scanner . currentPosition = end ; consumeToken ( ) ; } return true ; } return false ; } protected void parseSimpleTag ( ) { char first = this . source [ this . index ++ ] ; if ( first == '<STR_LIT:\\>' && this . source [ this . index ] == '<CHAR_LIT>' ) { int c1 , c2 , c3 , c4 ; int pos = this . index ; this . index ++ ; while ( this . source [ this . index ] == '<CHAR_LIT>' ) this . index ++ ; if ( ! ( ( ( c1 = ScannerHelper . getNumericValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c1 < <NUM_LIT:0> ) || ( ( c2 = ScannerHelper . getNumericValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c2 < <NUM_LIT:0> ) || ( ( c3 = ScannerHelper . getNumericValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c3 < <NUM_LIT:0> ) || ( ( c4 = ScannerHelper . getNumericValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c4 < <NUM_LIT:0> ) ) ) { first = ( char ) ( ( ( c1 * <NUM_LIT:16> + c2 ) * <NUM_LIT:16> + c3 ) * <NUM_LIT:16> + c4 ) ; } else { this . index = pos ; } } switch ( first ) { case '<CHAR_LIT>' : if ( ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT:c>' ) && ( readChar ( ) == '<CHAR_LIT:a>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT>' ) ) { char c = readChar ( ) ; if ( ScannerHelper . isWhitespace ( c ) || c == '<CHAR_LIT>' ) { this . tagValue = TAG_DEPRECATED_VALUE ; this . deprecated = true ; } } break ; case '<CHAR_LIT:c>' : if ( ( readChar ( ) == '<CHAR_LIT:a>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) ) { char c = readChar ( ) ; if ( ScannerHelper . isWhitespace ( c ) || c == '<CHAR_LIT>' ) { this . tagValue = TAG_CATEGORY_VALUE ; if ( this . scanner . source == null ) { this . scanner . setSource ( this . source ) ; } this . scanner . resetTo ( this . index , this . scanner . eofPosition ) ; parseIdentifierTag ( false ) ; } } break ; } } } </s>
<s> package org . eclipse . jdt . internal . compiler ; import java . util . HashMap ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . impl . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . core . util . CommentRecorderParser ; import org . eclipse . jdt . internal . core . util . Messages ; public class SourceElementParser extends CommentRecorderParser { ISourceElementRequestor requestor ; boolean reportReferenceInfo ; boolean reportLocalDeclarations ; HashtableOfObjectToInt sourceEnds = new HashtableOfObjectToInt ( ) ; HashMap nodesToCategories = new HashMap ( ) ; boolean useSourceJavadocParser = true ; SourceElementNotifier notifier ; public SourceElementParser ( final ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals ) { this ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , true ) ; } public SourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { super ( new ProblemReporter ( DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , options , problemFactory ) , optimizeStringLiterals ) ; this . reportLocalDeclarations = reportLocalDeclarations ; this . problemReporter = new ProblemReporter ( DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , options , problemFactory ) { public void record ( CategorizedProblem problem , CompilationResult unitResult , ReferenceContext context ) { unitResult . record ( problem , context ) ; SourceElementParser . this . requestor . acceptProblem ( problem ) ; } } ; this . requestor = requestor ; this . options = options ; this . notifier = new SourceElementNotifier ( this . requestor , reportLocalDeclarations ) ; this . useSourceJavadocParser = useSourceJavadocParser ; if ( useSourceJavadocParser ) { this . javadocParser = new SourceJavadocParser ( this ) ; } } private void acceptJavadocTypeReference ( Expression expression ) { if ( expression instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference singleRef = ( JavadocSingleTypeReference ) expression ; this . requestor . acceptTypeReference ( singleRef . token , singleRef . sourceStart ) ; } else if ( expression instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference qualifiedRef = ( JavadocQualifiedTypeReference ) expression ; this . requestor . acceptTypeReference ( qualifiedRef . tokens , qualifiedRef . sourceStart , qualifiedRef . sourceEnd ) ; } } public void addUnknownRef ( NameReference nameRef ) { if ( nameRef instanceof SingleNameReference ) { this . requestor . acceptUnknownReference ( ( ( SingleNameReference ) nameRef ) . token , nameRef . sourceStart ) ; } else { this . requestor . acceptUnknownReference ( ( ( QualifiedNameReference ) nameRef ) . tokens , nameRef . sourceStart , nameRef . sourceEnd ) ; } } public void checkComment ( ) { if ( ! ( this . diet && this . dietInt == <NUM_LIT:0> ) && this . scanner . commentPtr >= <NUM_LIT:0> ) { flushCommentsDefinedPriorTo ( this . endStatementPosition ) ; } int lastComment = this . scanner . commentPtr ; if ( this . modifiersSourceStart >= <NUM_LIT:0> ) { while ( lastComment >= <NUM_LIT:0> ) { int commentSourceStart = this . scanner . commentStarts [ lastComment ] ; if ( commentSourceStart < <NUM_LIT:0> ) commentSourceStart = - commentSourceStart ; if ( commentSourceStart <= this . modifiersSourceStart ) break ; lastComment -- ; } } if ( lastComment >= <NUM_LIT:0> ) { this . modifiersSourceStart = this . scanner . commentStarts [ <NUM_LIT:0> ] ; if ( this . modifiersSourceStart < <NUM_LIT:0> ) this . modifiersSourceStart = - this . modifiersSourceStart ; while ( lastComment >= <NUM_LIT:0> && this . scanner . commentStops [ lastComment ] < <NUM_LIT:0> ) lastComment -- ; if ( lastComment >= <NUM_LIT:0> && this . javadocParser != null ) { int commentEnd = this . scanner . commentStops [ lastComment ] - <NUM_LIT:1> ; if ( this . javadocParser . shouldReportProblems ) { this . javadocParser . reportProblems = this . currentElement == null || commentEnd > this . lastJavadocEnd ; } else { this . javadocParser . reportProblems = false ; } if ( this . javadocParser . checkDeprecation ( lastComment ) ) { checkAndSetModifiers ( ClassFileConstants . AccDeprecated ) ; } this . javadoc = this . javadocParser . docComment ; if ( this . currentElement == null ) this . lastJavadocEnd = commentEnd ; } } if ( this . reportReferenceInfo && this . javadocParser . checkDocComment && this . javadoc != null ) { TypeReference [ ] thrownExceptions = this . javadoc . exceptionReferences ; if ( thrownExceptions != null ) { for ( int i = <NUM_LIT:0> , max = thrownExceptions . length ; i < max ; i ++ ) { TypeReference typeRef = thrownExceptions [ i ] ; if ( typeRef instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference singleRef = ( JavadocSingleTypeReference ) typeRef ; this . requestor . acceptTypeReference ( singleRef . token , singleRef . sourceStart ) ; } else if ( typeRef instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference qualifiedRef = ( JavadocQualifiedTypeReference ) typeRef ; this . requestor . acceptTypeReference ( qualifiedRef . tokens , qualifiedRef . sourceStart , qualifiedRef . sourceEnd ) ; } } } Expression [ ] references = this . javadoc . seeReferences ; if ( references != null ) { for ( int i = <NUM_LIT:0> , max = references . length ; i < max ; i ++ ) { Expression reference = references [ i ] ; acceptJavadocTypeReference ( reference ) ; if ( reference instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) reference ; this . requestor . acceptFieldReference ( fieldRef . token , fieldRef . sourceStart ) ; if ( fieldRef . receiver != null && ! fieldRef . receiver . isThis ( ) ) { acceptJavadocTypeReference ( fieldRef . receiver ) ; } } else if ( reference instanceof JavadocMessageSend ) { JavadocMessageSend messageSend = ( JavadocMessageSend ) reference ; int argCount = messageSend . arguments == null ? <NUM_LIT:0> : messageSend . arguments . length ; this . requestor . acceptMethodReference ( messageSend . selector , argCount , messageSend . sourceStart ) ; this . requestor . acceptConstructorReference ( messageSend . selector , argCount , messageSend . sourceStart ) ; if ( messageSend . receiver != null && ! messageSend . receiver . isThis ( ) ) { acceptJavadocTypeReference ( messageSend . receiver ) ; } } else if ( reference instanceof JavadocAllocationExpression ) { JavadocAllocationExpression constructor = ( JavadocAllocationExpression ) reference ; int argCount = constructor . arguments == null ? <NUM_LIT:0> : constructor . arguments . length ; if ( constructor . type != null ) { char [ ] [ ] compoundName = constructor . type . getParameterizedTypeName ( ) ; this . requestor . acceptConstructorReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] , argCount , constructor . sourceStart ) ; if ( ! constructor . type . isThis ( ) ) { acceptJavadocTypeReference ( constructor . type ) ; } } } } } } } protected void classInstanceCreation ( boolean alwaysQualified ) { boolean previousFlag = this . reportReferenceInfo ; this . reportReferenceInfo = false ; super . classInstanceCreation ( alwaysQualified ) ; this . reportReferenceInfo = previousFlag ; if ( this . reportReferenceInfo ) { AllocationExpression alloc = ( AllocationExpression ) this . expressionStack [ this . expressionPtr ] ; TypeReference typeRef = alloc . type ; this . requestor . acceptConstructorReference ( typeRef instanceof SingleTypeReference ? ( ( SingleTypeReference ) typeRef ) . token : CharOperation . concatWith ( alloc . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } protected void consumeAnnotationAsModifier ( ) { super . consumeAnnotationAsModifier ( ) ; Annotation annotation = ( Annotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptAnnotationTypeReference ( annotation . type . getTypeName ( ) , annotation . sourceStart , annotation . sourceEnd ) ; } } protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments ( ) { boolean previousFlag = this . reportReferenceInfo ; this . reportReferenceInfo = false ; super . consumeClassInstanceCreationExpressionQualifiedWithTypeArguments ( ) ; this . reportReferenceInfo = previousFlag ; if ( this . reportReferenceInfo ) { AllocationExpression alloc = ( AllocationExpression ) this . expressionStack [ this . expressionPtr ] ; TypeReference typeRef = alloc . type ; this . requestor . acceptConstructorReference ( typeRef instanceof SingleTypeReference ? ( ( SingleTypeReference ) typeRef ) . token : CharOperation . concatWith ( alloc . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } protected void consumeAnnotationTypeDeclarationHeaderName ( ) { int currentAstPtr = this . astPtr ; super . consumeAnnotationTypeDeclarationHeaderName ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters ( ) { int currentAstPtr = this . astPtr ; super . consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeCatchFormalParameter ( ) { super . consumeCatchFormalParameter ( ) ; flushCommentsDefinedPriorTo ( this . scanner . currentPosition ) ; } protected void consumeClassHeaderName1 ( ) { int currentAstPtr = this . astPtr ; super . consumeClassHeaderName1 ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeClassInstanceCreationExpressionWithTypeArguments ( ) { boolean previousFlag = this . reportReferenceInfo ; this . reportReferenceInfo = false ; super . consumeClassInstanceCreationExpressionWithTypeArguments ( ) ; this . reportReferenceInfo = previousFlag ; if ( this . reportReferenceInfo ) { AllocationExpression alloc = ( AllocationExpression ) this . expressionStack [ this . expressionPtr ] ; TypeReference typeRef = alloc . type ; this . requestor . acceptConstructorReference ( typeRef instanceof SingleTypeReference ? ( ( SingleTypeReference ) typeRef ) . token : CharOperation . concatWith ( alloc . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } protected void consumeConstructorHeaderName ( ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeConstructorHeaderName ( ) ; if ( this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } } protected void consumeConstructorHeaderNameWithTypeParameters ( ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeConstructorHeaderNameWithTypeParameters ( ) ; if ( this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } } protected void consumeEnumConstantWithClassBody ( ) { super . consumeEnumConstantWithClassBody ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeEnumConstantNoClassBody ( ) { super . consumeEnumConstantNoClassBody ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeEnumHeaderName ( ) { int currentAstPtr = this . astPtr ; super . consumeEnumHeaderName ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeEnumHeaderNameWithTypeParameters ( ) { int currentAstPtr = this . astPtr ; super . consumeEnumHeaderNameWithTypeParameters ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeExitVariableWithInitialization ( ) { super . consumeExitVariableWithInitialization ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeExitVariableWithoutInitialization ( ) { super . consumeExitVariableWithoutInitialization ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeFieldAccess ( boolean isSuperAccess ) { super . consumeFieldAccess ( isSuperAccess ) ; FieldReference fr = ( FieldReference ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptFieldReference ( fr . token , fr . sourceStart ) ; } } protected void consumeFormalParameter ( boolean isVarArgs ) { super . consumeFormalParameter ( isVarArgs ) ; flushCommentsDefinedPriorTo ( this . scanner . currentPosition ) ; } protected void consumeInterfaceHeaderName1 ( ) { int currentAstPtr = this . astPtr ; super . consumeInterfaceHeaderName1 ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeMemberValuePair ( ) { super . consumeMemberValuePair ( ) ; MemberValuePair memberValuepair = ( MemberValuePair ) this . astStack [ this . astPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( memberValuepair . name , <NUM_LIT:0> , memberValuepair . sourceStart ) ; } } protected void consumeMarkerAnnotation ( ) { super . consumeMarkerAnnotation ( ) ; Annotation annotation = ( Annotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptAnnotationTypeReference ( annotation . type . getTypeName ( ) , annotation . sourceStart , annotation . sourceEnd ) ; } } protected void consumeMethodHeaderName ( boolean isAnnotationMethod ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeMethodHeaderName ( isAnnotationMethod ) ; if ( this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } } protected void consumeMethodHeaderNameWithTypeParameters ( boolean isAnnotationMethod ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeMethodHeaderNameWithTypeParameters ( isAnnotationMethod ) ; if ( this . astPtr > currentAstPtr ) this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } protected void consumeMethodInvocationName ( ) { super . consumeMethodInvocationName ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationNameWithTypeArguments ( ) { super . consumeMethodInvocationNameWithTypeArguments ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationPrimary ( ) { super . consumeMethodInvocationPrimary ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationPrimaryWithTypeArguments ( ) { super . consumeMethodInvocationPrimaryWithTypeArguments ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationSuper ( ) { super . consumeMethodInvocationSuper ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationSuperWithTypeArguments ( ) { super . consumeMethodInvocationSuperWithTypeArguments ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeNormalAnnotation ( ) { super . consumeNormalAnnotation ( ) ; Annotation annotation = ( Annotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptAnnotationTypeReference ( annotation . type . getTypeName ( ) , annotation . sourceStart , annotation . sourceEnd ) ; } } protected void consumeSingleMemberAnnotation ( ) { super . consumeSingleMemberAnnotation ( ) ; SingleMemberAnnotation member = ( SingleMemberAnnotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( TypeConstants . VALUE , <NUM_LIT:0> , member . sourceStart ) ; } } protected void consumeSingleStaticImportDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = newImportReference ( tokens , positions , false , ClassFileConstants . AccStatic ) ) ; this . modifiers = ClassFileConstants . AccDefault ; this . modifiersSourceStart = - <NUM_LIT:1> ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( ! this . statementRecoveryActivated && this . options . sourceLevel < ClassFileConstants . JDK1_5 && this . lastErrorEndPositionBeforeRecovery < this . scanner . currentPosition ) { impt . modifiers = ClassFileConstants . AccDefault ; problemReporter ( ) . invalidUsageOfStaticImports ( impt ) ; } if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { int tokensLength = impt . tokens . length - <NUM_LIT:1> ; int start = ( int ) ( impt . sourcePositions [ tokensLength ] > > > <NUM_LIT:32> ) ; char [ ] last = impt . tokens [ tokensLength ] ; this . requestor . acceptFieldReference ( last , start ) ; this . requestor . acceptMethodReference ( last , <NUM_LIT:0> , start ) ; this . requestor . acceptTypeReference ( last , start ) ; if ( tokensLength > <NUM_LIT:0> ) { char [ ] [ ] compoundName = new char [ tokensLength ] [ ] ; System . arraycopy ( impt . tokens , <NUM_LIT:0> , compoundName , <NUM_LIT:0> , tokensLength ) ; int end = ( int ) impt . sourcePositions [ tokensLength - <NUM_LIT:1> ] ; this . requestor . acceptTypeReference ( compoundName , impt . sourceStart , end ) ; } } } protected void consumeSingleTypeImportDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = newImportReference ( tokens , positions , false , ClassFileConstants . AccDefault ) ) ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( impt . tokens , impt . sourceStart , impt . sourceEnd ) ; } } protected void consumeStaticImportOnDemandDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = new ImportReference ( tokens , positions , true , ClassFileConstants . AccStatic ) ) ; impt . trailingStarPosition = this . intStack [ this . intPtr -- ] ; this . modifiers = ClassFileConstants . AccDefault ; this . modifiersSourceStart = - <NUM_LIT:1> ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( ! this . statementRecoveryActivated && this . options . sourceLevel < ClassFileConstants . JDK1_5 && this . lastErrorEndPositionBeforeRecovery < this . scanner . currentPosition ) { impt . modifiers = ClassFileConstants . AccDefault ; problemReporter ( ) . invalidUsageOfStaticImports ( impt ) ; } if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( impt . tokens , impt . sourceStart , impt . sourceEnd ) ; } } protected void consumeTypeImportOnDemandDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = new ImportReference ( tokens , positions , true , ClassFileConstants . AccDefault ) ) ; impt . trailingStarPosition = this . intStack [ this . intPtr -- ] ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { this . requestor . acceptUnknownReference ( impt . tokens , impt . sourceStart , impt . sourceEnd ) ; } } public MethodDeclaration convertToMethodDeclaration ( ConstructorDeclaration c , CompilationResult compilationResult ) { MethodDeclaration methodDeclaration = super . convertToMethodDeclaration ( c , compilationResult ) ; int selectorSourceEnd = this . sourceEnds . removeKey ( c ) ; if ( selectorSourceEnd != - <NUM_LIT:1> ) this . sourceEnds . put ( methodDeclaration , selectorSourceEnd ) ; char [ ] [ ] categories = ( char [ ] [ ] ) this . nodesToCategories . remove ( c ) ; if ( categories != null ) this . nodesToCategories . put ( methodDeclaration , categories ) ; return methodDeclaration ; } protected CompilationUnitDeclaration endParse ( int act ) { if ( this . scanner . recordLineSeparator ) { this . requestor . acceptLineSeparatorPositions ( this . scanner . getLineEnds ( ) ) ; } if ( this . compilationUnit != null ) { CompilationUnitDeclaration result = super . endParse ( act ) ; return result ; } else { return null ; } } public TypeReference getTypeReference ( int dim ) { int length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ; if ( length < <NUM_LIT:0> ) { TypeReference ref = TypeReference . baseTypeReference ( - length , dim ) ; ref . sourceStart = this . intStack [ this . intPtr -- ] ; if ( dim == <NUM_LIT:0> ) { ref . sourceEnd = this . intStack [ this . intPtr -- ] ; } else { this . intPtr -- ; ref . sourceEnd = this . endPosition ; } if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . getParameterizedTypeName ( ) , ref . sourceStart , ref . sourceEnd ) ; } return ref ; } else { int numberOfIdentifiers = this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr -- ] ; if ( length != numberOfIdentifiers || this . genericsLengthStack [ this . genericsLengthPtr ] != <NUM_LIT:0> ) { TypeReference ref = getTypeReferenceForGenericType ( dim , length , numberOfIdentifiers ) ; if ( this . reportReferenceInfo ) { if ( length == <NUM_LIT:1> && numberOfIdentifiers == <NUM_LIT:1> ) { ParameterizedSingleTypeReference parameterizedSingleTypeReference = ( ParameterizedSingleTypeReference ) ref ; this . requestor . acceptTypeReference ( parameterizedSingleTypeReference . token , parameterizedSingleTypeReference . sourceStart ) ; } else { ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = ( ParameterizedQualifiedTypeReference ) ref ; this . requestor . acceptTypeReference ( parameterizedQualifiedTypeReference . tokens , parameterizedQualifiedTypeReference . sourceStart , parameterizedQualifiedTypeReference . sourceEnd ) ; } } return ref ; } else if ( length == <NUM_LIT:1> ) { this . genericsLengthPtr -- ; if ( dim == <NUM_LIT:0> ) { SingleTypeReference ref = new SingleTypeReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] ) ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . token , ref . sourceStart ) ; } return ref ; } else { ArrayTypeReference ref = new ArrayTypeReference ( this . identifierStack [ this . identifierPtr ] , dim , this . identifierPositionStack [ this . identifierPtr -- ] ) ; ref . sourceEnd = this . endPosition ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . token , ref . sourceStart ) ; } return ref ; } } else { this . genericsLengthPtr -- ; char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( dim == <NUM_LIT:0> ) { QualifiedTypeReference ref = new QualifiedTypeReference ( tokens , positions ) ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . tokens , ref . sourceStart , ref . sourceEnd ) ; } return ref ; } else { ArrayQualifiedTypeReference ref = new ArrayQualifiedTypeReference ( tokens , dim , positions ) ; ref . sourceEnd = this . endPosition ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . tokens , ref . sourceStart , ref . sourceEnd ) ; } return ref ; } } } } public NameReference getUnspecifiedReference ( ) { int length ; if ( ( length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ) == <NUM_LIT:1> ) { SingleNameReference ref = newSingleNameReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] ) ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } else { char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; QualifiedNameReference ref = newQualifiedNameReference ( tokens , positions , ( int ) ( this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ this . identifierPtr + length ] ) ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } } public NameReference getUnspecifiedReferenceOptimized ( ) { int length ; if ( ( length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ) == <NUM_LIT:1> ) { SingleNameReference ref = newSingleNameReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] ) ; ref . bits &= ~ ASTNode . RestrictiveFlagMASK ; ref . bits |= Binding . LOCAL | Binding . FIELD ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; QualifiedNameReference ref = newQualifiedNameReference ( tokens , positions , ( int ) ( this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ this . identifierPtr + length ] ) ; ref . bits &= ~ ASTNode . RestrictiveFlagMASK ; ref . bits |= Binding . LOCAL | Binding . FIELD ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } protected ImportReference newImportReference ( char [ ] [ ] tokens , long [ ] positions , boolean onDemand , int mod ) { return new ImportReference ( tokens , positions , onDemand , mod ) ; } protected QualifiedNameReference newQualifiedNameReference ( char [ ] [ ] tokens , long [ ] positions , int sourceStart , int sourceEnd ) { return new QualifiedNameReference ( tokens , positions , sourceStart , sourceEnd ) ; } protected SingleNameReference newSingleNameReference ( char [ ] source , long positions ) { return new SingleNameReference ( source , positions ) ; } public CompilationUnitDeclaration parseCompilationUnit ( ICompilationUnit unit , boolean fullParse , IProgressMonitor pm ) { boolean old = this . diet ; CompilationUnitDeclaration parsedUnit = null ; try { this . diet = true ; this . reportReferenceInfo = fullParse ; CompilationResult compilationUnitResult = new CompilationResult ( unit , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) ; parsedUnit = parse ( unit , compilationUnitResult ) ; if ( pm != null && pm . isCanceled ( ) ) throw new OperationCanceledException ( Messages . operation_cancelled ) ; if ( this . scanner . recordLineSeparator ) { this . requestor . acceptLineSeparatorPositions ( compilationUnitResult . getLineSeparatorPositions ( ) ) ; } int initialStart = this . scanner . initialPosition ; int initialEnd = this . scanner . eofPosition ; if ( this . reportLocalDeclarations || fullParse ) { this . diet = false ; getMethodBodies ( parsedUnit ) ; } this . scanner . resetTo ( initialStart , initialEnd ) ; this . notifier . notifySourceElementRequestor ( parsedUnit , this . scanner . initialPosition , this . scanner . eofPosition , this . reportReferenceInfo , this . sourceEnds , this . nodesToCategories ) ; return parsedUnit ; } catch ( AbortCompilation e ) { } finally { this . diet = old ; reset ( ) ; } return parsedUnit ; } private void rememberCategories ( ) { if ( this . useSourceJavadocParser ) { SourceJavadocParser sourceJavadocParser = ( SourceJavadocParser ) this . javadocParser ; char [ ] [ ] categories = sourceJavadocParser . categories ; if ( categories . length > <NUM_LIT:0> ) { this . nodesToCategories . put ( this . astStack [ this . astPtr ] , categories ) ; sourceJavadocParser . categories = CharOperation . NO_CHAR_CHAR ; } } } public void reset ( ) { this . sourceEnds = new HashtableOfObjectToInt ( ) ; this . nodesToCategories = new HashMap ( ) ; } public void setRequestor ( ISourceElementRequestor requestor ) { this . requestor = requestor ; this . notifier . requestor = requestor ; } } </s>
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . impl . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . parser . * ; import org . eclipse . jdt . internal . compiler . problem . * ; public class DocumentElementParser extends Parser { IDocumentElementRequestor requestor ; private int localIntPtr ; private int lastFieldEndPosition ; private int lastFieldBodyEndPosition ; private int typeStartPosition ; private long selectorSourcePositions ; private int typeDims ; private int extendsDim ; private int declarationSourceStart ; int [ ] [ ] intArrayStack ; int intArrayPtr ; public DocumentElementParser ( final IDocumentElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options ) { super ( new ProblemReporter ( DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , options , problemFactory ) , false ) ; this . requestor = requestor ; this . intArrayStack = new int [ <NUM_LIT:30> ] [ ] ; this . options = options ; this . javadocParser . checkDocComment = false ; setMethodsFullRecovery ( false ) ; setStatementsRecovery ( false ) ; } public void checkComment ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; boolean deprecated = false ; int lastCommentIndex = - <NUM_LIT:1> ; int commentPtr = this . scanner . commentPtr ; nextComment : for ( lastCommentIndex = this . scanner . commentPtr ; lastCommentIndex >= <NUM_LIT:0> ; lastCommentIndex -- ) { int commentSourceStart = this . scanner . commentStarts [ lastCommentIndex ] ; if ( commentSourceStart < <NUM_LIT:0> || this . scanner . commentStops [ lastCommentIndex ] < <NUM_LIT:0> || ( this . modifiersSourceStart != - <NUM_LIT:1> && this . modifiersSourceStart < commentSourceStart ) ) { continue nextComment ; } deprecated = this . javadocParser . checkDeprecation ( lastCommentIndex ) ; break nextComment ; } if ( deprecated ) { checkAndSetModifiers ( ClassFileConstants . AccDeprecated ) ; } if ( commentPtr >= <NUM_LIT:0> ) { this . declarationSourceStart = this . scanner . commentStarts [ <NUM_LIT:0> ] ; if ( this . declarationSourceStart < <NUM_LIT:0> ) this . declarationSourceStart = - this . declarationSourceStart ; } } protected void consumeCatchFormalParameter ( ) { this . identifierLengthPtr -- ; char [ ] parameterName = this . identifierStack [ this . identifierPtr ] ; long namePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . intPtr -- ; TypeReference type = ( TypeReference ) this . astStack [ this . astPtr -- ] ; this . intPtr -= <NUM_LIT:3> ; Argument arg = new Argument ( parameterName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] ) ; arg . bits &= ~ ASTNode . IsArgument ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , arg . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } pushOnAstStack ( arg ) ; this . intArrayPtr -- ; } protected void consumeClassBodyDeclaration ( ) { super . consumeClassBodyDeclaration ( ) ; Initializer initializer = ( Initializer ) this . astStack [ this . astPtr ] ; this . requestor . acceptInitializer ( initializer . declarationSourceStart , initializer . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , <NUM_LIT:0> , this . modifiersSourceStart , initializer . block . sourceStart , initializer . block . sourceEnd ) ; } protected void consumeClassDeclaration ( ) { super . consumeClassDeclaration ( ) ; if ( isLocalDeclaration ( ) ) { return ; } this . requestor . exitClass ( this . endStatementPosition , ( ( TypeDeclaration ) this . astStack [ this . astPtr ] ) . declarationSourceEnd ) ; } protected void consumeClassHeader ( ) { super . consumeClassHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } TypeDeclaration typeDecl = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; TypeReference [ ] superInterfaces = typeDecl . superInterfaces ; char [ ] [ ] interfaceNames = null ; int [ ] interfaceNameStarts = null ; int [ ] interfaceNameEnds = null ; if ( superInterfaces != null ) { int superInterfacesLength = superInterfaces . length ; interfaceNames = new char [ superInterfacesLength ] [ ] ; interfaceNameStarts = new int [ superInterfacesLength ] ; interfaceNameEnds = new int [ superInterfacesLength ] ; for ( int i = <NUM_LIT:0> ; i < superInterfacesLength ; i ++ ) { TypeReference superInterface = superInterfaces [ i ] ; interfaceNames [ i ] = CharOperation . concatWith ( superInterface . getTypeName ( ) , '<CHAR_LIT:.>' ) ; interfaceNameStarts [ i ] = superInterface . sourceStart ; interfaceNameEnds [ i ] = superInterface . sourceEnd ; } } this . scanner . commentPtr = - <NUM_LIT:1> ; TypeReference superclass = typeDecl . superclass ; if ( superclass == null ) { this . requestor . enterClass ( typeDecl . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , typeDecl . modifiers , typeDecl . modifiersSourceStart , this . typeStartPosition , typeDecl . name , typeDecl . sourceStart , typeDecl . sourceEnd , null , - <NUM_LIT:1> , - <NUM_LIT:1> , interfaceNames , interfaceNameStarts , interfaceNameEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } else { this . requestor . enterClass ( typeDecl . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , typeDecl . modifiers , typeDecl . modifiersSourceStart , this . typeStartPosition , typeDecl . name , typeDecl . sourceStart , typeDecl . sourceEnd , CharOperation . concatWith ( superclass . getTypeName ( ) , '<CHAR_LIT:.>' ) , superclass . sourceStart , superclass . sourceEnd , interfaceNames , interfaceNameStarts , interfaceNameEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } } protected void consumeClassHeaderName1 ( ) { TypeDeclaration typeDecl = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; if ( this . nestedMethod [ this . nestedType ] == <NUM_LIT:0> ) { if ( this . nestedType != <NUM_LIT:0> ) { typeDecl . bits |= ASTNode . IsMemberType ; } } else { typeDecl . bits |= ASTNode . IsLocalType ; markEnclosingMemberWithLocalType ( ) ; blockReal ( ) ; } long pos = this . identifierPositionStack [ this . identifierPtr ] ; typeDecl . sourceEnd = ( int ) pos ; typeDecl . sourceStart = ( int ) ( pos > > > <NUM_LIT:32> ) ; typeDecl . name = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; this . typeStartPosition = typeDecl . declarationSourceStart = this . intStack [ this . intPtr -- ] ; this . intPtr -- ; int declSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiers = this . intStack [ this . intPtr -- ] ; if ( typeDecl . declarationSourceStart > declSourceStart ) { typeDecl . declarationSourceStart = declSourceStart ; } int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , typeDecl . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } typeDecl . bodyStart = typeDecl . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( typeDecl ) ; typeDecl . javadoc = this . javadoc ; this . javadoc = null ; } protected void consumeCompilationUnit ( ) { this . requestor . exitCompilationUnit ( this . scanner . source . length - <NUM_LIT:1> ) ; } protected void consumeConstructorDeclaration ( ) { super . consumeConstructorDeclaration ( ) ; if ( isLocalDeclaration ( ) ) { return ; } ConstructorDeclaration cd = ( ConstructorDeclaration ) this . astStack [ this . astPtr ] ; this . requestor . exitConstructor ( this . endStatementPosition , cd . declarationSourceEnd ) ; } protected void consumeConstructorHeader ( ) { super . consumeConstructorHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } ConstructorDeclaration cd = ( ConstructorDeclaration ) this . astStack [ this . astPtr ] ; Argument [ ] arguments = cd . arguments ; char [ ] [ ] argumentTypes = null ; char [ ] [ ] argumentNames = null ; int [ ] argumentTypeStarts = null ; int [ ] argumentTypeEnds = null ; int [ ] argumentNameStarts = null ; int [ ] argumentNameEnds = null ; if ( arguments != null ) { int argumentLength = arguments . length ; argumentTypes = new char [ argumentLength ] [ ] ; argumentNames = new char [ argumentLength ] [ ] ; argumentNameStarts = new int [ argumentLength ] ; argumentNameEnds = new int [ argumentLength ] ; argumentTypeStarts = new int [ argumentLength ] ; argumentTypeEnds = new int [ argumentLength ] ; for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { Argument argument = arguments [ i ] ; TypeReference argumentType = argument . type ; argumentTypes [ i ] = returnTypeName ( argumentType ) ; argumentNames [ i ] = argument . name ; argumentNameStarts [ i ] = argument . sourceStart ; argumentNameEnds [ i ] = argument . sourceEnd ; argumentTypeStarts [ i ] = argumentType . sourceStart ; argumentTypeEnds [ i ] = argumentType . sourceEnd ; } } TypeReference [ ] thrownExceptions = cd . thrownExceptions ; char [ ] [ ] exceptionTypes = null ; int [ ] exceptionTypeStarts = null ; int [ ] exceptionTypeEnds = null ; if ( thrownExceptions != null ) { int thrownExceptionLength = thrownExceptions . length ; exceptionTypes = new char [ thrownExceptionLength ] [ ] ; exceptionTypeStarts = new int [ thrownExceptionLength ] ; exceptionTypeEnds = new int [ thrownExceptionLength ] ; for ( int i = <NUM_LIT:0> ; i < thrownExceptionLength ; i ++ ) { TypeReference exception = thrownExceptions [ i ] ; exceptionTypes [ i ] = CharOperation . concatWith ( exception . getTypeName ( ) , '<CHAR_LIT:.>' ) ; exceptionTypeStarts [ i ] = exception . sourceStart ; exceptionTypeEnds [ i ] = exception . sourceEnd ; } } this . requestor . enterConstructor ( cd . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , cd . modifiers , cd . modifiersSourceStart , cd . selector , cd . sourceStart , ( int ) ( this . selectorSourcePositions & <NUM_LIT> ) , argumentTypes , argumentTypeStarts , argumentTypeEnds , argumentNames , argumentNameStarts , argumentNameEnds , this . rParenPos , exceptionTypes , exceptionTypeStarts , exceptionTypeEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } protected void consumeConstructorHeaderName ( ) { ConstructorDeclaration cd = new ConstructorDeclaration ( this . compilationUnit . compilationResult ) ; cd . selector = this . identifierStack [ this . identifierPtr ] ; this . selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; cd . declarationSourceStart = this . intStack [ this . intPtr -- ] ; cd . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; cd . modifiers = this . intStack [ this . intPtr -- ] ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , cd . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } cd . javadoc = this . javadoc ; this . javadoc = null ; cd . sourceStart = ( int ) ( this . selectorSourcePositions > > > <NUM_LIT:32> ) ; pushOnAstStack ( cd ) ; cd . sourceEnd = this . lParenPos ; cd . bodyStart = this . lParenPos + <NUM_LIT:1> ; } protected void consumeDefaultModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; pushOnIntStack ( - <NUM_LIT:1> ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . scanner . startPosition ) ; resetModifiers ( ) ; pushOnExpressionStackLengthStack ( <NUM_LIT:0> ) ; } protected void consumeDiet ( ) { super . consumeDiet ( ) ; pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; } protected void consumeEnterCompilationUnit ( ) { this . requestor . enterCompilationUnit ( ) ; } protected void consumeEnterVariable ( ) { boolean isLocalDeclaration = isLocalDeclaration ( ) ; if ( ! isLocalDeclaration && ( this . variablesCounter [ this . nestedType ] != <NUM_LIT:0> ) ) { this . requestor . exitField ( this . lastFieldBodyEndPosition , this . lastFieldEndPosition ) ; } char [ ] varName = this . identifierStack [ this . identifierPtr ] ; long namePosition = this . identifierPositionStack [ this . identifierPtr -- ] ; int extendedTypeDimension = this . intStack [ this . intPtr -- ] ; AbstractVariableDeclaration declaration ; if ( this . nestedMethod [ this . nestedType ] != <NUM_LIT:0> ) { declaration = new LocalDeclaration ( varName , ( int ) ( namePosition > > > <NUM_LIT:32> ) , ( int ) namePosition ) ; } else { declaration = new FieldDeclaration ( varName , ( int ) ( namePosition > > > <NUM_LIT:32> ) , ( int ) namePosition ) ; } this . identifierLengthPtr -- ; TypeReference type ; int variableIndex = this . variablesCounter [ this . nestedType ] ; int typeDim = <NUM_LIT:0> ; if ( variableIndex == <NUM_LIT:0> ) { if ( this . nestedMethod [ this . nestedType ] != <NUM_LIT:0> ) { declaration . declarationSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiers = this . intStack [ this . intPtr -- ] ; type = getTypeReference ( typeDim = this . intStack [ this . intPtr -- ] ) ; pushOnAstStack ( type ) ; } else { type = getTypeReference ( typeDim = this . intStack [ this . intPtr -- ] ) ; pushOnAstStack ( type ) ; declaration . declarationSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiers = this . intStack [ this . intPtr -- ] ; } int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , declaration . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } } else { type = ( TypeReference ) this . astStack [ this . astPtr - variableIndex ] ; typeDim = type . dimensions ( ) ; AbstractVariableDeclaration previousVariable = ( AbstractVariableDeclaration ) this . astStack [ this . astPtr ] ; declaration . declarationSourceStart = previousVariable . declarationSourceStart ; declaration . modifiers = previousVariable . modifiers ; declaration . modifiersSourceStart = previousVariable . modifiersSourceStart ; final Annotation [ ] annotations = previousVariable . annotations ; if ( annotations != null ) { final int annotationsLength = annotations . length ; System . arraycopy ( annotations , <NUM_LIT:0> , declaration . annotations = new Annotation [ annotationsLength ] , <NUM_LIT:0> , annotationsLength ) ; } } this . localIntPtr = this . intPtr ; if ( extendedTypeDimension == <NUM_LIT:0> ) { declaration . type = type ; } else { int dimension = typeDim + extendedTypeDimension ; declaration . type = copyDims ( type , dimension ) ; } this . variablesCounter [ this . nestedType ] ++ ; this . nestedMethod [ this . nestedType ] ++ ; pushOnAstStack ( declaration ) ; int [ ] javadocPositions = this . intArrayStack [ this . intArrayPtr ] ; if ( ! isLocalDeclaration ) { this . requestor . enterField ( declaration . declarationSourceStart , javadocPositions , declaration . modifiers , declaration . modifiersSourceStart , returnTypeName ( declaration . type ) , type . sourceStart , type . sourceEnd , this . typeDims , varName , ( int ) ( namePosition > > > <NUM_LIT:32> ) , ( int ) namePosition , extendedTypeDimension , extendedTypeDimension == <NUM_LIT:0> ? - <NUM_LIT:1> : this . endPosition ) ; } } protected void consumeExitVariableWithInitialization ( ) { super . consumeExitVariableWithInitialization ( ) ; this . nestedMethod [ this . nestedType ] -- ; this . lastFieldEndPosition = this . scanner . currentPosition - <NUM_LIT:1> ; this . lastFieldBodyEndPosition = ( ( AbstractVariableDeclaration ) this . astStack [ this . astPtr ] ) . initialization . sourceEnd ; } protected void consumeExitVariableWithoutInitialization ( ) { super . consumeExitVariableWithoutInitialization ( ) ; this . nestedMethod [ this . nestedType ] -- ; this . lastFieldEndPosition = this . scanner . currentPosition - <NUM_LIT:1> ; this . lastFieldBodyEndPosition = this . scanner . startPosition - <NUM_LIT:1> ; } protected void consumeFieldDeclaration ( ) { int variableIndex = this . variablesCounter [ this . nestedType ] ; super . consumeFieldDeclaration ( ) ; this . intArrayPtr -- ; if ( isLocalDeclaration ( ) ) return ; if ( variableIndex != <NUM_LIT:0> ) { this . requestor . exitField ( this . lastFieldBodyEndPosition , this . lastFieldEndPosition ) ; } } protected void consumeFormalParameter ( boolean isVarArgs ) { this . identifierLengthPtr -- ; char [ ] parameterName = this . identifierStack [ this . identifierPtr ] ; long namePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; int extendedDimensions = this . intStack [ this . intPtr -- ] ; int endOfEllipsis = <NUM_LIT:0> ; if ( isVarArgs ) { endOfEllipsis = this . intStack [ this . intPtr -- ] ; } int firstDimensions = this . intStack [ this . intPtr -- ] ; final int typeDimensions = firstDimensions + extendedDimensions ; TypeReference type = getTypeReference ( typeDimensions ) ; if ( isVarArgs ) { type = copyDims ( type , typeDimensions + <NUM_LIT:1> ) ; if ( extendedDimensions == <NUM_LIT:0> ) { type . sourceEnd = endOfEllipsis ; } type . bits |= ASTNode . IsVarArgs ; } this . intPtr -= <NUM_LIT:3> ; Argument arg = new Argument ( parameterName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , arg . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } pushOnAstStack ( arg ) ; this . intArrayPtr -- ; } protected void consumeInterfaceDeclaration ( ) { super . consumeInterfaceDeclaration ( ) ; if ( isLocalDeclaration ( ) ) { return ; } this . requestor . exitInterface ( this . endStatementPosition , ( ( TypeDeclaration ) this . astStack [ this . astPtr ] ) . declarationSourceEnd ) ; } protected void consumeInterfaceHeader ( ) { super . consumeInterfaceHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } TypeDeclaration typeDecl = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; TypeReference [ ] superInterfaces = typeDecl . superInterfaces ; char [ ] [ ] interfaceNames = null ; int [ ] interfaceNameStarts = null ; int [ ] interfacenameEnds = null ; int superInterfacesLength = <NUM_LIT:0> ; if ( superInterfaces != null ) { superInterfacesLength = superInterfaces . length ; interfaceNames = new char [ superInterfacesLength ] [ ] ; interfaceNameStarts = new int [ superInterfacesLength ] ; interfacenameEnds = new int [ superInterfacesLength ] ; } if ( superInterfaces != null ) { for ( int i = <NUM_LIT:0> ; i < superInterfacesLength ; i ++ ) { TypeReference superInterface = superInterfaces [ i ] ; interfaceNames [ i ] = CharOperation . concatWith ( superInterface . getTypeName ( ) , '<CHAR_LIT:.>' ) ; interfaceNameStarts [ i ] = superInterface . sourceStart ; interfacenameEnds [ i ] = superInterface . sourceEnd ; } } this . scanner . commentPtr = - <NUM_LIT:1> ; this . requestor . enterInterface ( typeDecl . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , typeDecl . modifiers , typeDecl . modifiersSourceStart , this . typeStartPosition , typeDecl . name , typeDecl . sourceStart , typeDecl . sourceEnd , interfaceNames , interfaceNameStarts , interfacenameEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } protected void consumeInterfaceHeaderName1 ( ) { TypeDeclaration typeDecl = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; if ( this . nestedMethod [ this . nestedType ] == <NUM_LIT:0> ) { if ( this . nestedType != <NUM_LIT:0> ) { typeDecl . bits |= ASTNode . IsMemberType ; } } else { typeDecl . bits |= ASTNode . IsLocalType ; markEnclosingMemberWithLocalType ( ) ; blockReal ( ) ; } long pos = this . identifierPositionStack [ this . identifierPtr ] ; typeDecl . sourceEnd = ( int ) pos ; typeDecl . sourceStart = ( int ) ( pos > > > <NUM_LIT:32> ) ; typeDecl . name = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; this . typeStartPosition = typeDecl . declarationSourceStart = this . intStack [ this . intPtr -- ] ; this . intPtr -- ; int declSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiers = this . intStack [ this . intPtr -- ] | ClassFileConstants . AccInterface ; if ( typeDecl . declarationSourceStart > declSourceStart ) { typeDecl . declarationSourceStart = declSourceStart ; } int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , typeDecl . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } typeDecl . bodyStart = typeDecl . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( typeDecl ) ; typeDecl . javadoc = this . javadoc ; this . javadoc = null ; } protected void consumeInternalCompilationUnit ( ) { } protected void consumeInternalCompilationUnitWithTypes ( ) { int length ; if ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) != <NUM_LIT:0> ) { this . compilationUnit . types = new TypeDeclaration [ length ] ; this . astPtr -= length ; System . arraycopy ( this . astStack , this . astPtr + <NUM_LIT:1> , this . compilationUnit . types , <NUM_LIT:0> , length ) ; } } protected void consumeLocalVariableDeclaration ( ) { super . consumeLocalVariableDeclaration ( ) ; this . intArrayPtr -- ; } protected void consumeMethodDeclaration ( boolean isNotAbstract ) { super . consumeMethodDeclaration ( isNotAbstract ) ; if ( isLocalDeclaration ( ) ) { return ; } MethodDeclaration md = ( MethodDeclaration ) this . astStack [ this . astPtr ] ; this . requestor . exitMethod ( this . endStatementPosition , md . declarationSourceEnd ) ; } protected void consumeMethodHeader ( ) { super . consumeMethodHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } MethodDeclaration md = ( MethodDeclaration ) this . astStack [ this . astPtr ] ; TypeReference returnType = md . returnType ; char [ ] returnTypeName = returnTypeName ( returnType ) ; Argument [ ] arguments = md . arguments ; char [ ] [ ] argumentTypes = null ; char [ ] [ ] argumentNames = null ; int [ ] argumentTypeStarts = null ; int [ ] argumentTypeEnds = null ; int [ ] argumentNameStarts = null ; int [ ] argumentNameEnds = null ; if ( arguments != null ) { int argumentLength = arguments . length ; argumentTypes = new char [ argumentLength ] [ ] ; argumentNames = new char [ argumentLength ] [ ] ; argumentNameStarts = new int [ argumentLength ] ; argumentNameEnds = new int [ argumentLength ] ; argumentTypeStarts = new int [ argumentLength ] ; argumentTypeEnds = new int [ argumentLength ] ; for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { Argument argument = arguments [ i ] ; TypeReference argumentType = argument . type ; argumentTypes [ i ] = returnTypeName ( argumentType ) ; argumentNames [ i ] = argument . name ; argumentNameStarts [ i ] = argument . sourceStart ; argumentNameEnds [ i ] = argument . sourceEnd ; argumentTypeStarts [ i ] = argumentType . sourceStart ; argumentTypeEnds [ i ] = argumentType . sourceEnd ; } } TypeReference [ ] thrownExceptions = md . thrownExceptions ; char [ ] [ ] exceptionTypes = null ; int [ ] exceptionTypeStarts = null ; int [ ] exceptionTypeEnds = null ; if ( thrownExceptions != null ) { int thrownExceptionLength = thrownExceptions . length ; exceptionTypeStarts = new int [ thrownExceptionLength ] ; exceptionTypeEnds = new int [ thrownExceptionLength ] ; exceptionTypes = new char [ thrownExceptionLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < thrownExceptionLength ; i ++ ) { TypeReference exception = thrownExceptions [ i ] ; exceptionTypes [ i ] = CharOperation . concatWith ( exception . getTypeName ( ) , '<CHAR_LIT:.>' ) ; exceptionTypeStarts [ i ] = exception . sourceStart ; exceptionTypeEnds [ i ] = exception . sourceEnd ; } } this . requestor . enterMethod ( md . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , md . modifiers , md . modifiersSourceStart , returnTypeName , returnType . sourceStart , returnType . sourceEnd , this . typeDims , md . selector , md . sourceStart , ( int ) ( this . selectorSourcePositions & <NUM_LIT> ) , argumentTypes , argumentTypeStarts , argumentTypeEnds , argumentNames , argumentNameStarts , argumentNameEnds , this . rParenPos , this . extendsDim , this . extendsDim == <NUM_LIT:0> ? - <NUM_LIT:1> : this . endPosition , exceptionTypes , exceptionTypeStarts , exceptionTypeEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } protected void consumeMethodHeaderExtendedDims ( ) { MethodDeclaration md = ( MethodDeclaration ) this . astStack [ this . astPtr ] ; int extendedDims = this . intStack [ this . intPtr -- ] ; this . extendsDim = extendedDims ; if ( extendedDims != <NUM_LIT:0> ) { TypeReference returnType = md . returnType ; md . sourceEnd = this . endPosition ; int dims = returnType . dimensions ( ) + extendedDims ; md . returnType = copyDims ( returnType , dims ) ; if ( this . currentToken == TokenNameLBRACE ) { md . bodyStart = this . endPosition + <NUM_LIT:1> ; } } } protected void consumeMethodHeaderName ( boolean isAnnotationMethod ) { MethodDeclaration md = null ; if ( isAnnotationMethod ) { md = new AnnotationMethodDeclaration ( this . compilationUnit . compilationResult ) ; } else { md = new MethodDeclaration ( this . compilationUnit . compilationResult ) ; } md . selector = this . identifierStack [ this . identifierPtr ] ; this . selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; md . returnType = getTypeReference ( this . typeDims = this . intStack [ this . intPtr -- ] ) ; md . declarationSourceStart = this . intStack [ this . intPtr -- ] ; md . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; md . modifiers = this . intStack [ this . intPtr -- ] ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , md . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } md . javadoc = this . javadoc ; this . javadoc = null ; md . sourceStart = ( int ) ( this . selectorSourcePositions > > > <NUM_LIT:32> ) ; pushOnAstStack ( md ) ; md . bodyStart = this . scanner . currentPosition - <NUM_LIT:1> ; } protected void consumeModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; resetModifiers ( ) ; } protected void consumePackageComment ( ) { if ( this . options . sourceLevel >= ClassFileConstants . JDK1_5 ) { checkComment ( ) ; } else { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; } resetModifiers ( ) ; } protected void consumePackageDeclarationName ( ) { super . consumePackageDeclarationName ( ) ; ImportReference importReference = this . compilationUnit . currentPackage ; this . requestor . acceptPackage ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart ) ; } protected void consumePackageDeclarationNameWithModifiers ( ) { super . consumePackageDeclarationNameWithModifiers ( ) ; ImportReference importReference = this . compilationUnit . currentPackage ; this . requestor . acceptPackage ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart ) ; } protected void consumePushModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; if ( this . modifiersSourceStart < <NUM_LIT:0> ) { pushOnIntStack ( - <NUM_LIT:1> ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . scanner . startPosition ) ; } else { pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; } resetModifiers ( ) ; pushOnExpressionStackLengthStack ( <NUM_LIT:0> ) ; } protected void consumePushRealModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; if ( this . modifiersSourceStart < <NUM_LIT:0> ) { pushOnIntStack ( - <NUM_LIT:1> ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . scanner . startPosition ) ; } else { pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; } resetModifiers ( ) ; } protected void consumeSingleStaticImportDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeSingleStaticImportDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , false , ClassFileConstants . AccStatic ) ; } protected void consumeSingleTypeImportDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeSingleTypeImportDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , false , ClassFileConstants . AccDefault ) ; } protected void consumeStaticImportOnDemandDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeStaticImportOnDemandDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , true , ClassFileConstants . AccStatic ) ; } protected void consumeStaticInitializer ( ) { super . consumeStaticInitializer ( ) ; Initializer initializer = ( Initializer ) this . astStack [ this . astPtr ] ; this . requestor . acceptInitializer ( initializer . declarationSourceStart , initializer . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , ClassFileConstants . AccStatic , this . intStack [ this . intPtr -- ] , initializer . block . sourceStart , initializer . declarationSourceEnd ) ; } protected void consumeStaticOnly ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . scanner . currentPosition ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; jumpOverMethodBody ( ) ; this . nestedMethod [ this . nestedType ] ++ ; resetModifiers ( ) ; } protected void consumeTypeImportOnDemandDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeTypeImportOnDemandDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , true , ClassFileConstants . AccDefault ) ; } public int flushCommentsDefinedPriorTo ( int position ) { return this . lastFieldEndPosition = super . flushCommentsDefinedPriorTo ( position ) ; } public CompilationUnitDeclaration endParse ( int act ) { if ( this . scanner . recordLineSeparator ) { this . requestor . acceptLineSeparatorPositions ( this . scanner . getLineEnds ( ) ) ; } return super . endParse ( act ) ; } public void initialize ( boolean initializeNLS ) { super . initialize ( initializeNLS ) ; this . intArrayPtr = - <NUM_LIT:1> ; } public void initialize ( ) { super . initialize ( ) ; this . intArrayPtr = - <NUM_LIT:1> ; } private boolean isLocalDeclaration ( ) { int nestedDepth = this . nestedType ; while ( nestedDepth >= <NUM_LIT:0> ) { if ( this . nestedMethod [ nestedDepth ] != <NUM_LIT:0> ) { return true ; } nestedDepth -- ; } return false ; } protected void parse ( ) { this . diet = true ; super . parse ( ) ; } public void parseCompilationUnit ( ICompilationUnit unit ) { char [ ] regionSource = unit . getContents ( ) ; try { initialize ( true ) ; goForCompilationUnit ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( unit , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseConstructor ( char [ ] regionSource ) { try { initialize ( ) ; goForClassBodyDeclarations ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseField ( char [ ] regionSource ) { try { initialize ( ) ; goForFieldDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseImport ( char [ ] regionSource ) { try { initialize ( ) ; goForImportDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseInitializer ( char [ ] regionSource ) { try { initialize ( ) ; goForInitializer ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseMethod ( char [ ] regionSource ) { try { initialize ( ) ; goForGenericMethodDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parsePackage ( char [ ] regionSource ) { try { initialize ( ) ; goForPackageDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseType ( char [ ] regionSource ) { try { initialize ( ) ; goForTypeDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public ProblemReporter problemReporter ( ) { this . problemReporter . referenceContext = this . referenceContext ; return this . problemReporter ; } protected void pushOnIntArrayStack ( int [ ] positions ) { int stackLength = this . intArrayStack . length ; if ( ++ this . intArrayPtr >= stackLength ) { System . arraycopy ( this . intArrayStack , <NUM_LIT:0> , this . intArrayStack = new int [ stackLength + StackIncrement ] [ ] , <NUM_LIT:0> , stackLength ) ; } this . intArrayStack [ this . intArrayPtr ] = positions ; } protected void resetModifiers ( ) { super . resetModifiers ( ) ; this . declarationSourceStart = - <NUM_LIT:1> ; } protected boolean resumeOnSyntaxError ( ) { return false ; } private char [ ] returnTypeName ( TypeReference type ) { int dimension = type . dimensions ( ) ; if ( dimension != <NUM_LIT:0> ) { char [ ] dimensionsArray = new char [ dimension * <NUM_LIT:2> ] ; for ( int i = <NUM_LIT:0> ; i < dimension ; i ++ ) { dimensionsArray [ i * <NUM_LIT:2> ] = '<CHAR_LIT:[>' ; dimensionsArray [ ( i * <NUM_LIT:2> ) + <NUM_LIT:1> ] = '<CHAR_LIT:]>' ; } return CharOperation . concat ( CharOperation . concatWith ( type . getTypeName ( ) , '<CHAR_LIT:.>' ) , dimensionsArray ) ; } return CharOperation . concatWith ( type . getTypeName ( ) , '<CHAR_LIT:.>' ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" + this . intArrayPtr + "<STR_LIT:n>" ) ; buffer . append ( super . toString ( ) ) ; return buffer . toString ( ) ; } protected TypeReference typeReference ( int dim , int localIdentifierPtr , int localIdentifierLengthPtr ) { int length ; TypeReference ref ; if ( ( length = this . identifierLengthStack [ localIdentifierLengthPtr ] ) == <NUM_LIT:1> ) { if ( dim == <NUM_LIT:0> ) { ref = new SingleTypeReference ( this . identifierStack [ localIdentifierPtr ] , this . identifierPositionStack [ localIdentifierPtr -- ] ) ; } else { ref = new ArrayTypeReference ( this . identifierStack [ localIdentifierPtr ] , dim , this . identifierPositionStack [ localIdentifierPtr -- ] ) ; ref . sourceEnd = this . endPosition ; } } else { if ( length < <NUM_LIT:0> ) { ref = TypeReference . baseTypeReference ( - length , dim ) ; ref . sourceStart = this . intStack [ this . localIntPtr -- ] ; if ( dim == <NUM_LIT:0> ) { ref . sourceEnd = this . intStack [ this . localIntPtr -- ] ; } else { this . localIntPtr -- ; ref . sourceEnd = this . endPosition ; } } else { char [ ] [ ] tokens = new char [ length ] [ ] ; localIdentifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , localIdentifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , localIdentifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( dim == <NUM_LIT:0> ) ref = new QualifiedTypeReference ( tokens , positions ) ; else ref = new ArrayQualifiedTypeReference ( tokens , dim , positions ) ; } } return ref ; } } </s>
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . env . IBinaryNestedType ; public final class ExtraFlags { public final static int HasNonPrivateStaticMemberTypes = <NUM_LIT> ; public final static int IsMemberType = <NUM_LIT> ; public final static int IsLocalType = <NUM_LIT> ; public final static int ParameterTypesStoredAsSignature = <NUM_LIT> ; public static int getExtraFlags ( ClassFileReader reader ) { int extraFlags = <NUM_LIT:0> ; if ( reader . isNestedType ( ) ) { extraFlags |= ExtraFlags . IsMemberType ; } if ( reader . isLocal ( ) ) { extraFlags |= ExtraFlags . IsLocalType ; } IBinaryNestedType [ ] memberTypes = reader . getMemberTypes ( ) ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; if ( memberTypeCounter > <NUM_LIT:0> ) { done : for ( int i = <NUM_LIT:0> ; i < memberTypeCounter ; i ++ ) { int modifiers = memberTypes [ i ] . getModifiers ( ) ; if ( ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> && ( modifiers & ClassFileConstants . AccPrivate ) == <NUM_LIT:0> ) { extraFlags |= ExtraFlags . HasNonPrivateStaticMemberTypes ; break done ; } } } return extraFlags ; } public static int getExtraFlags ( IType type ) throws JavaModelException { int extraFlags = <NUM_LIT:0> ; if ( type . isMember ( ) ) { extraFlags |= ExtraFlags . IsMemberType ; } if ( type . isLocal ( ) ) { extraFlags |= ExtraFlags . IsLocalType ; } IType [ ] memberTypes = type . getTypes ( ) ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; if ( memberTypeCounter > <NUM_LIT:0> ) { done : for ( int i = <NUM_LIT:0> ; i < memberTypeCounter ; i ++ ) { int flags = memberTypes [ i ] . getFlags ( ) ; if ( ( flags & ClassFileConstants . AccStatic ) != <NUM_LIT:0> && ( flags & ClassFileConstants . AccPrivate ) == <NUM_LIT:0> ) { extraFlags |= ExtraFlags . HasNonPrivateStaticMemberTypes ; break done ; } } } return extraFlags ; } public static int getExtraFlags ( TypeDeclaration typeDeclaration ) { int extraFlags = <NUM_LIT:0> ; if ( typeDeclaration . enclosingType != null ) { extraFlags |= ExtraFlags . IsMemberType ; } TypeDeclaration [ ] memberTypes = typeDeclaration . memberTypes ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; if ( memberTypeCounter > <NUM_LIT:0> ) { done : for ( int i = <NUM_LIT:0> ; i < memberTypeCounter ; i ++ ) { int modifiers = memberTypes [ i ] . modifiers ; if ( ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> && ( modifiers & ClassFileConstants . AccPrivate ) == <NUM_LIT:0> ) { extraFlags |= ExtraFlags . HasNonPrivateStaticMemberTypes ; break done ; } } } return extraFlags ; } } </s>
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; public class SourceElementRequestorAdapter implements ISourceElementRequestor { public void acceptAnnotationTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) { } public void acceptAnnotationTypeReference ( char [ ] typeName , int sourcePosition ) { } public void acceptConstructorReference ( char [ ] typeName , int argCount , int sourcePosition ) { } public void acceptFieldReference ( char [ ] fieldName , int sourcePosition ) { } public void acceptImport ( int declarationStart , int declarationEnd , int nameStart , int nameEnd , char [ ] [ ] tokens , boolean onDemand , int modifiers ) { } public void acceptLineSeparatorPositions ( int [ ] positions ) { } public void acceptMethodReference ( char [ ] methodName , int argCount , int sourcePosition ) { } public void acceptPackage ( ImportReference importReference ) { } public void acceptProblem ( CategorizedProblem problem ) { } public void acceptTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) { } public void acceptTypeReference ( char [ ] typeName , int sourcePosition ) { } public void acceptUnknownReference ( char [ ] [ ] name , int sourceStart , int sourceEnd ) { } public void acceptUnknownReference ( char [ ] name , int sourcePosition ) { } public void enterCompilationUnit ( ) { } public void enterConstructor ( MethodInfo methodInfo ) { } public void enterField ( FieldInfo fieldInfo ) { } public void enterInitializer ( int declarationStart , int modifiers ) { } public void enterMethod ( MethodInfo methodInfo ) { } public void enterType ( TypeInfo typeInfo ) { } public void exitCompilationUnit ( int declarationEnd ) { } public void exitConstructor ( int declarationEnd ) { } public void exitField ( int initializationStart , int declarationEnd , int declarationSourceEnd ) { } public void exitInitializer ( int declarationEnd ) { } public void exitMethod ( int declarationEnd , Expression defaultValue ) { } public void exitType ( int declarationEnd ) { } } </s>
<s> package org . eclipse . jdt . internal . compiler . parser ; import java . util . ArrayList ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . ArrayQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ArrayTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedSingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; public abstract class TypeConverter { int namePos ; protected ProblemReporter problemReporter ; protected boolean has1_5Compliance ; private char memberTypeSeparator ; protected TypeConverter ( ProblemReporter problemReporter , char memberTypeSeparator ) { this . problemReporter = problemReporter ; this . has1_5Compliance = problemReporter . options . originalComplianceLevel >= ClassFileConstants . JDK1_5 ; this . memberTypeSeparator = memberTypeSeparator ; } private void addIdentifiers ( String typeSignature , int start , int endExclusive , int identCount , ArrayList fragments ) { if ( identCount == <NUM_LIT:1> ) { char [ ] identifier ; typeSignature . getChars ( start , endExclusive , identifier = new char [ endExclusive - start ] , <NUM_LIT:0> ) ; fragments . add ( identifier ) ; } else fragments . add ( extractIdentifiers ( typeSignature , start , endExclusive - <NUM_LIT:1> , identCount ) ) ; } protected ImportReference createImportReference ( String [ ] importName , int start , int end , boolean onDemand , int modifiers ) { int length = importName . length ; long [ ] positions = new long [ length ] ; long position = ( ( long ) start << <NUM_LIT:32> ) + end ; char [ ] [ ] qImportName = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { qImportName [ i ] = importName [ i ] . toCharArray ( ) ; positions [ i ] = position ; } return new ImportReference ( qImportName , positions , onDemand , modifiers ) ; } protected TypeParameter createTypeParameter ( char [ ] typeParameterName , char [ ] [ ] typeParameterBounds , int start , int end ) { TypeParameter parameter = new TypeParameter ( ) ; parameter . name = typeParameterName ; parameter . sourceStart = start ; parameter . sourceEnd = end ; if ( typeParameterBounds != null ) { int length = typeParameterBounds . length ; if ( length > <NUM_LIT:0> ) { parameter . type = createTypeReference ( typeParameterBounds [ <NUM_LIT:0> ] , start , end ) ; if ( length > <NUM_LIT:1> ) { parameter . bounds = new TypeReference [ length - <NUM_LIT:1> ] ; for ( int i = <NUM_LIT:1> ; i < length ; i ++ ) { TypeReference bound = createTypeReference ( typeParameterBounds [ i ] , start , end ) ; bound . bits |= ASTNode . IsSuperType ; parameter . bounds [ i - <NUM_LIT:1> ] = bound ; } } } } return parameter ; } protected TypeReference createTypeReference ( char [ ] typeName , int start , int end , boolean includeGenericsAnyway ) { int length = typeName . length ; this . namePos = <NUM_LIT:0> ; return decodeType ( typeName , length , start , end , true ) ; } protected TypeReference createTypeReference ( char [ ] typeName , int start , int end ) { int length = typeName . length ; this . namePos = <NUM_LIT:0> ; return decodeType ( typeName , length , start , end , false ) ; } protected TypeReference createTypeReference ( String typeSignature , int start , int end ) { int length = typeSignature . length ( ) ; this . namePos = <NUM_LIT:0> ; return decodeType ( typeSignature , length , start , end ) ; } private TypeReference decodeType ( String typeSignature , int length , int start , int end ) { int identCount = <NUM_LIT:1> ; int dim = <NUM_LIT:0> ; int nameFragmentStart = this . namePos , nameFragmentEnd = - <NUM_LIT:1> ; boolean nameStarted = false ; ArrayList fragments = null ; typeLoop : while ( this . namePos < length ) { char currentChar = typeSignature . charAt ( this . namePos ) ; switch ( currentChar ) { case Signature . C_BOOLEAN : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . BOOLEAN . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . BOOLEAN . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_BYTE : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . BYTE . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . BYTE . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_CHAR : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . CHAR . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . CHAR . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_DOUBLE : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . DOUBLE . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . DOUBLE . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_FLOAT : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . FLOAT . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . FLOAT . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_INT : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . INT . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . INT . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_LONG : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . LONG . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . LONG . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_SHORT : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . SHORT . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . SHORT . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_VOID : if ( ! nameStarted ) { this . namePos ++ ; return new SingleTypeReference ( TypeBinding . VOID . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_RESOLVED : case Signature . C_UNRESOLVED : case Signature . C_TYPE_VARIABLE : if ( ! nameStarted ) { nameFragmentStart = this . namePos + <NUM_LIT:1> ; nameStarted = true ; } break ; case Signature . C_STAR : this . namePos ++ ; Wildcard result = new Wildcard ( Wildcard . UNBOUND ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case Signature . C_EXTENDS : this . namePos ++ ; result = new Wildcard ( Wildcard . EXTENDS ) ; result . bound = decodeType ( typeSignature , length , start , end ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case Signature . C_SUPER : this . namePos ++ ; result = new Wildcard ( Wildcard . SUPER ) ; result . bound = decodeType ( typeSignature , length , start , end ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case Signature . C_ARRAY : dim ++ ; break ; case Signature . C_GENERIC_END : case Signature . C_SEMICOLON : nameFragmentEnd = this . namePos - <NUM_LIT:1> ; this . namePos ++ ; break typeLoop ; case Signature . C_DOLLAR : if ( this . memberTypeSeparator != Signature . C_DOLLAR ) break ; case Signature . C_DOT : if ( ! nameStarted ) { nameFragmentStart = this . namePos + <NUM_LIT:1> ; nameStarted = true ; } else if ( this . namePos > nameFragmentStart ) identCount ++ ; break ; case Signature . C_GENERIC_START : nameFragmentEnd = this . namePos - <NUM_LIT:1> ; if ( ! this . has1_5Compliance ) break typeLoop ; if ( fragments == null ) fragments = new ArrayList ( <NUM_LIT:2> ) ; addIdentifiers ( typeSignature , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , identCount , fragments ) ; this . namePos ++ ; TypeReference [ ] arguments = decodeTypeArguments ( typeSignature , length , start , end ) ; fragments . add ( arguments ) ; identCount = <NUM_LIT:1> ; nameStarted = false ; break ; } this . namePos ++ ; } if ( fragments == null ) { if ( identCount == <NUM_LIT:1> ) { if ( dim == <NUM_LIT:0> ) { char [ ] nameFragment = new char [ nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ] ; typeSignature . getChars ( nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , nameFragment , <NUM_LIT:0> ) ; return new SingleTypeReference ( nameFragment , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } else { char [ ] nameFragment = new char [ nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ] ; typeSignature . getChars ( nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , nameFragment , <NUM_LIT:0> ) ; return new ArrayTypeReference ( nameFragment , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } else { long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } char [ ] [ ] identifiers = extractIdentifiers ( typeSignature , nameFragmentStart , nameFragmentEnd , identCount ) ; if ( dim == <NUM_LIT:0> ) { return new QualifiedTypeReference ( identifiers , positions ) ; } else { return new ArrayQualifiedTypeReference ( identifiers , dim , positions ) ; } } } else { if ( nameStarted ) { addIdentifiers ( typeSignature , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , identCount , fragments ) ; } int fragmentLength = fragments . size ( ) ; if ( fragmentLength == <NUM_LIT:2> ) { Object firstFragment = fragments . get ( <NUM_LIT:0> ) ; if ( firstFragment instanceof char [ ] ) { return new ParameterizedSingleTypeReference ( ( char [ ] ) firstFragment , ( TypeReference [ ] ) fragments . get ( <NUM_LIT:1> ) , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } identCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { identCount += ( ( char [ ] [ ] ) element ) . length ; } else if ( element instanceof char [ ] ) identCount ++ ; } char [ ] [ ] tokens = new char [ identCount ] [ ] ; TypeReference [ ] [ ] arguments = new TypeReference [ identCount ] [ ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { char [ ] [ ] fragmentTokens = ( char [ ] [ ] ) element ; int fragmentTokenLength = fragmentTokens . length ; System . arraycopy ( fragmentTokens , <NUM_LIT:0> , tokens , index , fragmentTokenLength ) ; index += fragmentTokenLength ; } else if ( element instanceof char [ ] ) { tokens [ index ++ ] = ( char [ ] ) element ; } else { arguments [ index - <NUM_LIT:1> ] = ( TypeReference [ ] ) element ; } } long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } return new ParameterizedQualifiedTypeReference ( tokens , arguments , dim , positions ) ; } } private TypeReference decodeType ( char [ ] typeName , int length , int start , int end , boolean includeGenericsAnyway ) { int identCount = <NUM_LIT:1> ; int dim = <NUM_LIT:0> ; int nameFragmentStart = this . namePos , nameFragmentEnd = - <NUM_LIT:1> ; ArrayList fragments = null ; typeLoop : while ( this . namePos < length ) { char currentChar = typeName [ this . namePos ] ; switch ( currentChar ) { case '<CHAR_LIT>' : this . namePos ++ ; while ( typeName [ this . namePos ] == '<CHAR_LIT:U+0020>' ) this . namePos ++ ; switch ( typeName [ this . namePos ] ) { case '<CHAR_LIT>' : checkSuper : { int max = TypeConstants . WILDCARD_SUPER . length - <NUM_LIT:1> ; for ( int ahead = <NUM_LIT:1> ; ahead < max ; ahead ++ ) { if ( typeName [ this . namePos + ahead ] != TypeConstants . WILDCARD_SUPER [ ahead + <NUM_LIT:1> ] ) { break checkSuper ; } } this . namePos += max ; Wildcard result = new Wildcard ( Wildcard . SUPER ) ; result . bound = decodeType ( typeName , length , start , end , includeGenericsAnyway ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; } break ; case '<CHAR_LIT:e>' : checkExtends : { int max = TypeConstants . WILDCARD_EXTENDS . length - <NUM_LIT:1> ; for ( int ahead = <NUM_LIT:1> ; ahead < max ; ahead ++ ) { if ( typeName [ this . namePos + ahead ] != TypeConstants . WILDCARD_EXTENDS [ ahead + <NUM_LIT:1> ] ) { break checkExtends ; } } this . namePos += max ; Wildcard result = new Wildcard ( Wildcard . EXTENDS ) ; result . bound = decodeType ( typeName , length , start , end , includeGenericsAnyway ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; } break ; } Wildcard result = new Wildcard ( Wildcard . UNBOUND ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case '<CHAR_LIT:[>' : if ( dim == <NUM_LIT:0> && nameFragmentEnd < <NUM_LIT:0> ) nameFragmentEnd = this . namePos - <NUM_LIT:1> ; dim ++ ; break ; case '<CHAR_LIT:]>' : break ; case '<CHAR_LIT:>>' : case '<CHAR_LIT:U+002C>' : break typeLoop ; case '<CHAR_LIT:.>' : if ( nameFragmentStart < <NUM_LIT:0> ) nameFragmentStart = this . namePos + <NUM_LIT:1> ; identCount ++ ; break ; case '<CHAR_LIT>' : if ( this . has1_5Compliance || includeGenericsAnyway ) { if ( fragments == null ) fragments = new ArrayList ( <NUM_LIT:2> ) ; } nameFragmentEnd = this . namePos - <NUM_LIT:1> ; if ( this . has1_5Compliance || includeGenericsAnyway ) { char [ ] [ ] identifiers = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeName , nameFragmentStart , this . namePos ) ; fragments . add ( identifiers ) ; } this . namePos ++ ; TypeReference [ ] arguments = decodeTypeArguments ( typeName , length , start , end , includeGenericsAnyway ) ; if ( this . has1_5Compliance || includeGenericsAnyway ) { fragments . add ( arguments ) ; identCount = <NUM_LIT:0> ; nameFragmentStart = - <NUM_LIT:1> ; nameFragmentEnd = - <NUM_LIT:1> ; } break ; } this . namePos ++ ; } if ( nameFragmentEnd < <NUM_LIT:0> ) nameFragmentEnd = this . namePos - <NUM_LIT:1> ; if ( fragments == null ) { if ( identCount == <NUM_LIT:1> ) { if ( dim == <NUM_LIT:0> ) { char [ ] nameFragment ; if ( nameFragmentStart != <NUM_LIT:0> || nameFragmentEnd >= <NUM_LIT:0> ) { int nameFragmentLength = nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ; System . arraycopy ( typeName , nameFragmentStart , nameFragment = new char [ nameFragmentLength ] , <NUM_LIT:0> , nameFragmentLength ) ; } else { nameFragment = typeName ; } return new SingleTypeReference ( nameFragment , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } else { int nameFragmentLength = nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ; char [ ] nameFragment = new char [ nameFragmentLength ] ; System . arraycopy ( typeName , nameFragmentStart , nameFragment , <NUM_LIT:0> , nameFragmentLength ) ; return new ArrayTypeReference ( nameFragment , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } else { long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } char [ ] [ ] identifiers = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeName , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> ) ; if ( dim == <NUM_LIT:0> ) { return new QualifiedTypeReference ( identifiers , positions ) ; } else { return new ArrayQualifiedTypeReference ( identifiers , dim , positions ) ; } } } else { if ( nameFragmentStart > <NUM_LIT:0> && nameFragmentStart < length ) { char [ ] [ ] identifiers = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeName , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> ) ; fragments . add ( identifiers ) ; } int fragmentLength = fragments . size ( ) ; if ( fragmentLength == <NUM_LIT:2> ) { char [ ] [ ] firstFragment = ( char [ ] [ ] ) fragments . get ( <NUM_LIT:0> ) ; if ( firstFragment . length == <NUM_LIT:1> ) { return new ParameterizedSingleTypeReference ( firstFragment [ <NUM_LIT:0> ] , ( TypeReference [ ] ) fragments . get ( <NUM_LIT:1> ) , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } identCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { identCount += ( ( char [ ] [ ] ) element ) . length ; } } char [ ] [ ] tokens = new char [ identCount ] [ ] ; TypeReference [ ] [ ] arguments = new TypeReference [ identCount ] [ ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { char [ ] [ ] fragmentTokens = ( char [ ] [ ] ) element ; int fragmentTokenLength = fragmentTokens . length ; System . arraycopy ( fragmentTokens , <NUM_LIT:0> , tokens , index , fragmentTokenLength ) ; index += fragmentTokenLength ; } else { arguments [ index - <NUM_LIT:1> ] = ( TypeReference [ ] ) element ; } } long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } return new ParameterizedQualifiedTypeReference ( tokens , arguments , dim , positions ) ; } } private TypeReference [ ] decodeTypeArguments ( char [ ] typeName , int length , int start , int end , boolean includeGenericsAnyway ) { ArrayList argumentList = new ArrayList ( <NUM_LIT:1> ) ; int count = <NUM_LIT:0> ; argumentsLoop : while ( this . namePos < length ) { TypeReference argument = decodeType ( typeName , length , start , end , includeGenericsAnyway ) ; count ++ ; argumentList . add ( argument ) ; if ( this . namePos >= length ) break argumentsLoop ; if ( typeName [ this . namePos ] == '<CHAR_LIT:>>' ) { break argumentsLoop ; } this . namePos ++ ; } TypeReference [ ] typeArguments = new TypeReference [ count ] ; argumentList . toArray ( typeArguments ) ; return typeArguments ; } private TypeReference [ ] decodeTypeArguments ( String typeSignature , int length , int start , int end ) { ArrayList argumentList = new ArrayList ( <NUM_LIT:1> ) ; int count = <NUM_LIT:0> ; argumentsLoop : while ( this . namePos < length ) { TypeReference argument = decodeType ( typeSignature , length , start , end ) ; count ++ ; argumentList . add ( argument ) ; if ( this . namePos >= length ) break argumentsLoop ; if ( typeSignature . charAt ( this . namePos ) == Signature . C_GENERIC_END ) { break argumentsLoop ; } } TypeReference [ ] typeArguments = new TypeReference [ count ] ; argumentList . toArray ( typeArguments ) ; return typeArguments ; } private char [ ] [ ] extractIdentifiers ( String typeSignature , int start , int endInclusive , int identCount ) { char [ ] [ ] result = new char [ identCount ] [ ] ; int charIndex = start ; int i = <NUM_LIT:0> ; while ( charIndex < endInclusive ) { char currentChar ; if ( ( currentChar = typeSignature . charAt ( charIndex ) ) == this . memberTypeSeparator || currentChar == Signature . C_DOT ) { typeSignature . getChars ( start , charIndex , result [ i ++ ] = new char [ charIndex - start ] , <NUM_LIT:0> ) ; start = ++ charIndex ; } else charIndex ++ ; } typeSignature . getChars ( start , charIndex + <NUM_LIT:1> , result [ i ++ ] = new char [ charIndex - start + <NUM_LIT:1> ] , <NUM_LIT:0> ) ; return result ; } } </s>
<s> package org . eclipse . jdt . internal . compiler . parser ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . jdt . core . IAnnotatable ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IImportDeclaration ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Annotation ; import org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ; import org . eclipse . jdt . internal . compiler . ast . Block ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . Statement ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . env . ISourceImport ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . CompilationUnitElementInfo ; import org . eclipse . jdt . internal . core . ImportDeclaration ; import org . eclipse . jdt . internal . core . InitializerElementInfo ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . SourceAnnotationMethodInfo ; import org . eclipse . jdt . internal . core . SourceField ; import org . eclipse . jdt . internal . core . SourceFieldElementInfo ; import org . eclipse . jdt . internal . core . SourceMethod ; import org . eclipse . jdt . internal . core . SourceMethodElementInfo ; import org . eclipse . jdt . internal . core . SourceType ; import org . eclipse . jdt . internal . core . SourceTypeElementInfo ; import org . eclipse . jdt . internal . core . util . Util ; public class SourceTypeConverter extends TypeConverter { static class AnonymousMemberFound extends RuntimeException { private static final long serialVersionUID = <NUM_LIT:1L> ; } public static final int FIELD = <NUM_LIT> ; public static final int CONSTRUCTOR = <NUM_LIT> ; public static final int METHOD = <NUM_LIT> ; public static final int MEMBER_TYPE = <NUM_LIT> ; public static final int FIELD_INITIALIZATION = <NUM_LIT> ; public static final int FIELD_AND_METHOD = FIELD | CONSTRUCTOR | METHOD ; public static final int LOCAL_TYPE = <NUM_LIT> ; public static final int NONE = <NUM_LIT:0> ; private int flags ; private CompilationUnitDeclaration unit ; private Parser parser ; private ICompilationUnit cu ; private char [ ] source ; private SourceTypeConverter ( int flags , ProblemReporter problemReporter ) { super ( problemReporter , Signature . C_DOT ) ; this . flags = flags ; } public static CompilationUnitDeclaration buildCompilationUnit ( ISourceType [ ] sourceTypes , int flags , ProblemReporter problemReporter , CompilationResult compilationResult ) { SourceTypeConverter converter = new SourceTypeConverter ( flags , problemReporter ) ; try { return converter . convert ( sourceTypes , compilationResult ) ; } catch ( JavaModelException e ) { return null ; } } private CompilationUnitDeclaration convert ( ISourceType [ ] sourceTypes , CompilationResult compilationResult ) throws JavaModelException { this . unit = LanguageSupportFactory . newCompilationUnitDeclaration ( ( ICompilationUnit ) ( ( SourceTypeElementInfo ) sourceTypes [ <NUM_LIT:0> ] ) . getHandle ( ) . getCompilationUnit ( ) , this . problemReporter , compilationResult , <NUM_LIT:0> ) ; if ( sourceTypes . length == <NUM_LIT:0> ) return this . unit ; SourceTypeElementInfo topLevelTypeInfo = ( SourceTypeElementInfo ) sourceTypes [ <NUM_LIT:0> ] ; org . eclipse . jdt . core . ICompilationUnit cuHandle = topLevelTypeInfo . getHandle ( ) . getCompilationUnit ( ) ; this . cu = ( ICompilationUnit ) cuHandle ; if ( LanguageSupportFactory . isInterestingSourceFile ( new String ( compilationResult . getFileName ( ) ) ) ) { try { return LanguageSupportFactory . getParser ( this , this . problemReporter . options , this . problemReporter , true , <NUM_LIT:3> ) . dietParse ( this . cu , compilationResult ) ; } catch ( Throwable t ) { t . printStackTrace ( ) ; } } if ( this . has1_5Compliance && ( ( CompilationUnitElementInfo ) ( ( JavaElement ) this . cu ) . getElementInfo ( ) ) . annotationNumber > <NUM_LIT:10> ) { if ( ( this . flags & LOCAL_TYPE ) == <NUM_LIT:0> ) { return new Parser ( this . problemReporter , true ) . dietParse ( this . cu , compilationResult ) ; } } int start = topLevelTypeInfo . getNameSourceStart ( ) ; int end = topLevelTypeInfo . getNameSourceEnd ( ) ; String [ ] packageName = ( ( PackageFragment ) cuHandle . getParent ( ) ) . names ; if ( packageName . length > <NUM_LIT:0> ) this . unit . currentPackage = createImportReference ( packageName , start , end , false , ClassFileConstants . AccDefault ) ; IImportDeclaration [ ] importDeclarations = topLevelTypeInfo . getHandle ( ) . getCompilationUnit ( ) . getImports ( ) ; int importCount = importDeclarations . length ; this . unit . imports = new ImportReference [ importCount ] ; for ( int i = <NUM_LIT:0> ; i < importCount ; i ++ ) { ImportDeclaration importDeclaration = ( ImportDeclaration ) importDeclarations [ i ] ; ISourceImport sourceImport = ( ISourceImport ) importDeclaration . getElementInfo ( ) ; String nameWithoutStar = importDeclaration . getNameWithoutStar ( ) ; this . unit . imports [ i ] = createImportReference ( Util . splitOn ( '<CHAR_LIT:.>' , nameWithoutStar , <NUM_LIT:0> , nameWithoutStar . length ( ) ) , sourceImport . getDeclarationSourceStart ( ) , sourceImport . getDeclarationSourceEnd ( ) , importDeclaration . isOnDemand ( ) , sourceImport . getModifiers ( ) ) ; } try { int typeCount = sourceTypes . length ; final TypeDeclaration [ ] types = new TypeDeclaration [ typeCount ] ; for ( int i = <NUM_LIT:0> ; i < typeCount ; i ++ ) { SourceTypeElementInfo typeInfo = ( SourceTypeElementInfo ) sourceTypes [ i ] ; types [ i ] = convert ( ( SourceType ) typeInfo . getHandle ( ) , compilationResult ) ; } this . unit . types = types ; return this . unit ; } catch ( AnonymousMemberFound e ) { return new Parser ( this . problemReporter , true ) . parse ( this . cu , compilationResult ) ; } } private Initializer convert ( InitializerElementInfo initializerInfo , CompilationResult compilationResult ) throws JavaModelException { Block block = new Block ( <NUM_LIT:0> ) ; Initializer initializer = new Initializer ( block , ClassFileConstants . AccDefault ) ; int start = initializerInfo . getDeclarationSourceStart ( ) ; int end = initializerInfo . getDeclarationSourceEnd ( ) ; initializer . sourceStart = initializer . declarationSourceStart = start ; initializer . sourceEnd = initializer . declarationSourceEnd = end ; initializer . modifiers = initializerInfo . getModifiers ( ) ; IJavaElement [ ] children = initializerInfo . getChildren ( ) ; int typesLength = children . length ; if ( typesLength > <NUM_LIT:0> ) { Statement [ ] statements = new Statement [ typesLength ] ; for ( int i = <NUM_LIT:0> ; i < typesLength ; i ++ ) { SourceType type = ( SourceType ) children [ i ] ; TypeDeclaration localType = convert ( type , compilationResult ) ; if ( ( localType . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression expression = new QualifiedAllocationExpression ( localType ) ; expression . type = localType . superclass ; localType . superclass = null ; localType . superInterfaces = null ; localType . allocation = expression ; statements [ i ] = expression ; } else { statements [ i ] = localType ; } } block . statements = statements ; } return initializer ; } private FieldDeclaration convert ( SourceField fieldHandle , TypeDeclaration type , CompilationResult compilationResult ) throws JavaModelException { SourceFieldElementInfo fieldInfo = ( SourceFieldElementInfo ) fieldHandle . getElementInfo ( ) ; FieldDeclaration field = new FieldDeclaration ( ) ; int start = fieldInfo . getNameSourceStart ( ) ; int end = fieldInfo . getNameSourceEnd ( ) ; field . name = fieldHandle . getElementName ( ) . toCharArray ( ) ; field . sourceStart = start ; field . sourceEnd = end ; field . declarationSourceStart = fieldInfo . getDeclarationSourceStart ( ) ; field . declarationSourceEnd = fieldInfo . getDeclarationSourceEnd ( ) ; int modifiers = fieldInfo . getModifiers ( ) ; boolean isEnumConstant = ( modifiers & ClassFileConstants . AccEnum ) != <NUM_LIT:0> ; if ( isEnumConstant ) { field . modifiers = modifiers & ~ ClassFileConstants . AccEnum ; } else { field . modifiers = modifiers ; field . type = createTypeReference ( fieldInfo . getTypeName ( ) , start , end ) ; } if ( this . has1_5Compliance ) { field . annotations = convertAnnotations ( fieldHandle ) ; } if ( ( this . flags & FIELD_INITIALIZATION ) != <NUM_LIT:0> ) { char [ ] initializationSource = fieldInfo . getInitializationSource ( ) ; if ( initializationSource != null ) { if ( this . parser == null ) { this . parser = new Parser ( this . problemReporter , true ) ; } this . parser . parse ( field , type , this . unit , initializationSource ) ; } } if ( ( this . flags & LOCAL_TYPE ) != <NUM_LIT:0> ) { IJavaElement [ ] children = fieldInfo . getChildren ( ) ; int childrenLength = children . length ; if ( childrenLength == <NUM_LIT:1> ) { field . initialization = convert ( children [ <NUM_LIT:0> ] , isEnumConstant ? field : null , compilationResult ) ; } else if ( childrenLength > <NUM_LIT:1> ) { ArrayInitializer initializer = new ArrayInitializer ( ) ; field . initialization = initializer ; Expression [ ] expressions = new Expression [ childrenLength ] ; initializer . expressions = expressions ; for ( int i = <NUM_LIT:0> ; i < childrenLength ; i ++ ) { expressions [ i ] = convert ( children [ i ] , isEnumConstant ? field : null , compilationResult ) ; } } } return field ; } private QualifiedAllocationExpression convert ( IJavaElement localType , FieldDeclaration enumConstant , CompilationResult compilationResult ) throws JavaModelException { TypeDeclaration anonymousLocalTypeDeclaration = convert ( ( SourceType ) localType , compilationResult ) ; QualifiedAllocationExpression expression = new QualifiedAllocationExpression ( anonymousLocalTypeDeclaration ) ; expression . type = anonymousLocalTypeDeclaration . superclass ; anonymousLocalTypeDeclaration . superclass = null ; anonymousLocalTypeDeclaration . superInterfaces = null ; anonymousLocalTypeDeclaration . allocation = expression ; if ( enumConstant != null ) { anonymousLocalTypeDeclaration . modifiers &= ~ ClassFileConstants . AccEnum ; expression . enumConstant = enumConstant ; expression . type = null ; } return expression ; } private AbstractMethodDeclaration convert ( SourceMethod methodHandle , SourceMethodElementInfo methodInfo , CompilationResult compilationResult ) throws JavaModelException { AbstractMethodDeclaration method ; int start = methodInfo . getNameSourceStart ( ) ; int end = methodInfo . getNameSourceEnd ( ) ; TypeParameter [ ] typeParams = null ; char [ ] [ ] typeParameterNames = methodInfo . getTypeParameterNames ( ) ; if ( typeParameterNames != null ) { int parameterCount = typeParameterNames . length ; if ( parameterCount > <NUM_LIT:0> ) { char [ ] [ ] [ ] typeParameterBounds = methodInfo . getTypeParameterBounds ( ) ; typeParams = new TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { typeParams [ i ] = createTypeParameter ( typeParameterNames [ i ] , typeParameterBounds [ i ] , start , end ) ; } } } int modifiers = methodInfo . getModifiers ( ) ; if ( methodInfo . isConstructor ( ) ) { ConstructorDeclaration decl = new ConstructorDeclaration ( compilationResult ) ; decl . bits &= ~ ASTNode . IsDefaultConstructor ; method = decl ; decl . typeParameters = typeParams ; } else { MethodDeclaration decl ; if ( methodInfo . isAnnotationMethod ( ) ) { AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration ( compilationResult ) ; SourceAnnotationMethodInfo annotationMethodInfo = ( SourceAnnotationMethodInfo ) methodInfo ; boolean hasDefaultValue = annotationMethodInfo . defaultValueStart != - <NUM_LIT:1> || annotationMethodInfo . defaultValueEnd != - <NUM_LIT:1> ; if ( ( this . flags & FIELD_INITIALIZATION ) != <NUM_LIT:0> ) { if ( hasDefaultValue ) { char [ ] defaultValueSource = CharOperation . subarray ( getSource ( ) , annotationMethodInfo . defaultValueStart , annotationMethodInfo . defaultValueEnd + <NUM_LIT:1> ) ; if ( defaultValueSource != null ) { Expression expression = parseMemberValue ( defaultValueSource ) ; if ( expression != null ) { annotationMethodDeclaration . defaultValue = expression ; } } else { hasDefaultValue = false ; } } } if ( hasDefaultValue ) modifiers |= ClassFileConstants . AccAnnotationDefault ; decl = annotationMethodDeclaration ; } else { decl = new MethodDeclaration ( compilationResult ) ; } decl . returnType = createTypeReference ( methodInfo . getReturnTypeName ( ) , start , end ) ; decl . typeParameters = typeParams ; method = decl ; } method . selector = methodHandle . getElementName ( ) . toCharArray ( ) ; boolean isVarargs = ( modifiers & ClassFileConstants . AccVarargs ) != <NUM_LIT:0> ; method . modifiers = modifiers & ~ ClassFileConstants . AccVarargs ; method . sourceStart = start ; method . sourceEnd = end ; method . declarationSourceStart = methodInfo . getDeclarationSourceStart ( ) ; method . declarationSourceEnd = methodInfo . getDeclarationSourceEnd ( ) ; if ( this . has1_5Compliance ) { method . annotations = convertAnnotations ( methodHandle ) ; } String [ ] argumentTypeSignatures = methodHandle . getParameterTypes ( ) ; char [ ] [ ] argumentNames = methodInfo . getArgumentNames ( ) ; int argumentCount = argumentTypeSignatures == null ? <NUM_LIT:0> : argumentTypeSignatures . length ; if ( argumentCount > <NUM_LIT:0> ) { long position = ( ( long ) start << <NUM_LIT:32> ) + end ; method . arguments = new Argument [ argumentCount ] ; for ( int i = <NUM_LIT:0> ; i < argumentCount ; i ++ ) { TypeReference typeReference = createTypeReference ( argumentTypeSignatures [ i ] , start , end ) ; if ( isVarargs && i == argumentCount - <NUM_LIT:1> ) { typeReference . bits |= ASTNode . IsVarArgs ; } method . arguments [ i ] = new Argument ( argumentNames [ i ] , position , typeReference , ClassFileConstants . AccDefault ) ; } } char [ ] [ ] exceptionTypeNames = methodInfo . getExceptionTypeNames ( ) ; int exceptionCount = exceptionTypeNames == null ? <NUM_LIT:0> : exceptionTypeNames . length ; if ( exceptionCount > <NUM_LIT:0> ) { method . thrownExceptions = new TypeReference [ exceptionCount ] ; for ( int i = <NUM_LIT:0> ; i < exceptionCount ; i ++ ) { method . thrownExceptions [ i ] = createTypeReference ( exceptionTypeNames [ i ] , start , end ) ; } } if ( ( this . flags & LOCAL_TYPE ) != <NUM_LIT:0> ) { IJavaElement [ ] children = methodInfo . getChildren ( ) ; int typesLength = children . length ; if ( typesLength != <NUM_LIT:0> ) { Statement [ ] statements = new Statement [ typesLength ] ; for ( int i = <NUM_LIT:0> ; i < typesLength ; i ++ ) { SourceType type = ( SourceType ) children [ i ] ; TypeDeclaration localType = convert ( type , compilationResult ) ; if ( ( localType . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression expression = new QualifiedAllocationExpression ( localType ) ; expression . type = localType . superclass ; localType . superclass = null ; localType . superInterfaces = null ; localType . allocation = expression ; statements [ i ] = expression ; } else { statements [ i ] = localType ; } } method . statements = statements ; } } return method ; } private TypeDeclaration convert ( SourceType typeHandle , CompilationResult compilationResult ) throws JavaModelException { SourceTypeElementInfo typeInfo = ( SourceTypeElementInfo ) typeHandle . getElementInfo ( ) ; if ( typeInfo . isAnonymousMember ( ) ) throw new AnonymousMemberFound ( ) ; TypeDeclaration type = new TypeDeclaration ( compilationResult ) ; if ( typeInfo . getEnclosingType ( ) == null ) { if ( typeHandle . isAnonymous ( ) ) { type . name = CharOperation . NO_CHAR ; type . bits |= ( ASTNode . IsAnonymousType | ASTNode . IsLocalType ) ; } else { if ( typeHandle . isLocal ( ) ) { type . bits |= ASTNode . IsLocalType ; } } } else { type . bits |= ASTNode . IsMemberType ; } if ( ( type . bits & ASTNode . IsAnonymousType ) == <NUM_LIT:0> ) { type . name = typeInfo . getName ( ) ; } type . name = typeInfo . getName ( ) ; int start , end ; type . sourceStart = start = typeInfo . getNameSourceStart ( ) ; type . sourceEnd = end = typeInfo . getNameSourceEnd ( ) ; type . modifiers = typeInfo . getModifiers ( ) ; type . declarationSourceStart = typeInfo . getDeclarationSourceStart ( ) ; type . declarationSourceEnd = typeInfo . getDeclarationSourceEnd ( ) ; type . bodyEnd = type . declarationSourceEnd ; if ( this . has1_5Compliance ) { type . annotations = convertAnnotations ( typeHandle ) ; } char [ ] [ ] typeParameterNames = typeInfo . getTypeParameterNames ( ) ; if ( typeParameterNames . length > <NUM_LIT:0> ) { int parameterCount = typeParameterNames . length ; char [ ] [ ] [ ] typeParameterBounds = typeInfo . getTypeParameterBounds ( ) ; type . typeParameters = new TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { type . typeParameters [ i ] = createTypeParameter ( typeParameterNames [ i ] , typeParameterBounds [ i ] , start , end ) ; } } if ( typeInfo . getSuperclassName ( ) != null ) { type . superclass = createTypeReference ( typeInfo . getSuperclassName ( ) , start , end , true ) ; type . superclass . bits |= ASTNode . IsSuperType ; } char [ ] [ ] interfaceNames = typeInfo . getInterfaceNames ( ) ; int interfaceCount = interfaceNames == null ? <NUM_LIT:0> : interfaceNames . length ; if ( interfaceCount > <NUM_LIT:0> ) { type . superInterfaces = new TypeReference [ interfaceCount ] ; for ( int i = <NUM_LIT:0> ; i < interfaceCount ; i ++ ) { type . superInterfaces [ i ] = createTypeReference ( interfaceNames [ i ] , start , end , true ) ; type . superInterfaces [ i ] . bits |= ASTNode . IsSuperType ; } } if ( ( this . flags & MEMBER_TYPE ) != <NUM_LIT:0> ) { SourceType [ ] sourceMemberTypes = typeInfo . getMemberTypeHandles ( ) ; int sourceMemberTypeCount = sourceMemberTypes . length ; type . memberTypes = new TypeDeclaration [ sourceMemberTypeCount ] ; for ( int i = <NUM_LIT:0> ; i < sourceMemberTypeCount ; i ++ ) { type . memberTypes [ i ] = convert ( sourceMemberTypes [ i ] , compilationResult ) ; type . memberTypes [ i ] . enclosingType = type ; } } InitializerElementInfo [ ] initializers = null ; int initializerCount = <NUM_LIT:0> ; if ( ( this . flags & LOCAL_TYPE ) != <NUM_LIT:0> ) { initializers = typeInfo . getInitializers ( ) ; initializerCount = initializers . length ; } SourceField [ ] sourceFields = null ; int sourceFieldCount = <NUM_LIT:0> ; if ( ( this . flags & FIELD ) != <NUM_LIT:0> ) { sourceFields = typeInfo . getFieldHandles ( ) ; sourceFieldCount = sourceFields . length ; } int length = initializerCount + sourceFieldCount ; if ( length > <NUM_LIT:0> ) { type . fields = new FieldDeclaration [ length ] ; for ( int i = <NUM_LIT:0> ; i < initializerCount ; i ++ ) { type . fields [ i ] = convert ( initializers [ i ] , compilationResult ) ; } int index = <NUM_LIT:0> ; for ( int i = initializerCount ; i < length ; i ++ ) { type . fields [ i ] = convert ( sourceFields [ index ++ ] , type , compilationResult ) ; } } boolean needConstructor = ( this . flags & CONSTRUCTOR ) != <NUM_LIT:0> ; boolean needMethod = ( this . flags & METHOD ) != <NUM_LIT:0> ; if ( needConstructor || needMethod ) { SourceMethod [ ] sourceMethods = typeInfo . getMethodHandles ( ) ; int sourceMethodCount = sourceMethods . length ; int extraConstructor = <NUM_LIT:0> ; int methodCount = <NUM_LIT:0> ; int kind = TypeDeclaration . kind ( type . modifiers ) ; boolean isAbstract = kind == TypeDeclaration . INTERFACE_DECL || kind == TypeDeclaration . ANNOTATION_TYPE_DECL ; if ( ! isAbstract ) { extraConstructor = needConstructor ? <NUM_LIT:1> : <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < sourceMethodCount ; i ++ ) { if ( sourceMethods [ i ] . isConstructor ( ) ) { if ( needConstructor ) { extraConstructor = <NUM_LIT:0> ; methodCount ++ ; } } else if ( needMethod ) { methodCount ++ ; } } } else { methodCount = needMethod ? sourceMethodCount : <NUM_LIT:0> ; } type . methods = new AbstractMethodDeclaration [ methodCount + extraConstructor ] ; if ( extraConstructor != <NUM_LIT:0> ) { type . methods [ <NUM_LIT:0> ] = type . createDefaultConstructor ( false , false ) ; } int index = <NUM_LIT:0> ; boolean hasAbstractMethods = false ; for ( int i = <NUM_LIT:0> ; i < sourceMethodCount ; i ++ ) { SourceMethod sourceMethod = sourceMethods [ i ] ; SourceMethodElementInfo methodInfo = ( SourceMethodElementInfo ) sourceMethod . getElementInfo ( ) ; boolean isConstructor = methodInfo . isConstructor ( ) ; if ( ( methodInfo . getModifiers ( ) & ClassFileConstants . AccAbstract ) != <NUM_LIT:0> ) { hasAbstractMethods = true ; } if ( ( isConstructor && needConstructor ) || ( ! isConstructor && needMethod ) ) { AbstractMethodDeclaration method = convert ( sourceMethod , methodInfo , compilationResult ) ; if ( isAbstract || method . isAbstract ( ) ) { method . modifiers |= ExtraCompilerModifiers . AccSemicolonBody ; } type . methods [ extraConstructor + index ++ ] = method ; } } if ( hasAbstractMethods ) type . bits |= ASTNode . HasAbstractMethods ; } return type ; } private Annotation [ ] convertAnnotations ( IAnnotatable element ) throws JavaModelException { IAnnotation [ ] annotations = element . getAnnotations ( ) ; int length = annotations . length ; Annotation [ ] astAnnotations = new Annotation [ length ] ; if ( length > <NUM_LIT:0> ) { char [ ] cuSource = getSource ( ) ; int recordedAnnotations = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ISourceRange positions = annotations [ i ] . getSourceRange ( ) ; int start = positions . getOffset ( ) ; int end = start + positions . getLength ( ) ; char [ ] annotationSource = CharOperation . subarray ( cuSource , start , end ) ; if ( annotationSource != null ) { Expression expression = parseMemberValue ( annotationSource ) ; if ( expression instanceof Annotation ) { astAnnotations [ recordedAnnotations ++ ] = ( Annotation ) expression ; } } } if ( length != recordedAnnotations ) { System . arraycopy ( astAnnotations , <NUM_LIT:0> , ( astAnnotations = new Annotation [ recordedAnnotations ] ) , <NUM_LIT:0> , recordedAnnotations ) ; } } return astAnnotations ; } private char [ ] getSource ( ) { if ( this . source == null ) this . source = this . cu . getContents ( ) ; return this . source ; } private Expression parseMemberValue ( char [ ] memberValue ) { if ( this . parser == null ) { this . parser = new Parser ( this . problemReporter , true ) ; } return this . parser . parseMemberValue ( memberValue , <NUM_LIT:0> , memberValue . length , this . unit ) ; } } </s>
<s> package org . eclipse . jdt . internal . compiler ; import java . util . HashMap ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Annotation ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; public interface ISourceElementRequestor { public static class TypeInfo { public int declarationStart ; public int modifiers ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] superclass ; public char [ ] [ ] superinterfaces ; public TypeParameterInfo [ ] typeParameters ; public char [ ] [ ] categories ; public boolean secondary ; public boolean anonymousMember ; public Annotation [ ] annotations ; public int extraFlags ; public TypeDeclaration node ; public HashMap childrenCategories = new HashMap ( ) ; } public static class TypeParameterInfo { public int declarationStart ; public int declarationEnd ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] [ ] bounds ; } public static class MethodInfo { public boolean isConstructor ; public boolean isAnnotation ; public int declarationStart ; public int modifiers ; public char [ ] returnType ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] [ ] parameterTypes ; public char [ ] [ ] parameterNames ; public char [ ] [ ] exceptionTypes ; public TypeParameterInfo [ ] typeParameters ; public char [ ] [ ] categories ; public Annotation [ ] annotations ; public char [ ] declaringPackageName ; public int declaringTypeModifiers ; public int extraFlags ; public AbstractMethodDeclaration node ; public ParameterInfo [ ] parameterInfos ; } public static class ParameterInfo { public int modifiers ; public int declarationStart ; public int declarationEnd ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] name ; } public static class FieldInfo { public int declarationStart ; public int modifiers ; public char [ ] type ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] [ ] categories ; public Annotation [ ] annotations ; public FieldDeclaration node ; } void acceptAnnotationTypeReference ( char [ ] [ ] annotation , int sourceStart , int sourceEnd ) ; void acceptAnnotationTypeReference ( char [ ] annotation , int sourcePosition ) ; void acceptConstructorReference ( char [ ] typeName , int argCount , int sourcePosition ) ; void acceptFieldReference ( char [ ] fieldName , int sourcePosition ) ; void acceptImport ( int declarationStart , int declarationEnd , int nameStart , int nameEnd , char [ ] [ ] tokens , boolean onDemand , int modifiers ) ; void acceptLineSeparatorPositions ( int [ ] positions ) ; void acceptMethodReference ( char [ ] methodName , int argCount , int sourcePosition ) ; void acceptPackage ( ImportReference importReference ) ; void acceptProblem ( CategorizedProblem problem ) ; void acceptTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) ; void acceptTypeReference ( char [ ] typeName , int sourcePosition ) ; void acceptUnknownReference ( char [ ] [ ] name , int sourceStart , int sourceEnd ) ; void acceptUnknownReference ( char [ ] name , int sourcePosition ) ; void enterCompilationUnit ( ) ; void enterConstructor ( MethodInfo methodInfo ) ; void enterField ( FieldInfo fieldInfo ) ; void enterInitializer ( int declarationStart , int modifiers ) ; void enterMethod ( MethodInfo methodInfo ) ; void enterType ( TypeInfo typeInfo ) ; void exitCompilationUnit ( int declarationEnd ) ; void exitConstructor ( int declarationEnd ) ; void exitField ( int initializationStart , int declarationEnd , int declarationSourceEnd ) ; void exitInitializer ( int declarationEnd ) ; void exitMethod ( int declarationEnd , Expression defaultValue ) ; void exitType ( int declarationEnd ) ; } </s>
<s> package org . eclipse . jdt . internal . compiler ; import java . util . ArrayList ; import java . util . Map ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor . ParameterInfo ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor . TypeParameterInfo ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AbstractVariableDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . Annotation ; import org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ; import org . eclipse . jdt . internal . compiler . ast . ArrayReference ; import org . eclipse . jdt . internal . compiler . ast . Assignment ; import org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ThisReference ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; public class SourceElementNotifier { public class LocalDeclarationVisitor extends ASTVisitor { public ImportReference currentPackage ; ArrayList declaringTypes ; public void pushDeclaringType ( TypeDeclaration declaringType ) { if ( this . declaringTypes == null ) { this . declaringTypes = new ArrayList ( ) ; } this . declaringTypes . add ( declaringType ) ; } public void popDeclaringType ( ) { this . declaringTypes . remove ( this . declaringTypes . size ( ) - <NUM_LIT:1> ) ; } public TypeDeclaration peekDeclaringType ( ) { if ( this . declaringTypes == null ) return null ; int size = this . declaringTypes . size ( ) ; if ( size == <NUM_LIT:0> ) return null ; return ( TypeDeclaration ) this . declaringTypes . get ( size - <NUM_LIT:1> ) ; } public boolean visit ( TypeDeclaration typeDeclaration , BlockScope scope ) { notifySourceElementRequestor ( typeDeclaration , true , peekDeclaringType ( ) , this . currentPackage ) ; return false ; } public boolean visit ( TypeDeclaration typeDeclaration , ClassScope scope ) { notifySourceElementRequestor ( typeDeclaration , true , peekDeclaringType ( ) , this . currentPackage ) ; return false ; } } ISourceElementRequestor requestor ; boolean reportReferenceInfo ; char [ ] [ ] typeNames ; char [ ] [ ] superTypeNames ; int nestedTypeIndex ; LocalDeclarationVisitor localDeclarationVisitor = null ; HashtableOfObjectToInt sourceEnds ; Map nodesToCategories ; int initialPosition ; int eofPosition ; public SourceElementNotifier ( ISourceElementRequestor requestor , boolean reportLocalDeclarations ) { this . requestor = requestor ; if ( reportLocalDeclarations ) { this . localDeclarationVisitor = new LocalDeclarationVisitor ( ) ; } this . typeNames = new char [ <NUM_LIT:4> ] [ ] ; this . superTypeNames = new char [ <NUM_LIT:4> ] [ ] ; this . nestedTypeIndex = <NUM_LIT:0> ; } protected Object [ ] [ ] getArgumentInfos ( Argument [ ] arguments ) { int argumentLength = arguments . length ; char [ ] [ ] argumentTypes = new char [ argumentLength ] [ ] ; char [ ] [ ] argumentNames = new char [ argumentLength ] [ ] ; ParameterInfo [ ] parameterInfos = new ParameterInfo [ argumentLength ] ; for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { Argument argument = arguments [ i ] ; argumentTypes [ i ] = CharOperation . concatWith ( argument . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; char [ ] name = argument . name ; argumentNames [ i ] = name ; ParameterInfo parameterInfo = new ParameterInfo ( ) ; parameterInfo . declarationStart = argument . declarationSourceStart ; parameterInfo . declarationEnd = argument . declarationSourceEnd ; parameterInfo . nameSourceStart = argument . sourceStart ; parameterInfo . nameSourceEnd = argument . sourceEnd ; parameterInfo . modifiers = argument . modifiers ; parameterInfo . name = name ; parameterInfos [ i ] = parameterInfo ; } return new Object [ ] [ ] { parameterInfos , new char [ ] [ ] [ ] { argumentTypes , argumentNames } } ; } protected char [ ] [ ] getInterfaceNames ( TypeDeclaration typeDeclaration ) { char [ ] [ ] interfaceNames = null ; int superInterfacesLength = <NUM_LIT:0> ; TypeReference [ ] superInterfaces = typeDeclaration . superInterfaces ; if ( superInterfaces != null ) { superInterfacesLength = superInterfaces . length ; interfaceNames = new char [ superInterfacesLength ] [ ] ; } else { if ( ( typeDeclaration . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression alloc = typeDeclaration . allocation ; if ( alloc != null && alloc . type != null ) { superInterfaces = new TypeReference [ ] { alloc . type } ; superInterfacesLength = <NUM_LIT:1> ; interfaceNames = new char [ <NUM_LIT:1> ] [ ] ; } } } if ( superInterfaces != null ) { for ( int i = <NUM_LIT:0> ; i < superInterfacesLength ; i ++ ) { interfaceNames [ i ] = CharOperation . concatWith ( superInterfaces [ i ] . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } } return interfaceNames ; } protected char [ ] getSuperclassName ( TypeDeclaration typeDeclaration ) { TypeReference superclass = typeDeclaration . superclass ; return superclass != null ? CharOperation . concatWith ( superclass . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) : null ; } protected char [ ] [ ] getThrownExceptions ( AbstractMethodDeclaration methodDeclaration ) { char [ ] [ ] thrownExceptionTypes = null ; TypeReference [ ] thrownExceptions = methodDeclaration . thrownExceptions ; if ( thrownExceptions != null ) { int thrownExceptionLength = thrownExceptions . length ; thrownExceptionTypes = new char [ thrownExceptionLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < thrownExceptionLength ; i ++ ) { thrownExceptionTypes [ i ] = CharOperation . concatWith ( thrownExceptions [ i ] . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } } return thrownExceptionTypes ; } protected char [ ] [ ] getTypeParameterBounds ( TypeParameter typeParameter ) { TypeReference firstBound = typeParameter . type ; TypeReference [ ] otherBounds = typeParameter . bounds ; char [ ] [ ] typeParameterBounds = null ; if ( firstBound != null ) { if ( otherBounds != null ) { int otherBoundsLength = otherBounds . length ; char [ ] [ ] boundNames = new char [ otherBoundsLength + <NUM_LIT:1> ] [ ] ; boundNames [ <NUM_LIT:0> ] = CharOperation . concatWith ( firstBound . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; for ( int j = <NUM_LIT:0> ; j < otherBoundsLength ; j ++ ) { boundNames [ j + <NUM_LIT:1> ] = CharOperation . concatWith ( otherBounds [ j ] . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } typeParameterBounds = boundNames ; } else { typeParameterBounds = new char [ ] [ ] { CharOperation . concatWith ( firstBound . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) } ; } } else { typeParameterBounds = CharOperation . NO_CHAR_CHAR ; } return typeParameterBounds ; } private TypeParameterInfo [ ] getTypeParameterInfos ( TypeParameter [ ] typeParameters ) { if ( typeParameters == null ) return null ; int typeParametersLength = typeParameters . length ; TypeParameterInfo [ ] result = new TypeParameterInfo [ typeParametersLength ] ; for ( int i = <NUM_LIT:0> ; i < typeParametersLength ; i ++ ) { TypeParameter typeParameter = typeParameters [ i ] ; char [ ] [ ] typeParameterBounds = getTypeParameterBounds ( typeParameter ) ; ISourceElementRequestor . TypeParameterInfo typeParameterInfo = new ISourceElementRequestor . TypeParameterInfo ( ) ; typeParameterInfo . declarationStart = typeParameter . declarationSourceStart ; typeParameterInfo . declarationEnd = typeParameter . declarationSourceEnd ; typeParameterInfo . name = typeParameter . name ; typeParameterInfo . nameSourceStart = typeParameter . sourceStart ; typeParameterInfo . nameSourceEnd = typeParameter . sourceEnd ; typeParameterInfo . bounds = typeParameterBounds ; result [ i ] = typeParameterInfo ; } return result ; } private boolean hasDeprecatedAnnotation ( Annotation [ ] annotations ) { if ( annotations != null ) { for ( int i = <NUM_LIT:0> , length = annotations . length ; i < length ; i ++ ) { Annotation annotation = annotations [ i ] ; if ( CharOperation . equals ( annotation . type . getLastToken ( ) , TypeConstants . JAVA_LANG_DEPRECATED [ <NUM_LIT:2> ] ) ) { return true ; } } } return false ; } protected void notifySourceElementRequestor ( AbstractMethodDeclaration methodDeclaration , TypeDeclaration declaringType , ImportReference currentPackage ) { boolean isInRange = this . initialPosition <= methodDeclaration . declarationSourceStart && this . eofPosition >= methodDeclaration . declarationSourceEnd ; if ( methodDeclaration . isClinit ( ) ) { this . visitIfNeeded ( methodDeclaration ) ; return ; } if ( methodDeclaration . isDefaultConstructor ( ) ) { if ( this . reportReferenceInfo ) { ConstructorDeclaration constructorDeclaration = ( ConstructorDeclaration ) methodDeclaration ; ExplicitConstructorCall constructorCall = constructorDeclaration . constructorCall ; if ( constructorCall != null ) { switch ( constructorCall . accessMode ) { case ExplicitConstructorCall . This : this . requestor . acceptConstructorReference ( this . typeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; case ExplicitConstructorCall . Super : case ExplicitConstructorCall . ImplicitSuper : this . requestor . acceptConstructorReference ( this . superTypeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; } } } return ; } char [ ] [ ] argumentTypes = null ; char [ ] [ ] argumentNames = null ; boolean isVarArgs = false ; Argument [ ] arguments = methodDeclaration . arguments ; ParameterInfo [ ] parameterInfos = null ; if ( arguments != null ) { Object [ ] [ ] argumentInfos = getArgumentInfos ( arguments ) ; parameterInfos = ( ParameterInfo [ ] ) argumentInfos [ <NUM_LIT:0> ] ; argumentTypes = ( char [ ] [ ] ) argumentInfos [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ; argumentNames = ( char [ ] [ ] ) argumentInfos [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ; isVarArgs = arguments [ arguments . length - <NUM_LIT:1> ] . isVarArgs ( ) ; } char [ ] [ ] thrownExceptionTypes = getThrownExceptions ( methodDeclaration ) ; int selectorSourceEnd = - <NUM_LIT:1> ; if ( methodDeclaration . isConstructor ( ) ) { selectorSourceEnd = this . sourceEnds . get ( methodDeclaration ) ; if ( isInRange ) { int currentModifiers = methodDeclaration . modifiers ; if ( isVarArgs ) currentModifiers |= ClassFileConstants . AccVarargs ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( methodDeclaration . annotations ) ; ISourceElementRequestor . MethodInfo methodInfo = new ISourceElementRequestor . MethodInfo ( ) ; methodInfo . isConstructor = true ; methodInfo . declarationStart = methodDeclaration . declarationSourceStart ; methodInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; methodInfo . name = methodDeclaration . selector ; methodInfo . nameSourceStart = methodDeclaration . sourceStart ; methodInfo . nameSourceEnd = selectorSourceEnd ; methodInfo . parameterTypes = argumentTypes ; methodInfo . parameterNames = argumentNames ; methodInfo . exceptionTypes = thrownExceptionTypes ; methodInfo . typeParameters = getTypeParameterInfos ( methodDeclaration . typeParameters ( ) ) ; methodInfo . parameterInfos = parameterInfos ; methodInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( methodDeclaration ) ; methodInfo . annotations = methodDeclaration . annotations ; methodInfo . declaringPackageName = currentPackage == null ? CharOperation . NO_CHAR : CharOperation . concatWith ( currentPackage . tokens , '<CHAR_LIT:.>' ) ; methodInfo . declaringTypeModifiers = declaringType . modifiers ; methodInfo . extraFlags = ExtraFlags . getExtraFlags ( declaringType ) ; methodInfo . node = methodDeclaration ; this . requestor . enterConstructor ( methodInfo ) ; } if ( this . reportReferenceInfo ) { ConstructorDeclaration constructorDeclaration = ( ConstructorDeclaration ) methodDeclaration ; ExplicitConstructorCall constructorCall = constructorDeclaration . constructorCall ; if ( constructorCall != null ) { switch ( constructorCall . accessMode ) { case ExplicitConstructorCall . This : this . requestor . acceptConstructorReference ( this . typeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; case ExplicitConstructorCall . Super : case ExplicitConstructorCall . ImplicitSuper : this . requestor . acceptConstructorReference ( this . superTypeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; } } } this . visitIfNeeded ( methodDeclaration ) ; if ( isInRange ) { this . requestor . exitConstructor ( methodDeclaration . declarationSourceEnd ) ; } return ; } selectorSourceEnd = this . sourceEnds . get ( methodDeclaration ) ; if ( isInRange ) { int currentModifiers = methodDeclaration . modifiers ; if ( isVarArgs ) currentModifiers |= ClassFileConstants . AccVarargs ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( methodDeclaration . annotations ) ; TypeReference returnType = methodDeclaration instanceof MethodDeclaration ? ( ( MethodDeclaration ) methodDeclaration ) . returnType : null ; ISourceElementRequestor . MethodInfo methodInfo = new ISourceElementRequestor . MethodInfo ( ) ; methodInfo . isAnnotation = methodDeclaration instanceof AnnotationMethodDeclaration ; methodInfo . declarationStart = methodDeclaration . declarationSourceStart ; methodInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; methodInfo . returnType = returnType == null ? null : CharOperation . concatWith ( returnType . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; methodInfo . name = methodDeclaration . selector ; methodInfo . nameSourceStart = methodDeclaration . sourceStart ; methodInfo . nameSourceEnd = selectorSourceEnd ; methodInfo . parameterTypes = argumentTypes ; methodInfo . parameterNames = argumentNames ; methodInfo . exceptionTypes = thrownExceptionTypes ; methodInfo . typeParameters = getTypeParameterInfos ( methodDeclaration . typeParameters ( ) ) ; methodInfo . parameterInfos = parameterInfos ; methodInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( methodDeclaration ) ; methodInfo . annotations = methodDeclaration . annotations ; methodInfo . node = methodDeclaration ; this . requestor . enterMethod ( methodInfo ) ; } this . visitIfNeeded ( methodDeclaration ) ; if ( isInRange ) { if ( methodDeclaration instanceof AnnotationMethodDeclaration ) { AnnotationMethodDeclaration annotationMethodDeclaration = ( AnnotationMethodDeclaration ) methodDeclaration ; Expression expression = annotationMethodDeclaration . defaultValue ; if ( expression != null ) { this . requestor . exitMethod ( methodDeclaration . declarationSourceEnd , expression ) ; return ; } } this . requestor . exitMethod ( methodDeclaration . declarationSourceEnd , null ) ; } } public void notifySourceElementRequestor ( CompilationUnitDeclaration parsedUnit , int sourceStart , int sourceEnd , boolean reportReference , HashtableOfObjectToInt sourceEndsMap , Map nodesToCategoriesMap ) { this . initialPosition = sourceStart ; this . eofPosition = sourceEnd ; this . reportReferenceInfo = reportReference ; this . sourceEnds = sourceEndsMap ; this . nodesToCategories = nodesToCategoriesMap ; try { boolean isInRange = this . initialPosition <= parsedUnit . sourceStart && this . eofPosition >= parsedUnit . sourceEnd ; int length = <NUM_LIT:0> ; ASTNode [ ] nodes = null ; if ( isInRange ) { this . requestor . enterCompilationUnit ( ) ; } ImportReference currentPackage = parsedUnit . currentPackage ; if ( this . localDeclarationVisitor != null ) { this . localDeclarationVisitor . currentPackage = currentPackage ; } ImportReference [ ] imports = parsedUnit . imports ; TypeDeclaration [ ] types = parsedUnit . types ; length = ( currentPackage == null ? <NUM_LIT:0> : <NUM_LIT:1> ) + ( imports == null ? <NUM_LIT:0> : imports . length ) + ( types == null ? <NUM_LIT:0> : types . length ) ; nodes = new ASTNode [ length ] ; int index = <NUM_LIT:0> ; if ( currentPackage != null ) { nodes [ index ++ ] = currentPackage ; } if ( imports != null ) { for ( int i = <NUM_LIT:0> , max = imports . length ; i < max ; i ++ ) { nodes [ index ++ ] = imports [ i ] ; } } if ( types != null ) { for ( int i = <NUM_LIT:0> , max = types . length ; i < max ; i ++ ) { nodes [ index ++ ] = types [ i ] ; } } if ( length > <NUM_LIT:0> ) { quickSort ( nodes , <NUM_LIT:0> , length - <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ASTNode node = nodes [ i ] ; if ( node instanceof ImportReference ) { ImportReference importRef = ( ImportReference ) node ; if ( node == parsedUnit . currentPackage ) { notifySourceElementRequestor ( importRef , true ) ; } else { notifySourceElementRequestor ( importRef , false ) ; } } else { notifySourceElementRequestor ( ( TypeDeclaration ) node , true , null , currentPackage ) ; } } } if ( isInRange ) { this . requestor . exitCompilationUnit ( parsedUnit . sourceEnd ) ; } } finally { reset ( ) ; } } protected void notifySourceElementRequestor ( FieldDeclaration fieldDeclaration , TypeDeclaration declaringType ) { boolean isInRange = this . initialPosition <= fieldDeclaration . declarationSourceStart && this . eofPosition >= fieldDeclaration . declarationSourceEnd ; switch ( fieldDeclaration . getKind ( ) ) { case AbstractVariableDeclaration . ENUM_CONSTANT : if ( this . reportReferenceInfo ) { if ( fieldDeclaration . initialization instanceof AllocationExpression ) { AllocationExpression alloc = ( AllocationExpression ) fieldDeclaration . initialization ; this . requestor . acceptConstructorReference ( declaringType . name , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } case AbstractVariableDeclaration . FIELD : int fieldEndPosition = this . sourceEnds . get ( fieldDeclaration ) ; if ( fieldEndPosition == - <NUM_LIT:1> ) { fieldEndPosition = fieldDeclaration . declarationSourceEnd ; } if ( isInRange ) { int currentModifiers = fieldDeclaration . modifiers ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( fieldDeclaration . annotations ) ; char [ ] typeName = null ; if ( fieldDeclaration . type == null ) { typeName = declaringType . name ; currentModifiers |= ClassFileConstants . AccEnum ; } else { typeName = CharOperation . concatWith ( fieldDeclaration . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } ISourceElementRequestor . FieldInfo fieldInfo = new ISourceElementRequestor . FieldInfo ( ) ; fieldInfo . declarationStart = fieldDeclaration . declarationSourceStart ; fieldInfo . name = fieldDeclaration . name ; fieldInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; fieldInfo . type = typeName ; fieldInfo . nameSourceStart = fieldDeclaration . sourceStart ; fieldInfo . nameSourceEnd = fieldDeclaration . sourceEnd ; fieldInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( fieldDeclaration ) ; fieldInfo . annotations = fieldDeclaration . annotations ; fieldInfo . node = fieldDeclaration ; this . requestor . enterField ( fieldInfo ) ; } this . visitIfNeeded ( fieldDeclaration , declaringType ) ; if ( isInRange ) { this . requestor . exitField ( ( fieldDeclaration . initialization == null || fieldDeclaration . initialization instanceof ArrayInitializer || fieldDeclaration . initialization instanceof AllocationExpression || fieldDeclaration . initialization instanceof ArrayAllocationExpression || fieldDeclaration . initialization instanceof Assignment || fieldDeclaration . initialization instanceof ClassLiteralAccess || fieldDeclaration . initialization instanceof MessageSend || fieldDeclaration . initialization instanceof ArrayReference || fieldDeclaration . initialization instanceof ThisReference ) ? - <NUM_LIT:1> : fieldDeclaration . initialization . sourceStart , fieldEndPosition , fieldDeclaration . declarationSourceEnd ) ; } break ; case AbstractVariableDeclaration . INITIALIZER : if ( isInRange ) { this . requestor . enterInitializer ( fieldDeclaration . declarationSourceStart , fieldDeclaration . modifiers ) ; } this . visitIfNeeded ( ( Initializer ) fieldDeclaration ) ; if ( isInRange ) { this . requestor . exitInitializer ( fieldDeclaration . declarationSourceEnd ) ; } break ; } } protected void notifySourceElementRequestor ( ImportReference importReference , boolean isPackage ) { if ( isPackage ) { this . requestor . acceptPackage ( importReference ) ; } else { final boolean onDemand = ( importReference . bits & ASTNode . OnDemand ) != <NUM_LIT:0> ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , importReference . sourceStart , onDemand ? importReference . trailingStarPosition : importReference . sourceEnd , importReference . tokens , onDemand , importReference . modifiers ) ; } } protected void notifySourceElementRequestor ( TypeDeclaration typeDeclaration , boolean notifyTypePresence , TypeDeclaration declaringType , ImportReference currentPackage ) { if ( CharOperation . equals ( TypeConstants . PACKAGE_INFO_NAME , typeDeclaration . name ) ) return ; boolean isInRange = this . initialPosition <= typeDeclaration . declarationSourceStart && this . eofPosition >= typeDeclaration . declarationSourceEnd ; FieldDeclaration [ ] fields = typeDeclaration . fields ; AbstractMethodDeclaration [ ] methods = typeDeclaration . methods ; TypeDeclaration [ ] memberTypes = typeDeclaration . memberTypes ; int fieldCounter = fields == null ? <NUM_LIT:0> : fields . length ; int methodCounter = methods == null ? <NUM_LIT:0> : methods . length ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; int fieldIndex = <NUM_LIT:0> ; int methodIndex = <NUM_LIT:0> ; int memberTypeIndex = <NUM_LIT:0> ; if ( notifyTypePresence ) { char [ ] [ ] interfaceNames = getInterfaceNames ( typeDeclaration ) ; int kind = TypeDeclaration . kind ( typeDeclaration . modifiers ) ; char [ ] implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_OBJECT ; if ( isInRange ) { int currentModifiers = typeDeclaration . modifiers ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( typeDeclaration . annotations ) ; boolean isEnumInit = typeDeclaration . allocation != null && typeDeclaration . allocation . enumConstant != null ; char [ ] superclassName ; if ( isEnumInit ) { currentModifiers |= ClassFileConstants . AccEnum ; superclassName = declaringType . name ; } else { superclassName = getSuperclassName ( typeDeclaration ) ; } ISourceElementRequestor . TypeInfo typeInfo = new ISourceElementRequestor . TypeInfo ( ) ; if ( typeDeclaration . allocation == null ) { typeInfo . declarationStart = typeDeclaration . declarationSourceStart ; } else if ( isEnumInit ) { typeInfo . declarationStart = typeDeclaration . allocation . enumConstant . sourceStart ; } else { typeInfo . declarationStart = typeDeclaration . allocation . sourceStart ; } typeInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; typeInfo . name = typeDeclaration . name ; typeInfo . nameSourceStart = isEnumInit ? typeDeclaration . allocation . enumConstant . sourceStart : typeDeclaration . sourceStart ; typeInfo . nameSourceEnd = sourceEnd ( typeDeclaration ) ; typeInfo . superclass = superclassName ; typeInfo . superinterfaces = interfaceNames ; typeInfo . typeParameters = getTypeParameterInfos ( typeDeclaration . typeParameters ) ; typeInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( typeDeclaration ) ; typeInfo . secondary = typeDeclaration . isSecondary ( ) ; typeInfo . anonymousMember = typeDeclaration . allocation != null && typeDeclaration . allocation . enclosingInstance != null ; typeInfo . annotations = typeDeclaration . annotations ; typeInfo . extraFlags = ExtraFlags . getExtraFlags ( typeDeclaration ) ; typeInfo . node = typeDeclaration ; this . requestor . enterType ( typeInfo ) ; switch ( kind ) { case TypeDeclaration . CLASS_DECL : if ( superclassName != null ) implicitSuperclassName = superclassName ; break ; case TypeDeclaration . INTERFACE_DECL : implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_OBJECT ; break ; case TypeDeclaration . ENUM_DECL : implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_ENUM ; break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_ANNOTATION_ANNOTATION ; break ; } } if ( this . nestedTypeIndex == this . typeNames . length ) { System . arraycopy ( this . typeNames , <NUM_LIT:0> , ( this . typeNames = new char [ this . nestedTypeIndex * <NUM_LIT:2> ] [ ] ) , <NUM_LIT:0> , this . nestedTypeIndex ) ; System . arraycopy ( this . superTypeNames , <NUM_LIT:0> , ( this . superTypeNames = new char [ this . nestedTypeIndex * <NUM_LIT:2> ] [ ] ) , <NUM_LIT:0> , this . nestedTypeIndex ) ; } this . typeNames [ this . nestedTypeIndex ] = typeDeclaration . name ; this . superTypeNames [ this . nestedTypeIndex ++ ] = implicitSuperclassName ; } while ( ( fieldIndex < fieldCounter ) || ( memberTypeIndex < memberTypeCounter ) || ( methodIndex < methodCounter ) ) { FieldDeclaration nextFieldDeclaration = null ; AbstractMethodDeclaration nextMethodDeclaration = null ; TypeDeclaration nextMemberDeclaration = null ; int position = Integer . MAX_VALUE ; int nextDeclarationType = - <NUM_LIT:1> ; if ( fieldIndex < fieldCounter ) { nextFieldDeclaration = fields [ fieldIndex ] ; if ( nextFieldDeclaration . declarationSourceStart < position ) { position = nextFieldDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:0> ; } } if ( methodIndex < methodCounter ) { nextMethodDeclaration = methods [ methodIndex ] ; if ( nextMethodDeclaration . declarationSourceStart < position ) { position = nextMethodDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:1> ; } } if ( memberTypeIndex < memberTypeCounter ) { nextMemberDeclaration = memberTypes [ memberTypeIndex ] ; if ( nextMemberDeclaration . declarationSourceStart < position ) { position = nextMemberDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:2> ; } } switch ( nextDeclarationType ) { case <NUM_LIT:0> : fieldIndex ++ ; notifySourceElementRequestor ( nextFieldDeclaration , typeDeclaration ) ; break ; case <NUM_LIT:1> : methodIndex ++ ; notifySourceElementRequestor ( nextMethodDeclaration , typeDeclaration , currentPackage ) ; break ; case <NUM_LIT:2> : memberTypeIndex ++ ; notifySourceElementRequestor ( nextMemberDeclaration , true , null , currentPackage ) ; } } if ( notifyTypePresence ) { if ( isInRange ) { this . requestor . exitType ( typeDeclaration . declarationSourceEnd ) ; } this . nestedTypeIndex -- ; } } private static void quickSort ( ASTNode [ ] sortedCollection , int left , int right ) { int original_left = left ; int original_right = right ; ASTNode mid = sortedCollection [ left + ( right - left ) / <NUM_LIT:2> ] ; do { while ( sortedCollection [ left ] . sourceStart < mid . sourceStart ) { left ++ ; } while ( mid . sourceStart < sortedCollection [ right ] . sourceStart ) { right -- ; } if ( left <= right ) { ASTNode tmp = sortedCollection [ left ] ; sortedCollection [ left ] = sortedCollection [ right ] ; sortedCollection [ right ] = tmp ; left ++ ; right -- ; } } while ( left <= right ) ; if ( original_left < right ) { quickSort ( sortedCollection , original_left , right ) ; } if ( left < original_right ) { quickSort ( sortedCollection , left , original_right ) ; } } private void reset ( ) { this . typeNames = new char [ <NUM_LIT:4> ] [ ] ; this . superTypeNames = new char [ <NUM_LIT:4> ] [ ] ; this . nestedTypeIndex = <NUM_LIT:0> ; this . sourceEnds = null ; } private int sourceEnd ( TypeDeclaration typeDeclaration ) { if ( ( typeDeclaration . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression allocation = typeDeclaration . allocation ; if ( allocation . enumConstant != null ) return allocation . enumConstant . sourceEnd ; return allocation . type . sourceEnd ; } else { return typeDeclaration . sourceEnd ; } } private void visitIfNeeded ( AbstractMethodDeclaration method ) { if ( this . localDeclarationVisitor != null && ( method . bits & ASTNode . HasLocalType ) != <NUM_LIT:0> ) { if ( method instanceof ConstructorDeclaration ) { ConstructorDeclaration constructorDeclaration = ( ConstructorDeclaration ) method ; if ( constructorDeclaration . constructorCall != null ) { constructorDeclaration . constructorCall . traverse ( this . localDeclarationVisitor , method . scope ) ; } } if ( method . statements != null ) { int statementsLength = method . statements . length ; for ( int i = <NUM_LIT:0> ; i < statementsLength ; i ++ ) method . statements [ i ] . traverse ( this . localDeclarationVisitor , method . scope ) ; } } } private void visitIfNeeded ( FieldDeclaration field , TypeDeclaration declaringType ) { if ( this . localDeclarationVisitor != null && ( field . bits & ASTNode . HasLocalType ) != <NUM_LIT:0> ) { if ( field . initialization != null ) { try { this . localDeclarationVisitor . pushDeclaringType ( declaringType ) ; field . initialization . traverse ( this . localDeclarationVisitor , ( MethodScope ) null ) ; } finally { this . localDeclarationVisitor . popDeclaringType ( ) ; } } } } private void visitIfNeeded ( Initializer initializer ) { if ( this . localDeclarationVisitor != null && ( initializer . bits & ASTNode . HasLocalType ) != <NUM_LIT:0> ) { if ( initializer . block != null ) { initializer . block . traverse ( this . localDeclarationVisitor , null ) ; } } } } </s>
<s> package org . codehaus . jdt . groovy . internal ; import org . eclipse . jdt . internal . codeassist . InternalExtendedCompletionContext ; public class SimplifiedExtendedCompletionContext extends InternalExtendedCompletionContext { public SimplifiedExtendedCompletionContext ( ) { super ( null , null , null , null , null , null , null , null ) ; } } </s>
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . jdt . internal . core . JavaProject ; public interface EventHandler { void handle ( JavaProject javaProject , String string ) ; } </s>
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . Platform ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . SearchRequestor ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . BinaryType ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . search . indexing . IndexingParser ; import org . eclipse . jdt . internal . core . search . matching . ImportMatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . MatchLocator ; import org . eclipse . jdt . internal . core . search . matching . MatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . PossibleMatch ; import org . eclipse . jdt . internal . core . util . Util ; import org . osgi . framework . Bundle ; public class LanguageSupportFactory { private static LanguageSupport languageSupport ; public static final int CommentRecorderParserVariant = <NUM_LIT:2> ; public static Parser getParser ( Object requestor , CompilerOptions compilerOptions , ProblemReporter problemReporter , boolean parseLiteralExpressionsAsConstants , int variant ) { return getLanguageSupport ( ) . getParser ( requestor , compilerOptions , problemReporter , parseLiteralExpressionsAsConstants , variant ) ; } public static IndexingParser getIndexingParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return getLanguageSupport ( ) . getIndexingParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public static SourceElementParser getSourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return getLanguageSupport ( ) . getSourceElementParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public static MatchLocatorParser getMatchLocatorParser ( ProblemReporter problemReporter , MatchLocator locator ) { return getLanguageSupport ( ) . getMatchLocatorParserParser ( problemReporter , locator ) ; } public static ImportMatchLocatorParser getImportMatchLocatorParser ( ProblemReporter problemReporter , MatchLocator locator ) { return getLanguageSupport ( ) . getImportMatchLocatorParserParser ( problemReporter , locator ) ; } public static CompilationUnit newCompilationUnit ( PackageFragment parent , String name , WorkingCopyOwner owner ) { return getLanguageSupport ( ) . newCompilationUnit ( parent , name , owner ) ; } public static CompilationUnitDeclaration newCompilationUnitDeclaration ( ICompilationUnit unit , ProblemReporter problemReporter , CompilationResult compilationResult , int sourceLength ) { return getLanguageSupport ( ) . newCompilationUnitDeclaration ( unit , problemReporter , compilationResult , sourceLength ) ; } public static boolean isInterestingProject ( IProject project ) { return getLanguageSupport ( ) . isInterestingProject ( project ) ; } public static boolean isSourceFile ( String fileName , boolean isInterestingProject ) { return getLanguageSupport ( ) . isSourceFile ( fileName , isInterestingProject ) ; } public static boolean isInterestingSourceFile ( String fileName ) { return getLanguageSupport ( ) . isInterestingSourceFile ( fileName ) ; } public static boolean maybePerformDelegatedSearch ( PossibleMatch possibleMatch , SearchPattern pattern , SearchRequestor requestor ) { return getLanguageSupport ( ) . maybePerformDelegatedSearch ( possibleMatch , pattern , requestor ) ; } public static void filterNonSourceMembers ( BinaryType binaryType ) { getLanguageSupport ( ) . filterNonSourceMembers ( binaryType ) ; } private static LanguageSupport getLanguageSupport ( ) { if ( languageSupport == null ) { languageSupport = tryInstantiate ( "<STR_LIT>" ) ; if ( languageSupport == null ) { languageSupport = new DefaultLanguageSupport ( ) ; } } return languageSupport ; } private static LanguageSupport tryInstantiate ( String className ) { LanguageSupport instance = null ; if ( className != null && className . length ( ) > <NUM_LIT:0> ) { try { int separator = className . indexOf ( '<CHAR_LIT::>' ) ; Bundle bundle = null ; if ( separator == - <NUM_LIT:1> ) { JavaCore javaCore = JavaCore . getJavaCore ( ) ; if ( javaCore == null ) { Class clazz = Class . forName ( className ) ; return ( LanguageSupport ) clazz . newInstance ( ) ; } else { bundle = javaCore . getBundle ( ) ; } } else { String bundleName = className . substring ( <NUM_LIT:0> , separator ) ; className = className . substring ( separator + <NUM_LIT:1> ) ; bundle = Platform . getBundle ( bundleName ) ; } Class c = bundle . loadClass ( className ) ; instance = ( LanguageSupport ) c . newInstance ( ) ; } catch ( ClassNotFoundException e ) { log ( e ) ; } catch ( InstantiationException e ) { log ( e ) ; } catch ( IllegalAccessException e ) { log ( e ) ; } catch ( ClassCastException e ) { log ( e ) ; } } return instance ; } private static void log ( Exception e ) { if ( JavaCore . getPlugin ( ) == null || JavaCore . getPlugin ( ) . getLog ( ) == null ) { System . err . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . err ) ; } else { Util . log ( e , "<STR_LIT>" ) ; } } public static EventHandler getEventHandler ( ) { return getLanguageSupport ( ) . getEventHandler ( ) ; } public static IJavaSearchScope expandSearchScope ( IJavaSearchScope scope , SearchPattern pattern , SearchRequestor requestor ) { return getLanguageSupport ( ) . expandSearchScope ( scope , pattern , requestor ) ; } public static boolean isGroovyLanguageSupportInstalled ( ) { return getLanguageSupport ( ) . getClass ( ) . getName ( ) . endsWith ( "<STR_LIT>" ) ; } } </s>
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . core . resources . IProject ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . SearchRequestor ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . BinaryType ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . JavaProject ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . search . indexing . IndexingParser ; import org . eclipse . jdt . internal . core . search . matching . ImportMatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . MatchLocator ; import org . eclipse . jdt . internal . core . search . matching . MatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . PossibleMatch ; import org . eclipse . jdt . internal . core . util . CommentRecorderParser ; import org . eclipse . jdt . internal . core . util . Util ; class DefaultLanguageSupport implements LanguageSupport { public Parser getParser ( Object requestor , CompilerOptions compilerOptions , ProblemReporter problemReporter , boolean parseLiteralExpressionsAsConstants , int variant ) { if ( variant == <NUM_LIT:1> ) { return new Parser ( problemReporter , parseLiteralExpressionsAsConstants ) ; } else { return new CommentRecorderParser ( problemReporter , parseLiteralExpressionsAsConstants ) ; } } public IndexingParser getIndexingParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return new IndexingParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public ImportMatchLocatorParser getImportMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) { return new ImportMatchLocatorParser ( problemReporter , locator ) ; } public SourceElementParser getSourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return new SourceElementParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public MatchLocatorParser getMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) { return new MatchLocatorParser ( problemReporter , locator ) ; } public CompilationUnit newCompilationUnit ( PackageFragment parent , String name , WorkingCopyOwner owner ) { return new CompilationUnit ( parent , name , owner ) ; } public CompilationUnitDeclaration newCompilationUnitDeclaration ( ICompilationUnit unit , ProblemReporter problemReporter , CompilationResult compilationResult , int sourceLength ) { return new CompilationUnitDeclaration ( problemReporter , compilationResult , sourceLength ) ; } public boolean isInterestingProject ( IProject project ) { return true ; } public boolean isSourceFile ( String fileName , boolean isInterestingProject ) { return Util . isJavaLikeFileName ( fileName ) ; } public boolean isInterestingSourceFile ( String fileName ) { return false ; } public boolean maybePerformDelegatedSearch ( PossibleMatch possibleMatch , SearchPattern pattern , SearchRequestor requestor ) { return false ; } public EventHandler getEventHandler ( ) { return DefaultEventHandler . instance ; } static class DefaultEventHandler implements EventHandler { static DefaultEventHandler instance = new DefaultEventHandler ( ) ; private DefaultEventHandler ( ) { } public void handle ( JavaProject javaProject , String string ) { } } public void filterNonSourceMembers ( BinaryType binaryType ) { } public IJavaSearchScope expandSearchScope ( IJavaSearchScope scope , SearchPattern pattern , SearchRequestor requestor ) { return scope ; } } </s>
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . core . resources . IProject ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . SearchRequestor ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . BinaryType ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . search . indexing . IndexingParser ; import org . eclipse . jdt . internal . core . search . matching . ImportMatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . MatchLocator ; import org . eclipse . jdt . internal . core . search . matching . MatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . PossibleMatch ; public interface LanguageSupport { Parser getParser ( Object requestor , CompilerOptions compilerOptions , ProblemReporter problemReporter , boolean parseLiteralExpressionsAsConstants , int variant ) ; IndexingParser getIndexingParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) ; MatchLocatorParser getMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) ; SourceElementParser getSourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) ; ImportMatchLocatorParser getImportMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) ; CompilationUnit newCompilationUnit ( PackageFragment parent , String name , WorkingCopyOwner owner ) ; CompilationUnitDeclaration newCompilationUnitDeclaration ( ICompilationUnit unit , ProblemReporter problemReporter , CompilationResult compilationResult , int sourceLength ) ; boolean isInterestingProject ( IProject project ) ; boolean isSourceFile ( String fileName , boolean isInterestingProject ) ; boolean isInterestingSourceFile ( String fileName ) ; boolean maybePerformDelegatedSearch ( PossibleMatch possibleMatch , SearchPattern pattern , SearchRequestor requestor ) ; EventHandler getEventHandler ( ) ; void filterNonSourceMembers ( BinaryType binaryType ) ; IJavaSearchScope expandSearchScope ( IJavaSearchScope scope , SearchPattern pattern , SearchRequestor requestor ) ; } </s>
<s> package org . eclipse . jdt . internal . formatter . comment ; import java . io . IOException ; import java . io . Reader ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . internal . compiler . parser . * ; public class Java2HTMLEntityReader extends SubstitutionTextReader { private static final int BEGIN_LINE = <NUM_LIT> ; private static final Map fgEntityLookup ; private int bits = BEGIN_LINE ; static { fgEntityLookup = new HashMap ( <NUM_LIT:7> ) ; fgEntityLookup . put ( "<STR_LIT:<>" , "<STR_LIT>" ) ; fgEntityLookup . put ( "<STR_LIT:>>" , "<STR_LIT>" ) ; fgEntityLookup . put ( "<STR_LIT:&>" , "<STR_LIT>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT>" ) ; fgEntityLookup . put ( "<STR_LIT:\">" , "<STR_LIT>" ) ; } public Java2HTMLEntityReader ( Reader reader ) { super ( reader ) ; setSkipWhitespace ( false ) ; } protected String computeSubstitution ( int c ) throws IOException { StringBuffer buf = new StringBuffer ( ) ; while ( c == '<CHAR_LIT>' ) { this . bits &= ~ BEGIN_LINE ; c = nextChar ( ) ; buf . append ( '<CHAR_LIT>' ) ; } if ( c == - <NUM_LIT:1> ) return buf . toString ( ) ; if ( c == '<CHAR_LIT:/>' && buf . length ( ) > <NUM_LIT:0> ) { buf . setLength ( buf . length ( ) - <NUM_LIT:1> ) ; buf . append ( "<STR_LIT>" ) ; } else if ( c == '<CHAR_LIT>' && ( this . bits & BEGIN_LINE ) != <NUM_LIT:0> ) { buf . append ( "<STR_LIT>" ) ; } else { String entity = ( String ) fgEntityLookup . get ( String . valueOf ( ( char ) c ) ) ; if ( entity != null ) buf . append ( entity ) ; else buf . append ( ( char ) c ) ; } if ( c == '<STR_LIT:\n>' || c == '<STR_LIT>' ) { this . bits |= BEGIN_LINE ; } else if ( ! ScannerHelper . isWhitespace ( ( char ) c ) ) { this . bits &= ~ BEGIN_LINE ; } return buf . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter . comment ; import java . util . Map ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . BadPositionCategoryException ; import org . eclipse . jface . text . DefaultPositionUpdater ; import org . eclipse . jface . text . Document ; import org . eclipse . jface . text . Position ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . internal . core . util . Util ; public class CommentFormatterUtil { public static String evaluateFormatterEdit ( String string , TextEdit edit , Position [ ] positions ) { try { Document doc = createDocument ( string , positions ) ; edit . apply ( doc , <NUM_LIT:0> ) ; if ( positions != null ) { for ( int i = <NUM_LIT:0> ; i < positions . length ; i ++ ) { Assert . isTrue ( ! positions [ i ] . isDeleted , "<STR_LIT>" ) ; } } return doc . get ( ) ; } catch ( BadLocationException e ) { log ( e ) ; Assert . isTrue ( false , "<STR_LIT>" + e . getMessage ( ) ) ; } return null ; } public static TextEdit format2 ( int kind , String string , int indentationLevel , String lineSeparator , Map options ) { int length = string . length ( ) ; if ( <NUM_LIT:0> < <NUM_LIT:0> || length < <NUM_LIT:0> || <NUM_LIT:0> + length > string . length ( ) ) { throw new IllegalArgumentException ( "<STR_LIT>" + <NUM_LIT:0> + "<STR_LIT>" + length + "<STR_LIT>" + string . length ( ) ) ; } return ToolFactory . createCodeFormatter ( options ) . format ( kind , string , <NUM_LIT:0> , length , indentationLevel , lineSeparator ) ; } private static Document createDocument ( String content , Position [ ] positions ) throws IllegalArgumentException { Document doc = new Document ( content ) ; try { if ( positions != null ) { final String POS_CATEGORY = "<STR_LIT>" ; doc . addPositionCategory ( POS_CATEGORY ) ; doc . addPositionUpdater ( new DefaultPositionUpdater ( POS_CATEGORY ) { protected boolean notDeleted ( ) { if ( this . fOffset < this . fPosition . offset && ( this . fPosition . offset + this . fPosition . length < this . fOffset + this . fLength ) ) { this . fPosition . offset = this . fOffset + this . fLength ; return false ; } return true ; } } ) ; for ( int i = <NUM_LIT:0> ; i < positions . length ; i ++ ) { try { doc . addPosition ( POS_CATEGORY , positions [ i ] ) ; } catch ( BadLocationException e ) { throw new IllegalArgumentException ( "<STR_LIT>" + positions [ i ] . offset + "<STR_LIT>" + positions [ i ] . length + "<STR_LIT>" + content . length ( ) ) ; } } } } catch ( BadPositionCategoryException cannotHappen ) { } return doc ; } public static void log ( Throwable t ) { Util . log ( t , "<STR_LIT>" ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter . comment ; public interface IJavaDocTagConstants { public static final char [ ] [ ] JAVADOC_SINGLE_BREAK_TAG = new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) } ; public static final char [ ] [ ] JAVADOC_CODE_TAGS = new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) } ; public static final char [ ] [ ] JAVADOC_BREAK_TAGS = new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT:q>" . toCharArray ( ) } ; public static final char [ ] [ ] JAVADOC_IMMUTABLE_TAGS = new char [ ] [ ] { "<STR_LIT:code>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT:q>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) } ; public static final char [ ] [ ] JAVADOC_NEWLINE_TAGS = new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT:q>" . toCharArray ( ) } ; public static final char [ ] [ ] JAVADOC_PARAM_TAGS = new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) } ; public static final char [ ] [ ] JAVADOC_SEPARATOR_TAGS = new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT:p>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , } ; public static final char JAVADOC_TAG_PREFIX = '<CHAR_LIT>' ; public static final char LINK_TAG_POSTFIX = '<CHAR_LIT:}>' ; public static final String LINK_TAG_PREFIX_STRING = "<STR_LIT>" ; public static final char [ ] LINK_TAG_PREFIX = LINK_TAG_PREFIX_STRING . toCharArray ( ) ; public static final char [ ] [ ] COMMENT_ROOT_TAGS = new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) } ; public static final char COMMENT_TAG_PREFIX = '<CHAR_LIT>' ; public static final String BLOCK_HEADER = "<STR_LIT>" ; public static final int BLOCK_HEADER_LENGTH = BLOCK_HEADER . length ( ) ; public static final String JAVADOC_HEADER = "<STR_LIT>" ; public static final int JAVADOC_HEADER_LENGTH = JAVADOC_HEADER . length ( ) ; public static final String BLOCK_LINE_PREFIX = "<STR_LIT>" ; public static final int BLOCK_LINE_PREFIX_LENGTH = BLOCK_LINE_PREFIX . length ( ) ; public static final String BLOCK_FOOTER = "<STR_LIT>" ; public static final int BLOCK_FOOTER_LENGTH = BLOCK_FOOTER . length ( ) ; public static final String LINE_COMMENT_PREFIX = "<STR_LIT>" ; public static final int LINE_COMMENT_PREFIX_LENGTH = LINE_COMMENT_PREFIX . length ( ) ; public static final String JAVADOC_STAR = "<STR_LIT:*>" ; static final int JAVADOC_TAGS_INDEX_MASK = <NUM_LIT> ; static final int JAVADOC_TAGS_ID_MASK = <NUM_LIT> ; static final int JAVADOC_SINGLE_BREAK_TAG_ID = <NUM_LIT> ; static final int JAVADOC_CODE_TAGS_ID = <NUM_LIT> ; static final int JAVADOC_BREAK_TAGS_ID = <NUM_LIT> ; static final int JAVADOC_IMMUTABLE_TAGS_ID = <NUM_LIT> ; static final int JAVADOC_SEPARATOR_TAGS_ID = <NUM_LIT> ; static final int JAVADOC_SINGLE_TAGS_ID = JAVADOC_SINGLE_BREAK_TAG_ID ; static final int JAVADOC_CLOSED_TAG = <NUM_LIT> ; } </s>
<s> package org . eclipse . jdt . internal . formatter . comment ; import java . io . IOException ; import java . io . Reader ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; public class HTMLEntity2JavaReader extends SubstitutionTextReader { private static final Map fgEntityLookup ; static { fgEntityLookup = new HashMap ( <NUM_LIT:7> ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT:<>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT:>>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT:U+0020>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT:&>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT>" ) ; fgEntityLookup . put ( "<STR_LIT>" , "<STR_LIT:\">" ) ; } public HTMLEntity2JavaReader ( Reader reader ) { super ( reader ) ; setSkipWhitespace ( false ) ; } protected String computeSubstitution ( int c ) throws IOException { if ( c == '<CHAR_LIT>' ) return processEntity ( ) ; return null ; } protected String entity2Text ( String symbol ) { if ( symbol . length ( ) > <NUM_LIT:1> && symbol . charAt ( <NUM_LIT:0> ) == '<CHAR_LIT>' ) { int ch ; try { if ( symbol . charAt ( <NUM_LIT:1> ) == '<CHAR_LIT>' ) { ch = Integer . parseInt ( symbol . substring ( <NUM_LIT:2> ) , <NUM_LIT:16> ) ; } else { ch = Integer . parseInt ( symbol . substring ( <NUM_LIT:1> ) , <NUM_LIT:10> ) ; } return String . valueOf ( ( char ) ch ) ; } catch ( NumberFormatException e ) { } } else { String str = ( String ) fgEntityLookup . get ( symbol ) ; if ( str != null ) { return str ; } } return "<STR_LIT:&>" + symbol ; } private String processEntity ( ) throws IOException { StringBuffer buf = new StringBuffer ( ) ; int ch = nextChar ( ) ; while ( ScannerHelper . isLetterOrDigit ( ( char ) ch ) || ch == '<CHAR_LIT>' ) { buf . append ( ( char ) ch ) ; ch = nextChar ( ) ; } if ( ch == '<CHAR_LIT:;>' ) return entity2Text ( buf . toString ( ) ) ; buf . insert ( <NUM_LIT:0> , '<CHAR_LIT>' ) ; if ( ch != - <NUM_LIT:1> ) buf . append ( ( char ) ch ) ; return buf . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter . comment ; import java . io . IOException ; import java . io . Reader ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; public abstract class SubstitutionTextReader extends Reader { private Reader fReader ; private boolean fWasWhiteSpace ; private int fCharAfterWhiteSpace ; private boolean fSkipWhiteSpace = true ; private boolean fReadFromBuffer ; private StringBuffer fBuffer ; private int fIndex ; protected SubstitutionTextReader ( Reader reader ) { this . fReader = reader ; this . fBuffer = new StringBuffer ( ) ; this . fIndex = <NUM_LIT:0> ; this . fReadFromBuffer = false ; this . fCharAfterWhiteSpace = - <NUM_LIT:1> ; this . fWasWhiteSpace = true ; } public String getString ( ) throws IOException { StringBuffer buf = new StringBuffer ( ) ; int ch ; while ( ( ch = read ( ) ) != - <NUM_LIT:1> ) { buf . append ( ( char ) ch ) ; } return buf . toString ( ) ; } protected abstract String computeSubstitution ( int c ) throws IOException ; protected Reader getReader ( ) { return this . fReader ; } protected int nextChar ( ) throws IOException { this . fReadFromBuffer = ( this . fBuffer . length ( ) > <NUM_LIT:0> ) ; if ( this . fReadFromBuffer ) { char ch = this . fBuffer . charAt ( this . fIndex ++ ) ; if ( this . fIndex >= this . fBuffer . length ( ) ) { this . fBuffer . setLength ( <NUM_LIT:0> ) ; this . fIndex = <NUM_LIT:0> ; } return ch ; } else { int ch = this . fCharAfterWhiteSpace ; if ( ch == - <NUM_LIT:1> ) { ch = this . fReader . read ( ) ; } if ( this . fSkipWhiteSpace && ScannerHelper . isWhitespace ( ( char ) ch ) ) { do { ch = this . fReader . read ( ) ; } while ( ScannerHelper . isWhitespace ( ( char ) ch ) ) ; if ( ch != - <NUM_LIT:1> ) { this . fCharAfterWhiteSpace = ch ; return '<CHAR_LIT:U+0020>' ; } } else { this . fCharAfterWhiteSpace = - <NUM_LIT:1> ; } return ch ; } } public int read ( ) throws IOException { int c ; do { c = nextChar ( ) ; while ( ! this . fReadFromBuffer && c != - <NUM_LIT:1> ) { String s = computeSubstitution ( c ) ; if ( s == null ) break ; if ( s . length ( ) > <NUM_LIT:0> ) this . fBuffer . insert ( <NUM_LIT:0> , s ) ; c = nextChar ( ) ; } } while ( this . fSkipWhiteSpace && this . fWasWhiteSpace && ( c == '<CHAR_LIT:U+0020>' ) ) ; this . fWasWhiteSpace = ( c == '<CHAR_LIT:U+0020>' || c == '<STR_LIT>' || c == '<STR_LIT:\n>' ) ; return c ; } public int read ( char cbuf [ ] , int off , int len ) throws IOException { int end = off + len ; for ( int i = off ; i < end ; i ++ ) { int ch = read ( ) ; if ( ch == - <NUM_LIT:1> ) { if ( i == off ) { return - <NUM_LIT:1> ; } else { return i - off ; } } cbuf [ i ] = ( char ) ch ; } return len ; } public boolean ready ( ) throws IOException { return this . fReader . ready ( ) ; } public void close ( ) throws IOException { this . fReader . close ( ) ; } public void reset ( ) throws IOException { this . fReader . reset ( ) ; this . fWasWhiteSpace = true ; this . fCharAfterWhiteSpace = - <NUM_LIT:1> ; this . fBuffer . setLength ( <NUM_LIT:0> ) ; this . fIndex = <NUM_LIT:0> ; } protected final void setSkipWhitespace ( boolean state ) { this . fSkipWhiteSpace = state ; } protected final boolean isSkippingWhitespace ( ) { return this . fSkipWhiteSpace ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import java . util . ArrayList ; import java . util . Map ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . core . formatter . CodeFormatter ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . AND_AND_Expression ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AbstractVariableDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ; import org . eclipse . jdt . internal . compiler . ast . ArrayQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ArrayReference ; import org . eclipse . jdt . internal . compiler . ast . ArrayTypeReference ; import org . eclipse . jdt . internal . compiler . ast . AssertStatement ; import org . eclipse . jdt . internal . compiler . ast . Assignment ; import org . eclipse . jdt . internal . compiler . ast . BinaryExpression ; import org . eclipse . jdt . internal . compiler . ast . Block ; import org . eclipse . jdt . internal . compiler . ast . BreakStatement ; import org . eclipse . jdt . internal . compiler . ast . CaseStatement ; import org . eclipse . jdt . internal . compiler . ast . CastExpression ; import org . eclipse . jdt . internal . compiler . ast . CharLiteral ; import org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ; import org . eclipse . jdt . internal . compiler . ast . Clinit ; import org . eclipse . jdt . internal . compiler . ast . CombinedBinaryExpression ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . CompoundAssignment ; import org . eclipse . jdt . internal . compiler . ast . ConditionalExpression ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ContinueStatement ; import org . eclipse . jdt . internal . compiler . ast . UnionTypeReference ; import org . eclipse . jdt . internal . compiler . ast . DoStatement ; import org . eclipse . jdt . internal . compiler . ast . DoubleLiteral ; import org . eclipse . jdt . internal . compiler . ast . EmptyStatement ; import org . eclipse . jdt . internal . compiler . ast . EqualExpression ; import org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . FalseLiteral ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldReference ; import org . eclipse . jdt . internal . compiler . ast . FloatLiteral ; import org . eclipse . jdt . internal . compiler . ast . ForStatement ; import org . eclipse . jdt . internal . compiler . ast . ForeachStatement ; import org . eclipse . jdt . internal . compiler . ast . IfStatement ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . InstanceOfExpression ; import org . eclipse . jdt . internal . compiler . ast . IntLiteral ; import org . eclipse . jdt . internal . compiler . ast . LabeledStatement ; import org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ; import org . eclipse . jdt . internal . compiler . ast . LongLiteral ; import org . eclipse . jdt . internal . compiler . ast . MarkerAnnotation ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . NormalAnnotation ; import org . eclipse . jdt . internal . compiler . ast . NullLiteral ; import org . eclipse . jdt . internal . compiler . ast . OR_OR_Expression ; import org . eclipse . jdt . internal . compiler . ast . OperatorIds ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedSingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . PostfixExpression ; import org . eclipse . jdt . internal . compiler . ast . PrefixExpression ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedThisReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ReturnStatement ; import org . eclipse . jdt . internal . compiler . ast . SingleMemberAnnotation ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . Statement ; import org . eclipse . jdt . internal . compiler . ast . StringLiteral ; import org . eclipse . jdt . internal . compiler . ast . StringLiteralConcatenation ; import org . eclipse . jdt . internal . compiler . ast . SuperReference ; import org . eclipse . jdt . internal . compiler . ast . SwitchStatement ; import org . eclipse . jdt . internal . compiler . ast . SynchronizedStatement ; import org . eclipse . jdt . internal . compiler . ast . ThisReference ; import org . eclipse . jdt . internal . compiler . ast . ThrowStatement ; import org . eclipse . jdt . internal . compiler . ast . TrueLiteral ; import org . eclipse . jdt . internal . compiler . ast . TryStatement ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . ast . UnaryExpression ; import org . eclipse . jdt . internal . compiler . ast . WhileStatement ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . CompilationUnitScope ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . core . util . CodeSnippetParsingUtil ; import org . eclipse . jdt . internal . formatter . align . Alignment ; import org . eclipse . jdt . internal . formatter . align . AlignmentException ; import org . eclipse . jface . text . IRegion ; import org . eclipse . text . edits . TextEdit ; public class CodeFormatterVisitor extends ASTVisitor { public static class MultiFieldDeclaration extends FieldDeclaration { FieldDeclaration [ ] declarations ; MultiFieldDeclaration ( FieldDeclaration [ ] declarations ) { this . declarations = declarations ; this . modifiers = declarations [ <NUM_LIT:0> ] . modifiers ; } } public final static boolean DEBUG = false ; private static final int NO_MODIFIERS = <NUM_LIT:0> ; private static final int [ ] SINGLETYPEREFERENCE_EXPECTEDTOKENS = new int [ ] { TerminalTokens . TokenNameIdentifier , TerminalTokens . TokenNameboolean , TerminalTokens . TokenNamebyte , TerminalTokens . TokenNamechar , TerminalTokens . TokenNamedouble , TerminalTokens . TokenNamefloat , TerminalTokens . TokenNameint , TerminalTokens . TokenNamelong , TerminalTokens . TokenNameshort , TerminalTokens . TokenNamevoid } ; private static final int [ ] CLOSING_GENERICS_EXPECTEDTOKENS = new int [ ] { TerminalTokens . TokenNameRIGHT_SHIFT , TerminalTokens . TokenNameGREATER , TerminalTokens . TokenNameUNSIGNED_RIGHT_SHIFT , } ; public int lastLocalDeclarationSourceStart ; int lastBinaryExpressionAlignmentBreakIndentation ; private Scanner localScanner ; public DefaultCodeFormatterOptions preferences ; public Scribe scribe ; final static long EXPRESSIONS_POS_ENTER_EQUALITY = <NUM_LIT:1> ; final static long EXPRESSIONS_POS_ENTER_TWO = <NUM_LIT:2> ; final static long EXPRESSIONS_POS_BETWEEN_TWO = <NUM_LIT:3> ; final static long EXPRESSIONS_POS_MASK = EXPRESSIONS_POS_BETWEEN_TWO ; long expressionsPos ; int expressionsDepth = - <NUM_LIT:1> ; int arrayInitializersDepth = - <NUM_LIT:1> ; public CodeFormatterVisitor ( DefaultCodeFormatterOptions preferences , Map settings , IRegion [ ] regions , CodeSnippetParsingUtil codeSnippetParsingUtil , boolean includeComments ) { long sourceLevel = settings == null ? ClassFileConstants . JDK1_3 : CompilerOptions . versionToJdkLevel ( settings . get ( JavaCore . COMPILER_SOURCE ) ) ; this . localScanner = new Scanner ( true , false , false , sourceLevel , null , null , true ) ; this . preferences = preferences ; this . scribe = new Scribe ( this , sourceLevel , regions , codeSnippetParsingUtil , includeComments ) ; } public void acceptProblem ( IProblem problem ) { super . acceptProblem ( problem ) ; } private BinaryExpressionFragmentBuilder buildFragments ( BinaryExpression binaryExpression , BlockScope scope ) { BinaryExpressionFragmentBuilder builder = new BinaryExpressionFragmentBuilder ( ) ; if ( binaryExpression instanceof CombinedBinaryExpression ) { binaryExpression . traverse ( builder , scope ) ; return builder ; } switch ( ( binaryExpression . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT ) { case OperatorIds . MULTIPLY : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameMULTIPLY ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . PLUS : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNamePLUS ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . DIVIDE : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameDIVIDE ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . REMAINDER : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameREMAINDER ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . XOR : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameXOR ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . MINUS : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameMINUS ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . OR : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameOR ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . AND : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameAND ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . AND_AND : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameAND_AND ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; case OperatorIds . OR_OR : binaryExpression . left . traverse ( builder , scope ) ; builder . operatorsList . add ( new Integer ( TerminalTokens . TokenNameOR_OR ) ) ; binaryExpression . right . traverse ( builder , scope ) ; break ; } return builder ; } private CascadingMethodInvocationFragmentBuilder buildFragments ( MessageSend messageSend , BlockScope scope ) { CascadingMethodInvocationFragmentBuilder builder = new CascadingMethodInvocationFragmentBuilder ( ) ; messageSend . traverse ( builder , scope ) ; return builder ; } private boolean commentStartsBlock ( int start , int end ) { this . localScanner . resetTo ( start , end ) ; try { if ( this . localScanner . getNextToken ( ) == TerminalTokens . TokenNameLBRACE ) { switch ( this . localScanner . getNextToken ( ) ) { case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : return true ; } } } catch ( InvalidInputException e ) { } return false ; } private ASTNode [ ] computeMergedMemberDeclarations ( ASTNode [ ] nodes ) { ArrayList mergedNodes = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> , max = nodes . length ; i < max ; i ++ ) { ASTNode currentNode = nodes [ i ] ; if ( currentNode instanceof FieldDeclaration ) { FieldDeclaration currentField = ( FieldDeclaration ) currentNode ; if ( mergedNodes . size ( ) == <NUM_LIT:0> ) { mergedNodes . add ( currentNode ) ; } else { ASTNode previousMergedNode = ( ASTNode ) mergedNodes . get ( mergedNodes . size ( ) - <NUM_LIT:1> ) ; if ( previousMergedNode instanceof MultiFieldDeclaration ) { MultiFieldDeclaration multiFieldDeclaration = ( MultiFieldDeclaration ) previousMergedNode ; int length = multiFieldDeclaration . declarations . length ; System . arraycopy ( multiFieldDeclaration . declarations , <NUM_LIT:0> , multiFieldDeclaration . declarations = new FieldDeclaration [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; multiFieldDeclaration . declarations [ length ] = currentField ; } else if ( previousMergedNode instanceof FieldDeclaration ) { final FieldDeclaration previousFieldDeclaration = ( FieldDeclaration ) previousMergedNode ; if ( currentField . declarationSourceStart == previousFieldDeclaration . declarationSourceStart ) { final MultiFieldDeclaration multiFieldDeclaration = new MultiFieldDeclaration ( new FieldDeclaration [ ] { previousFieldDeclaration , currentField } ) ; multiFieldDeclaration . annotations = previousFieldDeclaration . annotations ; mergedNodes . set ( mergedNodes . size ( ) - <NUM_LIT:1> , multiFieldDeclaration ) ; } else { mergedNodes . add ( currentNode ) ; } } else { mergedNodes . add ( currentNode ) ; } } } else { mergedNodes . add ( currentNode ) ; } } if ( mergedNodes . size ( ) != nodes . length ) { ASTNode [ ] result = new ASTNode [ mergedNodes . size ( ) ] ; mergedNodes . toArray ( result ) ; return result ; } else { return nodes ; } } private ASTNode [ ] computeMergedMemberDeclarations ( TypeDeclaration typeDeclaration ) { int fieldIndex = <NUM_LIT:0> , fieldCount = ( typeDeclaration . fields == null ) ? <NUM_LIT:0> : typeDeclaration . fields . length ; FieldDeclaration field = fieldCount == <NUM_LIT:0> ? null : typeDeclaration . fields [ fieldIndex ] ; int fieldStart = field == null ? Integer . MAX_VALUE : field . declarationSourceStart ; int methodIndex = <NUM_LIT:0> , methodCount = ( typeDeclaration . methods == null ) ? <NUM_LIT:0> : typeDeclaration . methods . length ; AbstractMethodDeclaration method = methodCount == <NUM_LIT:0> ? null : typeDeclaration . methods [ methodIndex ] ; int methodStart = method == null ? Integer . MAX_VALUE : method . declarationSourceStart ; int typeIndex = <NUM_LIT:0> , typeCount = ( typeDeclaration . memberTypes == null ) ? <NUM_LIT:0> : typeDeclaration . memberTypes . length ; TypeDeclaration type = typeCount == <NUM_LIT:0> ? null : typeDeclaration . memberTypes [ typeIndex ] ; int typeStart = type == null ? Integer . MAX_VALUE : type . declarationSourceStart ; final int memberLength = fieldCount + methodCount + typeCount ; ASTNode [ ] members = new ASTNode [ memberLength ] ; if ( memberLength != <NUM_LIT:0> ) { int index = <NUM_LIT:0> ; int previousFieldStart = - <NUM_LIT:1> ; do { if ( fieldStart < methodStart && fieldStart < typeStart ) { if ( field . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { previousFieldStart = fieldStart ; if ( ++ fieldIndex < fieldCount ) { fieldStart = ( field = typeDeclaration . fields [ fieldIndex ] ) . declarationSourceStart ; } else { fieldStart = Integer . MAX_VALUE ; } continue ; } if ( fieldStart == previousFieldStart ) { ASTNode previousMember = members [ index - <NUM_LIT:1> ] ; if ( previousMember instanceof MultiFieldDeclaration ) { MultiFieldDeclaration multiField = ( MultiFieldDeclaration ) previousMember ; int length = multiField . declarations . length ; System . arraycopy ( multiField . declarations , <NUM_LIT:0> , multiField . declarations = new FieldDeclaration [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; multiField . declarations [ length ] = field ; } else { FieldDeclaration fieldDeclaration = ( FieldDeclaration ) previousMember ; final MultiFieldDeclaration multiFieldDeclaration = new MultiFieldDeclaration ( new FieldDeclaration [ ] { fieldDeclaration , field } ) ; multiFieldDeclaration . annotations = fieldDeclaration . annotations ; members [ index - <NUM_LIT:1> ] = multiFieldDeclaration ; } } else { members [ index ++ ] = field ; } previousFieldStart = fieldStart ; if ( ++ fieldIndex < fieldCount ) { fieldStart = ( field = typeDeclaration . fields [ fieldIndex ] ) . declarationSourceStart ; } else { fieldStart = Integer . MAX_VALUE ; } } else if ( methodStart < fieldStart && methodStart < typeStart ) { if ( ! method . isDefaultConstructor ( ) && ! method . isClinit ( ) ) { members [ index ++ ] = method ; } if ( ++ methodIndex < methodCount ) { methodStart = ( method = typeDeclaration . methods [ methodIndex ] ) . declarationSourceStart ; } else { methodStart = Integer . MAX_VALUE ; } } else { members [ index ++ ] = type ; if ( ++ typeIndex < typeCount ) { typeStart = ( type = typeDeclaration . memberTypes [ typeIndex ] ) . declarationSourceStart ; } else { typeStart = Integer . MAX_VALUE ; } } } while ( ( fieldIndex < fieldCount ) || ( typeIndex < typeCount ) || ( methodIndex < methodCount ) ) ; if ( members . length != index ) { System . arraycopy ( members , <NUM_LIT:0> , members = new ASTNode [ index ] , <NUM_LIT:0> , index ) ; } } return members ; } private boolean dumpBinaryExpression ( BinaryExpression binaryExpression , int operator , BlockScope scope ) { final int numberOfParens = ( binaryExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( binaryExpression , numberOfParens ) ; } BinaryExpressionFragmentBuilder builder = buildFragments ( binaryExpression , scope ) ; final int fragmentsSize = builder . size ( ) ; if ( this . expressionsDepth < <NUM_LIT:0> ) { this . expressionsDepth = <NUM_LIT:0> ; } else { this . expressionsDepth ++ ; this . expressionsPos <<= <NUM_LIT:2> ; } try { this . lastBinaryExpressionAlignmentBreakIndentation = <NUM_LIT:0> ; if ( ( builder . realFragmentsSize ( ) > <NUM_LIT:1> || fragmentsSize > <NUM_LIT:4> ) && numberOfParens == <NUM_LIT:0> ) { int scribeLine = this . scribe . line ; this . scribe . printComment ( ) ; Alignment binaryExpressionAlignment = this . scribe . createAlignment ( Alignment . BINARY_EXPRESSION , this . preferences . alignment_for_binary_expression , Alignment . R_OUTERMOST , fragmentsSize , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( binaryExpressionAlignment ) ; boolean ok = false ; ASTNode [ ] fragments = builder . fragments ( ) ; int [ ] operators = builder . operators ( ) ; do { try { final int max = fragmentsSize - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { ASTNode fragment = fragments [ i ] ; fragment . traverse ( this , scope ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( this . scribe . lastNumberOfNewLines == <NUM_LIT:1> ) { this . scribe . indentationLevel = binaryExpressionAlignment . breakIndentationLevel ; } if ( this . preferences . wrap_before_binary_operator ) { this . scribe . alignFragment ( binaryExpressionAlignment , i ) ; this . scribe . printNextToken ( operators [ i ] , this . preferences . insert_space_before_binary_operator ) ; } else { this . scribe . printNextToken ( operators [ i ] , this . preferences . insert_space_before_binary_operator ) ; this . scribe . alignFragment ( binaryExpressionAlignment , i ) ; } if ( operators [ i ] == TerminalTokens . TokenNameMINUS && isNextToken ( TerminalTokens . TokenNameMINUS ) ) { this . scribe . space ( ) ; } if ( this . preferences . insert_space_after_binary_operator ) { this . scribe . space ( ) ; } } fragments [ max ] . traverse ( this , scope ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( binaryExpressionAlignment , true ) ; if ( this . scribe . line == scribeLine ) { this . lastBinaryExpressionAlignmentBreakIndentation = <NUM_LIT:0> ; } else { this . lastBinaryExpressionAlignmentBreakIndentation = binaryExpressionAlignment . breakIndentationLevel ; } } else { this . expressionsPos |= EXPRESSIONS_POS_ENTER_TWO ; binaryExpression . left . traverse ( this , scope ) ; this . expressionsPos &= ~ EXPRESSIONS_POS_MASK ; this . expressionsPos |= EXPRESSIONS_POS_BETWEEN_TWO ; this . scribe . printNextToken ( operator , this . preferences . insert_space_before_binary_operator , Scribe . PRESERVE_EMPTY_LINES_IN_BINARY_EXPRESSION ) ; if ( operator == TerminalTokens . TokenNameMINUS && isNextToken ( TerminalTokens . TokenNameMINUS ) ) { this . scribe . space ( ) ; } if ( this . preferences . insert_space_after_binary_operator ) { this . scribe . space ( ) ; } binaryExpression . right . traverse ( this , scope ) ; } } finally { this . expressionsDepth -- ; this . expressionsPos >>= <NUM_LIT:2> ; if ( this . expressionsDepth < <NUM_LIT:0> ) { this . lastBinaryExpressionAlignmentBreakIndentation = <NUM_LIT:0> ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( binaryExpression , numberOfParens ) ; } return false ; } private boolean dumpEqualityExpression ( BinaryExpression binaryExpression , int operator , BlockScope scope ) { final int numberOfParens = ( binaryExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( binaryExpression , numberOfParens ) ; } if ( this . expressionsDepth < <NUM_LIT:0> ) { this . expressionsDepth = <NUM_LIT:0> ; } else { this . expressionsDepth ++ ; this . expressionsPos <<= <NUM_LIT:2> ; } try { this . expressionsPos |= EXPRESSIONS_POS_ENTER_EQUALITY ; binaryExpression . left . traverse ( this , scope ) ; this . scribe . printNextToken ( operator , this . preferences . insert_space_before_binary_operator , Scribe . PRESERVE_EMPTY_LINES_IN_EQUALITY_EXPRESSION ) ; if ( this . preferences . insert_space_after_binary_operator ) { this . scribe . space ( ) ; } binaryExpression . right . traverse ( this , scope ) ; } finally { this . expressionsDepth -- ; this . expressionsPos >>= <NUM_LIT:2> ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( binaryExpression , numberOfParens ) ; } return false ; } private final TextEdit failedToFormat ( ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" + this . scribe . scanner ) ; System . out . println ( this . scribe ) ; } return null ; } private void format ( AbstractMethodDeclaration methodDeclaration , ClassScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { if ( isFirstClassBodyDeclaration ) { int newLinesBeforeFirstClassBodyDeclaration = this . preferences . blank_lines_before_first_class_body_declaration ; if ( newLinesBeforeFirstClassBodyDeclaration > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeFirstClassBodyDeclaration ) ; } } else { final int newLineBeforeChunk = isChunkStart ? this . preferences . blank_lines_before_new_chunk : <NUM_LIT:0> ; if ( newLineBeforeChunk > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLineBeforeChunk ) ; } } final int newLinesBeforeMethod = this . preferences . blank_lines_before_method ; if ( newLinesBeforeMethod > <NUM_LIT:0> && ! isFirstClassBodyDeclaration ) { this . scribe . printEmptyLines ( newLinesBeforeMethod ) ; } else if ( this . scribe . line != <NUM_LIT:0> || this . scribe . column != <NUM_LIT:1> ) { this . scribe . printNewLine ( ) ; } methodDeclaration . traverse ( this , scope ) ; } private void format ( FieldDeclaration fieldDeclaration , ASTVisitor visitor , MethodScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { if ( isFirstClassBodyDeclaration ) { int newLinesBeforeFirstClassBodyDeclaration = this . preferences . blank_lines_before_first_class_body_declaration ; if ( newLinesBeforeFirstClassBodyDeclaration > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeFirstClassBodyDeclaration ) ; } } else { int newLineBeforeChunk = isChunkStart ? this . preferences . blank_lines_before_new_chunk : <NUM_LIT:0> ; if ( newLineBeforeChunk > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLineBeforeChunk ) ; } final int newLinesBeforeField = this . preferences . blank_lines_before_field ; if ( newLinesBeforeField > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeField ) ; } } Alignment memberAlignment = this . scribe . getMemberAlignment ( ) ; this . scribe . printComment ( ) ; this . scribe . printModifiers ( fieldDeclaration . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_FIELD ) ; this . scribe . space ( ) ; fieldDeclaration . type . traverse ( this , scope ) ; this . scribe . alignFragment ( memberAlignment , <NUM_LIT:0> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; int extraDimensions = getDimensions ( ) ; if ( extraDimensions != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } final Expression initialization = fieldDeclaration . initialization ; if ( initialization != null ) { this . scribe . alignFragment ( memberAlignment , <NUM_LIT:1> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameEQUAL , this . preferences . insert_space_before_assignment_operator ) ; if ( this . preferences . insert_space_after_assignment_operator ) { this . scribe . space ( ) ; } Alignment assignmentAlignment = this . scribe . createAlignment ( Alignment . FIELD_DECLARATION_ASSIGNMENT , this . preferences . alignment_for_assignment , Alignment . R_INNERMOST , <NUM_LIT:1> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( assignmentAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( assignmentAlignment , <NUM_LIT:0> ) ; initialization . traverse ( this , scope ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( assignmentAlignment , true ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; if ( memberAlignment != null ) { this . scribe . alignFragment ( memberAlignment , <NUM_LIT:2> ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } else { this . scribe . space ( ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } private void format ( ImportReference importRef , boolean isLast ) { this . scribe . printNextToken ( TerminalTokens . TokenNameimport ) ; if ( ! isLast ) this . scribe . blank_lines_between_import_groups = this . preferences . blank_lines_between_import_groups ; this . scribe . space ( ) ; if ( importRef . isStatic ( ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNamestatic ) ; this . scribe . space ( ) ; } if ( ( importRef . bits & ASTNode . OnDemand ) != <NUM_LIT:0> ) { this . scribe . printQualifiedReference ( importRef . sourceEnd , false ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameMULTIPLY ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; } else { this . scribe . printQualifiedReference ( importRef . sourceEnd , false ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; } if ( isLast ) { this . scribe . blank_lines_between_import_groups = - <NUM_LIT:1> ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . IMPORT_TRAILING_COMMENT ) ; } else { this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . NO_TRAILING_COMMENT ) ; this . scribe . blank_lines_between_import_groups = - <NUM_LIT:1> ; } this . scribe . printNewLine ( ) ; } private void format ( MultiFieldDeclaration multiFieldDeclaration , ASTVisitor visitor , MethodScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { if ( isFirstClassBodyDeclaration ) { int newLinesBeforeFirstClassBodyDeclaration = this . preferences . blank_lines_before_first_class_body_declaration ; if ( newLinesBeforeFirstClassBodyDeclaration > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeFirstClassBodyDeclaration ) ; } } else { int newLineBeforeChunk = isChunkStart ? this . preferences . blank_lines_before_new_chunk : <NUM_LIT:0> ; if ( newLineBeforeChunk > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLineBeforeChunk ) ; } final int newLinesBeforeField = this . preferences . blank_lines_before_field ; if ( newLinesBeforeField > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeField ) ; } } Alignment fieldAlignment = this . scribe . getMemberAlignment ( ) ; this . scribe . printComment ( ) ; this . scribe . printModifiers ( multiFieldDeclaration . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_FIELD ) ; this . scribe . space ( ) ; multiFieldDeclaration . declarations [ <NUM_LIT:0> ] . type . traverse ( this , scope ) ; final int multipleFieldDeclarationsLength = multiFieldDeclaration . declarations . length ; Alignment multiFieldDeclarationsAlignment = this . scribe . createAlignment ( Alignment . MULTIPLE_FIELD , this . preferences . alignment_for_multiple_fields , multipleFieldDeclarationsLength - <NUM_LIT:1> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( multiFieldDeclarationsAlignment ) ; boolean ok = false ; do { try { for ( int i = <NUM_LIT:0> , length = multipleFieldDeclarationsLength ; i < length ; i ++ ) { FieldDeclaration fieldDeclaration = multiFieldDeclaration . declarations [ i ] ; if ( i == <NUM_LIT:0> ) { this . scribe . alignFragment ( fieldAlignment , <NUM_LIT:0> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , false ) ; } int extraDimensions = getDimensions ( ) ; if ( extraDimensions != <NUM_LIT:0> ) { for ( int index = <NUM_LIT:0> ; index < extraDimensions ; index ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } final Expression initialization = fieldDeclaration . initialization ; if ( initialization != null ) { if ( i == <NUM_LIT:0> ) { this . scribe . alignFragment ( fieldAlignment , <NUM_LIT:1> ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameEQUAL , this . preferences . insert_space_before_assignment_operator ) ; if ( this . preferences . insert_space_after_assignment_operator ) { this . scribe . space ( ) ; } initialization . traverse ( this , scope ) ; } if ( i != length - <NUM_LIT:1> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_multiple_field_declarations ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . alignFragment ( multiFieldDeclarationsAlignment , i ) ; if ( this . preferences . insert_space_after_comma_in_multiple_field_declarations ) { this . scribe . space ( ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . alignFragment ( fieldAlignment , <NUM_LIT:2> ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( multiFieldDeclarationsAlignment , true ) ; } public TextEdit format ( String string , ASTNode [ ] nodes ) { this . scribe . reset ( ) ; long startTime = <NUM_LIT:0> ; if ( DEBUG ) { startTime = System . currentTimeMillis ( ) ; } final char [ ] compilationUnitSource = string . toCharArray ( ) ; this . localScanner . setSource ( compilationUnitSource ) ; this . scribe . resetScanner ( compilationUnitSource ) ; if ( nodes == null ) { return null ; } this . lastLocalDeclarationSourceStart = - <NUM_LIT:1> ; try { formatClassBodyDeclarations ( nodes ) ; } catch ( AbortFormatting e ) { return failedToFormat ( ) ; } if ( DEBUG ) { System . out . println ( "<STR_LIT>" + ( System . currentTimeMillis ( ) - startTime ) ) ; } return this . scribe . getRootEdit ( ) ; } public TextEdit format ( String string , CompilationUnitDeclaration compilationUnitDeclaration ) { this . scribe . reset ( ) ; if ( compilationUnitDeclaration == null || compilationUnitDeclaration . ignoreFurtherInvestigation ) { return failedToFormat ( ) ; } long startTime = <NUM_LIT:0> ; if ( DEBUG ) { startTime = System . currentTimeMillis ( ) ; } final char [ ] compilationUnitSource = string . toCharArray ( ) ; this . localScanner . setSource ( compilationUnitSource ) ; this . scribe . resetScanner ( compilationUnitSource ) ; this . lastLocalDeclarationSourceStart = - <NUM_LIT:1> ; try { compilationUnitDeclaration . traverse ( this , compilationUnitDeclaration . scope ) ; } catch ( AbortFormatting e ) { return failedToFormat ( ) ; } if ( DEBUG ) { System . out . println ( "<STR_LIT>" + ( System . currentTimeMillis ( ) - startTime ) ) ; } return this . scribe . getRootEdit ( ) ; } public TextEdit format ( String string , ConstructorDeclaration constructorDeclaration ) { this . scribe . reset ( ) ; long startTime = <NUM_LIT:0> ; if ( DEBUG ) { startTime = System . currentTimeMillis ( ) ; } final char [ ] compilationUnitSource = string . toCharArray ( ) ; this . localScanner . setSource ( compilationUnitSource ) ; this . scribe . resetScanner ( compilationUnitSource ) ; if ( constructorDeclaration == null ) { return null ; } this . lastLocalDeclarationSourceStart = - <NUM_LIT:1> ; try { ExplicitConstructorCall explicitConstructorCall = constructorDeclaration . constructorCall ; if ( explicitConstructorCall != null && ! explicitConstructorCall . isImplicitSuper ( ) ) { explicitConstructorCall . traverse ( this , null ) ; } Statement [ ] statements = constructorDeclaration . statements ; if ( statements != null ) { formatStatements ( null , statements , false ) ; } if ( hasComments ( ) ) { this . scribe . printNewLine ( ) ; } this . scribe . printComment ( ) ; } catch ( AbortFormatting e ) { return failedToFormat ( ) ; } if ( DEBUG ) { System . out . println ( "<STR_LIT>" + ( System . currentTimeMillis ( ) - startTime ) ) ; } return this . scribe . getRootEdit ( ) ; } public TextEdit format ( String string , Expression expression ) { this . scribe . reset ( ) ; long startTime = <NUM_LIT:0> ; if ( DEBUG ) { startTime = System . currentTimeMillis ( ) ; } final char [ ] compilationUnitSource = string . toCharArray ( ) ; this . localScanner . setSource ( compilationUnitSource ) ; this . scribe . resetScanner ( compilationUnitSource ) ; if ( expression == null ) { return null ; } this . lastLocalDeclarationSourceStart = - <NUM_LIT:1> ; try { expression . traverse ( this , ( BlockScope ) null ) ; this . scribe . printComment ( ) ; } catch ( AbortFormatting e ) { return failedToFormat ( ) ; } if ( DEBUG ) { System . out . println ( "<STR_LIT>" + ( System . currentTimeMillis ( ) - startTime ) ) ; } return this . scribe . getRootEdit ( ) ; } public void formatComment ( int kind , String source , int start , int end , int indentationLevel ) { if ( source == null ) return ; this . scribe . printComment ( kind , source , start , end , indentationLevel ) ; } private void format ( TypeDeclaration typeDeclaration ) { this . scribe . printComment ( ) ; int line = this . scribe . line ; this . scribe . printModifiers ( typeDeclaration . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_TYPE ) ; if ( this . scribe . line > line ) { line = this . scribe . line ; } switch ( TypeDeclaration . kind ( typeDeclaration . modifiers ) ) { case TypeDeclaration . CLASS_DECL : this . scribe . printNextToken ( TerminalTokens . TokenNameclass , true ) ; break ; case TypeDeclaration . INTERFACE_DECL : this . scribe . printNextToken ( TerminalTokens . TokenNameinterface , true ) ; break ; case TypeDeclaration . ENUM_DECL : this . scribe . printNextToken ( TerminalTokens . TokenNameenum , true ) ; break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : this . scribe . printNextToken ( TerminalTokens . TokenNameAT , this . preferences . insert_space_before_at_in_annotation_type_declaration ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameinterface , this . preferences . insert_space_after_at_in_annotation_type_declaration ) ; break ; } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; TypeParameter [ ] typeParameters = typeDeclaration . typeParameters ; if ( typeParameters != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_parameters ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_parameters ) { this . scribe . space ( ) ; } int length = typeParameters . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeParameters [ i ] . traverse ( this , typeDeclaration . scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_parameters ) ; if ( this . preferences . insert_space_after_comma_in_type_parameters ) { this . scribe . space ( ) ; } } typeParameters [ length - <NUM_LIT:1> ] . traverse ( this , typeDeclaration . scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_parameters ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_parameters ) { this . scribe . space ( ) ; } } final TypeReference superclass = typeDeclaration . superclass ; if ( superclass != null ) { Alignment superclassAlignment = this . scribe . createAlignment ( Alignment . SUPER_CLASS , this . preferences . alignment_for_superclass_in_type_declaration , <NUM_LIT:2> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( superclassAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( superclassAlignment , <NUM_LIT:0> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameextends , true ) ; this . scribe . alignFragment ( superclassAlignment , <NUM_LIT:1> ) ; this . scribe . space ( ) ; superclass . traverse ( this , typeDeclaration . scope ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( superclassAlignment , true ) ; } final TypeReference [ ] superInterfaces = typeDeclaration . superInterfaces ; if ( superInterfaces != null ) { int alignment_for_superinterfaces ; int kind = TypeDeclaration . kind ( typeDeclaration . modifiers ) ; switch ( kind ) { case TypeDeclaration . ENUM_DECL : alignment_for_superinterfaces = this . preferences . alignment_for_superinterfaces_in_enum_declaration ; break ; default : alignment_for_superinterfaces = this . preferences . alignment_for_superinterfaces_in_type_declaration ; break ; } int superInterfaceLength = superInterfaces . length ; Alignment interfaceAlignment = this . scribe . createAlignment ( Alignment . SUPER_INTERFACES , alignment_for_superinterfaces , superInterfaceLength + <NUM_LIT:1> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( interfaceAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( interfaceAlignment , <NUM_LIT:0> ) ; if ( kind == TypeDeclaration . INTERFACE_DECL ) { this . scribe . printNextToken ( TerminalTokens . TokenNameextends , true ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameimplements , true ) ; } for ( int i = <NUM_LIT:0> ; i < superInterfaceLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_superinterfaces ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . alignFragment ( interfaceAlignment , i + <NUM_LIT:1> ) ; if ( this . preferences . insert_space_after_comma_in_superinterfaces ) { this . scribe . space ( ) ; } superInterfaces [ i ] . traverse ( this , typeDeclaration . scope ) ; } else { this . scribe . alignFragment ( interfaceAlignment , i + <NUM_LIT:1> ) ; this . scribe . space ( ) ; superInterfaces [ i ] . traverse ( this , typeDeclaration . scope ) ; } } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( interfaceAlignment , true ) ; } String class_declaration_brace ; boolean space_before_opening_brace ; int kind = TypeDeclaration . kind ( typeDeclaration . modifiers ) ; switch ( kind ) { case TypeDeclaration . ENUM_DECL : class_declaration_brace = this . preferences . brace_position_for_enum_declaration ; space_before_opening_brace = this . preferences . insert_space_before_opening_brace_in_enum_declaration ; break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : class_declaration_brace = this . preferences . brace_position_for_annotation_type_declaration ; space_before_opening_brace = this . preferences . insert_space_before_opening_brace_in_annotation_type_declaration ; break ; default : class_declaration_brace = this . preferences . brace_position_for_type_declaration ; space_before_opening_brace = this . preferences . insert_space_before_opening_brace_in_type_declaration ; break ; } formatLeftCurlyBrace ( line , class_declaration_brace ) ; formatTypeOpeningBrace ( class_declaration_brace , space_before_opening_brace , typeDeclaration ) ; boolean indent_body_declarations_compare_to_header ; switch ( kind ) { case TypeDeclaration . ENUM_DECL : indent_body_declarations_compare_to_header = this . preferences . indent_body_declarations_compare_to_enum_declaration_header ; break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : indent_body_declarations_compare_to_header = this . preferences . indent_body_declarations_compare_to_annotation_declaration_header ; break ; default : indent_body_declarations_compare_to_header = this . preferences . indent_body_declarations_compare_to_type_header ; break ; } if ( indent_body_declarations_compare_to_header ) { this . scribe . indent ( ) ; } if ( kind == TypeDeclaration . ENUM_DECL ) { FieldDeclaration [ ] fieldDeclarations = typeDeclaration . fields ; boolean hasConstants = false ; int length = fieldDeclarations != null ? fieldDeclarations . length : <NUM_LIT:0> ; int enumConstantsLength = <NUM_LIT:0> ; if ( fieldDeclarations != null ) { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { FieldDeclaration fieldDeclaration = fieldDeclarations [ i ] ; if ( fieldDeclaration . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { enumConstantsLength ++ ; } else { break ; } } hasConstants = enumConstantsLength != <NUM_LIT:0> ; if ( enumConstantsLength > <NUM_LIT:1> ) { Alignment enumConstantsAlignment = this . scribe . createAlignment ( Alignment . ENUM_CONSTANTS , this . preferences . alignment_for_enum_constants , enumConstantsLength , this . scribe . scanner . currentPosition , <NUM_LIT:0> , false ) ; this . scribe . enterAlignment ( enumConstantsAlignment ) ; boolean ok = false ; do { try { for ( int i = <NUM_LIT:0> ; i < enumConstantsLength ; i ++ ) { this . scribe . alignFragment ( enumConstantsAlignment , i ) ; FieldDeclaration fieldDeclaration = fieldDeclarations [ i ] ; fieldDeclaration . traverse ( this , typeDeclaration . initializerScope ) ; if ( isNextToken ( TerminalTokens . TokenNameCOMMA ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_enum_declarations ) ; if ( this . preferences . insert_space_after_comma_in_enum_declarations ) { this . scribe . space ( ) ; } this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( fieldDeclaration . initialization instanceof QualifiedAllocationExpression ) { this . scribe . printNewLine ( ) ; } } } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( enumConstantsAlignment , true ) ; } else if ( hasConstants ) { FieldDeclaration fieldDeclaration = fieldDeclarations [ <NUM_LIT:0> ] ; fieldDeclaration . traverse ( this , typeDeclaration . initializerScope ) ; if ( isNextToken ( TerminalTokens . TokenNameCOMMA ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_enum_declarations ) ; if ( this . preferences . insert_space_after_comma_in_enum_declarations ) { this . scribe . space ( ) ; } this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( fieldDeclaration . initialization instanceof QualifiedAllocationExpression ) { this . scribe . printNewLine ( ) ; } } } } if ( isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( hasConstants || ( ( enumConstantsLength - length ) != <NUM_LIT:0> ) || typeDeclaration . methods != null || typeDeclaration . memberTypes != null ) { this . scribe . printNewLine ( ) ; } } else if ( hasConstants ) { this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . printNewLine ( ) ; } } formatTypeMembers ( typeDeclaration ) ; if ( indent_body_declarations_compare_to_header ) { this . scribe . unIndent ( ) ; } switch ( kind ) { case TypeDeclaration . ENUM_DECL : if ( this . preferences . insert_new_line_in_empty_enum_declaration ) { this . scribe . printNewLine ( ) ; } break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : if ( this . preferences . insert_new_line_in_empty_annotation_declaration ) { this . scribe . printNewLine ( ) ; } break ; default : if ( this . preferences . insert_new_line_in_empty_type_declaration ) { this . scribe . printNewLine ( ) ; } } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( class_declaration_brace . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } if ( hasComments ( ) ) { this . scribe . printNewLine ( ) ; } } private void format ( TypeDeclaration memberTypeDeclaration , ClassScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { if ( isFirstClassBodyDeclaration ) { int newLinesBeforeFirstClassBodyDeclaration = this . preferences . blank_lines_before_first_class_body_declaration ; if ( newLinesBeforeFirstClassBodyDeclaration > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeFirstClassBodyDeclaration ) ; } } else { int newLineBeforeChunk = isChunkStart ? this . preferences . blank_lines_before_new_chunk : <NUM_LIT:0> ; if ( newLineBeforeChunk > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLineBeforeChunk ) ; } final int newLinesBeforeMember = this . preferences . blank_lines_before_member_type ; if ( newLinesBeforeMember > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeMember ) ; } } memberTypeDeclaration . traverse ( this , scope ) ; } private void formatAnonymousTypeDeclaration ( TypeDeclaration typeDeclaration ) { String anonymous_type_declaration_brace_position = this . preferences . brace_position_for_anonymous_type_declaration ; formatTypeOpeningBrace ( anonymous_type_declaration_brace_position , this . preferences . insert_space_before_opening_brace_in_anonymous_type_declaration , typeDeclaration ) ; this . scribe . indent ( ) ; formatTypeMembers ( typeDeclaration ) ; this . scribe . unIndent ( ) ; if ( this . preferences . insert_new_line_in_empty_anonymous_type_declaration ) { this . scribe . printNewLine ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE ) ; if ( anonymous_type_declaration_brace_position . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } } private void formatBlock ( Block block , BlockScope scope , String block_brace_position , boolean insertSpaceBeforeOpeningBrace ) { formatOpeningBrace ( block_brace_position , insertSpaceBeforeOpeningBrace ) ; final Statement [ ] statements = block . statements ; if ( statements != null ) { this . scribe . printNewLine ( ) ; if ( this . preferences . indent_statements_compare_to_block ) { this . scribe . indent ( ) ; } formatStatements ( scope , statements , true ) ; this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_AT_END_OF_BLOCK ) ; if ( this . preferences . indent_statements_compare_to_block ) { this . scribe . unIndent ( ) ; } } else if ( this . preferences . insert_new_line_in_empty_block ) { this . scribe . printNewLine ( ) ; if ( this . preferences . indent_statements_compare_to_block ) { this . scribe . indent ( ) ; } this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_AT_END_OF_BLOCK ) ; if ( this . preferences . indent_statements_compare_to_block ) { this . scribe . unIndent ( ) ; } } else { if ( this . preferences . indent_statements_compare_to_block ) { this . scribe . indent ( ) ; } this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_AT_END_OF_BLOCK ) ; if ( this . preferences . indent_statements_compare_to_block ) { this . scribe . unIndent ( ) ; } } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED . equals ( block_brace_position ) ) { this . scribe . unIndent ( ) ; } } private void formatCascadingMessageSends ( CascadingMethodInvocationFragmentBuilder builder , BlockScope scope ) { int size = builder . size ( ) ; MessageSend [ ] fragments = builder . fragments ( ) ; Expression fragment = fragments [ <NUM_LIT:0> ] . receiver ; int startingPositionInCascade = <NUM_LIT:1> ; if ( ! fragment . isImplicitThis ( ) ) { fragment . traverse ( this , scope ) ; } else { MessageSend currentMessageSend = fragments [ <NUM_LIT:1> ] ; final int numberOfParens = ( currentMessageSend . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( currentMessageSend , numberOfParens ) ; } ASTNode [ ] arguments = currentMessageSend . arguments ; TypeReference [ ] typeArguments = currentMessageSend . typeArguments ; if ( typeArguments != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_arguments ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } int length = typeArguments . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_arguments ) ; if ( this . preferences . insert_space_after_comma_in_type_arguments ) { this . scribe . space ( ) ; } } typeArguments [ length - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_arguments ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_method_invocation ) ; if ( arguments != null ) { if ( this . preferences . insert_space_after_opening_paren_in_method_invocation ) { this . scribe . space ( ) ; } int argumentLength = arguments . length ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . MESSAGE_ARGUMENTS , this . preferences . alignment_for_arguments_in_method_invocation , Alignment . R_OUTERMOST , argumentLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean okForArguments = false ; do { try { for ( int j = <NUM_LIT:0> ; j < argumentLength ; j ++ ) { if ( j > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_method_invocation_arguments ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . alignFragment ( argumentsAlignment , j ) ; if ( j > <NUM_LIT:0> && this . preferences . insert_space_after_comma_in_method_invocation_arguments ) { this . scribe . space ( ) ; } arguments [ j ] . traverse ( this , scope ) ; } okForArguments = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! okForArguments ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_method_invocation ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_between_empty_parens_in_method_invocation ) ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( currentMessageSend , numberOfParens ) ; } startingPositionInCascade = <NUM_LIT:2> ; } int tieBreakRule = this . preferences . wrap_outer_expressions_when_nested && size - startingPositionInCascade > <NUM_LIT:2> ? Alignment . R_OUTERMOST : Alignment . R_INNERMOST ; Alignment cascadingMessageSendAlignment = this . scribe . createAlignment ( Alignment . CASCADING_MESSAGE_SEND , this . preferences . alignment_for_selector_in_method_invocation , tieBreakRule , size , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( cascadingMessageSendAlignment ) ; boolean ok = false ; boolean setStartingColumn = true ; switch ( this . preferences . alignment_for_arguments_in_method_invocation & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_FIRST_BREAK_SPLIT : case Alignment . M_NEXT_SHIFTED_SPLIT : case Alignment . M_ONE_PER_LINE_SPLIT : setStartingColumn = false ; break ; } do { if ( setStartingColumn ) { cascadingMessageSendAlignment . startingColumn = this . scribe . column ; } try { this . scribe . alignFragment ( cascadingMessageSendAlignment , <NUM_LIT:0> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; for ( int i = startingPositionInCascade ; i < size ; i ++ ) { MessageSend currentMessageSend = fragments [ i ] ; final int numberOfParens = ( currentMessageSend . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( currentMessageSend , numberOfParens ) ; } TypeReference [ ] typeArguments = currentMessageSend . typeArguments ; if ( typeArguments != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_arguments ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } int length = typeArguments . length ; for ( int j = <NUM_LIT:0> ; j < length - <NUM_LIT:1> ; j ++ ) { typeArguments [ j ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_arguments ) ; if ( this . preferences . insert_space_after_comma_in_type_arguments ) { this . scribe . space ( ) ; } } typeArguments [ length - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_arguments ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } } ASTNode [ ] arguments = currentMessageSend . arguments ; this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_method_invocation ) ; if ( arguments != null ) { if ( this . preferences . insert_space_after_opening_paren_in_method_invocation ) { this . scribe . space ( ) ; } int argumentLength = arguments . length ; int alignmentMode = this . preferences . alignment_for_arguments_in_method_invocation ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . MESSAGE_ARGUMENTS , alignmentMode , Alignment . R_OUTERMOST , argumentLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean okForArguments = false ; do { switch ( alignmentMode & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : argumentsAlignment . startingColumn = this . scribe . column ; break ; } try { for ( int j = <NUM_LIT:0> ; j < argumentLength ; j ++ ) { if ( j > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_method_invocation_arguments ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . alignFragment ( argumentsAlignment , j ) ; if ( j == <NUM_LIT:0> ) { int fragmentIndentation = argumentsAlignment . fragmentIndentations [ j ] ; if ( ( argumentsAlignment . mode & Alignment . M_INDENT_ON_COLUMN ) != <NUM_LIT:0> && fragmentIndentation > <NUM_LIT:0> ) { this . scribe . indentationLevel = fragmentIndentation ; } } else if ( this . preferences . insert_space_after_comma_in_method_invocation_arguments ) { this . scribe . space ( ) ; } arguments [ j ] . traverse ( this , scope ) ; argumentsAlignment . startingColumn = - <NUM_LIT:1> ; } okForArguments = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! okForArguments ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_method_invocation ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_between_empty_parens_in_method_invocation ) ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( currentMessageSend , numberOfParens ) ; } cascadingMessageSendAlignment . startingColumn = - <NUM_LIT:1> ; if ( i < size - <NUM_LIT:1> ) { this . scribe . alignFragment ( cascadingMessageSendAlignment , i ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; } } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( cascadingMessageSendAlignment , true ) ; } private void formatClassBodyDeclarations ( ASTNode [ ] nodes ) { final int FIELD = <NUM_LIT:1> , METHOD = <NUM_LIT:2> , TYPE = <NUM_LIT:3> ; this . scribe . lastNumberOfNewLines = <NUM_LIT:1> ; ASTNode [ ] mergedNodes = computeMergedMemberDeclarations ( nodes ) ; Alignment memberAlignment = this . scribe . createMemberAlignment ( Alignment . TYPE_MEMBERS , this . preferences . align_type_members_on_columns ? Alignment . M_MULTICOLUMN : Alignment . M_NO_ALIGNMENT , <NUM_LIT:4> , this . scribe . scanner . currentPosition ) ; this . scribe . enterMemberAlignment ( memberAlignment ) ; boolean isChunkStart = false ; boolean ok = false ; int startIndex = <NUM_LIT:0> ; do { try { for ( int i = startIndex , max = mergedNodes . length ; i < max ; i ++ ) { ASTNode member = mergedNodes [ i ] ; if ( member instanceof FieldDeclaration ) { isChunkStart = memberAlignment . checkChunkStart ( FIELD , i , this . scribe . scanner . currentPosition ) ; if ( member instanceof MultiFieldDeclaration ) { MultiFieldDeclaration multiField = ( MultiFieldDeclaration ) member ; format ( multiField , this , null , isChunkStart , i == <NUM_LIT:0> ) ; } else if ( member instanceof Initializer ) { int newLineBeforeChunk = isChunkStart ? this . preferences . blank_lines_before_new_chunk : <NUM_LIT:0> ; if ( newLineBeforeChunk > <NUM_LIT:0> && i != <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLineBeforeChunk ) ; } else if ( i == <NUM_LIT:0> ) { int newLinesBeforeFirstClassBodyDeclaration = this . preferences . blank_lines_before_first_class_body_declaration ; if ( newLinesBeforeFirstClassBodyDeclaration > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeFirstClassBodyDeclaration ) ; } } Initializer initializer = ( Initializer ) member ; initializer . traverse ( this , null ) ; } else { FieldDeclaration field = ( FieldDeclaration ) member ; format ( field , this , null , isChunkStart , i == <NUM_LIT:0> ) ; } } else if ( member instanceof AbstractMethodDeclaration ) { isChunkStart = memberAlignment . checkChunkStart ( METHOD , i , this . scribe . scanner . currentPosition ) ; format ( ( AbstractMethodDeclaration ) member , null , isChunkStart , i == <NUM_LIT:0> ) ; } else { isChunkStart = memberAlignment . checkChunkStart ( TYPE , i , this . scribe . scanner . currentPosition ) ; format ( ( TypeDeclaration ) member , null , isChunkStart , i == <NUM_LIT:0> ) ; } while ( isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } if ( i != max - <NUM_LIT:1> ) { this . scribe . printNewLine ( ) ; } } ok = true ; } catch ( AlignmentException e ) { startIndex = memberAlignment . chunkStartIndex ; this . scribe . redoMemberAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitMemberAlignment ( memberAlignment ) ; if ( hasComments ( ) ) { this . scribe . printNewLine ( ) ; } this . scribe . printComment ( ) ; } private void formatEmptyTypeDeclaration ( boolean isFirst ) { boolean hasSemiColon = isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ; while ( isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ) { this . scribe . printComment ( ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } if ( hasSemiColon && isFirst ) { this . scribe . printNewLine ( ) ; } } private void formatGuardClauseBlock ( Block block , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACE , this . preferences . insert_space_before_opening_brace_in_block ) ; this . scribe . space ( ) ; final Statement [ ] statements = block . statements ; statements [ <NUM_LIT:0> ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE , true ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } private void formatLeftCurlyBrace ( final int line , final String bracePosition ) { this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_IN_FORMAT_LEFT_CURLY_BRACE ) ; if ( DefaultCodeFormatterConstants . NEXT_LINE_ON_WRAP . equals ( bracePosition ) && ( this . scribe . line > line || this . scribe . column >= this . preferences . page_width ) ) { this . scribe . printNewLine ( ) ; } } private void formatLocalDeclaration ( LocalDeclaration localDeclaration , BlockScope scope , boolean insertSpaceBeforeComma , boolean insertSpaceAfterComma ) { if ( ! isMultipleLocalDeclaration ( localDeclaration ) ) { if ( localDeclaration . modifiers != NO_MODIFIERS || localDeclaration . annotations != null ) { this . scribe . printComment ( ) ; this . scribe . printModifiers ( localDeclaration . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_LOCAL_VARIABLE ) ; this . scribe . space ( ) ; } if ( localDeclaration . type != null ) { localDeclaration . type . traverse ( this , scope ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , false ) ; } int extraDimensions = getDimensions ( ) ; if ( extraDimensions != <NUM_LIT:0> ) { for ( int index = <NUM_LIT:0> ; index < extraDimensions ; index ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } final Expression initialization = localDeclaration . initialization ; if ( initialization != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameEQUAL , this . preferences . insert_space_before_assignment_operator ) ; if ( this . preferences . insert_space_after_assignment_operator ) { this . scribe . space ( ) ; } Alignment assignmentAlignment = this . scribe . createAlignment ( Alignment . LOCAL_DECLARATION_ASSIGNMENT , this . preferences . alignment_for_assignment , Alignment . R_OUTERMOST , <NUM_LIT:1> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( assignmentAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( assignmentAlignment , <NUM_LIT:0> ) ; initialization . traverse ( this , scope ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( assignmentAlignment , true ) ; } if ( isPartOfMultipleLocalDeclaration ( ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , insertSpaceBeforeComma ) ; if ( insertSpaceAfterComma ) { this . scribe . space ( ) ; } this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } private void formatMessageSend ( MessageSend messageSend , BlockScope scope , Alignment messageAlignment ) { if ( messageAlignment != null ) { if ( ! this . preferences . wrap_outer_expressions_when_nested || messageAlignment . canAlign ( ) ) { this . scribe . alignFragment ( messageAlignment , <NUM_LIT:0> ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; } TypeReference [ ] typeArguments = messageSend . typeArguments ; if ( typeArguments != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_arguments ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } int length = typeArguments . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_arguments ) ; if ( this . preferences . insert_space_after_comma_in_type_arguments ) { this . scribe . space ( ) ; } } typeArguments [ length - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_arguments ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_method_invocation ) ; final Expression [ ] arguments = messageSend . arguments ; if ( arguments != null ) { if ( this . preferences . insert_space_after_opening_paren_in_method_invocation ) { this . scribe . space ( ) ; } int argumentsLength = arguments . length ; if ( argumentsLength > <NUM_LIT:1> ) { int alignmentMode = this . preferences . alignment_for_arguments_in_method_invocation ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . MESSAGE_ARGUMENTS , alignmentMode , argumentsLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean ok = false ; do { switch ( alignmentMode & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : argumentsAlignment . startingColumn = this . scribe . column ; break ; } try { for ( int i = <NUM_LIT:0> ; i < argumentsLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_method_invocation_arguments ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( this . scribe . lastNumberOfNewLines == <NUM_LIT:1> ) { this . scribe . indentationLevel = argumentsAlignment . breakIndentationLevel ; } } this . scribe . alignFragment ( argumentsAlignment , i ) ; if ( i > <NUM_LIT:0> && this . preferences . insert_space_after_comma_in_method_invocation_arguments ) { this . scribe . space ( ) ; } int fragmentIndentation = <NUM_LIT:0> ; if ( i == <NUM_LIT:0> ) { int wrappedIndex = argumentsAlignment . wrappedIndex ( ) ; if ( wrappedIndex >= <NUM_LIT:0> ) { fragmentIndentation = argumentsAlignment . fragmentIndentations [ wrappedIndex ] ; if ( ( argumentsAlignment . mode & Alignment . M_INDENT_ON_COLUMN ) != <NUM_LIT:0> && fragmentIndentation > <NUM_LIT:0> ) { this . scribe . indentationLevel = fragmentIndentation ; } } } arguments [ i ] . traverse ( this , scope ) ; argumentsAlignment . startingColumn = - <NUM_LIT:1> ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; } else { arguments [ <NUM_LIT:0> ] . traverse ( this , scope ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_method_invocation ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_between_empty_parens_in_method_invocation ) ; } } private void formatTryResources ( TryStatement tryStatement , boolean spaceBeforeOpenParen , boolean spaceBeforeClosingParen , boolean spaceBeforeFirstResource , boolean spaceBeforeSemicolon , boolean spaceAfterSemicolon , int tryResourcesAligment ) { LocalDeclaration [ ] resources = tryStatement . resources ; int length = resources != null ? resources . length : <NUM_LIT:0> ; if ( length > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , spaceBeforeOpenParen ) ; if ( spaceBeforeFirstResource ) { this . scribe . space ( ) ; } Alignment resourcesAlignment = this . scribe . createAlignment ( Alignment . TRY_RESOURCES , tryResourcesAligment , Alignment . R_OUTERMOST , length , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( resourcesAlignment ) ; boolean ok = false ; do { switch ( tryResourcesAligment & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : resourcesAlignment . startingColumn = this . scribe . column ; break ; } try { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , spaceBeforeSemicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( this . scribe . lastNumberOfNewLines == <NUM_LIT:1> ) { this . scribe . indentationLevel = resourcesAlignment . breakIndentationLevel ; } } this . scribe . alignFragment ( resourcesAlignment , i ) ; if ( i == <NUM_LIT:0> ) { int fragmentIndentation = resourcesAlignment . fragmentIndentations [ <NUM_LIT:0> ] ; if ( ( resourcesAlignment . mode & Alignment . M_INDENT_ON_COLUMN ) != <NUM_LIT:0> && fragmentIndentation > <NUM_LIT:0> ) { this . scribe . indentationLevel = fragmentIndentation ; } } else if ( spaceAfterSemicolon ) { this . scribe . space ( ) ; } resources [ i ] . traverse ( this , null ) ; resourcesAlignment . startingColumn = - <NUM_LIT:1> ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; if ( isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , spaceBeforeSemicolon ) ; } this . scribe . exitAlignment ( resourcesAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , spaceBeforeClosingParen ) ; } } private void formatMethodArguments ( AbstractMethodDeclaration methodDeclaration , boolean spaceBeforeOpenParen , boolean spaceBetweenEmptyParameters , boolean spaceBeforeClosingParen , boolean spaceBeforeFirstParameter , boolean spaceBeforeComma , boolean spaceAfterComma , int methodDeclarationParametersAlignment ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , spaceBeforeOpenParen ) ; final Argument [ ] arguments = methodDeclaration . arguments ; if ( arguments != null ) { if ( spaceBeforeFirstParameter ) { this . scribe . space ( ) ; } int argumentLength = arguments . length ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . METHOD_ARGUMENTS , methodDeclarationParametersAlignment , argumentLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean ok = false ; do { switch ( methodDeclarationParametersAlignment & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : argumentsAlignment . startingColumn = this . scribe . column ; break ; } try { for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , spaceBeforeComma ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( this . scribe . lastNumberOfNewLines == <NUM_LIT:1> ) { this . scribe . indentationLevel = argumentsAlignment . breakIndentationLevel ; } } this . scribe . alignFragment ( argumentsAlignment , i ) ; if ( i == <NUM_LIT:0> ) { int fragmentIndentation = argumentsAlignment . fragmentIndentations [ <NUM_LIT:0> ] ; if ( ( argumentsAlignment . mode & Alignment . M_INDENT_ON_COLUMN ) != <NUM_LIT:0> && fragmentIndentation > <NUM_LIT:0> ) { this . scribe . indentationLevel = fragmentIndentation ; } } else if ( spaceAfterComma ) { this . scribe . space ( ) ; } arguments [ i ] . traverse ( this , methodDeclaration . scope ) ; argumentsAlignment . startingColumn = - <NUM_LIT:1> ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , spaceBeforeClosingParen ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , spaceBetweenEmptyParameters ) ; } } private void formatEnumConstantArguments ( FieldDeclaration enumConstant , boolean spaceBeforeOpenParen , boolean spaceBetweenEmptyParameters , boolean spaceBeforeClosingParen , boolean spaceBeforeFirstParameter , boolean spaceBeforeComma , boolean spaceAfterComma , int methodDeclarationParametersAlignment ) { if ( ! isNextToken ( TerminalTokens . TokenNameLPAREN ) ) { return ; } this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , spaceBeforeOpenParen ) ; final Expression [ ] arguments = ( ( AllocationExpression ) enumConstant . initialization ) . arguments ; if ( arguments != null ) { int argumentLength = arguments . length ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . ENUM_CONSTANTS_ARGUMENTS , methodDeclarationParametersAlignment , argumentLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean ok = false ; do { try { if ( spaceBeforeFirstParameter ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , spaceBeforeComma ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . alignFragment ( argumentsAlignment , i ) ; if ( i > <NUM_LIT:0> && spaceAfterComma ) { this . scribe . space ( ) ; } arguments [ i ] . traverse ( this , ( BlockScope ) null ) ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , spaceBeforeClosingParen ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , spaceBetweenEmptyParameters ) ; } } private void formatNecessaryEmptyStatement ( ) { if ( this . preferences . put_empty_statement_on_new_line ) { this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . unIndent ( ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } private void formatOpeningBrace ( String bracePosition , boolean insertSpaceBeforeBrace ) { if ( DefaultCodeFormatterConstants . NEXT_LINE . equals ( bracePosition ) ) { this . scribe . printNewLine ( ) ; } else if ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED . equals ( bracePosition ) ) { this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACE , insertSpaceBeforeBrace , Scribe . PRESERVE_EMPTY_LINES_IN_FORMAT_OPENING_BRACE ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . UNMODIFIABLE_TRAILING_COMMENT ) ; } private void formatStatements ( BlockScope scope , final Statement [ ] statements , boolean insertNewLineAfterLastStatement ) { int statementsLength = statements . length ; for ( int i = <NUM_LIT:0> ; i < statementsLength ; i ++ ) { final Statement statement = statements [ i ] ; if ( i > <NUM_LIT:0> && ( statements [ i - <NUM_LIT:1> ] instanceof EmptyStatement ) && ! ( statement instanceof EmptyStatement ) ) { this . scribe . printNewLine ( ) ; } statement . traverse ( this , scope ) ; if ( statement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( i != statementsLength - <NUM_LIT:1> ) { if ( ! ( statement instanceof EmptyStatement ) && ! ( statements [ i + <NUM_LIT:1> ] instanceof EmptyStatement ) ) { this . scribe . printNewLine ( ) ; } } else if ( i == statementsLength - <NUM_LIT:1> && insertNewLineAfterLastStatement ) { this . scribe . printNewLine ( ) ; } } else if ( statement instanceof LocalDeclaration ) { LocalDeclaration currentLocal = ( LocalDeclaration ) statement ; if ( i < ( statementsLength - <NUM_LIT:1> ) ) { if ( statements [ i + <NUM_LIT:1> ] instanceof LocalDeclaration ) { LocalDeclaration nextLocal = ( LocalDeclaration ) statements [ i + <NUM_LIT:1> ] ; if ( currentLocal . declarationSourceStart != nextLocal . declarationSourceStart ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( i != statementsLength - <NUM_LIT:1> ) { if ( ! ( statement instanceof EmptyStatement ) && ! ( statements [ i + <NUM_LIT:1> ] instanceof EmptyStatement ) ) { this . scribe . printNewLine ( ) ; } } else if ( i == statementsLength - <NUM_LIT:1> && insertNewLineAfterLastStatement ) { this . scribe . printNewLine ( ) ; } } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( i != statementsLength - <NUM_LIT:1> ) { if ( ! ( statement instanceof EmptyStatement ) && ! ( statements [ i + <NUM_LIT:1> ] instanceof EmptyStatement ) ) { this . scribe . printNewLine ( ) ; } } else if ( i == statementsLength - <NUM_LIT:1> && insertNewLineAfterLastStatement ) { this . scribe . printNewLine ( ) ; } } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( i != statementsLength - <NUM_LIT:1> ) { if ( ! ( statement instanceof EmptyStatement ) && ! ( statements [ i + <NUM_LIT:1> ] instanceof EmptyStatement ) ) { this . scribe . printNewLine ( ) ; } } else if ( i == statementsLength - <NUM_LIT:1> && insertNewLineAfterLastStatement ) { this . scribe . printNewLine ( ) ; } } } else if ( i != statementsLength - <NUM_LIT:1> ) { if ( ! ( statement instanceof EmptyStatement ) && ! ( statements [ i + <NUM_LIT:1> ] instanceof EmptyStatement ) ) { this . scribe . printNewLine ( ) ; } } else if ( i == statementsLength - <NUM_LIT:1> && insertNewLineAfterLastStatement ) { this . scribe . printNewLine ( ) ; } } } private void formatThrowsClause ( AbstractMethodDeclaration methodDeclaration , boolean spaceBeforeComma , boolean spaceAfterComma , int alignmentForThrowsClause ) { final TypeReference [ ] thrownExceptions = methodDeclaration . thrownExceptions ; if ( thrownExceptions != null ) { int thrownExceptionsLength = thrownExceptions . length ; Alignment throwsAlignment = this . scribe . createAlignment ( Alignment . THROWS , alignmentForThrowsClause , thrownExceptionsLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( throwsAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( throwsAlignment , <NUM_LIT:0> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNamethrows , true ) ; for ( int i = <NUM_LIT:0> ; i < thrownExceptionsLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , spaceBeforeComma ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . alignFragment ( throwsAlignment , i ) ; if ( spaceAfterComma ) { this . scribe . space ( ) ; } } else { this . scribe . space ( ) ; } thrownExceptions [ i ] . traverse ( this , methodDeclaration . scope ) ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( throwsAlignment , true ) ; } } private void formatTypeMembers ( TypeDeclaration typeDeclaration ) { Alignment memberAlignment = this . scribe . createMemberAlignment ( Alignment . TYPE_MEMBERS , this . preferences . align_type_members_on_columns ? Alignment . M_MULTICOLUMN : Alignment . M_NO_ALIGNMENT , <NUM_LIT:3> , this . scribe . scanner . currentPosition ) ; this . scribe . enterMemberAlignment ( memberAlignment ) ; ASTNode [ ] members = computeMergedMemberDeclarations ( typeDeclaration ) ; boolean isChunkStart = false ; boolean ok = false ; int membersLength = members . length ; if ( membersLength > <NUM_LIT:0> ) { int startIndex = <NUM_LIT:0> ; do { try { for ( int i = startIndex , max = members . length ; i < max ; i ++ ) { while ( isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . printNewLine ( ) ; ASTNode member = members [ i ] ; if ( member instanceof FieldDeclaration ) { isChunkStart = memberAlignment . checkChunkStart ( Alignment . CHUNK_FIELD , i , this . scribe . scanner . currentPosition ) ; if ( member instanceof MultiFieldDeclaration ) { MultiFieldDeclaration multiField = ( MultiFieldDeclaration ) member ; if ( multiField . isStatic ( ) ) { format ( multiField , this , typeDeclaration . staticInitializerScope , isChunkStart , i == <NUM_LIT:0> ) ; } else { format ( multiField , this , typeDeclaration . initializerScope , isChunkStart , i == <NUM_LIT:0> ) ; } } else if ( member instanceof Initializer ) { int newLineBeforeChunk = isChunkStart ? this . preferences . blank_lines_before_new_chunk : <NUM_LIT:0> ; if ( newLineBeforeChunk > <NUM_LIT:0> && i != <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLineBeforeChunk ) ; } else if ( i == <NUM_LIT:0> ) { int newLinesBeforeFirstClassBodyDeclaration = this . preferences . blank_lines_before_first_class_body_declaration ; if ( newLinesBeforeFirstClassBodyDeclaration > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( newLinesBeforeFirstClassBodyDeclaration ) ; } } Initializer initializer = ( Initializer ) member ; if ( initializer . isStatic ( ) ) { initializer . traverse ( this , typeDeclaration . staticInitializerScope ) ; } else { initializer . traverse ( this , typeDeclaration . initializerScope ) ; } } else { FieldDeclaration field = ( FieldDeclaration ) member ; if ( field . isStatic ( ) ) { format ( field , this , typeDeclaration . staticInitializerScope , isChunkStart , i == <NUM_LIT:0> ) ; } else { format ( field , this , typeDeclaration . initializerScope , isChunkStart , i == <NUM_LIT:0> ) ; } } } else if ( member instanceof AbstractMethodDeclaration ) { isChunkStart = memberAlignment . checkChunkStart ( Alignment . CHUNK_METHOD , i , this . scribe . scanner . currentPosition ) ; format ( ( AbstractMethodDeclaration ) member , typeDeclaration . scope , isChunkStart , i == <NUM_LIT:0> ) ; } else if ( member instanceof TypeDeclaration ) { isChunkStart = memberAlignment . checkChunkStart ( Alignment . CHUNK_TYPE , i , this . scribe . scanner . currentPosition ) ; format ( ( TypeDeclaration ) member , typeDeclaration . scope , isChunkStart , i == <NUM_LIT:0> ) ; } while ( isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . printNewLine ( ) ; if ( this . scribe . memberAlignment != null ) { this . scribe . indentationLevel = this . scribe . memberAlignment . originalIndentationLevel ; } } ok = true ; } catch ( AlignmentException e ) { startIndex = memberAlignment . chunkStartIndex ; this . scribe . redoMemberAlignment ( e ) ; } } while ( ! ok ) ; } else if ( isNextToken ( TerminalTokens . TokenNameSEMICOLON ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . printComment ( Scribe . DO_NOT_PRESERVE_EMPTY_LINES ) ; this . scribe . exitMemberAlignment ( memberAlignment ) ; } private void formatTypeOpeningBraceForEnumConstant ( String bracePosition , boolean insertSpaceBeforeBrace , TypeDeclaration typeDeclaration ) { int fieldCount = ( typeDeclaration . fields == null ) ? <NUM_LIT:0> : typeDeclaration . fields . length ; int methodCount = ( typeDeclaration . methods == null ) ? <NUM_LIT:0> : typeDeclaration . methods . length ; int typeCount = ( typeDeclaration . memberTypes == null ) ? <NUM_LIT:0> : typeDeclaration . memberTypes . length ; if ( methodCount <= <NUM_LIT:2> ) { for ( int i = <NUM_LIT:0> , max = methodCount ; i < max ; i ++ ) { final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration . methods [ i ] ; if ( abstractMethodDeclaration . isDefaultConstructor ( ) ) { methodCount -- ; } else if ( abstractMethodDeclaration . isClinit ( ) ) { methodCount -- ; } } } final int memberLength = fieldCount + methodCount + typeCount ; boolean insertNewLine = memberLength > <NUM_LIT:0> ; if ( ! insertNewLine ) { if ( ( typeDeclaration . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { insertNewLine = this . preferences . insert_new_line_in_empty_enum_constant ; } } formatOpeningBrace ( bracePosition , insertSpaceBeforeBrace ) ; if ( insertNewLine ) { this . scribe . printNewLine ( ) ; } } private void formatTypeOpeningBrace ( String bracePosition , boolean insertSpaceBeforeBrace , TypeDeclaration typeDeclaration ) { int fieldCount = ( typeDeclaration . fields == null ) ? <NUM_LIT:0> : typeDeclaration . fields . length ; int methodCount = ( typeDeclaration . methods == null ) ? <NUM_LIT:0> : typeDeclaration . methods . length ; int typeCount = ( typeDeclaration . memberTypes == null ) ? <NUM_LIT:0> : typeDeclaration . memberTypes . length ; if ( methodCount <= <NUM_LIT:2> ) { for ( int i = <NUM_LIT:0> , max = methodCount ; i < max ; i ++ ) { final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration . methods [ i ] ; if ( abstractMethodDeclaration . isDefaultConstructor ( ) ) { methodCount -- ; } else if ( abstractMethodDeclaration . isClinit ( ) ) { methodCount -- ; } } } final int memberLength = fieldCount + methodCount + typeCount ; boolean insertNewLine = memberLength > <NUM_LIT:0> ; if ( ! insertNewLine ) { if ( TypeDeclaration . kind ( typeDeclaration . modifiers ) == TypeDeclaration . ENUM_DECL ) { insertNewLine = this . preferences . insert_new_line_in_empty_enum_declaration ; } else if ( ( typeDeclaration . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { insertNewLine = this . preferences . insert_new_line_in_empty_anonymous_type_declaration ; } else if ( TypeDeclaration . kind ( typeDeclaration . modifiers ) == TypeDeclaration . ANNOTATION_TYPE_DECL ) { insertNewLine = this . preferences . insert_new_line_in_empty_annotation_declaration ; } else { insertNewLine = this . preferences . insert_new_line_in_empty_type_declaration ; } } formatOpeningBrace ( bracePosition , insertSpaceBeforeBrace ) ; if ( insertNewLine ) { this . scribe . printNewLine ( ) ; } } private int getDimensions ( ) { this . localScanner . resetTo ( this . scribe . scanner . currentPosition , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; int dimensions = <NUM_LIT:0> ; int balance = <NUM_LIT:0> ; try { int token ; loop : while ( ( token = this . localScanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameRBRACKET : dimensions ++ ; balance -- ; break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : break ; case TerminalTokens . TokenNameLBRACKET : balance ++ ; break ; default : break loop ; } } } catch ( InvalidInputException e ) { } if ( balance == <NUM_LIT:0> ) { return dimensions ; } return <NUM_LIT:0> ; } private boolean hasComments ( ) { this . localScanner . resetTo ( this . scribe . scanner . startPosition , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; try { switch ( this . localScanner . getNextToken ( ) ) { case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : return true ; } } catch ( InvalidInputException e ) { } return false ; } private boolean isNextToken ( int tokenName ) { this . localScanner . resetTo ( this . scribe . scanner . currentPosition , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; try { int token = this . localScanner . getNextToken ( ) ; loop : while ( true ) { switch ( token ) { case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : token = this . localScanner . getNextToken ( ) ; continue loop ; default : break loop ; } } return token == tokenName ; } catch ( InvalidInputException e ) { } return false ; } private boolean isClosingGenericToken ( ) { this . localScanner . resetTo ( this . scribe . scanner . currentPosition , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; try { int token = this . localScanner . getNextToken ( ) ; loop : while ( true ) { switch ( token ) { case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : token = this . localScanner . getNextToken ( ) ; continue loop ; default : break loop ; } } switch ( token ) { case TerminalTokens . TokenNameGREATER : case TerminalTokens . TokenNameRIGHT_SHIFT : case TerminalTokens . TokenNameUNSIGNED_RIGHT_SHIFT : return true ; } } catch ( InvalidInputException e ) { } return false ; } private boolean isGuardClause ( Block block ) { return ! commentStartsBlock ( block . sourceStart , block . sourceEnd ) && block . statements != null && block . statements . length == <NUM_LIT:1> && ( block . statements [ <NUM_LIT:0> ] instanceof ReturnStatement || block . statements [ <NUM_LIT:0> ] instanceof ThrowStatement ) ; } private boolean isMultipleLocalDeclaration ( LocalDeclaration localDeclaration ) { if ( localDeclaration . declarationSourceStart == this . lastLocalDeclarationSourceStart ) return true ; this . lastLocalDeclarationSourceStart = localDeclaration . declarationSourceStart ; return false ; } private boolean isPartOfMultipleLocalDeclaration ( ) { this . localScanner . resetTo ( this . scribe . scanner . currentPosition , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; try { int token ; while ( ( token = this . localScanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameCOMMA : return true ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : break ; default : return false ; } } } catch ( InvalidInputException e ) { } return false ; } private void manageClosingParenthesizedExpression ( Expression expression , int numberOfParens ) { for ( int i = <NUM_LIT:0> ; i < numberOfParens ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_parenthesized_expression ) ; } } private void manageOpeningParenthesizedExpression ( Expression expression , int numberOfParens ) { for ( int i = <NUM_LIT:0> ; i < numberOfParens ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_parenthesized_expression ) ; if ( this . preferences . insert_space_after_opening_paren_in_parenthesized_expression ) { this . scribe . space ( ) ; } } } private void printComment ( ) { this . localScanner . resetTo ( this . scribe . scanner . startPosition , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; try { int token = this . localScanner . getNextToken ( ) ; switch ( token ) { case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_LINE : this . scribe . printComment ( token , Scribe . NO_TRAILING_COMMENT ) ; break ; } } catch ( InvalidInputException e ) { } } public boolean visit ( AllocationExpression allocationExpression , BlockScope scope ) { final int numberOfParens = ( allocationExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( allocationExpression , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamenew ) ; TypeReference [ ] typeArguments = allocationExpression . typeArguments ; if ( typeArguments != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_arguments ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } int length = typeArguments . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_arguments ) ; if ( this . preferences . insert_space_after_comma_in_type_arguments ) { this . scribe . space ( ) ; } } typeArguments [ length - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_arguments ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } } else { this . scribe . space ( ) ; } allocationExpression . type . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_method_invocation ) ; final Expression [ ] arguments = allocationExpression . arguments ; if ( arguments != null ) { if ( this . preferences . insert_space_after_opening_paren_in_method_invocation ) { this . scribe . space ( ) ; } int argumentLength = arguments . length ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . ALLOCATION , this . preferences . alignment_for_arguments_in_allocation_expression , argumentLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean ok = false ; do { try { for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_allocation_expression ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . alignFragment ( argumentsAlignment , i ) ; if ( i > <NUM_LIT:0> && this . preferences . insert_space_after_comma_in_allocation_expression ) { this . scribe . space ( ) ; } arguments [ i ] . traverse ( this , scope ) ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_method_invocation ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_between_empty_parens_in_method_invocation ) ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( allocationExpression , numberOfParens ) ; } return false ; } public boolean visit ( AND_AND_Expression and_and_Expression , BlockScope scope ) { return dumpBinaryExpression ( and_and_Expression , TerminalTokens . TokenNameAND_AND , scope ) ; } public boolean visit ( AnnotationMethodDeclaration annotationTypeMemberDeclaration , ClassScope scope ) { this . scribe . printComment ( ) ; this . scribe . printModifiers ( annotationTypeMemberDeclaration . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_METHOD ) ; this . scribe . space ( ) ; final TypeReference returnType = annotationTypeMemberDeclaration . returnType ; final MethodScope annotationTypeMemberDeclarationScope = annotationTypeMemberDeclaration . scope ; if ( returnType != null ) { returnType . traverse ( this , annotationTypeMemberDeclarationScope ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_annotation_type_member_declaration ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_between_empty_parens_in_annotation_type_member_declaration ) ; int extraDimensions = annotationTypeMemberDeclaration . extendedDimensions ; if ( extraDimensions != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } Expression defaultValue = annotationTypeMemberDeclaration . defaultValue ; if ( defaultValue != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNamedefault , true ) ; this . scribe . space ( ) ; defaultValue . traverse ( this , ( BlockScope ) null ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( Argument argument , BlockScope scope ) { if ( argument . modifiers != NO_MODIFIERS || argument . annotations != null ) { this . scribe . printComment ( ) ; this . scribe . printModifiers ( argument . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_PARAMETER ) ; this . scribe . space ( ) ; } if ( argument . type != null ) { if ( argument . type instanceof UnionTypeReference ) { formatMultiCatchArguments ( argument , this . preferences . insert_space_before_binary_operator , this . preferences . insert_space_after_binary_operator , this . preferences . alignment_for_union_type_in_multicatch , scope ) ; } else { argument . type . traverse ( this , scope ) ; } } if ( argument . isVarArgs ( ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameELLIPSIS , this . preferences . insert_space_before_ellipsis ) ; if ( this . preferences . insert_space_after_ellipsis ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , false ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; } int extraDimensions = getDimensions ( ) ; if ( extraDimensions != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } return false ; } public boolean visit ( ArrayAllocationExpression arrayAllocationExpression , BlockScope scope ) { final int numberOfParens = ( arrayAllocationExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( arrayAllocationExpression , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamenew ) ; this . scribe . space ( ) ; arrayAllocationExpression . type . traverse ( this , scope ) ; final Expression [ ] dimensions = arrayAllocationExpression . dimensions ; int dimensionsLength = dimensions . length ; for ( int i = <NUM_LIT:0> ; i < dimensionsLength ; i ++ ) { if ( this . preferences . insert_space_before_opening_bracket_in_array_allocation_expression ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET , false ) ; if ( dimensions [ i ] != null ) { if ( this . preferences . insert_space_after_opening_bracket_in_array_allocation_expression ) { this . scribe . space ( ) ; } dimensions [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET , this . preferences . insert_space_before_closing_bracket_in_array_allocation_expression ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET , this . preferences . insert_space_between_empty_brackets_in_array_allocation_expression ) ; } } final ArrayInitializer initializer = arrayAllocationExpression . initializer ; if ( initializer != null ) { initializer . traverse ( this , scope ) ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( arrayAllocationExpression , numberOfParens ) ; } return false ; } public boolean visit ( ArrayInitializer arrayInitializer , BlockScope scope ) { final int numberOfParens = ( arrayInitializer . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( arrayInitializer , numberOfParens ) ; } if ( this . arrayInitializersDepth < <NUM_LIT:0> ) { this . arrayInitializersDepth = <NUM_LIT:0> ; } else { this . arrayInitializersDepth ++ ; } int arrayInitializerIndentationLevel = this . scribe . indentationLevel ; try { final Expression [ ] expressions = arrayInitializer . expressions ; if ( expressions != null ) { String array_initializer_brace_position = this . preferences . brace_position_for_array_initializer ; formatOpeningBrace ( array_initializer_brace_position , this . preferences . insert_space_before_opening_brace_in_array_initializer ) ; int expressionsLength = expressions . length ; final boolean insert_new_line_after_opening_brace = this . preferences . insert_new_line_after_opening_brace_in_array_initializer ; boolean ok = false ; Alignment arrayInitializerAlignment = null ; if ( expressionsLength > <NUM_LIT:1> ) { if ( insert_new_line_after_opening_brace ) { this . scribe . printNewLine ( ) ; } arrayInitializerAlignment = this . scribe . createAlignment ( Alignment . ARRAY_INITIALIZER , this . preferences . alignment_for_expressions_in_array_initializer , Alignment . R_OUTERMOST , expressionsLength , this . scribe . scanner . currentPosition , this . preferences . continuation_indentation_for_array_initializer , true ) ; if ( insert_new_line_after_opening_brace ) { arrayInitializerAlignment . fragmentIndentations [ <NUM_LIT:0> ] = arrayInitializerAlignment . breakIndentationLevel ; } this . scribe . enterAlignment ( arrayInitializerAlignment ) ; do { try { this . scribe . alignFragment ( arrayInitializerAlignment , <NUM_LIT:0> ) ; if ( this . preferences . insert_space_after_opening_brace_in_array_initializer ) { this . scribe . space ( ) ; } expressions [ <NUM_LIT:0> ] . traverse ( this , scope ) ; for ( int i = <NUM_LIT:1> ; i < expressionsLength ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_array_initializer ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . alignFragment ( arrayInitializerAlignment , i ) ; if ( this . preferences . insert_space_after_comma_in_array_initializer ) { this . scribe . space ( ) ; } expressions [ i ] . traverse ( this , scope ) ; if ( i == expressionsLength - <NUM_LIT:1> ) { if ( isNextToken ( TerminalTokens . TokenNameCOMMA ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_array_initializer ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( arrayInitializerAlignment , true ) ; } else { if ( this . scribe . currentAlignment == null || this . scribe . currentAlignment . kind != Alignment . MESSAGE_ARGUMENTS ) { arrayInitializerAlignment = this . scribe . createAlignment ( Alignment . ARRAY_INITIALIZER , this . preferences . alignment_for_expressions_in_array_initializer , Alignment . R_OUTERMOST , <NUM_LIT:0> , this . scribe . scanner . currentPosition , this . preferences . continuation_indentation_for_array_initializer , true ) ; this . scribe . enterAlignment ( arrayInitializerAlignment ) ; } do { try { if ( insert_new_line_after_opening_brace ) { this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; } if ( this . preferences . insert_space_after_opening_brace_in_array_initializer ) { this . scribe . space ( ) ; } else { this . scribe . needSpace = false ; } expressions [ <NUM_LIT:0> ] . traverse ( this , scope ) ; if ( isNextToken ( TerminalTokens . TokenNameCOMMA ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_array_initializer ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } if ( insert_new_line_after_opening_brace ) { this . scribe . unIndent ( ) ; } ok = true ; } catch ( AlignmentException e ) { if ( arrayInitializerAlignment == null ) throw e ; this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; if ( arrayInitializerAlignment != null ) { this . scribe . exitAlignment ( arrayInitializerAlignment , true ) ; } } if ( this . preferences . insert_new_line_before_closing_brace_in_array_initializer ) { this . scribe . printNewLine ( ) ; } else if ( this . preferences . insert_space_before_closing_brace_in_array_initializer ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE , false , Scribe . PRESERVE_EMPTY_LINES_IN_CLOSING_ARRAY_INITIALIZER + ( arrayInitializerIndentationLevel << <NUM_LIT:16> ) ) ; if ( array_initializer_brace_position . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } } else { boolean keepEmptyArrayInitializerOnTheSameLine = this . preferences . keep_empty_array_initializer_on_one_line ; String array_initializer_brace_position = this . preferences . brace_position_for_array_initializer ; if ( keepEmptyArrayInitializerOnTheSameLine ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACE , this . preferences . insert_space_before_opening_brace_in_array_initializer ) ; if ( isNextToken ( TerminalTokens . TokenNameCOMMA ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_array_initializer ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE , this . preferences . insert_space_between_empty_braces_in_array_initializer ) ; } else { formatOpeningBrace ( array_initializer_brace_position , this . preferences . insert_space_before_opening_brace_in_array_initializer ) ; if ( isNextToken ( TerminalTokens . TokenNameCOMMA ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_array_initializer ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE , this . preferences . insert_space_between_empty_braces_in_array_initializer ) ; if ( array_initializer_brace_position . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } } } } finally { this . arrayInitializersDepth -- ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( arrayInitializer , numberOfParens ) ; } return false ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , BlockScope scope ) { final int numberOfParens = ( arrayQualifiedTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( arrayQualifiedTypeReference , numberOfParens ) ; } this . scribe . printArrayQualifiedReference ( arrayQualifiedTypeReference . tokens . length , arrayQualifiedTypeReference . sourceEnd ) ; int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( arrayQualifiedTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , ClassScope scope ) { final int numberOfParens = ( arrayQualifiedTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( arrayQualifiedTypeReference , numberOfParens ) ; } this . scribe . printArrayQualifiedReference ( arrayQualifiedTypeReference . tokens . length , arrayQualifiedTypeReference . sourceEnd ) ; int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( arrayQualifiedTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( ArrayReference arrayReference , BlockScope scope ) { final int numberOfParens = ( arrayReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( arrayReference , numberOfParens ) ; } arrayReference . receiver . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET , this . preferences . insert_space_before_opening_bracket_in_array_reference ) ; if ( this . preferences . insert_space_after_opening_bracket_in_array_reference ) { this . scribe . space ( ) ; } arrayReference . position . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET , this . preferences . insert_space_before_closing_bracket_in_array_reference ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( arrayReference , numberOfParens ) ; } return false ; } public boolean visit ( ArrayTypeReference arrayTypeReference , BlockScope scope ) { final int numberOfParens = ( arrayTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( arrayTypeReference , numberOfParens ) ; } this . scribe . printNextToken ( SINGLETYPEREFERENCE_EXPECTEDTOKENS ) ; int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> ) { if ( this . preferences . insert_space_before_opening_bracket_in_array_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; if ( this . preferences . insert_space_between_brackets_in_array_type_reference ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( arrayTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( ArrayTypeReference arrayTypeReference , ClassScope scope ) { final int numberOfParens = ( arrayTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( arrayTypeReference , numberOfParens ) ; } this . scribe . printNextToken ( SINGLETYPEREFERENCE_EXPECTEDTOKENS ) ; int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> ) { if ( this . preferences . insert_space_before_opening_bracket_in_array_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; if ( this . preferences . insert_space_between_brackets_in_array_type_reference ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( arrayTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( AssertStatement assertStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameassert ) ; this . scribe . space ( ) ; assertStatement . assertExpression . traverse ( this , scope ) ; if ( assertStatement . exceptionArgument != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOLON , this . preferences . insert_space_before_colon_in_assert ) ; if ( this . preferences . insert_space_after_colon_in_assert ) { this . scribe . space ( ) ; } assertStatement . exceptionArgument . traverse ( this , scope ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( Assignment assignment , BlockScope scope ) { final int numberOfParens = ( assignment . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( assignment , numberOfParens ) ; } assignment . lhs . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameEQUAL , this . preferences . insert_space_before_assignment_operator ) ; if ( this . preferences . insert_space_after_assignment_operator ) { this . scribe . space ( ) ; } Alignment assignmentAlignment = this . scribe . createAlignment ( Alignment . ASSIGNMENT , this . preferences . alignment_for_assignment , Alignment . R_OUTERMOST , <NUM_LIT:1> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( assignmentAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( assignmentAlignment , <NUM_LIT:0> ) ; assignment . expression . traverse ( this , scope ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( assignmentAlignment , true ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( assignment , numberOfParens ) ; } return false ; } public boolean visit ( BinaryExpression binaryExpression , BlockScope scope ) { switch ( ( binaryExpression . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT ) { case OperatorIds . AND : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameAND , scope ) ; case OperatorIds . DIVIDE : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameDIVIDE , scope ) ; case OperatorIds . GREATER : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameGREATER , scope ) ; case OperatorIds . GREATER_EQUAL : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameGREATER_EQUAL , scope ) ; case OperatorIds . LEFT_SHIFT : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameLEFT_SHIFT , scope ) ; case OperatorIds . LESS : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameLESS , scope ) ; case OperatorIds . LESS_EQUAL : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameLESS_EQUAL , scope ) ; case OperatorIds . MINUS : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameMINUS , scope ) ; case OperatorIds . MULTIPLY : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameMULTIPLY , scope ) ; case OperatorIds . OR : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameOR , scope ) ; case OperatorIds . PLUS : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNamePLUS , scope ) ; case OperatorIds . REMAINDER : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameREMAINDER , scope ) ; case OperatorIds . RIGHT_SHIFT : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameRIGHT_SHIFT , scope ) ; case OperatorIds . UNSIGNED_RIGHT_SHIFT : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameUNSIGNED_RIGHT_SHIFT , scope ) ; case OperatorIds . XOR : return dumpBinaryExpression ( binaryExpression , TerminalTokens . TokenNameXOR , scope ) ; default : throw new IllegalStateException ( ) ; } } public boolean visit ( Block block , BlockScope scope ) { formatBlock ( block , scope , this . preferences . brace_position_for_block , this . preferences . insert_space_before_opening_brace_in_block ) ; return false ; } public boolean visit ( BreakStatement breakStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamebreak ) ; if ( breakStatement . label != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( CaseStatement caseStatement , BlockScope scope ) { if ( caseStatement . constantExpression == null ) { this . scribe . printNextToken ( TerminalTokens . TokenNamedefault ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOLON , this . preferences . insert_space_before_colon_in_default ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNamecase ) ; this . scribe . space ( ) ; caseStatement . constantExpression . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOLON , this . preferences . insert_space_before_colon_in_case ) ; } return false ; } public boolean visit ( CastExpression castExpression , BlockScope scope ) { final int numberOfParens = ( castExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( castExpression , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN ) ; if ( this . preferences . insert_space_after_opening_paren_in_cast ) { this . scribe . space ( ) ; } castExpression . type . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_cast ) ; if ( this . preferences . insert_space_after_closing_paren_in_cast ) { this . scribe . space ( ) ; } castExpression . expression . traverse ( this , scope ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( castExpression , numberOfParens ) ; } return false ; } public boolean visit ( CharLiteral charLiteral , BlockScope scope ) { final int numberOfParens = ( charLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( charLiteral , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameCharacterLiteral ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( charLiteral , numberOfParens ) ; } return false ; } public boolean visit ( ClassLiteralAccess classLiteral , BlockScope scope ) { final int numberOfParens = ( classLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( classLiteral , numberOfParens ) ; } classLiteral . type . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameclass ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( classLiteral , numberOfParens ) ; } return false ; } public boolean visit ( Clinit clinit , ClassScope scope ) { return false ; } public boolean visit ( CompilationUnitDeclaration compilationUnitDeclaration , CompilationUnitScope scope ) { this . scribe . lastNumberOfNewLines = <NUM_LIT:1> ; final TypeDeclaration [ ] types = compilationUnitDeclaration . types ; int headerEndPosition = types == null ? compilationUnitDeclaration . sourceEnd : types [ <NUM_LIT:0> ] . declarationSourceStart ; this . scribe . setHeaderComment ( headerEndPosition ) ; ImportReference currentPackage = compilationUnitDeclaration . currentPackage ; final boolean hasPackage = currentPackage != null ; if ( hasPackage ) { printComment ( ) ; int blankLinesBeforePackage = this . preferences . blank_lines_before_package ; if ( blankLinesBeforePackage > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( blankLinesBeforePackage ) ; } this . scribe . printModifiers ( currentPackage . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_PACKAGE ) ; this . scribe . space ( ) ; this . scribe . printNextToken ( TerminalTokens . TokenNamepackage ) ; this . scribe . space ( ) ; this . scribe . printQualifiedReference ( compilationUnitDeclaration . currentPackage . sourceEnd , false ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; int blankLinesAfterPackage = this . preferences . blank_lines_after_package ; if ( blankLinesAfterPackage > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( blankLinesAfterPackage ) ; } else { this . scribe . printNewLine ( ) ; } } else { this . scribe . printComment ( ) ; } final ImportReference [ ] imports = compilationUnitDeclaration . imports ; if ( imports != null ) { if ( hasPackage ) { int blankLinesBeforeImports = this . preferences . blank_lines_before_imports ; if ( blankLinesBeforeImports > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( blankLinesBeforeImports ) ; } } int importLength = imports . length ; if ( importLength != <NUM_LIT:1> ) { format ( imports [ <NUM_LIT:0> ] , false ) ; for ( int i = <NUM_LIT:1> ; i < importLength - <NUM_LIT:1> ; i ++ ) { format ( imports [ i ] , false ) ; } format ( imports [ importLength - <NUM_LIT:1> ] , true ) ; } else { format ( imports [ <NUM_LIT:0> ] , true ) ; } int blankLinesAfterImports = this . preferences . blank_lines_after_imports ; if ( blankLinesAfterImports > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( blankLinesAfterImports ) ; } } formatEmptyTypeDeclaration ( true ) ; int blankLineBetweenTypeDeclarations = this . preferences . blank_lines_between_type_declarations ; if ( types != null ) { int typesLength = types . length ; for ( int i = <NUM_LIT:0> ; i < typesLength - <NUM_LIT:1> ; i ++ ) { types [ i ] . traverse ( this , scope ) ; formatEmptyTypeDeclaration ( false ) ; if ( blankLineBetweenTypeDeclarations != <NUM_LIT:0> ) { this . scribe . printEmptyLines ( blankLineBetweenTypeDeclarations ) ; } else { this . scribe . printNewLine ( ) ; } } types [ typesLength - <NUM_LIT:1> ] . traverse ( this , scope ) ; } this . scribe . printEndOfCompilationUnit ( ) ; return false ; } public boolean visit ( CompoundAssignment compoundAssignment , BlockScope scope ) { final int numberOfParens = ( compoundAssignment . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( compoundAssignment , numberOfParens ) ; } compoundAssignment . lhs . traverse ( this , scope ) ; int operator ; switch ( compoundAssignment . operator ) { case OperatorIds . PLUS : operator = TerminalTokens . TokenNamePLUS_EQUAL ; break ; case OperatorIds . MINUS : operator = TerminalTokens . TokenNameMINUS_EQUAL ; break ; case OperatorIds . MULTIPLY : operator = TerminalTokens . TokenNameMULTIPLY_EQUAL ; break ; case OperatorIds . DIVIDE : operator = TerminalTokens . TokenNameDIVIDE_EQUAL ; break ; case OperatorIds . AND : operator = TerminalTokens . TokenNameAND_EQUAL ; break ; case OperatorIds . OR : operator = TerminalTokens . TokenNameOR_EQUAL ; break ; case OperatorIds . XOR : operator = TerminalTokens . TokenNameXOR_EQUAL ; break ; case OperatorIds . REMAINDER : operator = TerminalTokens . TokenNameREMAINDER_EQUAL ; break ; case OperatorIds . LEFT_SHIFT : operator = TerminalTokens . TokenNameLEFT_SHIFT_EQUAL ; break ; case OperatorIds . RIGHT_SHIFT : operator = TerminalTokens . TokenNameRIGHT_SHIFT_EQUAL ; break ; default : operator = TerminalTokens . TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL ; } this . scribe . printNextToken ( operator , this . preferences . insert_space_before_assignment_operator ) ; if ( this . preferences . insert_space_after_assignment_operator ) { this . scribe . space ( ) ; } Alignment assignmentAlignment = this . scribe . createAlignment ( Alignment . COMPOUND_ASSIGNMENT , this . preferences . alignment_for_assignment , Alignment . R_OUTERMOST , <NUM_LIT:1> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( assignmentAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( assignmentAlignment , <NUM_LIT:0> ) ; compoundAssignment . expression . traverse ( this , scope ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( assignmentAlignment , true ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( compoundAssignment , numberOfParens ) ; } return false ; } public boolean visit ( ConditionalExpression conditionalExpression , BlockScope scope ) { final int numberOfParens = ( conditionalExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( conditionalExpression , numberOfParens ) ; } conditionalExpression . condition . traverse ( this , scope ) ; Alignment conditionalExpressionAlignment = this . scribe . createAlignment ( Alignment . CONDITIONAL_EXPRESSION , this . preferences . alignment_for_conditional_expression , <NUM_LIT:2> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( conditionalExpressionAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( conditionalExpressionAlignment , <NUM_LIT:0> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameQUESTION , this . preferences . insert_space_before_question_in_conditional ) ; if ( this . preferences . insert_space_after_question_in_conditional ) { this . scribe . space ( ) ; } conditionalExpression . valueIfTrue . traverse ( this , scope ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . alignFragment ( conditionalExpressionAlignment , <NUM_LIT:1> ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOLON , this . preferences . insert_space_before_colon_in_conditional ) ; if ( this . preferences . insert_space_after_colon_in_conditional ) { this . scribe . space ( ) ; } conditionalExpression . valueIfFalse . traverse ( this , scope ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( conditionalExpressionAlignment , true ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( conditionalExpression , numberOfParens ) ; } return false ; } public boolean visit ( ConstructorDeclaration constructorDeclaration , ClassScope scope ) { if ( constructorDeclaration . ignoreFurtherInvestigation ) { this . scribe . printComment ( ) ; if ( this . scribe . indentationLevel != <NUM_LIT:0> ) { this . scribe . printIndentationIfNecessary ( ) ; } this . scribe . scanner . resetTo ( constructorDeclaration . declarationSourceEnd + <NUM_LIT:1> , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; switch ( this . scribe . scanner . source [ this . scribe . scanner . currentPosition ] ) { case '<STR_LIT:\n>' : this . scribe . scanner . currentPosition ++ ; this . scribe . lastNumberOfNewLines = <NUM_LIT:1> ; break ; case '<STR_LIT>' : this . scribe . scanner . currentPosition ++ ; if ( this . scribe . scanner . source [ this . scribe . scanner . currentPosition ] == '<STR_LIT:\n>' ) { this . scribe . scanner . currentPosition ++ ; } this . scribe . lastNumberOfNewLines = <NUM_LIT:1> ; } return false ; } this . scribe . printComment ( ) ; int line = this . scribe . line ; this . scribe . printModifiers ( constructorDeclaration . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_METHOD ) ; if ( this . scribe . line > line ) { line = this . scribe . line ; } this . scribe . space ( ) ; TypeParameter [ ] typeParameters = constructorDeclaration . typeParameters ; if ( typeParameters != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_parameters ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_parameters ) { this . scribe . space ( ) ; } int length = typeParameters . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeParameters [ i ] . traverse ( this , constructorDeclaration . scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_parameters ) ; if ( this . preferences . insert_space_after_comma_in_type_parameters ) { this . scribe . space ( ) ; } } typeParameters [ length - <NUM_LIT:1> ] . traverse ( this , constructorDeclaration . scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_parameters ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_parameters ) { this . scribe . space ( ) ; } } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; formatMethodArguments ( constructorDeclaration , this . preferences . insert_space_before_opening_paren_in_constructor_declaration , this . preferences . insert_space_between_empty_parens_in_constructor_declaration , this . preferences . insert_space_before_closing_paren_in_constructor_declaration , this . preferences . insert_space_after_opening_paren_in_constructor_declaration , this . preferences . insert_space_before_comma_in_constructor_declaration_parameters , this . preferences . insert_space_after_comma_in_constructor_declaration_parameters , this . preferences . alignment_for_parameters_in_constructor_declaration ) ; formatThrowsClause ( constructorDeclaration , this . preferences . insert_space_before_comma_in_constructor_declaration_throws , this . preferences . insert_space_after_comma_in_constructor_declaration_throws , this . preferences . alignment_for_throws_clause_in_constructor_declaration ) ; if ( ! constructorDeclaration . isNative ( ) && ! constructorDeclaration . isAbstract ( ) ) { String constructor_declaration_brace = this . preferences . brace_position_for_constructor_declaration ; formatLeftCurlyBrace ( line , constructor_declaration_brace ) ; formatOpeningBrace ( constructor_declaration_brace , this . preferences . insert_space_before_opening_brace_in_constructor_declaration ) ; final int numberOfBlankLinesAtBeginningOfMethodBody = this . preferences . blank_lines_at_beginning_of_method_body ; if ( numberOfBlankLinesAtBeginningOfMethodBody > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( numberOfBlankLinesAtBeginningOfMethodBody ) ; } if ( constructorDeclaration . constructorCall != null && ! constructorDeclaration . constructorCall . isImplicitSuper ( ) ) { this . scribe . printNewLine ( ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . indent ( ) ; } constructorDeclaration . constructorCall . traverse ( this , constructorDeclaration . scope ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . unIndent ( ) ; } } final Statement [ ] statements = constructorDeclaration . statements ; if ( statements != null ) { this . scribe . printNewLine ( ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . indent ( ) ; } formatStatements ( constructorDeclaration . scope , statements , true ) ; this . scribe . printComment ( ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . unIndent ( ) ; } } else { if ( this . preferences . insert_new_line_in_empty_method_body ) { this . scribe . printNewLine ( ) ; } if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . indent ( ) ; } this . scribe . printComment ( ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . unIndent ( ) ; } } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( constructor_declaration_brace . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } return false ; } public boolean visit ( ContinueStatement continueStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamecontinue ) ; if ( continueStatement . label != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( DoStatement doStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamedo ) ; final int line = this . scribe . line ; final Statement action = doStatement . action ; if ( action != null ) { if ( action instanceof Block ) { formatLeftCurlyBrace ( line , this . preferences . brace_position_for_block ) ; action . traverse ( this , scope ) ; } else if ( action instanceof EmptyStatement ) { formatNecessaryEmptyStatement ( ) ; } else { this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; action . traverse ( this , scope ) ; if ( action instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . printNewLine ( ) ; this . scribe . unIndent ( ) ; } } else { formatNecessaryEmptyStatement ( ) ; } if ( this . preferences . insert_new_line_before_while_in_do_statement ) { this . scribe . printNewLine ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamewhile , this . preferences . insert_space_after_closing_brace_in_block ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_while ) ; if ( this . preferences . insert_space_after_opening_paren_in_while ) { this . scribe . space ( ) ; } doStatement . condition . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_while ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( DoubleLiteral doubleLiteral , BlockScope scope ) { final int numberOfParens = ( doubleLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( doubleLiteral , numberOfParens ) ; } if ( isNextToken ( TerminalTokens . TokenNameMINUS ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameMINUS ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameDoubleLiteral ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( doubleLiteral , numberOfParens ) ; } return false ; } public boolean visit ( EmptyStatement statement , BlockScope scope ) { if ( this . preferences . put_empty_statement_on_new_line ) { this . scribe . printNewLine ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( FieldDeclaration enumConstant , MethodScope scope ) { this . scribe . printComment ( ) ; final int line = this . scribe . line ; this . scribe . printModifiers ( enumConstant . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_FIELD ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , false ) ; formatEnumConstantArguments ( enumConstant , this . preferences . insert_space_before_opening_paren_in_enum_constant , this . preferences . insert_space_between_empty_parens_in_enum_constant , this . preferences . insert_space_before_closing_paren_in_enum_constant , this . preferences . insert_space_after_opening_paren_in_enum_constant , this . preferences . insert_space_before_comma_in_enum_constant_arguments , this . preferences . insert_space_after_comma_in_enum_constant_arguments , this . preferences . alignment_for_arguments_in_enum_constant ) ; Expression initialization = enumConstant . initialization ; if ( initialization instanceof QualifiedAllocationExpression ) { TypeDeclaration typeDeclaration = ( ( QualifiedAllocationExpression ) initialization ) . anonymousType ; int fieldsCount = typeDeclaration . fields == null ? <NUM_LIT:0> : typeDeclaration . fields . length ; int methodsCount = typeDeclaration . methods == null ? <NUM_LIT:0> : typeDeclaration . methods . length ; int membersCount = typeDeclaration . memberTypes == null ? <NUM_LIT:0> : typeDeclaration . memberTypes . length ; String enum_constant_brace = this . preferences . brace_position_for_enum_constant ; formatLeftCurlyBrace ( line , enum_constant_brace ) ; formatTypeOpeningBraceForEnumConstant ( enum_constant_brace , this . preferences . insert_space_before_opening_brace_in_enum_constant , typeDeclaration ) ; if ( this . preferences . indent_body_declarations_compare_to_enum_constant_header ) { this . scribe . indent ( ) ; } if ( fieldsCount != <NUM_LIT:0> || methodsCount != <NUM_LIT:0> || membersCount != <NUM_LIT:0> ) { formatTypeMembers ( typeDeclaration ) ; } if ( this . preferences . indent_body_declarations_compare_to_enum_constant_header ) { this . scribe . unIndent ( ) ; } if ( this . preferences . insert_new_line_in_empty_enum_constant ) { this . scribe . printNewLine ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( enum_constant_brace . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } if ( hasComments ( ) ) { this . scribe . printNewLine ( ) ; } } return false ; } public boolean visit ( EqualExpression equalExpression , BlockScope scope ) { if ( ( equalExpression . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT == OperatorIds . EQUAL_EQUAL ) { return dumpEqualityExpression ( equalExpression , TerminalTokens . TokenNameEQUAL_EQUAL , scope ) ; } else { return dumpEqualityExpression ( equalExpression , TerminalTokens . TokenNameNOT_EQUAL , scope ) ; } } public boolean visit ( ExplicitConstructorCall explicitConstructor , BlockScope scope ) { if ( explicitConstructor . isImplicitSuper ( ) ) { return false ; } final Expression qualification = explicitConstructor . qualification ; if ( qualification != null ) { qualification . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; } TypeReference [ ] typeArguments = explicitConstructor . typeArguments ; if ( typeArguments != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_arguments ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } int length = typeArguments . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_arguments ) ; if ( this . preferences . insert_space_after_comma_in_type_arguments ) { this . scribe . space ( ) ; } } typeArguments [ length - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_arguments ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } } if ( explicitConstructor . isSuperAccess ( ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNamesuper ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNamethis ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_method_invocation ) ; final Expression [ ] arguments = explicitConstructor . arguments ; if ( arguments != null ) { if ( this . preferences . insert_space_after_opening_paren_in_method_invocation ) { this . scribe . space ( ) ; } int argumentLength = arguments . length ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . EXPLICIT_CONSTRUCTOR_CALL , this . preferences . alignment_for_arguments_in_explicit_constructor_call , argumentLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean ok = false ; do { try { for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_explicit_constructor_call_arguments ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . alignFragment ( argumentsAlignment , i ) ; if ( i > <NUM_LIT:0> && this . preferences . insert_space_after_comma_in_explicit_constructor_call_arguments ) { this . scribe . space ( ) ; } arguments [ i ] . traverse ( this , scope ) ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_method_invocation ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_between_empty_parens_in_method_invocation ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( FalseLiteral falseLiteral , BlockScope scope ) { final int numberOfParens = ( falseLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( falseLiteral , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamefalse ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( falseLiteral , numberOfParens ) ; } return false ; } public boolean visit ( FieldReference fieldReference , BlockScope scope ) { final int numberOfParens = ( fieldReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( fieldReference , numberOfParens ) ; } fieldReference . receiver . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( fieldReference , numberOfParens ) ; } return false ; } public boolean visit ( FloatLiteral floatLiteral , BlockScope scope ) { final int numberOfParens = ( floatLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( floatLiteral , numberOfParens ) ; } if ( isNextToken ( TerminalTokens . TokenNameMINUS ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameMINUS ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameFloatingPointLiteral ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( floatLiteral , numberOfParens ) ; } return false ; } public boolean visit ( ForeachStatement forStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamefor ) ; final int line = this . scribe . line ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_for ) ; if ( this . preferences . insert_space_after_opening_paren_in_for ) { this . scribe . space ( ) ; } formatLocalDeclaration ( forStatement . elementVariable , scope , false , false ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOLON , this . preferences . insert_space_before_colon_in_for ) ; if ( this . preferences . insert_space_after_colon_in_for ) { this . scribe . space ( ) ; } forStatement . collection . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_for ) ; final Statement action = forStatement . action ; if ( action != null ) { if ( action instanceof Block ) { formatLeftCurlyBrace ( line , this . preferences . brace_position_for_block ) ; action . traverse ( this , scope ) ; } else if ( action instanceof EmptyStatement ) { formatNecessaryEmptyStatement ( ) ; } else { this . scribe . indent ( ) ; this . scribe . printNewLine ( ) ; action . traverse ( this , scope ) ; this . scribe . unIndent ( ) ; } if ( action instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } else { formatNecessaryEmptyStatement ( ) ; } return false ; } public boolean visit ( ForStatement forStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamefor ) ; final int line = this . scribe . line ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_for ) ; if ( this . preferences . insert_space_after_opening_paren_in_for ) { this . scribe . space ( ) ; } final Statement [ ] initializations = forStatement . initializations ; if ( initializations != null ) { int length = initializations . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( initializations [ i ] instanceof LocalDeclaration ) { formatLocalDeclaration ( ( LocalDeclaration ) initializations [ i ] , scope , this . preferences . insert_space_before_comma_in_for_inits , this . preferences . insert_space_after_comma_in_for_inits ) ; } else { initializations [ i ] . traverse ( this , scope ) ; if ( i >= <NUM_LIT:0> && ( i < length - <NUM_LIT:1> ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_for_inits ) ; if ( this . preferences . insert_space_after_comma_in_for_inits ) { this . scribe . space ( ) ; } this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } } } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon_in_for ) ; final Expression condition = forStatement . condition ; if ( condition != null ) { if ( this . preferences . insert_space_after_semicolon_in_for ) { this . scribe . space ( ) ; } condition . traverse ( this , scope ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon_in_for ) ; final Statement [ ] increments = forStatement . increments ; if ( increments != null ) { if ( this . preferences . insert_space_after_semicolon_in_for ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> , length = increments . length ; i < length ; i ++ ) { increments [ i ] . traverse ( this , scope ) ; if ( i != length - <NUM_LIT:1> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_for_increments ) ; if ( this . preferences . insert_space_after_comma_in_for_increments ) { this . scribe . space ( ) ; } this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } } this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_for ) ; final Statement action = forStatement . action ; if ( action != null ) { if ( action instanceof Block ) { formatLeftCurlyBrace ( line , this . preferences . brace_position_for_block ) ; action . traverse ( this , scope ) ; } else if ( action instanceof EmptyStatement ) { formatNecessaryEmptyStatement ( ) ; } else { this . scribe . indent ( ) ; this . scribe . printNewLine ( ) ; action . traverse ( this , scope ) ; this . scribe . unIndent ( ) ; } if ( action instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } else { formatNecessaryEmptyStatement ( ) ; } return false ; } public boolean visit ( IfStatement ifStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameif ) ; final int line = this . scribe . line ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_if ) ; if ( this . preferences . insert_space_after_opening_paren_in_if ) { this . scribe . space ( ) ; } ifStatement . condition . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_if ) ; final Statement thenStatement = ifStatement . thenStatement ; final Statement elseStatement = ifStatement . elseStatement ; boolean thenStatementIsBlock = false ; if ( thenStatement != null ) { if ( thenStatement instanceof Block ) { thenStatementIsBlock = true ; if ( isGuardClause ( ( Block ) thenStatement ) && elseStatement == null && this . preferences . keep_guardian_clause_on_one_line ) { formatGuardClauseBlock ( ( Block ) thenStatement , scope ) ; } else { formatLeftCurlyBrace ( line , this . preferences . brace_position_for_block ) ; thenStatement . traverse ( this , scope ) ; if ( elseStatement != null && ( this . preferences . insert_new_line_before_else_in_if_statement ) ) { this . scribe . printNewLine ( ) ; } } } else if ( elseStatement == null && this . preferences . keep_simple_if_on_one_line ) { Alignment compactIfAlignment = this . scribe . createAlignment ( Alignment . COMPACT_IF , this . preferences . alignment_for_compact_if , Alignment . R_OUTERMOST , <NUM_LIT:1> , this . scribe . scanner . currentPosition , <NUM_LIT:1> , false ) ; this . scribe . enterAlignment ( compactIfAlignment ) ; boolean ok = false ; do { try { this . scribe . alignFragment ( compactIfAlignment , <NUM_LIT:0> ) ; this . scribe . space ( ) ; thenStatement . traverse ( this , scope ) ; if ( thenStatement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( compactIfAlignment , true ) ; } else if ( this . preferences . keep_then_statement_on_same_line ) { this . scribe . space ( ) ; thenStatement . traverse ( this , scope ) ; if ( thenStatement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } if ( elseStatement != null ) { this . scribe . printNewLine ( ) ; } } else { this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; thenStatement . traverse ( this , scope ) ; if ( thenStatement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } if ( elseStatement != null ) { this . scribe . printNewLine ( ) ; } this . scribe . unIndent ( ) ; } } if ( elseStatement != null ) { if ( thenStatementIsBlock ) { this . scribe . printNextToken ( TerminalTokens . TokenNameelse , this . preferences . insert_space_after_closing_brace_in_block , Scribe . PRESERVE_EMPTY_LINES_BEFORE_ELSE ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameelse , true , Scribe . PRESERVE_EMPTY_LINES_BEFORE_ELSE ) ; } if ( elseStatement instanceof Block ) { elseStatement . traverse ( this , scope ) ; } else if ( elseStatement instanceof IfStatement ) { if ( ! this . preferences . compact_else_if ) { this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; } this . scribe . space ( ) ; elseStatement . traverse ( this , scope ) ; if ( ! this . preferences . compact_else_if ) { this . scribe . unIndent ( ) ; } } else if ( this . preferences . keep_else_statement_on_same_line ) { this . scribe . space ( ) ; elseStatement . traverse ( this , scope ) ; if ( elseStatement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } } else { this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; elseStatement . traverse ( this , scope ) ; if ( elseStatement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . unIndent ( ) ; } } return false ; } public boolean visit ( Initializer initializer , MethodScope scope ) { if ( initializer . isStatic ( ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNamestatic ) ; } initializer . block . traverse ( this , scope ) ; return false ; } public boolean visit ( InstanceOfExpression instanceOfExpression , BlockScope scope ) { final int numberOfParens = ( instanceOfExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( instanceOfExpression , numberOfParens ) ; } instanceOfExpression . expression . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameinstanceof , true ) ; this . scribe . space ( ) ; instanceOfExpression . type . traverse ( this , scope ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( instanceOfExpression , numberOfParens ) ; } return false ; } public boolean visit ( IntLiteral intLiteral , BlockScope scope ) { final int numberOfParens = ( intLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( intLiteral , numberOfParens ) ; } if ( isNextToken ( TerminalTokens . TokenNameMINUS ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameMINUS ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameIntegerLiteral ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( intLiteral , numberOfParens ) ; } return false ; } public boolean visit ( LabeledStatement labeledStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOLON , this . preferences . insert_space_before_colon_in_labeled_statement ) ; if ( this . preferences . insert_space_after_colon_in_labeled_statement ) { this . scribe . space ( ) ; } if ( this . preferences . insert_new_line_after_label ) { this . scribe . printNewLine ( ) ; } final Statement statement = labeledStatement . statement ; statement . traverse ( this , scope ) ; if ( statement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } return false ; } public boolean visit ( LocalDeclaration localDeclaration , BlockScope scope ) { formatLocalDeclaration ( localDeclaration , scope , this . preferences . insert_space_before_comma_in_multiple_local_declarations , this . preferences . insert_space_after_comma_in_multiple_local_declarations ) ; return false ; } public boolean visit ( LongLiteral longLiteral , BlockScope scope ) { final int numberOfParens = ( longLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( longLiteral , numberOfParens ) ; } if ( isNextToken ( TerminalTokens . TokenNameMINUS ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNameMINUS ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameLongLiteral ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( longLiteral , numberOfParens ) ; } return false ; } public boolean visit ( MarkerAnnotation annotation , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameAT ) ; if ( this . preferences . insert_space_after_at_in_annotation ) { this . scribe . space ( ) ; } this . scribe . printQualifiedReference ( annotation . sourceEnd , false ) ; return false ; } public boolean visit ( MarkerAnnotation annotation , ClassScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameAT ) ; if ( this . preferences . insert_space_after_at_in_annotation ) { this . scribe . space ( ) ; } this . scribe . printQualifiedReference ( annotation . sourceEnd , false ) ; return false ; } public boolean visit ( MemberValuePair pair , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameEQUAL , this . preferences . insert_space_before_assignment_operator ) ; if ( this . preferences . insert_space_after_assignment_operator ) { this . scribe . space ( ) ; } pair . value . traverse ( this , scope ) ; return false ; } public boolean visit ( MessageSend messageSend , BlockScope scope ) { final int numberOfParens = ( messageSend . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( messageSend , numberOfParens ) ; } CascadingMethodInvocationFragmentBuilder builder = buildFragments ( messageSend , scope ) ; if ( builder . size ( ) >= <NUM_LIT:3> && numberOfParens == <NUM_LIT:0> ) { formatCascadingMessageSends ( builder , scope ) ; } else { Alignment messageAlignment = null ; if ( ! messageSend . receiver . isImplicitThis ( ) ) { messageSend . receiver . traverse ( this , scope ) ; int alignmentMode = this . preferences . alignment_for_selector_in_method_invocation ; messageAlignment = this . scribe . createAlignment ( Alignment . MESSAGE_SEND , alignmentMode , <NUM_LIT:1> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( messageAlignment ) ; boolean ok = false ; do { switch ( alignmentMode & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : messageAlignment . startingColumn = this . scribe . column ; break ; } try { formatMessageSend ( messageSend , scope , messageAlignment ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( messageAlignment , true ) ; } else { formatMessageSend ( messageSend , scope , null ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( messageSend , numberOfParens ) ; } return false ; } public boolean visit ( MethodDeclaration methodDeclaration , ClassScope scope ) { if ( methodDeclaration . ignoreFurtherInvestigation ) { this . scribe . printComment ( ) ; if ( this . scribe . indentationLevel != <NUM_LIT:0> ) { this . scribe . printIndentationIfNecessary ( ) ; } this . scribe . scanner . resetTo ( methodDeclaration . declarationSourceEnd + <NUM_LIT:1> , this . scribe . scannerEndPosition - <NUM_LIT:1> ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( ! this . scribe . scanner . atEnd ( ) ) { switch ( this . scribe . scanner . source [ this . scribe . scanner . currentPosition ] ) { case '<STR_LIT:\n>' : this . scribe . scanner . currentPosition ++ ; this . scribe . lastNumberOfNewLines = <NUM_LIT:1> ; break ; case '<STR_LIT>' : this . scribe . scanner . currentPosition ++ ; if ( this . scribe . scanner . source [ this . scribe . scanner . currentPosition ] == '<STR_LIT:\n>' ) { this . scribe . scanner . currentPosition ++ ; } this . scribe . lastNumberOfNewLines = <NUM_LIT:1> ; } } return false ; } this . scribe . printComment ( ) ; int line = this . scribe . line ; Alignment methodDeclAlignment = this . scribe . createAlignment ( Alignment . METHOD_DECLARATION , this . preferences . alignment_for_method_declaration , Alignment . R_INNERMOST , <NUM_LIT:3> , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( methodDeclAlignment ) ; boolean ok = false ; final MethodScope methodDeclarationScope = methodDeclaration . scope ; do { try { this . scribe . printModifiers ( methodDeclaration . annotations , this , ICodeFormatterConstants . ANNOTATION_ON_METHOD ) ; int fragmentIndex = <NUM_LIT:0> ; this . scribe . alignFragment ( methodDeclAlignment , fragmentIndex ) ; if ( this . scribe . line > line ) { line = this . scribe . line ; } this . scribe . space ( ) ; TypeParameter [ ] typeParameters = methodDeclaration . typeParameters ; if ( typeParameters != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_parameters ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_parameters ) { this . scribe . space ( ) ; } int length = typeParameters . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeParameters [ i ] . traverse ( this , methodDeclaration . scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_parameters ) ; if ( this . preferences . insert_space_after_comma_in_type_parameters ) { this . scribe . space ( ) ; } } typeParameters [ length - <NUM_LIT:1> ] . traverse ( this , methodDeclaration . scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_parameters ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_parameters ) { this . scribe . space ( ) ; } this . scribe . alignFragment ( methodDeclAlignment , ++ fragmentIndex ) ; } final TypeReference returnType = methodDeclaration . returnType ; if ( returnType != null ) { returnType . traverse ( this , methodDeclarationScope ) ; } this . scribe . alignFragment ( methodDeclAlignment , ++ fragmentIndex ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier , true ) ; formatMethodArguments ( methodDeclaration , this . preferences . insert_space_before_opening_paren_in_method_declaration , this . preferences . insert_space_between_empty_parens_in_method_declaration , this . preferences . insert_space_before_closing_paren_in_method_declaration , this . preferences . insert_space_after_opening_paren_in_method_declaration , this . preferences . insert_space_before_comma_in_method_declaration_parameters , this . preferences . insert_space_after_comma_in_method_declaration_parameters , this . preferences . alignment_for_parameters_in_method_declaration ) ; int extraDimensions = getDimensions ( ) ; if ( extraDimensions != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } formatThrowsClause ( methodDeclaration , this . preferences . insert_space_before_comma_in_method_declaration_throws , this . preferences . insert_space_after_comma_in_method_declaration_throws , this . preferences . alignment_for_throws_clause_in_method_declaration ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( methodDeclAlignment , true ) ; if ( ! methodDeclaration . isNative ( ) && ! methodDeclaration . isAbstract ( ) && ( ( methodDeclaration . modifiers & ExtraCompilerModifiers . AccSemicolonBody ) == <NUM_LIT:0> ) ) { String method_declaration_brace = this . preferences . brace_position_for_method_declaration ; formatLeftCurlyBrace ( line , method_declaration_brace ) ; formatOpeningBrace ( method_declaration_brace , this . preferences . insert_space_before_opening_brace_in_method_declaration ) ; final int numberOfBlankLinesAtBeginningOfMethodBody = this . preferences . blank_lines_at_beginning_of_method_body ; if ( numberOfBlankLinesAtBeginningOfMethodBody > <NUM_LIT:0> ) { this . scribe . printEmptyLines ( numberOfBlankLinesAtBeginningOfMethodBody ) ; } final Statement [ ] statements = methodDeclaration . statements ; if ( statements != null ) { this . scribe . printNewLine ( ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . indent ( ) ; } formatStatements ( methodDeclarationScope , statements , true ) ; this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_AT_END_OF_METHOD_DECLARATION ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . unIndent ( ) ; } } else { if ( this . preferences . insert_new_line_in_empty_method_body ) { this . scribe . printNewLine ( ) ; } if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . indent ( ) ; } this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_AT_END_OF_METHOD_DECLARATION ) ; if ( this . preferences . indent_statements_compare_to_body ) { this . scribe . unIndent ( ) ; } } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( method_declaration_brace . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . COMPLEX_TRAILING_COMMENT ) ; } return false ; } public boolean visit ( NormalAnnotation annotation , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameAT ) ; if ( this . preferences . insert_space_after_at_in_annotation ) { this . scribe . space ( ) ; } this . scribe . printQualifiedReference ( annotation . sourceEnd , false ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_annotation ) ; if ( this . preferences . insert_space_after_opening_paren_in_annotation ) { this . scribe . space ( ) ; } MemberValuePair [ ] memberValuePairs = annotation . memberValuePairs ; if ( memberValuePairs != null ) { int length = memberValuePairs . length ; Alignment annotationAlignment = this . scribe . createAlignment ( Alignment . ANNOTATION_MEMBERS_VALUE_PAIRS , this . preferences . alignment_for_arguments_in_annotation , length , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( annotationAlignment ) ; boolean ok = false ; do { try { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_annotation ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . alignFragment ( annotationAlignment , i ) ; if ( i > <NUM_LIT:0> && this . preferences . insert_space_after_comma_in_annotation ) { this . scribe . space ( ) ; } memberValuePairs [ i ] . traverse ( this , scope ) ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( annotationAlignment , true ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_annotation ) ; return false ; } public boolean visit ( NullLiteral nullLiteral , BlockScope scope ) { final int numberOfParens = ( nullLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( nullLiteral , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamenull ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( nullLiteral , numberOfParens ) ; } return false ; } public boolean visit ( OR_OR_Expression or_or_Expression , BlockScope scope ) { return dumpBinaryExpression ( or_or_Expression , TerminalTokens . TokenNameOR_OR , scope ) ; } public boolean visit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , BlockScope scope ) { final int numberOfParens = ( parameterizedQualifiedTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( parameterizedQualifiedTypeReference , numberOfParens ) ; } TypeReference [ ] [ ] typeArguments = parameterizedQualifiedTypeReference . typeArguments ; int length = typeArguments . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; TypeReference [ ] typeArgument = typeArguments [ i ] ; if ( typeArgument != null ) { int typeArgumentLength = typeArgument . length ; if ( typeArgumentLength > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_parameterized_type_reference ) { this . scribe . space ( ) ; } for ( int j = <NUM_LIT:0> ; j < typeArgumentLength - <NUM_LIT:1> ; j ++ ) { typeArgument [ j ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_comma_in_parameterized_type_reference ) { this . scribe . space ( ) ; } } typeArgument [ typeArgumentLength - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_parameterized_type_reference ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS ) ; } } if ( i < length - <NUM_LIT:1> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; } } int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> && dimensions <= parameterizedQualifiedTypeReference . dimensions ( ) ) { if ( this . preferences . insert_space_before_opening_bracket_in_array_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; if ( this . preferences . insert_space_between_brackets_in_array_type_reference ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( parameterizedQualifiedTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , ClassScope scope ) { final int numberOfParens = ( parameterizedQualifiedTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( parameterizedQualifiedTypeReference , numberOfParens ) ; } TypeReference [ ] [ ] typeArguments = parameterizedQualifiedTypeReference . typeArguments ; int length = typeArguments . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; TypeReference [ ] typeArgument = typeArguments [ i ] ; if ( typeArgument != null ) { int typeArgumentLength = typeArgument . length ; if ( typeArgumentLength > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_parameterized_type_reference ) { this . scribe . space ( ) ; } for ( int j = <NUM_LIT:0> ; j < typeArgumentLength - <NUM_LIT:1> ; j ++ ) { typeArgument [ j ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_comma_in_parameterized_type_reference ) { this . scribe . space ( ) ; } } typeArgument [ typeArgumentLength - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_parameterized_type_reference ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS ) ; } } if ( i < length - <NUM_LIT:1> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; } } int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> && dimensions <= parameterizedQualifiedTypeReference . dimensions ( ) ) { if ( this . preferences . insert_space_before_opening_bracket_in_array_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; if ( this . preferences . insert_space_between_brackets_in_array_type_reference ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( parameterizedQualifiedTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , BlockScope scope ) { final int numberOfParens = ( parameterizedSingleTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( parameterizedSingleTypeReference , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; TypeReference [ ] typeArguments = parameterizedSingleTypeReference . typeArguments ; int typeArgumentsLength = typeArguments . length ; if ( typeArgumentsLength > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_parameterized_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < typeArgumentsLength - <NUM_LIT:1> ; i ++ ) { typeArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_comma_in_parameterized_type_reference ) { this . scribe . space ( ) ; } } typeArguments [ typeArgumentsLength - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_parameterized_type_reference ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS ) ; } int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> && dimensions <= parameterizedSingleTypeReference . dimensions ( ) ) { if ( this . preferences . insert_space_before_opening_bracket_in_array_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; if ( this . preferences . insert_space_between_brackets_in_array_type_reference ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( parameterizedSingleTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , ClassScope scope ) { final int numberOfParens = ( parameterizedSingleTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( parameterizedSingleTypeReference , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; TypeReference [ ] typeArguments = parameterizedSingleTypeReference . typeArguments ; int typeArgumentsLength = typeArguments . length ; if ( typeArgumentsLength > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_parameterized_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < typeArgumentsLength - <NUM_LIT:1> ; i ++ ) { typeArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_parameterized_type_reference ) ; if ( this . preferences . insert_space_after_comma_in_parameterized_type_reference ) { this . scribe . space ( ) ; } } typeArguments [ typeArgumentsLength - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_parameterized_type_reference ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ) ; this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS ) ; } int dimensions = getDimensions ( ) ; if ( dimensions != <NUM_LIT:0> && dimensions <= parameterizedSingleTypeReference . dimensions ( ) ) { if ( this . preferences . insert_space_before_opening_bracket_in_array_type_reference ) { this . scribe . space ( ) ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLBRACKET ) ; if ( this . preferences . insert_space_between_brackets_in_array_type_reference ) { this . scribe . space ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACKET ) ; } } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( parameterizedSingleTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( PostfixExpression postfixExpression , BlockScope scope ) { final int numberOfParens = ( postfixExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( postfixExpression , numberOfParens ) ; } postfixExpression . lhs . traverse ( this , scope ) ; int operator = postfixExpression . operator == OperatorIds . PLUS ? TerminalTokens . TokenNamePLUS_PLUS : TerminalTokens . TokenNameMINUS_MINUS ; this . scribe . printNextToken ( operator , this . preferences . insert_space_before_postfix_operator ) ; if ( this . preferences . insert_space_after_postfix_operator ) { this . scribe . space ( ) ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( postfixExpression , numberOfParens ) ; } return false ; } public boolean visit ( PrefixExpression prefixExpression , BlockScope scope ) { final int numberOfParens = ( prefixExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( prefixExpression , numberOfParens ) ; } int operator = prefixExpression . operator == OperatorIds . PLUS ? TerminalTokens . TokenNamePLUS_PLUS : TerminalTokens . TokenNameMINUS_MINUS ; this . scribe . printNextToken ( operator , this . preferences . insert_space_before_prefix_operator ) ; if ( this . preferences . insert_space_after_prefix_operator ) { this . scribe . space ( ) ; } prefixExpression . lhs . traverse ( this , scope ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( prefixExpression , numberOfParens ) ; } return false ; } public boolean visit ( QualifiedAllocationExpression qualifiedAllocationExpression , BlockScope scope ) { final int numberOfParens = ( qualifiedAllocationExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( qualifiedAllocationExpression , numberOfParens ) ; } final Expression enclosingInstance = qualifiedAllocationExpression . enclosingInstance ; if ( enclosingInstance != null ) { enclosingInstance . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamenew ) ; TypeReference [ ] typeArguments = qualifiedAllocationExpression . typeArguments ; if ( typeArguments != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameLESS , this . preferences . insert_space_before_opening_angle_bracket_in_type_arguments ) ; if ( this . preferences . insert_space_after_opening_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } int length = typeArguments . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { typeArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_type_arguments ) ; if ( this . preferences . insert_space_after_comma_in_type_arguments ) { this . scribe . space ( ) ; } } typeArguments [ length - <NUM_LIT:1> ] . traverse ( this , scope ) ; if ( isClosingGenericToken ( ) ) { this . scribe . printNextToken ( CLOSING_GENERICS_EXPECTEDTOKENS , this . preferences . insert_space_before_closing_angle_bracket_in_type_arguments ) ; } if ( this . preferences . insert_space_after_closing_angle_bracket_in_type_arguments ) { this . scribe . space ( ) ; } } else { this . scribe . space ( ) ; } final int line = this . scribe . line ; qualifiedAllocationExpression . type . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_method_invocation ) ; final Expression [ ] arguments = qualifiedAllocationExpression . arguments ; if ( arguments != null ) { if ( this . preferences . insert_space_after_opening_paren_in_method_invocation ) { this . scribe . space ( ) ; } int argumentLength = arguments . length ; Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . ALLOCATION , this . preferences . alignment_for_arguments_in_qualified_allocation_expression , argumentLength , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean ok = false ; do { try { for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameCOMMA , this . preferences . insert_space_before_comma_in_allocation_expression ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . alignFragment ( argumentsAlignment , i ) ; if ( i > <NUM_LIT:0> && this . preferences . insert_space_after_comma_in_allocation_expression ) { this . scribe . space ( ) ; } arguments [ i ] . traverse ( this , scope ) ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_method_invocation ) ; } else { this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_between_empty_parens_in_method_invocation ) ; } final TypeDeclaration anonymousType = qualifiedAllocationExpression . anonymousType ; if ( anonymousType != null ) { formatLeftCurlyBrace ( line , this . preferences . brace_position_for_anonymous_type_declaration ) ; formatAnonymousTypeDeclaration ( anonymousType ) ; } if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( qualifiedAllocationExpression , numberOfParens ) ; } return false ; } public boolean visit ( QualifiedNameReference qualifiedNameReference , BlockScope scope ) { final int numberOfParens = ( qualifiedNameReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( qualifiedNameReference , numberOfParens ) ; } this . scribe . printQualifiedReference ( qualifiedNameReference . sourceEnd , numberOfParens >= <NUM_LIT:0> ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( qualifiedNameReference , numberOfParens ) ; } return false ; } public boolean visit ( QualifiedSuperReference qualifiedSuperReference , BlockScope scope ) { final int numberOfParens = ( qualifiedSuperReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( qualifiedSuperReference , numberOfParens ) ; } qualifiedSuperReference . qualification . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; this . scribe . printNextToken ( TerminalTokens . TokenNamesuper ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( qualifiedSuperReference , numberOfParens ) ; } return false ; } public boolean visit ( QualifiedThisReference qualifiedThisReference , BlockScope scope ) { final int numberOfParens = ( qualifiedThisReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( qualifiedThisReference , numberOfParens ) ; } qualifiedThisReference . qualification . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; this . scribe . printNextToken ( TerminalTokens . TokenNamethis ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( qualifiedThisReference , numberOfParens ) ; } return false ; } public boolean visit ( QualifiedTypeReference qualifiedTypeReference , BlockScope scope ) { final int numberOfParens = ( qualifiedTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( qualifiedTypeReference , numberOfParens ) ; } this . scribe . printQualifiedReference ( qualifiedTypeReference . sourceEnd , numberOfParens >= <NUM_LIT:0> ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( qualifiedTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( QualifiedTypeReference qualifiedTypeReference , ClassScope scope ) { final int numberOfParens = ( qualifiedTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( qualifiedTypeReference , numberOfParens ) ; } this . scribe . printQualifiedReference ( qualifiedTypeReference . sourceEnd , numberOfParens >= <NUM_LIT:0> ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( qualifiedTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( ReturnStatement returnStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamereturn ) ; final Expression expression = returnStatement . expression ; if ( expression != null ) { final int numberOfParens = ( expression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( ( numberOfParens != <NUM_LIT:0> && this . preferences . insert_space_before_parenthesized_expression_in_return ) || numberOfParens == <NUM_LIT:0> ) { this . scribe . space ( ) ; } expression . traverse ( this , scope ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( SingleMemberAnnotation annotation , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameAT ) ; if ( this . preferences . insert_space_after_at_in_annotation ) { this . scribe . space ( ) ; } this . scribe . printQualifiedReference ( annotation . sourceEnd , false ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_annotation ) ; if ( this . preferences . insert_space_after_opening_paren_in_annotation ) { this . scribe . space ( ) ; } annotation . memberValue . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_annotation ) ; return false ; } public boolean visit ( SingleNameReference singleNameReference , BlockScope scope ) { final int numberOfParens = ( singleNameReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( singleNameReference , numberOfParens ) ; } this . scribe . printNextToken ( SINGLETYPEREFERENCE_EXPECTEDTOKENS ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( singleNameReference , numberOfParens ) ; } return false ; } public boolean visit ( SingleTypeReference singleTypeReference , BlockScope scope ) { final int numberOfParens = ( singleTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( singleTypeReference , numberOfParens ) ; } this . scribe . printNextToken ( SINGLETYPEREFERENCE_EXPECTEDTOKENS ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( singleTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( SingleTypeReference singleTypeReference , ClassScope scope ) { final int numberOfParens = ( singleTypeReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( singleTypeReference , numberOfParens ) ; } this . scribe . printNextToken ( SINGLETYPEREFERENCE_EXPECTEDTOKENS ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( singleTypeReference , numberOfParens ) ; } return false ; } public boolean visit ( StringLiteral stringLiteral , BlockScope scope ) { final int numberOfParens = ( stringLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( stringLiteral , numberOfParens ) ; } this . scribe . checkNLSTag ( stringLiteral . sourceStart ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameStringLiteral ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( stringLiteral , numberOfParens ) ; } return false ; } public boolean visit ( StringLiteralConcatenation stringLiteral , BlockScope scope ) { final int numberOfParens = ( stringLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( stringLiteral , numberOfParens ) ; } this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_IN_STRING_LITERAL_CONCATENATION ) ; ASTNode [ ] fragments = stringLiteral . literals ; int fragmentsSize = stringLiteral . counter ; Alignment binaryExpressionAlignment = this . scribe . createAlignment ( Alignment . STRING_CONCATENATION , this . preferences . alignment_for_binary_expression , Alignment . R_OUTERMOST , fragmentsSize , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( binaryExpressionAlignment ) ; boolean ok = false ; do { try { for ( int i = <NUM_LIT:0> ; i < fragmentsSize - <NUM_LIT:1> ; i ++ ) { ASTNode fragment = fragments [ i ] ; fragment . traverse ( this , scope ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( this . scribe . lastNumberOfNewLines == <NUM_LIT:1> ) { this . scribe . indentationLevel = binaryExpressionAlignment . breakIndentationLevel ; } this . scribe . alignFragment ( binaryExpressionAlignment , i ) ; this . scribe . printNextToken ( TerminalTokens . TokenNamePLUS , this . preferences . insert_space_before_binary_operator ) ; if ( this . preferences . insert_space_after_binary_operator ) { this . scribe . space ( ) ; } } fragments [ fragmentsSize - <NUM_LIT:1> ] . traverse ( this , scope ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( binaryExpressionAlignment , true ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( stringLiteral , numberOfParens ) ; } return false ; } public boolean visit ( SuperReference superReference , BlockScope scope ) { final int numberOfParens = ( superReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( superReference , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamesuper ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( superReference , numberOfParens ) ; } return false ; } public boolean visit ( SwitchStatement switchStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameswitch ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_switch ) ; if ( this . preferences . insert_space_after_opening_paren_in_switch ) { this . scribe . space ( ) ; } switchStatement . expression . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_switch ) ; String switch_brace = this . preferences . brace_position_for_switch ; formatOpeningBrace ( switch_brace , this . preferences . insert_space_before_opening_brace_in_switch ) ; this . scribe . printNewLine ( ) ; final Statement [ ] statements = switchStatement . statements ; int switchIndentationLevel = this . scribe . indentationLevel ; int caseIndentation = <NUM_LIT:0> ; int statementIndentation = <NUM_LIT:0> ; int breakIndentation = <NUM_LIT:0> ; if ( this . preferences . indent_switchstatements_compare_to_switch ) { caseIndentation ++ ; statementIndentation ++ ; breakIndentation ++ ; } if ( this . preferences . indent_switchstatements_compare_to_cases ) { statementIndentation ++ ; } if ( this . preferences . indent_breaks_compare_to_cases ) { breakIndentation ++ ; } boolean wasACase = false ; boolean wasABreak = false ; if ( statements != null ) { int statementsLength = statements . length ; for ( int i = <NUM_LIT:0> ; i < statementsLength ; i ++ ) { final Statement statement = statements [ i ] ; if ( statement instanceof CaseStatement ) { if ( wasABreak ) { this . scribe . setIndentation ( switchIndentationLevel , caseIndentation ) ; this . scribe . printComment ( ) ; } else { if ( wasACase ) { this . scribe . printComment ( Scribe . PRESERVE_EMPTY_LINES_IN_SWITCH_CASE ) ; } else { this . scribe . printComment ( ) ; } this . scribe . setIndentation ( switchIndentationLevel , caseIndentation ) ; } if ( wasACase ) { this . scribe . printNewLine ( ) ; } statement . traverse ( this , scope ) ; this . scribe . setIndentation ( switchIndentationLevel , statementIndentation ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . COMPLEX_TRAILING_COMMENT ) ; wasACase = true ; wasABreak = false ; } else if ( statement instanceof BreakStatement ) { this . scribe . setIndentation ( switchIndentationLevel , breakIndentation ) ; if ( wasACase ) { this . scribe . printNewLine ( ) ; } this . scribe . printComment ( ) ; statement . traverse ( this , scope ) ; wasACase = false ; wasABreak = true ; } else if ( statement instanceof Block ) { this . scribe . setIndentation ( switchIndentationLevel , wasACase ? caseIndentation : statementIndentation ) ; this . scribe . printComment ( ) ; String bracePosition = wasACase ? this . preferences . brace_position_for_block_in_case : this . preferences . brace_position_for_block ; formatBlock ( ( Block ) statement , scope , bracePosition , this . preferences . insert_space_before_opening_brace_in_block ) ; wasACase = false ; wasABreak = false ; } else { this . scribe . setIndentation ( switchIndentationLevel , statementIndentation ) ; this . scribe . printNewLine ( ) ; this . scribe . printComment ( ) ; statement . traverse ( this , scope ) ; wasACase = false ; wasABreak = false ; } if ( statement instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . printNewLine ( ) ; } else if ( statement instanceof LocalDeclaration ) { LocalDeclaration currentLocal = ( LocalDeclaration ) statement ; if ( i < ( statementsLength - <NUM_LIT:1> ) ) { if ( statements [ i + <NUM_LIT:1> ] instanceof LocalDeclaration ) { LocalDeclaration nextLocal = ( LocalDeclaration ) statements [ i + <NUM_LIT:1> ] ; if ( currentLocal . declarationSourceStart != nextLocal . declarationSourceStart ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . printNewLine ( ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . printNewLine ( ) ; } } else { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; this . scribe . printNewLine ( ) ; } } else if ( ! wasACase ) { this . scribe . printNewLine ( ) ; } } } this . scribe . printNewLine ( ) ; if ( wasABreak ) { this . scribe . setIndentation ( switchIndentationLevel , <NUM_LIT:0> ) ; this . scribe . printComment ( ) ; } else { this . scribe . printComment ( ) ; this . scribe . setIndentation ( switchIndentationLevel , <NUM_LIT:0> ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameRBRACE ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( switch_brace . equals ( DefaultCodeFormatterConstants . NEXT_LINE_SHIFTED ) ) { this . scribe . unIndent ( ) ; } return false ; } public boolean visit ( SynchronizedStatement synchronizedStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamesynchronized ) ; final int line = this . scribe . line ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_synchronized ) ; if ( this . preferences . insert_space_after_opening_paren_in_synchronized ) { this . scribe . space ( ) ; } synchronizedStatement . expression . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_synchronized ) ; formatLeftCurlyBrace ( line , this . preferences . brace_position_for_block ) ; synchronizedStatement . block . traverse ( this , scope ) ; return false ; } public boolean visit ( ThisReference thisReference , BlockScope scope ) { if ( ! thisReference . isImplicitThis ( ) ) { final int numberOfParens = ( thisReference . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( thisReference , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamethis ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( thisReference , numberOfParens ) ; } } return false ; } public boolean visit ( ThrowStatement throwStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamethrow ) ; Expression expression = throwStatement . exception ; final int numberOfParens = ( expression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( ( numberOfParens > <NUM_LIT:0> && this . preferences . insert_space_before_parenthesized_expression_in_throw ) || numberOfParens == <NUM_LIT:0> ) { this . scribe . space ( ) ; } expression . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; return false ; } public boolean visit ( TrueLiteral trueLiteral , BlockScope scope ) { final int numberOfParens = ( trueLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( trueLiteral , numberOfParens ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNametrue ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( trueLiteral , numberOfParens ) ; } return false ; } public boolean visit ( TryStatement tryStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNametry ) ; formatTryResources ( tryStatement , this . preferences . insert_space_before_opening_paren_in_try , this . preferences . insert_space_before_closing_paren_in_try , this . preferences . insert_space_after_opening_paren_in_try , this . preferences . insert_space_before_semicolon_in_try_resources , this . preferences . insert_space_after_semicolon_in_try_resources , this . preferences . alignment_for_resources_in_try ) ; tryStatement . tryBlock . traverse ( this , scope ) ; if ( tryStatement . catchArguments != null ) { for ( int i = <NUM_LIT:0> , max = tryStatement . catchBlocks . length ; i < max ; i ++ ) { if ( this . preferences . insert_new_line_before_catch_in_try_statement ) { this . scribe . printNewLine ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamecatch , this . preferences . insert_space_after_closing_brace_in_block ) ; final int line = this . scribe . line ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_catch ) ; if ( this . preferences . insert_space_after_opening_paren_in_catch ) { this . scribe . space ( ) ; } tryStatement . catchArguments [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_catch ) ; formatLeftCurlyBrace ( line , this . preferences . brace_position_for_block ) ; tryStatement . catchBlocks [ i ] . traverse ( this , scope ) ; } } if ( tryStatement . finallyBlock != null ) { if ( this . preferences . insert_new_line_before_finally_in_try_statement ) { this . scribe . printNewLine ( ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNamefinally , this . preferences . insert_space_after_closing_brace_in_block ) ; tryStatement . finallyBlock . traverse ( this , scope ) ; } return false ; } private void formatMultiCatchArguments ( Argument argument , boolean spaceBeforePipe , boolean spaceAfterPipe , int multiCatchAlignment , BlockScope scope ) { UnionTypeReference unionType = ( UnionTypeReference ) argument . type ; int length = unionType . typeReferences != null ? unionType . typeReferences . length : <NUM_LIT:0> ; if ( length > <NUM_LIT:0> ) { Alignment argumentsAlignment = this . scribe . createAlignment ( Alignment . MULTI_CATCH , multiCatchAlignment , length , this . scribe . scanner . currentPosition ) ; this . scribe . enterAlignment ( argumentsAlignment ) ; boolean ok = false ; do { switch ( multiCatchAlignment & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : argumentsAlignment . startingColumn = this . scribe . column ; break ; } try { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( i > <NUM_LIT:0> ) { if ( this . preferences . wrap_before_or_operator_multicatch ) { this . scribe . alignFragment ( argumentsAlignment , i ) ; } this . scribe . printNextToken ( TerminalTokens . TokenNameOR , spaceBeforePipe ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; if ( this . scribe . lastNumberOfNewLines == <NUM_LIT:1> ) { this . scribe . indentationLevel = argumentsAlignment . breakIndentationLevel ; } if ( ! this . preferences . wrap_before_or_operator_multicatch ) { this . scribe . alignFragment ( argumentsAlignment , i ) ; } } if ( i == <NUM_LIT:0> ) { this . scribe . alignFragment ( argumentsAlignment , i ) ; int fragmentIndentation = argumentsAlignment . fragmentIndentations [ <NUM_LIT:0> ] ; if ( ( argumentsAlignment . mode & Alignment . M_INDENT_ON_COLUMN ) != <NUM_LIT:0> && fragmentIndentation > <NUM_LIT:0> ) { this . scribe . indentationLevel = fragmentIndentation ; } } else if ( spaceAfterPipe ) { this . scribe . space ( ) ; } unionType . typeReferences [ i ] . traverse ( this , scope ) ; argumentsAlignment . startingColumn = - <NUM_LIT:1> ; } ok = true ; } catch ( AlignmentException e ) { this . scribe . redoAlignment ( e ) ; } } while ( ! ok ) ; this . scribe . exitAlignment ( argumentsAlignment , true ) ; } } public boolean visit ( TypeDeclaration localTypeDeclaration , BlockScope scope ) { format ( localTypeDeclaration ) ; return false ; } public boolean visit ( TypeDeclaration memberTypeDeclaration , ClassScope scope ) { format ( memberTypeDeclaration ) ; return false ; } public boolean visit ( TypeDeclaration typeDeclaration , CompilationUnitScope scope ) { format ( typeDeclaration ) ; return false ; } public boolean visit ( TypeParameter typeParameter , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; if ( typeParameter . type != null ) { this . scribe . space ( ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameextends , true ) ; this . scribe . space ( ) ; typeParameter . type . traverse ( this , scope ) ; } final TypeReference [ ] bounds = typeParameter . bounds ; if ( bounds != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameAND , this . preferences . insert_space_before_and_in_type_parameter ) ; if ( this . preferences . insert_space_after_and_in_type_parameter ) { this . scribe . space ( ) ; } int boundsLength = bounds . length ; for ( int i = <NUM_LIT:0> ; i < boundsLength - <NUM_LIT:1> ; i ++ ) { bounds [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameAND , this . preferences . insert_space_before_and_in_type_parameter ) ; if ( this . preferences . insert_space_after_and_in_type_parameter ) { this . scribe . space ( ) ; } } bounds [ boundsLength - <NUM_LIT:1> ] . traverse ( this , scope ) ; } return false ; } public boolean visit ( TypeParameter typeParameter , ClassScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameIdentifier ) ; if ( typeParameter . type != null ) { this . scribe . space ( ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameextends , true ) ; this . scribe . space ( ) ; typeParameter . type . traverse ( this , scope ) ; } final TypeReference [ ] bounds = typeParameter . bounds ; if ( bounds != null ) { this . scribe . printNextToken ( TerminalTokens . TokenNameAND , this . preferences . insert_space_before_and_in_type_parameter ) ; if ( this . preferences . insert_space_after_and_in_type_parameter ) { this . scribe . space ( ) ; } int boundsLength = bounds . length ; for ( int i = <NUM_LIT:0> ; i < boundsLength - <NUM_LIT:1> ; i ++ ) { bounds [ i ] . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameAND , this . preferences . insert_space_before_and_in_type_parameter ) ; if ( this . preferences . insert_space_after_and_in_type_parameter ) { this . scribe . space ( ) ; } } bounds [ boundsLength - <NUM_LIT:1> ] . traverse ( this , scope ) ; } return false ; } public boolean visit ( UnaryExpression unaryExpression , BlockScope scope ) { final int numberOfParens = ( unaryExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { manageOpeningParenthesizedExpression ( unaryExpression , numberOfParens ) ; } int operator ; int operatorValue = ( unaryExpression . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT ; switch ( operatorValue ) { case OperatorIds . PLUS : operator = TerminalTokens . TokenNamePLUS ; break ; case OperatorIds . MINUS : operator = TerminalTokens . TokenNameMINUS ; break ; case OperatorIds . TWIDDLE : operator = TerminalTokens . TokenNameTWIDDLE ; break ; default : operator = TerminalTokens . TokenNameNOT ; } this . scribe . printNextToken ( operator , this . preferences . insert_space_before_unary_operator ) ; if ( this . preferences . insert_space_after_unary_operator ) { this . scribe . space ( ) ; } Expression expression = unaryExpression . expression ; if ( expression instanceof PrefixExpression ) { PrefixExpression prefixExpression = ( PrefixExpression ) expression ; final int numberOfParensForExpression = ( prefixExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParensForExpression == <NUM_LIT:0> ) { switch ( operatorValue ) { case OperatorIds . PLUS : if ( prefixExpression . operator == OperatorIds . PLUS ) { this . scribe . space ( ) ; } break ; case OperatorIds . MINUS : if ( prefixExpression . operator == OperatorIds . MINUS ) { this . scribe . space ( ) ; } break ; } } } else if ( expression instanceof UnaryExpression ) { UnaryExpression unaryExpression2 = ( UnaryExpression ) expression ; final int numberOfParensForExpression = ( unaryExpression2 . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParensForExpression == <NUM_LIT:0> ) { int operatorValue2 = ( unaryExpression2 . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT ; switch ( operatorValue ) { case OperatorIds . PLUS : if ( operatorValue2 == OperatorIds . PLUS ) { this . scribe . space ( ) ; } break ; case OperatorIds . MINUS : if ( operatorValue2 == OperatorIds . MINUS ) { this . scribe . space ( ) ; } break ; } } } expression . traverse ( this , scope ) ; if ( numberOfParens > <NUM_LIT:0> ) { manageClosingParenthesizedExpression ( unaryExpression , numberOfParens ) ; } return false ; } public boolean visit ( UnionTypeReference unionTypeReference , BlockScope scope ) { TypeReference [ ] typeReferences = unionTypeReference . typeReferences ; for ( int i = <NUM_LIT:0> , max = typeReferences . length ; i < max ; i ++ ) { if ( i != <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameOR , true ) ; this . scribe . space ( ) ; } typeReferences [ i ] . traverse ( this , scope ) ; } return false ; } public boolean visit ( UnionTypeReference unionTypeReference , ClassScope scope ) { TypeReference [ ] typeReferences = unionTypeReference . typeReferences ; for ( int i = <NUM_LIT:0> , max = typeReferences . length ; i < max ; i ++ ) { if ( i != <NUM_LIT:0> ) { this . scribe . printNextToken ( TerminalTokens . TokenNameOR , true ) ; this . scribe . space ( ) ; } typeReferences [ i ] . traverse ( this , scope ) ; } return false ; } public boolean visit ( WhileStatement whileStatement , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNamewhile ) ; final int line = this . scribe . line ; this . scribe . printNextToken ( TerminalTokens . TokenNameLPAREN , this . preferences . insert_space_before_opening_paren_in_while ) ; if ( this . preferences . insert_space_after_opening_paren_in_while ) { this . scribe . space ( ) ; } whileStatement . condition . traverse ( this , scope ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameRPAREN , this . preferences . insert_space_before_closing_paren_in_while ) ; final Statement action = whileStatement . action ; if ( action != null ) { if ( action instanceof Block ) { formatLeftCurlyBrace ( line , this . preferences . brace_position_for_block ) ; action . traverse ( this , scope ) ; } else if ( action instanceof EmptyStatement ) { formatNecessaryEmptyStatement ( ) ; } else { this . scribe . printNewLine ( ) ; this . scribe . indent ( ) ; action . traverse ( this , scope ) ; if ( action instanceof Expression ) { this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; this . scribe . printComment ( CodeFormatter . K_UNKNOWN , Scribe . BASIC_TRAILING_COMMENT ) ; } this . scribe . unIndent ( ) ; } } else { formatNecessaryEmptyStatement ( ) ; } return false ; } public boolean visit ( Wildcard wildcard , BlockScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameQUESTION , this . preferences . insert_space_before_question_in_wilcard ) ; switch ( wildcard . kind ) { case Wildcard . SUPER : this . scribe . printNextToken ( TerminalTokens . TokenNamesuper , true ) ; this . scribe . space ( ) ; wildcard . bound . traverse ( this , scope ) ; break ; case Wildcard . EXTENDS : this . scribe . printNextToken ( TerminalTokens . TokenNameextends , true ) ; this . scribe . space ( ) ; wildcard . bound . traverse ( this , scope ) ; break ; case Wildcard . UNBOUND : if ( this . preferences . insert_space_after_question_in_wilcard ) { this . scribe . space ( ) ; } } return false ; } public boolean visit ( Wildcard wildcard , ClassScope scope ) { this . scribe . printNextToken ( TerminalTokens . TokenNameQUESTION , this . preferences . insert_space_before_question_in_wilcard ) ; switch ( wildcard . kind ) { case Wildcard . SUPER : this . scribe . printNextToken ( TerminalTokens . TokenNamesuper , true ) ; this . scribe . space ( ) ; wildcard . bound . traverse ( this , scope ) ; break ; case Wildcard . EXTENDS : this . scribe . printNextToken ( TerminalTokens . TokenNameextends , true ) ; this . scribe . space ( ) ; wildcard . bound . traverse ( this , scope ) ; break ; case Wildcard . UNBOUND : if ( this . preferences . insert_space_after_question_in_wilcard ) { this . scribe . space ( ) ; } } return false ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; public class Location { public int inputOffset ; public int inputColumn ; public int outputLine ; public int outputColumn ; public int outputIndentationLevel ; public boolean needSpace ; public boolean pendingSpace ; public int nlsTagCounter ; public int lastLocalDeclarationSourceStart ; public int numberOfIndentations ; public int lastNumberOfNewLines ; int editsIndex ; OptimizedReplaceEdit textEdit ; public Location ( Scribe scribe , int sourceRestart ) { update ( scribe , sourceRestart ) ; } public void update ( Scribe scribe , int sourceRestart ) { this . outputColumn = scribe . column ; this . outputLine = scribe . line ; this . inputOffset = sourceRestart ; this . inputColumn = scribe . getCurrentIndentation ( sourceRestart ) + <NUM_LIT:1> ; this . outputIndentationLevel = scribe . indentationLevel ; this . lastNumberOfNewLines = scribe . lastNumberOfNewLines ; this . needSpace = scribe . needSpace ; this . pendingSpace = scribe . pendingSpace ; this . editsIndex = scribe . editsIndex ; this . nlsTagCounter = scribe . nlsTagCounter ; this . numberOfIndentations = scribe . numberOfIndentations ; this . textEdit = scribe . getLastEdit ( ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" + this . outputColumn ) ; buffer . append ( "<STR_LIT>" + this . outputLine ) ; buffer . append ( "<STR_LIT>" + this . outputIndentationLevel ) ; buffer . append ( "<STR_LIT>" + this . inputOffset ) ; buffer . append ( "<STR_LIT>" + this . inputColumn ) ; buffer . append ( '<CHAR_LIT:)>' ) ; return buffer . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; public class OptimizedReplaceEdit { int offset ; int length ; String replacement ; public OptimizedReplaceEdit ( int offset , int length , String replacement ) { this . offset = offset ; this . length = length ; this . replacement = replacement ; } public String toString ( ) { return ( this . offset < <NUM_LIT:0> ? "<STR_LIT:(>" : "<STR_LIT>" ) + this . offset + "<STR_LIT>" + this . length + "<STR_LIT>" + this . replacement + "<STR_LIT:<>" ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import java . util . ArrayList ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . AND_AND_Expression ; import org . eclipse . jdt . internal . compiler . ast . AllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ; import org . eclipse . jdt . internal . compiler . ast . ArrayQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ArrayReference ; import org . eclipse . jdt . internal . compiler . ast . ArrayTypeReference ; import org . eclipse . jdt . internal . compiler . ast . Assignment ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . BinaryExpression ; import org . eclipse . jdt . internal . compiler . ast . CastExpression ; import org . eclipse . jdt . internal . compiler . ast . CharLiteral ; import org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ; import org . eclipse . jdt . internal . compiler . ast . CombinedBinaryExpression ; import org . eclipse . jdt . internal . compiler . ast . CompoundAssignment ; import org . eclipse . jdt . internal . compiler . ast . ConditionalExpression ; import org . eclipse . jdt . internal . compiler . ast . DoubleLiteral ; import org . eclipse . jdt . internal . compiler . ast . EqualExpression ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ExtendedStringLiteral ; import org . eclipse . jdt . internal . compiler . ast . FalseLiteral ; import org . eclipse . jdt . internal . compiler . ast . FieldReference ; import org . eclipse . jdt . internal . compiler . ast . FloatLiteral ; import org . eclipse . jdt . internal . compiler . ast . InstanceOfExpression ; import org . eclipse . jdt . internal . compiler . ast . IntLiteral ; import org . eclipse . jdt . internal . compiler . ast . LongLiteral ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . StringLiteralConcatenation ; import org . eclipse . jdt . internal . compiler . ast . NullLiteral ; import org . eclipse . jdt . internal . compiler . ast . OR_OR_Expression ; import org . eclipse . jdt . internal . compiler . ast . OperatorIds ; import org . eclipse . jdt . internal . compiler . ast . PostfixExpression ; import org . eclipse . jdt . internal . compiler . ast . PrefixExpression ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedThisReference ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . ast . StringLiteral ; import org . eclipse . jdt . internal . compiler . ast . SuperReference ; import org . eclipse . jdt . internal . compiler . ast . ThisReference ; import org . eclipse . jdt . internal . compiler . ast . TrueLiteral ; import org . eclipse . jdt . internal . compiler . ast . UnaryExpression ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; class BinaryExpressionFragmentBuilder extends ASTVisitor { ArrayList fragmentsList ; ArrayList operatorsList ; private int realFragmentsSize ; BinaryExpressionFragmentBuilder ( ) { this . fragmentsList = new ArrayList ( ) ; this . operatorsList = new ArrayList ( ) ; this . realFragmentsSize = <NUM_LIT:0> ; } private final void addRealFragment ( ASTNode node ) { this . fragmentsList . add ( node ) ; this . realFragmentsSize ++ ; } private final void addSmallFragment ( ASTNode node ) { this . fragmentsList . add ( node ) ; } private boolean buildFragments ( Expression expression ) { if ( ( ( expression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ) != <NUM_LIT:0> ) { addRealFragment ( expression ) ; return false ; } return true ; } public ASTNode [ ] fragments ( ) { ASTNode [ ] fragments = new ASTNode [ this . fragmentsList . size ( ) ] ; this . fragmentsList . toArray ( fragments ) ; return fragments ; } public int [ ] operators ( ) { int length = this . operatorsList . size ( ) ; int [ ] tab = new int [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { tab [ i ] = ( ( Integer ) this . operatorsList . get ( i ) ) . intValue ( ) ; } return tab ; } public int realFragmentsSize ( ) { return this . realFragmentsSize ; } public boolean visit ( AllocationExpression allocationExpression , BlockScope scope ) { addRealFragment ( allocationExpression ) ; return false ; } public boolean visit ( AND_AND_Expression and_and_Expression , BlockScope scope ) { if ( ( ( and_and_Expression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ) != <NUM_LIT:0> ) { addRealFragment ( and_and_Expression ) ; } else { and_and_Expression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameAND_AND ) ) ; and_and_Expression . right . traverse ( this , scope ) ; } return false ; } public boolean visit ( ArrayAllocationExpression arrayAllocationExpression , BlockScope scope ) { addRealFragment ( arrayAllocationExpression ) ; return false ; } public boolean visit ( ArrayInitializer arrayInitializer , BlockScope scope ) { addRealFragment ( arrayInitializer ) ; return false ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , BlockScope scope ) { addRealFragment ( arrayQualifiedTypeReference ) ; return false ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , ClassScope scope ) { addRealFragment ( arrayQualifiedTypeReference ) ; return false ; } public boolean visit ( ArrayReference arrayReference , BlockScope scope ) { addRealFragment ( arrayReference ) ; return false ; } public boolean visit ( ArrayTypeReference arrayTypeReference , BlockScope scope ) { addRealFragment ( arrayTypeReference ) ; return false ; } public boolean visit ( ArrayTypeReference arrayTypeReference , ClassScope scope ) { addRealFragment ( arrayTypeReference ) ; return false ; } public boolean visit ( Assignment assignment , BlockScope scope ) { addRealFragment ( assignment ) ; return false ; } public boolean visit ( BinaryExpression binaryExpression , BlockScope scope ) { if ( binaryExpression instanceof CombinedBinaryExpression ) { CombinedBinaryExpression expression = ( CombinedBinaryExpression ) binaryExpression ; if ( expression . referencesTable != null ) { return this . visit ( expression , scope ) ; } } final int numberOfParens = ( binaryExpression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ; if ( numberOfParens > <NUM_LIT:0> ) { addRealFragment ( binaryExpression ) ; } else { switch ( ( binaryExpression . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT ) { case OperatorIds . PLUS : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNamePLUS ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; case OperatorIds . MINUS : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameMINUS ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; case OperatorIds . MULTIPLY : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameMULTIPLY ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; case OperatorIds . REMAINDER : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameREMAINDER ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; case OperatorIds . XOR : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameXOR ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; case OperatorIds . DIVIDE : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameDIVIDE ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; case OperatorIds . OR : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameOR ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; case OperatorIds . AND : if ( buildFragments ( binaryExpression ) ) { binaryExpression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameAND ) ) ; binaryExpression . right . traverse ( this , scope ) ; } return false ; default : addRealFragment ( binaryExpression ) ; } } return false ; } public boolean visit ( CombinedBinaryExpression combinedBinaryExpression , BlockScope scope ) { if ( combinedBinaryExpression . referencesTable == null ) { addRealFragment ( combinedBinaryExpression . left ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNamePLUS ) ) ; addRealFragment ( combinedBinaryExpression . right ) ; return false ; } BinaryExpression cursor = combinedBinaryExpression . referencesTable [ <NUM_LIT:0> ] ; if ( cursor . left instanceof CombinedBinaryExpression ) { this . visit ( ( CombinedBinaryExpression ) cursor . left , scope ) ; } else { addRealFragment ( cursor . left ) ; } for ( int i = <NUM_LIT:0> , end = combinedBinaryExpression . arity ; i < end ; i ++ ) { this . operatorsList . add ( new Integer ( TerminalTokens . TokenNamePLUS ) ) ; addRealFragment ( combinedBinaryExpression . referencesTable [ i ] . right ) ; } this . operatorsList . add ( new Integer ( TerminalTokens . TokenNamePLUS ) ) ; addRealFragment ( combinedBinaryExpression . right ) ; return false ; } public boolean visit ( CastExpression castExpression , BlockScope scope ) { addRealFragment ( castExpression ) ; return false ; } public boolean visit ( CharLiteral charLiteral , BlockScope scope ) { addSmallFragment ( charLiteral ) ; return false ; } public boolean visit ( ClassLiteralAccess classLiteralAccess , BlockScope scope ) { addRealFragment ( classLiteralAccess ) ; return false ; } public boolean visit ( CompoundAssignment compoundAssignment , BlockScope scope ) { addRealFragment ( compoundAssignment ) ; return false ; } public boolean visit ( ConditionalExpression conditionalExpression , BlockScope scope ) { addRealFragment ( conditionalExpression ) ; return false ; } public boolean visit ( DoubleLiteral doubleLiteral , BlockScope scope ) { addSmallFragment ( doubleLiteral ) ; return false ; } public boolean visit ( EqualExpression equalExpression , BlockScope scope ) { addRealFragment ( equalExpression ) ; return false ; } public boolean visit ( ExtendedStringLiteral extendedStringLiteral , BlockScope scope ) { addRealFragment ( extendedStringLiteral ) ; return false ; } public boolean visit ( FalseLiteral falseLiteral , BlockScope scope ) { addSmallFragment ( falseLiteral ) ; return false ; } public boolean visit ( FieldReference fieldReference , BlockScope scope ) { addRealFragment ( fieldReference ) ; return false ; } public boolean visit ( FloatLiteral floatLiteral , BlockScope scope ) { addSmallFragment ( floatLiteral ) ; return false ; } public boolean visit ( InstanceOfExpression instanceOfExpression , BlockScope scope ) { addRealFragment ( instanceOfExpression ) ; return false ; } public boolean visit ( IntLiteral intLiteral , BlockScope scope ) { addSmallFragment ( intLiteral ) ; return false ; } public boolean visit ( LongLiteral longLiteral , BlockScope scope ) { addSmallFragment ( longLiteral ) ; return false ; } public boolean visit ( MessageSend messageSend , BlockScope scope ) { addRealFragment ( messageSend ) ; return false ; } public boolean visit ( StringLiteralConcatenation stringLiteral , BlockScope scope ) { if ( ( ( stringLiteral . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ) != <NUM_LIT:0> ) { addRealFragment ( stringLiteral ) ; } else { for ( int i = <NUM_LIT:0> , max = stringLiteral . counter ; i < max ; i ++ ) { addRealFragment ( stringLiteral . literals [ i ] ) ; if ( i < max - <NUM_LIT:1> ) { this . operatorsList . add ( new Integer ( TerminalTokens . TokenNamePLUS ) ) ; } } } return false ; } public boolean visit ( NullLiteral nullLiteral , BlockScope scope ) { addRealFragment ( nullLiteral ) ; return false ; } public boolean visit ( OR_OR_Expression or_or_Expression , BlockScope scope ) { if ( ( ( or_or_Expression . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT ) != <NUM_LIT:0> ) { addRealFragment ( or_or_Expression ) ; } else { or_or_Expression . left . traverse ( this , scope ) ; this . operatorsList . add ( new Integer ( TerminalTokens . TokenNameOR_OR ) ) ; or_or_Expression . right . traverse ( this , scope ) ; } return false ; } public boolean visit ( PostfixExpression postfixExpression , BlockScope scope ) { addRealFragment ( postfixExpression ) ; return false ; } public boolean visit ( PrefixExpression prefixExpression , BlockScope scope ) { addRealFragment ( prefixExpression ) ; return false ; } public boolean visit ( QualifiedAllocationExpression qualifiedAllocationExpression , BlockScope scope ) { addRealFragment ( qualifiedAllocationExpression ) ; return false ; } public boolean visit ( QualifiedNameReference qualifiedNameReference , BlockScope scope ) { addRealFragment ( qualifiedNameReference ) ; return false ; } public boolean visit ( QualifiedSuperReference qualifiedSuperReference , BlockScope scope ) { addRealFragment ( qualifiedSuperReference ) ; return false ; } public boolean visit ( QualifiedThisReference qualifiedThisReference , BlockScope scope ) { addRealFragment ( qualifiedThisReference ) ; return false ; } public boolean visit ( SingleNameReference singleNameReference , BlockScope scope ) { addRealFragment ( singleNameReference ) ; return false ; } public boolean visit ( StringLiteral stringLiteral , BlockScope scope ) { addRealFragment ( stringLiteral ) ; return false ; } public boolean visit ( SuperReference superReference , BlockScope scope ) { addRealFragment ( superReference ) ; return false ; } public boolean visit ( ThisReference thisReference , BlockScope scope ) { addRealFragment ( thisReference ) ; return false ; } public boolean visit ( TrueLiteral trueLiteral , BlockScope scope ) { addSmallFragment ( trueLiteral ) ; return false ; } public boolean visit ( UnaryExpression unaryExpression , BlockScope scope ) { addRealFragment ( unaryExpression ) ; return false ; } public int size ( ) { return this . fragmentsList . size ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; public class FormatJavadocReference extends FormatJavadocNode { public FormatJavadocReference ( int start , int end , int line ) { super ( start , end , line ) ; } public FormatJavadocReference ( long position , int line ) { super ( ( int ) ( position > > > <NUM_LIT:32> ) , ( int ) position , line ) ; } void clean ( ) { } protected void toString ( StringBuffer buffer ) { buffer . append ( "<STR_LIT>" ) ; super . toString ( buffer ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import java . util . ArrayList ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; class CascadingMethodInvocationFragmentBuilder extends ASTVisitor { ArrayList fragmentsList ; CascadingMethodInvocationFragmentBuilder ( ) { this . fragmentsList = new ArrayList ( ) ; } public MessageSend [ ] fragments ( ) { MessageSend [ ] fragments = new MessageSend [ this . fragmentsList . size ( ) ] ; this . fragmentsList . toArray ( fragments ) ; return fragments ; } public int size ( ) { return this . fragmentsList . size ( ) ; } public boolean visit ( MessageSend messageSend , BlockScope scope ) { if ( ( messageSend . receiver . bits & ASTNode . ParenthesizedMASK ) > > ASTNode . ParenthesizedSHIFT == <NUM_LIT:0> ) { if ( messageSend . receiver instanceof MessageSend ) { this . fragmentsList . add ( <NUM_LIT:0> , messageSend ) ; messageSend . receiver . traverse ( this , scope ) ; return false ; } this . fragmentsList . add ( <NUM_LIT:0> , messageSend ) ; this . fragmentsList . add ( <NUM_LIT:1> , messageSend ) ; } else { this . fragmentsList . add ( <NUM_LIT:0> , messageSend ) ; this . fragmentsList . add ( <NUM_LIT:1> , messageSend ) ; } return false ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import java . util . List ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . parser . JavadocParser ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . formatter . comment . IJavaDocTagConstants ; public class FormatterCommentParser extends JavadocParser implements IJavaDocTagConstants { char [ ] [ ] htmlTags ; int htmlTagsPtr = - <NUM_LIT:1> ; int inlineHtmlTagsPtr = - <NUM_LIT:1> ; private boolean invalidTagName ; public boolean parseHtmlTags ; public FormatterCommentParser ( long sourceLevel ) { super ( null ) ; this . kind = FORMATTER_COMMENT_PARSER | TEXT_PARSE ; this . reportProblems = false ; this . checkDocComment = true ; this . sourceLevel = sourceLevel ; } public boolean parse ( int start , int end ) { this . javadocStart = start ; this . javadocEnd = end ; this . firstTagPosition = this . javadocStart ; this . htmlTagsPtr = - <NUM_LIT:1> ; boolean valid = commentParse ( ) ; return valid && this . docComment != null ; } protected Object createArgumentReference ( char [ ] name , int dim , boolean isVarargs , Object ref , long [ ] dimPositions , long argNamePos ) throws InvalidInputException { FormatJavadocReference typeRef = ( FormatJavadocReference ) ref ; if ( dim > <NUM_LIT:0> ) { typeRef . sourceEnd = ( int ) dimPositions [ dim - <NUM_LIT:1> ] ; } if ( argNamePos >= <NUM_LIT:0> ) typeRef . sourceEnd = ( int ) argNamePos ; return ref ; } protected boolean createFakeReference ( int start ) { this . scanner . currentPosition = this . index ; int lineStart = this . scanner . getLineNumber ( start ) ; FormatJavadocReference reference = new FormatJavadocReference ( start , this . index - <NUM_LIT:1> , lineStart ) ; return pushSeeRef ( reference ) ; } protected Object createFieldReference ( Object receiver ) throws InvalidInputException { int start = receiver == null ? this . memberStart : ( ( FormatJavadocReference ) receiver ) . sourceStart ; int lineStart = this . scanner . getLineNumber ( start ) ; return new FormatJavadocReference ( start , ( int ) this . identifierPositionStack [ <NUM_LIT:0> ] , lineStart ) ; } protected Object createMethodReference ( Object receiver , List arguments ) throws InvalidInputException { int start = receiver == null ? this . memberStart : ( ( FormatJavadocReference ) receiver ) . sourceStart ; int lineStart = this . scanner . getLineNumber ( start ) ; return new FormatJavadocReference ( start , this . scanner . getCurrentTokenEndPosition ( ) , lineStart ) ; } protected void createTag ( ) { int lineStart = this . scanner . getLineNumber ( this . tagSourceStart ) ; if ( this . inlineTagStarted ) { FormatJavadocBlock block = new FormatJavadocBlock ( this . inlineTagStart , this . tagSourceEnd , lineStart , this . tagValue ) ; FormatJavadocBlock previousBlock = null ; if ( this . astPtr == - <NUM_LIT:1> ) { previousBlock = new FormatJavadocBlock ( this . inlineTagStart , this . tagSourceEnd , lineStart , NO_TAG_VALUE ) ; pushOnAstStack ( previousBlock , true ) ; } else { previousBlock = ( FormatJavadocBlock ) this . astStack [ this . astPtr ] ; } previousBlock . addBlock ( block , this . htmlTagsPtr == - <NUM_LIT:1> ? <NUM_LIT:0> : this . htmlTagsPtr ) ; } else { FormatJavadocBlock block = new FormatJavadocBlock ( this . tagSourceStart , this . tagSourceEnd , lineStart , this . tagValue ) ; pushOnAstStack ( block , true ) ; } } protected Object createTypeReference ( int primitiveToken ) { int size = this . identifierLengthStack [ this . identifierLengthPtr ] ; if ( size == <NUM_LIT:0> ) return null ; int start = ( int ) ( this . identifierPositionStack [ this . identifierPtr ] > > > <NUM_LIT:32> ) ; int lineStart = this . scanner . getLineNumber ( start ) ; if ( size == <NUM_LIT:1> ) { return new FormatJavadocReference ( this . identifierPositionStack [ this . identifierPtr ] , lineStart ) ; } long [ ] positions = new long [ size ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr - size + <NUM_LIT:1> , positions , <NUM_LIT:0> , size ) ; return new FormatJavadocReference ( ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) , ( int ) positions [ positions . length - <NUM_LIT:1> ] , lineStart ) ; } private int getHtmlTagIndex ( char [ ] htmlTag ) { int length = htmlTag == null ? <NUM_LIT:0> : htmlTag . length ; int tagId = <NUM_LIT:0> ; if ( length > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> , max = JAVADOC_SINGLE_BREAK_TAG . length ; i < max ; i ++ ) { char [ ] tag = JAVADOC_SINGLE_BREAK_TAG [ i ] ; if ( length == tag . length && CharOperation . equals ( htmlTag , tag , false ) ) { return ( tagId | JAVADOC_SINGLE_BREAK_TAG_ID ) + i ; } } for ( int i = <NUM_LIT:0> , max = JAVADOC_CODE_TAGS . length ; i < max ; i ++ ) { char [ ] tag = JAVADOC_CODE_TAGS [ i ] ; if ( length == tag . length && CharOperation . equals ( htmlTag , tag , false ) ) { return ( tagId | JAVADOC_CODE_TAGS_ID ) + i ; } } for ( int i = <NUM_LIT:0> , max = JAVADOC_BREAK_TAGS . length ; i < max ; i ++ ) { char [ ] tag = JAVADOC_BREAK_TAGS [ i ] ; if ( length == tag . length && CharOperation . equals ( htmlTag , tag , false ) ) { return ( tagId | JAVADOC_BREAK_TAGS_ID ) + i ; } } for ( int i = <NUM_LIT:0> , max = JAVADOC_IMMUTABLE_TAGS . length ; i < max ; i ++ ) { char [ ] tag = JAVADOC_IMMUTABLE_TAGS [ i ] ; if ( length == tag . length && CharOperation . equals ( htmlTag , tag , false ) ) { return ( tagId | JAVADOC_IMMUTABLE_TAGS_ID ) + i ; } } for ( int i = <NUM_LIT:0> , max = JAVADOC_SEPARATOR_TAGS . length ; i < max ; i ++ ) { char [ ] tag = JAVADOC_SEPARATOR_TAGS [ i ] ; if ( length == tag . length && CharOperation . equals ( htmlTag , tag , false ) ) { return ( tagId | JAVADOC_SEPARATOR_TAGS_ID ) + i ; } } } return JAVADOC_TAGS_ID_MASK ; } protected boolean parseHtmlTag ( int previousPosition , int endTextPosition ) throws InvalidInputException { if ( ! this . parseHtmlTags ) return false ; boolean closing = false ; boolean valid = false ; boolean incremented = false ; int start = this . scanner . currentPosition ; int currentPosition = start ; int htmlPtr = this . htmlTagsPtr ; char firstChar = peekChar ( ) ; boolean hasWhitespaces = firstChar == '<CHAR_LIT:U+0020>' || ScannerHelper . isWhitespace ( firstChar ) ; try { int token = readTokenAndConsume ( ) ; char [ ] htmlTag ; int htmlIndex ; switch ( token ) { case TerminalTokens . TokenNameIdentifier : htmlTag = this . scanner . getCurrentIdentifierSource ( ) ; htmlIndex = getHtmlTagIndex ( htmlTag ) ; if ( htmlIndex == JAVADOC_TAGS_ID_MASK ) return false ; if ( htmlPtr >= <NUM_LIT:0> ) { int lastHtmlTagIndex = getHtmlTagIndex ( this . htmlTags [ htmlPtr ] ) ; if ( ( lastHtmlTagIndex & JAVADOC_TAGS_ID_MASK ) == JAVADOC_IMMUTABLE_TAGS_ID ) { if ( ( htmlIndex & JAVADOC_TAGS_ID_MASK ) == JAVADOC_CODE_TAGS_ID ) { FormatJavadocBlock previousBlock = ( FormatJavadocBlock ) this . astStack [ this . astPtr ] ; FormatJavadocNode parentNode = previousBlock ; FormatJavadocNode lastNode = parentNode ; while ( lastNode . getLastNode ( ) != null ) { parentNode = lastNode ; lastNode = lastNode . getLastNode ( ) ; } if ( lastNode . isText ( ) ) { FormatJavadocText text = ( FormatJavadocText ) lastNode ; if ( text . separatorsPtr == - <NUM_LIT:1> ) { break ; } } } return false ; } } if ( ( htmlIndex & JAVADOC_TAGS_ID_MASK ) > JAVADOC_SINGLE_TAGS_ID ) { if ( this . htmlTagsPtr == - <NUM_LIT:1> || ! CharOperation . equals ( this . htmlTags [ this . htmlTagsPtr ] , htmlTag , false ) ) { if ( ++ this . htmlTagsPtr == <NUM_LIT:0> ) { this . htmlTags = new char [ AST_STACK_INCREMENT ] [ ] ; } else { if ( this . htmlTagsPtr == this . htmlTags . length ) { System . arraycopy ( this . htmlTags , <NUM_LIT:0> , ( this . htmlTags = new char [ this . htmlTags . length + AST_STACK_INCREMENT ] [ ] ) , <NUM_LIT:0> , this . htmlTagsPtr ) ; } } this . htmlTags [ this . htmlTagsPtr ] = htmlTag ; incremented = true ; } } currentPosition = this . scanner . currentPosition ; if ( readToken ( ) == TerminalTokens . TokenNameDIVIDE ) { consumeToken ( ) ; } break ; case TerminalTokens . TokenNameDIVIDE : if ( this . htmlTagsPtr == - <NUM_LIT:1> ) return false ; htmlTag = this . htmlTags [ this . htmlTagsPtr ] ; if ( ( token = readTokenAndConsume ( ) ) != TerminalTokens . TokenNameIdentifier ) { return false ; } char [ ] identifier = this . scanner . getCurrentIdentifierSource ( ) ; htmlIndex = getHtmlTagIndex ( identifier ) ; if ( htmlIndex == JAVADOC_TAGS_ID_MASK ) return false ; int ptr = this . htmlTagsPtr ; while ( ! CharOperation . equals ( htmlTag , identifier , false ) ) { if ( this . htmlTagsPtr <= <NUM_LIT:0> ) { this . htmlTagsPtr = ptr ; return false ; } this . htmlTagsPtr -- ; htmlTag = this . htmlTags [ this . htmlTagsPtr ] ; } htmlIndex |= JAVADOC_CLOSED_TAG ; closing = true ; currentPosition = this . scanner . currentPosition ; break ; default : return false ; } switch ( readTokenAndConsume ( ) ) { case TerminalTokens . TokenNameLESS : case TerminalTokens . TokenNameLESS_EQUAL : return false ; case TerminalTokens . TokenNameGREATER : break ; case TerminalTokens . TokenNameGREATER_EQUAL : case TerminalTokens . TokenNameRIGHT_SHIFT : case TerminalTokens . TokenNameRIGHT_SHIFT_EQUAL : break ; default : this . index = currentPosition ; loop : while ( true ) { switch ( readChar ( ) ) { case '<CHAR_LIT>' : if ( hasWhitespaces ) { return false ; } this . index = currentPosition ; this . scanner . startPosition = currentPosition ; this . scanner . currentPosition = currentPosition ; this . scanner . currentCharacter = '<CHAR_LIT>' ; break loop ; case '<CHAR_LIT:>>' : this . scanner . startPosition = this . index ; this . scanner . currentPosition = this . index ; this . scanner . currentCharacter = peekChar ( ) ; break loop ; default : break ; } if ( this . index >= this . javadocTextEnd ) { this . index = currentPosition ; this . scanner . startPosition = currentPosition ; this . scanner . currentPosition = currentPosition ; break ; } } } if ( this . lineStarted && this . textStart != - <NUM_LIT:1> && this . textStart < endTextPosition ) { pushText ( this . textStart , endTextPosition , - <NUM_LIT:1> , htmlPtr ) ; } pushText ( previousPosition , this . index , htmlIndex , this . htmlTagsPtr ) ; this . textStart = - <NUM_LIT:1> ; valid = true ; } finally { if ( valid ) { if ( closing ) { this . htmlTagsPtr -- ; } } else if ( ! this . abort ) { if ( incremented ) { this . htmlTagsPtr -- ; if ( this . htmlTagsPtr == - <NUM_LIT:1> ) this . htmlTags = null ; } this . scanner . resetTo ( start , this . scanner . eofPosition - <NUM_LIT:1> ) ; this . index = start ; } } return valid ; } protected boolean parseIdentifierTag ( boolean report ) { if ( super . parseIdentifierTag ( report ) ) { createTag ( ) ; this . index = this . tagSourceEnd + <NUM_LIT:1> ; this . scanner . resetTo ( this . index , this . javadocEnd ) ; return true ; } this . tagValue = TAG_OTHERS_VALUE ; return false ; } protected boolean parseParam ( ) throws InvalidInputException { boolean valid = super . parseParam ( ) ; if ( ! valid ) { this . scanner . resetTo ( this . tagSourceEnd + <NUM_LIT:1> , this . javadocEnd ) ; this . index = this . tagSourceEnd + <NUM_LIT:1> ; char ch = peekChar ( ) ; if ( ch == '<CHAR_LIT:U+0020>' || ScannerHelper . isWhitespace ( ch ) ) { int token = this . scanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameIdentifier ) { ch = peekChar ( ) ; if ( ch == '<CHAR_LIT:U+0020>' || ScannerHelper . isWhitespace ( ch ) ) { pushIdentifier ( true , false ) ; pushParamName ( false ) ; this . index = this . scanner . currentPosition ; valid = true ; } } this . scanner . resetTo ( this . tagSourceEnd + <NUM_LIT:1> , this . javadocEnd ) ; } this . tagValue = TAG_OTHERS_VALUE ; } return valid ; } protected boolean parseReference ( ) throws InvalidInputException { boolean valid = super . parseReference ( ) ; if ( ! valid ) { this . scanner . resetTo ( this . tagSourceEnd + <NUM_LIT:1> , this . javadocEnd ) ; this . index = this . tagSourceEnd + <NUM_LIT:1> ; this . tagValue = TAG_OTHERS_VALUE ; } return valid ; } protected boolean parseReturn ( ) { createTag ( ) ; return true ; } protected boolean parseTag ( int previousPosition ) throws InvalidInputException { if ( this . htmlTagsPtr >= <NUM_LIT:0> ) { int ptr = this . htmlTagsPtr ; while ( ptr >= <NUM_LIT:0> ) { if ( getHtmlTagIndex ( this . htmlTags [ ptr -- ] ) == JAVADOC_CODE_TAGS_ID ) { if ( this . textStart == - <NUM_LIT:1> ) this . textStart = this . inlineTagStarted ? this . inlineTagStart : previousPosition ; this . inlineTagStarted = false ; return true ; } } } int ptr = this . astPtr ; this . tagSourceStart = previousPosition ; this . scanner . startPosition = this . index ; this . scanner . currentCharacter = readChar ( ) ; switch ( this . scanner . currentCharacter ) { case '<CHAR_LIT:U+0020>' : case '<CHAR_LIT>' : case '<CHAR_LIT:}>' : this . tagSourceEnd = previousPosition ; if ( this . textStart == - <NUM_LIT:1> ) this . textStart = previousPosition ; return true ; default : if ( ScannerHelper . isWhitespace ( this . scanner . currentCharacter ) ) { this . tagSourceEnd = previousPosition ; if ( this . textStart == - <NUM_LIT:1> ) this . textStart = previousPosition ; return true ; } break ; } int currentPosition = this . index ; char currentChar = this . scanner . currentCharacter ; while ( currentChar != '<CHAR_LIT:U+0020>' && currentChar != '<CHAR_LIT>' && currentChar != '<CHAR_LIT:}>' && ! ScannerHelper . isWhitespace ( currentChar ) ) { currentPosition = this . index ; currentChar = readChar ( ) ; } this . tagSourceEnd = currentPosition - <NUM_LIT:1> ; this . scanner . currentCharacter = currentChar ; this . scanner . currentPosition = currentPosition ; char [ ] tagName = this . scanner . getCurrentIdentifierSource ( ) ; int length = tagName . length ; this . index = this . tagSourceEnd + <NUM_LIT:1> ; this . tagValue = TAG_OTHERS_VALUE ; boolean valid = false ; switch ( tagName [ <NUM_LIT:0> ] ) { case '<CHAR_LIT:a>' : if ( length == TAG_AUTHOR_LENGTH && CharOperation . equals ( TAG_AUTHOR , tagName ) ) { this . tagValue = TAG_AUTHOR_VALUE ; } break ; case '<CHAR_LIT:c>' : if ( length == TAG_CATEGORY_LENGTH && CharOperation . equals ( TAG_CATEGORY , tagName ) ) { this . tagValue = TAG_CATEGORY_VALUE ; valid = parseIdentifierTag ( false ) ; } else if ( length == TAG_CODE_LENGTH && this . inlineTagStarted && CharOperation . equals ( TAG_CODE , tagName ) ) { this . tagValue = TAG_CODE_VALUE ; } break ; case '<CHAR_LIT>' : if ( length == TAG_DEPRECATED_LENGTH && CharOperation . equals ( TAG_DEPRECATED , tagName ) ) { this . deprecated = true ; valid = true ; this . tagValue = TAG_DEPRECATED_VALUE ; } else if ( length == TAG_DOC_ROOT_LENGTH && CharOperation . equals ( TAG_DOC_ROOT , tagName ) ) { valid = true ; this . tagValue = TAG_DOC_ROOT_VALUE ; } break ; case '<CHAR_LIT:e>' : if ( length == TAG_EXCEPTION_LENGTH && CharOperation . equals ( TAG_EXCEPTION , tagName ) ) { this . tagValue = TAG_EXCEPTION_VALUE ; valid = parseThrows ( ) ; } break ; case '<CHAR_LIT>' : if ( length == TAG_INHERITDOC_LENGTH && CharOperation . equals ( TAG_INHERITDOC , tagName ) ) { if ( this . reportProblems ) { recordInheritedPosition ( ( ( ( long ) this . tagSourceStart ) << <NUM_LIT:32> ) + this . tagSourceEnd ) ; } valid = true ; this . tagValue = TAG_INHERITDOC_VALUE ; } break ; case '<CHAR_LIT>' : if ( length == TAG_LINK_LENGTH && CharOperation . equals ( TAG_LINK , tagName ) ) { this . tagValue = TAG_LINK_VALUE ; if ( this . inlineTagStarted || ( this . kind & COMPLETION_PARSER ) != <NUM_LIT:0> ) { valid = parseReference ( ) ; } else { valid = false ; if ( this . reportProblems ) { this . sourceParser . problemReporter ( ) . javadocUnexpectedTag ( this . tagSourceStart , this . tagSourceEnd ) ; } } } else if ( length == TAG_LINKPLAIN_LENGTH && CharOperation . equals ( TAG_LINKPLAIN , tagName ) ) { this . tagValue = TAG_LINKPLAIN_VALUE ; if ( this . inlineTagStarted ) { valid = parseReference ( ) ; } else { valid = false ; if ( this . reportProblems ) { this . sourceParser . problemReporter ( ) . javadocUnexpectedTag ( this . tagSourceStart , this . tagSourceEnd ) ; } } } else if ( length == TAG_LITERAL_LENGTH && this . inlineTagStarted && CharOperation . equals ( TAG_LITERAL , tagName ) ) { this . tagValue = TAG_LITERAL_VALUE ; } break ; case '<CHAR_LIT>' : if ( length == TAG_PARAM_LENGTH && CharOperation . equals ( TAG_PARAM , tagName ) ) { this . tagValue = TAG_PARAM_VALUE ; valid = parseParam ( ) ; } break ; case '<CHAR_LIT>' : if ( length == TAG_SEE_LENGTH && CharOperation . equals ( TAG_SEE , tagName ) ) { if ( this . inlineTagStarted ) { valid = false ; if ( this . reportProblems ) { this . sourceParser . problemReporter ( ) . javadocUnexpectedTag ( this . tagSourceStart , this . tagSourceEnd ) ; } } else { this . tagValue = TAG_SEE_VALUE ; valid = parseReference ( ) ; } } else if ( length == TAG_SERIAL_LENGTH && CharOperation . equals ( TAG_SERIAL , tagName ) ) { this . tagValue = TAG_SERIAL_VALUE ; } else if ( length == TAG_SERIAL_DATA_LENGTH && CharOperation . equals ( TAG_SERIAL_DATA , tagName ) ) { this . tagValue = TAG_SERIAL_DATA_VALUE ; } else if ( length == TAG_SERIAL_FIELD_LENGTH && CharOperation . equals ( TAG_SERIAL_FIELD , tagName ) ) { this . tagValue = TAG_SERIAL_FIELD_VALUE ; } else if ( length == TAG_SINCE_LENGTH && CharOperation . equals ( TAG_SINCE , tagName ) ) { this . tagValue = TAG_SINCE_VALUE ; } break ; case '<CHAR_LIT>' : if ( length == TAG_VALUE_LENGTH && CharOperation . equals ( TAG_VALUE , tagName ) ) { this . tagValue = TAG_VALUE_VALUE ; if ( this . sourceLevel >= ClassFileConstants . JDK1_5 ) { if ( this . inlineTagStarted ) { valid = parseReference ( ) ; } else { valid = false ; if ( this . reportProblems ) this . sourceParser . problemReporter ( ) . javadocUnexpectedTag ( this . tagSourceStart , this . tagSourceEnd ) ; } } } else if ( length == TAG_VERSION_LENGTH && CharOperation . equals ( TAG_VERSION , tagName ) ) { this . tagValue = TAG_VERSION_VALUE ; } else { createTag ( ) ; } break ; case '<CHAR_LIT>' : if ( length == TAG_RETURN_LENGTH && CharOperation . equals ( TAG_RETURN , tagName ) ) { this . tagValue = TAG_RETURN_VALUE ; valid = parseReturn ( ) ; } break ; case '<CHAR_LIT>' : if ( length == TAG_THROWS_LENGTH && CharOperation . equals ( TAG_THROWS , tagName ) ) { this . tagValue = TAG_THROWS_VALUE ; valid = parseThrows ( ) ; } break ; default : createTag ( ) ; break ; } consumeToken ( ) ; this . textStart = - <NUM_LIT:1> ; if ( valid ) { switch ( this . tagValue ) { case TAG_INHERITDOC_VALUE : case TAG_DEPRECATED_VALUE : createTag ( ) ; break ; } } else if ( this . invalidTagName ) { this . textStart = previousPosition ; } else if ( this . astPtr == ptr ) { createTag ( ) ; } return true ; } protected boolean parseThrows ( ) { boolean valid = super . parseThrows ( ) ; if ( ! valid ) { this . scanner . resetTo ( this . tagSourceEnd + <NUM_LIT:1> , this . javadocEnd ) ; this . index = this . tagSourceEnd + <NUM_LIT:1> ; this . tagValue = TAG_OTHERS_VALUE ; } return valid ; } protected boolean pushParamName ( boolean isTypeParam ) { int lineTagStart = this . scanner . getLineNumber ( this . tagSourceStart ) ; FormatJavadocBlock block = new FormatJavadocBlock ( this . tagSourceStart , this . tagSourceEnd , lineTagStart , TAG_PARAM_VALUE ) ; int start = ( int ) ( this . identifierPositionStack [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int lineStart = this . scanner . getLineNumber ( start ) ; FormatJavadocReference reference ; reference = new FormatJavadocReference ( start , ( int ) this . identifierPositionStack [ isTypeParam ? <NUM_LIT:2> : <NUM_LIT:0> ] , lineStart ) ; block . reference = reference ; block . sourceEnd = reference . sourceEnd ; pushOnAstStack ( block , true ) ; return true ; } protected boolean pushSeeRef ( Object statement ) { FormatJavadocReference reference = ( FormatJavadocReference ) statement ; int lineTagStart = this . scanner . getLineNumber ( this . tagSourceStart ) ; FormatJavadocBlock block = new FormatJavadocBlock ( this . tagSourceStart , this . tagSourceEnd , lineTagStart , this . tagValue ) ; block . reference = reference ; block . sourceEnd = reference . sourceEnd ; if ( this . inlineTagStarted ) { block . sourceStart = this . inlineTagStart ; FormatJavadocBlock previousBlock = null ; if ( this . astPtr == - <NUM_LIT:1> ) { int lineStart = this . scanner . getLineNumber ( this . inlineTagStart ) ; previousBlock = new FormatJavadocBlock ( this . inlineTagStart , this . tagSourceEnd , lineStart , NO_TAG_VALUE ) ; previousBlock . sourceEnd = reference . sourceEnd ; pushOnAstStack ( previousBlock , true ) ; } else { previousBlock = ( FormatJavadocBlock ) this . astStack [ this . astPtr ] ; } previousBlock . addBlock ( block , this . htmlTagsPtr == - <NUM_LIT:1> ? <NUM_LIT:0> : this . htmlTagsPtr ) ; block . flags |= FormatJavadocBlock . INLINED ; } else { pushOnAstStack ( block , true ) ; } return true ; } protected void pushText ( int start , int end ) { pushText ( start , end , - <NUM_LIT:1> , this . htmlTagsPtr == - <NUM_LIT:1> ? <NUM_LIT:0> : this . htmlTagsPtr ) ; } private void pushText ( int start , int end , int htmlIndex , int htmlDepth ) { FormatJavadocBlock previousBlock = null ; int previousStart = start ; int lineStart = this . scanner . getLineNumber ( start ) ; if ( this . astPtr == - <NUM_LIT:1> ) { previousBlock = new FormatJavadocBlock ( start , start , lineStart , NO_TAG_VALUE ) ; pushOnAstStack ( previousBlock , true ) ; } else { previousBlock = ( FormatJavadocBlock ) this . astStack [ this . astPtr ] ; previousStart = previousBlock . sourceStart ; } if ( this . inlineTagStarted ) { if ( previousBlock . nodes == null ) { } else { FormatJavadocNode lastNode = previousBlock . nodes [ previousBlock . nodesPtr ] ; while ( lastNode != null && lastNode . isText ( ) ) { lastNode = lastNode . getLastNode ( ) ; } if ( lastNode != null ) { previousBlock = ( FormatJavadocBlock ) lastNode ; previousStart = previousBlock . sourceStart ; } } } FormatJavadocText text = new FormatJavadocText ( start , end - <NUM_LIT:1> , lineStart , htmlIndex , htmlDepth == - <NUM_LIT:1> ? <NUM_LIT:0> : htmlDepth ) ; previousBlock . addText ( text ) ; previousBlock . sourceStart = previousStart ; if ( lineStart == previousBlock . lineStart ) { previousBlock . flags |= FormatJavadocBlock . TEXT_ON_TAG_LINE ; } this . textStart = - <NUM_LIT:1> ; } protected boolean pushThrowName ( Object typeRef ) { int lineStart = this . scanner . getLineNumber ( this . tagSourceStart ) ; FormatJavadocBlock block = new FormatJavadocBlock ( this . tagSourceStart , this . tagSourceEnd , lineStart , this . tagValue ) ; block . reference = ( FormatJavadocReference ) typeRef ; block . sourceEnd = block . reference . sourceEnd ; pushOnAstStack ( block , true ) ; return true ; } protected void refreshInlineTagPosition ( int previousPosition ) { if ( this . astPtr != - <NUM_LIT:1> ) { FormatJavadocNode previousBlock = ( FormatJavadocNode ) this . astStack [ this . astPtr ] ; if ( this . inlineTagStarted ) { FormatJavadocNode lastNode = previousBlock ; while ( lastNode != null ) { lastNode . sourceEnd = previousPosition ; lastNode = lastNode . getLastNode ( ) ; } } } } protected void setInlineTagStarted ( boolean started ) { super . setInlineTagStarted ( started ) ; if ( started ) { this . inlineHtmlTagsPtr = this . htmlTagsPtr ; } else { if ( this . htmlTagsPtr > this . inlineHtmlTagsPtr ) { this . htmlTagsPtr = this . inlineHtmlTagsPtr ; } } } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( super . toString ( ) ) ; return buffer . toString ( ) ; } public String toDebugString ( ) { if ( this . docComment == null ) { return "<STR_LIT>" ; } return ( ( FormatJavadoc ) this . docComment ) . toDebugString ( this . source ) ; } protected void updateDocComment ( ) { int length = this . astPtr + <NUM_LIT:1> ; FormatJavadoc formatJavadoc = new FormatJavadoc ( this . javadocStart , this . javadocEnd , length ) ; if ( length > <NUM_LIT:0> ) { formatJavadoc . blocks = new FormatJavadocBlock [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { FormatJavadocBlock block = ( FormatJavadocBlock ) this . astStack [ i ] ; block . clean ( ) ; block . update ( this . scanner ) ; formatJavadoc . blocks [ i ] = block ; if ( i == <NUM_LIT:0> ) { block . flags |= FormatJavadocBlock . FIRST ; } } } formatJavadoc . textStart = this . javadocTextStart ; formatJavadoc . textEnd = this . javadocTextEnd ; formatJavadoc . lineStart = this . scanner . getLineNumber ( this . javadocTextStart ) ; formatJavadoc . lineEnd = this . scanner . getLineNumber ( this . javadocTextEnd ) ; FormatJavadocBlock firstBlock = formatJavadoc . getFirstBlock ( ) ; if ( firstBlock != null ) { firstBlock . setHeaderLine ( formatJavadoc . lineStart ) ; } this . docComment = formatJavadoc ; if ( DefaultCodeFormatter . DEBUG ) { System . out . println ( toDebugString ( ) ) ; } } protected boolean verifyEndLine ( int textPosition ) { return true ; } protected boolean verifySpaceOrEndComment ( ) { return true ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import org . eclipse . jdt . internal . compiler . parser . JavadocTagConstants ; public abstract class FormatJavadocNode implements JavadocTagConstants { final static int DEFAULT_ARRAY_SIZE = <NUM_LIT:10> ; final static int INCREMENT_ARRAY_SIZE = <NUM_LIT:10> ; protected int sourceStart , sourceEnd ; protected int lineStart ; protected int linesBefore = <NUM_LIT:0> ; public FormatJavadocNode ( int start , int end , int line ) { this . sourceStart = start ; this . sourceEnd = end ; this . lineStart = line ; } abstract void clean ( ) ; FormatJavadocNode getLastNode ( ) { return null ; } public int getLength ( ) { return this . sourceEnd - this . sourceStart + <NUM_LIT:1> ; } public boolean isText ( ) { return false ; } public boolean isImmutable ( ) { return false ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; toString ( buffer ) ; return buffer . toString ( ) ; } protected void toString ( StringBuffer buffer ) { buffer . append ( "<STR_LIT::U+0020>" ) ; buffer . append ( this . sourceStart ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . sourceEnd ) ; } public String toStringDebug ( char [ ] source ) { StringBuffer buffer = new StringBuffer ( ) ; toStringDebug ( buffer , source ) ; return buffer . toString ( ) ; } public void toStringDebug ( StringBuffer buffer , char [ ] source ) { buffer . append ( source , this . sourceStart , this . sourceEnd - this . sourceStart + <NUM_LIT:1> ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; } void setHeaderLine ( int javadocLineStart ) { } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import org . eclipse . jdt . internal . formatter . comment . IJavaDocTagConstants ; public class FormatJavadocText extends FormatJavadocNode implements IJavaDocTagConstants { long [ ] separators ; int separatorsPtr = - <NUM_LIT:1> ; private int htmlTagIndex = - <NUM_LIT:1> ; boolean immutable = false ; FormatJavadocNode [ ] htmlNodes ; int [ ] htmlIndexes ; int htmlNodesPtr = - <NUM_LIT:1> ; int depth = <NUM_LIT:0> ; public FormatJavadocText ( int start , int end , int line , int htmlIndex , int htmlDepth ) { super ( start , end , line ) ; this . htmlTagIndex = htmlIndex ; this . depth = htmlDepth ; } void appendText ( FormatJavadocText text ) { text . immutable = this . immutable ; if ( this . depth == text . depth ) { addSeparator ( text ) ; this . sourceEnd = text . sourceEnd ; if ( text . isClosingHtmlTag ( ) ) { this . htmlTagIndex = text . htmlTagIndex ; } } else { appendNode ( text ) ; } if ( text . isHtmlTag ( ) ) { switch ( text . htmlTagIndex & JAVADOC_TAGS_ID_MASK ) { case JAVADOC_CODE_TAGS_ID : text . linesBefore = this . htmlNodesPtr == - <NUM_LIT:1> ? <NUM_LIT:0> : <NUM_LIT:2> ; break ; case JAVADOC_SEPARATOR_TAGS_ID : text . linesBefore = <NUM_LIT:1> ; break ; case JAVADOC_SINGLE_BREAK_TAG_ID : if ( ! text . isClosingHtmlTag ( ) ) text . linesBefore = <NUM_LIT:1> ; break ; case JAVADOC_BREAK_TAGS_ID : if ( ! text . isClosingHtmlTag ( ) ) text . linesBefore = <NUM_LIT:1> ; } } } void appendNode ( FormatJavadocNode node ) { if ( ++ this . htmlNodesPtr == <NUM_LIT:0> ) { this . htmlNodes = new FormatJavadocNode [ DEFAULT_ARRAY_SIZE ] ; } else { if ( this . htmlNodesPtr == this . htmlNodes . length ) { int size = this . htmlNodesPtr + DEFAULT_ARRAY_SIZE ; System . arraycopy ( this . htmlNodes , <NUM_LIT:0> , ( this . htmlNodes = new FormatJavadocNode [ size ] ) , <NUM_LIT:0> , this . htmlNodesPtr ) ; } } addSeparator ( node ) ; this . htmlNodes [ this . htmlNodesPtr ] = node ; this . sourceEnd = node . sourceEnd ; } private void addSeparator ( FormatJavadocNode node ) { if ( ++ this . separatorsPtr == <NUM_LIT:0> ) { this . separators = new long [ DEFAULT_ARRAY_SIZE ] ; this . htmlIndexes = new int [ DEFAULT_ARRAY_SIZE ] ; } else { if ( this . separatorsPtr == this . separators . length ) { int size = this . separatorsPtr + DEFAULT_ARRAY_SIZE ; System . arraycopy ( this . separators , <NUM_LIT:0> , ( this . separators = new long [ size ] ) , <NUM_LIT:0> , this . separatorsPtr ) ; System . arraycopy ( this . htmlIndexes , <NUM_LIT:0> , ( this . htmlIndexes = new int [ size ] ) , <NUM_LIT:0> , this . separatorsPtr ) ; } } this . separators [ this . separatorsPtr ] = ( ( ( long ) this . sourceEnd ) << <NUM_LIT:32> ) + node . sourceStart ; this . htmlIndexes [ this . separatorsPtr ] = node . isText ( ) ? ( ( FormatJavadocText ) node ) . htmlTagIndex : - <NUM_LIT:1> ; } void clean ( ) { int length = this . separators == null ? <NUM_LIT:0> : this . separators . length ; if ( this . separatorsPtr != ( length - <NUM_LIT:1> ) ) { System . arraycopy ( this . separators , <NUM_LIT:0> , this . separators = new long [ this . separatorsPtr + <NUM_LIT:1> ] , <NUM_LIT:0> , this . separatorsPtr + <NUM_LIT:1> ) ; System . arraycopy ( this . htmlIndexes , <NUM_LIT:0> , this . htmlIndexes = new int [ this . separatorsPtr + <NUM_LIT:1> ] , <NUM_LIT:0> , this . separatorsPtr + <NUM_LIT:1> ) ; } length = this . htmlNodes == null ? <NUM_LIT:0> : this . htmlNodes . length ; if ( this . htmlNodesPtr != ( length - <NUM_LIT:1> ) ) { System . arraycopy ( this . htmlNodes , <NUM_LIT:0> , this . htmlNodes = new FormatJavadocNode [ this . htmlNodesPtr + <NUM_LIT:1> ] , <NUM_LIT:0> , this . htmlNodesPtr + <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> ; i <= this . htmlNodesPtr ; i ++ ) { this . htmlNodes [ i ] . clean ( ) ; } } } void closeTag ( ) { this . htmlTagIndex |= JAVADOC_CLOSED_TAG ; } int getHtmlTagIndex ( ) { return this . htmlTagIndex & JAVADOC_TAGS_INDEX_MASK ; } int getHtmlTagID ( ) { return this . htmlTagIndex & JAVADOC_TAGS_ID_MASK ; } FormatJavadocNode getLastNode ( ) { if ( this . htmlNodes != null ) { return this . htmlNodes [ this . htmlNodesPtr ] ; } return null ; } public boolean isClosingHtmlTag ( ) { return this . htmlTagIndex != - <NUM_LIT:1> && ( this . htmlTagIndex & JAVADOC_CLOSED_TAG ) != <NUM_LIT:0> ; } public boolean isHtmlTag ( ) { return this . htmlTagIndex != - <NUM_LIT:1> ; } public boolean isImmutableHtmlTag ( ) { return this . htmlTagIndex != - <NUM_LIT:1> && ( this . htmlTagIndex & JAVADOC_TAGS_ID_MASK ) == JAVADOC_IMMUTABLE_TAGS_ID ; } public boolean isImmutable ( ) { return this . immutable || ( this . htmlTagIndex != - <NUM_LIT:1> && ( this . htmlTagIndex & JAVADOC_TAGS_ID_MASK ) == JAVADOC_IMMUTABLE_TAGS_ID ) ; } public boolean isTextAfterHtmlSeparatorTag ( int separatorIndex ) { int ptr = separatorIndex ; if ( ptr > this . separatorsPtr ) return false ; int tagIndex = this . htmlIndexes [ ptr ] & JAVADOC_TAGS_ID_MASK ; return tagIndex != - <NUM_LIT:1> && tagIndex == JAVADOC_SEPARATOR_TAGS_ID ; } public boolean isText ( ) { return true ; } void setHeaderLine ( int javadocLineStart ) { for ( int i = <NUM_LIT:0> ; i < this . htmlNodesPtr ; i ++ ) { FormatJavadocNode node = this . htmlNodes [ i ] ; if ( ! node . isText ( ) ) { ( ( FormatJavadocBlock ) node ) . setHeaderLine ( javadocLineStart ) ; } } } protected void toString ( StringBuffer buffer ) { StringBuffer indentation = new StringBuffer ( ) ; for ( int t = <NUM_LIT:0> ; t <= this . depth ; t ++ ) indentation . append ( '<STR_LIT:\t>' ) ; buffer . append ( indentation ) ; if ( isImmutable ( ) ) { buffer . append ( "<STR_LIT>" ) ; } buffer . append ( "<STR_LIT:text>" ) ; super . toString ( buffer ) ; buffer . append ( "<STR_LIT:U+0020(>" ) ; buffer . append ( this . separatorsPtr + <NUM_LIT:1> ) . append ( "<STR_LIT>" ) ; buffer . append ( this . htmlNodesPtr + <NUM_LIT:1> ) . append ( "<STR_LIT>" ) ; buffer . append ( this . depth ) . append ( "<STR_LIT>" ) ; buffer . append ( this . linesBefore ) . append ( "<STR_LIT>" ) ; String tagID = "<STR_LIT>" ; switch ( getHtmlTagID ( ) ) { case JAVADOC_TAGS_ID_MASK : tagID = "<STR_LIT>" ; break ; case JAVADOC_SINGLE_BREAK_TAG_ID : tagID = "<STR_LIT>" ; break ; case JAVADOC_CODE_TAGS_ID : tagID = "<STR_LIT:code>" ; break ; case JAVADOC_BREAK_TAGS_ID : tagID = "<STR_LIT>" ; break ; case JAVADOC_IMMUTABLE_TAGS_ID : tagID = "<STR_LIT>" ; break ; case JAVADOC_SEPARATOR_TAGS_ID : tagID = "<STR_LIT>" ; break ; } buffer . append ( tagID ) . append ( "<STR_LIT>" ) ; buffer . append ( '<STR_LIT:\n>' ) ; } public void toStringDebug ( StringBuffer buffer , char [ ] source ) { if ( buffer . length ( ) > <NUM_LIT:0> ) { for ( int l = <NUM_LIT:0> ; l < this . linesBefore ; l ++ ) { buffer . append ( '<STR_LIT:\n>' ) ; for ( int t = <NUM_LIT:0> ; t < this . depth ; t ++ ) buffer . append ( '<STR_LIT:\t>' ) ; } } if ( this . separatorsPtr == - <NUM_LIT:1> ) { super . toStringDebug ( buffer , source ) ; return ; } int ptr = <NUM_LIT:0> ; int nextStart = this . sourceStart ; int idx = <NUM_LIT:0> ; while ( idx <= this . separatorsPtr || ( this . htmlNodesPtr != - <NUM_LIT:1> && ptr <= this . htmlNodesPtr ) ) { if ( idx > this . separatorsPtr ) { FormatJavadocNode node = this . htmlNodes [ ptr ++ ] ; node . toStringDebug ( buffer , source ) ; return ; } int end = ( int ) ( this . separators [ idx ] > > > <NUM_LIT:32> ) ; if ( this . htmlNodesPtr >= <NUM_LIT:0> && ptr <= this . htmlNodesPtr && end > this . htmlNodes [ ptr ] . sourceStart ) { FormatJavadocNode node = this . htmlNodes [ ptr ++ ] ; node . toStringDebug ( buffer , source ) ; } else { if ( idx > <NUM_LIT:1> && source [ nextStart ] != '<CHAR_LIT>' ) { buffer . append ( '<STR_LIT:\n>' ) ; for ( int t = <NUM_LIT:0> ; t < this . depth ; t ++ ) buffer . append ( '<STR_LIT:\t>' ) ; } buffer . append ( source , nextStart , end - nextStart + <NUM_LIT:1> ) ; } nextStart = ( int ) this . separators [ idx ++ ] ; } if ( source [ nextStart ] == '<CHAR_LIT>' ) { switch ( getHtmlTagID ( ) ) { case JAVADOC_CODE_TAGS_ID : buffer . append ( '<STR_LIT:\n>' ) ; for ( int t = <NUM_LIT:0> ; t < this . depth ; t ++ ) buffer . append ( '<STR_LIT:\t>' ) ; break ; } } buffer . append ( source , nextStart , this . sourceEnd - nextStart + <NUM_LIT:1> ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . formatter . comment . IJavaDocTagConstants ; public class FormatJavadocBlock extends FormatJavadocNode implements IJavaDocTagConstants { final static int INLINED = <NUM_LIT> ; final static int FIRST = <NUM_LIT> ; final static int ON_HEADER_LINE = <NUM_LIT> ; final static int TEXT_ON_TAG_LINE = <NUM_LIT> ; final static int ONE_LINE_TAG = <NUM_LIT> ; final static int PARAM_TAG = <NUM_LIT> ; final static int IN_PARAM_TAG = <NUM_LIT> ; final static int IN_DESCRIPTION = <NUM_LIT> ; final static int IMMUTABLE = <NUM_LIT> ; final static int MAX_TAG_HIERARCHY = <NUM_LIT:10> ; private int tagValue = NO_TAG_VALUE ; int tagEnd ; FormatJavadocReference reference ; FormatJavadocNode [ ] nodes ; int nodesPtr = - <NUM_LIT:1> ; int flags = <NUM_LIT:0> ; public FormatJavadocBlock ( int start , int end , int line , int value ) { super ( start , end , line ) ; this . tagValue = value ; this . tagEnd = end ; switch ( value ) { case TAG_PARAM_VALUE : case TAG_SERIAL_FIELD_VALUE : case TAG_THROWS_VALUE : case TAG_EXCEPTION_VALUE : this . flags |= PARAM_TAG ; break ; case TAG_CODE_VALUE : case TAG_LITERAL_VALUE : this . flags |= IMMUTABLE ; break ; } } private void addNode ( FormatJavadocNode node ) { if ( ++ this . nodesPtr == <NUM_LIT:0> ) { this . nodes = new FormatJavadocNode [ DEFAULT_ARRAY_SIZE ] ; } else if ( this . nodesPtr >= this . nodes . length ) { System . arraycopy ( this . nodes , <NUM_LIT:0> , this . nodes = new FormatJavadocNode [ this . nodes . length + INCREMENT_ARRAY_SIZE ] , <NUM_LIT:0> , this . nodesPtr ) ; } this . nodes [ this . nodesPtr ] = node ; this . sourceEnd = node . sourceEnd ; } void addBlock ( FormatJavadocBlock block , int htmlLevel ) { if ( this . nodes != null ) { FormatJavadocText [ ] textHierarchy = getTextHierarchy ( block , htmlLevel ) ; if ( textHierarchy != null ) { FormatJavadocText lastText = textHierarchy [ htmlLevel ] ; if ( lastText != null ) { lastText . appendNode ( block ) ; for ( int i = htmlLevel - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { textHierarchy [ i ] . sourceEnd = block . sourceEnd ; } this . sourceEnd = block . sourceEnd ; if ( isParamTag ( ) ) { block . flags |= IN_PARAM_TAG ; } else if ( isDescription ( ) ) { block . flags |= IN_DESCRIPTION ; } block . flags |= INLINED ; return ; } } } addNode ( block ) ; if ( isParamTag ( ) ) { block . flags |= IN_PARAM_TAG ; } else if ( isDescription ( ) ) { block . flags |= IN_DESCRIPTION ; } block . flags |= INLINED ; } void addText ( FormatJavadocText text ) { if ( this . nodes != null ) { FormatJavadocText [ ] textHierarchy = getTextHierarchy ( text , text . depth ) ; if ( textHierarchy != null ) { FormatJavadocText lastText = textHierarchy [ text . depth ] ; if ( lastText != null ) { lastText . appendText ( text ) ; for ( int i = text . depth - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { textHierarchy [ i ] . sourceEnd = text . sourceEnd ; } this . sourceEnd = text . sourceEnd ; return ; } if ( text . depth > <NUM_LIT:0> ) { FormatJavadocText parentText = textHierarchy [ text . depth - <NUM_LIT:1> ] ; if ( parentText != null ) { parentText . appendText ( text ) ; for ( int i = text . depth - <NUM_LIT:2> ; i >= <NUM_LIT:0> ; i -- ) { textHierarchy [ i ] . sourceEnd = text . sourceEnd ; } this . sourceEnd = text . sourceEnd ; return ; } } } } if ( text . isHtmlTag ( ) ) { switch ( text . getHtmlTagID ( ) ) { case JAVADOC_CODE_TAGS_ID : text . linesBefore = this . nodesPtr == - <NUM_LIT:1> ? <NUM_LIT:0> : <NUM_LIT:2> ; break ; case JAVADOC_SEPARATOR_TAGS_ID : text . linesBefore = <NUM_LIT:1> ; break ; } } addNode ( text ) ; if ( isImmutable ( ) ) { text . immutable = true ; } } void clean ( ) { int length = this . nodes == null ? <NUM_LIT:0> : this . nodes . length ; if ( this . nodesPtr != ( length - <NUM_LIT:1> ) ) { System . arraycopy ( this . nodes , <NUM_LIT:0> , this . nodes = new FormatJavadocNode [ this . nodesPtr + <NUM_LIT:1> ] , <NUM_LIT:0> , this . nodesPtr + <NUM_LIT:1> ) ; } for ( int i = <NUM_LIT:0> ; i <= this . nodesPtr ; i ++ ) { this . nodes [ i ] . clean ( ) ; } } FormatJavadocNode getLastNode ( ) { if ( this . nodes != null ) { return this . nodes [ this . nodesPtr ] ; } return null ; } FormatJavadocText [ ] getTextHierarchy ( FormatJavadocNode node , int htmlDepth ) { if ( this . nodes == null ) return null ; FormatJavadocText [ ] textHierarchy = null ; int ptr = <NUM_LIT:0> ; FormatJavadocText text = node . isText ( ) ? ( FormatJavadocText ) node : null ; FormatJavadocNode lastNode = this . nodes [ this . nodesPtr ] ; while ( lastNode . isText ( ) ) { FormatJavadocText lastText = ( FormatJavadocText ) lastNode ; int lastTagCategory = lastText . getHtmlTagID ( ) ; boolean lastSingleTag = lastTagCategory <= JAVADOC_SINGLE_TAGS_ID ; boolean lastTextCanHaveChildren = lastText . isHtmlTag ( ) && ! lastText . isClosingHtmlTag ( ) && ! lastSingleTag ; if ( lastText . depth == htmlDepth || lastText . htmlNodesPtr == - <NUM_LIT:1> ) { if ( lastText . isHtmlTag ( ) ) { boolean setLinesBefore = lastText . separatorsPtr == - <NUM_LIT:1> || ( ptr == <NUM_LIT:0> && lastText . isClosingHtmlTag ( ) ) ; if ( ! setLinesBefore && ptr > <NUM_LIT:0> && lastText . isClosingHtmlTag ( ) ) { FormatJavadocText parentText = textHierarchy [ ptr - <NUM_LIT:1> ] ; int textStart = ( int ) parentText . separators [ parentText . separatorsPtr ] ; if ( textStart < lastText . sourceStart ) { setLinesBefore = true ; } } if ( setLinesBefore ) { switch ( lastText . getHtmlTagID ( ) ) { case JAVADOC_CODE_TAGS_ID : if ( node . linesBefore < <NUM_LIT:2> ) { node . linesBefore = <NUM_LIT:2> ; } break ; case JAVADOC_SEPARATOR_TAGS_ID : case JAVADOC_SINGLE_BREAK_TAG_ID : if ( node . linesBefore < <NUM_LIT:1> ) { node . linesBefore = <NUM_LIT:1> ; } } } if ( text != null && text . isHtmlTag ( ) && ! text . isClosingHtmlTag ( ) && text . getHtmlTagIndex ( ) == lastText . getHtmlTagIndex ( ) && ! lastText . isClosingHtmlTag ( ) ) { lastText . closeTag ( ) ; return textHierarchy ; } } if ( lastTextCanHaveChildren || ( htmlDepth == <NUM_LIT:0> && ! lastText . isHtmlTag ( ) && text != null && ! text . isHtmlTag ( ) ) ) { if ( textHierarchy == null ) textHierarchy = new FormatJavadocText [ htmlDepth + <NUM_LIT:1> ] ; textHierarchy [ ptr ] = lastText ; return textHierarchy ; } return textHierarchy ; } if ( textHierarchy == null ) textHierarchy = new FormatJavadocText [ htmlDepth + <NUM_LIT:1> ] ; textHierarchy [ ptr ++ ] = lastText ; lastNode = lastText . htmlNodes [ lastText . htmlNodesPtr ] ; } return textHierarchy ; } public boolean hasTextOnTagLine ( ) { return ( this . flags & TEXT_ON_TAG_LINE ) != <NUM_LIT:0> ; } public boolean isDescription ( ) { return this . tagValue == NO_TAG_VALUE ; } public boolean isFirst ( ) { return ( this . flags & FIRST ) != <NUM_LIT:0> ; } public boolean isHeaderLine ( ) { return ( this . flags & ON_HEADER_LINE ) != <NUM_LIT:0> ; } public boolean isImmutable ( ) { return ( this . flags & IMMUTABLE ) == IMMUTABLE ; } public boolean isInDescription ( ) { return this . tagValue == NO_TAG_VALUE || ( this . flags & IN_DESCRIPTION ) == IN_DESCRIPTION ; } public boolean isInlined ( ) { return ( this . flags & INLINED ) != <NUM_LIT:0> ; } public boolean isInParamTag ( ) { return ( this . flags & ( PARAM_TAG | IN_PARAM_TAG ) ) != <NUM_LIT:0> ; } public boolean isOneLineTag ( ) { return ( this . flags & ONE_LINE_TAG ) != <NUM_LIT:0> ; } public boolean isParamTag ( ) { return ( this . flags & PARAM_TAG ) == PARAM_TAG ; } void setHeaderLine ( int javadocLineStart ) { if ( javadocLineStart == this . lineStart ) { this . flags |= ON_HEADER_LINE ; } for ( int i = <NUM_LIT:0> ; i < this . nodesPtr ; i ++ ) { this . nodes [ i ] . setHeaderLine ( javadocLineStart ) ; } } protected void toString ( StringBuffer buffer ) { boolean inlined = ( this . flags & INLINED ) != <NUM_LIT:0> ; if ( inlined ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( '<CHAR_LIT>' ) ; if ( this . tagValue == TAG_OTHERS_VALUE ) { buffer . append ( "<STR_LIT>" ) ; } else { buffer . append ( TAG_NAMES [ this . tagValue ] ) ; } super . toString ( buffer ) ; if ( this . reference == null ) { buffer . append ( '<STR_LIT:\n>' ) ; } else { buffer . append ( "<STR_LIT:U+0020(>" ) ; this . reference . toString ( buffer ) ; buffer . append ( "<STR_LIT>" ) ; } StringBuffer flagsBuffer = new StringBuffer ( ) ; if ( isDescription ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT:description>" ) ; } if ( isFirst ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( isHeaderLine ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( isImmutable ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( isInDescription ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( isInlined ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( isInParamTag ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( isOneLineTag ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( isParamTag ( ) ) { if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) flagsBuffer . append ( '<CHAR_LIT:U+002C>' ) ; flagsBuffer . append ( "<STR_LIT>" ) ; } if ( flagsBuffer . length ( ) > <NUM_LIT:0> ) { if ( inlined ) buffer . append ( '<STR_LIT:\t>' ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( flagsBuffer ) ; buffer . append ( '<STR_LIT:\n>' ) ; } if ( this . nodesPtr > - <NUM_LIT:1> ) { for ( int i = <NUM_LIT:0> ; i <= this . nodesPtr ; i ++ ) { if ( inlined ) buffer . append ( '<STR_LIT:\t>' ) ; this . nodes [ i ] . toString ( buffer ) ; } } } public String toStringDebug ( char [ ] source ) { StringBuffer buffer = new StringBuffer ( ) ; toStringDebug ( buffer , source ) ; return buffer . toString ( ) ; } public void toStringDebug ( StringBuffer buffer , char [ ] source ) { if ( this . tagValue > <NUM_LIT:0> ) { buffer . append ( source , this . sourceStart , this . tagEnd - this . sourceStart + <NUM_LIT:1> ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; } if ( this . reference != null ) { this . reference . toStringDebug ( buffer , source ) ; } for ( int i = <NUM_LIT:0> ; i <= this . nodesPtr ; i ++ ) { this . nodes [ i ] . toStringDebug ( buffer , source ) ; } } void update ( Scanner scanner ) { int blockEnd = scanner . getLineNumber ( this . sourceEnd ) ; if ( blockEnd == this . lineStart ) { this . flags |= FormatJavadocBlock . ONE_LINE_TAG ; } for ( int i = <NUM_LIT:0> ; i <= this . nodesPtr ; i ++ ) { if ( ! this . nodes [ i ] . isText ( ) ) { ( ( FormatJavadocBlock ) this . nodes [ i ] ) . update ( scanner ) ; } } } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import java . io . IOException ; import java . io . StringReader ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Map ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . core . formatter . CodeFormatter ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . Annotation ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . util . CodeSnippetParsingUtil ; import org . eclipse . jdt . internal . core . util . RecordedParsingInformation ; import org . eclipse . jdt . internal . formatter . align . Alignment ; import org . eclipse . jdt . internal . formatter . align . AlignmentException ; import org . eclipse . jdt . internal . formatter . comment . CommentFormatterUtil ; import org . eclipse . jdt . internal . formatter . comment . HTMLEntity2JavaReader ; import org . eclipse . jdt . internal . formatter . comment . IJavaDocTagConstants ; import org . eclipse . jdt . internal . formatter . comment . Java2HTMLEntityReader ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . DefaultLineTracker ; import org . eclipse . jface . text . ILineTracker ; import org . eclipse . jface . text . IRegion ; import org . eclipse . jface . text . Region ; import org . eclipse . text . edits . MalformedTreeException ; import org . eclipse . text . edits . MultiTextEdit ; import org . eclipse . text . edits . ReplaceEdit ; import org . eclipse . text . edits . TextEdit ; public class Scribe implements IJavaDocTagConstants { private static final int INITIAL_SIZE = <NUM_LIT:100> ; private boolean checkLineWrapping ; public int column ; private int [ ] [ ] commentPositions ; public Alignment currentAlignment ; public int currentToken ; private OptimizedReplaceEdit [ ] edits ; public int editsIndex ; public CodeFormatterVisitor formatter ; public int indentationLevel ; public int lastNumberOfNewLines ; private boolean preserveLineBreakIndentation = false ; public int line ; private int [ ] lineEnds ; private int maxLines ; public Alignment memberAlignment ; public boolean needSpace = false ; final private String lineSeparator ; final private String lineSeparatorAndSpace ; final private char firstLS ; final private int lsLength ; public int nlsTagCounter ; public int pageWidth ; public boolean pendingSpace = false ; public Scanner scanner ; public int scannerEndPosition ; public int tabLength ; public int indentationSize ; private final IRegion [ ] regions ; private IRegion [ ] adaptedRegions ; public int tabChar ; public int numberOfIndentations ; private boolean useTabsOnlyForLeadingIndents ; private final boolean indentEmptyLines ; int blank_lines_between_import_groups = - <NUM_LIT:1> ; public static final int DO_NOT_PRESERVE_EMPTY_LINES = - <NUM_LIT:1> ; public static final int PRESERVE_EMPTY_LINES_KEEP_LAST_NEW_LINES_INDENTATION = <NUM_LIT:1> ; public static final int PRESERVE_EMPTY_LINES_IN_FORMAT_LEFT_CURLY_BRACE = <NUM_LIT:2> ; public static final int PRESERVE_EMPTY_LINES_IN_STRING_LITERAL_CONCATENATION = <NUM_LIT:3> ; public static final int PRESERVE_EMPTY_LINES_IN_CLOSING_ARRAY_INITIALIZER = <NUM_LIT:4> ; public static final int PRESERVE_EMPTY_LINES_IN_FORMAT_OPENING_BRACE = <NUM_LIT:5> ; public static final int PRESERVE_EMPTY_LINES_IN_BINARY_EXPRESSION = <NUM_LIT:6> ; public static final int PRESERVE_EMPTY_LINES_IN_EQUALITY_EXPRESSION = <NUM_LIT:7> ; public static final int PRESERVE_EMPTY_LINES_BEFORE_ELSE = <NUM_LIT:8> ; public static final int PRESERVE_EMPTY_LINES_IN_SWITCH_CASE = <NUM_LIT:9> ; public static final int PRESERVE_EMPTY_LINES_AT_END_OF_METHOD_DECLARATION = <NUM_LIT:10> ; public static final int PRESERVE_EMPTY_LINES_AT_END_OF_BLOCK = <NUM_LIT:11> ; final static int PRESERVE_EMPTY_LINES_DO_NOT_USE_ANY_INDENTATION = - <NUM_LIT:1> ; final static int PRESERVE_EMPTY_LINES_USE_CURRENT_INDENTATION = <NUM_LIT:0> ; final static int PRESERVE_EMPTY_LINES_USE_TEMPORARY_INDENTATION = <NUM_LIT:1> ; boolean editsEnabled ; boolean useTags ; int tagsKind ; private static final int INCLUDE_BLOCK_COMMENTS = CodeFormatter . F_INCLUDE_COMMENTS | CodeFormatter . K_MULTI_LINE_COMMENT ; private static final int INCLUDE_JAVA_DOC = CodeFormatter . F_INCLUDE_COMMENTS | CodeFormatter . K_JAVA_DOC ; private static final int INCLUDE_LINE_COMMENTS = CodeFormatter . F_INCLUDE_COMMENTS | CodeFormatter . K_SINGLE_LINE_COMMENT ; private static final int SKIP_FIRST_WHITESPACE_TOKEN = - <NUM_LIT:2> ; private static final int INVALID_TOKEN = <NUM_LIT> ; static final int NO_TRAILING_COMMENT = <NUM_LIT> ; static final int BASIC_TRAILING_COMMENT = <NUM_LIT> ; static final int COMPLEX_TRAILING_COMMENT = <NUM_LIT> ; static final int IMPORT_TRAILING_COMMENT = COMPLEX_TRAILING_COMMENT | <NUM_LIT> ; static final int UNMODIFIABLE_TRAILING_COMMENT = <NUM_LIT> ; private int formatComments = <NUM_LIT:0> ; private int headerEndPosition = - <NUM_LIT:1> ; String commentIndentation ; static class LineComment { boolean contiguous = false ; int currentIndentation , indentation ; int lines ; char [ ] leadingSpaces ; } final LineComment lastLineComment = new LineComment ( ) ; private FormatterCommentParser formatterCommentParser ; OptimizedReplaceEdit previousDisabledEdit ; private char [ ] disablingTag , enablingTag ; private String [ ] newEmptyLines = new String [ <NUM_LIT:10> ] ; private static String [ ] COMMENT_INDENTATIONS = new String [ <NUM_LIT:20> ] ; private final StringBuffer tempBuffer = new StringBuffer ( ) ; private final StringBuffer blockCommentBuffer = new StringBuffer ( ) ; private final StringBuffer blockCommentTokensBuffer = new StringBuffer ( ) ; private final StringBuffer codeSnippetBuffer = new StringBuffer ( ) ; private final StringBuffer javadocBlockRefBuffer = new StringBuffer ( ) ; private final StringBuffer javadocGapLinesBuffer = new StringBuffer ( ) ; private StringBuffer [ ] javadocHtmlTagBuffers = new StringBuffer [ <NUM_LIT:5> ] ; private final StringBuffer javadocTextBuffer = new StringBuffer ( ) ; private final StringBuffer javadocTokensBuffer = new StringBuffer ( ) ; Scribe ( CodeFormatterVisitor formatter , long sourceLevel , IRegion [ ] regions , CodeSnippetParsingUtil codeSnippetParsingUtil , boolean includeComments ) { initializeScanner ( sourceLevel , formatter . preferences ) ; this . formatter = formatter ; this . pageWidth = formatter . preferences . page_width ; this . tabLength = formatter . preferences . tab_size ; this . indentationLevel = <NUM_LIT:0> ; this . numberOfIndentations = <NUM_LIT:0> ; this . useTabsOnlyForLeadingIndents = formatter . preferences . use_tabs_only_for_leading_indentations ; this . indentEmptyLines = formatter . preferences . indent_empty_lines ; this . tabChar = formatter . preferences . tab_char ; if ( this . tabChar == DefaultCodeFormatterOptions . MIXED ) { this . indentationSize = formatter . preferences . indentation_size ; } else { this . indentationSize = this . tabLength ; } this . lineSeparator = formatter . preferences . line_separator ; this . lineSeparatorAndSpace = this . lineSeparator + '<CHAR_LIT:U+0020>' ; this . firstLS = this . lineSeparator . charAt ( <NUM_LIT:0> ) ; this . lsLength = this . lineSeparator . length ( ) ; this . indentationLevel = formatter . preferences . initial_indentation_level * this . indentationSize ; this . regions = regions ; if ( codeSnippetParsingUtil != null ) { final RecordedParsingInformation information = codeSnippetParsingUtil . recordedParsingInformation ; if ( information != null ) { this . lineEnds = information . lineEnds ; this . commentPositions = information . commentPositions ; } } if ( formatter . preferences . comment_format_line_comment ) this . formatComments |= CodeFormatter . K_SINGLE_LINE_COMMENT ; if ( formatter . preferences . comment_format_block_comment ) this . formatComments |= CodeFormatter . K_MULTI_LINE_COMMENT ; if ( formatter . preferences . comment_format_javadoc_comment ) this . formatComments |= CodeFormatter . K_JAVA_DOC ; if ( includeComments ) this . formatComments |= CodeFormatter . F_INCLUDE_COMMENTS ; reset ( ) ; } private void adaptRegions ( ) { int max = this . regions . length ; if ( max == <NUM_LIT:1> ) { if ( this . regions [ <NUM_LIT:0> ] . getOffset ( ) == <NUM_LIT:0> && this . regions [ <NUM_LIT:0> ] . getLength ( ) == this . scannerEndPosition ) { this . adaptedRegions = this . regions ; return ; } } this . adaptedRegions = new IRegion [ max ] ; int commentIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { IRegion aRegion = this . regions [ i ] ; int offset = aRegion . getOffset ( ) ; int length = aRegion . getLength ( ) ; int index = getCommentIndex ( commentIndex , offset ) ; int adaptedOffset = offset ; int adaptedLength = length ; if ( index >= <NUM_LIT:0> ) { adaptedOffset = this . commentPositions [ index ] [ <NUM_LIT:0> ] ; if ( adaptedOffset >= <NUM_LIT:0> ) { adaptedLength = length + offset - adaptedOffset ; commentIndex = index ; } } index = getCommentIndex ( commentIndex , offset + length - <NUM_LIT:1> ) ; if ( index >= <NUM_LIT:0> && this . commentPositions [ index ] [ <NUM_LIT:0> ] >= <NUM_LIT:0> ) { int commentEnd = this . commentPositions [ index ] [ <NUM_LIT:1> ] ; if ( commentEnd < <NUM_LIT:0> ) commentEnd = - commentEnd ; adaptedLength = commentEnd - adaptedOffset ; commentIndex = index ; } if ( adaptedLength != length ) { this . adaptedRegions [ i ] = new Region ( adaptedOffset , adaptedLength ) ; } else { this . adaptedRegions [ i ] = aRegion ; } } } private void adaptEdits ( ) { int max = this . regions . length ; if ( max == <NUM_LIT:1> ) { if ( this . regions [ <NUM_LIT:0> ] . getOffset ( ) == <NUM_LIT:0> && this . regions [ <NUM_LIT:0> ] . getLength ( ) == this . scannerEndPosition ) { return ; } } OptimizedReplaceEdit [ ] sortedEdits = new OptimizedReplaceEdit [ this . editsIndex ] ; System . arraycopy ( this . edits , <NUM_LIT:0> , sortedEdits , <NUM_LIT:0> , this . editsIndex ) ; Arrays . sort ( sortedEdits , new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { OptimizedReplaceEdit edit1 = ( OptimizedReplaceEdit ) o1 ; OptimizedReplaceEdit edit2 = ( OptimizedReplaceEdit ) o2 ; return edit1 . offset - edit2 . offset ; } } ) ; int currentEdit = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { IRegion region = this . adaptedRegions [ i ] ; int offset = region . getOffset ( ) ; int length = region . getLength ( ) ; int index = adaptEdit ( sortedEdits , currentEdit , offset , offset + length ) ; if ( index != - <NUM_LIT:1> ) { currentEdit = index ; } } if ( currentEdit != - <NUM_LIT:1> ) { int length = sortedEdits . length ; for ( int e = currentEdit ; e < length ; e ++ ) { sortedEdits [ e ] . offset = - <NUM_LIT:1> ; } } } private int adaptEdit ( OptimizedReplaceEdit [ ] sortedEdits , int start , int regionStart , int regionEnd ) { int initialStart = start == - <NUM_LIT:1> ? <NUM_LIT:0> : start ; int bottom = initialStart , top = sortedEdits . length - <NUM_LIT:1> ; int topEnd = top ; int i = <NUM_LIT:0> ; OptimizedReplaceEdit edit = null ; int overlapIndex = - <NUM_LIT:1> ; while ( bottom <= top ) { i = bottom + ( top - bottom ) / <NUM_LIT:2> ; edit = sortedEdits [ i ] ; int editStart = edit . offset ; int editEnd = editStart + edit . length ; if ( editStart > regionStart ) { top = i - <NUM_LIT:1> ; if ( editStart > regionEnd ) { topEnd = top ; } } else { if ( editEnd < regionStart ) { bottom = i + <NUM_LIT:1> ; } else { int linesOutside = <NUM_LIT:0> ; StringBuffer spacesOutside = new StringBuffer ( ) ; this . scanner . resetTo ( editStart , editEnd - <NUM_LIT:1> ) ; while ( this . scanner . currentPosition < regionStart && ! this . scanner . atEnd ( ) ) { char ch = ( char ) this . scanner . getNextChar ( ) ; switch ( ch ) { case '<STR_LIT:\n>' : linesOutside ++ ; spacesOutside . setLength ( <NUM_LIT:0> ) ; break ; case '<STR_LIT>' : break ; default : spacesOutside . append ( ch ) ; break ; } } edit . offset = regionStart ; int editLength = edit . length ; edit . length -= edit . offset - editStart ; int length = edit . replacement . length ( ) ; if ( length > <NUM_LIT:0> ) { int linesReplaced = <NUM_LIT:0> ; for ( int idx = <NUM_LIT:0> ; idx < length ; idx ++ ) { if ( edit . replacement . charAt ( idx ) == '<STR_LIT:\n>' ) linesReplaced ++ ; } if ( editLength > <NUM_LIT:0> && edit . length == <NUM_LIT:0> && editEnd == regionStart && linesReplaced == <NUM_LIT:0> && linesOutside == <NUM_LIT:0> ) { edit . offset = - <NUM_LIT:1> ; } else { if ( linesReplaced > <NUM_LIT:0> ) { int linesCount = linesOutside >= linesReplaced ? linesReplaced : linesOutside ; if ( linesCount > <NUM_LIT:0> ) { int idx = <NUM_LIT:0> ; loop : while ( idx < length ) { char ch = edit . replacement . charAt ( idx ) ; switch ( ch ) { case '<STR_LIT:\n>' : linesCount -- ; if ( linesCount == <NUM_LIT:0> ) { idx ++ ; break loop ; } break ; case '<STR_LIT>' : case '<CHAR_LIT:U+0020>' : case '<STR_LIT:\t>' : break ; default : break loop ; } idx ++ ; } int spacesOutsideLength = spacesOutside . length ( ) ; int replacementStart = idx ; for ( int o = <NUM_LIT:0> , r = <NUM_LIT:0> ; o < spacesOutsideLength && r < ( length - idx ) ; o ++ ) { char rch = edit . replacement . charAt ( idx + r ) ; char och = spacesOutside . charAt ( o ) ; if ( rch == och ) { replacementStart ++ ; r ++ ; } else if ( rch == '<STR_LIT:\t>' && ( this . tabLength > <NUM_LIT:0> && och == '<CHAR_LIT:U+0020>' ) ) { if ( ( o + <NUM_LIT:1> ) % this . tabLength == <NUM_LIT:0> ) { replacementStart ++ ; r ++ ; } } else { break ; } } if ( replacementStart > length || ( replacementStart == length && spacesOutsideLength > <NUM_LIT:0> ) ) { edit . offset = - <NUM_LIT:1> ; } else if ( spacesOutsideLength == <NUM_LIT:0> && replacementStart == length ) { edit . replacement = "<STR_LIT>" ; } else { edit . replacement = edit . replacement . substring ( replacementStart ) ; } } } } } overlapIndex = i ; break ; } } } int validIndex = ( overlapIndex != - <NUM_LIT:1> ) ? overlapIndex : bottom ; if ( overlapIndex != - <NUM_LIT:1> ) bottom = overlapIndex ; while ( bottom <= topEnd ) { i = bottom + ( topEnd - bottom ) / <NUM_LIT:2> ; edit = sortedEdits [ i ] ; int editStart = edit . offset ; int editEnd = editStart + edit . length ; if ( regionEnd < editStart ) { topEnd = i - <NUM_LIT:1> ; } else if ( regionEnd == editStart ) { topEnd = i - <NUM_LIT:1> ; if ( edit . length == <NUM_LIT:0> ) { int nrLength = <NUM_LIT:0> ; int rLength = edit . replacement . length ( ) ; if ( nrLength < rLength ) { int ch = edit . replacement . charAt ( nrLength ) ; loop : while ( nrLength < rLength ) { switch ( ch ) { case '<CHAR_LIT:U+0020>' : case '<STR_LIT:\t>' : nrLength ++ ; break ; default : break loop ; } } } if ( nrLength > <NUM_LIT:0> ) { topEnd ++ ; if ( nrLength < rLength ) { edit . replacement = edit . replacement . substring ( <NUM_LIT:0> , nrLength ) ; } } } break ; } else if ( editEnd <= regionEnd ) { bottom = i + <NUM_LIT:1> ; } else { int linesOutside = <NUM_LIT:0> ; this . scanner . resetTo ( editStart , editEnd - <NUM_LIT:1> ) ; while ( ! this . scanner . atEnd ( ) ) { boolean after = this . scanner . currentPosition >= regionEnd ; char ch = ( char ) this . scanner . getNextChar ( ) ; if ( ch == '<STR_LIT:\n>' ) { if ( after ) linesOutside ++ ; } } int length = edit . replacement . length ( ) ; if ( length > <NUM_LIT:0> ) { int linesReplaced = <NUM_LIT:0> ; for ( int idx = <NUM_LIT:0> ; idx < length ; idx ++ ) { if ( edit . replacement . charAt ( idx ) == '<STR_LIT:\n>' ) linesReplaced ++ ; } if ( linesReplaced == <NUM_LIT:0> ) { edit . replacement = "<STR_LIT>" ; } else { int linesCount = linesReplaced > linesOutside ? linesReplaced - linesOutside : <NUM_LIT:0> ; if ( linesCount == <NUM_LIT:0> ) { edit . replacement = "<STR_LIT>" ; } else { edit . replacement = getNewLineString ( linesCount ) ; } } } edit . length = regionEnd - editStart ; topEnd = i ; break ; } } for ( int e = initialStart ; e < validIndex ; e ++ ) { sortedEdits [ e ] . offset = - <NUM_LIT:1> ; } return topEnd + <NUM_LIT:1> ; } private final void addDeleteEdit ( int start , int end ) { if ( this . edits . length == this . editsIndex ) { resize ( ) ; } addOptimizedReplaceEdit ( start , end - start + <NUM_LIT:1> , Util . EMPTY_STRING ) ; } public final void addInsertEdit ( int insertPosition , String insertedString ) { if ( this . edits . length == this . editsIndex ) { resize ( ) ; } addOptimizedReplaceEdit ( insertPosition , <NUM_LIT:0> , insertedString ) ; } private final void addOptimizedReplaceEdit ( int offset , int length , String replacement ) { if ( ! this . editsEnabled ) { if ( this . previousDisabledEdit != null && this . previousDisabledEdit . offset == offset ) { replacement = this . previousDisabledEdit . replacement ; } this . previousDisabledEdit = null ; if ( replacement . indexOf ( this . lineSeparator ) >= <NUM_LIT:0> ) { if ( length == <NUM_LIT:0> || printNewLinesCharacters ( offset , length ) ) { this . previousDisabledEdit = new OptimizedReplaceEdit ( offset , length , replacement ) ; } } return ; } if ( this . editsIndex > <NUM_LIT:0> ) { final OptimizedReplaceEdit previous = this . edits [ this . editsIndex - <NUM_LIT:1> ] ; final int previousOffset = previous . offset ; final int previousLength = previous . length ; final int endOffsetOfPreviousEdit = previousOffset + previousLength ; final int replacementLength = replacement . length ( ) ; final String previousReplacement = previous . replacement ; final int previousReplacementLength = previousReplacement . length ( ) ; if ( previousOffset == offset && previousLength == length && ( replacementLength == <NUM_LIT:0> || previousReplacementLength == <NUM_LIT:0> ) ) { if ( this . currentAlignment != null ) { final Location location = this . currentAlignment . location ; if ( location . editsIndex == this . editsIndex ) { location . editsIndex -- ; location . textEdit = previous ; } } this . editsIndex -- ; return ; } if ( endOffsetOfPreviousEdit == offset ) { if ( length != <NUM_LIT:0> ) { if ( replacementLength != <NUM_LIT:0> ) { this . edits [ this . editsIndex - <NUM_LIT:1> ] = new OptimizedReplaceEdit ( previousOffset , previousLength + length , previousReplacement + replacement ) ; } else if ( previousLength + length == previousReplacementLength ) { boolean canBeRemoved = true ; loop : for ( int i = previousOffset ; i < previousOffset + previousReplacementLength ; i ++ ) { if ( this . scanner . source [ i ] != previousReplacement . charAt ( i - previousOffset ) ) { this . edits [ this . editsIndex - <NUM_LIT:1> ] = new OptimizedReplaceEdit ( previousOffset , previousReplacementLength , previousReplacement ) ; canBeRemoved = false ; break loop ; } } if ( canBeRemoved ) { if ( this . currentAlignment != null ) { final Location location = this . currentAlignment . location ; if ( location . editsIndex == this . editsIndex ) { location . editsIndex -- ; location . textEdit = previous ; } } this . editsIndex -- ; } } else { this . edits [ this . editsIndex - <NUM_LIT:1> ] = new OptimizedReplaceEdit ( previousOffset , previousLength + length , previousReplacement ) ; } } else { if ( replacementLength != <NUM_LIT:0> ) { this . edits [ this . editsIndex - <NUM_LIT:1> ] = new OptimizedReplaceEdit ( previousOffset , previousLength , previousReplacement + replacement ) ; } } } else if ( ( offset + length == previousOffset ) && ( previousLength + length == replacementLength + previousReplacementLength ) ) { boolean canBeRemoved = true ; String totalReplacement = replacement + previousReplacement ; loop : for ( int i = <NUM_LIT:0> ; i < previousLength + length ; i ++ ) { if ( this . scanner . source [ i + offset ] != totalReplacement . charAt ( i ) ) { this . edits [ this . editsIndex - <NUM_LIT:1> ] = new OptimizedReplaceEdit ( offset , previousLength + length , totalReplacement ) ; canBeRemoved = false ; break loop ; } } if ( canBeRemoved ) { if ( this . currentAlignment != null ) { final Location location = this . currentAlignment . location ; if ( location . editsIndex == this . editsIndex ) { location . editsIndex -- ; location . textEdit = previous ; } } this . editsIndex -- ; } } else { this . edits [ this . editsIndex ++ ] = new OptimizedReplaceEdit ( offset , length , replacement ) ; } } else { this . edits [ this . editsIndex ++ ] = new OptimizedReplaceEdit ( offset , length , replacement ) ; } } public final void addReplaceEdit ( int start , int end , String replacement ) { if ( this . edits . length == this . editsIndex ) { resize ( ) ; } addOptimizedReplaceEdit ( start , end - start + <NUM_LIT:1> , replacement ) ; } public void alignFragment ( Alignment alignment , int fragmentIndex ) { alignment . fragmentIndex = fragmentIndex ; alignment . checkColumn ( ) ; alignment . performFragmentEffect ( ) ; } public void checkNLSTag ( int sourceStart ) { if ( hasNLSTag ( sourceStart ) ) { this . nlsTagCounter ++ ; } } private int consumeInvalidToken ( int end ) { this . scanner . resetTo ( this . scanner . startPosition , end ) ; if ( this . scanner . currentCharacter == '<STR_LIT:\\>' ) { this . scanner . currentPosition = this . scanner . startPosition + <NUM_LIT:1> ; } int previousPosition = this . scanner . currentPosition ; char ch = ( char ) this . scanner . getNextChar ( ) ; if ( this . scanner . atEnd ( ) ) { return INVALID_TOKEN ; } while ( ! this . scanner . atEnd ( ) && ch != '<CHAR_LIT>' && ! ScannerHelper . isWhitespace ( ch ) ) { previousPosition = this . scanner . currentPosition ; ch = ( char ) this . scanner . getNextChar ( ) ; } this . scanner . currentPosition = previousPosition ; return INVALID_TOKEN ; } public Alignment createAlignment ( int kind , int mode , int count , int sourceRestart ) { return createAlignment ( kind , mode , Alignment . R_INNERMOST , count , sourceRestart ) ; } public Alignment createAlignment ( int kind , int mode , int tieBreakRule , int count , int sourceRestart ) { return createAlignment ( kind , mode , tieBreakRule , count , sourceRestart , this . formatter . preferences . continuation_indentation , false ) ; } public Alignment createAlignment ( int kind , int mode , int count , int sourceRestart , int continuationIndent , boolean adjust ) { return createAlignment ( kind , mode , Alignment . R_INNERMOST , count , sourceRestart , continuationIndent , adjust ) ; } public Alignment createAlignment ( int kind , int mode , int tieBreakRule , int count , int sourceRestart , int continuationIndent , boolean adjust ) { Alignment alignment = new Alignment ( kind , mode , tieBreakRule , this , count , sourceRestart , continuationIndent ) ; if ( ( this . currentAlignment == null && this . formatter . expressionsDepth >= <NUM_LIT:0> ) || ( this . currentAlignment != null && this . currentAlignment . kind == Alignment . BINARY_EXPRESSION && ( this . formatter . expressionsPos & CodeFormatterVisitor . EXPRESSIONS_POS_MASK ) == CodeFormatterVisitor . EXPRESSIONS_POS_BETWEEN_TWO ) ) { switch ( kind ) { case Alignment . CONDITIONAL_EXPRESSION : case Alignment . MESSAGE_ARGUMENTS : case Alignment . MESSAGE_SEND : if ( this . formatter . lastBinaryExpressionAlignmentBreakIndentation == alignment . breakIndentationLevel ) { alignment . breakIndentationLevel += this . indentationSize ; alignment . shiftBreakIndentationLevel += this . indentationSize ; this . formatter . lastBinaryExpressionAlignmentBreakIndentation = <NUM_LIT:0> ; } break ; } } if ( adjust && this . memberAlignment != null ) { Alignment current = this . memberAlignment ; while ( current . enclosing != null ) { current = current . enclosing ; } if ( ( current . mode & Alignment . M_MULTICOLUMN ) != <NUM_LIT:0> ) { final int indentSize = this . indentationSize ; switch ( current . chunkKind ) { case Alignment . CHUNK_METHOD : case Alignment . CHUNK_TYPE : if ( ( mode & Alignment . M_INDENT_BY_ONE ) != <NUM_LIT:0> ) { alignment . breakIndentationLevel = this . indentationLevel + indentSize ; } else { alignment . breakIndentationLevel = this . indentationLevel + continuationIndent * indentSize ; } alignment . update ( ) ; break ; case Alignment . CHUNK_FIELD : if ( ( mode & Alignment . M_INDENT_BY_ONE ) != <NUM_LIT:0> ) { alignment . breakIndentationLevel = current . originalIndentationLevel + indentSize ; } else { alignment . breakIndentationLevel = current . originalIndentationLevel + continuationIndent * indentSize ; } alignment . update ( ) ; break ; } } else { switch ( current . mode & Alignment . SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_COMPACT_FIRST_BREAK_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : case Alignment . M_NEXT_SHIFTED_SPLIT : case Alignment . M_ONE_PER_LINE_SPLIT : final int indentSize = this . indentationSize ; switch ( current . chunkKind ) { case Alignment . CHUNK_METHOD : case Alignment . CHUNK_TYPE : if ( ( mode & Alignment . M_INDENT_BY_ONE ) != <NUM_LIT:0> ) { alignment . breakIndentationLevel = this . indentationLevel + indentSize ; } else { alignment . breakIndentationLevel = this . indentationLevel + continuationIndent * indentSize ; } alignment . update ( ) ; break ; case Alignment . CHUNK_FIELD : if ( ( mode & Alignment . M_INDENT_BY_ONE ) != <NUM_LIT:0> ) { alignment . breakIndentationLevel = current . originalIndentationLevel + indentSize ; } else { alignment . breakIndentationLevel = current . originalIndentationLevel + continuationIndent * indentSize ; } alignment . update ( ) ; break ; } break ; } } } return alignment ; } public Alignment createMemberAlignment ( int kind , int mode , int count , int sourceRestart ) { Alignment mAlignment = createAlignment ( kind , mode , Alignment . R_INNERMOST , count , sourceRestart ) ; mAlignment . breakIndentationLevel = this . indentationLevel ; return mAlignment ; } public void enterAlignment ( Alignment alignment ) { alignment . enclosing = this . currentAlignment ; alignment . location . lastLocalDeclarationSourceStart = this . formatter . lastLocalDeclarationSourceStart ; this . currentAlignment = alignment ; } public void enterMemberAlignment ( Alignment alignment ) { alignment . enclosing = this . memberAlignment ; alignment . location . lastLocalDeclarationSourceStart = this . formatter . lastLocalDeclarationSourceStart ; this . memberAlignment = alignment ; } public void exitAlignment ( Alignment alignment , boolean discardAlignment ) { Alignment current = this . currentAlignment ; while ( current != null ) { if ( current == alignment ) break ; current = current . enclosing ; } if ( current == null ) { throw new AbortFormatting ( "<STR_LIT>" + alignment ) ; } this . indentationLevel = alignment . location . outputIndentationLevel ; this . numberOfIndentations = alignment . location . numberOfIndentations ; this . formatter . lastLocalDeclarationSourceStart = alignment . location . lastLocalDeclarationSourceStart ; if ( discardAlignment ) { this . currentAlignment = alignment . enclosing ; if ( this . currentAlignment == null ) { this . formatter . lastBinaryExpressionAlignmentBreakIndentation = <NUM_LIT:0> ; } } } public void exitMemberAlignment ( Alignment alignment ) { Alignment current = this . memberAlignment ; while ( current != null ) { if ( current == alignment ) break ; current = current . enclosing ; } if ( current == null ) { throw new AbortFormatting ( "<STR_LIT>" + alignment ) ; } this . indentationLevel = current . location . outputIndentationLevel ; this . numberOfIndentations = current . location . numberOfIndentations ; this . formatter . lastLocalDeclarationSourceStart = alignment . location . lastLocalDeclarationSourceStart ; this . memberAlignment = current . enclosing ; } public int getColumnIndentationLevel ( ) { return this . column - <NUM_LIT:1> ; } public final int getCommentIndex ( int position ) { if ( this . commentPositions == null ) return - <NUM_LIT:1> ; int length = this . commentPositions . length ; if ( length == <NUM_LIT:0> ) { return - <NUM_LIT:1> ; } int g = <NUM_LIT:0> , d = length - <NUM_LIT:1> ; int m = <NUM_LIT:0> ; while ( g <= d ) { m = g + ( d - g ) / <NUM_LIT:2> ; int bound = this . commentPositions [ m ] [ <NUM_LIT:1> ] ; if ( bound < <NUM_LIT:0> ) { bound = - bound ; } if ( bound < position ) { g = m + <NUM_LIT:1> ; } else if ( bound > position ) { d = m - <NUM_LIT:1> ; } else { return m ; } } return - ( g + <NUM_LIT:1> ) ; } private int getCommentIndex ( int start , int position ) { int commentsLength = this . commentPositions == null ? <NUM_LIT:0> : this . commentPositions . length ; if ( commentsLength == <NUM_LIT:0> ) return - <NUM_LIT:1> ; if ( position == <NUM_LIT:0> ) { if ( commentsLength > <NUM_LIT:0> && this . commentPositions [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == <NUM_LIT:0> ) { return <NUM_LIT:0> ; } return - <NUM_LIT:1> ; } int bottom = start , top = commentsLength - <NUM_LIT:1> ; int i = <NUM_LIT:0> ; int [ ] comment = null ; while ( bottom <= top ) { i = bottom + ( top - bottom ) / <NUM_LIT:2> ; comment = this . commentPositions [ i ] ; int commentStart = comment [ <NUM_LIT:0> ] ; if ( commentStart < <NUM_LIT:0> ) commentStart = - commentStart ; if ( position < commentStart ) { top = i - <NUM_LIT:1> ; } else { int commentEnd = comment [ <NUM_LIT:1> ] ; if ( commentEnd < <NUM_LIT:0> ) commentEnd = - commentEnd ; if ( position >= commentEnd ) { bottom = i + <NUM_LIT:1> ; } else { return i ; } } } return - <NUM_LIT:1> ; } private int getCurrentCommentIndentation ( int start ) { int linePtr = - Arrays . binarySearch ( this . lineEnds , start ) ; int indentation = <NUM_LIT:0> ; int beginningOfLine = getLineEnd ( linePtr - <NUM_LIT:1> ) + <NUM_LIT:1> ; if ( beginningOfLine == - <NUM_LIT:1> ) { beginningOfLine = <NUM_LIT:0> ; } int currentStartPosition = start ; char [ ] source = this . scanner . source ; while ( beginningOfLine > currentStartPosition ) { if ( linePtr > <NUM_LIT:0> ) { beginningOfLine = getLineEnd ( -- linePtr ) + <NUM_LIT:1> ; } else { beginningOfLine = <NUM_LIT:0> ; break ; } } for ( int i = beginningOfLine ; i < currentStartPosition ; i ++ ) { char currentCharacter = source [ i ] ; switch ( currentCharacter ) { case '<STR_LIT:\t>' : if ( this . tabLength != <NUM_LIT:0> ) { int reminder = indentation % this . tabLength ; if ( reminder == <NUM_LIT:0> ) { indentation += this . tabLength ; } else { indentation = ( ( indentation / this . tabLength ) + <NUM_LIT:1> ) * this . tabLength ; } } break ; case '<STR_LIT>' : case '<STR_LIT:\n>' : indentation = <NUM_LIT:0> ; break ; default : indentation ++ ; break ; } } return indentation ; } int getCurrentIndentation ( char [ ] whitespaces , int offset ) { if ( whitespaces == null ) return offset ; int length = whitespaces . length ; if ( this . tabLength == <NUM_LIT:0> ) return length ; int indentation = offset ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char ch = whitespaces [ i ] ; switch ( ch ) { case '<STR_LIT:\t>' : int reminder = indentation % this . tabLength ; if ( reminder == <NUM_LIT:0> ) { indentation += this . tabLength ; } else { indentation = ( ( indentation / this . tabLength ) + <NUM_LIT:1> ) * this . tabLength ; } break ; case '<STR_LIT>' : case '<STR_LIT:\n>' : indentation = <NUM_LIT:0> ; break ; default : indentation ++ ; break ; } } return indentation ; } int getCurrentIndentation ( int start ) { int linePtr = Arrays . binarySearch ( this . lineEnds , start ) ; if ( linePtr < <NUM_LIT:0> ) { linePtr = - linePtr - <NUM_LIT:1> ; } int indentation = <NUM_LIT:0> ; int beginningOfLine = getLineEnd ( linePtr ) + <NUM_LIT:1> ; if ( beginningOfLine == - <NUM_LIT:1> ) { beginningOfLine = <NUM_LIT:0> ; } char [ ] source = this . scanner . source ; for ( int i = beginningOfLine ; i < start ; i ++ ) { char currentCharacter = source [ i ] ; switch ( currentCharacter ) { case '<STR_LIT:\t>' : if ( this . tabLength != <NUM_LIT:0> ) { int reminder = indentation % this . tabLength ; if ( reminder == <NUM_LIT:0> ) { indentation += this . tabLength ; } else { indentation = ( ( indentation / this . tabLength ) + <NUM_LIT:1> ) * this . tabLength ; } } break ; case '<STR_LIT>' : case '<STR_LIT:\n>' : indentation = <NUM_LIT:0> ; break ; case '<CHAR_LIT:U+0020>' : indentation ++ ; break ; default : return indentation ; } } return indentation ; } public String getEmptyLines ( int linesNumber ) { if ( this . nlsTagCounter > <NUM_LIT:0> ) { return Util . EMPTY_STRING ; } String emptyLines ; if ( this . lastNumberOfNewLines == <NUM_LIT:0> ) { linesNumber ++ ; if ( this . indentEmptyLines ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; for ( int i = <NUM_LIT:0> ; i < linesNumber ; i ++ ) { printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; } emptyLines = this . tempBuffer . toString ( ) ; } else { emptyLines = getNewLineString ( linesNumber ) ; } this . lastNumberOfNewLines += linesNumber ; this . line += linesNumber ; this . column = <NUM_LIT:1> ; this . needSpace = false ; this . pendingSpace = false ; } else if ( this . lastNumberOfNewLines == <NUM_LIT:1> ) { if ( this . indentEmptyLines ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; for ( int i = <NUM_LIT:0> ; i < linesNumber ; i ++ ) { printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; } emptyLines = this . tempBuffer . toString ( ) ; } else { emptyLines = getNewLineString ( linesNumber ) ; } this . lastNumberOfNewLines += linesNumber ; this . line += linesNumber ; this . column = <NUM_LIT:1> ; this . needSpace = false ; this . pendingSpace = false ; } else { if ( ( this . lastNumberOfNewLines - <NUM_LIT:1> ) >= linesNumber ) { return Util . EMPTY_STRING ; } final int realNewLineNumber = linesNumber - this . lastNumberOfNewLines + <NUM_LIT:1> ; if ( this . indentEmptyLines ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; for ( int i = <NUM_LIT:0> ; i < realNewLineNumber ; i ++ ) { printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; } emptyLines = this . tempBuffer . toString ( ) ; } else { emptyLines = getNewLineString ( realNewLineNumber ) ; } this . lastNumberOfNewLines += realNewLineNumber ; this . line += realNewLineNumber ; this . column = <NUM_LIT:1> ; this . needSpace = false ; this . pendingSpace = false ; } return emptyLines ; } public OptimizedReplaceEdit getLastEdit ( ) { if ( this . editsIndex > <NUM_LIT:0> ) { return this . edits [ this . editsIndex - <NUM_LIT:1> ] ; } return null ; } public final int getLineEnd ( int lineNumber ) { if ( this . lineEnds == null ) return - <NUM_LIT:1> ; if ( lineNumber >= this . lineEnds . length + <NUM_LIT:1> ) return this . scannerEndPosition ; if ( lineNumber <= <NUM_LIT:0> ) return - <NUM_LIT:1> ; return this . lineEnds [ lineNumber - <NUM_LIT:1> ] ; } Alignment getMemberAlignment ( ) { return this . memberAlignment ; } public String getNewLine ( ) { if ( this . nlsTagCounter > <NUM_LIT:0> ) { return Util . EMPTY_STRING ; } if ( this . lastNumberOfNewLines >= <NUM_LIT:1> ) { this . column = <NUM_LIT:1> ; return Util . EMPTY_STRING ; } this . line ++ ; this . lastNumberOfNewLines = <NUM_LIT:1> ; this . column = <NUM_LIT:1> ; this . needSpace = false ; this . pendingSpace = false ; return this . lineSeparator ; } private String getNewLineString ( int linesCount ) { int length = this . newEmptyLines . length ; if ( linesCount > length ) { System . arraycopy ( this . newEmptyLines , <NUM_LIT:0> , this . newEmptyLines = new String [ linesCount + <NUM_LIT:10> ] , <NUM_LIT:0> , length ) ; } String newLineString = this . newEmptyLines [ linesCount - <NUM_LIT:1> ] ; if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; for ( int j = <NUM_LIT:0> ; j < linesCount ; j ++ ) { this . tempBuffer . append ( this . lineSeparator ) ; } newLineString = this . tempBuffer . toString ( ) ; this . newEmptyLines [ linesCount - <NUM_LIT:1> ] = newLineString ; } return newLineString ; } public int getNextIndentationLevel ( int someColumn ) { int indent = someColumn - <NUM_LIT:1> ; if ( indent == <NUM_LIT:0> ) return this . indentationLevel ; if ( this . tabChar == DefaultCodeFormatterOptions . TAB ) { if ( this . useTabsOnlyForLeadingIndents ) { return indent ; } if ( this . indentationSize == <NUM_LIT:0> ) { return indent ; } int rem = indent % this . indentationSize ; int addition = rem == <NUM_LIT:0> ? <NUM_LIT:0> : this . indentationSize - rem ; return indent + addition ; } return indent ; } private String getPreserveEmptyLines ( int count , int emptyLinesRules ) { if ( count == <NUM_LIT:0> ) { int currentIndentationLevel = this . indentationLevel ; int useAlignmentBreakIndentation = useAlignmentBreakIndentation ( emptyLinesRules ) ; switch ( useAlignmentBreakIndentation ) { case PRESERVE_EMPTY_LINES_DO_NOT_USE_ANY_INDENTATION : return Util . EMPTY_STRING ; default : StringBuffer buffer = new StringBuffer ( getNewLine ( ) ) ; printIndentationIfNecessary ( buffer ) ; if ( useAlignmentBreakIndentation == PRESERVE_EMPTY_LINES_USE_TEMPORARY_INDENTATION ) { this . indentationLevel = currentIndentationLevel ; } return buffer . toString ( ) ; } } if ( this . blank_lines_between_import_groups >= <NUM_LIT:0> ) { useAlignmentBreakIndentation ( emptyLinesRules ) ; return getEmptyLines ( this . blank_lines_between_import_groups ) ; } if ( this . formatter . preferences . number_of_empty_lines_to_preserve != <NUM_LIT:0> ) { useAlignmentBreakIndentation ( emptyLinesRules ) ; int linesToPreserve = Math . min ( count , this . formatter . preferences . number_of_empty_lines_to_preserve ) ; return getEmptyLines ( linesToPreserve ) ; } return getNewLine ( ) ; } private int useAlignmentBreakIndentation ( int emptyLinesRules ) { boolean specificEmptyLinesRule = emptyLinesRules != PRESERVE_EMPTY_LINES_KEEP_LAST_NEW_LINES_INDENTATION ; if ( ( this . currentAlignment != null || specificEmptyLinesRule ) && ! this . formatter . preferences . join_wrapped_lines ) { if ( this . lastNumberOfNewLines == <NUM_LIT:0> || specificEmptyLinesRule || this . formatter . arrayInitializersDepth >= <NUM_LIT:0> ) { boolean useAlignmentBreakIndentation ; boolean useAlignmentShiftBreakIndentation = false ; boolean useLastBinaryExpressionAlignmentBreakIndentation = false ; switch ( emptyLinesRules ) { case DO_NOT_PRESERVE_EMPTY_LINES : case PRESERVE_EMPTY_LINES_IN_SWITCH_CASE : case PRESERVE_EMPTY_LINES_AT_END_OF_METHOD_DECLARATION : case PRESERVE_EMPTY_LINES_AT_END_OF_BLOCK : return PRESERVE_EMPTY_LINES_DO_NOT_USE_ANY_INDENTATION ; case PRESERVE_EMPTY_LINES_IN_BINARY_EXPRESSION : useAlignmentBreakIndentation = true ; if ( ( this . formatter . expressionsPos & CodeFormatterVisitor . EXPRESSIONS_POS_MASK ) == CodeFormatterVisitor . EXPRESSIONS_POS_BETWEEN_TWO ) { useLastBinaryExpressionAlignmentBreakIndentation = true ; } break ; case PRESERVE_EMPTY_LINES_IN_EQUALITY_EXPRESSION : useAlignmentShiftBreakIndentation = this . currentAlignment == null || this . currentAlignment . kind == Alignment . BINARY_EXPRESSION ; useAlignmentBreakIndentation = ! useAlignmentShiftBreakIndentation ; break ; case PRESERVE_EMPTY_LINES_IN_FORMAT_OPENING_BRACE : useAlignmentBreakIndentation = this . formatter . arrayInitializersDepth <= <NUM_LIT:1> && this . currentAlignment != null && this . currentAlignment . kind == Alignment . ARRAY_INITIALIZER ; break ; case PRESERVE_EMPTY_LINES_IN_FORMAT_LEFT_CURLY_BRACE : useAlignmentBreakIndentation = false ; break ; default : if ( ( emptyLinesRules & <NUM_LIT> ) == PRESERVE_EMPTY_LINES_IN_CLOSING_ARRAY_INITIALIZER && this . scanner . currentCharacter == '<CHAR_LIT:}>' ) { this . indentationLevel = emptyLinesRules > > <NUM_LIT:16> ; this . preserveLineBreakIndentation = true ; return PRESERVE_EMPTY_LINES_USE_CURRENT_INDENTATION ; } useAlignmentBreakIndentation = true ; break ; } Alignment alignment = this . currentAlignment ; if ( alignment == null ) { if ( useLastBinaryExpressionAlignmentBreakIndentation ) { if ( this . indentationLevel < this . formatter . lastBinaryExpressionAlignmentBreakIndentation ) { this . indentationLevel = this . formatter . lastBinaryExpressionAlignmentBreakIndentation ; } } if ( useAlignmentShiftBreakIndentation && this . memberAlignment != null ) { if ( this . indentationLevel < this . memberAlignment . shiftBreakIndentationLevel ) { this . indentationLevel = this . memberAlignment . shiftBreakIndentationLevel ; } } } else { if ( this . memberAlignment != null && this . memberAlignment . location . inputOffset > alignment . location . inputOffset ) { alignment = this . memberAlignment ; } if ( useLastBinaryExpressionAlignmentBreakIndentation ) { if ( this . indentationLevel < this . formatter . lastBinaryExpressionAlignmentBreakIndentation ) { this . indentationLevel = this . formatter . lastBinaryExpressionAlignmentBreakIndentation ; } } if ( useAlignmentBreakIndentation ) { if ( this . indentationLevel < alignment . breakIndentationLevel ) { this . indentationLevel = alignment . breakIndentationLevel ; } } else if ( useAlignmentShiftBreakIndentation ) { if ( this . indentationLevel < alignment . shiftBreakIndentationLevel ) { this . indentationLevel = alignment . shiftBreakIndentationLevel ; } } } this . preserveLineBreakIndentation = true ; if ( useLastBinaryExpressionAlignmentBreakIndentation || useAlignmentShiftBreakIndentation ) { return PRESERVE_EMPTY_LINES_USE_TEMPORARY_INDENTATION ; } return PRESERVE_EMPTY_LINES_USE_CURRENT_INDENTATION ; } } return PRESERVE_EMPTY_LINES_DO_NOT_USE_ANY_INDENTATION ; } public TextEdit getRootEdit ( ) { adaptRegions ( ) ; adaptEdits ( ) ; MultiTextEdit edit = null ; int regionsLength = this . adaptedRegions . length ; int textRegionStart ; int textRegionEnd ; if ( regionsLength == <NUM_LIT:1> ) { IRegion lastRegion = this . adaptedRegions [ <NUM_LIT:0> ] ; textRegionStart = lastRegion . getOffset ( ) ; textRegionEnd = textRegionStart + lastRegion . getLength ( ) ; } else { textRegionStart = this . adaptedRegions [ <NUM_LIT:0> ] . getOffset ( ) ; IRegion lastRegion = this . adaptedRegions [ regionsLength - <NUM_LIT:1> ] ; textRegionEnd = lastRegion . getOffset ( ) + lastRegion . getLength ( ) ; } int length = textRegionEnd - textRegionStart + <NUM_LIT:1> ; if ( textRegionStart <= <NUM_LIT:0> ) { if ( length <= <NUM_LIT:0> ) { edit = new MultiTextEdit ( <NUM_LIT:0> , <NUM_LIT:0> ) ; } else { edit = new MultiTextEdit ( <NUM_LIT:0> , textRegionEnd ) ; } } else { edit = new MultiTextEdit ( textRegionStart , length - <NUM_LIT:1> ) ; } for ( int i = <NUM_LIT:0> , max = this . editsIndex ; i < max ; i ++ ) { OptimizedReplaceEdit currentEdit = this . edits [ i ] ; if ( currentEdit . offset >= <NUM_LIT:0> && currentEdit . offset <= this . scannerEndPosition ) { if ( currentEdit . length == <NUM_LIT:0> || ( currentEdit . offset != this . scannerEndPosition && isMeaningfulEdit ( currentEdit ) ) ) { try { edit . addChild ( new ReplaceEdit ( currentEdit . offset , currentEdit . length , currentEdit . replacement ) ) ; } catch ( MalformedTreeException ex ) { CommentFormatterUtil . log ( ex ) ; throw ex ; } } } } this . edits = null ; return edit ; } public void handleLineTooLong ( ) { if ( this . formatter . preferences . wrap_outer_expressions_when_nested ) { handleLineTooLongSmartly ( ) ; return ; } int relativeDepth = <NUM_LIT:0> , outerMostDepth = - <NUM_LIT:1> ; Alignment targetAlignment = this . currentAlignment ; while ( targetAlignment != null ) { if ( targetAlignment . tieBreakRule == Alignment . R_OUTERMOST && targetAlignment . couldBreak ( ) ) { outerMostDepth = relativeDepth ; } targetAlignment = targetAlignment . enclosing ; relativeDepth ++ ; } if ( outerMostDepth >= <NUM_LIT:0> ) { throw new AlignmentException ( AlignmentException . LINE_TOO_LONG , outerMostDepth ) ; } relativeDepth = <NUM_LIT:0> ; targetAlignment = this . currentAlignment ; while ( targetAlignment != null ) { if ( targetAlignment . couldBreak ( ) ) { throw new AlignmentException ( AlignmentException . LINE_TOO_LONG , relativeDepth ) ; } targetAlignment = targetAlignment . enclosing ; relativeDepth ++ ; } } private void handleLineTooLongSmartly ( ) { int relativeDepth = <NUM_LIT:0> , outerMostDepth = - <NUM_LIT:1> ; Alignment targetAlignment = this . currentAlignment ; int previousKind = - <NUM_LIT:1> ; int insideMessage = <NUM_LIT:0> ; boolean insideStringConcat = false ; while ( targetAlignment != null ) { boolean couldBreak = targetAlignment . tieBreakRule == Alignment . R_OUTERMOST || ( ! insideStringConcat && insideMessage > <NUM_LIT:0> && targetAlignment . kind == Alignment . MESSAGE_ARGUMENTS && ( ! targetAlignment . wasReset ( ) || previousKind != Alignment . MESSAGE_SEND ) ) ; if ( couldBreak && targetAlignment . couldBreak ( ) ) { outerMostDepth = relativeDepth ; } switch ( targetAlignment . kind ) { case Alignment . MESSAGE_ARGUMENTS : case Alignment . MESSAGE_SEND : insideMessage ++ ; break ; case Alignment . STRING_CONCATENATION : insideStringConcat = true ; break ; } previousKind = targetAlignment . kind ; targetAlignment = targetAlignment . enclosing ; relativeDepth ++ ; } if ( outerMostDepth >= <NUM_LIT:0> ) { throw new AlignmentException ( AlignmentException . LINE_TOO_LONG , outerMostDepth ) ; } relativeDepth = <NUM_LIT:0> ; targetAlignment = this . currentAlignment ; AlignmentException alignmentException = null ; int msgArgsDepth = - <NUM_LIT:1> ; while ( targetAlignment != null ) { if ( targetAlignment . kind == Alignment . MESSAGE_ARGUMENTS ) { msgArgsDepth = relativeDepth ; } if ( alignmentException == null ) { if ( targetAlignment . couldBreak ( ) ) { alignmentException = new AlignmentException ( AlignmentException . LINE_TOO_LONG , relativeDepth ) ; if ( insideStringConcat ) throw alignmentException ; } } else if ( targetAlignment . wasSplit ) { if ( ! targetAlignment . wasReset ( ) ) { targetAlignment . reset ( ) ; if ( msgArgsDepth > alignmentException . relativeDepth ) { alignmentException . relativeDepth = msgArgsDepth ; } throw alignmentException ; } } targetAlignment = targetAlignment . enclosing ; relativeDepth ++ ; } if ( alignmentException != null ) { throw alignmentException ; } if ( this . currentAlignment != null ) { this . currentAlignment . blockAlign = false ; this . currentAlignment . tooLong = true ; } } private boolean hasNLSTag ( int sourceStart ) { if ( this . lineEnds == null ) return false ; int index = Arrays . binarySearch ( this . lineEnds , sourceStart ) ; int currentLineEnd = getLineEnd ( - index ) ; if ( currentLineEnd != - <NUM_LIT:1> ) { int commentIndex = getCommentIndex ( currentLineEnd ) ; if ( commentIndex < <NUM_LIT:0> ) { commentIndex = - commentIndex - <NUM_LIT:2> ; } if ( commentIndex >= <NUM_LIT:0> && commentIndex < this . commentPositions . length ) { int start = this . commentPositions [ commentIndex ] [ <NUM_LIT:0> ] ; if ( start < <NUM_LIT:0> ) { start = - start ; int lineIndexForComment = Arrays . binarySearch ( this . lineEnds , start ) ; if ( lineIndexForComment == index ) { return CharOperation . indexOf ( Scanner . TAG_PREFIX , this . scanner . source , true , start , currentLineEnd ) != - <NUM_LIT:1> ; } } } } return false ; } private boolean includesBlockComments ( ) { return ( ( this . formatComments & INCLUDE_BLOCK_COMMENTS ) == INCLUDE_BLOCK_COMMENTS && this . headerEndPosition < this . scanner . currentPosition ) || ( this . formatter . preferences . comment_format_header && this . headerEndPosition >= this . scanner . currentPosition ) ; } private boolean includesJavadocComments ( ) { return ( ( this . formatComments & INCLUDE_JAVA_DOC ) == INCLUDE_JAVA_DOC && this . headerEndPosition < this . scanner . currentPosition ) || ( this . formatter . preferences . comment_format_header && this . headerEndPosition >= this . scanner . currentPosition ) ; } private boolean includesLineComments ( ) { return ( ( this . formatComments & INCLUDE_LINE_COMMENTS ) == INCLUDE_LINE_COMMENTS && this . headerEndPosition < this . scanner . currentPosition ) || ( this . formatter . preferences . comment_format_header && this . headerEndPosition >= this . scanner . currentPosition ) ; } boolean includesComments ( ) { return ( this . formatComments & CodeFormatter . F_INCLUDE_COMMENTS ) != <NUM_LIT:0> ; } public void indent ( ) { this . indentationLevel += this . indentationSize ; this . numberOfIndentations ++ ; } void setIndentation ( int level , int n ) { this . indentationLevel = level + n * this . indentationSize ; this . numberOfIndentations = this . indentationLevel / this . indentationSize ; } private void initializeScanner ( long sourceLevel , DefaultCodeFormatterOptions preferences ) { this . useTags = preferences . use_tags ; this . tagsKind = <NUM_LIT:0> ; char [ ] [ ] taskTags = null ; if ( this . useTags ) { this . disablingTag = preferences . disabling_tag ; this . enablingTag = preferences . enabling_tag ; if ( this . disablingTag == null ) { if ( this . enablingTag != null ) { taskTags = new char [ ] [ ] { this . enablingTag } ; } } else if ( this . enablingTag == null ) { taskTags = new char [ ] [ ] { this . disablingTag } ; } else { taskTags = new char [ ] [ ] { this . disablingTag , this . enablingTag } ; } } if ( taskTags != null ) { loop : for ( int i = <NUM_LIT:0> , length = taskTags . length ; i < length ; i ++ ) { if ( taskTags [ i ] . length > <NUM_LIT:2> && taskTags [ i ] [ <NUM_LIT:0> ] == '<CHAR_LIT:/>' ) { switch ( taskTags [ i ] [ <NUM_LIT:1> ] ) { case '<CHAR_LIT:/>' : this . tagsKind = TerminalTokens . TokenNameCOMMENT_LINE ; break loop ; case '<CHAR_LIT>' : if ( taskTags [ i ] [ <NUM_LIT:2> ] != '<CHAR_LIT>' ) { this . tagsKind = TerminalTokens . TokenNameCOMMENT_BLOCK ; break loop ; } break ; } } } } this . scanner = new Scanner ( true , true , false , sourceLevel , taskTags , null , true ) ; this . editsEnabled = true ; } private void initFormatterCommentParser ( ) { if ( this . formatterCommentParser == null ) { this . formatterCommentParser = new FormatterCommentParser ( this . scanner . sourceLevel ) ; } this . formatterCommentParser . scanner . setSource ( this . scanner . source ) ; this . formatterCommentParser . source = this . scanner . source ; this . formatterCommentParser . scanner . lineEnds = this . lineEnds ; this . formatterCommentParser . scanner . linePtr = this . maxLines ; this . formatterCommentParser . parseHtmlTags = this . formatter . preferences . comment_format_html ; } private boolean isOnFirstColumn ( int start ) { if ( this . lineEnds == null ) return start == <NUM_LIT:0> ; int index = Arrays . binarySearch ( this . lineEnds , start ) ; int previousLineEnd = getLineEnd ( - index - <NUM_LIT:1> ) ; return previousLineEnd != - <NUM_LIT:1> && previousLineEnd == start - <NUM_LIT:1> ; } private boolean isMeaningfulEdit ( OptimizedReplaceEdit edit ) { final int editLength = edit . length ; final int editReplacementLength = edit . replacement . length ( ) ; final int editOffset = edit . offset ; if ( editReplacementLength != <NUM_LIT:0> && editLength == editReplacementLength ) { for ( int i = editOffset , max = editOffset + editLength ; i < max ; i ++ ) { if ( this . scanner . source [ i ] != edit . replacement . charAt ( i - editOffset ) ) { return true ; } } return false ; } return true ; } private void preserveEmptyLines ( int count , int insertPosition ) { if ( count > <NUM_LIT:0> ) { if ( this . blank_lines_between_import_groups >= <NUM_LIT:0> ) { printEmptyLines ( this . blank_lines_between_import_groups , insertPosition ) ; } else if ( this . formatter . preferences . number_of_empty_lines_to_preserve != <NUM_LIT:0> ) { int linesToPreserve = Math . min ( count , this . formatter . preferences . number_of_empty_lines_to_preserve ) ; printEmptyLines ( linesToPreserve , insertPosition ) ; } else { printNewLine ( insertPosition ) ; } } } private void print ( int length , boolean considerSpaceIfAny ) { if ( this . checkLineWrapping && length + this . column > this . pageWidth ) { handleLineTooLong ( ) ; } this . lastNumberOfNewLines = <NUM_LIT:0> ; if ( this . indentationLevel != <NUM_LIT:0> ) { printIndentationIfNecessary ( ) ; } if ( considerSpaceIfAny ) { space ( ) ; } if ( this . pendingSpace ) { addInsertEdit ( this . scanner . getCurrentTokenStartPosition ( ) , "<STR_LIT:U+0020>" ) ; } this . pendingSpace = false ; this . column += length ; this . needSpace = true ; } private void printBlockComment ( boolean isJavadoc ) { int currentTokenStartPosition = this . scanner . getCurrentTokenStartPosition ( ) ; int currentTokenEndPosition = this . scanner . getCurrentTokenEndPosition ( ) + <NUM_LIT:1> ; boolean includesBlockComments = ! isJavadoc && includesBlockComments ( ) ; this . scanner . resetTo ( currentTokenStartPosition , currentTokenEndPosition - <NUM_LIT:1> ) ; int currentCharacter ; boolean isNewLine = false ; int start = currentTokenStartPosition ; int nextCharacterStart = currentTokenStartPosition ; int previousStart = currentTokenStartPosition ; boolean onFirstColumn = isOnFirstColumn ( start ) ; boolean indentComment = false ; if ( this . indentationLevel != <NUM_LIT:0> ) { if ( isJavadoc || ! this . formatter . preferences . never_indent_block_comments_on_first_column || ! onFirstColumn ) { indentComment = true ; printIndentationIfNecessary ( ) ; } } if ( this . pendingSpace ) { addInsertEdit ( currentTokenStartPosition , "<STR_LIT:U+0020>" ) ; } this . needSpace = false ; this . pendingSpace = false ; int commentColumn = this . column ; if ( includesBlockComments ) { if ( printBlockComment ( currentTokenStartPosition , currentTokenEndPosition ) ) { return ; } } int currentIndentationLevel = this . indentationLevel ; if ( ( commentColumn - <NUM_LIT:1> ) > this . indentationLevel ) { this . indentationLevel = commentColumn - <NUM_LIT:1> ; } int currentCommentIndentation = onFirstColumn ? <NUM_LIT:0> : getCurrentCommentIndentation ( start ) ; boolean formatComment = ( isJavadoc && ( this . formatComments & CodeFormatter . K_JAVA_DOC ) != <NUM_LIT:0> ) || ( ! isJavadoc && ( this . formatComments & CodeFormatter . K_MULTI_LINE_COMMENT ) != <NUM_LIT:0> ) ; try { while ( nextCharacterStart <= currentTokenEndPosition && ( currentCharacter = this . scanner . getNextChar ( ) ) != - <NUM_LIT:1> ) { nextCharacterStart = this . scanner . currentPosition ; switch ( currentCharacter ) { case '<STR_LIT>' : start = previousStart ; isNewLine = true ; if ( this . scanner . getNextChar ( '<STR_LIT:\n>' ) ) { currentCharacter = '<STR_LIT:\n>' ; nextCharacterStart = this . scanner . currentPosition ; } break ; case '<STR_LIT:\n>' : start = previousStart ; isNewLine = true ; nextCharacterStart = this . scanner . currentPosition ; break ; default : if ( isNewLine ) { this . column = <NUM_LIT:1> ; this . line ++ ; isNewLine = false ; boolean addSpace = false ; if ( onFirstColumn ) { if ( formatComment ) { if ( ScannerHelper . isWhitespace ( ( char ) currentCharacter ) ) { int previousStartPosition = this . scanner . currentPosition ; while ( currentCharacter != - <NUM_LIT:1> && currentCharacter != '<STR_LIT>' && currentCharacter != '<STR_LIT:\n>' && ScannerHelper . isWhitespace ( ( char ) currentCharacter ) ) { previousStart = nextCharacterStart ; previousStartPosition = this . scanner . currentPosition ; currentCharacter = this . scanner . getNextChar ( ) ; nextCharacterStart = this . scanner . currentPosition ; } if ( currentCharacter == '<STR_LIT>' || currentCharacter == '<STR_LIT:\n>' ) { nextCharacterStart = previousStartPosition ; } } if ( currentCharacter != '<STR_LIT>' && currentCharacter != '<STR_LIT:\n>' ) { addSpace = true ; } } } else { if ( ScannerHelper . isWhitespace ( ( char ) currentCharacter ) ) { int previousStartPosition = this . scanner . currentPosition ; int currentIndentation = <NUM_LIT:0> ; loop : while ( currentCharacter != - <NUM_LIT:1> && currentCharacter != '<STR_LIT>' && currentCharacter != '<STR_LIT:\n>' && ScannerHelper . isWhitespace ( ( char ) currentCharacter ) ) { if ( currentIndentation >= currentCommentIndentation ) { break loop ; } previousStart = nextCharacterStart ; previousStartPosition = this . scanner . currentPosition ; switch ( currentCharacter ) { case '<STR_LIT:\t>' : if ( this . tabLength != <NUM_LIT:0> ) { int reminder = currentIndentation % this . tabLength ; if ( reminder == <NUM_LIT:0> ) { currentIndentation += this . tabLength ; } else { currentIndentation = ( ( currentIndentation / this . tabLength ) + <NUM_LIT:1> ) * this . tabLength ; } } break ; default : currentIndentation ++ ; } currentCharacter = this . scanner . getNextChar ( ) ; nextCharacterStart = this . scanner . currentPosition ; } if ( currentCharacter == '<STR_LIT>' || currentCharacter == '<STR_LIT:\n>' ) { nextCharacterStart = previousStartPosition ; } } if ( formatComment ) { int previousStartTemp = previousStart ; int nextCharacterStartTemp = nextCharacterStart ; while ( currentCharacter != - <NUM_LIT:1> && currentCharacter != '<STR_LIT>' && currentCharacter != '<STR_LIT:\n>' && ScannerHelper . isWhitespace ( ( char ) currentCharacter ) ) { previousStart = nextCharacterStart ; currentCharacter = this . scanner . getNextChar ( ) ; nextCharacterStart = this . scanner . currentPosition ; } if ( currentCharacter == '<CHAR_LIT>' ) { addSpace = true ; } else { previousStart = previousStartTemp ; nextCharacterStart = nextCharacterStartTemp ; } this . scanner . currentPosition = nextCharacterStart ; } } String replacement ; if ( indentComment ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . tempBuffer . append ( this . lineSeparator ) ; if ( this . indentationLevel > <NUM_LIT:0> ) { printIndentationIfNecessary ( this . tempBuffer ) ; } if ( addSpace ) { this . tempBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } replacement = this . tempBuffer . toString ( ) ; } else { replacement = addSpace ? this . lineSeparatorAndSpace : this . lineSeparator ; } addReplaceEdit ( start , previousStart - <NUM_LIT:1> , replacement ) ; } else { this . column += ( nextCharacterStart - previousStart ) ; } } previousStart = nextCharacterStart ; this . scanner . currentPosition = nextCharacterStart ; } } finally { this . indentationLevel = currentIndentationLevel ; } this . lastNumberOfNewLines = <NUM_LIT:0> ; this . needSpace = false ; this . scanner . resetTo ( currentTokenEndPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; } private boolean printBlockComment ( int currentTokenStartPosition , int currentTokenEndPosition ) { int maxColumn = this . formatter . preferences . comment_line_length + <NUM_LIT:1> ; int indentLevel = this . indentationLevel ; int indentations = this . numberOfIndentations ; switch ( this . tabChar ) { case DefaultCodeFormatterOptions . TAB : switch ( this . tabLength ) { case <NUM_LIT:0> : this . indentationLevel = <NUM_LIT:0> ; this . column = <NUM_LIT:1> ; this . numberOfIndentations = <NUM_LIT:0> ; break ; case <NUM_LIT:1> : this . indentationLevel = this . column - <NUM_LIT:1> ; this . numberOfIndentations = this . indentationLevel ; break ; default : this . indentationLevel = ( this . column / this . tabLength ) * this . tabLength ; this . column = this . indentationLevel + <NUM_LIT:1> ; this . numberOfIndentations = this . indentationLevel / this . tabLength ; } break ; case DefaultCodeFormatterOptions . MIXED : if ( this . tabLength == <NUM_LIT:0> ) { this . indentationLevel = <NUM_LIT:0> ; this . column = <NUM_LIT:1> ; this . numberOfIndentations = <NUM_LIT:0> ; } else { this . indentationLevel = this . column - <NUM_LIT:1> ; this . numberOfIndentations = this . indentationLevel / this . tabLength ; } break ; case DefaultCodeFormatterOptions . SPACE : if ( this . indentationSize == <NUM_LIT:0> ) { this . indentationLevel = <NUM_LIT:0> ; this . column = <NUM_LIT:1> ; this . numberOfIndentations = <NUM_LIT:0> ; } else { this . indentationLevel = this . column - <NUM_LIT:1> ; } break ; } this . blockCommentBuffer . setLength ( <NUM_LIT:0> ) ; this . scanner . getNextChar ( ) ; this . scanner . getNextChar ( ) ; this . column += <NUM_LIT:2> ; this . scanner . skipComments = true ; this . blockCommentTokensBuffer . setLength ( <NUM_LIT:0> ) ; int editStart = this . scanner . currentPosition ; int editEnd = - <NUM_LIT:1> ; int previousToken = - <NUM_LIT:1> ; boolean newLine = false ; boolean multiLines = false ; boolean hasMultiLines = false ; boolean hasTokens = false ; boolean bufferHasTokens = false ; boolean bufferHasNewLine = false ; boolean lineHasTokens = false ; int hasTextOnFirstLine = <NUM_LIT:0> ; boolean firstWord = true ; boolean clearBlankLines = this . formatter . preferences . comment_clear_blank_lines_in_block_comment ; boolean joinLines = this . formatter . preferences . join_lines_in_comments ; boolean newLinesAtBoundaries = this . formatter . preferences . comment_new_lines_at_block_boundaries ; int scannerLine = Util . getLineNumber ( this . scanner . currentPosition , this . lineEnds , <NUM_LIT:0> , this . maxLines ) ; int firstLine = scannerLine ; int lineNumber = scannerLine ; int lastTextLine = - <NUM_LIT:1> ; while ( ! this . scanner . atEnd ( ) ) { int token ; try { token = this . scanner . getNextToken ( ) ; } catch ( InvalidInputException iie ) { token = consumeInvalidToken ( currentTokenEndPosition - <NUM_LIT:1> ) ; newLine = false ; } boolean insertSpace = ( previousToken == TerminalTokens . TokenNameWHITESPACE ) && ( ! firstWord || ! hasTokens ) ; boolean isTokenStar = false ; switch ( token ) { case TerminalTokens . TokenNameWHITESPACE : if ( this . blockCommentTokensBuffer . length ( ) > <NUM_LIT:0> ) { if ( hasTextOnFirstLine == <NUM_LIT:1> && multiLines ) { printBlockCommentHeaderLine ( this . blockCommentBuffer ) ; hasTextOnFirstLine = - <NUM_LIT:1> ; } this . blockCommentBuffer . append ( this . blockCommentTokensBuffer ) ; this . column += this . blockCommentTokensBuffer . length ( ) ; this . blockCommentTokensBuffer . setLength ( <NUM_LIT:0> ) ; bufferHasTokens = true ; bufferHasNewLine = false ; } if ( previousToken == - <NUM_LIT:1> ) { previousToken = SKIP_FIRST_WHITESPACE_TOKEN ; } else { previousToken = token ; } lineNumber = Util . getLineNumber ( this . scanner . currentPosition , this . lineEnds , scannerLine > <NUM_LIT:1> ? scannerLine - <NUM_LIT:2> : <NUM_LIT:0> , this . maxLines ) ; if ( lineNumber > scannerLine ) { hasMultiLines = true ; newLine = true ; } scannerLine = lineNumber ; continue ; case TerminalTokens . TokenNameMULTIPLY : isTokenStar = true ; lineNumber = Util . getLineNumber ( this . scanner . currentPosition , this . lineEnds , scannerLine > <NUM_LIT:1> ? scannerLine - <NUM_LIT:2> : <NUM_LIT:0> , this . maxLines ) ; if ( lineNumber == firstLine && previousToken == SKIP_FIRST_WHITESPACE_TOKEN ) { this . blockCommentBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } previousToken = token ; if ( this . scanner . currentCharacter == '<CHAR_LIT:/>' ) { editEnd = this . scanner . startPosition - <NUM_LIT:1> ; if ( this . blockCommentTokensBuffer . length ( ) > <NUM_LIT:0> ) { this . blockCommentBuffer . append ( this . blockCommentTokensBuffer ) ; this . column += this . blockCommentTokensBuffer . length ( ) ; } if ( newLinesAtBoundaries ) { if ( multiLines || hasMultiLines ) { this . blockCommentBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . blockCommentBuffer ) ; } } this . blockCommentBuffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column += BLOCK_FOOTER_LENGTH + <NUM_LIT:1> ; this . scanner . getNextChar ( ) ; continue ; } if ( newLine ) { scannerLine = lineNumber ; newLine = false ; continue ; } break ; case TerminalTokens . TokenNameMULTIPLY_EQUAL : if ( newLine ) { this . scanner . resetTo ( this . scanner . startPosition , currentTokenEndPosition - <NUM_LIT:1> ) ; this . scanner . getNextChar ( ) ; previousToken = TerminalTokens . TokenNameMULTIPLY ; scannerLine = Util . getLineNumber ( this . scanner . currentPosition , this . lineEnds , scannerLine > <NUM_LIT:1> ? scannerLine - <NUM_LIT:2> : <NUM_LIT:0> , this . maxLines ) ; continue ; } break ; case TerminalTokens . TokenNameMINUS : case TerminalTokens . TokenNameMINUS_MINUS : if ( previousToken == - <NUM_LIT:1> ) { this . indentationLevel = indentLevel ; this . numberOfIndentations = indentations ; this . lastNumberOfNewLines = <NUM_LIT:0> ; this . needSpace = false ; this . scanner . skipComments = false ; this . scanner . resetTo ( currentTokenStartPosition , currentTokenEndPosition - <NUM_LIT:1> ) ; return false ; } break ; default : break ; } int linesGap ; int max ; lineNumber = Util . getLineNumber ( this . scanner . currentPosition , this . lineEnds , scannerLine > <NUM_LIT:1> ? scannerLine - <NUM_LIT:2> : <NUM_LIT:0> , this . maxLines ) ; if ( lastTextLine == - <NUM_LIT:1> ) { linesGap = newLinesAtBoundaries ? lineNumber - firstLine : <NUM_LIT:0> ; max = <NUM_LIT:0> ; } else { linesGap = lineNumber - lastTextLine ; if ( token == TerminalTokens . TokenNameAT && linesGap == <NUM_LIT:1> ) { linesGap = <NUM_LIT:2> ; } max = joinLines && lineHasTokens ? <NUM_LIT:1> : <NUM_LIT:0> ; } if ( linesGap > max ) { if ( clearBlankLines ) { if ( token == TerminalTokens . TokenNameAT ) { linesGap = <NUM_LIT:1> ; } else { linesGap = ( max == <NUM_LIT:0> || ! joinLines ) ? <NUM_LIT:1> : <NUM_LIT:0> ; } } for ( int i = <NUM_LIT:0> ; i < linesGap ; i ++ ) { if ( this . blockCommentTokensBuffer . length ( ) > <NUM_LIT:0> ) { if ( hasTextOnFirstLine == <NUM_LIT:1> ) { printBlockCommentHeaderLine ( this . blockCommentBuffer ) ; hasTextOnFirstLine = - <NUM_LIT:1> ; } this . blockCommentBuffer . append ( this . blockCommentTokensBuffer ) ; this . blockCommentTokensBuffer . setLength ( <NUM_LIT:0> ) ; bufferHasTokens = true ; } this . blockCommentBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . blockCommentBuffer ) ; this . blockCommentBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; firstWord = true ; multiLines = true ; bufferHasNewLine = true ; } insertSpace = insertSpace && linesGap == <NUM_LIT:0> ; } if ( newLine ) lineHasTokens = false ; int tokenStart = this . scanner . getCurrentTokenStartPosition ( ) ; int tokenLength = ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - tokenStart ; hasTokens = true ; if ( ! isTokenStar ) lineHasTokens = true ; if ( hasTextOnFirstLine == <NUM_LIT:0> && ! isTokenStar ) { if ( firstLine == lineNumber ) { hasTextOnFirstLine = <NUM_LIT:1> ; this . column ++ ; } else { hasTextOnFirstLine = - <NUM_LIT:1> ; } } int lastColumn = this . column + this . blockCommentTokensBuffer . length ( ) + tokenLength ; if ( insertSpace ) lastColumn ++ ; if ( lineHasTokens && ! firstWord && lastColumn > maxColumn ) { String tokensString = this . blockCommentTokensBuffer . toString ( ) . trim ( ) ; int tokensStringLength = tokensString . length ( ) ; if ( hasTextOnFirstLine == <NUM_LIT:1> ) { printBlockCommentHeaderLine ( this . blockCommentBuffer ) ; } if ( ( this . indentationLevel + tokensStringLength + tokenLength ) > maxColumn ) { this . blockCommentBuffer . append ( this . blockCommentTokensBuffer ) ; this . column += this . blockCommentTokensBuffer . length ( ) ; this . blockCommentTokensBuffer . setLength ( <NUM_LIT:0> ) ; bufferHasNewLine = false ; bufferHasTokens = true ; } if ( bufferHasTokens && ! bufferHasNewLine ) { this . blockCommentBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . blockCommentBuffer ) ; this . blockCommentBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; } if ( this . blockCommentTokensBuffer . length ( ) > <NUM_LIT:0> ) { this . blockCommentBuffer . append ( tokensString ) ; this . column += tokensStringLength ; this . blockCommentTokensBuffer . setLength ( <NUM_LIT:0> ) ; } this . blockCommentBuffer . append ( this . scanner . source , tokenStart , tokenLength ) ; bufferHasTokens = true ; bufferHasNewLine = false ; this . column += tokenLength ; multiLines = true ; hasTextOnFirstLine = - <NUM_LIT:1> ; } else { if ( insertSpace ) { this . blockCommentTokensBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } this . blockCommentTokensBuffer . append ( this . scanner . source , tokenStart , tokenLength ) ; } previousToken = token ; newLine = false ; firstWord = false ; scannerLine = lineNumber ; lastTextLine = lineNumber ; } if ( this . nlsTagCounter == <NUM_LIT:0> || ! multiLines ) { if ( hasTokens || multiLines ) { StringBuffer replacement ; if ( hasTextOnFirstLine == <NUM_LIT:1> ) { this . blockCommentTokensBuffer . setLength ( <NUM_LIT:0> ) ; replacement = this . blockCommentTokensBuffer ; if ( ( hasMultiLines || multiLines ) ) { int col = this . column ; replacement . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( replacement ) ; replacement . append ( BLOCK_LINE_PREFIX ) ; this . column = col ; } else if ( this . blockCommentBuffer . length ( ) == <NUM_LIT:0> || this . blockCommentBuffer . charAt ( <NUM_LIT:0> ) != '<CHAR_LIT:U+0020>' ) { replacement . append ( '<CHAR_LIT:U+0020>' ) ; } replacement . append ( this . blockCommentBuffer ) ; } else { replacement = this . blockCommentBuffer ; } addReplaceEdit ( editStart , editEnd , replacement . toString ( ) ) ; } } this . indentationLevel = indentLevel ; this . numberOfIndentations = indentations ; this . lastNumberOfNewLines = <NUM_LIT:0> ; this . needSpace = false ; this . scanner . resetTo ( currentTokenEndPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; this . scanner . skipComments = false ; return true ; } private void printBlockCommentHeaderLine ( StringBuffer buffer ) { if ( ! this . formatter . preferences . comment_new_lines_at_block_boundaries ) { buffer . insert ( <NUM_LIT:0> , '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } else if ( buffer . length ( ) == <NUM_LIT:0> ) { buffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( buffer ) ; buffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; } else { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; buffer . insert ( <NUM_LIT:0> , this . tempBuffer . toString ( ) ) ; } } public void printEndOfCompilationUnit ( ) { try { int currentTokenStartPosition = this . scanner . currentPosition ; boolean hasComment = false ; boolean hasLineComment = false ; boolean hasWhitespace = false ; int count = <NUM_LIT:0> ; while ( true ) { this . currentToken = this . scanner . getNextToken ( ) ; switch ( this . currentToken ) { case TerminalTokens . TokenNameWHITESPACE : char [ ] whiteSpaces = this . scanner . getCurrentTokenSource ( ) ; count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , max = whiteSpaces . length ; i < max ; i ++ ) { switch ( whiteSpaces [ i ] ) { case '<STR_LIT>' : if ( ( i + <NUM_LIT:1> ) < max ) { if ( whiteSpaces [ i + <NUM_LIT:1> ] == '<STR_LIT:\n>' ) { i ++ ; } } count ++ ; break ; case '<STR_LIT:\n>' : count ++ ; } } if ( count == <NUM_LIT:0> ) { hasWhitespace = true ; addDeleteEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . scanner . getCurrentTokenEndPosition ( ) ) ; } else if ( hasLineComment ) { preserveEmptyLines ( count , this . scanner . getCurrentTokenStartPosition ( ) ) ; addDeleteEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . scanner . getCurrentTokenEndPosition ( ) ) ; } else if ( hasComment ) { if ( count == <NUM_LIT:1> ) { this . printNewLine ( this . scanner . getCurrentTokenStartPosition ( ) ) ; } else { preserveEmptyLines ( count - <NUM_LIT:1> , this . scanner . getCurrentTokenStartPosition ( ) ) ; } addDeleteEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . scanner . getCurrentTokenEndPosition ( ) ) ; } else { addDeleteEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . scanner . getCurrentTokenEndPosition ( ) ) ; } currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameCOMMENT_LINE : if ( count >= <NUM_LIT:1> ) { if ( count > <NUM_LIT:1> ) { preserveEmptyLines ( count - <NUM_LIT:1> , this . scanner . getCurrentTokenStartPosition ( ) ) ; } else if ( count == <NUM_LIT:1> ) { printNewLine ( this . scanner . getCurrentTokenStartPosition ( ) ) ; } } else if ( hasWhitespace ) { space ( ) ; } hasWhitespace = false ; printLineComment ( ) ; currentTokenStartPosition = this . scanner . currentPosition ; hasLineComment = true ; count = <NUM_LIT:0> ; break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : if ( count >= <NUM_LIT:1> ) { if ( count > <NUM_LIT:1> ) { preserveEmptyLines ( count - <NUM_LIT:1> , this . scanner . getCurrentTokenStartPosition ( ) ) ; } else if ( count == <NUM_LIT:1> ) { printNewLine ( this . scanner . getCurrentTokenStartPosition ( ) ) ; } } else if ( hasWhitespace ) { space ( ) ; } hasWhitespace = false ; printBlockComment ( false ) ; currentTokenStartPosition = this . scanner . currentPosition ; hasLineComment = false ; hasComment = true ; count = <NUM_LIT:0> ; break ; case TerminalTokens . TokenNameCOMMENT_JAVADOC : if ( count >= <NUM_LIT:1> ) { if ( count > <NUM_LIT:1> ) { preserveEmptyLines ( count - <NUM_LIT:1> , this . scanner . startPosition ) ; } else if ( count == <NUM_LIT:1> ) { printNewLine ( this . scanner . startPosition ) ; } } else if ( hasWhitespace ) { space ( ) ; } hasWhitespace = false ; if ( includesJavadocComments ( ) ) { printJavadocComment ( this . scanner . startPosition , this . scanner . currentPosition ) ; } else { printBlockComment ( true ) ; } printNewLine ( ) ; currentTokenStartPosition = this . scanner . currentPosition ; hasLineComment = false ; hasComment = true ; count = <NUM_LIT:0> ; break ; case TerminalTokens . TokenNameSEMICOLON : print ( this . scanner . currentPosition - this . scanner . startPosition , this . formatter . preferences . insert_space_before_semicolon ) ; break ; case TerminalTokens . TokenNameEOF : if ( count >= <NUM_LIT:1> || this . formatter . preferences . insert_new_line_at_end_of_file_if_missing ) { this . printNewLine ( this . scannerEndPosition ) ; } return ; default : this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } } } catch ( InvalidInputException e ) { throw new AbortFormatting ( e ) ; } } private void printCodeSnippet ( int startPosition , int endPosition , int linesGap ) { String snippet = new String ( this . scanner . source , startPosition , endPosition - startPosition + <NUM_LIT:1> ) ; int firstLine = Util . getLineNumber ( startPosition , this . lineEnds , <NUM_LIT:0> , this . maxLines ) - <NUM_LIT:1> ; int lastLine = Util . getLineNumber ( endPosition , this . lineEnds , firstLine > <NUM_LIT:1> ? firstLine - <NUM_LIT:2> : <NUM_LIT:0> , this . maxLines ) - <NUM_LIT:1> ; this . codeSnippetBuffer . setLength ( <NUM_LIT:0> ) ; if ( firstLine == lastLine && linesGap == <NUM_LIT:0> ) { this . codeSnippetBuffer . append ( snippet ) ; } else { boolean hasCharsAfterStar = false ; if ( linesGap == <NUM_LIT:0> ) { this . codeSnippetBuffer . append ( this . scanner . source , startPosition , this . lineEnds [ firstLine ] + <NUM_LIT:1> - startPosition ) ; firstLine ++ ; } int initialLength = this . codeSnippetBuffer . length ( ) ; for ( int currentLine = firstLine ; currentLine <= lastLine ; currentLine ++ ) { this . scanner . resetTo ( this . lineEnds [ currentLine - <NUM_LIT:1> ] + <NUM_LIT:1> , this . lineEnds [ currentLine ] ) ; int lineStart = this . scanner . currentPosition ; boolean hasStar = false ; loop : while ( ! this . scanner . atEnd ( ) ) { char ch = ( char ) this . scanner . getNextChar ( ) ; switch ( ch ) { case '<CHAR_LIT:U+0020>' : case '<STR_LIT:\t>' : case '<CHAR_LIT>' : break ; case '<STR_LIT>' : case '<STR_LIT:\n>' : break loop ; case '<CHAR_LIT>' : hasStar = true ; break loop ; default : if ( ScannerHelper . isWhitespace ( ch ) ) { break ; } break loop ; } } if ( hasStar ) { lineStart = this . scanner . currentPosition ; if ( ! hasCharsAfterStar && ! this . scanner . atEnd ( ) ) { char ch = ( char ) this . scanner . getNextChar ( ) ; boolean atEnd = this . scanner . atEnd ( ) ; switch ( ch ) { case '<CHAR_LIT:U+0020>' : case '<STR_LIT:\t>' : case '<CHAR_LIT>' : break ; case '<STR_LIT>' : case '<STR_LIT:\n>' : atEnd = true ; break ; default : if ( ! ScannerHelper . isWhitespace ( ch ) ) { if ( hasStar ) { hasCharsAfterStar = true ; currentLine = firstLine - <NUM_LIT:1> ; this . codeSnippetBuffer . setLength ( initialLength ) ; continue ; } } break ; } if ( ! hasCharsAfterStar && ! atEnd ) { lineStart = this . scanner . currentPosition ; } } } int end = currentLine == lastLine ? endPosition : this . lineEnds [ currentLine ] ; this . codeSnippetBuffer . append ( this . scanner . source , lineStart , end + <NUM_LIT:1> - lineStart ) ; } } HTMLEntity2JavaReader reader = new HTMLEntity2JavaReader ( new StringReader ( this . codeSnippetBuffer . toString ( ) ) ) ; char [ ] buf = new char [ this . codeSnippetBuffer . length ( ) ] ; String convertedSnippet ; try { int read = reader . read ( buf ) ; convertedSnippet = new String ( buf , <NUM_LIT:0> , read ) ; } catch ( IOException e ) { CommentFormatterUtil . log ( e ) ; return ; } String formattedSnippet = convertedSnippet ; Map options = this . formatter . preferences . getMap ( ) ; if ( this . scanner . sourceLevel > ClassFileConstants . JDK1_3 ) { options . put ( JavaCore . COMPILER_SOURCE , CompilerOptions . versionFromJdkLevel ( this . scanner . sourceLevel ) ) ; } TextEdit edit = CommentFormatterUtil . format2 ( CodeFormatter . K_UNKNOWN | CodeFormatter . F_INCLUDE_COMMENTS , convertedSnippet , <NUM_LIT:0> , this . lineSeparator , options ) ; if ( edit == null ) { formattedSnippet = this . codeSnippetBuffer . toString ( ) ; } else { formattedSnippet = CommentFormatterUtil . evaluateFormatterEdit ( convertedSnippet , edit , null ) ; Java2HTMLEntityReader javaReader = new Java2HTMLEntityReader ( new StringReader ( formattedSnippet ) ) ; buf = new char [ <NUM_LIT> ] ; this . codeSnippetBuffer . setLength ( <NUM_LIT:0> ) ; int l ; try { do { l = javaReader . read ( buf ) ; if ( l != - <NUM_LIT:1> ) this . codeSnippetBuffer . append ( buf , <NUM_LIT:0> , l ) ; } while ( l > <NUM_LIT:0> ) ; formattedSnippet = this . codeSnippetBuffer . toString ( ) ; } catch ( IOException e ) { CommentFormatterUtil . log ( e ) ; return ; } } this . codeSnippetBuffer . setLength ( <NUM_LIT:0> ) ; ILineTracker tracker = new DefaultLineTracker ( ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . codeSnippetBuffer ) ; this . codeSnippetBuffer . append ( BLOCK_LINE_PREFIX ) ; String linePrefix = this . codeSnippetBuffer . toString ( ) ; this . codeSnippetBuffer . setLength ( <NUM_LIT:0> ) ; String replacement = formattedSnippet ; tracker . set ( formattedSnippet ) ; int numberOfLines = tracker . getNumberOfLines ( ) ; if ( numberOfLines > <NUM_LIT:1> ) { int lastLineOffset = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < numberOfLines - <NUM_LIT:1> ; i ++ ) { if ( i > <NUM_LIT:0> ) this . codeSnippetBuffer . append ( linePrefix ) ; try { lastLineOffset = tracker . getLineOffset ( i + <NUM_LIT:1> ) ; this . codeSnippetBuffer . append ( formattedSnippet . substring ( tracker . getLineOffset ( i ) , lastLineOffset ) ) ; } catch ( BadLocationException e ) { CommentFormatterUtil . log ( e ) ; return ; } } this . codeSnippetBuffer . append ( linePrefix ) ; this . codeSnippetBuffer . append ( formattedSnippet . substring ( lastLineOffset ) ) ; replacement = this . codeSnippetBuffer . toString ( ) ; } addReplaceEdit ( startPosition , endPosition , replacement ) ; } void printComment ( ) { printComment ( CodeFormatter . K_UNKNOWN , NO_TRAILING_COMMENT , PRESERVE_EMPTY_LINES_KEEP_LAST_NEW_LINES_INDENTATION ) ; } void printComment ( int emptyLinesRules ) { printComment ( CodeFormatter . K_UNKNOWN , NO_TRAILING_COMMENT , emptyLinesRules ) ; } void printComment ( int kind , int trailing ) { printComment ( kind , trailing , PRESERVE_EMPTY_LINES_KEEP_LAST_NEW_LINES_INDENTATION ) ; } void printComment ( int kind , int trailing , int emptyLinesRules ) { final boolean rejectLineComment = kind == CodeFormatter . K_MULTI_LINE_COMMENT || kind == CodeFormatter . K_JAVA_DOC ; final boolean rejectBlockComment = kind == CodeFormatter . K_SINGLE_LINE_COMMENT || kind == CodeFormatter . K_JAVA_DOC ; final boolean rejectJavadocComment = kind == CodeFormatter . K_SINGLE_LINE_COMMENT || kind == CodeFormatter . K_MULTI_LINE_COMMENT ; try { int currentTokenStartPosition = this . scanner . currentPosition ; boolean hasComment = false ; boolean hasLineComment = false ; boolean hasWhitespaces = false ; int lines = <NUM_LIT:0> ; while ( ( this . currentToken = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { int foundTaskCount = this . scanner . foundTaskCount ; int tokenStartPosition = this . scanner . getCurrentTokenStartPosition ( ) ; switch ( this . currentToken ) { case TerminalTokens . TokenNameWHITESPACE : char [ ] whiteSpaces = this . scanner . getCurrentTokenSource ( ) ; int whitespacesEndPosition = this . scanner . getCurrentTokenEndPosition ( ) ; lines = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , max = whiteSpaces . length ; i < max ; i ++ ) { switch ( whiteSpaces [ i ] ) { case '<STR_LIT>' : if ( ( i + <NUM_LIT:1> ) < max ) { if ( whiteSpaces [ i + <NUM_LIT:1> ] == '<STR_LIT:\n>' ) { i ++ ; } } lines ++ ; break ; case '<STR_LIT:\n>' : lines ++ ; } } boolean realTrailing = trailing > NO_TRAILING_COMMENT ; if ( realTrailing && this . scanner . currentCharacter == '<CHAR_LIT:/>' && ( lines == <NUM_LIT:0> || ( lines == <NUM_LIT:1> && ! hasLineComment && trailing == IMPORT_TRAILING_COMMENT ) ) ) { boolean canChangeTrailing = ( trailing & COMPLEX_TRAILING_COMMENT ) != <NUM_LIT:0> ; if ( trailing == BASIC_TRAILING_COMMENT && hasLineComment ) { int currentCommentIndentation = getCurrentIndentation ( whiteSpaces , <NUM_LIT:0> ) ; int relativeIndentation = currentCommentIndentation - this . lastLineComment . currentIndentation ; if ( this . tabLength == <NUM_LIT:0> ) { canChangeTrailing = relativeIndentation == <NUM_LIT:0> ; } else { canChangeTrailing = relativeIndentation > - this . tabLength ; } } if ( canChangeTrailing ) { int currentPosition = this . scanner . currentPosition ; if ( this . scanner . getNextToken ( ) == TerminalTokens . TokenNameCOMMENT_LINE ) { realTrailing = ! hasLineComment ; switch ( this . scanner . getNextToken ( ) ) { case TerminalTokens . TokenNameCOMMENT_LINE : realTrailing = false ; break ; case TerminalTokens . TokenNameWHITESPACE : if ( this . scanner . getNextToken ( ) == TerminalTokens . TokenNameCOMMENT_LINE ) { realTrailing = false ; } break ; } } this . scanner . resetTo ( currentPosition , this . scanner . eofPosition - <NUM_LIT:1> ) ; } } if ( lines > <NUM_LIT:1> || ( lines == <NUM_LIT:1> && hasLineComment ) ) { this . lastLineComment . contiguous = false ; } this . lastLineComment . leadingSpaces = whiteSpaces ; this . lastLineComment . lines = lines ; if ( realTrailing ) { if ( hasLineComment ) { if ( lines >= <NUM_LIT:1> ) { currentTokenStartPosition = tokenStartPosition ; preserveEmptyLines ( lines , currentTokenStartPosition ) ; addDeleteEdit ( currentTokenStartPosition , whitespacesEndPosition ) ; this . scanner . resetTo ( this . scanner . currentPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } if ( lines >= <NUM_LIT:1> ) { if ( hasComment ) { this . printNewLine ( tokenStartPosition ) ; } this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } hasWhitespaces = true ; currentTokenStartPosition = this . scanner . currentPosition ; addDeleteEdit ( tokenStartPosition , whitespacesEndPosition ) ; } else { if ( lines == <NUM_LIT:0> ) { hasWhitespaces = true ; if ( hasLineComment && emptyLinesRules != PRESERVE_EMPTY_LINES_KEEP_LAST_NEW_LINES_INDENTATION ) { addReplaceEdit ( tokenStartPosition , whitespacesEndPosition , getPreserveEmptyLines ( <NUM_LIT:0> , emptyLinesRules ) ) ; } else { addDeleteEdit ( tokenStartPosition , whitespacesEndPosition ) ; } } else if ( hasLineComment ) { useAlignmentBreakIndentation ( emptyLinesRules ) ; currentTokenStartPosition = tokenStartPosition ; preserveEmptyLines ( lines , currentTokenStartPosition ) ; addDeleteEdit ( currentTokenStartPosition , whitespacesEndPosition ) ; } else if ( hasComment ) { useAlignmentBreakIndentation ( emptyLinesRules ) ; if ( lines == <NUM_LIT:1> ) { this . printNewLine ( tokenStartPosition ) ; } else { preserveEmptyLines ( lines - <NUM_LIT:1> , tokenStartPosition ) ; } addDeleteEdit ( tokenStartPosition , whitespacesEndPosition ) ; } else if ( lines != <NUM_LIT:0> && ( ! this . formatter . preferences . join_wrapped_lines || this . formatter . preferences . number_of_empty_lines_to_preserve != <NUM_LIT:0> || this . blank_lines_between_import_groups > <NUM_LIT:0> ) ) { addReplaceEdit ( tokenStartPosition , whitespacesEndPosition , getPreserveEmptyLines ( lines - <NUM_LIT:1> , emptyLinesRules ) ) ; } else { useAlignmentBreakIndentation ( emptyLinesRules ) ; addDeleteEdit ( tokenStartPosition , whitespacesEndPosition ) ; } } currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameCOMMENT_LINE : if ( this . useTags && this . editsEnabled ) { boolean turnOff = false ; if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; turnOff = true ; } else if ( this . tagsKind == this . currentToken && CharOperation . fragmentEquals ( this . disablingTag , this . scanner . source , tokenStartPosition , true ) ) { this . editsEnabled = false ; turnOff = true ; } if ( turnOff ) { if ( ! this . editsEnabled && this . editsIndex > <NUM_LIT:1> ) { OptimizedReplaceEdit currentEdit = this . edits [ this . editsIndex - <NUM_LIT:1> ] ; if ( this . scanner . startPosition == currentEdit . offset + currentEdit . length ) { printNewLinesBeforeDisablingComment ( ) ; } } } } if ( rejectLineComment ) break ; if ( lines >= <NUM_LIT:1> ) { if ( lines > <NUM_LIT:1> ) { preserveEmptyLines ( lines - <NUM_LIT:1> , this . scanner . getCurrentTokenStartPosition ( ) ) ; } else if ( lines == <NUM_LIT:1> ) { printNewLine ( this . scanner . getCurrentTokenStartPosition ( ) ) ; } } else if ( hasWhitespaces ) { space ( ) ; } hasWhitespaces = false ; printLineComment ( ) ; currentTokenStartPosition = this . scanner . currentPosition ; hasLineComment = true ; lines = <NUM_LIT:0> ; if ( this . useTags && ! this . editsEnabled ) { if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; } else if ( this . tagsKind == this . currentToken ) { this . editsEnabled = CharOperation . fragmentEquals ( this . enablingTag , this . scanner . source , tokenStartPosition , true ) ; } } break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : if ( this . useTags && this . editsEnabled ) { boolean turnOff = false ; if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; turnOff = true ; } else if ( this . tagsKind == this . currentToken && CharOperation . fragmentEquals ( this . disablingTag , this . scanner . source , tokenStartPosition , true ) ) { this . editsEnabled = false ; turnOff = true ; } if ( turnOff ) { if ( ! this . editsEnabled && this . editsIndex > <NUM_LIT:1> ) { OptimizedReplaceEdit currentEdit = this . edits [ this . editsIndex - <NUM_LIT:1> ] ; if ( this . scanner . startPosition == currentEdit . offset + currentEdit . length ) { printNewLinesBeforeDisablingComment ( ) ; } } } } if ( trailing > NO_TRAILING_COMMENT && lines >= <NUM_LIT:1> ) { this . scanner . resetTo ( this . scanner . getCurrentTokenStartPosition ( ) , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } this . lastLineComment . contiguous = false ; if ( rejectBlockComment ) break ; if ( lines >= <NUM_LIT:1> ) { if ( lines > <NUM_LIT:1> ) { preserveEmptyLines ( lines - <NUM_LIT:1> , this . scanner . getCurrentTokenStartPosition ( ) ) ; } else if ( lines == <NUM_LIT:1> ) { printNewLine ( this . scanner . getCurrentTokenStartPosition ( ) ) ; } } else if ( hasWhitespaces ) { space ( ) ; } hasWhitespaces = false ; printBlockComment ( false ) ; currentTokenStartPosition = this . scanner . currentPosition ; hasLineComment = false ; hasComment = true ; lines = <NUM_LIT:0> ; if ( this . useTags && ! this . editsEnabled ) { if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; } else if ( this . tagsKind == this . currentToken ) { this . editsEnabled = CharOperation . fragmentEquals ( this . enablingTag , this . scanner . source , tokenStartPosition , true ) ; } } break ; case TerminalTokens . TokenNameCOMMENT_JAVADOC : if ( this . useTags && this . editsEnabled && foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; if ( ! this . editsEnabled && this . editsIndex > <NUM_LIT:1> ) { OptimizedReplaceEdit currentEdit = this . edits [ this . editsIndex - <NUM_LIT:1> ] ; if ( this . scanner . startPosition == currentEdit . offset + currentEdit . length ) { printNewLinesBeforeDisablingComment ( ) ; } } } if ( trailing > NO_TRAILING_COMMENT ) { this . scanner . resetTo ( this . scanner . getCurrentTokenStartPosition ( ) , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } this . lastLineComment . contiguous = false ; if ( rejectJavadocComment ) break ; if ( lines >= <NUM_LIT:1> ) { if ( lines > <NUM_LIT:1> ) { preserveEmptyLines ( lines - <NUM_LIT:1> , this . scanner . getCurrentTokenStartPosition ( ) ) ; } else if ( lines == <NUM_LIT:1> ) { printNewLine ( this . scanner . getCurrentTokenStartPosition ( ) ) ; } } else if ( hasWhitespaces ) { space ( ) ; } hasWhitespaces = false ; if ( includesJavadocComments ( ) ) { printJavadocComment ( this . scanner . startPosition , this . scanner . currentPosition ) ; } else { printBlockComment ( true ) ; } if ( this . useTags && ! this . editsEnabled && foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; } printNewLine ( ) ; currentTokenStartPosition = this . scanner . currentPosition ; hasLineComment = false ; hasComment = true ; lines = <NUM_LIT:0> ; break ; default : this . lastLineComment . contiguous = false ; this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } } } catch ( InvalidInputException e ) { throw new AbortFormatting ( e ) ; } } void printComment ( int kind , String source , int start , int end , int level ) { resetScanner ( source . toCharArray ( ) ) ; this . scanner . resetTo ( start , end ) ; this . numberOfIndentations = level ; this . indentationLevel = level * this . indentationSize ; this . column = this . indentationLevel + <NUM_LIT:1> ; switch ( kind ) { case CodeFormatter . K_SINGLE_LINE_COMMENT : printComment ( kind , NO_TRAILING_COMMENT ) ; break ; case CodeFormatter . K_MULTI_LINE_COMMENT : printComment ( kind , NO_TRAILING_COMMENT ) ; break ; case CodeFormatter . K_JAVA_DOC : printJavadocComment ( start , end ) ; break ; } } private void printLineComment ( ) { int currentTokenStartPosition = this . scanner . getCurrentTokenStartPosition ( ) ; int currentTokenEndPosition = this . scanner . getCurrentTokenEndPosition ( ) + <NUM_LIT:1> ; boolean includesLineComments = includesLineComments ( ) ; boolean isNlsTag = false ; if ( CharOperation . indexOf ( Scanner . TAG_PREFIX , this . scanner . source , true , currentTokenStartPosition , currentTokenEndPosition ) != - <NUM_LIT:1> ) { this . nlsTagCounter = <NUM_LIT:0> ; isNlsTag = true ; } this . scanner . resetTo ( currentTokenStartPosition , currentTokenEndPosition - <NUM_LIT:1> ) ; int currentCharacter ; int start = currentTokenStartPosition ; int nextCharacterStart = currentTokenStartPosition ; int commentIndentationLevel ; boolean onFirstColumn = isOnFirstColumn ( start ) ; if ( this . indentationLevel == <NUM_LIT:0> ) { commentIndentationLevel = this . column - <NUM_LIT:1> ; } else { if ( onFirstColumn && ( ( includesLineComments && ! this . formatter . preferences . comment_format_line_comment_starting_on_first_column ) || this . formatter . preferences . never_indent_line_comments_on_first_column ) ) { commentIndentationLevel = this . column - <NUM_LIT:1> ; } else { if ( this . lastLineComment . contiguous ) { int currentCommentIndentation = getCurrentIndentation ( this . lastLineComment . leadingSpaces , <NUM_LIT:0> ) ; int relativeIndentation = currentCommentIndentation - this . lastLineComment . currentIndentation ; boolean similarCommentsIndentation = false ; if ( this . tabLength == <NUM_LIT:0> ) { similarCommentsIndentation = relativeIndentation == <NUM_LIT:0> ; } else if ( relativeIndentation > - this . tabLength ) { similarCommentsIndentation = relativeIndentation == <NUM_LIT:0> || currentCommentIndentation != <NUM_LIT:0> && this . lastLineComment . currentIndentation != <NUM_LIT:0> ; } if ( similarCommentsIndentation && this . lastLineComment . indentation != this . indentationLevel ) { int currentIndentationLevel = this . indentationLevel ; this . indentationLevel = this . lastLineComment . indentation ; printIndentationIfNecessary ( ) ; this . indentationLevel = currentIndentationLevel ; commentIndentationLevel = this . lastLineComment . indentation ; } else { printIndentationIfNecessary ( ) ; commentIndentationLevel = this . column - <NUM_LIT:1> ; } } else { if ( this . currentAlignment != null && this . currentAlignment . kind == Alignment . ARRAY_INITIALIZER && this . currentAlignment . fragmentCount > <NUM_LIT:0> && this . indentationLevel < this . currentAlignment . breakIndentationLevel && this . lastLineComment . lines > <NUM_LIT:0> ) { int currentIndentationLevel = this . indentationLevel ; this . indentationLevel = this . currentAlignment . breakIndentationLevel ; printIndentationIfNecessary ( ) ; this . indentationLevel = currentIndentationLevel ; commentIndentationLevel = this . currentAlignment . breakIndentationLevel ; } else { printIndentationIfNecessary ( ) ; commentIndentationLevel = this . column - <NUM_LIT:1> ; } } } } this . lastLineComment . contiguous = true ; this . lastLineComment . currentIndentation = getCurrentCommentIndentation ( currentTokenStartPosition ) ; this . lastLineComment . indentation = commentIndentationLevel ; if ( this . pendingSpace ) { if ( this . formatter . preferences . comment_preserve_white_space_between_code_and_line_comments ) { addInsertEdit ( currentTokenStartPosition , new String ( this . lastLineComment . leadingSpaces ) ) ; } else { addInsertEdit ( currentTokenStartPosition , "<STR_LIT:U+0020>" ) ; } } this . needSpace = false ; this . pendingSpace = false ; int previousStart = currentTokenStartPosition ; if ( ! isNlsTag && includesLineComments && ( ! onFirstColumn || this . formatter . preferences . comment_format_line_comment_starting_on_first_column ) ) { printLineComment ( currentTokenStartPosition , currentTokenEndPosition - <NUM_LIT:1> ) ; } else { loop : while ( nextCharacterStart <= currentTokenEndPosition && ( currentCharacter = this . scanner . getNextChar ( ) ) != - <NUM_LIT:1> ) { nextCharacterStart = this . scanner . currentPosition ; switch ( currentCharacter ) { case '<STR_LIT>' : start = previousStart ; break loop ; case '<STR_LIT:\n>' : start = previousStart ; break loop ; } previousStart = nextCharacterStart ; } if ( start != currentTokenStartPosition ) { addReplaceEdit ( start , currentTokenEndPosition - <NUM_LIT:1> , this . lineSeparator ) ; this . line ++ ; this . column = <NUM_LIT:1> ; this . lastNumberOfNewLines = <NUM_LIT:1> ; } } this . needSpace = false ; this . pendingSpace = false ; if ( this . currentAlignment != null ) { if ( this . memberAlignment != null ) { if ( this . currentAlignment . location . inputOffset > this . memberAlignment . location . inputOffset ) { if ( this . currentAlignment . couldBreak ( ) && this . currentAlignment . wasSplit ) { this . currentAlignment . performFragmentEffect ( ) ; } } else { this . indentationLevel = Math . max ( this . indentationLevel , this . memberAlignment . breakIndentationLevel ) ; } } else if ( this . currentAlignment . couldBreak ( ) && this . currentAlignment . wasSplit ) { this . currentAlignment . performFragmentEffect ( ) ; } if ( this . currentAlignment . kind == Alignment . BINARY_EXPRESSION && this . currentAlignment . enclosing != null && this . currentAlignment . enclosing . kind == Alignment . BINARY_EXPRESSION && this . indentationLevel < this . currentAlignment . breakIndentationLevel ) { this . indentationLevel = this . currentAlignment . breakIndentationLevel ; } } this . scanner . resetTo ( currentTokenEndPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; } private void printLineComment ( int commentStart , int commentEnd ) { int firstColumn = this . column ; int indentLevel = this . indentationLevel ; int indentations = this . numberOfIndentations ; this . indentationLevel = getNextIndentationLevel ( firstColumn ) ; if ( this . indentationSize != <NUM_LIT:0> ) { this . numberOfIndentations = this . indentationLevel / this . indentationSize ; } else { this . numberOfIndentations = <NUM_LIT:0> ; } this . scanner . resetTo ( commentStart , commentEnd ) ; this . scanner . getNextChar ( ) ; this . scanner . getNextChar ( ) ; this . column += <NUM_LIT:2> ; int maxColumn = this . formatter . preferences . comment_line_length + <NUM_LIT:1> ; int previousToken = - <NUM_LIT:1> ; int lastTokenEndPosition = commentStart ; int spaceStartPosition = - <NUM_LIT:1> ; int spaceEndPosition = - <NUM_LIT:1> ; this . scanner . skipComments = true ; String newLineString = null ; this . commentIndentation = null ; while ( ! this . scanner . atEnd ( ) ) { int token ; try { token = this . scanner . getNextToken ( ) ; } catch ( InvalidInputException iie ) { token = consumeInvalidToken ( commentEnd ) ; } switch ( token ) { case TerminalTokens . TokenNameWHITESPACE : if ( previousToken == - <NUM_LIT:1> ) { previousToken = SKIP_FIRST_WHITESPACE_TOKEN ; } else { previousToken = token ; } spaceStartPosition = this . scanner . getCurrentTokenStartPosition ( ) ; spaceEndPosition = this . scanner . getCurrentTokenEndPosition ( ) ; continue ; case TerminalTokens . TokenNameEOF : continue ; case TerminalTokens . TokenNameIdentifier : if ( previousToken == - <NUM_LIT:1> || previousToken == SKIP_FIRST_WHITESPACE_TOKEN ) { char [ ] identifier = this . scanner . getCurrentTokenSource ( ) ; int startPosition = this . scanner . getCurrentTokenStartPosition ( ) ; int restartPosition = this . scanner . currentPosition ; if ( CharOperation . equals ( identifier , Parser . FALL_THROUGH_TAG , <NUM_LIT:0> , <NUM_LIT:5> ) && this . scanner . currentCharacter == '<CHAR_LIT:->' ) { try { this . scanner . getNextToken ( ) ; token = this . scanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameIdentifier ) { identifier = this . scanner . getCurrentTokenSource ( ) ; if ( CharOperation . endsWith ( Parser . FALL_THROUGH_TAG , identifier ) ) { if ( previousToken == SKIP_FIRST_WHITESPACE_TOKEN ) { addReplaceEdit ( spaceStartPosition , startPosition - <NUM_LIT:1> , "<STR_LIT:U+0020>" ) ; } this . scanner . startPosition = startPosition ; previousToken = token ; break ; } } } catch ( InvalidInputException iie ) { } } this . scanner . startPosition = startPosition ; this . scanner . currentPosition = restartPosition ; } break ; } int tokenStart = this . scanner . getCurrentTokenStartPosition ( ) ; int tokenLength = ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - tokenStart ; if ( previousToken == - <NUM_LIT:1> ) { addInsertEdit ( this . scanner . startPosition , "<STR_LIT:U+0020>" ) ; this . column ++ ; } else if ( previousToken == SKIP_FIRST_WHITESPACE_TOKEN ) { addReplaceEdit ( spaceStartPosition , this . scanner . startPosition - <NUM_LIT:1> , "<STR_LIT:U+0020>" ) ; this . column ++ ; spaceStartPosition = - <NUM_LIT:1> ; } else { boolean insertSpace = previousToken == TerminalTokens . TokenNameWHITESPACE ; if ( insertSpace ) { tokenLength ++ ; } if ( spaceStartPosition > <NUM_LIT:0> && ( this . column + tokenLength ) > maxColumn ) { this . lastNumberOfNewLines ++ ; this . line ++ ; if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; if ( ! this . formatter . preferences . never_indent_line_comments_on_first_column ) { printIndentationIfNecessary ( this . tempBuffer ) ; } this . tempBuffer . append ( LINE_COMMENT_PREFIX ) ; this . column += LINE_COMMENT_PREFIX_LENGTH ; newLineString = this . tempBuffer . toString ( ) ; firstColumn = this . column ; } else { this . column = firstColumn ; } if ( lastTokenEndPosition > spaceEndPosition ) { this . column += lastTokenEndPosition - ( spaceEndPosition + <NUM_LIT:1> ) ; } if ( this . edits [ this . editsIndex - <NUM_LIT:1> ] . offset == spaceStartPosition ) { this . editsIndex -- ; } addReplaceEdit ( spaceStartPosition , spaceEndPosition , newLineString ) ; spaceStartPosition = - <NUM_LIT:1> ; if ( insertSpace ) { tokenLength -- ; } } else if ( insertSpace ) { addReplaceEdit ( spaceStartPosition , this . scanner . startPosition - <NUM_LIT:1> , "<STR_LIT:U+0020>" ) ; } } this . column += tokenLength ; previousToken = token ; lastTokenEndPosition = this . scanner . currentPosition ; } this . scanner . skipComments = false ; this . indentationLevel = indentLevel ; this . numberOfIndentations = indentations ; this . lastNumberOfNewLines = <NUM_LIT:0> ; this . scanner . resetTo ( lastTokenEndPosition , commentEnd ) ; while ( ! this . scanner . atEnd ( ) ) { spaceEndPosition = this . scanner . currentPosition ; this . scanner . getNextChar ( ) ; if ( this . scanner . currentCharacter == '<STR_LIT:\n>' || this . scanner . currentCharacter == '<STR_LIT>' ) { this . column = <NUM_LIT:1> ; this . line ++ ; this . lastNumberOfNewLines ++ ; break ; } } int startReplace = previousToken == SKIP_FIRST_WHITESPACE_TOKEN ? spaceStartPosition : lastTokenEndPosition ; if ( this . column == <NUM_LIT:1> && commentEnd >= startReplace ) { addReplaceEdit ( startReplace , commentEnd , this . formatter . preferences . line_separator ) ; } } public void printEmptyLines ( int linesNumber ) { this . printEmptyLines ( linesNumber , this . scanner . getCurrentTokenEndPosition ( ) + <NUM_LIT:1> ) ; } private void printEmptyLines ( int linesNumber , int insertPosition ) { final String buffer = getEmptyLines ( linesNumber ) ; if ( Util . EMPTY_STRING == buffer ) return ; addInsertEdit ( insertPosition , buffer ) ; } void printIndentationIfNecessary ( ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; printIndentationIfNecessary ( this . tempBuffer ) ; if ( this . tempBuffer . length ( ) > <NUM_LIT:0> ) { addInsertEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . tempBuffer . toString ( ) ) ; this . pendingSpace = false ; } } private void printIndentationIfNecessary ( StringBuffer buffer ) { switch ( this . tabChar ) { case DefaultCodeFormatterOptions . TAB : boolean useTabsForLeadingIndents = this . useTabsOnlyForLeadingIndents ; int numberOfLeadingIndents = this . numberOfIndentations ; int indentationsAsTab = <NUM_LIT:0> ; if ( useTabsForLeadingIndents ) { while ( this . column <= this . indentationLevel ) { if ( this . tabLength > <NUM_LIT:0> && indentationsAsTab < numberOfLeadingIndents ) { if ( buffer != null ) buffer . append ( '<STR_LIT:\t>' ) ; indentationsAsTab ++ ; int complement = this . tabLength - ( ( this . column - <NUM_LIT:1> ) % this . tabLength ) ; this . column += complement ; } else { if ( buffer != null ) buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } this . needSpace = false ; } } else if ( this . tabLength > <NUM_LIT:0> ) { while ( this . column <= this . indentationLevel ) { if ( buffer != null ) buffer . append ( '<STR_LIT:\t>' ) ; int complement = this . tabLength - ( ( this . column - <NUM_LIT:1> ) % this . tabLength ) ; this . column += complement ; this . needSpace = false ; } } break ; case DefaultCodeFormatterOptions . SPACE : while ( this . column <= this . indentationLevel ) { if ( buffer != null ) buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; this . needSpace = false ; } break ; case DefaultCodeFormatterOptions . MIXED : useTabsForLeadingIndents = this . useTabsOnlyForLeadingIndents ; numberOfLeadingIndents = this . numberOfIndentations ; indentationsAsTab = <NUM_LIT:0> ; if ( useTabsForLeadingIndents ) { final int columnForLeadingIndents = numberOfLeadingIndents * this . indentationSize ; while ( this . column <= this . indentationLevel ) { if ( this . column <= columnForLeadingIndents ) { if ( this . tabLength > <NUM_LIT:0> && ( this . column - <NUM_LIT:1> + this . tabLength ) <= this . indentationLevel ) { if ( buffer != null ) buffer . append ( '<STR_LIT:\t>' ) ; this . column += this . tabLength ; } else if ( ( this . column - <NUM_LIT:1> + this . indentationSize ) <= this . indentationLevel ) { for ( int i = <NUM_LIT:0> , max = this . indentationSize ; i < max ; i ++ ) { if ( buffer != null ) buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } } else { if ( buffer != null ) buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } } else { for ( int i = this . column , max = this . indentationLevel ; i <= max ; i ++ ) { if ( buffer != null ) buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } } this . needSpace = false ; } } else { while ( this . column <= this . indentationLevel ) { if ( this . tabLength > <NUM_LIT:0> && ( this . column - <NUM_LIT:1> + this . tabLength ) <= this . indentationLevel ) { if ( buffer != null ) buffer . append ( '<STR_LIT:\t>' ) ; this . column += this . tabLength ; } else if ( this . indentationSize > <NUM_LIT:0> && ( this . column - <NUM_LIT:1> + this . indentationSize ) <= this . indentationLevel ) { for ( int i = <NUM_LIT:0> , max = this . indentationSize ; i < max ; i ++ ) { if ( buffer != null ) buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } } else { if ( buffer != null ) buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } this . needSpace = false ; } } break ; } } private void printJavadocBlock ( FormatJavadocBlock block ) { if ( block == null ) return ; int previousEnd = block . tagEnd ; int maxNodes = block . nodesPtr ; boolean headerLine = block . isHeaderLine ( ) && this . lastNumberOfNewLines == <NUM_LIT:0> ; int maxColumn = this . formatter . preferences . comment_line_length + <NUM_LIT:1> ; if ( headerLine ) { maxColumn ++ ; } if ( ! block . isInlined ( ) ) { this . lastNumberOfNewLines = <NUM_LIT:0> ; } if ( block . isDescription ( ) ) { if ( ! block . isInlined ( ) ) { this . commentIndentation = null ; } } else { int tagLength = previousEnd - block . sourceStart + <NUM_LIT:1> ; this . column += tagLength ; if ( ! block . isInlined ( ) ) { boolean indentRootTags = this . formatter . preferences . comment_indent_root_tags && ! block . isInDescription ( ) ; int commentIndentationLevel = <NUM_LIT:0> ; if ( indentRootTags ) { commentIndentationLevel = tagLength + <NUM_LIT:1> ; boolean indentParamTag = this . formatter . preferences . comment_indent_parameter_description && block . isInParamTag ( ) ; if ( indentParamTag ) { commentIndentationLevel += this . indentationSize ; } } setCommentIndentation ( commentIndentationLevel ) ; } FormatJavadocReference reference = block . reference ; if ( reference != null ) { printJavadocBlockReference ( block , reference ) ; previousEnd = reference . sourceEnd ; } if ( maxNodes < <NUM_LIT:0> ) { if ( block . isInlined ( ) ) { this . column ++ ; } return ; } } int previousLine = Util . getLineNumber ( previousEnd , this . lineEnds , <NUM_LIT:0> , this . maxLines ) ; boolean clearBlankLines = this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment ; boolean joinLines = this . formatter . preferences . join_lines_in_comments ; for ( int i = <NUM_LIT:0> ; i <= maxNodes ; i ++ ) { FormatJavadocNode node = block . nodes [ i ] ; int nodeStart = node . sourceStart ; int newLines ; if ( i == <NUM_LIT:0> ) { newLines = this . formatter . preferences . comment_insert_new_line_for_parameter && block . isParamTag ( ) ? <NUM_LIT:1> : <NUM_LIT:0> ; if ( nodeStart > ( previousEnd + <NUM_LIT:1> ) ) { if ( ! clearBlankLines || ! joinLines ) { int startLine = Util . getLineNumber ( nodeStart , this . lineEnds , previousLine - <NUM_LIT:1> , this . maxLines ) ; int gapLine = previousLine ; if ( joinLines ) gapLine ++ ; if ( startLine > gapLine ) { newLines = startLine - previousLine ; } if ( clearBlankLines ) { if ( newLines > <NUM_LIT:0> ) newLines = <NUM_LIT:1> ; } } if ( newLines == <NUM_LIT:0> && ( ! node . isImmutable ( ) || block . reference != null ) ) { newLines = printJavadocBlockNodesNewLines ( block , node , previousEnd ) ; } if ( block . isImmutable ( ) ) { printJavadocGapLinesForImmutableBlock ( block ) ; } else { printJavadocGapLines ( previousEnd + <NUM_LIT:1> , nodeStart - <NUM_LIT:1> , newLines , clearBlankLines , false , null ) ; } } else { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; if ( newLines > <NUM_LIT:0> ) { for ( int j = <NUM_LIT:0> ; j < newLines ; j ++ ) { printJavadocNewLine ( this . tempBuffer ) ; } addInsertEdit ( nodeStart , this . tempBuffer . toString ( ) ) ; } } } else { newLines = this . column > maxColumn ? <NUM_LIT:1> : <NUM_LIT:0> ; if ( ! clearBlankLines && node . lineStart > ( previousLine + <NUM_LIT:1> ) ) newLines = node . lineStart - previousLine ; if ( newLines < node . linesBefore ) newLines = node . linesBefore ; if ( newLines == <NUM_LIT:0> ) { newLines = printJavadocBlockNodesNewLines ( block , node , previousEnd ) ; } if ( newLines > <NUM_LIT:0> || nodeStart > ( previousEnd + <NUM_LIT:1> ) ) { printJavadocGapLines ( previousEnd + <NUM_LIT:1> , nodeStart - <NUM_LIT:1> , newLines , clearBlankLines , false , null ) ; } } if ( headerLine && newLines > <NUM_LIT:0> ) { headerLine = false ; maxColumn -- ; } if ( node . isText ( ) ) { FormatJavadocText text = ( FormatJavadocText ) node ; if ( text . isImmutable ( ) ) { if ( text . isImmutableHtmlTag ( ) && newLines > <NUM_LIT:0> && this . commentIndentation != null ) { addInsertEdit ( node . sourceStart , this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; } printJavadocImmutableText ( text , block , newLines > <NUM_LIT:0> ) ; this . column += getTextLength ( block , text ) ; } else if ( text . isHtmlTag ( ) ) { printJavadocHtmlTag ( text , block , newLines > <NUM_LIT:0> ) ; } else { printJavadocText ( text , block , newLines > <NUM_LIT:0> ) ; } } else { if ( newLines > <NUM_LIT:0> && this . commentIndentation != null ) { addInsertEdit ( node . sourceStart , this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; } printJavadocBlock ( ( FormatJavadocBlock ) node ) ; } previousEnd = node . sourceEnd ; previousLine = Util . getLineNumber ( previousEnd , this . lineEnds , node . lineStart > <NUM_LIT:1> ? node . lineStart - <NUM_LIT:2> : <NUM_LIT:0> , this . maxLines ) ; } this . lastNumberOfNewLines = <NUM_LIT:0> ; } private int printJavadocBlockNodesNewLines ( FormatJavadocBlock block , FormatJavadocNode node , int previousEnd ) { int maxColumn = this . formatter . preferences . comment_line_length + <NUM_LIT:1> ; int nodeStart = node . sourceStart ; try { this . scanner . resetTo ( nodeStart , node . sourceEnd ) ; int length = <NUM_LIT:0> ; boolean newLine = false ; boolean headerLine = block . isHeaderLine ( ) && this . lastNumberOfNewLines == <NUM_LIT:0> ; int firstColumn = <NUM_LIT:1> + this . indentationLevel + BLOCK_LINE_PREFIX_LENGTH ; if ( this . commentIndentation != null ) firstColumn += this . commentIndentation . length ( ) ; if ( headerLine ) maxColumn ++ ; FormatJavadocText text = null ; boolean isImmutableNode = node . isImmutable ( ) ; boolean nodeIsText = node . isText ( ) ; if ( nodeIsText ) { text = ( FormatJavadocText ) node ; } else { FormatJavadocBlock inlinedBlock = ( FormatJavadocBlock ) node ; if ( isImmutableNode ) { text = ( FormatJavadocText ) inlinedBlock . getLastNode ( ) ; if ( text != null ) { length += inlinedBlock . tagEnd - inlinedBlock . sourceStart + <NUM_LIT:1> ; if ( nodeStart > ( previousEnd + <NUM_LIT:1> ) ) { length ++ ; } this . scanner . resetTo ( text . sourceStart , node . sourceEnd ) ; } } } if ( text != null ) { if ( isImmutableNode ) { if ( nodeStart > ( previousEnd + <NUM_LIT:1> ) ) { length ++ ; } int lastColumn = this . column + length ; while ( ! this . scanner . atEnd ( ) ) { try { int token = this . scanner . getNextToken ( ) ; switch ( token ) { case TerminalTokens . TokenNameWHITESPACE : if ( CharOperation . indexOf ( '<STR_LIT:\n>' , this . scanner . source , this . scanner . startPosition , this . scanner . currentPosition ) >= <NUM_LIT:0> ) { return <NUM_LIT:0> ; } lastColumn = getCurrentIndentation ( this . scanner . getCurrentTokenSource ( ) , lastColumn ) ; break ; case TerminalTokens . TokenNameMULTIPLY : if ( newLine ) { newLine = false ; continue ; } lastColumn ++ ; break ; default : lastColumn += ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; break ; } } catch ( InvalidInputException iie ) { lastColumn += ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; } if ( lastColumn > maxColumn ) { return <NUM_LIT:1> ; } } return <NUM_LIT:0> ; } if ( text . isHtmlTag ( ) ) { if ( text . getHtmlTagID ( ) == JAVADOC_SINGLE_BREAK_TAG_ID ) { return <NUM_LIT:0> ; } this . scanner . getNextToken ( ) ; if ( this . scanner . getNextToken ( ) == TerminalTokens . TokenNameDIVIDE ) { length ++ ; this . scanner . getNextToken ( ) ; } length += ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; this . scanner . getNextToken ( ) ; length ++ ; } else { while ( true ) { int token = this . scanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameWHITESPACE || token == TerminalTokens . TokenNameEOF ) break ; int tokenLength = ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; length += tokenLength ; if ( ( this . column + length ) >= maxColumn ) { break ; } } } } else { FormatJavadocBlock inlinedBlock = ( FormatJavadocBlock ) node ; length += inlinedBlock . tagEnd - inlinedBlock . sourceStart + <NUM_LIT:1> ; if ( inlinedBlock . reference != null ) { length ++ ; this . scanner . resetTo ( inlinedBlock . reference . sourceStart , inlinedBlock . reference . sourceEnd ) ; int previousToken = - <NUM_LIT:1> ; loop : while ( ! this . scanner . atEnd ( ) ) { int token = this . scanner . getNextToken ( ) ; int tokenLength = ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; switch ( token ) { case TerminalTokens . TokenNameWHITESPACE : if ( previousToken == TerminalTokens . TokenNameCOMMA ) { length ++ ; } break ; case TerminalTokens . TokenNameMULTIPLY : break ; default : length += tokenLength ; if ( ( this . column + length ) > maxColumn ) { break loop ; } break ; } previousToken = token ; } } length ++ ; } if ( nodeStart > ( previousEnd + <NUM_LIT:1> ) ) { length ++ ; } if ( ( firstColumn + length ) >= maxColumn && node == block . nodes [ <NUM_LIT:0> ] ) { return <NUM_LIT:0> ; } if ( ( this . column + length ) > maxColumn ) { return <NUM_LIT:1> ; } } catch ( InvalidInputException iie ) { int tokenLength = <NUM_LIT:1> ; if ( nodeStart > ( previousEnd + <NUM_LIT:1> ) ) { tokenLength ++ ; } if ( ( this . column + tokenLength ) > maxColumn ) { return <NUM_LIT:1> ; } } return <NUM_LIT:0> ; } private void printJavadocBlockReference ( FormatJavadocBlock block , FormatJavadocReference reference ) { int maxColumn = this . formatter . preferences . comment_line_length + <NUM_LIT:1> ; boolean headerLine = block . isHeaderLine ( ) ; boolean inlined = block . isInlined ( ) ; if ( headerLine ) maxColumn ++ ; this . scanner . resetTo ( block . tagEnd + <NUM_LIT:1> , reference . sourceEnd ) ; this . javadocBlockRefBuffer . setLength ( <NUM_LIT:0> ) ; boolean needFormat = false ; int previousToken = - <NUM_LIT:1> ; int spacePosition = - <NUM_LIT:1> ; String newLineString = null ; int firstColumn = - <NUM_LIT:1> ; while ( ! this . scanner . atEnd ( ) ) { int token ; try { token = this . scanner . getNextToken ( ) ; int tokenLength = ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; switch ( token ) { case TerminalTokens . TokenNameWHITESPACE : if ( previousToken != - <NUM_LIT:1> || tokenLength > <NUM_LIT:1> || this . scanner . currentCharacter != '<CHAR_LIT:U+0020>' ) needFormat = true ; switch ( previousToken ) { case TerminalTokens . TokenNameMULTIPLY : case TerminalTokens . TokenNameLPAREN : break ; default : spacePosition = this . javadocBlockRefBuffer . length ( ) ; case - <NUM_LIT:1> : this . javadocBlockRefBuffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; break ; } break ; case TerminalTokens . TokenNameMULTIPLY : break ; default : if ( ! inlined && spacePosition > <NUM_LIT:0> && ( this . column + tokenLength ) > maxColumn ) { this . lastNumberOfNewLines ++ ; this . line ++ ; if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; if ( this . commentIndentation != null ) { this . tempBuffer . append ( this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; } newLineString = this . tempBuffer . substring ( <NUM_LIT:0> , this . tempBuffer . length ( ) - <NUM_LIT:1> ) ; firstColumn = this . column ; } else { this . column = firstColumn ; } this . column = firstColumn + this . javadocBlockRefBuffer . length ( ) - spacePosition - <NUM_LIT:1> ; this . javadocBlockRefBuffer . insert ( spacePosition , newLineString ) ; if ( headerLine ) { headerLine = false ; maxColumn -- ; } spacePosition = - <NUM_LIT:1> ; } this . javadocBlockRefBuffer . append ( this . scanner . source , this . scanner . startPosition , tokenLength ) ; this . column += tokenLength ; break ; } previousToken = token ; } catch ( InvalidInputException iie ) { } } if ( needFormat ) { addReplaceEdit ( block . tagEnd + <NUM_LIT:1> , reference . sourceEnd , this . javadocBlockRefBuffer . toString ( ) ) ; } } private int getTextLength ( FormatJavadocBlock block , FormatJavadocText text ) { if ( text . isImmutable ( ) ) { this . scanner . resetTo ( text . sourceStart , text . sourceEnd ) ; int textLength = <NUM_LIT:0> ; while ( ! this . scanner . atEnd ( ) ) { try { int token = this . scanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameWHITESPACE ) { if ( CharOperation . indexOf ( '<STR_LIT:\n>' , this . scanner . source , this . scanner . startPosition , this . scanner . currentPosition ) >= <NUM_LIT:0> ) { textLength = <NUM_LIT:0> ; this . scanner . getNextChar ( ) ; if ( this . scanner . currentCharacter == '<CHAR_LIT>' ) { this . scanner . getNextChar ( ) ; if ( this . scanner . currentCharacter != '<CHAR_LIT:U+0020>' ) { textLength ++ ; } } else { textLength ++ ; } continue ; } } textLength += ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; } catch ( InvalidInputException e ) { textLength += ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - this . scanner . startPosition ; } } return textLength ; } if ( block . isOneLineTag ( ) ) { return text . sourceEnd - text . sourceStart + <NUM_LIT:1> ; } int startLine = Util . getLineNumber ( text . sourceStart , this . lineEnds , <NUM_LIT:0> , this . maxLines ) ; int endLine = startLine ; int previousEnd = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i <= text . separatorsPtr ; i ++ ) { int end = ( int ) ( text . separators [ i ] > > > <NUM_LIT:32> ) ; endLine = Util . getLineNumber ( end , this . lineEnds , endLine - <NUM_LIT:1> , this . maxLines ) ; if ( endLine > startLine ) { return previousEnd - text . sourceStart + <NUM_LIT:1> ; } previousEnd = end ; } return text . sourceEnd - text . sourceStart + <NUM_LIT:1> ; } void printJavadocComment ( int start , int end ) { int lastIndentationLevel = this . indentationLevel ; try { this . scanner . resetTo ( start , end - <NUM_LIT:1> ) ; if ( ! this . formatterCommentParser . parse ( start , end - <NUM_LIT:1> ) ) { return ; } FormatJavadoc javadoc = ( FormatJavadoc ) this . formatterCommentParser . docComment ; if ( this . indentationLevel != <NUM_LIT:0> ) { printIndentationIfNecessary ( ) ; } if ( this . pendingSpace ) { addInsertEdit ( start , "<STR_LIT:U+0020>" ) ; } if ( javadoc . blocks == null ) { return ; } this . needSpace = false ; this . pendingSpace = false ; int length = javadoc . blocks . length ; FormatJavadocBlock previousBlock = javadoc . blocks [ <NUM_LIT:0> ] ; this . lastNumberOfNewLines = <NUM_LIT:0> ; int currentLine = this . line ; int firstBlockStart = previousBlock . sourceStart ; printIndentationIfNecessary ( null ) ; this . column += JAVADOC_HEADER_LENGTH ; int index = <NUM_LIT:1> ; if ( length > <NUM_LIT:1> ) { if ( previousBlock . isDescription ( ) ) { printJavadocBlock ( previousBlock ) ; FormatJavadocBlock block = javadoc . blocks [ index ++ ] ; int newLines = this . formatter . preferences . comment_insert_empty_line_before_root_tags ? <NUM_LIT:2> : <NUM_LIT:1> ; printJavadocGapLines ( previousBlock . sourceEnd + <NUM_LIT:1> , block . sourceStart - <NUM_LIT:1> , newLines , this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment , false , null ) ; previousBlock = block ; } while ( index < length ) { printJavadocBlock ( previousBlock ) ; FormatJavadocBlock block = javadoc . blocks [ index ++ ] ; printJavadocGapLines ( previousBlock . sourceEnd + <NUM_LIT:1> , block . sourceStart - <NUM_LIT:1> , <NUM_LIT:1> , this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment , false , null ) ; previousBlock = block ; } } printJavadocBlock ( previousBlock ) ; int newLines = ( this . formatter . preferences . comment_new_lines_at_javadoc_boundaries && ( this . line > currentLine || javadoc . isMultiLine ( ) ) ) ? <NUM_LIT:1> : <NUM_LIT:0> ; printJavadocGapLines ( javadoc . textStart , firstBlockStart - <NUM_LIT:1> , newLines , this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment , false , null ) ; printJavadocGapLines ( previousBlock . sourceEnd + <NUM_LIT:1> , javadoc . textEnd , newLines , this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment , true , null ) ; } finally { this . scanner . resetTo ( end , this . scannerEndPosition - <NUM_LIT:1> ) ; this . needSpace = false ; this . indentationLevel = lastIndentationLevel ; this . lastNumberOfNewLines = <NUM_LIT:0> ; } } private void printJavadocGapLines ( int textStartPosition , int textEndPosition , int newLines , boolean clearBlankLines , boolean footer , StringBuffer output ) { try { if ( newLines == <NUM_LIT:0> ) { if ( output == null ) { addReplaceEdit ( textStartPosition , textEndPosition , "<STR_LIT:U+0020>" ) ; } else { output . append ( '<CHAR_LIT:U+0020>' ) ; } this . column ++ ; return ; } if ( textStartPosition > textEndPosition ) { if ( newLines > <NUM_LIT:0> ) { this . javadocGapLinesBuffer . setLength ( <NUM_LIT:0> ) ; for ( int i = <NUM_LIT:0> ; i < newLines ; i ++ ) { this . javadocGapLinesBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . javadocGapLinesBuffer ) ; if ( footer ) { this . javadocGapLinesBuffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } else { this . javadocGapLinesBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; } } if ( output == null ) { addInsertEdit ( textStartPosition , this . javadocGapLinesBuffer . toString ( ) ) ; } else { output . append ( this . javadocGapLinesBuffer ) ; } } return ; } this . scanner . resetTo ( textStartPosition , textEndPosition ) ; this . scanner . recordLineSeparator = true ; this . scanner . linePtr = Util . getLineNumber ( textStartPosition , this . lineEnds , <NUM_LIT:0> , this . maxLines ) - <NUM_LIT:2> ; int linePtr = this . scanner . linePtr ; int lineCount = <NUM_LIT:0> ; int start = textStartPosition ; boolean endsOnMultiply = false ; while ( ! this . scanner . atEnd ( ) ) { switch ( this . scanner . getNextToken ( ) ) { case TerminalTokens . TokenNameMULTIPLY : int linesGap = this . scanner . linePtr - linePtr ; if ( linesGap > <NUM_LIT:0> ) { this . javadocGapLinesBuffer . setLength ( <NUM_LIT:0> ) ; if ( lineCount > <NUM_LIT:0> ) { this . javadocGapLinesBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } for ( int i = <NUM_LIT:0> ; i < linesGap ; i ++ ) { if ( clearBlankLines && lineCount >= newLines ) { if ( textEndPosition >= start ) { if ( output == null ) { addReplaceEdit ( start , textEndPosition , this . javadocGapLinesBuffer . toString ( ) ) ; } else { output . append ( this . javadocGapLinesBuffer ) ; } } return ; } this . javadocGapLinesBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . javadocGapLinesBuffer ) ; if ( i == ( linesGap - <NUM_LIT:1> ) ) { this . javadocGapLinesBuffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } else { this . javadocGapLinesBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; } lineCount ++ ; } int currentTokenStartPosition = this . scanner . getCurrentTokenStartPosition ( ) ; int tokenLength = this . scanner . currentPosition - currentTokenStartPosition ; if ( output == null ) { addReplaceEdit ( start , currentTokenStartPosition - <NUM_LIT:1> , this . javadocGapLinesBuffer . toString ( ) ) ; } else { output . append ( this . javadocGapLinesBuffer ) ; output . append ( this . scanner . source , currentTokenStartPosition , tokenLength ) ; } this . column += tokenLength ; if ( footer && clearBlankLines && lineCount == newLines ) { if ( textEndPosition >= currentTokenStartPosition ) { if ( output == null ) { addDeleteEdit ( currentTokenStartPosition , textEndPosition ) ; } } return ; } } start = this . scanner . currentPosition ; linePtr = this . scanner . linePtr ; endsOnMultiply = true ; break ; default : endsOnMultiply = false ; break ; } } if ( lineCount < newLines ) { this . javadocGapLinesBuffer . setLength ( <NUM_LIT:0> ) ; if ( lineCount > <NUM_LIT:0> ) { this . javadocGapLinesBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } for ( int i = lineCount ; i < newLines - <NUM_LIT:1> ; i ++ ) { printJavadocNewLine ( this . javadocGapLinesBuffer ) ; } this . javadocGapLinesBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . javadocGapLinesBuffer ) ; if ( footer ) { this . javadocGapLinesBuffer . append ( '<CHAR_LIT:U+0020>' ) ; this . column ++ ; } else { this . javadocGapLinesBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; } if ( output == null ) { if ( textEndPosition >= start ) { addReplaceEdit ( start , textEndPosition , this . javadocGapLinesBuffer . toString ( ) ) ; } else { addInsertEdit ( textEndPosition + <NUM_LIT:1> , this . javadocGapLinesBuffer . toString ( ) ) ; } } else { output . append ( this . javadocGapLinesBuffer ) ; } } else { if ( textEndPosition >= start ) { this . javadocGapLinesBuffer . setLength ( <NUM_LIT:0> ) ; if ( this . scanner . linePtr > linePtr ) { if ( lineCount > <NUM_LIT:0> ) { this . javadocGapLinesBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } this . javadocGapLinesBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . javadocGapLinesBuffer ) ; } this . javadocGapLinesBuffer . append ( '<CHAR_LIT:U+0020>' ) ; if ( output == null ) { addReplaceEdit ( start , textEndPosition , this . javadocGapLinesBuffer . toString ( ) ) ; } else { output . append ( this . javadocGapLinesBuffer ) ; } this . needSpace = false ; } else if ( endsOnMultiply ) { if ( output == null ) { addInsertEdit ( textEndPosition + <NUM_LIT:1> , "<STR_LIT:U+0020>" ) ; } else { output . append ( '<CHAR_LIT:U+0020>' ) ; } this . needSpace = false ; } this . column ++ ; } } catch ( InvalidInputException iie ) { } finally { this . scanner . recordLineSeparator = false ; this . needSpace = false ; this . scanner . resetTo ( textEndPosition + <NUM_LIT:1> , this . scannerEndPosition - <NUM_LIT:1> ) ; this . lastNumberOfNewLines += newLines ; this . line += newLines ; } } private void printJavadocImmutableText ( FormatJavadocText text , FormatJavadocBlock block , boolean textOnNewLine ) { try { int textLineStart = text . lineStart ; this . scanner . tokenizeWhiteSpace = false ; String newLineString = null ; for ( int idx = <NUM_LIT:0> , max = text . separatorsPtr ; idx <= max ; idx ++ ) { int start = ( int ) text . separators [ idx ] ; int lineStart = Util . getLineNumber ( start , this . lineEnds , textLineStart - <NUM_LIT:1> , this . maxLines ) ; while ( textLineStart < lineStart ) { int end = this . lineEnds [ textLineStart - <NUM_LIT:1> ] ; this . scanner . resetTo ( end , start ) ; int token = this . scanner . getNextToken ( ) ; switch ( token ) { case TerminalTokens . TokenNameMULTIPLY : case TerminalTokens . TokenNameMULTIPLY_EQUAL : break ; default : return ; } if ( this . scanner . currentCharacter == '<CHAR_LIT:U+0020>' ) { this . scanner . getNextChar ( ) ; } if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; newLineString = this . tempBuffer . toString ( ) ; } addReplaceEdit ( end + <NUM_LIT:1> , this . scanner . getCurrentTokenEndPosition ( ) , newLineString ) ; textLineStart = Util . getLineNumber ( this . scanner . currentPosition - <NUM_LIT:1> , this . lineEnds , textLineStart , this . maxLines ) ; } } } catch ( InvalidInputException iie ) { } finally { this . needSpace = false ; this . scanner . tokenizeWhiteSpace = true ; this . scanner . resetTo ( text . sourceEnd + <NUM_LIT:1> , this . scannerEndPosition - <NUM_LIT:1> ) ; } } private void printJavadocGapLinesForImmutableBlock ( FormatJavadocBlock block ) { int firstLineEnd = - <NUM_LIT:1> ; int newLineStart = - <NUM_LIT:1> ; int secondLineStart = - <NUM_LIT:1> ; int starPosition = - <NUM_LIT:1> ; int offset = <NUM_LIT:0> ; int start = block . tagEnd + <NUM_LIT:1> ; int end = block . nodes [ <NUM_LIT:0> ] . sourceStart - <NUM_LIT:1> ; this . scanner . resetTo ( start , end ) ; int lineStart = block . lineStart ; int lineEnd = Util . getLineNumber ( block . nodes [ <NUM_LIT:0> ] . sourceEnd , this . lineEnds , lineStart - <NUM_LIT:1> , this . maxLines ) ; boolean multiLinesBlock = lineEnd > ( lineStart + <NUM_LIT:1> ) ; int previousPosition = this . scanner . currentPosition ; String newLineString = null ; int indentationColumn = <NUM_LIT:0> ; int leadingSpaces = - <NUM_LIT:1> ; while ( ! this . scanner . atEnd ( ) ) { char ch = ( char ) this . scanner . getNextChar ( ) ; switch ( ch ) { case '<STR_LIT:\t>' : if ( secondLineStart > <NUM_LIT:0> || firstLineEnd < <NUM_LIT:0> ) { int reminder = this . tabLength == <NUM_LIT:0> ? <NUM_LIT:0> : offset % this . tabLength ; if ( reminder == <NUM_LIT:0> ) { offset += this . tabLength ; } else { offset = ( ( offset / this . tabLength ) + <NUM_LIT:1> ) * this . tabLength ; } } else if ( leadingSpaces >= <NUM_LIT:0> ) { int reminder = this . tabLength == <NUM_LIT:0> ? <NUM_LIT:0> : offset % this . tabLength ; if ( reminder == <NUM_LIT:0> ) { leadingSpaces += this . tabLength ; } else { leadingSpaces = ( ( offset / this . tabLength ) + <NUM_LIT:1> ) * this . tabLength ; } } break ; case '<STR_LIT>' : case '<STR_LIT:\n>' : if ( firstLineEnd < <NUM_LIT:0> ) { firstLineEnd = previousPosition ; } if ( leadingSpaces > <NUM_LIT:0> && multiLinesBlock ) { if ( newLineString == null ) { this . column = <NUM_LIT:1> ; this . tempBuffer . setLength ( <NUM_LIT:0> ) ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; newLineString = this . tempBuffer . toString ( ) ; indentationColumn = this . column ; } else { this . column = indentationColumn ; } addReplaceEdit ( newLineStart , newLineStart + indentationColumn - <NUM_LIT:2> , newLineString ) ; } newLineStart = this . scanner . currentPosition ; leadingSpaces = <NUM_LIT:0> ; starPosition = - <NUM_LIT:1> ; if ( multiLinesBlock ) { offset = <NUM_LIT:0> ; secondLineStart = - <NUM_LIT:1> ; } break ; case '<CHAR_LIT>' : if ( starPosition < <NUM_LIT:0> && firstLineEnd > <NUM_LIT:0> ) { secondLineStart = this . scanner . currentPosition ; starPosition = this . scanner . currentPosition ; leadingSpaces = - <NUM_LIT:1> ; } break ; default : if ( secondLineStart > <NUM_LIT:0> ) { if ( secondLineStart == starPosition ) { secondLineStart = this . scanner . currentPosition ; } else { if ( offset == <NUM_LIT:0> && multiLinesBlock ) { if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; indentationColumn = this . column ; newLineString = this . tempBuffer . toString ( ) ; } else { this . column = indentationColumn ; } addReplaceEdit ( newLineStart , secondLineStart - <NUM_LIT:1> , newLineString ) ; } offset ++ ; } } else if ( firstLineEnd < <NUM_LIT:0> ) { offset ++ ; } else if ( leadingSpaces >= <NUM_LIT:0> ) { leadingSpaces ++ ; } break ; } previousPosition = this . scanner . currentPosition ; } if ( multiLinesBlock ) { this . column += offset ; } else { this . column ++ ; } if ( ! multiLinesBlock ) { if ( firstLineEnd > <NUM_LIT:0> ) { addReplaceEdit ( firstLineEnd , end , "<STR_LIT:U+0020>" ) ; } } else if ( secondLineStart > <NUM_LIT:0> ) { if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; newLineString = this . tempBuffer . toString ( ) ; indentationColumn = this . column ; } else { this . column = indentationColumn ; } addReplaceEdit ( newLineStart , secondLineStart - <NUM_LIT:1> , newLineString ) ; } else if ( leadingSpaces > <NUM_LIT:0> ) { if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; newLineString = this . tempBuffer . toString ( ) ; indentationColumn = this . column ; } else { this . column = indentationColumn ; } addReplaceEdit ( newLineStart , newLineStart + indentationColumn - <NUM_LIT:2> , newLineString ) ; } this . needSpace = false ; this . scanner . resetTo ( end + <NUM_LIT:1> , this . scannerEndPosition - <NUM_LIT:1> ) ; } private int printJavadocHtmlTag ( FormatJavadocText text , FormatJavadocBlock block , boolean textOnNewLine ) { boolean clearBlankLines = this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment ; int textStart = text . sourceStart ; int nextStart = textStart ; int startLine = Util . getLineNumber ( textStart , this . lineEnds , <NUM_LIT:0> , this . maxLines ) ; int htmlTagID = text . getHtmlTagID ( ) ; if ( text . depth >= this . javadocHtmlTagBuffers . length ) { int length = this . javadocHtmlTagBuffers . length ; System . arraycopy ( this . javadocHtmlTagBuffers , <NUM_LIT:0> , this . javadocHtmlTagBuffers = new StringBuffer [ text . depth + <NUM_LIT:6> ] , <NUM_LIT:0> , length ) ; } StringBuffer buffer = this . javadocHtmlTagBuffers [ text . depth ] ; if ( buffer == null ) { buffer = new StringBuffer ( ) ; this . javadocHtmlTagBuffers [ text . depth ] = buffer ; } else { buffer . setLength ( <NUM_LIT:0> ) ; } int max = text . separatorsPtr ; int linesAfter = <NUM_LIT:0> ; int previousEnd = - <NUM_LIT:1> ; boolean isHtmlBreakTag = htmlTagID == JAVADOC_SINGLE_BREAK_TAG_ID ; boolean isHtmlSeparatorTag = htmlTagID == JAVADOC_SEPARATOR_TAGS_ID ; if ( isHtmlBreakTag ) { return <NUM_LIT:1> ; } boolean isCode = htmlTagID == JAVADOC_CODE_TAGS_ID ; for ( int idx = <NUM_LIT:0> , ptr = <NUM_LIT:0> ; idx <= max || ( text . htmlNodesPtr != - <NUM_LIT:1> && ptr <= text . htmlNodesPtr ) ; idx ++ ) { int end = ( idx > max ) ? text . sourceEnd : ( int ) ( text . separators [ idx ] > > > <NUM_LIT:32> ) ; int nodeKind = <NUM_LIT:0> ; if ( text . htmlNodesPtr >= <NUM_LIT:0> && ptr <= text . htmlNodesPtr && end > text . htmlNodes [ ptr ] . sourceStart ) { FormatJavadocNode node = text . htmlNodes [ ptr ] ; FormatJavadocText htmlTag = node . isText ( ) ? ( FormatJavadocText ) node : null ; int newLines = htmlTag == null ? <NUM_LIT:0> : htmlTag . linesBefore ; if ( linesAfter > newLines ) { newLines = linesAfter ; if ( newLines > <NUM_LIT:1> && clearBlankLines ) { if ( idx < <NUM_LIT:2> || ( text . htmlIndexes [ idx - <NUM_LIT:2> ] & JAVADOC_TAGS_ID_MASK ) != JAVADOC_CODE_TAGS_ID ) { newLines = <NUM_LIT:1> ; } } } if ( textStart < previousEnd ) { addReplaceEdit ( textStart , previousEnd , buffer . toString ( ) ) ; } boolean immutable = node . isImmutable ( ) ; if ( newLines == <NUM_LIT:0> ) { newLines = printJavadocBlockNodesNewLines ( block , node , previousEnd ) ; } int nodeStart = node . sourceStart ; if ( newLines > <NUM_LIT:0> || ( idx > <NUM_LIT:1> && nodeStart > ( previousEnd + <NUM_LIT:1> ) ) ) { printJavadocGapLines ( previousEnd + <NUM_LIT:1> , nodeStart - <NUM_LIT:1> , newLines , clearBlankLines , false , null ) ; } if ( newLines > <NUM_LIT:0> ) textOnNewLine = true ; buffer . setLength ( <NUM_LIT:0> ) ; if ( node . isText ( ) ) { if ( immutable ) { if ( textOnNewLine && this . commentIndentation != null ) { addInsertEdit ( node . sourceStart , this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; } printJavadocImmutableText ( htmlTag , block , textOnNewLine ) ; this . column += getTextLength ( block , htmlTag ) ; linesAfter = <NUM_LIT:0> ; } else { linesAfter = printJavadocHtmlTag ( htmlTag , block , textOnNewLine ) ; } nodeKind = <NUM_LIT:1> ; } else { if ( textOnNewLine && this . commentIndentation != null ) { addInsertEdit ( node . sourceStart , this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; } printJavadocBlock ( ( FormatJavadocBlock ) node ) ; linesAfter = <NUM_LIT:0> ; nodeKind = <NUM_LIT:2> ; } textStart = node . sourceEnd + <NUM_LIT:1> ; ptr ++ ; if ( idx > max ) { return linesAfter ; } } else { if ( idx > <NUM_LIT:0> && linesAfter > <NUM_LIT:0> ) { printJavadocGapLines ( previousEnd + <NUM_LIT:1> , nextStart - <NUM_LIT:1> , linesAfter , clearBlankLines , false , buffer ) ; textOnNewLine = true ; } boolean needIndentation = textOnNewLine ; if ( idx > <NUM_LIT:0> ) { if ( ! needIndentation && text . isTextAfterHtmlSeparatorTag ( idx - <NUM_LIT:1> ) ) { needIndentation = true ; } } this . needSpace = idx > <NUM_LIT:1> && ( previousEnd + <NUM_LIT:1> ) < nextStart ; printJavadocTextLine ( buffer , nextStart , end , block , idx == <NUM_LIT:0> , needIndentation , idx == <NUM_LIT:0> || text . htmlIndexes [ idx - <NUM_LIT:1> ] != - <NUM_LIT:1> ) ; linesAfter = <NUM_LIT:0> ; if ( idx == <NUM_LIT:0> ) { if ( isHtmlSeparatorTag ) { linesAfter = <NUM_LIT:1> ; } } else if ( text . htmlIndexes [ idx - <NUM_LIT:1> ] == JAVADOC_SINGLE_BREAK_TAG_ID ) { linesAfter = <NUM_LIT:1> ; } } nextStart = ( int ) text . separators [ idx ] ; int endLine = Util . getLineNumber ( end , this . lineEnds , startLine - <NUM_LIT:1> , this . maxLines ) ; startLine = Util . getLineNumber ( nextStart , this . lineEnds , endLine - <NUM_LIT:1> , this . maxLines ) ; int linesGap = startLine - endLine ; if ( linesGap > <NUM_LIT:0> ) { if ( clearBlankLines ) { } else { if ( idx == <NUM_LIT:0> || linesGap > <NUM_LIT:1> || ( idx < max && nodeKind == <NUM_LIT:1> && ( text . htmlIndexes [ idx - <NUM_LIT:1> ] & JAVADOC_TAGS_ID_MASK ) != JAVADOC_IMMUTABLE_TAGS_ID ) ) { if ( linesAfter < linesGap ) { linesAfter = linesGap ; } } } } textOnNewLine = linesAfter > <NUM_LIT:0> ; if ( isCode ) { int codeEnd = ( int ) ( text . separators [ max ] > > > <NUM_LIT:32> ) ; if ( codeEnd > end ) { if ( this . formatter . preferences . comment_format_source ) { if ( textStart < end ) addReplaceEdit ( textStart , end , buffer . toString ( ) ) ; if ( linesGap > <NUM_LIT:0> ) { int lineStart = this . scanner . getLineStart ( startLine ) ; if ( nextStart > lineStart ) { this . scanner . resetTo ( lineStart , nextStart - <NUM_LIT:1> ) ; try { int token = this . scanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameWHITESPACE ) { token = this . scanner . getNextToken ( ) ; } if ( token == TerminalTokens . TokenNameMULTIPLY ) { nextStart = this . scanner . currentPosition ; } } catch ( InvalidInputException iie ) { } } } int newLines = linesGap ; if ( newLines == <NUM_LIT:0> ) newLines = <NUM_LIT:1> ; this . needSpace = false ; printJavadocGapLines ( end + <NUM_LIT:1> , nextStart - <NUM_LIT:1> , newLines , false , false , null ) ; printCodeSnippet ( nextStart , codeEnd , linesGap ) ; nextStart = ( int ) text . separators [ max ] ; printJavadocGapLines ( codeEnd + <NUM_LIT:1> , nextStart - <NUM_LIT:1> , <NUM_LIT:1> , false , false , null ) ; return <NUM_LIT:2> ; } } else { nextStart = ( int ) text . separators [ max ] ; if ( ( nextStart - <NUM_LIT:1> ) > ( end + <NUM_LIT:1> ) ) { int line1 = Util . getLineNumber ( end + <NUM_LIT:1> , this . lineEnds , startLine - <NUM_LIT:1> , this . maxLines ) ; int line2 = Util . getLineNumber ( nextStart - <NUM_LIT:1> , this . lineEnds , line1 - <NUM_LIT:1> , this . maxLines ) ; int gapLines = line2 - line1 - <NUM_LIT:1> ; printJavadocGapLines ( end + <NUM_LIT:1> , nextStart - <NUM_LIT:1> , gapLines , false , false , null ) ; if ( gapLines > <NUM_LIT:0> ) textOnNewLine = true ; } } return <NUM_LIT:1> ; } previousEnd = end ; } boolean closingTag = isHtmlBreakTag || ( text . htmlIndexes != null && ( text . htmlIndexes [ max ] & JAVADOC_TAGS_ID_MASK ) == htmlTagID ) ; boolean isValidHtmlSeparatorTag = max > <NUM_LIT:0> && isHtmlSeparatorTag && closingTag ; if ( previousEnd != - <NUM_LIT:1> ) { if ( isValidHtmlSeparatorTag ) { if ( linesAfter == <NUM_LIT:0> ) linesAfter = <NUM_LIT:1> ; } if ( linesAfter > <NUM_LIT:0> ) { printJavadocGapLines ( previousEnd + <NUM_LIT:1> , nextStart - <NUM_LIT:1> , linesAfter , clearBlankLines , false , buffer ) ; textOnNewLine = linesAfter > <NUM_LIT:0> ; } } boolean needIndentation = textOnNewLine ; if ( ! needIndentation && ! isHtmlBreakTag && text . htmlIndexes != null && text . isTextAfterHtmlSeparatorTag ( max ) ) { needIndentation = true ; } this . needSpace = ! closingTag && max > <NUM_LIT:0> && ( previousEnd + <NUM_LIT:1> ) < nextStart ; printJavadocTextLine ( buffer , nextStart , text . sourceEnd , block , max <= <NUM_LIT:0> , needIndentation , closingTag ) ; if ( textStart < text . sourceEnd ) { addReplaceEdit ( textStart , text . sourceEnd , buffer . toString ( ) ) ; } this . needSpace = false ; this . scanner . resetTo ( text . sourceEnd + <NUM_LIT:1> , this . scannerEndPosition - <NUM_LIT:1> ) ; return isValidHtmlSeparatorTag ? <NUM_LIT:1> : <NUM_LIT:0> ; } private void printJavadocNewLine ( StringBuffer buffer ) { buffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( buffer ) ; buffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; this . line ++ ; this . lastNumberOfNewLines ++ ; } private void printJavadocText ( FormatJavadocText text , FormatJavadocBlock block , boolean textOnNewLine ) { boolean clearBlankLines = this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment ; boolean joinLines = this . formatter . preferences . join_lines_in_comments ; this . javadocTextBuffer . setLength ( <NUM_LIT:0> ) ; int textStart = text . sourceStart ; int nextStart = textStart ; int startLine = Util . getLineNumber ( textStart , this . lineEnds , <NUM_LIT:0> , this . maxLines ) ; for ( int idx = <NUM_LIT:0> , max = text . separatorsPtr ; idx <= max ; idx ++ ) { int end = ( int ) ( text . separators [ idx ] > > > <NUM_LIT:32> ) ; boolean needIndentation = textOnNewLine ; if ( idx > <NUM_LIT:0> ) { if ( ! needIndentation && text . isTextAfterHtmlSeparatorTag ( idx - <NUM_LIT:1> ) ) { needIndentation = true ; } } this . needSpace = idx > <NUM_LIT:0> ; printJavadocTextLine ( this . javadocTextBuffer , nextStart , end , block , idx == <NUM_LIT:0> || ( ! joinLines && textOnNewLine ) , needIndentation , false ) ; textOnNewLine = false ; nextStart = ( int ) text . separators [ idx ] ; if ( ! clearBlankLines || ! joinLines ) { int endLine = Util . getLineNumber ( end , this . lineEnds , startLine - <NUM_LIT:1> , this . maxLines ) ; startLine = Util . getLineNumber ( nextStart , this . lineEnds , endLine - <NUM_LIT:1> , this . maxLines ) ; int gapLine = endLine ; if ( joinLines ) gapLine ++ ; if ( startLine > gapLine ) { addReplaceEdit ( textStart , end , this . javadocTextBuffer . toString ( ) ) ; textStart = nextStart ; this . javadocTextBuffer . setLength ( <NUM_LIT:0> ) ; int newLines = startLine - endLine ; if ( clearBlankLines ) newLines = <NUM_LIT:1> ; printJavadocGapLines ( end + <NUM_LIT:1> , nextStart - <NUM_LIT:1> , newLines , this . formatter . preferences . comment_clear_blank_lines_in_javadoc_comment , false , null ) ; textOnNewLine = true ; } else if ( startLine > endLine ) { textOnNewLine = ! joinLines ; } } } boolean needIndentation = textOnNewLine ; this . needSpace = text . separatorsPtr >= <NUM_LIT:0> ; printJavadocTextLine ( this . javadocTextBuffer , nextStart , text . sourceEnd , block , text . separatorsPtr == - <NUM_LIT:1> , needIndentation , false ) ; addReplaceEdit ( textStart , text . sourceEnd , this . javadocTextBuffer . toString ( ) ) ; this . needSpace = false ; this . scanner . resetTo ( text . sourceEnd + <NUM_LIT:1> , this . scannerEndPosition - <NUM_LIT:1> ) ; } private void printJavadocTextLine ( StringBuffer buffer , int textStart , int textEnd , FormatJavadocBlock block , boolean firstText , boolean needIndentation , boolean isHtmlTag ) { boolean headerLine = block . isHeaderLine ( ) && this . lastNumberOfNewLines == <NUM_LIT:0> ; this . javadocTokensBuffer . setLength ( <NUM_LIT:0> ) ; int firstColumn = <NUM_LIT:1> + this . indentationLevel + BLOCK_LINE_PREFIX_LENGTH ; int maxColumn = this . formatter . preferences . comment_line_length + <NUM_LIT:1> ; if ( headerLine ) { firstColumn ++ ; maxColumn ++ ; } if ( needIndentation && this . commentIndentation != null ) { buffer . append ( this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; firstColumn += this . commentIndentation . length ( ) ; } if ( this . column < firstColumn ) { this . column = firstColumn ; } String newLineString = null ; try { this . scanner . resetTo ( textStart , textEnd ) ; this . scanner . skipComments = true ; int previousToken = - <NUM_LIT:1> ; boolean textOnNewLine = needIndentation ; while ( ! this . scanner . atEnd ( ) ) { int token ; try { token = this . scanner . getNextToken ( ) ; } catch ( InvalidInputException iie ) { token = consumeInvalidToken ( textEnd ) ; } int tokensBufferLength = this . javadocTokensBuffer . length ( ) ; int tokenStart = this . scanner . getCurrentTokenStartPosition ( ) ; int tokenLength = ( this . scanner . atEnd ( ) ? this . scanner . eofPosition : this . scanner . currentPosition ) - tokenStart ; boolean insertSpace = ( previousToken == TerminalTokens . TokenNameWHITESPACE || this . needSpace ) && ! textOnNewLine ; String tokensBufferString = this . javadocTokensBuffer . toString ( ) . trim ( ) ; switch ( token ) { case TerminalTokens . TokenNameWHITESPACE : if ( tokensBufferLength > <NUM_LIT:0> ) { boolean shouldSplit = ( this . column + tokensBufferLength ) > maxColumn && ! isHtmlTag && ( insertSpace || tokensBufferLength > <NUM_LIT:1> ) && tokensBufferString . charAt ( <NUM_LIT:0> ) != '<CHAR_LIT>' ; if ( shouldSplit ) { this . lastNumberOfNewLines ++ ; this . line ++ ; if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; if ( this . commentIndentation != null ) { this . tempBuffer . append ( this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; } firstColumn = this . column ; newLineString = this . tempBuffer . toString ( ) ; } else { this . column = firstColumn ; } buffer . append ( newLineString ) ; buffer . append ( tokensBufferString ) ; this . column += tokensBufferString . length ( ) ; if ( headerLine ) { firstColumn -- ; maxColumn -- ; headerLine = false ; } } else { buffer . append ( this . javadocTokensBuffer ) ; this . column += tokensBufferLength ; } this . javadocTokensBuffer . setLength ( <NUM_LIT:0> ) ; } textOnNewLine = false ; previousToken = token ; continue ; case TerminalTokens . TokenNameCharacterLiteral : if ( this . scanner . currentPosition > this . scanner . eofPosition ) { this . scanner . resetTo ( this . scanner . startPosition , textEnd ) ; this . scanner . getNextChar ( ) ; token = <NUM_LIT:1> ; } break ; } int lastColumn = this . column + tokensBufferLength + tokenLength ; if ( insertSpace ) lastColumn ++ ; boolean shouldSplit = lastColumn > maxColumn && ( ! isHtmlTag || previousToken == - <NUM_LIT:1> ) && token != TerminalTokens . TokenNameAT && ( tokensBufferLength == <NUM_LIT:0> || this . javadocTokensBuffer . charAt ( tokensBufferLength - <NUM_LIT:1> ) != '<CHAR_LIT>' ) ; if ( shouldSplit ) { if ( ( tokensBufferLength > <NUM_LIT:0> || tokenLength < maxColumn ) && ! isHtmlTag && tokensBufferLength > <NUM_LIT:0> && ( firstColumn + tokensBufferLength + tokenLength ) >= maxColumn ) { buffer . append ( this . javadocTokensBuffer ) ; this . column += tokensBufferLength ; this . javadocTokensBuffer . setLength ( <NUM_LIT:0> ) ; tokensBufferLength = <NUM_LIT:0> ; textOnNewLine = false ; } if ( ( tokensBufferLength > <NUM_LIT:0> || this . column > firstColumn ) && ( ! textOnNewLine || ! firstText ) ) { this . lastNumberOfNewLines ++ ; this . line ++ ; if ( newLineString == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . tempBuffer . append ( this . lineSeparator ) ; this . column = <NUM_LIT:1> ; printIndentationIfNecessary ( this . tempBuffer ) ; this . tempBuffer . append ( BLOCK_LINE_PREFIX ) ; this . column += BLOCK_LINE_PREFIX_LENGTH ; if ( this . commentIndentation != null ) { this . tempBuffer . append ( this . commentIndentation ) ; this . column += this . commentIndentation . length ( ) ; } firstColumn = this . column ; newLineString = this . tempBuffer . toString ( ) ; } else { this . column = firstColumn ; } buffer . append ( newLineString ) ; } if ( tokensBufferLength > <NUM_LIT:0> ) { String tokensString = tokensBufferString ; buffer . append ( tokensString ) ; this . column += tokensString . length ( ) ; this . javadocTokensBuffer . setLength ( <NUM_LIT:0> ) ; tokensBufferLength = <NUM_LIT:0> ; } buffer . append ( this . scanner . source , tokenStart , tokenLength ) ; this . column += tokenLength ; textOnNewLine = false ; if ( headerLine ) { firstColumn -- ; maxColumn -- ; headerLine = false ; } } else { if ( insertSpace ) { this . javadocTokensBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } this . javadocTokensBuffer . append ( this . scanner . source , tokenStart , tokenLength ) ; } previousToken = token ; this . needSpace = false ; if ( headerLine && lastColumn == maxColumn && this . scanner . atEnd ( ) ) { this . lastNumberOfNewLines ++ ; this . line ++ ; } } } finally { this . scanner . skipComments = false ; if ( this . javadocTokensBuffer . length ( ) > <NUM_LIT:0> ) { buffer . append ( this . javadocTokensBuffer ) ; this . column += this . javadocTokensBuffer . length ( ) ; } } } public void printModifiers ( Annotation [ ] annotations , ASTVisitor visitor ) { printModifiers ( annotations , visitor , ICodeFormatterConstants . ANNOTATION_UNSPECIFIED ) ; } public void printModifiers ( Annotation [ ] annotations , ASTVisitor visitor , int annotationSourceKind ) { try { int annotationsLength = annotations != null ? annotations . length : <NUM_LIT:0> ; int annotationsIndex = <NUM_LIT:0> ; boolean isFirstModifier = true ; int currentTokenStartPosition = this . scanner . currentPosition ; boolean hasComment = false ; boolean hasModifiers = false ; while ( ( this . currentToken = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { int foundTaskCount = this . scanner . foundTaskCount ; int tokenStartPosition = this . scanner . getCurrentTokenStartPosition ( ) ; int tokenEndPosition = this . scanner . getCurrentTokenEndPosition ( ) ; switch ( this . currentToken ) { case TerminalTokens . TokenNamepublic : case TerminalTokens . TokenNameprotected : case TerminalTokens . TokenNameprivate : case TerminalTokens . TokenNamestatic : case TerminalTokens . TokenNameabstract : case TerminalTokens . TokenNamefinal : case TerminalTokens . TokenNamenative : case TerminalTokens . TokenNamesynchronized : case TerminalTokens . TokenNametransient : case TerminalTokens . TokenNamevolatile : case TerminalTokens . TokenNamestrictfp : hasModifiers = true ; print ( this . scanner . currentPosition - this . scanner . startPosition , ! isFirstModifier ) ; isFirstModifier = false ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameAT : hasModifiers = true ; if ( ! isFirstModifier ) { space ( ) ; } this . scanner . resetTo ( this . scanner . getCurrentTokenStartPosition ( ) , this . scannerEndPosition - <NUM_LIT:1> ) ; if ( annotationsIndex < annotationsLength ) { boolean insertSpaceBeforeBrace = this . formatter . preferences . insert_space_before_opening_brace_in_array_initializer ; this . formatter . preferences . insert_space_before_opening_brace_in_array_initializer = false ; try { annotations [ annotationsIndex ++ ] . traverse ( visitor , ( BlockScope ) null ) ; } finally { this . formatter . preferences . insert_space_before_opening_brace_in_array_initializer = insertSpaceBeforeBrace ; } boolean shouldAddNewLine = false ; switch ( annotationSourceKind ) { case ICodeFormatterConstants . ANNOTATION_ON_TYPE : if ( this . formatter . preferences . insert_new_line_after_annotation_on_type ) { shouldAddNewLine = true ; } break ; case ICodeFormatterConstants . ANNOTATION_ON_FIELD : if ( this . formatter . preferences . insert_new_line_after_annotation_on_field ) { shouldAddNewLine = true ; } break ; case ICodeFormatterConstants . ANNOTATION_ON_METHOD : if ( this . formatter . preferences . insert_new_line_after_annotation_on_method ) { shouldAddNewLine = true ; } break ; case ICodeFormatterConstants . ANNOTATION_ON_PACKAGE : if ( this . formatter . preferences . insert_new_line_after_annotation_on_package ) { shouldAddNewLine = true ; } break ; case ICodeFormatterConstants . ANNOTATION_ON_PARAMETER : if ( this . formatter . preferences . insert_new_line_after_annotation_on_parameter ) { shouldAddNewLine = true ; } break ; case ICodeFormatterConstants . ANNOTATION_ON_LOCAL_VARIABLE : if ( this . formatter . preferences . insert_new_line_after_annotation_on_local_variable ) { shouldAddNewLine = true ; } break ; default : } if ( shouldAddNewLine ) { this . printNewLine ( ) ; } } else { return ; } isFirstModifier = false ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : if ( this . useTags && this . editsEnabled ) { boolean turnOff = false ; if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; turnOff = true ; } else if ( this . tagsKind == this . currentToken && CharOperation . equals ( this . disablingTag , this . scanner . source , tokenStartPosition , tokenEndPosition + <NUM_LIT:1> ) ) { this . editsEnabled = false ; turnOff = true ; } if ( turnOff ) { if ( ! this . editsEnabled && this . editsIndex > <NUM_LIT:1> ) { OptimizedReplaceEdit currentEdit = this . edits [ this . editsIndex - <NUM_LIT:1> ] ; if ( this . scanner . startPosition == currentEdit . offset + currentEdit . length ) { printNewLinesBeforeDisablingComment ( ) ; } } } } printBlockComment ( this . currentToken == TerminalTokens . TokenNameCOMMENT_JAVADOC ) ; if ( this . useTags && ! this . editsEnabled ) { if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; } else if ( this . tagsKind == this . currentToken ) { this . editsEnabled = CharOperation . equals ( this . enablingTag , this . scanner . source , tokenStartPosition , tokenEndPosition + <NUM_LIT:1> ) ; } } currentTokenStartPosition = this . scanner . currentPosition ; hasComment = true ; break ; case TerminalTokens . TokenNameCOMMENT_LINE : tokenEndPosition = - this . scanner . commentStops [ this . scanner . commentPtr ] ; if ( this . useTags && this . editsEnabled ) { boolean turnOff = false ; if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; turnOff = true ; } else if ( this . tagsKind == this . currentToken && CharOperation . equals ( this . disablingTag , this . scanner . source , tokenStartPosition , tokenEndPosition ) ) { this . editsEnabled = false ; turnOff = true ; } if ( turnOff ) { if ( ! this . editsEnabled && this . editsIndex > <NUM_LIT:1> ) { OptimizedReplaceEdit currentEdit = this . edits [ this . editsIndex - <NUM_LIT:1> ] ; if ( this . scanner . startPosition == currentEdit . offset + currentEdit . length ) { printNewLinesBeforeDisablingComment ( ) ; } } } } printLineComment ( ) ; if ( this . useTags && ! this . editsEnabled ) { if ( foundTaskCount > <NUM_LIT:0> ) { setEditsEnabled ( foundTaskCount ) ; } else if ( this . tagsKind == this . currentToken ) { this . editsEnabled = CharOperation . equals ( this . enablingTag , this . scanner . source , tokenStartPosition , tokenEndPosition ) ; } } currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameWHITESPACE : addDeleteEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . scanner . getCurrentTokenEndPosition ( ) ) ; int count = <NUM_LIT:0> ; char [ ] whiteSpaces = this . scanner . getCurrentTokenSource ( ) ; for ( int i = <NUM_LIT:0> , max = whiteSpaces . length ; i < max ; i ++ ) { switch ( whiteSpaces [ i ] ) { case '<STR_LIT>' : if ( ( i + <NUM_LIT:1> ) < max ) { if ( whiteSpaces [ i + <NUM_LIT:1> ] == '<STR_LIT:\n>' ) { i ++ ; } } count ++ ; break ; case '<STR_LIT:\n>' : count ++ ; } } if ( count >= <NUM_LIT:1> && hasComment ) { printNewLine ( ) ; } currentTokenStartPosition = this . scanner . currentPosition ; hasComment = false ; break ; default : if ( hasModifiers ) { space ( ) ; } this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } } } catch ( InvalidInputException e ) { throw new AbortFormatting ( e ) ; } } public void printNewLine ( ) { this . printNewLine ( this . scanner . getCurrentTokenEndPosition ( ) + <NUM_LIT:1> ) ; } public void printNewLine ( int insertPosition ) { if ( this . nlsTagCounter > <NUM_LIT:0> ) { return ; } if ( this . lastNumberOfNewLines >= <NUM_LIT:1> ) { if ( ! this . preserveLineBreakIndentation ) { this . column = <NUM_LIT:1> ; } this . preserveLineBreakIndentation = false ; return ; } addInsertEdit ( insertPosition , this . lineSeparator ) ; this . line ++ ; this . lastNumberOfNewLines = <NUM_LIT:1> ; this . column = <NUM_LIT:1> ; this . needSpace = false ; this . pendingSpace = false ; this . preserveLineBreakIndentation = false ; this . lastLineComment . contiguous = false ; } private void printNewLinesBeforeDisablingComment ( ) { int linePtr = Arrays . binarySearch ( this . lineEnds , this . scanner . startPosition ) ; if ( linePtr < <NUM_LIT:0> ) { linePtr = - linePtr - <NUM_LIT:1> ; } int indentation = <NUM_LIT:0> ; int beginningOfLine = getLineEnd ( linePtr ) + <NUM_LIT:1> ; if ( beginningOfLine == - <NUM_LIT:1> ) { beginningOfLine = <NUM_LIT:0> ; } OptimizedReplaceEdit currentEdit = this . edits [ this . editsIndex - <NUM_LIT:1> ] ; int offset = currentEdit . offset ; if ( offset >= beginningOfLine ) return ; int scannerStartPosition = this . scanner . startPosition ; int scannerEofPosition = this . scanner . eofPosition ; int scannerCurrentPosition = this . scanner . currentPosition ; char scannerCurrentChar = this . scanner . currentCharacter ; int length = currentEdit . length ; this . scanner . resetTo ( beginningOfLine , offset + length - <NUM_LIT:1> ) ; try { while ( ! this . scanner . atEnd ( ) ) { char ch = ( char ) this . scanner . getNextChar ( ) ; switch ( ch ) { case '<STR_LIT:\t>' : if ( this . tabLength != <NUM_LIT:0> ) { int reminder = indentation % this . tabLength ; if ( reminder == <NUM_LIT:0> ) { indentation += this . tabLength ; } else { indentation = ( ( indentation / this . tabLength ) + <NUM_LIT:1> ) * this . tabLength ; } } break ; case '<CHAR_LIT:U+0020>' : indentation ++ ; break ; default : return ; } } String indentationString ; int currentIndentation = getCurrentIndentation ( this . scanner . currentPosition ) ; if ( currentIndentation > <NUM_LIT:0> && this . indentationLevel > <NUM_LIT:0> ) { int col = this . column ; this . tempBuffer . setLength ( <NUM_LIT:0> ) ; printIndentationIfNecessary ( this . tempBuffer ) ; indentationString = this . tempBuffer . toString ( ) ; this . column = col ; } else { indentationString = Util . EMPTY_STRING ; } String replacement = currentEdit . replacement ; if ( replacement . length ( ) == <NUM_LIT:0> ) { this . edits [ this . editsIndex - <NUM_LIT:1> ] = new OptimizedReplaceEdit ( beginningOfLine , offset + length - beginningOfLine , indentationString ) ; } else { int idx = replacement . lastIndexOf ( this . lineSeparator ) ; if ( idx >= <NUM_LIT:0> ) { int start = idx + this . lsLength ; this . tempBuffer . setLength ( <NUM_LIT:0> ) ; this . tempBuffer . append ( replacement . substring ( <NUM_LIT:0> , start ) ) ; if ( indentationString != Util . EMPTY_STRING ) { this . tempBuffer . append ( indentationString ) ; } this . edits [ this . editsIndex - <NUM_LIT:1> ] = new OptimizedReplaceEdit ( offset , length , this . tempBuffer . toString ( ) ) ; } } } finally { this . scanner . startPosition = scannerStartPosition ; this . scanner . eofPosition = scannerEofPosition ; this . scanner . currentPosition = scannerCurrentPosition ; this . scanner . currentCharacter = scannerCurrentChar ; } } private boolean printNewLinesCharacters ( int offset , int length ) { boolean foundNewLine = false ; int scannerStartPosition = this . scanner . startPosition ; int scannerEofPosition = this . scanner . eofPosition ; int scannerCurrentPosition = this . scanner . currentPosition ; char scannerCurrentChar = this . scanner . currentCharacter ; this . scanner . resetTo ( offset , offset + length - <NUM_LIT:1> ) ; try { while ( ! this . scanner . atEnd ( ) ) { int start = this . scanner . currentPosition ; char ch = ( char ) this . scanner . getNextChar ( ) ; boolean needReplace = ch != this . firstLS ; switch ( ch ) { case '<STR_LIT>' : if ( this . scanner . atEnd ( ) ) break ; ch = ( char ) this . scanner . getNextChar ( ) ; if ( ch != '<STR_LIT:\n>' ) break ; needReplace = needReplace || this . lsLength != <NUM_LIT:2> ; case '<STR_LIT:\n>' : if ( needReplace ) { if ( this . editsIndex == <NUM_LIT:0> || this . edits [ this . editsIndex - <NUM_LIT:1> ] . offset != start ) { this . edits [ this . editsIndex ++ ] = new OptimizedReplaceEdit ( start , this . scanner . currentPosition - start , this . lineSeparator ) ; } } foundNewLine = true ; break ; } } } finally { this . scanner . startPosition = scannerStartPosition ; this . scanner . eofPosition = scannerEofPosition ; this . scanner . currentPosition = scannerCurrentPosition ; this . scanner . currentCharacter = scannerCurrentChar ; } return foundNewLine ; } public void printNextToken ( int expectedTokenType ) { printNextToken ( expectedTokenType , false ) ; } public void printNextToken ( int expectedTokenType , boolean considerSpaceIfAny ) { printNextToken ( expectedTokenType , considerSpaceIfAny , PRESERVE_EMPTY_LINES_KEEP_LAST_NEW_LINES_INDENTATION ) ; } public void printNextToken ( int expectedTokenType , boolean considerSpaceIfAny , int emptyLineRules ) { printComment ( CodeFormatter . K_UNKNOWN , NO_TRAILING_COMMENT , emptyLineRules ) ; try { this . currentToken = this . scanner . getNextToken ( ) ; if ( expectedTokenType != this . currentToken ) { throw new AbortFormatting ( "<STR_LIT>" + expectedTokenType + "<STR_LIT>" + this . currentToken ) ; } print ( this . scanner . currentPosition - this . scanner . startPosition , considerSpaceIfAny ) ; } catch ( InvalidInputException e ) { throw new AbortFormatting ( e ) ; } } public void printNextToken ( int [ ] expectedTokenTypes ) { printNextToken ( expectedTokenTypes , false ) ; } public void printNextToken ( int [ ] expectedTokenTypes , boolean considerSpaceIfAny ) { printComment ( CodeFormatter . K_UNKNOWN , NO_TRAILING_COMMENT ) ; try { this . currentToken = this . scanner . getNextToken ( ) ; if ( Arrays . binarySearch ( expectedTokenTypes , this . currentToken ) < <NUM_LIT:0> ) { StringBuffer expectations = new StringBuffer ( <NUM_LIT:5> ) ; for ( int i = <NUM_LIT:0> ; i < expectedTokenTypes . length ; i ++ ) { if ( i > <NUM_LIT:0> ) { expectations . append ( '<CHAR_LIT:U+002C>' ) ; } expectations . append ( expectedTokenTypes [ i ] ) ; } throw new AbortFormatting ( "<STR_LIT>" + expectations . toString ( ) + "<STR_LIT>" + this . currentToken ) ; } print ( this . scanner . currentPosition - this . scanner . startPosition , considerSpaceIfAny ) ; } catch ( InvalidInputException e ) { throw new AbortFormatting ( e ) ; } } public void printArrayQualifiedReference ( int numberOfTokens , int sourceEnd ) { int currentTokenStartPosition = this . scanner . currentPosition ; int numberOfIdentifiers = <NUM_LIT:0> ; try { do { printComment ( CodeFormatter . K_UNKNOWN , NO_TRAILING_COMMENT ) ; switch ( this . currentToken = this . scanner . getNextToken ( ) ) { case TerminalTokens . TokenNameEOF : return ; case TerminalTokens . TokenNameWHITESPACE : addDeleteEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . scanner . getCurrentTokenEndPosition ( ) ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : printBlockComment ( false ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameCOMMENT_LINE : printLineComment ( ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameIdentifier : print ( this . scanner . currentPosition - this . scanner . startPosition , false ) ; currentTokenStartPosition = this . scanner . currentPosition ; if ( ++ numberOfIdentifiers == numberOfTokens ) { this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } break ; case TerminalTokens . TokenNameDOT : print ( this . scanner . currentPosition - this . scanner . startPosition , false ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameRPAREN : currentTokenStartPosition = this . scanner . startPosition ; default : this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } } while ( this . scanner . currentPosition <= sourceEnd ) ; } catch ( InvalidInputException e ) { throw new AbortFormatting ( e ) ; } } public void printQualifiedReference ( int sourceEnd , boolean expectParenthesis ) { int currentTokenStartPosition = this . scanner . currentPosition ; try { do { printComment ( CodeFormatter . K_UNKNOWN , NO_TRAILING_COMMENT ) ; switch ( this . currentToken = this . scanner . getNextToken ( ) ) { case TerminalTokens . TokenNameEOF : return ; case TerminalTokens . TokenNameWHITESPACE : addDeleteEdit ( this . scanner . getCurrentTokenStartPosition ( ) , this . scanner . getCurrentTokenEndPosition ( ) ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : printBlockComment ( false ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameCOMMENT_LINE : printLineComment ( ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameIdentifier : case TerminalTokens . TokenNameDOT : print ( this . scanner . currentPosition - this . scanner . startPosition , false ) ; currentTokenStartPosition = this . scanner . currentPosition ; break ; case TerminalTokens . TokenNameRPAREN : if ( expectParenthesis ) { currentTokenStartPosition = this . scanner . startPosition ; } default : this . scanner . resetTo ( currentTokenStartPosition , this . scannerEndPosition - <NUM_LIT:1> ) ; return ; } } while ( this . scanner . currentPosition <= sourceEnd ) ; } catch ( InvalidInputException e ) { throw new AbortFormatting ( e ) ; } } private void printRule ( StringBuffer stringBuffer ) { for ( int i = <NUM_LIT:0> ; i < this . pageWidth ; i ++ ) { if ( ( i % this . tabLength ) == <NUM_LIT:0> ) { stringBuffer . append ( '<CHAR_LIT>' ) ; } else { stringBuffer . append ( '<CHAR_LIT:->' ) ; } } stringBuffer . append ( this . lineSeparator ) ; for ( int i = <NUM_LIT:0> ; i < ( this . pageWidth / this . tabLength ) ; i ++ ) { stringBuffer . append ( i ) ; stringBuffer . append ( '<STR_LIT:\t>' ) ; } } void redoAlignment ( AlignmentException e ) { if ( e . relativeDepth > <NUM_LIT:0> ) { e . relativeDepth -- ; this . currentAlignment = this . currentAlignment . enclosing ; throw e ; } resetAt ( this . currentAlignment . location ) ; this . scanner . resetTo ( this . currentAlignment . location . inputOffset , this . scanner . eofPosition - <NUM_LIT:1> ) ; this . currentAlignment . chunkKind = <NUM_LIT:0> ; } void redoMemberAlignment ( AlignmentException e ) { resetAt ( this . memberAlignment . location ) ; this . scanner . resetTo ( this . memberAlignment . location . inputOffset , this . scanner . eofPosition - <NUM_LIT:1> ) ; this . memberAlignment . chunkKind = <NUM_LIT:0> ; } public void reset ( ) { this . checkLineWrapping = true ; this . line = <NUM_LIT:0> ; this . column = <NUM_LIT:1> ; this . editsIndex = <NUM_LIT:0> ; this . nlsTagCounter = <NUM_LIT:0> ; } private void resetAt ( Location location ) { this . line = location . outputLine ; this . column = location . outputColumn ; this . indentationLevel = location . outputIndentationLevel ; this . numberOfIndentations = location . numberOfIndentations ; this . lastNumberOfNewLines = location . lastNumberOfNewLines ; this . needSpace = location . needSpace ; this . pendingSpace = location . pendingSpace ; this . editsIndex = location . editsIndex ; this . nlsTagCounter = location . nlsTagCounter ; if ( this . editsIndex > <NUM_LIT:0> ) { this . edits [ this . editsIndex - <NUM_LIT:1> ] = location . textEdit ; } this . formatter . lastLocalDeclarationSourceStart = location . lastLocalDeclarationSourceStart ; } public void resetScanner ( char [ ] compilationUnitSource ) { this . scanner . setSource ( compilationUnitSource ) ; this . scannerEndPosition = compilationUnitSource . length ; this . scanner . resetTo ( <NUM_LIT:0> , this . scannerEndPosition - <NUM_LIT:1> ) ; this . edits = new OptimizedReplaceEdit [ INITIAL_SIZE ] ; this . maxLines = this . lineEnds == null ? - <NUM_LIT:1> : this . lineEnds . length - <NUM_LIT:1> ; this . scanner . lineEnds = this . lineEnds ; this . scanner . linePtr = this . maxLines ; initFormatterCommentParser ( ) ; } private void resize ( ) { System . arraycopy ( this . edits , <NUM_LIT:0> , ( this . edits = new OptimizedReplaceEdit [ this . editsIndex * <NUM_LIT:2> ] ) , <NUM_LIT:0> , this . editsIndex ) ; } private void setCommentIndentation ( int commentIndentationLevel ) { if ( commentIndentationLevel == <NUM_LIT:0> ) { this . commentIndentation = null ; } else { int length = COMMENT_INDENTATIONS . length ; if ( commentIndentationLevel > length ) { System . arraycopy ( COMMENT_INDENTATIONS , <NUM_LIT:0> , COMMENT_INDENTATIONS = new String [ commentIndentationLevel + <NUM_LIT:10> ] , <NUM_LIT:0> , length ) ; } this . commentIndentation = COMMENT_INDENTATIONS [ commentIndentationLevel - <NUM_LIT:1> ] ; if ( this . commentIndentation == null ) { this . tempBuffer . setLength ( <NUM_LIT:0> ) ; for ( int i = <NUM_LIT:0> ; i < commentIndentationLevel ; i ++ ) { this . tempBuffer . append ( '<CHAR_LIT:U+0020>' ) ; } this . commentIndentation = this . tempBuffer . toString ( ) ; COMMENT_INDENTATIONS [ commentIndentationLevel - <NUM_LIT:1> ] = this . commentIndentation ; } } } private void setEditsEnabled ( int count ) { for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { if ( this . disablingTag != null && CharOperation . equals ( this . scanner . foundTaskTags [ i ] , this . disablingTag ) ) { this . editsEnabled = false ; } if ( this . enablingTag != null && CharOperation . equals ( this . scanner . foundTaskTags [ i ] , this . enablingTag ) ) { this . editsEnabled = true ; } } } void setIncludeComments ( boolean on ) { if ( on ) { this . formatComments |= CodeFormatter . F_INCLUDE_COMMENTS ; } else { this . formatComments &= ~ CodeFormatter . F_INCLUDE_COMMENTS ; } } void setHeaderComment ( int position ) { this . headerEndPosition = position ; } public void space ( ) { if ( ! this . needSpace ) return ; this . lastNumberOfNewLines = <NUM_LIT:0> ; this . pendingSpace = true ; this . column ++ ; this . needSpace = false ; } public String toString ( ) { StringBuffer stringBuffer = new StringBuffer ( ) ; stringBuffer . append ( "<STR_LIT>" + this . pageWidth + "<STR_LIT>" ) ; switch ( this . tabChar ) { case DefaultCodeFormatterOptions . TAB : stringBuffer . append ( "<STR_LIT>" ) ; break ; case DefaultCodeFormatterOptions . SPACE : stringBuffer . append ( "<STR_LIT>" ) ; break ; default : stringBuffer . append ( "<STR_LIT>" ) ; } stringBuffer . append ( "<STR_LIT>" + this . tabLength + "<STR_LIT:)>" ) . append ( this . lineSeparator ) . append ( "<STR_LIT>" + this . line + "<STR_LIT>" + this . column + "<STR_LIT>" + this . indentationLevel + "<STR_LIT:)>" ) . append ( this . lineSeparator ) . append ( "<STR_LIT>" + this . needSpace + "<STR_LIT>" + this . lastNumberOfNewLines + "<STR_LIT>" + this . checkLineWrapping + "<STR_LIT:)>" ) . append ( this . lineSeparator ) . append ( "<STR_LIT>" ) . append ( this . lineSeparator ) ; if ( this . tabLength > <NUM_LIT:0> ) { printRule ( stringBuffer ) ; } return stringBuffer . toString ( ) ; } public void unIndent ( ) { this . indentationLevel -= this . indentationSize ; this . numberOfIndentations -- ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; public interface ICodeFormatterConstants { public static final int ANNOTATION_UNSPECIFIED = <NUM_LIT:0> ; public static final int ANNOTATION_ON_TYPE = <NUM_LIT:1> ; public static final int ANNOTATION_ON_FIELD = <NUM_LIT:2> ; public static final int ANNOTATION_ON_METHOD = <NUM_LIT:3> ; public static final int ANNOTATION_ON_PACKAGE = <NUM_LIT:4> ; public static final int ANNOTATION_ON_PARAMETER = <NUM_LIT:5> ; public static final int ANNOTATION_ON_LOCAL_VARIABLE = <NUM_LIT:6> ; } </s>
<s> package org . eclipse . jdt . internal . formatter . old ; import java . util . Map ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . formatter . DefaultCodeFormatter ; import org . eclipse . text . edits . ReplaceEdit ; import org . eclipse . text . edits . TextEdit ; public class CodeFormatter implements TerminalTokens , org . eclipse . jdt . core . ICodeFormatter { private Map options ; public CodeFormatter ( Map options ) { if ( options == null ) { this . options = JavaCore . getOptions ( ) ; } else { this . options = options ; } } public String format ( String string , int indentLevel , int [ ] positions , String lineSeparator ) { Map newOptions = DefaultCodeFormatterConstants . getEclipse21Settings ( ) ; Object formatterNewLineOpeningBrace = this . options . get ( JavaCore . FORMATTER_NEWLINE_OPENING_BRACE ) ; if ( formatterNewLineOpeningBrace != null ) { if ( JavaCore . INSERT . equals ( formatterNewLineOpeningBrace ) ) { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION , DefaultCodeFormatterConstants . NEXT_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_BLOCK , DefaultCodeFormatterConstants . NEXT_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION , DefaultCodeFormatterConstants . NEXT_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION , DefaultCodeFormatterConstants . NEXT_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_SWITCH , DefaultCodeFormatterConstants . NEXT_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION , DefaultCodeFormatterConstants . NEXT_LINE ) ; } else { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION , DefaultCodeFormatterConstants . END_OF_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_BLOCK , DefaultCodeFormatterConstants . END_OF_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION , DefaultCodeFormatterConstants . END_OF_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION , DefaultCodeFormatterConstants . END_OF_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_SWITCH , DefaultCodeFormatterConstants . END_OF_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION , DefaultCodeFormatterConstants . END_OF_LINE ) ; } } Object formatterNewLineControl = this . options . get ( JavaCore . FORMATTER_NEWLINE_CONTROL ) ; if ( formatterNewLineControl != null ) { if ( JavaCore . INSERT . equals ( formatterNewLineControl ) ) { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT , JavaCore . INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT , JavaCore . INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT , JavaCore . INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT , JavaCore . INSERT ) ; } else { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT , JavaCore . DO_NOT_INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT , JavaCore . DO_NOT_INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT , JavaCore . DO_NOT_INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT , JavaCore . DO_NOT_INSERT ) ; } } Object formatterClearBlankLines = this . options . get ( JavaCore . FORMATTER_CLEAR_BLANK_LINES ) ; if ( formatterClearBlankLines != null ) { if ( JavaCore . PRESERVE_ONE . equals ( formatterClearBlankLines ) ) { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE , "<STR_LIT:1>" ) ; } else { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE , "<STR_LIT:0>" ) ; } } Object formatterNewLineElseIf = this . options . get ( JavaCore . FORMATTER_NEWLINE_ELSE_IF ) ; if ( formatterNewLineElseIf != null ) { if ( JavaCore . INSERT . equals ( formatterNewLineElseIf ) ) { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_COMPACT_ELSE_IF , DefaultCodeFormatterConstants . FALSE ) ; } else { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_COMPACT_ELSE_IF , DefaultCodeFormatterConstants . TRUE ) ; } } Object formatterNewLineEmptyBlock = this . options . get ( JavaCore . FORMATTER_NEWLINE_EMPTY_BLOCK ) ; if ( formatterNewLineEmptyBlock != null ) { if ( JavaCore . INSERT . equals ( formatterNewLineEmptyBlock ) ) { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK , JavaCore . INSERT ) ; } else { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK , JavaCore . DO_NOT_INSERT ) ; } } Object formatterCompactAssignment = this . options . get ( JavaCore . FORMATTER_COMPACT_ASSIGNMENT ) ; if ( formatterCompactAssignment != null ) { if ( JavaCore . COMPACT . equals ( formatterCompactAssignment ) ) { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR , JavaCore . DO_NOT_INSERT ) ; } else { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR , JavaCore . INSERT ) ; } } if ( this . options . get ( JavaCore . FORMATTER_SPACE_CASTEXPRESSION ) != null ) { if ( JavaCore . INSERT . equals ( this . options . get ( JavaCore . FORMATTER_SPACE_CASTEXPRESSION ) ) ) { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST , JavaCore . INSERT ) ; } else { newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST , JavaCore . DO_NOT_INSERT ) ; } } newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_TAB_CHAR , this . options . get ( JavaCore . FORMATTER_TAB_CHAR ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_TAB_SIZE , this . options . get ( JavaCore . FORMATTER_TAB_SIZE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_LINE_SPLIT , this . options . get ( JavaCore . FORMATTER_LINE_SPLIT ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER , DefaultCodeFormatterConstants . END_OF_LINE ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_CONTINUATION_INDENTATION , "<STR_LIT:1>" ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION , DefaultCodeFormatterConstants . createAlignmentValue ( false , DefaultCodeFormatterConstants . WRAP_ONE_PER_LINE , DefaultCodeFormatterConstants . INDENT_BY_ONE ) ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER , JavaCore . INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER , JavaCore . INSERT ) ; newOptions . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER , JavaCore . INSERT ) ; DefaultCodeFormatter defaultCodeFormatter = new DefaultCodeFormatter ( newOptions ) ; TextEdit textEdit = defaultCodeFormatter . format ( org . eclipse . jdt . core . formatter . CodeFormatter . K_UNKNOWN , string , <NUM_LIT:0> , string . length ( ) , indentLevel , lineSeparator ) ; if ( positions != null && textEdit != null ) { TextEdit [ ] edits = textEdit . getChildren ( ) ; int textEditSize = edits . length ; int editsIndex = <NUM_LIT:0> ; int delta = <NUM_LIT:0> ; int originalSourceLength = string . length ( ) - <NUM_LIT:1> ; if ( textEditSize != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> , max = positions . length ; i < max ; i ++ ) { int currentPosition = positions [ i ] ; if ( currentPosition > originalSourceLength ) { currentPosition = originalSourceLength ; } ReplaceEdit currentEdit = ( ReplaceEdit ) edits [ editsIndex ] ; while ( currentEdit . getOffset ( ) <= currentPosition ) { delta += currentEdit . getText ( ) . length ( ) - currentEdit . getLength ( ) ; editsIndex ++ ; if ( editsIndex < textEditSize ) { currentEdit = ( ReplaceEdit ) edits [ editsIndex ] ; } else { break ; } } positions [ i ] = currentPosition + delta ; } } } return org . eclipse . jdt . internal . core . util . Util . editedString ( string , textEdit ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . ITerminalSymbols ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . core . formatter . CodeFormatter ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . util . CodeSnippetParsingUtil ; import org . eclipse . jface . text . IRegion ; import org . eclipse . jface . text . Region ; import org . eclipse . text . edits . TextEdit ; public class DefaultCodeFormatter extends CodeFormatter { public static boolean DEBUG = false ; private static final int K_MASK = K_UNKNOWN | K_EXPRESSION | K_STATEMENTS | K_CLASS_BODY_DECLARATIONS | K_COMPILATION_UNIT | K_SINGLE_LINE_COMMENT | K_MULTI_LINE_COMMENT | K_JAVA_DOC ; private static Scanner PROBING_SCANNER ; private CodeSnippetParsingUtil codeSnippetParsingUtil ; private Map defaultCompilerOptions ; private CodeFormatterVisitor newCodeFormatter ; private Map options ; private DefaultCodeFormatterOptions preferences ; public DefaultCodeFormatter ( ) { this ( new DefaultCodeFormatterOptions ( DefaultCodeFormatterConstants . getJavaConventionsSettings ( ) ) , null ) ; } public DefaultCodeFormatter ( DefaultCodeFormatterOptions preferences ) { this ( preferences , null ) ; } public DefaultCodeFormatter ( DefaultCodeFormatterOptions defaultCodeFormatterOptions , Map options ) { if ( options != null ) { this . options = options ; this . preferences = new DefaultCodeFormatterOptions ( options ) ; } else { this . options = JavaCore . getOptions ( ) ; this . preferences = new DefaultCodeFormatterOptions ( DefaultCodeFormatterConstants . getJavaConventionsSettings ( ) ) ; } this . defaultCompilerOptions = getDefaultCompilerOptions ( ) ; if ( defaultCodeFormatterOptions != null ) { this . preferences . set ( defaultCodeFormatterOptions . getMap ( ) ) ; } } public DefaultCodeFormatter ( Map options ) { this ( null , options ) ; } public String createIndentationString ( final int indentationLevel ) { if ( indentationLevel < <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } int tabs = <NUM_LIT:0> ; int spaces = <NUM_LIT:0> ; switch ( this . preferences . tab_char ) { case DefaultCodeFormatterOptions . SPACE : spaces = indentationLevel * this . preferences . tab_size ; break ; case DefaultCodeFormatterOptions . TAB : tabs = indentationLevel ; break ; case DefaultCodeFormatterOptions . MIXED : int tabSize = this . preferences . tab_size ; if ( tabSize != <NUM_LIT:0> ) { int spaceEquivalents = indentationLevel * this . preferences . indentation_size ; tabs = spaceEquivalents / tabSize ; spaces = spaceEquivalents % tabSize ; } break ; default : return Util . EMPTY_STRING ; } if ( tabs == <NUM_LIT:0> && spaces == <NUM_LIT:0> ) { return Util . EMPTY_STRING ; } StringBuffer buffer = new StringBuffer ( tabs + spaces ) ; for ( int i = <NUM_LIT:0> ; i < tabs ; i ++ ) { buffer . append ( '<STR_LIT:\t>' ) ; } for ( int i = <NUM_LIT:0> ; i < spaces ; i ++ ) { buffer . append ( '<CHAR_LIT:U+0020>' ) ; } return buffer . toString ( ) ; } public TextEdit format ( int kind , String source , int offset , int length , int indentationLevel , String lineSeparator ) { if ( offset < <NUM_LIT:0> || length < <NUM_LIT:0> || length > source . length ( ) ) { throw new IllegalArgumentException ( ) ; } switch ( kind & K_MASK ) { case K_JAVA_DOC : return formatComment ( kind & K_MASK , source , indentationLevel , lineSeparator , new IRegion [ ] { new Region ( offset , length ) } ) ; case K_MULTI_LINE_COMMENT : case K_SINGLE_LINE_COMMENT : return formatComment ( kind & K_MASK , source , indentationLevel , lineSeparator , new IRegion [ ] { new Region ( offset , length ) } ) ; } return format ( kind , source , new IRegion [ ] { new Region ( offset , length ) } , indentationLevel , lineSeparator ) ; } public TextEdit format ( int kind , String source , IRegion [ ] regions , int indentationLevel , String lineSeparator ) { if ( ! regionsSatisfiesPreconditions ( regions , source . length ( ) ) ) { throw new IllegalArgumentException ( ) ; } this . codeSnippetParsingUtil = new CodeSnippetParsingUtil ( ) ; boolean includeComments = ( kind & F_INCLUDE_COMMENTS ) != <NUM_LIT:0> ; switch ( kind & K_MASK ) { case K_CLASS_BODY_DECLARATIONS : return formatClassBodyDeclarations ( source , indentationLevel , lineSeparator , regions , includeComments ) ; case K_COMPILATION_UNIT : return formatCompilationUnit ( source , indentationLevel , lineSeparator , regions , includeComments ) ; case K_EXPRESSION : return formatExpression ( source , indentationLevel , lineSeparator , regions , includeComments ) ; case K_STATEMENTS : return formatStatements ( source , indentationLevel , lineSeparator , regions , includeComments ) ; case K_UNKNOWN : return probeFormatting ( source , indentationLevel , lineSeparator , regions , includeComments ) ; case K_JAVA_DOC : case K_MULTI_LINE_COMMENT : case K_SINGLE_LINE_COMMENT : throw new IllegalArgumentException ( ) ; } return null ; } private TextEdit formatClassBodyDeclarations ( String source , int indentationLevel , String lineSeparator , IRegion [ ] regions , boolean includeComments ) { ASTNode [ ] bodyDeclarations = this . codeSnippetParsingUtil . parseClassBodyDeclarations ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true ) ; if ( bodyDeclarations == null ) { return null ; } return internalFormatClassBodyDeclarations ( source , indentationLevel , lineSeparator , bodyDeclarations , regions , includeComments ) ; } private TextEdit formatComment ( int kind , String source , int indentationLevel , String lineSeparator , IRegion [ ] regions ) { Object oldOption = oldCommentFormatOption ( ) ; boolean isFormattingComments = false ; if ( oldOption == null ) { switch ( kind & K_MASK ) { case K_SINGLE_LINE_COMMENT : isFormattingComments = DefaultCodeFormatterConstants . TRUE . equals ( this . options . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_LINE_COMMENT ) ) ; break ; case K_MULTI_LINE_COMMENT : isFormattingComments = DefaultCodeFormatterConstants . TRUE . equals ( this . options . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT ) ) ; break ; case K_JAVA_DOC : isFormattingComments = DefaultCodeFormatterConstants . TRUE . equals ( this . options . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT ) ) ; } } else { isFormattingComments = DefaultCodeFormatterConstants . TRUE . equals ( oldOption ) ; } if ( isFormattingComments ) { if ( lineSeparator != null ) { this . preferences . line_separator = lineSeparator ; } else { this . preferences . line_separator = Util . LINE_SEPARATOR ; } this . preferences . initial_indentation_level = indentationLevel ; if ( this . codeSnippetParsingUtil == null ) this . codeSnippetParsingUtil = new CodeSnippetParsingUtil ( ) ; this . codeSnippetParsingUtil . parseCompilationUnit ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true ) ; this . newCodeFormatter = new CodeFormatterVisitor ( this . preferences , this . options , regions , this . codeSnippetParsingUtil , true ) ; IRegion coveredRegion = getCoveredRegion ( regions ) ; int start = coveredRegion . getOffset ( ) ; int end = start + coveredRegion . getLength ( ) ; this . newCodeFormatter . formatComment ( kind , source , start , end , indentationLevel ) ; return this . newCodeFormatter . scribe . getRootEdit ( ) ; } return null ; } private TextEdit formatCompilationUnit ( String source , int indentationLevel , String lineSeparator , IRegion [ ] regions , boolean includeComments ) { CompilationUnitDeclaration compilationUnitDeclaration = this . codeSnippetParsingUtil . parseCompilationUnit ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true ) ; if ( lineSeparator != null ) { this . preferences . line_separator = lineSeparator ; } else { this . preferences . line_separator = Util . LINE_SEPARATOR ; } this . preferences . initial_indentation_level = indentationLevel ; this . newCodeFormatter = new CodeFormatterVisitor ( this . preferences , this . options , regions , this . codeSnippetParsingUtil , includeComments ) ; return this . newCodeFormatter . format ( source , compilationUnitDeclaration ) ; } private TextEdit formatExpression ( String source , int indentationLevel , String lineSeparator , IRegion [ ] regions , boolean includeComments ) { Expression expression = this . codeSnippetParsingUtil . parseExpression ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true ) ; if ( expression == null ) { return null ; } return internalFormatExpression ( source , indentationLevel , lineSeparator , expression , regions , includeComments ) ; } private TextEdit formatStatements ( String source , int indentationLevel , String lineSeparator , IRegion [ ] regions , boolean includeComments ) { ConstructorDeclaration constructorDeclaration = this . codeSnippetParsingUtil . parseStatements ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true , false ) ; if ( constructorDeclaration . statements == null ) { return null ; } return internalFormatStatements ( source , indentationLevel , lineSeparator , constructorDeclaration , regions , includeComments ) ; } private IRegion getCoveredRegion ( IRegion [ ] regions ) { int length = regions . length ; if ( length == <NUM_LIT:1> ) { return regions [ <NUM_LIT:0> ] ; } int offset = regions [ <NUM_LIT:0> ] . getOffset ( ) ; IRegion lastRegion = regions [ length - <NUM_LIT:1> ] ; return new Region ( offset , lastRegion . getOffset ( ) + lastRegion . getLength ( ) - offset ) ; } public String getDebugOutput ( ) { return this . newCodeFormatter . scribe . toString ( ) ; } private Map getDefaultCompilerOptions ( ) { if ( this . defaultCompilerOptions == null ) { Map optionsMap = new HashMap ( <NUM_LIT:30> ) ; optionsMap . put ( CompilerOptions . OPTION_LocalVariableAttribute , CompilerOptions . DO_NOT_GENERATE ) ; optionsMap . put ( CompilerOptions . OPTION_LineNumberAttribute , CompilerOptions . DO_NOT_GENERATE ) ; optionsMap . put ( CompilerOptions . OPTION_SourceFileAttribute , CompilerOptions . DO_NOT_GENERATE ) ; optionsMap . put ( CompilerOptions . OPTION_PreserveUnusedLocal , CompilerOptions . PRESERVE ) ; optionsMap . put ( CompilerOptions . OPTION_DocCommentSupport , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMethodWithConstructorName , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportOverridingPackageDefaultMethod , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportOverridingMethodWithoutSuperInvocation , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportDeprecation , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportDeprecationInDeprecatedCode , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportDeprecationWhenOverridingDeprecatedMethod , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportHiddenCatchBlock , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedLocal , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedObjectAllocation , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedParameter , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedImport , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportSyntheticAccessEmulation , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportNoEffectAssignment , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportNonExternalizedStringLiteral , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportNoImplicitStringConversion , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportNonStaticAccessToStatic , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportIndirectStaticAccess , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportIncompatibleNonInheritedInterfaceMethod , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedPrivateMember , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportLocalVariableHiding , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportFieldHiding , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportPossibleAccidentalBooleanAssignment , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportEmptyStatement , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportAssertIdentifier , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportEnumIdentifier , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUndocumentedEmptyBlock , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnnecessaryTypeCheck , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportInvalidJavadoc , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportInvalidJavadocTagsVisibility , CompilerOptions . PUBLIC ) ; optionsMap . put ( CompilerOptions . OPTION_ReportInvalidJavadocTags , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMissingJavadocTagDescription , CompilerOptions . RETURN_TAG ) ; optionsMap . put ( CompilerOptions . OPTION_ReportInvalidJavadocTagsDeprecatedRef , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportInvalidJavadocTagsNotVisibleRef , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMissingJavadocTags , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMissingJavadocTagsVisibility , CompilerOptions . PUBLIC ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMissingJavadocTagsOverriding , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMissingJavadocComments , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMissingJavadocCommentsVisibility , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMissingJavadocCommentsOverriding , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportFinallyBlockNotCompletingNormally , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedDeclaredThrownException , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnqualifiedFieldAccess , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_Compliance , CompilerOptions . VERSION_1_4 ) ; optionsMap . put ( CompilerOptions . OPTION_TargetPlatform , CompilerOptions . VERSION_1_2 ) ; optionsMap . put ( CompilerOptions . OPTION_TaskTags , Util . EMPTY_STRING ) ; optionsMap . put ( CompilerOptions . OPTION_TaskPriorities , Util . EMPTY_STRING ) ; optionsMap . put ( CompilerOptions . OPTION_TaskCaseSensitive , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedParameterWhenImplementingAbstract , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnusedParameterWhenOverridingConcrete , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportSpecialParameterHidingField , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportUnavoidableGenericTypeProblems , CompilerOptions . ENABLED ) ; optionsMap . put ( CompilerOptions . OPTION_MaxProblemPerUnit , String . valueOf ( <NUM_LIT:100> ) ) ; optionsMap . put ( CompilerOptions . OPTION_InlineJsr , CompilerOptions . DISABLED ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMethodCanBeStatic , CompilerOptions . IGNORE ) ; optionsMap . put ( CompilerOptions . OPTION_ReportMethodCanBePotentiallyStatic , CompilerOptions . IGNORE ) ; this . defaultCompilerOptions = optionsMap ; } Object sourceOption = this . options . get ( CompilerOptions . OPTION_Source ) ; if ( sourceOption != null ) { this . defaultCompilerOptions . put ( CompilerOptions . OPTION_Source , sourceOption ) ; } else { this . defaultCompilerOptions . put ( CompilerOptions . OPTION_Source , CompilerOptions . VERSION_1_3 ) ; } return this . defaultCompilerOptions ; } private TextEdit internalFormatClassBodyDeclarations ( String source , int indentationLevel , String lineSeparator , ASTNode [ ] bodyDeclarations , IRegion [ ] regions , boolean includeComments ) { if ( lineSeparator != null ) { this . preferences . line_separator = lineSeparator ; } else { this . preferences . line_separator = Util . LINE_SEPARATOR ; } this . preferences . initial_indentation_level = indentationLevel ; this . newCodeFormatter = new CodeFormatterVisitor ( this . preferences , this . options , regions , this . codeSnippetParsingUtil , includeComments ) ; return this . newCodeFormatter . format ( source , bodyDeclarations ) ; } private TextEdit internalFormatExpression ( String source , int indentationLevel , String lineSeparator , Expression expression , IRegion [ ] regions , boolean includeComments ) { if ( lineSeparator != null ) { this . preferences . line_separator = lineSeparator ; } else { this . preferences . line_separator = Util . LINE_SEPARATOR ; } this . preferences . initial_indentation_level = indentationLevel ; this . newCodeFormatter = new CodeFormatterVisitor ( this . preferences , this . options , regions , this . codeSnippetParsingUtil , includeComments ) ; TextEdit textEdit = this . newCodeFormatter . format ( source , expression ) ; return textEdit ; } private TextEdit internalFormatStatements ( String source , int indentationLevel , String lineSeparator , ConstructorDeclaration constructorDeclaration , IRegion [ ] regions , boolean includeComments ) { if ( lineSeparator != null ) { this . preferences . line_separator = lineSeparator ; } else { this . preferences . line_separator = Util . LINE_SEPARATOR ; } this . preferences . initial_indentation_level = indentationLevel ; this . newCodeFormatter = new CodeFormatterVisitor ( this . preferences , this . options , regions , this . codeSnippetParsingUtil , includeComments ) ; return this . newCodeFormatter . format ( source , constructorDeclaration ) ; } private Object oldCommentFormatOption ( ) { return this . options . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT ) ; } private TextEdit probeFormatting ( String source , int indentationLevel , String lineSeparator , IRegion [ ] regions , boolean includeComments ) { if ( PROBING_SCANNER == null ) { PROBING_SCANNER = new Scanner ( true , false , false , ClassFileConstants . JDK1_6 , ClassFileConstants . JDK1_6 , null , null , true ) ; } PROBING_SCANNER . setSource ( source . toCharArray ( ) ) ; IRegion coveredRegion = getCoveredRegion ( regions ) ; int offset = coveredRegion . getOffset ( ) ; int length = coveredRegion . getLength ( ) ; PROBING_SCANNER . resetTo ( offset , offset + length - <NUM_LIT:1> ) ; try { int kind = - <NUM_LIT:1> ; switch ( PROBING_SCANNER . getNextToken ( ) ) { case ITerminalSymbols . TokenNameCOMMENT_BLOCK : if ( PROBING_SCANNER . getNextToken ( ) == TerminalTokens . TokenNameEOF ) { kind = K_MULTI_LINE_COMMENT ; } break ; case ITerminalSymbols . TokenNameCOMMENT_LINE : if ( PROBING_SCANNER . getNextToken ( ) == TerminalTokens . TokenNameEOF ) { kind = K_SINGLE_LINE_COMMENT ; } break ; case ITerminalSymbols . TokenNameCOMMENT_JAVADOC : if ( PROBING_SCANNER . getNextToken ( ) == TerminalTokens . TokenNameEOF ) { kind = K_JAVA_DOC ; } break ; } if ( kind != - <NUM_LIT:1> ) { return formatComment ( kind , source , indentationLevel , lineSeparator , regions ) ; } } catch ( InvalidInputException e ) { } PROBING_SCANNER . setSource ( ( char [ ] ) null ) ; Expression expression = this . codeSnippetParsingUtil . parseExpression ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true ) ; if ( expression != null ) { return internalFormatExpression ( source , indentationLevel , lineSeparator , expression , regions , includeComments ) ; } ASTNode [ ] bodyDeclarations = this . codeSnippetParsingUtil . parseClassBodyDeclarations ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true ) ; if ( bodyDeclarations != null ) { return internalFormatClassBodyDeclarations ( source , indentationLevel , lineSeparator , bodyDeclarations , regions , includeComments ) ; } ConstructorDeclaration constructorDeclaration = this . codeSnippetParsingUtil . parseStatements ( source . toCharArray ( ) , getDefaultCompilerOptions ( ) , true , false ) ; if ( constructorDeclaration . statements != null ) { return internalFormatStatements ( source , indentationLevel , lineSeparator , constructorDeclaration , regions , includeComments ) ; } return formatCompilationUnit ( source , indentationLevel , lineSeparator , regions , includeComments ) ; } private boolean regionsSatisfiesPreconditions ( IRegion [ ] regions , int maxLength ) { int regionsLength = regions == null ? <NUM_LIT:0> : regions . length ; if ( regionsLength == <NUM_LIT:0> ) { return false ; } IRegion first = regions [ <NUM_LIT:0> ] ; if ( first . getOffset ( ) < <NUM_LIT:0> || first . getLength ( ) < <NUM_LIT:0> || first . getOffset ( ) + first . getLength ( ) > maxLength ) { return false ; } int lastOffset = first . getOffset ( ) + first . getLength ( ) - <NUM_LIT:1> ; for ( int i = <NUM_LIT:1> ; i < regionsLength ; i ++ ) { IRegion current = regions [ i ] ; if ( lastOffset > current . getOffset ( ) ) { return false ; } if ( current . getOffset ( ) < <NUM_LIT:0> || current . getLength ( ) < <NUM_LIT:0> || current . getOffset ( ) + current . getLength ( ) > maxLength ) { return false ; } lastOffset = current . getOffset ( ) + current . getLength ( ) - <NUM_LIT:1> ; } return true ; } } </s>
<s> package org . eclipse . jdt . internal . formatter . align ; public class AlignmentException extends RuntimeException { public static final int LINE_TOO_LONG = <NUM_LIT:1> ; public static final int ALIGN_TOO_SMALL = <NUM_LIT:2> ; private static final long serialVersionUID = - <NUM_LIT> ; int reason ; int value ; public int relativeDepth ; public AlignmentException ( int reason , int relativeDepth ) { this ( reason , <NUM_LIT:0> , relativeDepth ) ; } public AlignmentException ( int reason , int value , int relativeDepth ) { this . reason = reason ; this . value = value ; this . relativeDepth = relativeDepth ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( <NUM_LIT:10> ) ; switch ( this . reason ) { case LINE_TOO_LONG : buffer . append ( "<STR_LIT>" ) ; break ; case ALIGN_TOO_SMALL : buffer . append ( "<STR_LIT>" ) ; break ; } buffer . append ( "<STR_LIT>" ) . append ( this . relativeDepth ) . append ( "<STR_LIT>" ) ; return buffer . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . formatter . align ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jdt . internal . formatter . Location ; import org . eclipse . jdt . internal . formatter . Scribe ; public class Alignment { public int kind ; public static final int ALLOCATION = <NUM_LIT:1> ; public static final int ANNOTATION_MEMBERS_VALUE_PAIRS = <NUM_LIT:2> ; public static final int ARRAY_INITIALIZER = <NUM_LIT:3> ; public static final int ASSIGNMENT = <NUM_LIT:4> ; public static final int BINARY_EXPRESSION = <NUM_LIT:5> ; public static final int CASCADING_MESSAGE_SEND = <NUM_LIT:6> ; public static final int COMPACT_IF = <NUM_LIT:7> ; public static final int COMPOUND_ASSIGNMENT = <NUM_LIT:8> ; public static final int CONDITIONAL_EXPRESSION = <NUM_LIT:9> ; public static final int ENUM_CONSTANTS = <NUM_LIT:10> ; public static final int ENUM_CONSTANTS_ARGUMENTS = <NUM_LIT:11> ; public static final int EXPLICIT_CONSTRUCTOR_CALL = <NUM_LIT:12> ; public static final int FIELD_DECLARATION_ASSIGNMENT = <NUM_LIT> ; public static final int LOCAL_DECLARATION_ASSIGNMENT = <NUM_LIT> ; public static final int MESSAGE_ARGUMENTS = <NUM_LIT:15> ; public static final int MESSAGE_SEND = <NUM_LIT:16> ; public static final int METHOD_ARGUMENTS = <NUM_LIT> ; public static final int METHOD_DECLARATION = <NUM_LIT> ; public static final int MULTIPLE_FIELD = <NUM_LIT> ; public static final int SUPER_CLASS = <NUM_LIT:20> ; public static final int SUPER_INTERFACES = <NUM_LIT> ; public static final int THROWS = <NUM_LIT> ; public static final int TYPE_MEMBERS = <NUM_LIT> ; public static final int STRING_CONCATENATION = <NUM_LIT:24> ; public static final int TRY_RESOURCES = <NUM_LIT> ; public static final int MULTI_CATCH = <NUM_LIT> ; public String name ; public static final String [ ] NAMES = { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , } ; public Alignment enclosing ; public Location location ; public int fragmentIndex ; public int fragmentCount ; public int [ ] fragmentIndentations ; public boolean needRedoColumnAlignment ; public int chunkStartIndex ; public int chunkKind ; public int originalIndentationLevel ; public int breakIndentationLevel ; public int shiftBreakIndentationLevel ; public int [ ] fragmentBreaks ; public boolean wasSplit ; public boolean blockAlign = false ; public boolean tooLong = false ; public Scribe scribe ; private boolean reset = false ; public static final int M_FORCE = <NUM_LIT:1> ; public static final int M_INDENT_ON_COLUMN = <NUM_LIT:2> ; public static final int M_INDENT_BY_ONE = <NUM_LIT:4> ; public static final int M_COMPACT_SPLIT = <NUM_LIT:16> ; public static final int M_COMPACT_FIRST_BREAK_SPLIT = <NUM_LIT:32> ; public static final int M_ONE_PER_LINE_SPLIT = <NUM_LIT:32> + <NUM_LIT:16> ; public static final int M_NEXT_SHIFTED_SPLIT = <NUM_LIT> ; public static final int M_NEXT_PER_LINE_SPLIT = <NUM_LIT> + <NUM_LIT:16> ; public static final int M_MULTICOLUMN = <NUM_LIT> ; public static final int M_NO_ALIGNMENT = <NUM_LIT:0> ; public int mode ; public static final int SPLIT_MASK = M_ONE_PER_LINE_SPLIT | M_NEXT_SHIFTED_SPLIT | M_COMPACT_SPLIT | M_COMPACT_FIRST_BREAK_SPLIT | M_NEXT_PER_LINE_SPLIT ; public static final int R_OUTERMOST = <NUM_LIT:1> ; public static final int R_INNERMOST = <NUM_LIT:2> ; public int tieBreakRule ; public int startingColumn = - <NUM_LIT:1> ; public static final int NONE = <NUM_LIT:0> ; public static final int BREAK = <NUM_LIT:1> ; public static final int CHUNK_FIELD = <NUM_LIT:1> ; public static final int CHUNK_METHOD = <NUM_LIT:2> ; public static final int CHUNK_TYPE = <NUM_LIT:3> ; public static final int CHUNK_ENUM = <NUM_LIT:4> ; public Alignment ( int kind , int mode , int tieBreakRule , Scribe scribe , int fragmentCount , int sourceRestart , int continuationIndent ) { Assert . isTrue ( kind >= ALLOCATION && kind <= MULTI_CATCH ) ; this . kind = kind ; this . name = NAMES [ kind ] ; this . location = new Location ( scribe , sourceRestart ) ; this . mode = mode ; this . tieBreakRule = tieBreakRule ; this . fragmentCount = fragmentCount ; this . scribe = scribe ; this . originalIndentationLevel = this . scribe . indentationLevel ; this . wasSplit = false ; final int indentSize = this . scribe . indentationSize ; int currentColumn = this . location . outputColumn ; if ( currentColumn == <NUM_LIT:1> ) { currentColumn = this . location . outputIndentationLevel + <NUM_LIT:1> ; } if ( ( mode & M_INDENT_ON_COLUMN ) != <NUM_LIT:0> ) { this . breakIndentationLevel = this . scribe . getNextIndentationLevel ( currentColumn ) ; if ( this . breakIndentationLevel == this . location . outputIndentationLevel ) { this . breakIndentationLevel += ( continuationIndent * indentSize ) ; } } else if ( ( mode & M_INDENT_BY_ONE ) != <NUM_LIT:0> ) { this . breakIndentationLevel = this . location . outputIndentationLevel + indentSize ; } else { this . breakIndentationLevel = this . location . outputIndentationLevel + continuationIndent * indentSize ; } this . shiftBreakIndentationLevel = this . breakIndentationLevel + indentSize ; this . fragmentIndentations = new int [ this . fragmentCount ] ; this . fragmentBreaks = new int [ this . fragmentCount ] ; if ( ( this . mode & M_FORCE ) != <NUM_LIT:0> ) { couldBreak ( ) ; } } public boolean checkChunkStart ( int chunk , int startIndex , int sourceRestart ) { if ( this . chunkKind != chunk ) { this . chunkKind = chunk ; if ( startIndex != this . chunkStartIndex ) { this . chunkStartIndex = startIndex ; this . location . update ( this . scribe , sourceRestart ) ; reset ( ) ; } return true ; } return false ; } public void checkColumn ( ) { if ( ( this . mode & M_MULTICOLUMN ) != <NUM_LIT:0> && this . fragmentCount > <NUM_LIT:0> ) { int currentIndentation = this . scribe . getNextIndentationLevel ( this . scribe . column + ( this . scribe . needSpace ? <NUM_LIT:1> : <NUM_LIT:0> ) ) ; int fragmentIndentation = this . fragmentIndentations [ this . fragmentIndex ] ; if ( currentIndentation > fragmentIndentation ) { this . fragmentIndentations [ this . fragmentIndex ] = currentIndentation ; if ( fragmentIndentation != <NUM_LIT:0> ) { for ( int i = this . fragmentIndex + <NUM_LIT:1> ; i < this . fragmentCount ; i ++ ) { this . fragmentIndentations [ i ] = <NUM_LIT:0> ; } this . needRedoColumnAlignment = true ; } } if ( this . needRedoColumnAlignment && this . fragmentIndex == this . fragmentCount - <NUM_LIT:1> ) { this . needRedoColumnAlignment = false ; int relativeDepth = <NUM_LIT:0> ; Alignment targetAlignment = this . scribe . memberAlignment ; while ( targetAlignment != null ) { if ( targetAlignment == this ) { throw new AlignmentException ( AlignmentException . ALIGN_TOO_SMALL , relativeDepth ) ; } targetAlignment = targetAlignment . enclosing ; relativeDepth ++ ; } } } } public int depth ( ) { int depth = <NUM_LIT:0> ; Alignment current = this . enclosing ; while ( current != null ) { depth ++ ; current = current . enclosing ; } return depth ; } public boolean canAlign ( ) { if ( this . tooLong ) { return true ; } boolean canAlign = true ; Alignment enclosingAlignment = this . enclosing ; while ( enclosingAlignment != null ) { switch ( enclosingAlignment . kind ) { case Alignment . ALLOCATION : case Alignment . MESSAGE_ARGUMENTS : if ( enclosingAlignment . isWrapped ( ) && ( enclosingAlignment . fragmentIndex > <NUM_LIT:0> || enclosingAlignment . fragmentCount < <NUM_LIT:2> ) ) { return ! this . blockAlign ; } if ( enclosingAlignment . tooLong ) { return true ; } canAlign = false ; break ; case Alignment . MESSAGE_SEND : switch ( this . kind ) { case Alignment . ALLOCATION : case Alignment . MESSAGE_ARGUMENTS : case Alignment . MESSAGE_SEND : Alignment superEnclosingAlignment = enclosingAlignment . enclosing ; while ( superEnclosingAlignment != null ) { switch ( superEnclosingAlignment . kind ) { case Alignment . ALLOCATION : case Alignment . MESSAGE_ARGUMENTS : case Alignment . MESSAGE_SEND : if ( this . scribe . nlsTagCounter == <NUM_LIT:0> ) { enclosingAlignment . blockAlign = true ; } return ! this . blockAlign ; } superEnclosingAlignment = superEnclosingAlignment . enclosing ; } break ; } return ! this . blockAlign ; } enclosingAlignment = enclosingAlignment . enclosing ; } return canAlign && ! this . blockAlign ; } public boolean couldBreak ( ) { if ( this . fragmentCount == <NUM_LIT:0> ) return false ; int i ; switch ( this . mode & SPLIT_MASK ) { case M_COMPACT_FIRST_BREAK_SPLIT : if ( this . fragmentBreaks [ <NUM_LIT:0> ] == NONE ) { this . fragmentBreaks [ <NUM_LIT:0> ] = BREAK ; this . fragmentIndentations [ <NUM_LIT:0> ] = this . breakIndentationLevel ; return this . wasSplit = true ; } i = this . fragmentIndex ; do { if ( this . fragmentBreaks [ i ] == NONE ) { this . fragmentBreaks [ i ] = BREAK ; this . fragmentIndentations [ i ] = this . breakIndentationLevel ; return this . wasSplit = true ; } } while ( -- i >= <NUM_LIT:0> ) ; break ; case M_COMPACT_SPLIT : i = this . fragmentIndex ; do { if ( this . fragmentBreaks [ i ] == NONE ) { this . fragmentBreaks [ i ] = BREAK ; this . fragmentIndentations [ i ] = this . breakIndentationLevel ; return this . wasSplit = true ; } } while ( -- i >= <NUM_LIT:0> ) ; break ; case M_NEXT_SHIFTED_SPLIT : if ( this . fragmentBreaks [ <NUM_LIT:0> ] == NONE ) { this . fragmentBreaks [ <NUM_LIT:0> ] = BREAK ; this . fragmentIndentations [ <NUM_LIT:0> ] = this . breakIndentationLevel ; for ( i = <NUM_LIT:1> ; i < this . fragmentCount ; i ++ ) { this . fragmentBreaks [ i ] = BREAK ; this . fragmentIndentations [ i ] = this . shiftBreakIndentationLevel ; } return this . wasSplit = true ; } break ; case M_ONE_PER_LINE_SPLIT : if ( this . fragmentBreaks [ <NUM_LIT:0> ] == NONE ) { for ( i = <NUM_LIT:0> ; i < this . fragmentCount ; i ++ ) { this . fragmentBreaks [ i ] = BREAK ; this . fragmentIndentations [ i ] = this . breakIndentationLevel ; } return this . wasSplit = true ; } break ; case M_NEXT_PER_LINE_SPLIT : if ( this . fragmentBreaks [ <NUM_LIT:0> ] == NONE ) { if ( this . fragmentCount > <NUM_LIT:1> && this . fragmentBreaks [ <NUM_LIT:1> ] == NONE ) { if ( ( this . mode & M_INDENT_ON_COLUMN ) != <NUM_LIT:0> ) { this . fragmentIndentations [ <NUM_LIT:0> ] = this . breakIndentationLevel ; } for ( i = <NUM_LIT:1> ; i < this . fragmentCount ; i ++ ) { this . fragmentBreaks [ i ] = BREAK ; this . fragmentIndentations [ i ] = this . breakIndentationLevel ; } return this . wasSplit = true ; } } break ; } return false ; } public boolean isWrapped ( ) { if ( this . fragmentCount == <NUM_LIT:0> ) return false ; return this . fragmentBreaks [ this . fragmentIndex ] == BREAK ; } public int wrappedIndex ( ) { for ( int i = <NUM_LIT:0> , max = this . fragmentCount ; i < max ; i ++ ) { if ( this . fragmentBreaks [ i ] == BREAK ) { return i ; } } return - <NUM_LIT:1> ; } public void performFragmentEffect ( ) { if ( this . fragmentCount == <NUM_LIT:0> ) return ; if ( ( this . mode & M_MULTICOLUMN ) == <NUM_LIT:0> ) { switch ( this . mode & SPLIT_MASK ) { case Alignment . M_COMPACT_SPLIT : case Alignment . M_COMPACT_FIRST_BREAK_SPLIT : case Alignment . M_NEXT_PER_LINE_SPLIT : case Alignment . M_NEXT_SHIFTED_SPLIT : case Alignment . M_ONE_PER_LINE_SPLIT : break ; default : return ; } } int fragmentIndentation = this . fragmentIndentations [ this . fragmentIndex ] ; if ( this . startingColumn < <NUM_LIT:0> || ( fragmentIndentation + <NUM_LIT:1> ) < this . startingColumn ) { if ( this . fragmentBreaks [ this . fragmentIndex ] == BREAK ) { this . scribe . printNewLine ( ) ; } if ( fragmentIndentation > <NUM_LIT:0> ) { this . scribe . indentationLevel = fragmentIndentation ; } } } public void reset ( ) { this . wasSplit = false ; if ( this . fragmentCount > <NUM_LIT:0> ) { this . fragmentIndentations = new int [ this . fragmentCount ] ; this . fragmentBreaks = new int [ this . fragmentCount ] ; } if ( ( this . mode & M_FORCE ) != <NUM_LIT:0> ) { couldBreak ( ) ; } this . reset = true ; } public void toFragmentsString ( StringBuffer buffer ) { } public String toString ( ) { StringBuffer buffer = new StringBuffer ( <NUM_LIT:10> ) ; return toString ( buffer , - <NUM_LIT:1> ) ; } public String toString ( StringBuffer buffer , int level ) { StringBuffer indentation = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> ; i < level ; i ++ ) { indentation . append ( '<STR_LIT:\t>' ) ; } buffer . append ( indentation ) ; buffer . append ( "<STR_LIT>" ) . append ( this . kind ) . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) . append ( this . name ) . append ( "<STR_LIT>" ) ; buffer . append ( indentation ) ; buffer . append ( "<STR_LIT>" ) . append ( depth ( ) ) . append ( "<STR_LIT>" ) . append ( this . breakIndentationLevel ) . append ( "<STR_LIT>" ) . append ( this . shiftBreakIndentationLevel ) . append ( "<STR_LIT>" ) ; buffer . append ( indentation ) ; buffer . append ( "<STR_LIT>" ) . append ( this . location . toString ( ) ) . append ( "<STR_LIT>" ) ; buffer . append ( indentation ) . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . fragmentCount ; i ++ ) { buffer . append ( indentation ) . append ( "<STR_LIT:U+0020-U+0020>" ) . append ( i ) . append ( "<STR_LIT::U+0020>" ) . append ( "<STR_LIT>" ) . append ( this . fragmentBreaks [ i ] > <NUM_LIT:0> ? "<STR_LIT>" : "<STR_LIT>" ) . append ( "<STR_LIT:>>" ) . append ( "<STR_LIT>" ) . append ( this . fragmentIndentations [ i ] ) . append ( "<STR_LIT>" ) ; } buffer . append ( indentation ) . append ( "<STR_LIT>" ) ; if ( this . enclosing != null && level >= <NUM_LIT:0> ) { buffer . append ( indentation ) . append ( "<STR_LIT>" ) ; this . enclosing . toString ( buffer , level + <NUM_LIT:1> ) ; buffer . append ( indentation ) . append ( "<STR_LIT>" ) ; } return buffer . toString ( ) ; } public void update ( ) { for ( int i = <NUM_LIT:1> ; i < this . fragmentCount ; i ++ ) { if ( this . fragmentBreaks [ i ] == BREAK ) { this . fragmentIndentations [ i ] = this . breakIndentationLevel ; } } } public boolean wasReset ( ) { return this . reset ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; public class AbortFormatting extends RuntimeException { Throwable nestedException ; private static final long serialVersionUID = - <NUM_LIT> ; public AbortFormatting ( String message ) { super ( message ) ; } public AbortFormatting ( Throwable nestedException ) { super ( nestedException . getMessage ( ) ) ; this . nestedException = nestedException ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . formatter . align . Alignment ; public class DefaultCodeFormatterOptions { public static final int TAB = <NUM_LIT:1> ; public static final int SPACE = <NUM_LIT:2> ; public static final int MIXED = <NUM_LIT:4> ; public static DefaultCodeFormatterOptions getDefaultSettings ( ) { DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions ( ) ; options . setDefaultSettings ( ) ; return options ; } public static DefaultCodeFormatterOptions getEclipseDefaultSettings ( ) { DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions ( ) ; options . setEclipseDefaultSettings ( ) ; return options ; } public static DefaultCodeFormatterOptions getJavaConventionsSettings ( ) { DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions ( ) ; options . setJavaConventionsSettings ( ) ; return options ; } public int alignment_for_arguments_in_allocation_expression ; public int alignment_for_arguments_in_annotation ; public int alignment_for_arguments_in_enum_constant ; public int alignment_for_arguments_in_explicit_constructor_call ; public int alignment_for_arguments_in_method_invocation ; public int alignment_for_arguments_in_qualified_allocation_expression ; public int alignment_for_assignment ; public int alignment_for_binary_expression ; public int alignment_for_compact_if ; public int alignment_for_conditional_expression ; public int alignment_for_enum_constants ; public int alignment_for_expressions_in_array_initializer ; public int alignment_for_method_declaration ; public int alignment_for_multiple_fields ; public int alignment_for_parameters_in_constructor_declaration ; public int alignment_for_parameters_in_method_declaration ; public int alignment_for_selector_in_method_invocation ; public int alignment_for_superclass_in_type_declaration ; public int alignment_for_superinterfaces_in_enum_declaration ; public int alignment_for_superinterfaces_in_type_declaration ; public int alignment_for_throws_clause_in_constructor_declaration ; public int alignment_for_throws_clause_in_method_declaration ; public int alignment_for_resources_in_try ; public int alignment_for_union_type_in_multicatch ; public boolean align_type_members_on_columns ; public String brace_position_for_annotation_type_declaration ; public String brace_position_for_anonymous_type_declaration ; public String brace_position_for_array_initializer ; public String brace_position_for_block ; public String brace_position_for_block_in_case ; public String brace_position_for_constructor_declaration ; public String brace_position_for_enum_constant ; public String brace_position_for_enum_declaration ; public String brace_position_for_method_declaration ; public String brace_position_for_type_declaration ; public String brace_position_for_switch ; public int continuation_indentation ; public int continuation_indentation_for_array_initializer ; public int blank_lines_after_imports ; public int blank_lines_after_package ; public int blank_lines_before_field ; public int blank_lines_before_first_class_body_declaration ; public int blank_lines_before_imports ; public int blank_lines_before_member_type ; public int blank_lines_before_method ; public int blank_lines_before_new_chunk ; public int blank_lines_before_package ; public int blank_lines_between_import_groups ; public int blank_lines_between_type_declarations ; public int blank_lines_at_beginning_of_method_body ; public boolean comment_clear_blank_lines_in_javadoc_comment ; public boolean comment_clear_blank_lines_in_block_comment ; public boolean comment_new_lines_at_block_boundaries ; public boolean comment_new_lines_at_javadoc_boundaries ; public boolean comment_format_javadoc_comment ; public boolean comment_format_line_comment ; public boolean comment_format_line_comment_starting_on_first_column ; public boolean comment_format_block_comment ; public boolean comment_format_header ; public boolean comment_format_html ; public boolean comment_format_source ; public boolean comment_indent_parameter_description ; public boolean comment_indent_root_tags ; public boolean comment_insert_empty_line_before_root_tags ; public boolean comment_insert_new_line_for_parameter ; public boolean comment_preserve_white_space_between_code_and_line_comments ; public int comment_line_length ; public boolean use_tags ; public char [ ] disabling_tag ; public char [ ] enabling_tag ; private final static char [ ] DEFAULT_DISABLING_TAG = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] DEFAULT_ENABLING_TAG = "<STR_LIT>" . toCharArray ( ) ; public boolean indent_statements_compare_to_block ; public boolean indent_statements_compare_to_body ; public boolean indent_body_declarations_compare_to_annotation_declaration_header ; public boolean indent_body_declarations_compare_to_enum_constant_header ; public boolean indent_body_declarations_compare_to_enum_declaration_header ; public boolean indent_body_declarations_compare_to_type_header ; public boolean indent_breaks_compare_to_cases ; public boolean indent_empty_lines ; public boolean indent_switchstatements_compare_to_cases ; public boolean indent_switchstatements_compare_to_switch ; public int indentation_size ; public boolean insert_new_line_after_annotation_on_type ; public boolean insert_new_line_after_annotation_on_field ; public boolean insert_new_line_after_annotation_on_method ; public boolean insert_new_line_after_annotation_on_package ; public boolean insert_new_line_after_annotation_on_parameter ; public boolean insert_new_line_after_annotation_on_local_variable ; public boolean insert_new_line_after_label ; public boolean insert_new_line_after_opening_brace_in_array_initializer ; public boolean insert_new_line_at_end_of_file_if_missing ; public boolean insert_new_line_before_catch_in_try_statement ; public boolean insert_new_line_before_closing_brace_in_array_initializer ; public boolean insert_new_line_before_else_in_if_statement ; public boolean insert_new_line_before_finally_in_try_statement ; public boolean insert_new_line_before_while_in_do_statement ; public boolean insert_new_line_in_empty_anonymous_type_declaration ; public boolean insert_new_line_in_empty_block ; public boolean insert_new_line_in_empty_annotation_declaration ; public boolean insert_new_line_in_empty_enum_constant ; public boolean insert_new_line_in_empty_enum_declaration ; public boolean insert_new_line_in_empty_method_body ; public boolean insert_new_line_in_empty_type_declaration ; public boolean insert_space_after_and_in_type_parameter ; public boolean insert_space_after_assignment_operator ; public boolean insert_space_after_at_in_annotation ; public boolean insert_space_after_at_in_annotation_type_declaration ; public boolean insert_space_after_binary_operator ; public boolean insert_space_after_closing_angle_bracket_in_type_arguments ; public boolean insert_space_after_closing_angle_bracket_in_type_parameters ; public boolean insert_space_after_closing_paren_in_cast ; public boolean insert_space_after_closing_brace_in_block ; public boolean insert_space_after_colon_in_assert ; public boolean insert_space_after_colon_in_case ; public boolean insert_space_after_colon_in_conditional ; public boolean insert_space_after_colon_in_for ; public boolean insert_space_after_colon_in_labeled_statement ; public boolean insert_space_after_comma_in_allocation_expression ; public boolean insert_space_after_comma_in_annotation ; public boolean insert_space_after_comma_in_array_initializer ; public boolean insert_space_after_comma_in_constructor_declaration_parameters ; public boolean insert_space_after_comma_in_constructor_declaration_throws ; public boolean insert_space_after_comma_in_enum_constant_arguments ; public boolean insert_space_after_comma_in_enum_declarations ; public boolean insert_space_after_comma_in_explicit_constructor_call_arguments ; public boolean insert_space_after_comma_in_for_increments ; public boolean insert_space_after_comma_in_for_inits ; public boolean insert_space_after_comma_in_method_invocation_arguments ; public boolean insert_space_after_comma_in_method_declaration_parameters ; public boolean insert_space_after_comma_in_method_declaration_throws ; public boolean insert_space_after_comma_in_multiple_field_declarations ; public boolean insert_space_after_comma_in_multiple_local_declarations ; public boolean insert_space_after_comma_in_parameterized_type_reference ; public boolean insert_space_after_comma_in_superinterfaces ; public boolean insert_space_after_comma_in_type_arguments ; public boolean insert_space_after_comma_in_type_parameters ; public boolean insert_space_after_ellipsis ; public boolean insert_space_after_opening_angle_bracket_in_parameterized_type_reference ; public boolean insert_space_after_opening_angle_bracket_in_type_arguments ; public boolean insert_space_after_opening_angle_bracket_in_type_parameters ; public boolean insert_space_after_opening_bracket_in_array_allocation_expression ; public boolean insert_space_after_opening_bracket_in_array_reference ; public boolean insert_space_after_opening_brace_in_array_initializer ; public boolean insert_space_after_opening_paren_in_annotation ; public boolean insert_space_after_opening_paren_in_cast ; public boolean insert_space_after_opening_paren_in_catch ; public boolean insert_space_after_opening_paren_in_constructor_declaration ; public boolean insert_space_after_opening_paren_in_enum_constant ; public boolean insert_space_after_opening_paren_in_for ; public boolean insert_space_after_opening_paren_in_if ; public boolean insert_space_after_opening_paren_in_method_declaration ; public boolean insert_space_after_opening_paren_in_method_invocation ; public boolean insert_space_after_opening_paren_in_parenthesized_expression ; public boolean insert_space_after_opening_paren_in_switch ; public boolean insert_space_after_opening_paren_in_synchronized ; public boolean insert_space_after_opening_paren_in_try ; public boolean insert_space_after_opening_paren_in_while ; public boolean insert_space_after_postfix_operator ; public boolean insert_space_after_prefix_operator ; public boolean insert_space_after_question_in_conditional ; public boolean insert_space_after_question_in_wilcard ; public boolean insert_space_after_semicolon_in_for ; public boolean insert_space_after_semicolon_in_try_resources ; public boolean insert_space_after_unary_operator ; public boolean insert_space_before_and_in_type_parameter ; public boolean insert_space_before_at_in_annotation_type_declaration ; public boolean insert_space_before_assignment_operator ; public boolean insert_space_before_binary_operator ; public boolean insert_space_before_closing_angle_bracket_in_parameterized_type_reference ; public boolean insert_space_before_closing_angle_bracket_in_type_arguments ; public boolean insert_space_before_closing_angle_bracket_in_type_parameters ; public boolean insert_space_before_closing_brace_in_array_initializer ; public boolean insert_space_before_closing_bracket_in_array_allocation_expression ; public boolean insert_space_before_closing_bracket_in_array_reference ; public boolean insert_space_before_closing_paren_in_annotation ; public boolean insert_space_before_closing_paren_in_cast ; public boolean insert_space_before_closing_paren_in_catch ; public boolean insert_space_before_closing_paren_in_constructor_declaration ; public boolean insert_space_before_closing_paren_in_enum_constant ; public boolean insert_space_before_closing_paren_in_for ; public boolean insert_space_before_closing_paren_in_if ; public boolean insert_space_before_closing_paren_in_method_declaration ; public boolean insert_space_before_closing_paren_in_method_invocation ; public boolean insert_space_before_closing_paren_in_parenthesized_expression ; public boolean insert_space_before_closing_paren_in_switch ; public boolean insert_space_before_closing_paren_in_synchronized ; public boolean insert_space_before_closing_paren_in_try ; public boolean insert_space_before_closing_paren_in_while ; public boolean insert_space_before_colon_in_assert ; public boolean insert_space_before_colon_in_case ; public boolean insert_space_before_colon_in_conditional ; public boolean insert_space_before_colon_in_default ; public boolean insert_space_before_colon_in_for ; public boolean insert_space_before_colon_in_labeled_statement ; public boolean insert_space_before_comma_in_allocation_expression ; public boolean insert_space_before_comma_in_annotation ; public boolean insert_space_before_comma_in_array_initializer ; public boolean insert_space_before_comma_in_constructor_declaration_parameters ; public boolean insert_space_before_comma_in_constructor_declaration_throws ; public boolean insert_space_before_comma_in_enum_constant_arguments ; public boolean insert_space_before_comma_in_enum_declarations ; public boolean insert_space_before_comma_in_explicit_constructor_call_arguments ; public boolean insert_space_before_comma_in_for_increments ; public boolean insert_space_before_comma_in_for_inits ; public boolean insert_space_before_comma_in_method_invocation_arguments ; public boolean insert_space_before_comma_in_method_declaration_parameters ; public boolean insert_space_before_comma_in_method_declaration_throws ; public boolean insert_space_before_comma_in_multiple_field_declarations ; public boolean insert_space_before_comma_in_multiple_local_declarations ; public boolean insert_space_before_comma_in_parameterized_type_reference ; public boolean insert_space_before_comma_in_superinterfaces ; public boolean insert_space_before_comma_in_type_arguments ; public boolean insert_space_before_comma_in_type_parameters ; public boolean insert_space_before_ellipsis ; public boolean insert_space_before_parenthesized_expression_in_return ; public boolean insert_space_before_parenthesized_expression_in_throw ; public boolean insert_space_before_question_in_wilcard ; public boolean insert_space_before_opening_angle_bracket_in_parameterized_type_reference ; public boolean insert_space_before_opening_angle_bracket_in_type_arguments ; public boolean insert_space_before_opening_angle_bracket_in_type_parameters ; public boolean insert_space_before_opening_brace_in_annotation_type_declaration ; public boolean insert_space_before_opening_brace_in_anonymous_type_declaration ; public boolean insert_space_before_opening_brace_in_array_initializer ; public boolean insert_space_before_opening_brace_in_block ; public boolean insert_space_before_opening_brace_in_constructor_declaration ; public boolean insert_space_before_opening_brace_in_enum_constant ; public boolean insert_space_before_opening_brace_in_enum_declaration ; public boolean insert_space_before_opening_brace_in_method_declaration ; public boolean insert_space_before_opening_brace_in_type_declaration ; public boolean insert_space_before_opening_bracket_in_array_allocation_expression ; public boolean insert_space_before_opening_bracket_in_array_reference ; public boolean insert_space_before_opening_bracket_in_array_type_reference ; public boolean insert_space_before_opening_paren_in_annotation ; public boolean insert_space_before_opening_paren_in_annotation_type_member_declaration ; public boolean insert_space_before_opening_paren_in_catch ; public boolean insert_space_before_opening_paren_in_constructor_declaration ; public boolean insert_space_before_opening_paren_in_enum_constant ; public boolean insert_space_before_opening_paren_in_for ; public boolean insert_space_before_opening_paren_in_if ; public boolean insert_space_before_opening_paren_in_method_invocation ; public boolean insert_space_before_opening_paren_in_method_declaration ; public boolean insert_space_before_opening_paren_in_switch ; public boolean insert_space_before_opening_paren_in_try ; public boolean insert_space_before_opening_brace_in_switch ; public boolean insert_space_before_opening_paren_in_synchronized ; public boolean insert_space_before_opening_paren_in_parenthesized_expression ; public boolean insert_space_before_opening_paren_in_while ; public boolean insert_space_before_postfix_operator ; public boolean insert_space_before_prefix_operator ; public boolean insert_space_before_question_in_conditional ; public boolean insert_space_before_semicolon ; public boolean insert_space_before_semicolon_in_for ; public boolean insert_space_before_semicolon_in_try_resources ; public boolean insert_space_before_unary_operator ; public boolean insert_space_between_brackets_in_array_type_reference ; public boolean insert_space_between_empty_braces_in_array_initializer ; public boolean insert_space_between_empty_brackets_in_array_allocation_expression ; public boolean insert_space_between_empty_parens_in_annotation_type_member_declaration ; public boolean insert_space_between_empty_parens_in_constructor_declaration ; public boolean insert_space_between_empty_parens_in_enum_constant ; public boolean insert_space_between_empty_parens_in_method_declaration ; public boolean insert_space_between_empty_parens_in_method_invocation ; public boolean compact_else_if ; public boolean keep_guardian_clause_on_one_line ; public boolean keep_else_statement_on_same_line ; public boolean keep_empty_array_initializer_on_one_line ; public boolean keep_simple_if_on_one_line ; public boolean keep_then_statement_on_same_line ; public boolean never_indent_block_comments_on_first_column ; public boolean never_indent_line_comments_on_first_column ; public int number_of_empty_lines_to_preserve ; public boolean join_wrapped_lines ; public boolean join_lines_in_comments ; public boolean put_empty_statement_on_new_line ; public int tab_size ; public final char filling_space = '<CHAR_LIT:U+0020>' ; public int page_width ; public int tab_char ; public boolean use_tabs_only_for_leading_indentations ; public boolean wrap_before_binary_operator ; public boolean wrap_before_or_operator_multicatch ; public boolean wrap_outer_expressions_when_nested ; public int initial_indentation_level ; public String line_separator ; private DefaultCodeFormatterOptions ( ) { } public DefaultCodeFormatterOptions ( Map settings ) { setDefaultSettings ( ) ; if ( settings == null ) return ; set ( settings ) ; } private String getAlignment ( int alignment ) { return Integer . toString ( alignment ) ; } public Map getMap ( ) { Map options = new HashMap ( ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION , getAlignment ( this . alignment_for_arguments_in_allocation_expression ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ANNOTATION , getAlignment ( this . alignment_for_arguments_in_annotation ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT , getAlignment ( this . alignment_for_arguments_in_enum_constant ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL , getAlignment ( this . alignment_for_arguments_in_explicit_constructor_call ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION , getAlignment ( this . alignment_for_arguments_in_method_invocation ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION , getAlignment ( this . alignment_for_arguments_in_qualified_allocation_expression ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ASSIGNMENT , getAlignment ( this . alignment_for_assignment ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION , getAlignment ( this . alignment_for_binary_expression ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_COMPACT_IF , getAlignment ( this . alignment_for_compact_if ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION , getAlignment ( this . alignment_for_conditional_expression ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS , getAlignment ( this . alignment_for_enum_constants ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER , getAlignment ( this . alignment_for_expressions_in_array_initializer ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_METHOD_DECLARATION , getAlignment ( this . alignment_for_method_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS , getAlignment ( this . alignment_for_multiple_fields ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION , getAlignment ( this . alignment_for_parameters_in_constructor_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION , getAlignment ( this . alignment_for_parameters_in_method_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY , getAlignment ( this . alignment_for_resources_in_try ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION , getAlignment ( this . alignment_for_selector_in_method_invocation ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION , getAlignment ( this . alignment_for_superclass_in_type_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION , getAlignment ( this . alignment_for_superinterfaces_in_enum_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION , getAlignment ( this . alignment_for_superinterfaces_in_type_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION , getAlignment ( this . alignment_for_throws_clause_in_constructor_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION , getAlignment ( this . alignment_for_throws_clause_in_method_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH , getAlignment ( this . alignment_for_union_type_in_multicatch ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS , this . align_type_members_on_columns ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION , this . brace_position_for_annotation_type_declaration ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION , this . brace_position_for_anonymous_type_declaration ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER , this . brace_position_for_array_initializer ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_BLOCK , this . brace_position_for_block ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE , this . brace_position_for_block_in_case ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION , this . brace_position_for_constructor_declaration ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT , this . brace_position_for_enum_constant ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION , this . brace_position_for_enum_declaration ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION , this . brace_position_for_method_declaration ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION , this . brace_position_for_type_declaration ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_SWITCH , this . brace_position_for_switch ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT , this . comment_clear_blank_lines_in_block_comment ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT , this . comment_clear_blank_lines_in_javadoc_comment ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES , this . comment_new_lines_at_block_boundaries ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES , this . comment_new_lines_at_javadoc_boundaries ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT , this . comment_format_block_comment ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_HEADER , this . comment_format_header ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_HTML , this . comment_format_html ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT , this . comment_format_javadoc_comment ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_LINE_COMMENT , this . comment_format_line_comment ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN , this . comment_format_line_comment_starting_on_first_column ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_SOURCE , this . comment_format_source ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION , this . comment_indent_parameter_description ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INDENT_ROOT_TAGS , this . comment_indent_root_tags ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS , this . comment_insert_empty_line_before_root_tags ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER , this . comment_insert_new_line_for_parameter ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT , this . comment_preserve_white_space_between_code_and_line_comments ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_LINE_LENGTH , Integer . toString ( this . comment_line_length ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_CONTINUATION_INDENTATION , Integer . toString ( this . continuation_indentation ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER , Integer . toString ( this . continuation_indentation_for_array_initializer ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_AFTER_IMPORTS , Integer . toString ( this . blank_lines_after_imports ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_AFTER_PACKAGE , Integer . toString ( this . blank_lines_after_package ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_FIELD , Integer . toString ( this . blank_lines_before_field ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION , Integer . toString ( this . blank_lines_before_first_class_body_declaration ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_IMPORTS , Integer . toString ( this . blank_lines_before_imports ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE , Integer . toString ( this . blank_lines_before_member_type ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_METHOD , Integer . toString ( this . blank_lines_before_method ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK , Integer . toString ( this . blank_lines_before_new_chunk ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_PACKAGE , Integer . toString ( this . blank_lines_before_package ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS , Integer . toString ( this . blank_lines_between_import_groups ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS , Integer . toString ( this . blank_lines_between_type_declarations ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY , Integer . toString ( this . blank_lines_at_beginning_of_method_body ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK , this . indent_statements_compare_to_block ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY , this . indent_statements_compare_to_body ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER , this . indent_body_declarations_compare_to_annotation_declaration_header ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER , this . indent_body_declarations_compare_to_enum_constant_header ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER , this . indent_body_declarations_compare_to_enum_declaration_header ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER , this . indent_body_declarations_compare_to_type_header ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES , this . indent_breaks_compare_to_cases ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_EMPTY_LINES , this . indent_empty_lines ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES , this . indent_switchstatements_compare_to_cases ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH , this . indent_switchstatements_compare_to_switch ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INDENTATION_SIZE , Integer . toString ( this . indentation_size ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE , this . insert_new_line_after_annotation_on_type ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD , this . insert_new_line_after_annotation_on_field ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD , this . insert_new_line_after_annotation_on_method ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE , this . insert_new_line_after_annotation_on_package ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER , this . insert_new_line_after_annotation_on_parameter ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE , this . insert_new_line_after_annotation_on_local_variable ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER , this . insert_new_line_after_opening_brace_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING , this . insert_new_line_at_end_of_file_if_missing ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT , this . insert_new_line_before_catch_in_try_statement ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER , this . insert_new_line_before_closing_brace_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT , this . insert_new_line_before_else_in_if_statement ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT , this . insert_new_line_before_finally_in_try_statement ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT , this . insert_new_line_before_while_in_do_statement ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION , this . insert_new_line_in_empty_anonymous_type_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK , this . insert_new_line_in_empty_block ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION , this . insert_new_line_in_empty_annotation_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT , this . insert_new_line_in_empty_enum_constant ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION , this . insert_new_line_in_empty_enum_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY , this . insert_new_line_in_empty_method_body ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION , this . insert_new_line_in_empty_type_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_LABEL , this . insert_new_line_after_label ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER , this . insert_space_after_and_in_type_parameter ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR , this . insert_space_after_assignment_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION , this . insert_space_after_at_in_annotation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION , this . insert_space_after_at_in_annotation_type_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR , this . insert_space_after_binary_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS , this . insert_space_after_closing_angle_bracket_in_type_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS , this . insert_space_after_closing_angle_bracket_in_type_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST , this . insert_space_after_closing_paren_in_cast ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK , this . insert_space_after_closing_brace_in_block ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT , this . insert_space_after_colon_in_assert ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE , this . insert_space_after_colon_in_case ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL , this . insert_space_after_colon_in_conditional ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR , this . insert_space_after_colon_in_for ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT , this . insert_space_after_colon_in_labeled_statement ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION , this . insert_space_after_comma_in_allocation_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION , this . insert_space_after_comma_in_annotation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER , this . insert_space_after_comma_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS , this . insert_space_after_comma_in_constructor_declaration_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS , this . insert_space_after_comma_in_constructor_declaration_throws ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS , this . insert_space_after_comma_in_enum_constant_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS , this . insert_space_after_comma_in_enum_declarations ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS , this . insert_space_after_comma_in_explicit_constructor_call_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS , this . insert_space_after_comma_in_for_increments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS , this . insert_space_after_comma_in_for_inits ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS , this . insert_space_after_comma_in_method_invocation_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS , this . insert_space_after_comma_in_method_declaration_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS , this . insert_space_after_comma_in_method_declaration_throws ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS , this . insert_space_after_comma_in_multiple_field_declarations ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS , this . insert_space_after_comma_in_multiple_local_declarations ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE , this . insert_space_after_comma_in_parameterized_type_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES , this . insert_space_after_comma_in_superinterfaces ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS , this . insert_space_after_comma_in_type_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS , this . insert_space_after_comma_in_type_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION , this . insert_space_after_opening_bracket_in_array_allocation_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS , this . insert_space_after_ellipsis ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE , this . insert_space_after_opening_angle_bracket_in_parameterized_type_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS , this . insert_space_after_opening_angle_bracket_in_type_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS , this . insert_space_after_opening_angle_bracket_in_type_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE , this . insert_space_after_opening_bracket_in_array_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER , this . insert_space_after_opening_brace_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION , this . insert_space_after_opening_paren_in_annotation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST , this . insert_space_after_opening_paren_in_cast ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH , this . insert_space_after_opening_paren_in_catch ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION , this . insert_space_after_opening_paren_in_constructor_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT , this . insert_space_after_opening_paren_in_enum_constant ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR , this . insert_space_after_opening_paren_in_for ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF , this . insert_space_after_opening_paren_in_if ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION , this . insert_space_after_opening_paren_in_method_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION , this . insert_space_after_opening_paren_in_method_invocation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION , this . insert_space_after_opening_paren_in_parenthesized_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH , this . insert_space_after_opening_paren_in_switch ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED , this . insert_space_after_opening_paren_in_synchronized ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_TRY , this . insert_space_after_opening_paren_in_try ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE , this . insert_space_after_opening_paren_in_while ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR , this . insert_space_after_postfix_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR , this . insert_space_after_prefix_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL , this . insert_space_after_question_in_conditional ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_WILDCARD , this . insert_space_after_question_in_wilcard ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR , this . insert_space_after_semicolon_in_for ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_TRY_RESOURCES , this . insert_space_after_semicolon_in_try_resources ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR , this . insert_space_after_unary_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_AND_IN_TYPE_PARAMETER , this . insert_space_before_and_in_type_parameter ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION , this . insert_space_before_at_in_annotation_type_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR , this . insert_space_before_assignment_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR , this . insert_space_before_binary_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE , this . insert_space_before_closing_angle_bracket_in_parameterized_type_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS , this . insert_space_before_closing_angle_bracket_in_type_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS , this . insert_space_before_closing_angle_bracket_in_type_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER , this . insert_space_before_closing_brace_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION , this . insert_space_before_closing_bracket_in_array_allocation_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE , this . insert_space_before_closing_bracket_in_array_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION , this . insert_space_before_closing_paren_in_annotation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST , this . insert_space_before_closing_paren_in_cast ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH , this . insert_space_before_closing_paren_in_catch ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION , this . insert_space_before_closing_paren_in_constructor_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT , this . insert_space_before_closing_paren_in_enum_constant ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR , this . insert_space_before_closing_paren_in_for ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF , this . insert_space_before_closing_paren_in_if ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION , this . insert_space_before_closing_paren_in_method_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION , this . insert_space_before_closing_paren_in_method_invocation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION , this . insert_space_before_closing_paren_in_parenthesized_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH , this . insert_space_before_closing_paren_in_switch ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED , this . insert_space_before_closing_paren_in_synchronized ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_TRY , this . insert_space_before_closing_paren_in_try ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE , this . insert_space_before_closing_paren_in_while ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT , this . insert_space_before_colon_in_assert ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE , this . insert_space_before_colon_in_case ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL , this . insert_space_before_colon_in_conditional ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT , this . insert_space_before_colon_in_default ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR , this . insert_space_before_colon_in_for ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT , this . insert_space_before_colon_in_labeled_statement ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION , this . insert_space_before_comma_in_allocation_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION , this . insert_space_before_comma_in_annotation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER , this . insert_space_before_comma_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS , this . insert_space_before_comma_in_constructor_declaration_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS , this . insert_space_before_comma_in_constructor_declaration_throws ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS , this . insert_space_before_comma_in_enum_constant_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS , this . insert_space_before_comma_in_enum_declarations ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS , this . insert_space_before_comma_in_explicit_constructor_call_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS , this . insert_space_before_comma_in_for_increments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS , this . insert_space_before_comma_in_for_inits ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS , this . insert_space_before_comma_in_method_invocation_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS , this . insert_space_before_comma_in_method_declaration_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS , this . insert_space_before_comma_in_method_declaration_throws ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS , this . insert_space_before_comma_in_multiple_field_declarations ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS , this . insert_space_before_comma_in_multiple_local_declarations ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES , this . insert_space_before_comma_in_superinterfaces ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS , this . insert_space_before_comma_in_type_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS , this . insert_space_before_comma_in_type_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE , this . insert_space_before_comma_in_parameterized_type_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS , this . insert_space_before_ellipsis ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE , this . insert_space_before_opening_angle_bracket_in_parameterized_type_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS , this . insert_space_before_opening_angle_bracket_in_type_arguments ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS , this . insert_space_before_opening_angle_bracket_in_type_parameters ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION , this . insert_space_before_opening_brace_in_annotation_type_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION , this . insert_space_before_opening_brace_in_anonymous_type_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER , this . insert_space_before_opening_brace_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK , this . insert_space_before_opening_brace_in_block ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION , this . insert_space_before_opening_brace_in_constructor_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT , this . insert_space_before_opening_brace_in_enum_constant ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION , this . insert_space_before_opening_brace_in_enum_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION , this . insert_space_before_opening_brace_in_method_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION , this . insert_space_before_opening_brace_in_type_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION , this . insert_space_before_opening_bracket_in_array_allocation_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE , this . insert_space_before_opening_bracket_in_array_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE , this . insert_space_before_opening_bracket_in_array_type_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION , this . insert_space_before_opening_paren_in_annotation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION , this . insert_space_before_opening_paren_in_annotation_type_member_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH , this . insert_space_before_opening_paren_in_catch ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION , this . insert_space_before_opening_paren_in_constructor_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT , this . insert_space_before_opening_paren_in_enum_constant ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR , this . insert_space_before_opening_paren_in_for ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF , this . insert_space_before_opening_paren_in_if ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION , this . insert_space_before_opening_paren_in_method_invocation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION , this . insert_space_before_opening_paren_in_method_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH , this . insert_space_before_opening_paren_in_switch ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH , this . insert_space_before_opening_brace_in_switch ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED , this . insert_space_before_opening_paren_in_synchronized ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY , this . insert_space_before_opening_paren_in_try ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION , this . insert_space_before_opening_paren_in_parenthesized_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE , this . insert_space_before_opening_paren_in_while ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN , this . insert_space_before_parenthesized_expression_in_return ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW , this . insert_space_before_parenthesized_expression_in_throw ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR , this . insert_space_before_postfix_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR , this . insert_space_before_prefix_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL , this . insert_space_before_question_in_conditional ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD , this . insert_space_before_question_in_wilcard ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON , this . insert_space_before_semicolon ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR , this . insert_space_before_semicolon_in_for ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_TRY_RESOURCES , this . insert_space_before_semicolon_in_try_resources ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR , this . insert_space_before_unary_operator ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE , this . insert_space_between_brackets_in_array_type_reference ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER , this . insert_space_between_empty_braces_in_array_initializer ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION , this . insert_space_between_empty_brackets_in_array_allocation_expression ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION , this . insert_space_between_empty_parens_in_annotation_type_member_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION , this . insert_space_between_empty_parens_in_constructor_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT , this . insert_space_between_empty_parens_in_enum_constant ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION , this . insert_space_between_empty_parens_in_method_declaration ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION , this . insert_space_between_empty_parens_in_method_invocation ? JavaCore . INSERT : JavaCore . DO_NOT_INSERT ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_COMPACT_ELSE_IF , this . compact_else_if ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE , this . keep_guardian_clause_on_one_line ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE , this . keep_else_statement_on_same_line ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE , this . keep_empty_array_initializer_on_one_line ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE , this . keep_simple_if_on_one_line ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE , this . keep_then_statement_on_same_line ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN , this . never_indent_block_comments_on_first_column ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN , this . never_indent_line_comments_on_first_column ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE , Integer . toString ( this . number_of_empty_lines_to_preserve ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_JOIN_WRAPPED_LINES , this . join_wrapped_lines ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_JOIN_LINES_IN_COMMENTS , this . join_lines_in_comments ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE , this . put_empty_statement_on_new_line ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_LINE_SPLIT , Integer . toString ( this . page_width ) ) ; switch ( this . tab_char ) { case SPACE : options . put ( DefaultCodeFormatterConstants . FORMATTER_TAB_CHAR , JavaCore . SPACE ) ; break ; case TAB : options . put ( DefaultCodeFormatterConstants . FORMATTER_TAB_CHAR , JavaCore . TAB ) ; break ; case MIXED : options . put ( DefaultCodeFormatterConstants . FORMATTER_TAB_CHAR , DefaultCodeFormatterConstants . MIXED ) ; break ; } options . put ( DefaultCodeFormatterConstants . FORMATTER_TAB_SIZE , Integer . toString ( this . tab_size ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS , this . use_tabs_only_for_leading_indentations ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_WRAP_BEFORE_BINARY_OPERATOR , this . wrap_before_binary_operator ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_WRAP_BEFORE_OR_OPERATOR_MULTICATCH , this . wrap_before_or_operator_multicatch ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_DISABLING_TAG , this . disabling_tag == null ? Util . EMPTY_STRING : new String ( this . disabling_tag ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_ENABLING_TAG , this . enabling_tag == null ? Util . EMPTY_STRING : new String ( this . enabling_tag ) ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_USE_ON_OFF_TAGS , this . use_tags ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; options . put ( DefaultCodeFormatterConstants . FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED , this . wrap_outer_expressions_when_nested ? DefaultCodeFormatterConstants . TRUE : DefaultCodeFormatterConstants . FALSE ) ; return options ; } public void set ( Map settings ) { final Object alignmentForArgumentsInAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION ) ; if ( alignmentForArgumentsInAllocationExpressionOption != null ) { try { this . alignment_for_arguments_in_allocation_expression = Integer . parseInt ( ( String ) alignmentForArgumentsInAllocationExpressionOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_arguments_in_allocation_expression = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_arguments_in_allocation_expression = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForArgumentsInAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ANNOTATION ) ; if ( alignmentForArgumentsInAnnotationOption != null ) { try { this . alignment_for_arguments_in_annotation = Integer . parseInt ( ( String ) alignmentForArgumentsInAnnotationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_arguments_in_annotation = Alignment . M_NO_ALIGNMENT ; } catch ( ClassCastException e ) { this . alignment_for_arguments_in_annotation = Alignment . M_NO_ALIGNMENT ; } } final Object alignmentForArgumentsInEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT ) ; if ( alignmentForArgumentsInEnumConstantOption != null ) { try { this . alignment_for_arguments_in_enum_constant = Integer . parseInt ( ( String ) alignmentForArgumentsInEnumConstantOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_arguments_in_enum_constant = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_arguments_in_enum_constant = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForArgumentsInExplicitConstructorCallOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL ) ; if ( alignmentForArgumentsInExplicitConstructorCallOption != null ) { try { this . alignment_for_arguments_in_explicit_constructor_call = Integer . parseInt ( ( String ) alignmentForArgumentsInExplicitConstructorCallOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_arguments_in_explicit_constructor_call = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_arguments_in_explicit_constructor_call = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForArgumentsInMethodInvocationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION ) ; if ( alignmentForArgumentsInMethodInvocationOption != null ) { try { this . alignment_for_arguments_in_method_invocation = Integer . parseInt ( ( String ) alignmentForArgumentsInMethodInvocationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_arguments_in_method_invocation = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_arguments_in_method_invocation = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForArgumentsInQualifiedAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION ) ; if ( alignmentForArgumentsInQualifiedAllocationExpressionOption != null ) { try { this . alignment_for_arguments_in_qualified_allocation_expression = Integer . parseInt ( ( String ) alignmentForArgumentsInQualifiedAllocationExpressionOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_arguments_in_qualified_allocation_expression = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_arguments_in_qualified_allocation_expression = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForAssignmentOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ASSIGNMENT ) ; if ( alignmentForAssignmentOption != null ) { try { this . alignment_for_assignment = Integer . parseInt ( ( String ) alignmentForAssignmentOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_assignment = Alignment . M_ONE_PER_LINE_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_assignment = Alignment . M_ONE_PER_LINE_SPLIT ; } } final Object alignmentForBinaryExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION ) ; if ( alignmentForBinaryExpressionOption != null ) { try { this . alignment_for_binary_expression = Integer . parseInt ( ( String ) alignmentForBinaryExpressionOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_binary_expression = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_binary_expression = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForCompactIfOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_COMPACT_IF ) ; if ( alignmentForCompactIfOption != null ) { try { this . alignment_for_compact_if = Integer . parseInt ( ( String ) alignmentForCompactIfOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_compact_if = Alignment . M_ONE_PER_LINE_SPLIT | Alignment . M_INDENT_BY_ONE ; } catch ( ClassCastException e ) { this . alignment_for_compact_if = Alignment . M_ONE_PER_LINE_SPLIT | Alignment . M_INDENT_BY_ONE ; } } final Object alignmentForConditionalExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION ) ; if ( alignmentForConditionalExpressionOption != null ) { try { this . alignment_for_conditional_expression = Integer . parseInt ( ( String ) alignmentForConditionalExpressionOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_conditional_expression = Alignment . M_ONE_PER_LINE_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_conditional_expression = Alignment . M_ONE_PER_LINE_SPLIT ; } } final Object alignmentForEnumConstantsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS ) ; if ( alignmentForEnumConstantsOption != null ) { try { this . alignment_for_enum_constants = Integer . parseInt ( ( String ) alignmentForEnumConstantsOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_enum_constants = Alignment . NONE ; } catch ( ClassCastException e ) { this . alignment_for_enum_constants = Alignment . NONE ; } } final Object alignmentForExpressionsInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER ) ; if ( alignmentForExpressionsInArrayInitializerOption != null ) { try { this . alignment_for_expressions_in_array_initializer = Integer . parseInt ( ( String ) alignmentForExpressionsInArrayInitializerOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_expressions_in_array_initializer = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_expressions_in_array_initializer = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_METHOD_DECLARATION ) ; if ( alignmentForMethodDeclarationOption != null ) { try { this . alignment_for_method_declaration = Integer . parseInt ( ( String ) alignmentForMethodDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_method_declaration = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_method_declaration = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForMultipleFieldsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS ) ; if ( alignmentForMultipleFieldsOption != null ) { try { this . alignment_for_multiple_fields = Integer . parseInt ( ( String ) alignmentForMultipleFieldsOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_multiple_fields = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_multiple_fields = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForParametersInConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION ) ; if ( alignmentForParametersInConstructorDeclarationOption != null ) { try { this . alignment_for_parameters_in_constructor_declaration = Integer . parseInt ( ( String ) alignmentForParametersInConstructorDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_parameters_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_parameters_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForParametersInMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION ) ; if ( alignmentForParametersInMethodDeclarationOption != null ) { try { this . alignment_for_parameters_in_method_declaration = Integer . parseInt ( ( String ) alignmentForParametersInMethodDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_parameters_in_method_declaration = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_parameters_in_method_declaration = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForResourcesInTry = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY ) ; if ( alignmentForResourcesInTry != null ) { try { this . alignment_for_resources_in_try = Integer . parseInt ( ( String ) alignmentForResourcesInTry ) ; } catch ( NumberFormatException e ) { this . alignment_for_resources_in_try = Alignment . M_NEXT_PER_LINE_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_resources_in_try = Alignment . M_NEXT_PER_LINE_SPLIT ; } } final Object alignmentForSelectorInMethodInvocationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION ) ; if ( alignmentForSelectorInMethodInvocationOption != null ) { try { this . alignment_for_selector_in_method_invocation = Integer . parseInt ( ( String ) alignmentForSelectorInMethodInvocationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_selector_in_method_invocation = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_selector_in_method_invocation = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForSuperclassInTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION ) ; if ( alignmentForSuperclassInTypeDeclarationOption != null ) { try { this . alignment_for_superclass_in_type_declaration = Integer . parseInt ( ( String ) alignmentForSuperclassInTypeDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_superclass_in_type_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_superclass_in_type_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; } } final Object alignmentForSuperinterfacesInEnumDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION ) ; if ( alignmentForSuperinterfacesInEnumDeclarationOption != null ) { try { this . alignment_for_superinterfaces_in_enum_declaration = Integer . parseInt ( ( String ) alignmentForSuperinterfacesInEnumDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_superinterfaces_in_enum_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_superinterfaces_in_enum_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; } } final Object alignmentForSuperinterfacesInTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION ) ; if ( alignmentForSuperinterfacesInTypeDeclarationOption != null ) { try { this . alignment_for_superinterfaces_in_type_declaration = Integer . parseInt ( ( String ) alignmentForSuperinterfacesInTypeDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_superinterfaces_in_type_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_superinterfaces_in_type_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; } } final Object alignmentForThrowsClauseInConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION ) ; if ( alignmentForThrowsClauseInConstructorDeclarationOption != null ) { try { this . alignment_for_throws_clause_in_constructor_declaration = Integer . parseInt ( ( String ) alignmentForThrowsClauseInConstructorDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_throws_clause_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_throws_clause_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForThrowsClauseInMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION ) ; if ( alignmentForThrowsClauseInMethodDeclarationOption != null ) { try { this . alignment_for_throws_clause_in_method_declaration = Integer . parseInt ( ( String ) alignmentForThrowsClauseInMethodDeclarationOption ) ; } catch ( NumberFormatException e ) { this . alignment_for_throws_clause_in_method_declaration = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_throws_clause_in_method_declaration = Alignment . M_COMPACT_SPLIT ; } } final Object alignmentForUnionTypeInMulticatch = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH ) ; if ( alignmentForUnionTypeInMulticatch != null ) { try { this . alignment_for_union_type_in_multicatch = Integer . parseInt ( ( String ) alignmentForUnionTypeInMulticatch ) ; } catch ( NumberFormatException e ) { this . alignment_for_union_type_in_multicatch = Alignment . M_COMPACT_SPLIT ; } catch ( ClassCastException e ) { this . alignment_for_union_type_in_multicatch = Alignment . M_COMPACT_SPLIT ; } } final Object alignTypeMembersOnColumnsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS ) ; if ( alignTypeMembersOnColumnsOption != null ) { this . align_type_members_on_columns = DefaultCodeFormatterConstants . TRUE . equals ( alignTypeMembersOnColumnsOption ) ; } final Object bracePositionForAnnotationTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION ) ; if ( bracePositionForAnnotationTypeDeclarationOption != null ) { try { this . brace_position_for_annotation_type_declaration = ( String ) bracePositionForAnnotationTypeDeclarationOption ; } catch ( ClassCastException e ) { this . brace_position_for_annotation_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForAnonymousTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION ) ; if ( bracePositionForAnonymousTypeDeclarationOption != null ) { try { this . brace_position_for_anonymous_type_declaration = ( String ) bracePositionForAnonymousTypeDeclarationOption ; } catch ( ClassCastException e ) { this . brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER ) ; if ( bracePositionForArrayInitializerOption != null ) { try { this . brace_position_for_array_initializer = ( String ) bracePositionForArrayInitializerOption ; } catch ( ClassCastException e ) { this . brace_position_for_array_initializer = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForBlockOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_BLOCK ) ; if ( bracePositionForBlockOption != null ) { try { this . brace_position_for_block = ( String ) bracePositionForBlockOption ; } catch ( ClassCastException e ) { this . brace_position_for_block = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForBlockInCaseOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE ) ; if ( bracePositionForBlockInCaseOption != null ) { try { this . brace_position_for_block_in_case = ( String ) bracePositionForBlockInCaseOption ; } catch ( ClassCastException e ) { this . brace_position_for_block_in_case = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION ) ; if ( bracePositionForConstructorDeclarationOption != null ) { try { this . brace_position_for_constructor_declaration = ( String ) bracePositionForConstructorDeclarationOption ; } catch ( ClassCastException e ) { this . brace_position_for_constructor_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT ) ; if ( bracePositionForEnumConstantOption != null ) { try { this . brace_position_for_enum_constant = ( String ) bracePositionForEnumConstantOption ; } catch ( ClassCastException e ) { this . brace_position_for_enum_constant = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForEnumDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION ) ; if ( bracePositionForEnumDeclarationOption != null ) { try { this . brace_position_for_enum_declaration = ( String ) bracePositionForEnumDeclarationOption ; } catch ( ClassCastException e ) { this . brace_position_for_enum_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION ) ; if ( bracePositionForMethodDeclarationOption != null ) { try { this . brace_position_for_method_declaration = ( String ) bracePositionForMethodDeclarationOption ; } catch ( ClassCastException e ) { this . brace_position_for_method_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForSwitchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_SWITCH ) ; if ( bracePositionForSwitchOption != null ) { try { this . brace_position_for_switch = ( String ) bracePositionForSwitchOption ; } catch ( ClassCastException e ) { this . brace_position_for_switch = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object bracePositionForTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION ) ; if ( bracePositionForTypeDeclarationOption != null ) { try { this . brace_position_for_type_declaration = ( String ) bracePositionForTypeDeclarationOption ; } catch ( ClassCastException e ) { this . brace_position_for_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; } } final Object continuationIndentationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_CONTINUATION_INDENTATION ) ; if ( continuationIndentationOption != null ) { try { this . continuation_indentation = Integer . parseInt ( ( String ) continuationIndentationOption ) ; } catch ( NumberFormatException e ) { this . continuation_indentation = <NUM_LIT:2> ; } catch ( ClassCastException e ) { this . continuation_indentation = <NUM_LIT:2> ; } } final Object continuationIndentationForArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER ) ; if ( continuationIndentationForArrayInitializerOption != null ) { try { this . continuation_indentation_for_array_initializer = Integer . parseInt ( ( String ) continuationIndentationForArrayInitializerOption ) ; } catch ( NumberFormatException e ) { this . continuation_indentation_for_array_initializer = <NUM_LIT:2> ; } catch ( ClassCastException e ) { this . continuation_indentation_for_array_initializer = <NUM_LIT:2> ; } } final Object blankLinesAfterImportsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_AFTER_IMPORTS ) ; if ( blankLinesAfterImportsOption != null ) { try { this . blank_lines_after_imports = Integer . parseInt ( ( String ) blankLinesAfterImportsOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_after_imports = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_after_imports = <NUM_LIT:0> ; } } final Object blankLinesAfterPackageOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_AFTER_PACKAGE ) ; if ( blankLinesAfterPackageOption != null ) { try { this . blank_lines_after_package = Integer . parseInt ( ( String ) blankLinesAfterPackageOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_after_package = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_after_package = <NUM_LIT:0> ; } } final Object blankLinesBeforeFieldOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_FIELD ) ; if ( blankLinesBeforeFieldOption != null ) { try { this . blank_lines_before_field = Integer . parseInt ( ( String ) blankLinesBeforeFieldOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_before_field = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_before_field = <NUM_LIT:0> ; } } final Object blankLinesBeforeFirstClassBodyDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION ) ; if ( blankLinesBeforeFirstClassBodyDeclarationOption != null ) { try { this . blank_lines_before_first_class_body_declaration = Integer . parseInt ( ( String ) blankLinesBeforeFirstClassBodyDeclarationOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_before_first_class_body_declaration = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_before_first_class_body_declaration = <NUM_LIT:0> ; } } final Object blankLinesBeforeImportsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_IMPORTS ) ; if ( blankLinesBeforeImportsOption != null ) { try { this . blank_lines_before_imports = Integer . parseInt ( ( String ) blankLinesBeforeImportsOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_before_imports = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_before_imports = <NUM_LIT:0> ; } } final Object blankLinesBeforeMemberTypeOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE ) ; if ( blankLinesBeforeMemberTypeOption != null ) { try { this . blank_lines_before_member_type = Integer . parseInt ( ( String ) blankLinesBeforeMemberTypeOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_before_member_type = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_before_member_type = <NUM_LIT:0> ; } } final Object blankLinesBeforeMethodOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_METHOD ) ; if ( blankLinesBeforeMethodOption != null ) { try { this . blank_lines_before_method = Integer . parseInt ( ( String ) blankLinesBeforeMethodOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_before_method = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_before_method = <NUM_LIT:0> ; } } final Object blankLinesBeforeNewChunkOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK ) ; if ( blankLinesBeforeNewChunkOption != null ) { try { this . blank_lines_before_new_chunk = Integer . parseInt ( ( String ) blankLinesBeforeNewChunkOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_before_new_chunk = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_before_new_chunk = <NUM_LIT:0> ; } } final Object blankLinesBeforePackageOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BEFORE_PACKAGE ) ; if ( blankLinesBeforePackageOption != null ) { try { this . blank_lines_before_package = Integer . parseInt ( ( String ) blankLinesBeforePackageOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_before_package = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_before_package = <NUM_LIT:0> ; } } final Object blankLinesBetweenImportGroupsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS ) ; if ( blankLinesBetweenImportGroupsOption != null ) { try { this . blank_lines_between_import_groups = Integer . parseInt ( ( String ) blankLinesBetweenImportGroupsOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_between_import_groups = <NUM_LIT:1> ; } catch ( ClassCastException e ) { this . blank_lines_between_import_groups = <NUM_LIT:1> ; } } final Object blankLinesBetweenTypeDeclarationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS ) ; if ( blankLinesBetweenTypeDeclarationsOption != null ) { try { this . blank_lines_between_type_declarations = Integer . parseInt ( ( String ) blankLinesBetweenTypeDeclarationsOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_between_type_declarations = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_between_type_declarations = <NUM_LIT:0> ; } } final Object blankLinesAtBeginningOfMethodBodyOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY ) ; if ( blankLinesAtBeginningOfMethodBodyOption != null ) { try { this . blank_lines_at_beginning_of_method_body = Integer . parseInt ( ( String ) blankLinesAtBeginningOfMethodBodyOption ) ; } catch ( NumberFormatException e ) { this . blank_lines_at_beginning_of_method_body = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . blank_lines_at_beginning_of_method_body = <NUM_LIT:0> ; } } setDeprecatedOptions ( settings ) ; final Object commentFormatJavadocCommentOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT ) ; if ( commentFormatJavadocCommentOption != null ) { this . comment_format_javadoc_comment = DefaultCodeFormatterConstants . TRUE . equals ( commentFormatJavadocCommentOption ) ; } final Object commentFormatBlockCommentOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT ) ; if ( commentFormatBlockCommentOption != null ) { this . comment_format_block_comment = DefaultCodeFormatterConstants . TRUE . equals ( commentFormatBlockCommentOption ) ; } final Object commentFormatLineCommentOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_LINE_COMMENT ) ; if ( commentFormatLineCommentOption != null ) { this . comment_format_line_comment = DefaultCodeFormatterConstants . TRUE . equals ( commentFormatLineCommentOption ) ; } final Object formatLineCommentStartingOnFirstColumnOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN ) ; if ( formatLineCommentStartingOnFirstColumnOption != null ) { this . comment_format_line_comment_starting_on_first_column = DefaultCodeFormatterConstants . TRUE . equals ( formatLineCommentStartingOnFirstColumnOption ) ; } final Object commentFormatHeaderOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_HEADER ) ; if ( commentFormatHeaderOption != null ) { this . comment_format_header = DefaultCodeFormatterConstants . TRUE . equals ( commentFormatHeaderOption ) ; } final Object commentFormatHtmlOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_HTML ) ; if ( commentFormatHtmlOption != null ) { this . comment_format_html = DefaultCodeFormatterConstants . TRUE . equals ( commentFormatHtmlOption ) ; } final Object commentFormatSourceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_SOURCE ) ; if ( commentFormatSourceOption != null ) { this . comment_format_source = DefaultCodeFormatterConstants . TRUE . equals ( commentFormatSourceOption ) ; } final Object commentIndentParameterDescriptionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION ) ; if ( commentIndentParameterDescriptionOption != null ) { this . comment_indent_parameter_description = DefaultCodeFormatterConstants . TRUE . equals ( commentIndentParameterDescriptionOption ) ; } final Object commentIndentRootTagsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INDENT_ROOT_TAGS ) ; if ( commentIndentRootTagsOption != null ) { this . comment_indent_root_tags = DefaultCodeFormatterConstants . TRUE . equals ( commentIndentRootTagsOption ) ; } final Object commentInsertEmptyLineBeforeRootTagsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS ) ; if ( commentInsertEmptyLineBeforeRootTagsOption != null ) { this . comment_insert_empty_line_before_root_tags = JavaCore . INSERT . equals ( commentInsertEmptyLineBeforeRootTagsOption ) ; } final Object commentInsertNewLineForParameterOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER ) ; if ( commentInsertNewLineForParameterOption != null ) { this . comment_insert_new_line_for_parameter = JavaCore . INSERT . equals ( commentInsertNewLineForParameterOption ) ; } final Object commentPreserveWhiteSpaceBetweenCodeAndLineCommentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT ) ; if ( commentPreserveWhiteSpaceBetweenCodeAndLineCommentsOption != null ) { this . comment_preserve_white_space_between_code_and_line_comments = DefaultCodeFormatterConstants . TRUE . equals ( commentPreserveWhiteSpaceBetweenCodeAndLineCommentsOption ) ; } final Object commentLineLengthOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_LINE_LENGTH ) ; if ( commentLineLengthOption != null ) { try { this . comment_line_length = Integer . parseInt ( ( String ) commentLineLengthOption ) ; } catch ( NumberFormatException e ) { this . comment_line_length = <NUM_LIT> ; } catch ( ClassCastException e ) { this . comment_line_length = <NUM_LIT> ; } } final Object commentNewLinesAtBlockBoundariesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES ) ; if ( commentNewLinesAtBlockBoundariesOption != null ) { this . comment_new_lines_at_block_boundaries = DefaultCodeFormatterConstants . TRUE . equals ( commentNewLinesAtBlockBoundariesOption ) ; } final Object commentNewLinesAtJavadocBoundariesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES ) ; if ( commentNewLinesAtJavadocBoundariesOption != null ) { this . comment_new_lines_at_javadoc_boundaries = DefaultCodeFormatterConstants . TRUE . equals ( commentNewLinesAtJavadocBoundariesOption ) ; } final Object indentStatementsCompareToBlockOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK ) ; if ( indentStatementsCompareToBlockOption != null ) { this . indent_statements_compare_to_block = DefaultCodeFormatterConstants . TRUE . equals ( indentStatementsCompareToBlockOption ) ; } final Object indentStatementsCompareToBodyOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY ) ; if ( indentStatementsCompareToBodyOption != null ) { this . indent_statements_compare_to_body = DefaultCodeFormatterConstants . TRUE . equals ( indentStatementsCompareToBodyOption ) ; } final Object indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER ) ; if ( indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption != null ) { this . indent_body_declarations_compare_to_annotation_declaration_header = DefaultCodeFormatterConstants . TRUE . equals ( indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption ) ; } final Object indentBodyDeclarationsCompareToEnumConstantHeaderOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER ) ; if ( indentBodyDeclarationsCompareToEnumConstantHeaderOption != null ) { this . indent_body_declarations_compare_to_enum_constant_header = DefaultCodeFormatterConstants . TRUE . equals ( indentBodyDeclarationsCompareToEnumConstantHeaderOption ) ; } final Object indentBodyDeclarationsCompareToEnumDeclarationHeaderOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER ) ; if ( indentBodyDeclarationsCompareToEnumDeclarationHeaderOption != null ) { this . indent_body_declarations_compare_to_enum_declaration_header = DefaultCodeFormatterConstants . TRUE . equals ( indentBodyDeclarationsCompareToEnumDeclarationHeaderOption ) ; } final Object indentBodyDeclarationsCompareToTypeHeaderOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER ) ; if ( indentBodyDeclarationsCompareToTypeHeaderOption != null ) { this . indent_body_declarations_compare_to_type_header = DefaultCodeFormatterConstants . TRUE . equals ( indentBodyDeclarationsCompareToTypeHeaderOption ) ; } final Object indentBreaksCompareToCasesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES ) ; if ( indentBreaksCompareToCasesOption != null ) { this . indent_breaks_compare_to_cases = DefaultCodeFormatterConstants . TRUE . equals ( indentBreaksCompareToCasesOption ) ; } final Object indentEmptyLinesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_EMPTY_LINES ) ; if ( indentEmptyLinesOption != null ) { this . indent_empty_lines = DefaultCodeFormatterConstants . TRUE . equals ( indentEmptyLinesOption ) ; } final Object indentSwitchstatementsCompareToCasesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES ) ; if ( indentSwitchstatementsCompareToCasesOption != null ) { this . indent_switchstatements_compare_to_cases = DefaultCodeFormatterConstants . TRUE . equals ( indentSwitchstatementsCompareToCasesOption ) ; } final Object indentSwitchstatementsCompareToSwitchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH ) ; if ( indentSwitchstatementsCompareToSwitchOption != null ) { this . indent_switchstatements_compare_to_switch = DefaultCodeFormatterConstants . TRUE . equals ( indentSwitchstatementsCompareToSwitchOption ) ; } final Object indentationSizeOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INDENTATION_SIZE ) ; if ( indentationSizeOption != null ) { try { this . indentation_size = Integer . parseInt ( ( String ) indentationSizeOption ) ; } catch ( NumberFormatException e ) { this . indentation_size = <NUM_LIT:4> ; } catch ( ClassCastException e ) { this . indentation_size = <NUM_LIT:4> ; } } final Object insertNewLineAfterOpeningBraceInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER ) ; if ( insertNewLineAfterOpeningBraceInArrayInitializerOption != null ) { this . insert_new_line_after_opening_brace_in_array_initializer = JavaCore . INSERT . equals ( insertNewLineAfterOpeningBraceInArrayInitializerOption ) ; } final Object insertNewLineAtEndOfFileIfMissingOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING ) ; if ( insertNewLineAtEndOfFileIfMissingOption != null ) { this . insert_new_line_at_end_of_file_if_missing = JavaCore . INSERT . equals ( insertNewLineAtEndOfFileIfMissingOption ) ; } final Object insertNewLineBeforeCatchInTryStatementOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT ) ; if ( insertNewLineBeforeCatchInTryStatementOption != null ) { this . insert_new_line_before_catch_in_try_statement = JavaCore . INSERT . equals ( insertNewLineBeforeCatchInTryStatementOption ) ; } final Object insertNewLineBeforeClosingBraceInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER ) ; if ( insertNewLineBeforeClosingBraceInArrayInitializerOption != null ) { this . insert_new_line_before_closing_brace_in_array_initializer = JavaCore . INSERT . equals ( insertNewLineBeforeClosingBraceInArrayInitializerOption ) ; } final Object insertNewLineBeforeElseInIfStatementOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT ) ; if ( insertNewLineBeforeElseInIfStatementOption != null ) { this . insert_new_line_before_else_in_if_statement = JavaCore . INSERT . equals ( insertNewLineBeforeElseInIfStatementOption ) ; } final Object insertNewLineBeforeFinallyInTryStatementOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT ) ; if ( insertNewLineBeforeFinallyInTryStatementOption != null ) { this . insert_new_line_before_finally_in_try_statement = JavaCore . INSERT . equals ( insertNewLineBeforeFinallyInTryStatementOption ) ; } final Object insertNewLineBeforeWhileInDoStatementOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT ) ; if ( insertNewLineBeforeWhileInDoStatementOption != null ) { this . insert_new_line_before_while_in_do_statement = JavaCore . INSERT . equals ( insertNewLineBeforeWhileInDoStatementOption ) ; } final Object insertNewLineInEmptyAnonymousTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION ) ; if ( insertNewLineInEmptyAnonymousTypeDeclarationOption != null ) { this . insert_new_line_in_empty_anonymous_type_declaration = JavaCore . INSERT . equals ( insertNewLineInEmptyAnonymousTypeDeclarationOption ) ; } final Object insertNewLineInEmptyBlockOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK ) ; if ( insertNewLineInEmptyBlockOption != null ) { this . insert_new_line_in_empty_block = JavaCore . INSERT . equals ( insertNewLineInEmptyBlockOption ) ; } final Object insertNewLineInEmptyAnnotationDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION ) ; if ( insertNewLineInEmptyAnnotationDeclarationOption != null ) { this . insert_new_line_in_empty_annotation_declaration = JavaCore . INSERT . equals ( insertNewLineInEmptyAnnotationDeclarationOption ) ; } final Object insertNewLineInEmptyEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT ) ; if ( insertNewLineInEmptyEnumConstantOption != null ) { this . insert_new_line_in_empty_enum_constant = JavaCore . INSERT . equals ( insertNewLineInEmptyEnumConstantOption ) ; } final Object insertNewLineInEmptyEnumDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION ) ; if ( insertNewLineInEmptyEnumDeclarationOption != null ) { this . insert_new_line_in_empty_enum_declaration = JavaCore . INSERT . equals ( insertNewLineInEmptyEnumDeclarationOption ) ; } final Object insertNewLineInEmptyMethodBodyOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY ) ; if ( insertNewLineInEmptyMethodBodyOption != null ) { this . insert_new_line_in_empty_method_body = JavaCore . INSERT . equals ( insertNewLineInEmptyMethodBodyOption ) ; } final Object insertNewLineInEmptyTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION ) ; if ( insertNewLineInEmptyTypeDeclarationOption != null ) { this . insert_new_line_in_empty_type_declaration = JavaCore . INSERT . equals ( insertNewLineInEmptyTypeDeclarationOption ) ; } final Object insertNewLineAfterLabelOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_LABEL ) ; if ( insertNewLineAfterLabelOption != null ) { this . insert_new_line_after_label = JavaCore . INSERT . equals ( insertNewLineAfterLabelOption ) ; } final Object insertSpaceAfterAndInWildcardOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER ) ; if ( insertSpaceAfterAndInWildcardOption != null ) { this . insert_space_after_and_in_type_parameter = JavaCore . INSERT . equals ( insertSpaceAfterAndInWildcardOption ) ; } final Object insertSpaceAfterAssignmentOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR ) ; if ( insertSpaceAfterAssignmentOperatorOption != null ) { this . insert_space_after_assignment_operator = JavaCore . INSERT . equals ( insertSpaceAfterAssignmentOperatorOption ) ; } final Object insertSpaceAfterAtInAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION ) ; if ( insertSpaceAfterAtInAnnotationOption != null ) { this . insert_space_after_at_in_annotation = JavaCore . INSERT . equals ( insertSpaceAfterAtInAnnotationOption ) ; } final Object insertSpaceAfterAtInAnnotationTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION ) ; if ( insertSpaceAfterAtInAnnotationTypeDeclarationOption != null ) { this . insert_space_after_at_in_annotation_type_declaration = JavaCore . INSERT . equals ( insertSpaceAfterAtInAnnotationTypeDeclarationOption ) ; } final Object insertSpaceAfterBinaryOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR ) ; if ( insertSpaceAfterBinaryOperatorOption != null ) { this . insert_space_after_binary_operator = JavaCore . INSERT . equals ( insertSpaceAfterBinaryOperatorOption ) ; } final Object insertSpaceAfterClosingAngleBracketInTypeArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS ) ; if ( insertSpaceAfterClosingAngleBracketInTypeArgumentsOption != null ) { this . insert_space_after_closing_angle_bracket_in_type_arguments = JavaCore . INSERT . equals ( insertSpaceAfterClosingAngleBracketInTypeArgumentsOption ) ; } final Object insertSpaceAfterClosingAngleBracketInTypeParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS ) ; if ( insertSpaceAfterClosingAngleBracketInTypeParametersOption != null ) { this . insert_space_after_closing_angle_bracket_in_type_parameters = JavaCore . INSERT . equals ( insertSpaceAfterClosingAngleBracketInTypeParametersOption ) ; } final Object insertSpaceAfterClosingParenInCastOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST ) ; if ( insertSpaceAfterClosingParenInCastOption != null ) { this . insert_space_after_closing_paren_in_cast = JavaCore . INSERT . equals ( insertSpaceAfterClosingParenInCastOption ) ; } final Object insertSpaceAfterClosingBraceInBlockOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK ) ; if ( insertSpaceAfterClosingBraceInBlockOption != null ) { this . insert_space_after_closing_brace_in_block = JavaCore . INSERT . equals ( insertSpaceAfterClosingBraceInBlockOption ) ; } final Object insertSpaceAfterColonInAssertOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT ) ; if ( insertSpaceAfterColonInAssertOption != null ) { this . insert_space_after_colon_in_assert = JavaCore . INSERT . equals ( insertSpaceAfterColonInAssertOption ) ; } final Object insertSpaceAfterColonInCaseOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE ) ; if ( insertSpaceAfterColonInCaseOption != null ) { this . insert_space_after_colon_in_case = JavaCore . INSERT . equals ( insertSpaceAfterColonInCaseOption ) ; } final Object insertSpaceAfterColonInConditionalOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL ) ; if ( insertSpaceAfterColonInConditionalOption != null ) { this . insert_space_after_colon_in_conditional = JavaCore . INSERT . equals ( insertSpaceAfterColonInConditionalOption ) ; } final Object insertSpaceAfterColonInForOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR ) ; if ( insertSpaceAfterColonInForOption != null ) { this . insert_space_after_colon_in_for = JavaCore . INSERT . equals ( insertSpaceAfterColonInForOption ) ; } final Object insertSpaceAfterColonInLabeledStatementOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT ) ; if ( insertSpaceAfterColonInLabeledStatementOption != null ) { this . insert_space_after_colon_in_labeled_statement = JavaCore . INSERT . equals ( insertSpaceAfterColonInLabeledStatementOption ) ; } final Object insertSpaceAfterCommaInAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION ) ; if ( insertSpaceAfterCommaInAllocationExpressionOption != null ) { this . insert_space_after_comma_in_allocation_expression = JavaCore . INSERT . equals ( insertSpaceAfterCommaInAllocationExpressionOption ) ; } final Object insertSpaceAfterCommaInAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION ) ; if ( insertSpaceAfterCommaInAnnotationOption != null ) { this . insert_space_after_comma_in_annotation = JavaCore . INSERT . equals ( insertSpaceAfterCommaInAnnotationOption ) ; } final Object insertSpaceAfterCommaInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER ) ; if ( insertSpaceAfterCommaInArrayInitializerOption != null ) { this . insert_space_after_comma_in_array_initializer = JavaCore . INSERT . equals ( insertSpaceAfterCommaInArrayInitializerOption ) ; } final Object insertSpaceAfterCommaInConstructorDeclarationParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS ) ; if ( insertSpaceAfterCommaInConstructorDeclarationParametersOption != null ) { this . insert_space_after_comma_in_constructor_declaration_parameters = JavaCore . INSERT . equals ( insertSpaceAfterCommaInConstructorDeclarationParametersOption ) ; } final Object insertSpaceAfterCommaInConstructorDeclarationThrowsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS ) ; if ( insertSpaceAfterCommaInConstructorDeclarationThrowsOption != null ) { this . insert_space_after_comma_in_constructor_declaration_throws = JavaCore . INSERT . equals ( insertSpaceAfterCommaInConstructorDeclarationThrowsOption ) ; } final Object insertSpaceAfterCommaInEnumConstantArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS ) ; if ( insertSpaceAfterCommaInEnumConstantArgumentsOption != null ) { this . insert_space_after_comma_in_enum_constant_arguments = JavaCore . INSERT . equals ( insertSpaceAfterCommaInEnumConstantArgumentsOption ) ; } final Object insertSpaceAfterCommaInEnumDeclarationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS ) ; if ( insertSpaceAfterCommaInEnumDeclarationsOption != null ) { this . insert_space_after_comma_in_enum_declarations = JavaCore . INSERT . equals ( insertSpaceAfterCommaInEnumDeclarationsOption ) ; } final Object insertSpaceAfterCommaInExplicitConstructorCallArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS ) ; if ( insertSpaceAfterCommaInExplicitConstructorCallArgumentsOption != null ) { this . insert_space_after_comma_in_explicit_constructor_call_arguments = JavaCore . INSERT . equals ( insertSpaceAfterCommaInExplicitConstructorCallArgumentsOption ) ; } final Object insertSpaceAfterCommaInForIncrementsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS ) ; if ( insertSpaceAfterCommaInForIncrementsOption != null ) { this . insert_space_after_comma_in_for_increments = JavaCore . INSERT . equals ( insertSpaceAfterCommaInForIncrementsOption ) ; } final Object insertSpaceAfterCommaInForInitsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS ) ; if ( insertSpaceAfterCommaInForInitsOption != null ) { this . insert_space_after_comma_in_for_inits = JavaCore . INSERT . equals ( insertSpaceAfterCommaInForInitsOption ) ; } final Object insertSpaceAfterCommaInMethodInvocationArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS ) ; if ( insertSpaceAfterCommaInMethodInvocationArgumentsOption != null ) { this . insert_space_after_comma_in_method_invocation_arguments = JavaCore . INSERT . equals ( insertSpaceAfterCommaInMethodInvocationArgumentsOption ) ; } final Object insertSpaceAfterCommaInMethodDeclarationParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS ) ; if ( insertSpaceAfterCommaInMethodDeclarationParametersOption != null ) { this . insert_space_after_comma_in_method_declaration_parameters = JavaCore . INSERT . equals ( insertSpaceAfterCommaInMethodDeclarationParametersOption ) ; } final Object insertSpaceAfterCommaInMethodDeclarationThrowsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS ) ; if ( insertSpaceAfterCommaInMethodDeclarationThrowsOption != null ) { this . insert_space_after_comma_in_method_declaration_throws = JavaCore . INSERT . equals ( insertSpaceAfterCommaInMethodDeclarationThrowsOption ) ; } final Object insertSpaceAfterCommaInMultipleFieldDeclarationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS ) ; if ( insertSpaceAfterCommaInMultipleFieldDeclarationsOption != null ) { this . insert_space_after_comma_in_multiple_field_declarations = JavaCore . INSERT . equals ( insertSpaceAfterCommaInMultipleFieldDeclarationsOption ) ; } final Object insertSpaceAfterCommaInMultipleLocalDeclarationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS ) ; if ( insertSpaceAfterCommaInMultipleLocalDeclarationsOption != null ) { this . insert_space_after_comma_in_multiple_local_declarations = JavaCore . INSERT . equals ( insertSpaceAfterCommaInMultipleLocalDeclarationsOption ) ; } final Object insertSpaceAfterCommaInParameterizedTypeReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE ) ; if ( insertSpaceAfterCommaInParameterizedTypeReferenceOption != null ) { this . insert_space_after_comma_in_parameterized_type_reference = JavaCore . INSERT . equals ( insertSpaceAfterCommaInParameterizedTypeReferenceOption ) ; } final Object insertSpaceAfterCommaInSuperinterfacesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES ) ; if ( insertSpaceAfterCommaInSuperinterfacesOption != null ) { this . insert_space_after_comma_in_superinterfaces = JavaCore . INSERT . equals ( insertSpaceAfterCommaInSuperinterfacesOption ) ; } final Object insertSpaceAfterCommaInTypeArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS ) ; if ( insertSpaceAfterCommaInTypeArgumentsOption != null ) { this . insert_space_after_comma_in_type_arguments = JavaCore . INSERT . equals ( insertSpaceAfterCommaInTypeArgumentsOption ) ; } final Object insertSpaceAfterCommaInTypeParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS ) ; if ( insertSpaceAfterCommaInTypeParametersOption != null ) { this . insert_space_after_comma_in_type_parameters = JavaCore . INSERT . equals ( insertSpaceAfterCommaInTypeParametersOption ) ; } final Object insertSpaceAfterEllipsisOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS ) ; if ( insertSpaceAfterEllipsisOption != null ) { this . insert_space_after_ellipsis = JavaCore . INSERT . equals ( insertSpaceAfterEllipsisOption ) ; } final Object insertSpaceAfterOpeningAngleBracketInParameterizedTypeReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE ) ; if ( insertSpaceAfterOpeningAngleBracketInParameterizedTypeReferenceOption != null ) { this . insert_space_after_opening_angle_bracket_in_parameterized_type_reference = JavaCore . INSERT . equals ( insertSpaceAfterOpeningAngleBracketInParameterizedTypeReferenceOption ) ; } final Object insertSpaceAfterOpeningAngleBracketInTypeArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS ) ; if ( insertSpaceAfterOpeningAngleBracketInTypeArgumentsOption != null ) { this . insert_space_after_opening_angle_bracket_in_type_arguments = JavaCore . INSERT . equals ( insertSpaceAfterOpeningAngleBracketInTypeArgumentsOption ) ; } final Object insertSpaceAfterOpeningAngleBracketInTypeParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS ) ; if ( insertSpaceAfterOpeningAngleBracketInTypeParametersOption != null ) { this . insert_space_after_opening_angle_bracket_in_type_parameters = JavaCore . INSERT . equals ( insertSpaceAfterOpeningAngleBracketInTypeParametersOption ) ; } final Object insertSpaceAfterOpeningBracketInArrayAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION ) ; if ( insertSpaceAfterOpeningBracketInArrayAllocationExpressionOption != null ) { this . insert_space_after_opening_bracket_in_array_allocation_expression = JavaCore . INSERT . equals ( insertSpaceAfterOpeningBracketInArrayAllocationExpressionOption ) ; } final Object insertSpaceAfterOpeningBracketInArrayReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE ) ; if ( insertSpaceAfterOpeningBracketInArrayReferenceOption != null ) { this . insert_space_after_opening_bracket_in_array_reference = JavaCore . INSERT . equals ( insertSpaceAfterOpeningBracketInArrayReferenceOption ) ; } final Object insertSpaceAfterOpeningBraceInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER ) ; if ( insertSpaceAfterOpeningBraceInArrayInitializerOption != null ) { this . insert_space_after_opening_brace_in_array_initializer = JavaCore . INSERT . equals ( insertSpaceAfterOpeningBraceInArrayInitializerOption ) ; } final Object insertSpaceAfterOpeningParenInAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION ) ; if ( insertSpaceAfterOpeningParenInAnnotationOption != null ) { this . insert_space_after_opening_paren_in_annotation = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInAnnotationOption ) ; } final Object insertSpaceAfterOpeningParenInCastOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST ) ; if ( insertSpaceAfterOpeningParenInCastOption != null ) { this . insert_space_after_opening_paren_in_cast = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInCastOption ) ; } final Object insertSpaceAfterOpeningParenInCatchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH ) ; if ( insertSpaceAfterOpeningParenInCatchOption != null ) { this . insert_space_after_opening_paren_in_catch = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInCatchOption ) ; } final Object insertSpaceAfterOpeningParenInConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION ) ; if ( insertSpaceAfterOpeningParenInConstructorDeclarationOption != null ) { this . insert_space_after_opening_paren_in_constructor_declaration = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInConstructorDeclarationOption ) ; } final Object insertSpaceAfterOpeningParenInEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT ) ; if ( insertSpaceAfterOpeningParenInEnumConstantOption != null ) { this . insert_space_after_opening_paren_in_enum_constant = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInEnumConstantOption ) ; } final Object insertSpaceAfterOpeningParenInForOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR ) ; if ( insertSpaceAfterOpeningParenInForOption != null ) { this . insert_space_after_opening_paren_in_for = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInForOption ) ; } final Object insertSpaceAfterOpeningParenInIfOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF ) ; if ( insertSpaceAfterOpeningParenInIfOption != null ) { this . insert_space_after_opening_paren_in_if = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInIfOption ) ; } final Object insertSpaceAfterOpeningParenInMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION ) ; if ( insertSpaceAfterOpeningParenInMethodDeclarationOption != null ) { this . insert_space_after_opening_paren_in_method_declaration = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInMethodDeclarationOption ) ; } final Object insertSpaceAfterOpeningParenInMethodInvocationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION ) ; if ( insertSpaceAfterOpeningParenInMethodInvocationOption != null ) { this . insert_space_after_opening_paren_in_method_invocation = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInMethodInvocationOption ) ; } final Object insertSpaceAfterOpeningParenInParenthesizedExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION ) ; if ( insertSpaceAfterOpeningParenInParenthesizedExpressionOption != null ) { this . insert_space_after_opening_paren_in_parenthesized_expression = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInParenthesizedExpressionOption ) ; } final Object insertSpaceAfterOpeningParenInSwitchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH ) ; if ( insertSpaceAfterOpeningParenInSwitchOption != null ) { this . insert_space_after_opening_paren_in_switch = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInSwitchOption ) ; } final Object insertSpaceAfterOpeningParenInSynchronizedOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED ) ; if ( insertSpaceAfterOpeningParenInSynchronizedOption != null ) { this . insert_space_after_opening_paren_in_synchronized = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInSynchronizedOption ) ; } final Object insertSpaceAfterOpeningParenInTryOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_TRY ) ; if ( insertSpaceAfterOpeningParenInTryOption != null ) { this . insert_space_after_opening_paren_in_try = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInTryOption ) ; } final Object insertSpaceAfterOpeningParenInWhileOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE ) ; if ( insertSpaceAfterOpeningParenInWhileOption != null ) { this . insert_space_after_opening_paren_in_while = JavaCore . INSERT . equals ( insertSpaceAfterOpeningParenInWhileOption ) ; } final Object insertSpaceAfterPostfixOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR ) ; if ( insertSpaceAfterPostfixOperatorOption != null ) { this . insert_space_after_postfix_operator = JavaCore . INSERT . equals ( insertSpaceAfterPostfixOperatorOption ) ; } final Object insertSpaceAfterPrefixOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR ) ; if ( insertSpaceAfterPrefixOperatorOption != null ) { this . insert_space_after_prefix_operator = JavaCore . INSERT . equals ( insertSpaceAfterPrefixOperatorOption ) ; } final Object insertSpaceAfterQuestionInConditionalOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL ) ; if ( insertSpaceAfterQuestionInConditionalOption != null ) { this . insert_space_after_question_in_conditional = JavaCore . INSERT . equals ( insertSpaceAfterQuestionInConditionalOption ) ; } final Object insertSpaceAfterQuestionInWildcardOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_WILDCARD ) ; if ( insertSpaceAfterQuestionInWildcardOption != null ) { this . insert_space_after_question_in_wilcard = JavaCore . INSERT . equals ( insertSpaceAfterQuestionInWildcardOption ) ; } final Object insertSpaceAfterSemicolonInForOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR ) ; if ( insertSpaceAfterSemicolonInForOption != null ) { this . insert_space_after_semicolon_in_for = JavaCore . INSERT . equals ( insertSpaceAfterSemicolonInForOption ) ; } final Object insertSpaceAfterSemicolonInTryOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_TRY_RESOURCES ) ; if ( insertSpaceAfterSemicolonInTryOption != null ) { this . insert_space_after_semicolon_in_try_resources = JavaCore . INSERT . equals ( insertSpaceAfterSemicolonInTryOption ) ; } final Object insertSpaceAfterUnaryOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR ) ; if ( insertSpaceAfterUnaryOperatorOption != null ) { this . insert_space_after_unary_operator = JavaCore . INSERT . equals ( insertSpaceAfterUnaryOperatorOption ) ; } final Object insertSpaceBeforeAndInWildcardOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_AND_IN_TYPE_PARAMETER ) ; if ( insertSpaceBeforeAndInWildcardOption != null ) { this . insert_space_before_and_in_type_parameter = JavaCore . INSERT . equals ( insertSpaceBeforeAndInWildcardOption ) ; } final Object insertSpaceBeforeAtInAnnotationTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION ) ; if ( insertSpaceBeforeAtInAnnotationTypeDeclarationOption != null ) { this . insert_space_before_at_in_annotation_type_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeAtInAnnotationTypeDeclarationOption ) ; } final Object insertSpaceBeforeAssignmentOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR ) ; if ( insertSpaceBeforeAssignmentOperatorOption != null ) { this . insert_space_before_assignment_operator = JavaCore . INSERT . equals ( insertSpaceBeforeAssignmentOperatorOption ) ; } final Object insertSpaceBeforeBinaryOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR ) ; if ( insertSpaceBeforeBinaryOperatorOption != null ) { this . insert_space_before_binary_operator = JavaCore . INSERT . equals ( insertSpaceBeforeBinaryOperatorOption ) ; } final Object insertSpaceBeforeClosingAngleBracketInParameterizedTypeReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE ) ; if ( insertSpaceBeforeClosingAngleBracketInParameterizedTypeReferenceOption != null ) { this . insert_space_before_closing_angle_bracket_in_parameterized_type_reference = JavaCore . INSERT . equals ( insertSpaceBeforeClosingAngleBracketInParameterizedTypeReferenceOption ) ; } final Object insertSpaceBeforeClosingAngleBracketInTypeArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS ) ; if ( insertSpaceBeforeClosingAngleBracketInTypeArgumentsOption != null ) { this . insert_space_before_closing_angle_bracket_in_type_arguments = JavaCore . INSERT . equals ( insertSpaceBeforeClosingAngleBracketInTypeArgumentsOption ) ; } final Object insertSpaceBeforeClosingAngleBracketInTypeParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS ) ; if ( insertSpaceBeforeClosingAngleBracketInTypeParametersOption != null ) { this . insert_space_before_closing_angle_bracket_in_type_parameters = JavaCore . INSERT . equals ( insertSpaceBeforeClosingAngleBracketInTypeParametersOption ) ; } final Object insertSpaceBeforeClosingBraceInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER ) ; if ( insertSpaceBeforeClosingBraceInArrayInitializerOption != null ) { this . insert_space_before_closing_brace_in_array_initializer = JavaCore . INSERT . equals ( insertSpaceBeforeClosingBraceInArrayInitializerOption ) ; } final Object insertSpaceBeforeClosingBracketInArrayAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION ) ; if ( insertSpaceBeforeClosingBracketInArrayAllocationExpressionOption != null ) { this . insert_space_before_closing_bracket_in_array_allocation_expression = JavaCore . INSERT . equals ( insertSpaceBeforeClosingBracketInArrayAllocationExpressionOption ) ; } final Object insertSpaceBeforeClosingBracketInArrayReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE ) ; if ( insertSpaceBeforeClosingBracketInArrayReferenceOption != null ) { this . insert_space_before_closing_bracket_in_array_reference = JavaCore . INSERT . equals ( insertSpaceBeforeClosingBracketInArrayReferenceOption ) ; } final Object insertSpaceBeforeClosingParenInAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION ) ; if ( insertSpaceBeforeClosingParenInAnnotationOption != null ) { this . insert_space_before_closing_paren_in_annotation = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInAnnotationOption ) ; } final Object insertSpaceBeforeClosingParenInCastOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST ) ; if ( insertSpaceBeforeClosingParenInCastOption != null ) { this . insert_space_before_closing_paren_in_cast = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInCastOption ) ; } final Object insertSpaceBeforeClosingParenInCatchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH ) ; if ( insertSpaceBeforeClosingParenInCatchOption != null ) { this . insert_space_before_closing_paren_in_catch = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInCatchOption ) ; } final Object insertSpaceBeforeClosingParenInConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION ) ; if ( insertSpaceBeforeClosingParenInConstructorDeclarationOption != null ) { this . insert_space_before_closing_paren_in_constructor_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInConstructorDeclarationOption ) ; } final Object insertSpaceBeforeClosingParenInEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT ) ; if ( insertSpaceBeforeClosingParenInEnumConstantOption != null ) { this . insert_space_before_closing_paren_in_enum_constant = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInEnumConstantOption ) ; } final Object insertSpaceBeforeClosingParenInForOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR ) ; if ( insertSpaceBeforeClosingParenInForOption != null ) { this . insert_space_before_closing_paren_in_for = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInForOption ) ; } final Object insertSpaceBeforeClosingParenInIfOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF ) ; if ( insertSpaceBeforeClosingParenInIfOption != null ) { this . insert_space_before_closing_paren_in_if = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInIfOption ) ; } final Object insertSpaceBeforeClosingParenInMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION ) ; if ( insertSpaceBeforeClosingParenInMethodDeclarationOption != null ) { this . insert_space_before_closing_paren_in_method_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInMethodDeclarationOption ) ; } final Object insertSpaceBeforeClosingParenInMethodInvocationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION ) ; if ( insertSpaceBeforeClosingParenInMethodInvocationOption != null ) { this . insert_space_before_closing_paren_in_method_invocation = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInMethodInvocationOption ) ; } final Object insertSpaceBeforeClosingParenInParenthesizedExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION ) ; if ( insertSpaceBeforeClosingParenInParenthesizedExpressionOption != null ) { this . insert_space_before_closing_paren_in_parenthesized_expression = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInParenthesizedExpressionOption ) ; } final Object insertSpaceBeforeClosingParenInSwitchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH ) ; if ( insertSpaceBeforeClosingParenInSwitchOption != null ) { this . insert_space_before_closing_paren_in_switch = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInSwitchOption ) ; } final Object insertSpaceBeforeClosingParenInSynchronizedOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED ) ; if ( insertSpaceBeforeClosingParenInSynchronizedOption != null ) { this . insert_space_before_closing_paren_in_synchronized = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInSynchronizedOption ) ; } final Object insertSpaceBeforeClosingParenInTryOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_TRY ) ; if ( insertSpaceBeforeClosingParenInTryOption != null ) { this . insert_space_before_closing_paren_in_try = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInTryOption ) ; } final Object insertSpaceBeforeClosingParenInWhileOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE ) ; if ( insertSpaceBeforeClosingParenInWhileOption != null ) { this . insert_space_before_closing_paren_in_while = JavaCore . INSERT . equals ( insertSpaceBeforeClosingParenInWhileOption ) ; } final Object insertSpaceBeforeColonInAssertOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT ) ; if ( insertSpaceBeforeColonInAssertOption != null ) { this . insert_space_before_colon_in_assert = JavaCore . INSERT . equals ( insertSpaceBeforeColonInAssertOption ) ; } final Object insertSpaceBeforeColonInCaseOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE ) ; if ( insertSpaceBeforeColonInCaseOption != null ) { this . insert_space_before_colon_in_case = JavaCore . INSERT . equals ( insertSpaceBeforeColonInCaseOption ) ; } final Object insertSpaceBeforeColonInConditionalOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL ) ; if ( insertSpaceBeforeColonInConditionalOption != null ) { this . insert_space_before_colon_in_conditional = JavaCore . INSERT . equals ( insertSpaceBeforeColonInConditionalOption ) ; } final Object insertSpaceBeforeColonInDefaultOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT ) ; if ( insertSpaceBeforeColonInDefaultOption != null ) { this . insert_space_before_colon_in_default = JavaCore . INSERT . equals ( insertSpaceBeforeColonInDefaultOption ) ; } final Object insertSpaceBeforeColonInForOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR ) ; if ( insertSpaceBeforeColonInForOption != null ) { this . insert_space_before_colon_in_for = JavaCore . INSERT . equals ( insertSpaceBeforeColonInForOption ) ; } final Object insertSpaceBeforeColonInLabeledStatementOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT ) ; if ( insertSpaceBeforeColonInLabeledStatementOption != null ) { this . insert_space_before_colon_in_labeled_statement = JavaCore . INSERT . equals ( insertSpaceBeforeColonInLabeledStatementOption ) ; } final Object insertSpaceBeforeCommaInAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION ) ; if ( insertSpaceBeforeCommaInAllocationExpressionOption != null ) { this . insert_space_before_comma_in_allocation_expression = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInAllocationExpressionOption ) ; } final Object insertSpaceBeforeCommaInAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION ) ; if ( insertSpaceBeforeCommaInAnnotationOption != null ) { this . insert_space_before_comma_in_annotation = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInAnnotationOption ) ; } final Object insertSpaceBeforeCommaInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER ) ; if ( insertSpaceBeforeCommaInArrayInitializerOption != null ) { this . insert_space_before_comma_in_array_initializer = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInArrayInitializerOption ) ; } final Object insertSpaceBeforeCommaInConstructorDeclarationParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS ) ; if ( insertSpaceBeforeCommaInConstructorDeclarationParametersOption != null ) { this . insert_space_before_comma_in_constructor_declaration_parameters = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInConstructorDeclarationParametersOption ) ; } final Object insertSpaceBeforeCommaInConstructorDeclarationThrowsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS ) ; if ( insertSpaceBeforeCommaInConstructorDeclarationThrowsOption != null ) { this . insert_space_before_comma_in_constructor_declaration_throws = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInConstructorDeclarationThrowsOption ) ; } final Object insertSpaceBeforeCommaInEnumConstantArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS ) ; if ( insertSpaceBeforeCommaInEnumConstantArgumentsOption != null ) { this . insert_space_before_comma_in_enum_constant_arguments = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInEnumConstantArgumentsOption ) ; } final Object insertSpaceBeforeCommaInEnumDeclarationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS ) ; if ( insertSpaceBeforeCommaInEnumDeclarationsOption != null ) { this . insert_space_before_comma_in_enum_declarations = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInEnumDeclarationsOption ) ; } final Object insertSpaceBeforeCommaInExplicitConstructorCallArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS ) ; if ( insertSpaceBeforeCommaInExplicitConstructorCallArgumentsOption != null ) { this . insert_space_before_comma_in_explicit_constructor_call_arguments = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInExplicitConstructorCallArgumentsOption ) ; } final Object insertSpaceBeforeCommaInForIncrementsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS ) ; if ( insertSpaceBeforeCommaInForIncrementsOption != null ) { this . insert_space_before_comma_in_for_increments = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInForIncrementsOption ) ; } final Object insertSpaceBeforeCommaInForInitsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS ) ; if ( insertSpaceBeforeCommaInForInitsOption != null ) { this . insert_space_before_comma_in_for_inits = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInForInitsOption ) ; } final Object insertSpaceBeforeCommaInMethodInvocationArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS ) ; if ( insertSpaceBeforeCommaInMethodInvocationArgumentsOption != null ) { this . insert_space_before_comma_in_method_invocation_arguments = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInMethodInvocationArgumentsOption ) ; } final Object insertSpaceBeforeCommaInMethodDeclarationParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS ) ; if ( insertSpaceBeforeCommaInMethodDeclarationParametersOption != null ) { this . insert_space_before_comma_in_method_declaration_parameters = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInMethodDeclarationParametersOption ) ; } final Object insertSpaceBeforeCommaInMethodDeclarationThrowsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS ) ; if ( insertSpaceBeforeCommaInMethodDeclarationThrowsOption != null ) { this . insert_space_before_comma_in_method_declaration_throws = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInMethodDeclarationThrowsOption ) ; } final Object insertSpaceBeforeCommaInMultipleFieldDeclarationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS ) ; if ( insertSpaceBeforeCommaInMultipleFieldDeclarationsOption != null ) { this . insert_space_before_comma_in_multiple_field_declarations = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInMultipleFieldDeclarationsOption ) ; } final Object insertSpaceBeforeCommaInMultipleLocalDeclarationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS ) ; if ( insertSpaceBeforeCommaInMultipleLocalDeclarationsOption != null ) { this . insert_space_before_comma_in_multiple_local_declarations = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInMultipleLocalDeclarationsOption ) ; } final Object insertSpaceBeforeCommaInParameterizedTypeReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE ) ; if ( insertSpaceBeforeCommaInParameterizedTypeReferenceOption != null ) { this . insert_space_before_comma_in_parameterized_type_reference = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInParameterizedTypeReferenceOption ) ; } final Object insertSpaceBeforeCommaInSuperinterfacesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES ) ; if ( insertSpaceBeforeCommaInSuperinterfacesOption != null ) { this . insert_space_before_comma_in_superinterfaces = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInSuperinterfacesOption ) ; } final Object insertSpaceBeforeCommaInTypeArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS ) ; if ( insertSpaceBeforeCommaInTypeArgumentsOption != null ) { this . insert_space_before_comma_in_type_arguments = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInTypeArgumentsOption ) ; } final Object insertSpaceBeforeCommaInTypeParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS ) ; if ( insertSpaceBeforeCommaInTypeParametersOption != null ) { this . insert_space_before_comma_in_type_parameters = JavaCore . INSERT . equals ( insertSpaceBeforeCommaInTypeParametersOption ) ; } final Object insertSpaceBeforeEllipsisOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS ) ; if ( insertSpaceBeforeEllipsisOption != null ) { this . insert_space_before_ellipsis = JavaCore . INSERT . equals ( insertSpaceBeforeEllipsisOption ) ; } final Object insertSpaceBeforeOpeningAngleBrackerInParameterizedTypeReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE ) ; if ( insertSpaceBeforeOpeningAngleBrackerInParameterizedTypeReferenceOption != null ) { this . insert_space_before_opening_angle_bracket_in_parameterized_type_reference = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningAngleBrackerInParameterizedTypeReferenceOption ) ; } final Object insertSpaceBeforeOpeningAngleBrackerInTypeArgumentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS ) ; if ( insertSpaceBeforeOpeningAngleBrackerInTypeArgumentsOption != null ) { this . insert_space_before_opening_angle_bracket_in_type_arguments = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningAngleBrackerInTypeArgumentsOption ) ; } final Object insertSpaceBeforeOpeningAngleBrackerInTypeParametersOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS ) ; if ( insertSpaceBeforeOpeningAngleBrackerInTypeParametersOption != null ) { this . insert_space_before_opening_angle_bracket_in_type_parameters = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningAngleBrackerInTypeParametersOption ) ; } final Object insertSpaceBeforeOpeningBraceInAnnotationTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION ) ; if ( insertSpaceBeforeOpeningBraceInAnnotationTypeDeclarationOption != null ) { this . insert_space_before_opening_brace_in_annotation_type_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInAnnotationTypeDeclarationOption ) ; } final Object insertSpaceBeforeOpeningBraceInAnonymousTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION ) ; if ( insertSpaceBeforeOpeningBraceInAnonymousTypeDeclarationOption != null ) { this . insert_space_before_opening_brace_in_anonymous_type_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInAnonymousTypeDeclarationOption ) ; } final Object insertSpaceBeforeOpeningBraceInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER ) ; if ( insertSpaceBeforeOpeningBraceInArrayInitializerOption != null ) { this . insert_space_before_opening_brace_in_array_initializer = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInArrayInitializerOption ) ; } final Object insertSpaceBeforeOpeningBraceInBlockOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK ) ; if ( insertSpaceBeforeOpeningBraceInBlockOption != null ) { this . insert_space_before_opening_brace_in_block = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInBlockOption ) ; } final Object insertSpaceBeforeOpeningBraceInConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION ) ; if ( insertSpaceBeforeOpeningBraceInConstructorDeclarationOption != null ) { this . insert_space_before_opening_brace_in_constructor_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInConstructorDeclarationOption ) ; } final Object insertSpaceBeforeOpeningBraceInEnumDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION ) ; if ( insertSpaceBeforeOpeningBraceInEnumDeclarationOption != null ) { this . insert_space_before_opening_brace_in_enum_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInEnumDeclarationOption ) ; } final Object insertSpaceBeforeOpeningBraceInEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT ) ; if ( insertSpaceBeforeOpeningBraceInEnumConstantOption != null ) { this . insert_space_before_opening_brace_in_enum_constant = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInEnumConstantOption ) ; } final Object insertSpaceBeforeOpeningBraceInMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION ) ; if ( insertSpaceBeforeOpeningBraceInMethodDeclarationOption != null ) { this . insert_space_before_opening_brace_in_method_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInMethodDeclarationOption ) ; } final Object insertSpaceBeforeOpeningBraceInTypeDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION ) ; if ( insertSpaceBeforeOpeningBraceInTypeDeclarationOption != null ) { this . insert_space_before_opening_brace_in_type_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInTypeDeclarationOption ) ; } final Object insertSpaceBeforeOpeningBracketInArrayAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION ) ; if ( insertSpaceBeforeOpeningBracketInArrayAllocationExpressionOption != null ) { this . insert_space_before_opening_bracket_in_array_allocation_expression = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBracketInArrayAllocationExpressionOption ) ; } final Object insertSpaceBeforeOpeningBracketInArrayReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE ) ; if ( insertSpaceBeforeOpeningBracketInArrayReferenceOption != null ) { this . insert_space_before_opening_bracket_in_array_reference = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBracketInArrayReferenceOption ) ; } final Object insertSpaceBeforeOpeningBracketInArrayTypeReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE ) ; if ( insertSpaceBeforeOpeningBracketInArrayTypeReferenceOption != null ) { this . insert_space_before_opening_bracket_in_array_type_reference = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBracketInArrayTypeReferenceOption ) ; } final Object insertSpaceBeforeOpeningParenInAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION ) ; if ( insertSpaceBeforeOpeningParenInAnnotationOption != null ) { this . insert_space_before_opening_paren_in_annotation = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInAnnotationOption ) ; } final Object insertSpaceBeforeOpeningParenInAnnotationTypeMemberDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION ) ; if ( insertSpaceBeforeOpeningParenInAnnotationTypeMemberDeclarationOption != null ) { this . insert_space_before_opening_paren_in_annotation_type_member_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInAnnotationTypeMemberDeclarationOption ) ; } final Object insertSpaceBeforeOpeningParenInCatchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH ) ; if ( insertSpaceBeforeOpeningParenInCatchOption != null ) { this . insert_space_before_opening_paren_in_catch = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInCatchOption ) ; } final Object insertSpaceBeforeOpeningParenInConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION ) ; if ( insertSpaceBeforeOpeningParenInConstructorDeclarationOption != null ) { this . insert_space_before_opening_paren_in_constructor_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInConstructorDeclarationOption ) ; } final Object insertSpaceBeforeOpeningParenInEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT ) ; if ( insertSpaceBeforeOpeningParenInEnumConstantOption != null ) { this . insert_space_before_opening_paren_in_enum_constant = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInEnumConstantOption ) ; } final Object insertSpaceBeforeOpeningParenInForOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR ) ; if ( insertSpaceBeforeOpeningParenInForOption != null ) { this . insert_space_before_opening_paren_in_for = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInForOption ) ; } final Object insertSpaceBeforeOpeningParenInIfOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF ) ; if ( insertSpaceBeforeOpeningParenInIfOption != null ) { this . insert_space_before_opening_paren_in_if = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInIfOption ) ; } final Object insertSpaceBeforeOpeningParenInMethodInvocationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION ) ; if ( insertSpaceBeforeOpeningParenInMethodInvocationOption != null ) { this . insert_space_before_opening_paren_in_method_invocation = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInMethodInvocationOption ) ; } final Object insertSpaceBeforeOpeningParenInMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION ) ; if ( insertSpaceBeforeOpeningParenInMethodDeclarationOption != null ) { this . insert_space_before_opening_paren_in_method_declaration = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInMethodDeclarationOption ) ; } final Object insertSpaceBeforeOpeningParenInSwitchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH ) ; if ( insertSpaceBeforeOpeningParenInSwitchOption != null ) { this . insert_space_before_opening_paren_in_switch = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInSwitchOption ) ; } final Object insertSpaceBeforeOpeningBraceInSwitchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH ) ; if ( insertSpaceBeforeOpeningBraceInSwitchOption != null ) { this . insert_space_before_opening_brace_in_switch = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningBraceInSwitchOption ) ; } final Object insertSpaceBeforeOpeningParenInSynchronizedOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED ) ; if ( insertSpaceBeforeOpeningParenInSynchronizedOption != null ) { this . insert_space_before_opening_paren_in_synchronized = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInSynchronizedOption ) ; } final Object insertSpaceBeforeOpeningParenInTryOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY ) ; if ( insertSpaceBeforeOpeningParenInTryOption != null ) { this . insert_space_before_opening_paren_in_try = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInTryOption ) ; } final Object insertSpaceBeforeOpeningParenInParenthesizedExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION ) ; if ( insertSpaceBeforeOpeningParenInParenthesizedExpressionOption != null ) { this . insert_space_before_opening_paren_in_parenthesized_expression = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInParenthesizedExpressionOption ) ; } final Object insertSpaceBeforeOpeningParenInWhileOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE ) ; if ( insertSpaceBeforeOpeningParenInWhileOption != null ) { this . insert_space_before_opening_paren_in_while = JavaCore . INSERT . equals ( insertSpaceBeforeOpeningParenInWhileOption ) ; } final Object insertSpaceBeforeParenthesizedExpressionInReturnOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN ) ; if ( insertSpaceBeforeParenthesizedExpressionInReturnOption != null ) { this . insert_space_before_parenthesized_expression_in_return = JavaCore . INSERT . equals ( insertSpaceBeforeParenthesizedExpressionInReturnOption ) ; } final Object insertSpaceBeforeParenthesizedExpressionInThrowOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW ) ; if ( insertSpaceBeforeParenthesizedExpressionInThrowOption != null ) { this . insert_space_before_parenthesized_expression_in_throw = JavaCore . INSERT . equals ( insertSpaceBeforeParenthesizedExpressionInThrowOption ) ; } final Object insertSpaceBeforePostfixOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR ) ; if ( insertSpaceBeforePostfixOperatorOption != null ) { this . insert_space_before_postfix_operator = JavaCore . INSERT . equals ( insertSpaceBeforePostfixOperatorOption ) ; } final Object insertSpaceBeforePrefixOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR ) ; if ( insertSpaceBeforePrefixOperatorOption != null ) { this . insert_space_before_prefix_operator = JavaCore . INSERT . equals ( insertSpaceBeforePrefixOperatorOption ) ; } final Object insertSpaceBeforeQuestionInConditionalOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL ) ; if ( insertSpaceBeforeQuestionInConditionalOption != null ) { this . insert_space_before_question_in_conditional = JavaCore . INSERT . equals ( insertSpaceBeforeQuestionInConditionalOption ) ; } final Object insertSpaceBeforeQuestionInWildcardOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD ) ; if ( insertSpaceBeforeQuestionInWildcardOption != null ) { this . insert_space_before_question_in_wilcard = JavaCore . INSERT . equals ( insertSpaceBeforeQuestionInWildcardOption ) ; } final Object insertSpaceBeforeSemicolonOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON ) ; if ( insertSpaceBeforeSemicolonOption != null ) { this . insert_space_before_semicolon = JavaCore . INSERT . equals ( insertSpaceBeforeSemicolonOption ) ; } final Object insertSpaceBeforeSemicolonInForOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR ) ; if ( insertSpaceBeforeSemicolonInForOption != null ) { this . insert_space_before_semicolon_in_for = JavaCore . INSERT . equals ( insertSpaceBeforeSemicolonInForOption ) ; } final Object insertSpaceBeforeSemicolonInTryOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_TRY_RESOURCES ) ; if ( insertSpaceBeforeSemicolonInTryOption != null ) { this . insert_space_before_semicolon_in_try_resources = JavaCore . INSERT . equals ( insertSpaceBeforeSemicolonInTryOption ) ; } final Object insertSpaceBeforeUnaryOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR ) ; if ( insertSpaceBeforeUnaryOperatorOption != null ) { this . insert_space_before_unary_operator = JavaCore . INSERT . equals ( insertSpaceBeforeUnaryOperatorOption ) ; } final Object insertSpaceBetweenBracketsInArrayTypeReferenceOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE ) ; if ( insertSpaceBetweenBracketsInArrayTypeReferenceOption != null ) { this . insert_space_between_brackets_in_array_type_reference = JavaCore . INSERT . equals ( insertSpaceBetweenBracketsInArrayTypeReferenceOption ) ; } final Object insertSpaceBetweenEmptyBracesInArrayInitializerOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER ) ; if ( insertSpaceBetweenEmptyBracesInArrayInitializerOption != null ) { this . insert_space_between_empty_braces_in_array_initializer = JavaCore . INSERT . equals ( insertSpaceBetweenEmptyBracesInArrayInitializerOption ) ; } final Object insertSpaceBetweenEmptyBracketsInArrayAllocationExpressionOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION ) ; if ( insertSpaceBetweenEmptyBracketsInArrayAllocationExpressionOption != null ) { this . insert_space_between_empty_brackets_in_array_allocation_expression = JavaCore . INSERT . equals ( insertSpaceBetweenEmptyBracketsInArrayAllocationExpressionOption ) ; } final Object insertSpaceBetweenEmptyParensInConstructorDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION ) ; if ( insertSpaceBetweenEmptyParensInConstructorDeclarationOption != null ) { this . insert_space_between_empty_parens_in_constructor_declaration = JavaCore . INSERT . equals ( insertSpaceBetweenEmptyParensInConstructorDeclarationOption ) ; } final Object insertSpaceBetweenEmptyParensInAnnotationTypeMemberDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION ) ; if ( insertSpaceBetweenEmptyParensInAnnotationTypeMemberDeclarationOption != null ) { this . insert_space_between_empty_parens_in_annotation_type_member_declaration = JavaCore . INSERT . equals ( insertSpaceBetweenEmptyParensInAnnotationTypeMemberDeclarationOption ) ; } final Object insertSpaceBetweenEmptyParensInEnumConstantOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT ) ; if ( insertSpaceBetweenEmptyParensInEnumConstantOption != null ) { this . insert_space_between_empty_parens_in_enum_constant = JavaCore . INSERT . equals ( insertSpaceBetweenEmptyParensInEnumConstantOption ) ; } final Object insertSpaceBetweenEmptyParensInMethodDeclarationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION ) ; if ( insertSpaceBetweenEmptyParensInMethodDeclarationOption != null ) { this . insert_space_between_empty_parens_in_method_declaration = JavaCore . INSERT . equals ( insertSpaceBetweenEmptyParensInMethodDeclarationOption ) ; } final Object insertSpaceBetweenEmptyParensInMethodInvocationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION ) ; if ( insertSpaceBetweenEmptyParensInMethodInvocationOption != null ) { this . insert_space_between_empty_parens_in_method_invocation = JavaCore . INSERT . equals ( insertSpaceBetweenEmptyParensInMethodInvocationOption ) ; } final Object compactElseIfOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMPACT_ELSE_IF ) ; if ( compactElseIfOption != null ) { this . compact_else_if = DefaultCodeFormatterConstants . TRUE . equals ( compactElseIfOption ) ; } final Object keepGuardianClauseOnOneLineOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE ) ; if ( keepGuardianClauseOnOneLineOption != null ) { this . keep_guardian_clause_on_one_line = DefaultCodeFormatterConstants . TRUE . equals ( keepGuardianClauseOnOneLineOption ) ; } final Object keepElseStatementOnSameLineOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE ) ; if ( keepElseStatementOnSameLineOption != null ) { this . keep_else_statement_on_same_line = DefaultCodeFormatterConstants . TRUE . equals ( keepElseStatementOnSameLineOption ) ; } final Object keepEmptyArrayInitializerOnOneLineOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE ) ; if ( keepEmptyArrayInitializerOnOneLineOption != null ) { this . keep_empty_array_initializer_on_one_line = DefaultCodeFormatterConstants . TRUE . equals ( keepEmptyArrayInitializerOnOneLineOption ) ; } final Object keepSimpleIfOnOneLineOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE ) ; if ( keepSimpleIfOnOneLineOption != null ) { this . keep_simple_if_on_one_line = DefaultCodeFormatterConstants . TRUE . equals ( keepSimpleIfOnOneLineOption ) ; } final Object keepThenStatementOnSameLineOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE ) ; if ( keepThenStatementOnSameLineOption != null ) { this . keep_then_statement_on_same_line = DefaultCodeFormatterConstants . TRUE . equals ( keepThenStatementOnSameLineOption ) ; } final Object neverIndentBlockCommentOnFirstColumnOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN ) ; if ( neverIndentBlockCommentOnFirstColumnOption != null ) { this . never_indent_block_comments_on_first_column = DefaultCodeFormatterConstants . TRUE . equals ( neverIndentBlockCommentOnFirstColumnOption ) ; } final Object neverIndentLineCommentOnFirstColumnOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN ) ; if ( neverIndentLineCommentOnFirstColumnOption != null ) { this . never_indent_line_comments_on_first_column = DefaultCodeFormatterConstants . TRUE . equals ( neverIndentLineCommentOnFirstColumnOption ) ; } final Object numberOfEmptyLinesToPreserveOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE ) ; if ( numberOfEmptyLinesToPreserveOption != null ) { try { this . number_of_empty_lines_to_preserve = Integer . parseInt ( ( String ) numberOfEmptyLinesToPreserveOption ) ; } catch ( NumberFormatException e ) { this . number_of_empty_lines_to_preserve = <NUM_LIT:0> ; } catch ( ClassCastException e ) { this . number_of_empty_lines_to_preserve = <NUM_LIT:0> ; } } final Object joinLinesInCommentsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_JOIN_LINES_IN_COMMENTS ) ; if ( joinLinesInCommentsOption != null ) { this . join_lines_in_comments = DefaultCodeFormatterConstants . TRUE . equals ( joinLinesInCommentsOption ) ; } final Object joinWrappedLinesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_JOIN_WRAPPED_LINES ) ; if ( joinWrappedLinesOption != null ) { this . join_wrapped_lines = DefaultCodeFormatterConstants . TRUE . equals ( joinWrappedLinesOption ) ; } final Object putEmptyStatementOnNewLineOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE ) ; if ( putEmptyStatementOnNewLineOption != null ) { this . put_empty_statement_on_new_line = DefaultCodeFormatterConstants . TRUE . equals ( putEmptyStatementOnNewLineOption ) ; } final Object tabSizeOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_TAB_SIZE ) ; if ( tabSizeOption != null ) { try { this . tab_size = Integer . parseInt ( ( String ) tabSizeOption ) ; } catch ( NumberFormatException e ) { this . tab_size = <NUM_LIT:4> ; } catch ( ClassCastException e ) { this . tab_size = <NUM_LIT:4> ; } } final Object useTabsOnlyForLeadingIndentationsOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS ) ; if ( useTabsOnlyForLeadingIndentationsOption != null ) { this . use_tabs_only_for_leading_indentations = DefaultCodeFormatterConstants . TRUE . equals ( useTabsOnlyForLeadingIndentationsOption ) ; } final Object pageWidthOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_LINE_SPLIT ) ; if ( pageWidthOption != null ) { try { this . page_width = Integer . parseInt ( ( String ) pageWidthOption ) ; } catch ( NumberFormatException e ) { this . page_width = <NUM_LIT> ; } catch ( ClassCastException e ) { this . page_width = <NUM_LIT> ; } } final Object useTabOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_TAB_CHAR ) ; if ( useTabOption != null ) { if ( JavaCore . TAB . equals ( useTabOption ) ) { this . tab_char = TAB ; } else if ( JavaCore . SPACE . equals ( useTabOption ) ) { this . tab_char = SPACE ; } else { this . tab_char = MIXED ; } } final Object wrapBeforeBinaryOperatorOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_WRAP_BEFORE_BINARY_OPERATOR ) ; if ( wrapBeforeBinaryOperatorOption != null ) { this . wrap_before_binary_operator = DefaultCodeFormatterConstants . TRUE . equals ( wrapBeforeBinaryOperatorOption ) ; } final Object wrapBeforeOrOperatorMulticatchOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_WRAP_BEFORE_OR_OPERATOR_MULTICATCH ) ; if ( wrapBeforeOrOperatorMulticatchOption != null ) { this . wrap_before_or_operator_multicatch = DefaultCodeFormatterConstants . TRUE . equals ( wrapBeforeOrOperatorMulticatchOption ) ; } final Object useTags = settings . get ( DefaultCodeFormatterConstants . FORMATTER_USE_ON_OFF_TAGS ) ; if ( useTags != null ) { this . use_tags = DefaultCodeFormatterConstants . TRUE . equals ( useTags ) ; } final Object disableTagOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_DISABLING_TAG ) ; if ( disableTagOption != null ) { if ( disableTagOption instanceof String ) { String stringValue = ( String ) disableTagOption ; int idx = stringValue . indexOf ( '<STR_LIT:\n>' ) ; if ( idx == <NUM_LIT:0> ) { this . disabling_tag = null ; } else { String tag = idx < <NUM_LIT:0> ? stringValue . trim ( ) : stringValue . substring ( <NUM_LIT:0> , idx ) . trim ( ) ; if ( tag . length ( ) == <NUM_LIT:0> ) { this . disabling_tag = null ; } else { this . disabling_tag = tag . toCharArray ( ) ; } } } } final Object enableTagOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_ENABLING_TAG ) ; if ( enableTagOption != null ) { if ( enableTagOption instanceof String ) { String stringValue = ( String ) enableTagOption ; int idx = stringValue . indexOf ( '<STR_LIT:\n>' ) ; if ( idx == <NUM_LIT:0> ) { this . enabling_tag = null ; } else { String tag = idx < <NUM_LIT:0> ? stringValue . trim ( ) : stringValue . substring ( <NUM_LIT:0> , idx ) . trim ( ) ; if ( tag . length ( ) == <NUM_LIT:0> ) { this . enabling_tag = null ; } else { this . enabling_tag = tag . toCharArray ( ) ; } } } } final Object wrapWrapOuterExpressionsWhenNestedOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED ) ; if ( wrapWrapOuterExpressionsWhenNestedOption != null ) { this . wrap_outer_expressions_when_nested = DefaultCodeFormatterConstants . TRUE . equals ( wrapWrapOuterExpressionsWhenNestedOption ) ; } } private void setDeprecatedOptions ( Map settings ) { final Object commentClearBlankLinesOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_CLEAR_BLANK_LINES ) ; if ( commentClearBlankLinesOption != null ) { this . comment_clear_blank_lines_in_javadoc_comment = DefaultCodeFormatterConstants . TRUE . equals ( commentClearBlankLinesOption ) ; this . comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants . TRUE . equals ( commentClearBlankLinesOption ) ; } else { final Object commentClearBlankLinesInJavadocCommentOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT ) ; if ( commentClearBlankLinesInJavadocCommentOption != null ) { this . comment_clear_blank_lines_in_javadoc_comment = DefaultCodeFormatterConstants . TRUE . equals ( commentClearBlankLinesInJavadocCommentOption ) ; } final Object commentClearBlankLinesInBlockCommentOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT ) ; if ( commentClearBlankLinesInBlockCommentOption != null ) { this . comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants . TRUE . equals ( commentClearBlankLinesInBlockCommentOption ) ; } } final Object insertNewLineAfterAnnotationOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION ) ; final Object insertNewLineAfterAnnotationOnMemberOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER ) ; final Object insertNewLineAfterAnnotationOnTypeOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE ) ; final Object insertNewLineAfterAnnotationOnFieldOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD ) ; final Object insertNewLineAfterAnnotationOnMethodOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD ) ; final Object insertNewLineAfterAnnotationOnPackageOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE ) ; final Object insertNewLineAfterAnnotationOnParameterOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER ) ; final Object insertNewLineAfterAnnotationOnLocalVariableOption = settings . get ( DefaultCodeFormatterConstants . FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE ) ; if ( insertNewLineAfterAnnotationOnTypeOption == null && insertNewLineAfterAnnotationOnFieldOption == null && insertNewLineAfterAnnotationOnMethodOption == null && insertNewLineAfterAnnotationOnPackageOption == null ) { if ( insertNewLineAfterAnnotationOnMemberOption != null ) { boolean insert = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnMemberOption ) ; this . insert_new_line_after_annotation_on_type = insert ; this . insert_new_line_after_annotation_on_field = insert ; this . insert_new_line_after_annotation_on_method = insert ; this . insert_new_line_after_annotation_on_package = insert ; if ( insertNewLineAfterAnnotationOnParameterOption != null ) { this . insert_new_line_after_annotation_on_parameter = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnParameterOption ) ; } if ( insertNewLineAfterAnnotationOnLocalVariableOption != null ) { this . insert_new_line_after_annotation_on_local_variable = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnLocalVariableOption ) ; } } else if ( insertNewLineAfterAnnotationOnParameterOption == null && insertNewLineAfterAnnotationOnLocalVariableOption == null ) { if ( insertNewLineAfterAnnotationOption != null ) { boolean insert = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOption ) ; this . insert_new_line_after_annotation_on_type = insert ; this . insert_new_line_after_annotation_on_field = insert ; this . insert_new_line_after_annotation_on_method = insert ; this . insert_new_line_after_annotation_on_package = insert ; this . insert_new_line_after_annotation_on_parameter = insert ; this . insert_new_line_after_annotation_on_local_variable = insert ; } } } else { if ( insertNewLineAfterAnnotationOnTypeOption != null ) { this . insert_new_line_after_annotation_on_type = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnTypeOption ) ; } if ( insertNewLineAfterAnnotationOnFieldOption != null ) { this . insert_new_line_after_annotation_on_field = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnFieldOption ) ; } if ( insertNewLineAfterAnnotationOnMethodOption != null ) { this . insert_new_line_after_annotation_on_method = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnMethodOption ) ; } if ( insertNewLineAfterAnnotationOnPackageOption != null ) { this . insert_new_line_after_annotation_on_package = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnPackageOption ) ; } if ( insertNewLineAfterAnnotationOnParameterOption != null ) { this . insert_new_line_after_annotation_on_parameter = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnParameterOption ) ; } if ( insertNewLineAfterAnnotationOnLocalVariableOption != null ) { this . insert_new_line_after_annotation_on_local_variable = JavaCore . INSERT . equals ( insertNewLineAfterAnnotationOnLocalVariableOption ) ; } } } public void setDefaultSettings ( ) { this . alignment_for_arguments_in_allocation_expression = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_annotation = Alignment . M_NO_ALIGNMENT ; this . alignment_for_arguments_in_enum_constant = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_explicit_constructor_call = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_method_invocation = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_qualified_allocation_expression = Alignment . M_COMPACT_SPLIT ; this . alignment_for_assignment = Alignment . M_NO_ALIGNMENT ; this . alignment_for_binary_expression = Alignment . M_COMPACT_SPLIT ; this . alignment_for_compact_if = Alignment . M_ONE_PER_LINE_SPLIT | Alignment . M_INDENT_BY_ONE ; this . alignment_for_conditional_expression = Alignment . M_ONE_PER_LINE_SPLIT ; this . alignment_for_enum_constants = Alignment . NONE ; this . alignment_for_expressions_in_array_initializer = Alignment . M_COMPACT_SPLIT ; this . alignment_for_method_declaration = Alignment . M_NO_ALIGNMENT ; this . alignment_for_multiple_fields = Alignment . M_COMPACT_SPLIT ; this . alignment_for_parameters_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_parameters_in_method_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_resources_in_try = Alignment . M_NEXT_PER_LINE_SPLIT ; this . alignment_for_selector_in_method_invocation = Alignment . M_COMPACT_SPLIT ; this . alignment_for_superclass_in_type_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; this . alignment_for_superinterfaces_in_enum_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; this . alignment_for_superinterfaces_in_type_declaration = Alignment . M_NEXT_SHIFTED_SPLIT ; this . alignment_for_throws_clause_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_throws_clause_in_method_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_union_type_in_multicatch = Alignment . M_COMPACT_SPLIT ; this . align_type_members_on_columns = false ; this . brace_position_for_annotation_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_array_initializer = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_block = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_block_in_case = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_constructor_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_enum_constant = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_enum_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_method_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_switch = DefaultCodeFormatterConstants . END_OF_LINE ; this . comment_clear_blank_lines_in_block_comment = false ; this . comment_clear_blank_lines_in_javadoc_comment = false ; this . comment_format_block_comment = true ; this . comment_format_javadoc_comment = true ; this . comment_format_line_comment = true ; this . comment_format_line_comment_starting_on_first_column = true ; this . comment_format_header = false ; this . comment_format_html = true ; this . comment_format_source = true ; this . comment_indent_parameter_description = true ; this . comment_indent_root_tags = true ; this . comment_insert_empty_line_before_root_tags = true ; this . comment_insert_new_line_for_parameter = true ; this . comment_new_lines_at_block_boundaries = true ; this . comment_new_lines_at_javadoc_boundaries = true ; this . comment_line_length = <NUM_LIT> ; this . comment_preserve_white_space_between_code_and_line_comments = false ; this . continuation_indentation = <NUM_LIT:2> ; this . continuation_indentation_for_array_initializer = <NUM_LIT:2> ; this . blank_lines_after_imports = <NUM_LIT:0> ; this . blank_lines_after_package = <NUM_LIT:0> ; this . blank_lines_before_field = <NUM_LIT:0> ; this . blank_lines_before_first_class_body_declaration = <NUM_LIT:0> ; this . blank_lines_before_imports = <NUM_LIT:0> ; this . blank_lines_before_member_type = <NUM_LIT:0> ; this . blank_lines_before_method = <NUM_LIT:0> ; this . blank_lines_before_new_chunk = <NUM_LIT:0> ; this . blank_lines_before_package = <NUM_LIT:0> ; this . blank_lines_between_import_groups = <NUM_LIT:1> ; this . blank_lines_between_type_declarations = <NUM_LIT:0> ; this . blank_lines_at_beginning_of_method_body = <NUM_LIT:0> ; this . indent_statements_compare_to_block = true ; this . indent_statements_compare_to_body = true ; this . indent_body_declarations_compare_to_annotation_declaration_header = true ; this . indent_body_declarations_compare_to_enum_constant_header = true ; this . indent_body_declarations_compare_to_enum_declaration_header = true ; this . indent_body_declarations_compare_to_type_header = true ; this . indent_breaks_compare_to_cases = true ; this . indent_empty_lines = false ; this . indent_switchstatements_compare_to_cases = true ; this . indent_switchstatements_compare_to_switch = true ; this . indentation_size = <NUM_LIT:4> ; this . insert_new_line_after_annotation_on_type = true ; this . insert_new_line_after_annotation_on_field = true ; this . insert_new_line_after_annotation_on_method = true ; this . insert_new_line_after_annotation_on_package = true ; this . insert_new_line_after_annotation_on_parameter = false ; this . insert_new_line_after_annotation_on_local_variable = true ; this . insert_new_line_after_opening_brace_in_array_initializer = false ; this . insert_new_line_at_end_of_file_if_missing = false ; this . insert_new_line_before_catch_in_try_statement = false ; this . insert_new_line_before_closing_brace_in_array_initializer = false ; this . insert_new_line_before_else_in_if_statement = false ; this . insert_new_line_before_finally_in_try_statement = false ; this . insert_new_line_before_while_in_do_statement = false ; this . insert_new_line_in_empty_anonymous_type_declaration = true ; this . insert_new_line_in_empty_block = true ; this . insert_new_line_in_empty_annotation_declaration = true ; this . insert_new_line_in_empty_enum_constant = true ; this . insert_new_line_in_empty_enum_declaration = true ; this . insert_new_line_in_empty_method_body = true ; this . insert_new_line_in_empty_type_declaration = true ; this . insert_space_after_and_in_type_parameter = true ; this . insert_space_after_assignment_operator = true ; this . insert_space_after_at_in_annotation = false ; this . insert_space_after_at_in_annotation_type_declaration = false ; this . insert_space_after_binary_operator = true ; this . insert_space_after_closing_angle_bracket_in_type_arguments = true ; this . insert_space_after_closing_angle_bracket_in_type_parameters = true ; this . insert_space_after_closing_paren_in_cast = true ; this . insert_space_after_closing_brace_in_block = true ; this . insert_space_after_colon_in_assert = true ; this . insert_space_after_colon_in_case = true ; this . insert_space_after_colon_in_conditional = true ; this . insert_space_after_colon_in_for = true ; this . insert_space_after_colon_in_labeled_statement = true ; this . insert_space_after_comma_in_allocation_expression = true ; this . insert_space_after_comma_in_annotation = true ; this . insert_space_after_comma_in_array_initializer = true ; this . insert_space_after_comma_in_constructor_declaration_parameters = true ; this . insert_space_after_comma_in_constructor_declaration_throws = true ; this . insert_space_after_comma_in_enum_constant_arguments = true ; this . insert_space_after_comma_in_enum_declarations = true ; this . insert_space_after_comma_in_explicit_constructor_call_arguments = true ; this . insert_space_after_comma_in_for_increments = true ; this . insert_space_after_comma_in_for_inits = true ; this . insert_space_after_comma_in_method_invocation_arguments = true ; this . insert_space_after_comma_in_method_declaration_parameters = true ; this . insert_space_after_comma_in_method_declaration_throws = true ; this . insert_space_after_comma_in_multiple_field_declarations = true ; this . insert_space_after_comma_in_multiple_local_declarations = true ; this . insert_space_after_comma_in_parameterized_type_reference = true ; this . insert_space_after_comma_in_superinterfaces = true ; this . insert_space_after_comma_in_type_arguments = true ; this . insert_space_after_comma_in_type_parameters = true ; this . insert_space_after_ellipsis = true ; this . insert_space_after_opening_angle_bracket_in_parameterized_type_reference = false ; this . insert_space_after_opening_angle_bracket_in_type_arguments = false ; this . insert_space_after_opening_angle_bracket_in_type_parameters = false ; this . insert_space_after_opening_bracket_in_array_allocation_expression = false ; this . insert_space_after_opening_bracket_in_array_reference = false ; this . insert_space_after_opening_brace_in_array_initializer = false ; this . insert_space_after_opening_paren_in_annotation = false ; this . insert_space_after_opening_paren_in_cast = false ; this . insert_space_after_opening_paren_in_catch = false ; this . insert_space_after_opening_paren_in_constructor_declaration = false ; this . insert_space_after_opening_paren_in_enum_constant = false ; this . insert_space_after_opening_paren_in_for = false ; this . insert_space_after_opening_paren_in_if = false ; this . insert_space_after_opening_paren_in_method_declaration = false ; this . insert_space_after_opening_paren_in_method_invocation = false ; this . insert_space_after_opening_paren_in_parenthesized_expression = false ; this . insert_space_after_opening_paren_in_switch = false ; this . insert_space_after_opening_paren_in_synchronized = false ; this . insert_space_after_opening_paren_in_try = false ; this . insert_space_after_opening_paren_in_while = false ; this . insert_space_after_postfix_operator = false ; this . insert_space_after_prefix_operator = false ; this . insert_space_after_question_in_conditional = true ; this . insert_space_after_question_in_wilcard = false ; this . insert_space_after_semicolon_in_for = true ; this . insert_space_after_semicolon_in_try_resources = true ; this . insert_space_after_unary_operator = false ; this . insert_space_before_and_in_type_parameter = true ; this . insert_space_before_at_in_annotation_type_declaration = true ; this . insert_space_before_assignment_operator = true ; this . insert_space_before_binary_operator = true ; this . insert_space_before_closing_angle_bracket_in_parameterized_type_reference = false ; this . insert_space_before_closing_angle_bracket_in_type_arguments = false ; this . insert_space_before_closing_angle_bracket_in_type_parameters = false ; this . insert_space_before_closing_brace_in_array_initializer = false ; this . insert_space_before_closing_bracket_in_array_allocation_expression = false ; this . insert_space_before_closing_bracket_in_array_reference = false ; this . insert_space_before_closing_paren_in_annotation = false ; this . insert_space_before_closing_paren_in_cast = false ; this . insert_space_before_closing_paren_in_catch = false ; this . insert_space_before_closing_paren_in_constructor_declaration = false ; this . insert_space_before_closing_paren_in_enum_constant = false ; this . insert_space_before_closing_paren_in_for = false ; this . insert_space_before_closing_paren_in_if = false ; this . insert_space_before_closing_paren_in_method_declaration = false ; this . insert_space_before_closing_paren_in_method_invocation = false ; this . insert_space_before_closing_paren_in_parenthesized_expression = false ; this . insert_space_before_closing_paren_in_switch = false ; this . insert_space_before_closing_paren_in_synchronized = false ; this . insert_space_before_closing_paren_in_try = false ; this . insert_space_before_closing_paren_in_while = false ; this . insert_space_before_colon_in_assert = true ; this . insert_space_before_colon_in_case = true ; this . insert_space_before_colon_in_conditional = true ; this . insert_space_before_colon_in_default = true ; this . insert_space_before_colon_in_for = true ; this . insert_space_before_colon_in_labeled_statement = true ; this . insert_space_before_comma_in_allocation_expression = false ; this . insert_space_before_comma_in_array_initializer = false ; this . insert_space_before_comma_in_constructor_declaration_parameters = false ; this . insert_space_before_comma_in_constructor_declaration_throws = false ; this . insert_space_before_comma_in_enum_constant_arguments = false ; this . insert_space_before_comma_in_enum_declarations = false ; this . insert_space_before_comma_in_explicit_constructor_call_arguments = false ; this . insert_space_before_comma_in_for_increments = false ; this . insert_space_before_comma_in_for_inits = false ; this . insert_space_before_comma_in_method_invocation_arguments = false ; this . insert_space_before_comma_in_method_declaration_parameters = false ; this . insert_space_before_comma_in_method_declaration_throws = false ; this . insert_space_before_comma_in_multiple_field_declarations = false ; this . insert_space_before_comma_in_multiple_local_declarations = false ; this . insert_space_before_comma_in_parameterized_type_reference = false ; this . insert_space_before_comma_in_superinterfaces = false ; this . insert_space_before_comma_in_type_arguments = false ; this . insert_space_before_comma_in_type_parameters = false ; this . insert_space_before_ellipsis = false ; this . insert_space_before_parenthesized_expression_in_return = true ; this . insert_space_before_parenthesized_expression_in_throw = true ; this . insert_space_before_opening_angle_bracket_in_parameterized_type_reference = false ; this . insert_space_before_opening_angle_bracket_in_type_arguments = false ; this . insert_space_before_opening_angle_bracket_in_type_parameters = false ; this . insert_space_before_opening_brace_in_annotation_type_declaration = true ; this . insert_space_before_opening_brace_in_anonymous_type_declaration = true ; this . insert_space_before_opening_brace_in_array_initializer = false ; this . insert_space_before_opening_brace_in_block = true ; this . insert_space_before_opening_brace_in_constructor_declaration = true ; this . insert_space_before_opening_brace_in_enum_constant = true ; this . insert_space_before_opening_brace_in_enum_declaration = true ; this . insert_space_before_opening_brace_in_method_declaration = true ; this . insert_space_before_opening_brace_in_switch = true ; this . insert_space_before_opening_brace_in_type_declaration = true ; this . insert_space_before_opening_bracket_in_array_allocation_expression = false ; this . insert_space_before_opening_bracket_in_array_reference = false ; this . insert_space_before_opening_bracket_in_array_type_reference = false ; this . insert_space_before_opening_paren_in_annotation = false ; this . insert_space_before_opening_paren_in_annotation_type_member_declaration = false ; this . insert_space_before_opening_paren_in_catch = true ; this . insert_space_before_opening_paren_in_constructor_declaration = false ; this . insert_space_before_opening_paren_in_enum_constant = false ; this . insert_space_before_opening_paren_in_for = true ; this . insert_space_before_opening_paren_in_if = true ; this . insert_space_before_opening_paren_in_method_invocation = false ; this . insert_space_before_opening_paren_in_method_declaration = false ; this . insert_space_before_opening_paren_in_switch = true ; this . insert_space_before_opening_paren_in_synchronized = true ; this . insert_space_before_opening_paren_in_try = true ; this . insert_space_before_opening_paren_in_parenthesized_expression = false ; this . insert_space_before_opening_paren_in_while = true ; this . insert_space_before_postfix_operator = false ; this . insert_space_before_prefix_operator = false ; this . insert_space_before_question_in_conditional = true ; this . insert_space_before_question_in_wilcard = false ; this . insert_space_before_semicolon = false ; this . insert_space_before_semicolon_in_for = false ; this . insert_space_before_semicolon_in_try_resources = false ; this . insert_space_before_unary_operator = false ; this . insert_space_between_brackets_in_array_type_reference = false ; this . insert_space_between_empty_braces_in_array_initializer = false ; this . insert_space_between_empty_brackets_in_array_allocation_expression = false ; this . insert_space_between_empty_parens_in_annotation_type_member_declaration = false ; this . insert_space_between_empty_parens_in_constructor_declaration = false ; this . insert_space_between_empty_parens_in_enum_constant = false ; this . insert_space_between_empty_parens_in_method_declaration = false ; this . insert_space_between_empty_parens_in_method_invocation = false ; this . compact_else_if = true ; this . keep_guardian_clause_on_one_line = false ; this . keep_else_statement_on_same_line = false ; this . keep_empty_array_initializer_on_one_line = false ; this . keep_simple_if_on_one_line = false ; this . keep_then_statement_on_same_line = false ; this . never_indent_block_comments_on_first_column = false ; this . never_indent_line_comments_on_first_column = false ; this . number_of_empty_lines_to_preserve = <NUM_LIT:1> ; this . join_lines_in_comments = true ; this . join_wrapped_lines = true ; this . put_empty_statement_on_new_line = false ; this . tab_size = <NUM_LIT:4> ; this . page_width = <NUM_LIT> ; this . tab_char = TAB ; this . use_tabs_only_for_leading_indentations = false ; this . wrap_before_binary_operator = true ; this . wrap_before_or_operator_multicatch = true ; this . use_tags = false ; this . disabling_tag = DEFAULT_DISABLING_TAG ; this . enabling_tag = DEFAULT_ENABLING_TAG ; this . wrap_outer_expressions_when_nested = true ; } public void setEclipseDefaultSettings ( ) { setJavaConventionsSettings ( ) ; this . tab_char = TAB ; this . tab_size = <NUM_LIT:4> ; } public void setJavaConventionsSettings ( ) { this . alignment_for_arguments_in_allocation_expression = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_annotation = Alignment . M_NO_ALIGNMENT ; this . alignment_for_arguments_in_enum_constant = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_explicit_constructor_call = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_method_invocation = Alignment . M_COMPACT_SPLIT ; this . alignment_for_arguments_in_qualified_allocation_expression = Alignment . M_COMPACT_SPLIT ; this . alignment_for_assignment = Alignment . M_NO_ALIGNMENT ; this . alignment_for_binary_expression = Alignment . M_COMPACT_SPLIT ; this . alignment_for_compact_if = Alignment . M_COMPACT_SPLIT ; this . alignment_for_conditional_expression = Alignment . M_NEXT_PER_LINE_SPLIT ; this . alignment_for_enum_constants = Alignment . NONE ; this . alignment_for_expressions_in_array_initializer = Alignment . M_COMPACT_SPLIT ; this . alignment_for_method_declaration = Alignment . M_NO_ALIGNMENT ; this . alignment_for_multiple_fields = Alignment . M_COMPACT_SPLIT ; this . alignment_for_parameters_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_parameters_in_method_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_resources_in_try = Alignment . M_NEXT_PER_LINE_SPLIT ; this . alignment_for_selector_in_method_invocation = Alignment . M_COMPACT_SPLIT ; this . alignment_for_superclass_in_type_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_superinterfaces_in_enum_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_superinterfaces_in_type_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_throws_clause_in_constructor_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_throws_clause_in_method_declaration = Alignment . M_COMPACT_SPLIT ; this . alignment_for_union_type_in_multicatch = Alignment . M_COMPACT_SPLIT ; this . align_type_members_on_columns = false ; this . brace_position_for_annotation_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_array_initializer = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_block = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_block_in_case = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_constructor_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_enum_constant = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_enum_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_method_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_type_declaration = DefaultCodeFormatterConstants . END_OF_LINE ; this . brace_position_for_switch = DefaultCodeFormatterConstants . END_OF_LINE ; this . comment_clear_blank_lines_in_block_comment = false ; this . comment_clear_blank_lines_in_javadoc_comment = false ; this . comment_format_block_comment = true ; this . comment_format_javadoc_comment = true ; this . comment_format_line_comment = true ; this . comment_format_line_comment_starting_on_first_column = true ; this . comment_format_header = false ; this . comment_format_html = true ; this . comment_format_source = true ; this . comment_indent_parameter_description = true ; this . comment_indent_root_tags = true ; this . comment_insert_empty_line_before_root_tags = true ; this . comment_insert_new_line_for_parameter = true ; this . comment_new_lines_at_block_boundaries = true ; this . comment_new_lines_at_javadoc_boundaries = true ; this . comment_line_length = <NUM_LIT> ; this . comment_preserve_white_space_between_code_and_line_comments = false ; this . continuation_indentation = <NUM_LIT:2> ; this . continuation_indentation_for_array_initializer = <NUM_LIT:2> ; this . blank_lines_after_imports = <NUM_LIT:1> ; this . blank_lines_after_package = <NUM_LIT:1> ; this . blank_lines_before_field = <NUM_LIT:0> ; this . blank_lines_before_first_class_body_declaration = <NUM_LIT:0> ; this . blank_lines_before_imports = <NUM_LIT:1> ; this . blank_lines_before_member_type = <NUM_LIT:1> ; this . blank_lines_before_method = <NUM_LIT:1> ; this . blank_lines_before_new_chunk = <NUM_LIT:1> ; this . blank_lines_before_package = <NUM_LIT:0> ; this . blank_lines_between_import_groups = <NUM_LIT:1> ; this . blank_lines_between_type_declarations = <NUM_LIT:1> ; this . blank_lines_at_beginning_of_method_body = <NUM_LIT:0> ; this . indent_statements_compare_to_block = true ; this . indent_statements_compare_to_body = true ; this . indent_body_declarations_compare_to_annotation_declaration_header = true ; this . indent_body_declarations_compare_to_enum_constant_header = true ; this . indent_body_declarations_compare_to_enum_declaration_header = true ; this . indent_body_declarations_compare_to_type_header = true ; this . indent_breaks_compare_to_cases = true ; this . indent_empty_lines = false ; this . indent_switchstatements_compare_to_cases = true ; this . indent_switchstatements_compare_to_switch = false ; this . indentation_size = <NUM_LIT:4> ; this . insert_new_line_after_annotation_on_type = true ; this . insert_new_line_after_annotation_on_field = true ; this . insert_new_line_after_annotation_on_method = true ; this . insert_new_line_after_annotation_on_package = true ; this . insert_new_line_after_annotation_on_parameter = false ; this . insert_new_line_after_annotation_on_local_variable = true ; this . insert_new_line_after_opening_brace_in_array_initializer = false ; this . insert_new_line_at_end_of_file_if_missing = false ; this . insert_new_line_before_catch_in_try_statement = false ; this . insert_new_line_before_closing_brace_in_array_initializer = false ; this . insert_new_line_before_else_in_if_statement = false ; this . insert_new_line_before_finally_in_try_statement = false ; this . insert_new_line_before_while_in_do_statement = false ; this . insert_new_line_in_empty_anonymous_type_declaration = true ; this . insert_new_line_in_empty_block = true ; this . insert_new_line_in_empty_annotation_declaration = true ; this . insert_new_line_in_empty_enum_constant = true ; this . insert_new_line_in_empty_enum_declaration = true ; this . insert_new_line_in_empty_method_body = true ; this . insert_new_line_in_empty_type_declaration = true ; this . insert_space_after_and_in_type_parameter = true ; this . insert_space_after_assignment_operator = true ; this . insert_space_after_at_in_annotation = false ; this . insert_space_after_at_in_annotation_type_declaration = false ; this . insert_space_after_binary_operator = true ; this . insert_space_after_closing_angle_bracket_in_type_arguments = true ; this . insert_space_after_closing_angle_bracket_in_type_parameters = true ; this . insert_space_after_closing_paren_in_cast = true ; this . insert_space_after_closing_brace_in_block = true ; this . insert_space_after_colon_in_assert = true ; this . insert_space_after_colon_in_case = true ; this . insert_space_after_colon_in_conditional = true ; this . insert_space_after_colon_in_for = true ; this . insert_space_after_colon_in_labeled_statement = true ; this . insert_space_after_comma_in_allocation_expression = true ; this . insert_space_after_comma_in_annotation = true ; this . insert_space_after_comma_in_array_initializer = true ; this . insert_space_after_comma_in_constructor_declaration_parameters = true ; this . insert_space_after_comma_in_constructor_declaration_throws = true ; this . insert_space_after_comma_in_enum_constant_arguments = true ; this . insert_space_after_comma_in_enum_declarations = true ; this . insert_space_after_comma_in_explicit_constructor_call_arguments = true ; this . insert_space_after_comma_in_for_increments = true ; this . insert_space_after_comma_in_for_inits = true ; this . insert_space_after_comma_in_method_invocation_arguments = true ; this . insert_space_after_comma_in_method_declaration_parameters = true ; this . insert_space_after_comma_in_method_declaration_throws = true ; this . insert_space_after_comma_in_multiple_field_declarations = true ; this . insert_space_after_comma_in_multiple_local_declarations = true ; this . insert_space_after_comma_in_parameterized_type_reference = true ; this . insert_space_after_comma_in_superinterfaces = true ; this . insert_space_after_comma_in_type_arguments = true ; this . insert_space_after_comma_in_type_parameters = true ; this . insert_space_after_ellipsis = true ; this . insert_space_after_opening_angle_bracket_in_parameterized_type_reference = false ; this . insert_space_after_opening_angle_bracket_in_type_arguments = false ; this . insert_space_after_opening_angle_bracket_in_type_parameters = false ; this . insert_space_after_opening_bracket_in_array_allocation_expression = false ; this . insert_space_after_opening_bracket_in_array_reference = false ; this . insert_space_after_opening_brace_in_array_initializer = true ; this . insert_space_after_opening_paren_in_annotation = false ; this . insert_space_after_opening_paren_in_cast = false ; this . insert_space_after_opening_paren_in_catch = false ; this . insert_space_after_opening_paren_in_constructor_declaration = false ; this . insert_space_after_opening_paren_in_enum_constant = false ; this . insert_space_after_opening_paren_in_for = false ; this . insert_space_after_opening_paren_in_if = false ; this . insert_space_after_opening_paren_in_method_declaration = false ; this . insert_space_after_opening_paren_in_method_invocation = false ; this . insert_space_after_opening_paren_in_parenthesized_expression = false ; this . insert_space_after_opening_paren_in_switch = false ; this . insert_space_after_opening_paren_in_synchronized = false ; this . insert_space_after_opening_paren_in_try = false ; this . insert_space_after_opening_paren_in_while = false ; this . insert_space_after_postfix_operator = false ; this . insert_space_after_prefix_operator = false ; this . insert_space_after_question_in_conditional = true ; this . insert_space_after_question_in_wilcard = false ; this . insert_space_after_semicolon_in_for = true ; this . insert_space_after_semicolon_in_try_resources = true ; this . insert_space_after_unary_operator = false ; this . insert_space_before_and_in_type_parameter = true ; this . insert_space_before_at_in_annotation_type_declaration = true ; this . insert_space_before_assignment_operator = true ; this . insert_space_before_binary_operator = true ; this . insert_space_before_closing_angle_bracket_in_parameterized_type_reference = false ; this . insert_space_before_closing_angle_bracket_in_type_arguments = false ; this . insert_space_before_closing_angle_bracket_in_type_parameters = false ; this . insert_space_before_closing_brace_in_array_initializer = true ; this . insert_space_before_closing_bracket_in_array_allocation_expression = false ; this . insert_space_before_closing_bracket_in_array_reference = false ; this . insert_space_before_closing_paren_in_annotation = false ; this . insert_space_before_closing_paren_in_cast = false ; this . insert_space_before_closing_paren_in_catch = false ; this . insert_space_before_closing_paren_in_constructor_declaration = false ; this . insert_space_before_closing_paren_in_enum_constant = false ; this . insert_space_before_closing_paren_in_for = false ; this . insert_space_before_closing_paren_in_if = false ; this . insert_space_before_closing_paren_in_method_declaration = false ; this . insert_space_before_closing_paren_in_method_invocation = false ; this . insert_space_before_closing_paren_in_parenthesized_expression = false ; this . insert_space_before_closing_paren_in_switch = false ; this . insert_space_before_closing_paren_in_synchronized = false ; this . insert_space_before_closing_paren_in_try = false ; this . insert_space_before_closing_paren_in_while = false ; this . insert_space_before_colon_in_assert = true ; this . insert_space_before_colon_in_case = false ; this . insert_space_before_colon_in_conditional = true ; this . insert_space_before_colon_in_default = false ; this . insert_space_before_colon_in_for = true ; this . insert_space_before_colon_in_labeled_statement = false ; this . insert_space_before_comma_in_allocation_expression = false ; this . insert_space_before_comma_in_array_initializer = false ; this . insert_space_before_comma_in_constructor_declaration_parameters = false ; this . insert_space_before_comma_in_constructor_declaration_throws = false ; this . insert_space_before_comma_in_enum_constant_arguments = false ; this . insert_space_before_comma_in_enum_declarations = false ; this . insert_space_before_comma_in_explicit_constructor_call_arguments = false ; this . insert_space_before_comma_in_for_increments = false ; this . insert_space_before_comma_in_for_inits = false ; this . insert_space_before_comma_in_method_invocation_arguments = false ; this . insert_space_before_comma_in_method_declaration_parameters = false ; this . insert_space_before_comma_in_method_declaration_throws = false ; this . insert_space_before_comma_in_multiple_field_declarations = false ; this . insert_space_before_comma_in_multiple_local_declarations = false ; this . insert_space_before_comma_in_parameterized_type_reference = false ; this . insert_space_before_comma_in_superinterfaces = false ; this . insert_space_before_comma_in_type_arguments = false ; this . insert_space_before_comma_in_type_parameters = false ; this . insert_space_before_ellipsis = false ; this . insert_space_before_parenthesized_expression_in_return = true ; this . insert_space_before_parenthesized_expression_in_throw = true ; this . insert_space_before_opening_angle_bracket_in_parameterized_type_reference = false ; this . insert_space_before_opening_angle_bracket_in_type_arguments = false ; this . insert_space_before_opening_angle_bracket_in_type_parameters = false ; this . insert_space_before_opening_brace_in_annotation_type_declaration = true ; this . insert_space_before_opening_brace_in_anonymous_type_declaration = true ; this . insert_space_before_opening_brace_in_array_initializer = true ; this . insert_space_before_opening_brace_in_block = true ; this . insert_space_before_opening_brace_in_constructor_declaration = true ; this . insert_space_before_opening_brace_in_enum_constant = true ; this . insert_space_before_opening_brace_in_enum_declaration = true ; this . insert_space_before_opening_brace_in_method_declaration = true ; this . insert_space_before_opening_brace_in_switch = true ; this . insert_space_before_opening_brace_in_type_declaration = true ; this . insert_space_before_opening_bracket_in_array_allocation_expression = false ; this . insert_space_before_opening_bracket_in_array_reference = false ; this . insert_space_before_opening_bracket_in_array_type_reference = false ; this . insert_space_before_opening_paren_in_annotation = false ; this . insert_space_before_opening_paren_in_annotation_type_member_declaration = false ; this . insert_space_before_opening_paren_in_catch = true ; this . insert_space_before_opening_paren_in_constructor_declaration = false ; this . insert_space_before_opening_paren_in_enum_constant = false ; this . insert_space_before_opening_paren_in_for = true ; this . insert_space_before_opening_paren_in_if = true ; this . insert_space_before_opening_paren_in_method_invocation = false ; this . insert_space_before_opening_paren_in_method_declaration = false ; this . insert_space_before_opening_paren_in_switch = true ; this . insert_space_before_opening_paren_in_synchronized = true ; this . insert_space_before_opening_paren_in_try = true ; this . insert_space_before_opening_paren_in_parenthesized_expression = false ; this . insert_space_before_opening_paren_in_while = true ; this . insert_space_before_postfix_operator = false ; this . insert_space_before_prefix_operator = false ; this . insert_space_before_question_in_conditional = true ; this . insert_space_before_question_in_wilcard = false ; this . insert_space_before_semicolon = false ; this . insert_space_before_semicolon_in_for = false ; this . insert_space_before_semicolon_in_try_resources = false ; this . insert_space_before_unary_operator = false ; this . insert_space_between_brackets_in_array_type_reference = false ; this . insert_space_between_empty_braces_in_array_initializer = false ; this . insert_space_between_empty_brackets_in_array_allocation_expression = false ; this . insert_space_between_empty_parens_in_annotation_type_member_declaration = false ; this . insert_space_between_empty_parens_in_constructor_declaration = false ; this . insert_space_between_empty_parens_in_enum_constant = false ; this . insert_space_between_empty_parens_in_method_declaration = false ; this . insert_space_between_empty_parens_in_method_invocation = false ; this . compact_else_if = true ; this . keep_guardian_clause_on_one_line = false ; this . keep_else_statement_on_same_line = false ; this . keep_empty_array_initializer_on_one_line = false ; this . keep_simple_if_on_one_line = false ; this . keep_then_statement_on_same_line = false ; this . never_indent_block_comments_on_first_column = false ; this . never_indent_line_comments_on_first_column = false ; this . number_of_empty_lines_to_preserve = <NUM_LIT:1> ; this . join_lines_in_comments = true ; this . join_wrapped_lines = true ; this . put_empty_statement_on_new_line = true ; this . tab_size = <NUM_LIT:8> ; this . page_width = <NUM_LIT> ; this . tab_char = MIXED ; this . use_tabs_only_for_leading_indentations = false ; this . wrap_before_binary_operator = true ; this . wrap_before_or_operator_multicatch = true ; this . use_tags = false ; this . disabling_tag = DEFAULT_DISABLING_TAG ; this . enabling_tag = DEFAULT_ENABLING_TAG ; this . wrap_outer_expressions_when_nested = true ; } } </s>
<s> package org . eclipse . jdt . internal . formatter ; import org . eclipse . jdt . internal . compiler . ast . Javadoc ; public class FormatJavadoc extends Javadoc { FormatJavadocBlock [ ] blocks ; int textStart , textEnd ; int lineStart , lineEnd ; public FormatJavadoc ( int sourceStart , int sourceEnd , int length ) { super ( sourceStart , sourceEnd ) ; if ( length > <NUM_LIT:0> ) { this . blocks = new FormatJavadocBlock [ length ] ; } } public FormatJavadocBlock getFirstBlock ( ) { if ( this . blocks != null ) { return this . blocks [ <NUM_LIT:0> ] ; } return null ; } public boolean isMultiLine ( ) { return this . lineStart < this . lineEnd ; } public String toDebugString ( char [ ] source ) { if ( this . blocks == null ) { return "<STR_LIT>" ; } StringBuffer buffer = new StringBuffer ( ) ; int length = this . blocks . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { this . blocks [ i ] . toStringDebug ( buffer , source ) ; buffer . append ( '<STR_LIT:\n>' ) ; } return buffer . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . core . formatter ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jface . text . IRegion ; import org . eclipse . text . edits . TextEdit ; public abstract class CodeFormatter { public static final int K_UNKNOWN = <NUM_LIT:0x00> ; public static final int K_EXPRESSION = <NUM_LIT> ; public static final int K_STATEMENTS = <NUM_LIT> ; public static final int K_CLASS_BODY_DECLARATIONS = <NUM_LIT> ; public static final int K_COMPILATION_UNIT = <NUM_LIT> ; public static final int K_SINGLE_LINE_COMMENT = <NUM_LIT> ; public static final int K_MULTI_LINE_COMMENT = <NUM_LIT> ; public static final int K_JAVA_DOC = <NUM_LIT> ; public static final int F_INCLUDE_COMMENTS = <NUM_LIT> ; public abstract TextEdit format ( int kind , String source , int offset , int length , int indentationLevel , String lineSeparator ) ; public abstract TextEdit format ( int kind , String source , IRegion [ ] regions , int indentationLevel , String lineSeparator ) ; public String createIndentationString ( int indentationLevel ) { return Util . EMPTY_STRING ; } } </s>
<s> package org . eclipse . jdt . core . formatter ; import java . util . Map ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . internal . formatter . DefaultCodeFormatterOptions ; import org . eclipse . jdt . internal . formatter . align . Alignment ; public class DefaultCodeFormatterConstants { public static final String END_OF_LINE = "<STR_LIT>" ; public static final String FALSE = "<STR_LIT:false>" ; public static final String FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ASSIGNMENT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_COMPACT_IF = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_AFTER_IMPORTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_AFTER_PACKAGE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BEFORE_FIELD = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BEFORE_IMPORTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BEFORE_METHOD = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BEFORE_PACKAGE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_SWITCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public final static String FORMATTER_COMMENT_CLEAR_BLANK_LINES = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_FORMAT = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_FORMAT_LINE_COMMENT = "<STR_LIT>" ; public static final String FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public final static String FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_FORMAT_HEADER = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_FORMAT_HTML = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_FORMAT_SOURCE = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_INDENT_ROOT_TAGS = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_LINE_LENGTH = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES = "<STR_LIT>" ; public final static String FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES = "<STR_LIT>" ; public static final String FORMATTER_COMPACT_ELSE_IF = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_CONTINUATION_INDENTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_USE_ON_OFF_TAGS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_DISABLING_TAG = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_ENABLING_TAG = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_EMPTY_LINES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INDENTATION_SIZE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_LABEL = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_TRY = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_WILDCARD = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_TRY_RESOURCES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_AND_IN_TYPE_PARAMETER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_TRY = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_TRY_RESOURCES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_LINE_SPLIT = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_JOIN_WRAPPED_LINES = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_JOIN_LINES_IN_COMMENTS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_TAB_CHAR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_TAB_SIZE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_WRAP_BEFORE_BINARY_OPERATOR = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_WRAP_BEFORE_OR_OPERATOR_MULTICATCH = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final String FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED = JavaCore . PLUGIN_ID + "<STR_LIT>" ; public static final int INDENT_BY_ONE = <NUM_LIT:2> ; public static final int INDENT_DEFAULT = <NUM_LIT:0> ; public static final int INDENT_ON_COLUMN = <NUM_LIT:1> ; public static final String MIXED = "<STR_LIT>" ; public static final String NEXT_LINE = "<STR_LIT>" ; public static final String NEXT_LINE_ON_WRAP = "<STR_LIT>" ; public static final String NEXT_LINE_SHIFTED = "<STR_LIT>" ; public static final String TRUE = "<STR_LIT:true>" ; public static final int WRAP_COMPACT = <NUM_LIT:1> ; public static final int WRAP_COMPACT_FIRST_BREAK = <NUM_LIT:2> ; public static final int WRAP_NEXT_PER_LINE = <NUM_LIT:5> ; public static final int WRAP_NEXT_SHIFTED = <NUM_LIT:4> ; public static final int WRAP_NO_SPLIT = <NUM_LIT:0> ; public static final int WRAP_ONE_PER_LINE = <NUM_LIT:3> ; private static final IllegalArgumentException WRONG_ARGUMENT = new IllegalArgumentException ( ) ; public static String createAlignmentValue ( boolean forceSplit , int wrapStyle , int indentStyle ) { int alignmentValue = <NUM_LIT:0> ; switch ( wrapStyle ) { case WRAP_COMPACT : alignmentValue |= Alignment . M_COMPACT_SPLIT ; break ; case WRAP_COMPACT_FIRST_BREAK : alignmentValue |= Alignment . M_COMPACT_FIRST_BREAK_SPLIT ; break ; case WRAP_NEXT_PER_LINE : alignmentValue |= Alignment . M_NEXT_PER_LINE_SPLIT ; break ; case WRAP_NEXT_SHIFTED : alignmentValue |= Alignment . M_NEXT_SHIFTED_SPLIT ; break ; case WRAP_ONE_PER_LINE : alignmentValue |= Alignment . M_ONE_PER_LINE_SPLIT ; break ; } if ( forceSplit ) { alignmentValue |= Alignment . M_FORCE ; } switch ( indentStyle ) { case INDENT_BY_ONE : alignmentValue |= Alignment . M_INDENT_BY_ONE ; break ; case INDENT_ON_COLUMN : alignmentValue |= Alignment . M_INDENT_ON_COLUMN ; } return String . valueOf ( alignmentValue ) ; } public static Map getEclipse21Settings ( ) { return DefaultCodeFormatterOptions . getDefaultSettings ( ) . getMap ( ) ; } public static Map getEclipseDefaultSettings ( ) { return DefaultCodeFormatterOptions . getEclipseDefaultSettings ( ) . getMap ( ) ; } public static boolean getForceWrapping ( String value ) { if ( value == null ) { throw WRONG_ARGUMENT ; } try { int existingValue = Integer . parseInt ( value ) ; return ( existingValue & Alignment . M_FORCE ) != <NUM_LIT:0> ; } catch ( NumberFormatException e ) { throw WRONG_ARGUMENT ; } } public static int getIndentStyle ( String value ) { if ( value == null ) { throw WRONG_ARGUMENT ; } try { int existingValue = Integer . parseInt ( value ) ; if ( ( existingValue & Alignment . M_INDENT_BY_ONE ) != <NUM_LIT:0> ) { return INDENT_BY_ONE ; } else if ( ( existingValue & Alignment . M_INDENT_ON_COLUMN ) != <NUM_LIT:0> ) { return INDENT_ON_COLUMN ; } else { return INDENT_DEFAULT ; } } catch ( NumberFormatException e ) { throw WRONG_ARGUMENT ; } } public static Map getJavaConventionsSettings ( ) { return DefaultCodeFormatterOptions . getJavaConventionsSettings ( ) . getMap ( ) ; } public static int getWrappingStyle ( String value ) { if ( value == null ) { throw WRONG_ARGUMENT ; } try { int existingValue = Integer . parseInt ( value ) & Alignment . SPLIT_MASK ; switch ( existingValue ) { case Alignment . M_COMPACT_SPLIT : return WRAP_COMPACT ; case Alignment . M_COMPACT_FIRST_BREAK_SPLIT : return WRAP_COMPACT_FIRST_BREAK ; case Alignment . M_NEXT_PER_LINE_SPLIT : return WRAP_NEXT_PER_LINE ; case Alignment . M_NEXT_SHIFTED_SPLIT : return WRAP_NEXT_SHIFTED ; case Alignment . M_ONE_PER_LINE_SPLIT : return WRAP_ONE_PER_LINE ; default : return WRAP_NO_SPLIT ; } } catch ( NumberFormatException e ) { throw WRONG_ARGUMENT ; } } public static String setForceWrapping ( String value , boolean force ) { if ( value == null ) { throw WRONG_ARGUMENT ; } try { int existingValue = Integer . parseInt ( value ) ; existingValue &= ~ Alignment . M_FORCE ; if ( force ) { existingValue |= Alignment . M_FORCE ; } return String . valueOf ( existingValue ) ; } catch ( NumberFormatException e ) { throw WRONG_ARGUMENT ; } } public static String setIndentStyle ( String value , int indentStyle ) { if ( value == null ) { throw WRONG_ARGUMENT ; } switch ( indentStyle ) { case INDENT_BY_ONE : case INDENT_DEFAULT : case INDENT_ON_COLUMN : break ; default : throw WRONG_ARGUMENT ; } try { int existingValue = Integer . parseInt ( value ) ; existingValue &= ~ ( Alignment . M_INDENT_BY_ONE | Alignment . M_INDENT_ON_COLUMN ) ; switch ( indentStyle ) { case INDENT_BY_ONE : existingValue |= Alignment . M_INDENT_BY_ONE ; break ; case INDENT_ON_COLUMN : existingValue |= Alignment . M_INDENT_ON_COLUMN ; } return String . valueOf ( existingValue ) ; } catch ( NumberFormatException e ) { throw WRONG_ARGUMENT ; } } public static String setWrappingStyle ( String value , int wrappingStyle ) { if ( value == null ) { throw WRONG_ARGUMENT ; } switch ( wrappingStyle ) { case WRAP_COMPACT : case WRAP_COMPACT_FIRST_BREAK : case WRAP_NEXT_PER_LINE : case WRAP_NEXT_SHIFTED : case WRAP_NO_SPLIT : case WRAP_ONE_PER_LINE : break ; default : throw WRONG_ARGUMENT ; } try { int existingValue = Integer . parseInt ( value ) ; existingValue &= ~ ( Alignment . SPLIT_MASK ) ; switch ( wrappingStyle ) { case WRAP_COMPACT : existingValue |= Alignment . M_COMPACT_SPLIT ; break ; case WRAP_COMPACT_FIRST_BREAK : existingValue |= Alignment . M_COMPACT_FIRST_BREAK_SPLIT ; break ; case WRAP_NEXT_PER_LINE : existingValue |= Alignment . M_NEXT_PER_LINE_SPLIT ; break ; case WRAP_NEXT_SHIFTED : existingValue |= Alignment . M_NEXT_SHIFTED_SPLIT ; break ; case WRAP_ONE_PER_LINE : existingValue |= Alignment . M_ONE_PER_LINE_SPLIT ; break ; } return String . valueOf ( existingValue ) ; } catch ( NumberFormatException e ) { throw WRONG_ARGUMENT ; } } } </s>
<s> package org . eclipse . jdt . core . formatter ; import java . io . BufferedInputStream ; import java . io . BufferedWriter ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . text . MessageFormat ; import java . util . ArrayList ; import java . util . Map ; import java . util . Properties ; import org . eclipse . equinox . app . IApplication ; import org . eclipse . equinox . app . IApplicationContext ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . internal . core . util . Util ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . Document ; import org . eclipse . jface . text . IDocument ; import org . eclipse . osgi . util . NLS ; import org . eclipse . text . edits . TextEdit ; public class CodeFormatterApplication implements IApplication { private final static class Messages extends NLS { private static final String BUNDLE_NAME = "<STR_LIT>" ; public static String CommandLineConfigFile ; public static String CommandLineDone ; public static String CommandLineErrorConfig ; public static String CommandLineErrorFileTryFullPath ; public static String CommandLineErrorFile ; public static String CommandLineErrorFileDir ; public static String CommandLineErrorQuietVerbose ; public static String CommandLineErrorNoConfigFile ; public static String CommandLineFormatting ; public static String CommandLineStart ; public static String CommandLineUsage ; public static String ConfigFileNotFoundErrorTryFullPath ; public static String ConfigFileReadingError ; public static String FormatProblem ; public static String CaughtException ; public static String ExceptionSkip ; static { NLS . initializeMessages ( BUNDLE_NAME , Messages . class ) ; } public static String bind ( String message ) { return bind ( message , null ) ; } public static String bind ( String message , Object binding ) { return bind ( message , new Object [ ] { binding } ) ; } public static String bind ( String message , Object binding1 , Object binding2 ) { return bind ( message , new Object [ ] { binding1 , binding2 } ) ; } public static String bind ( String message , Object [ ] bindings ) { return MessageFormat . format ( message , bindings ) ; } } private static final String ARG_CONFIG = "<STR_LIT>" ; private static final String ARG_HELP = "<STR_LIT>" ; private static final String ARG_QUIET = "<STR_LIT>" ; private static final String ARG_VERBOSE = "<STR_LIT>" ; private String configName ; private Map options = null ; private static final String PDE_LAUNCH = "<STR_LIT>" ; private boolean quiet = false ; private boolean verbose = false ; private void displayHelp ( ) { System . out . println ( Messages . bind ( Messages . CommandLineUsage ) ) ; } private void displayHelp ( String message ) { System . err . println ( message ) ; System . out . println ( ) ; displayHelp ( ) ; } private void formatDirTree ( File dir , CodeFormatter codeFormatter ) { File [ ] files = dir . listFiles ( ) ; if ( files == null ) return ; for ( int i = <NUM_LIT:0> ; i < files . length ; i ++ ) { File file = files [ i ] ; if ( file . isDirectory ( ) ) { formatDirTree ( file , codeFormatter ) ; } else if ( Util . isJavaLikeFileName ( file . getPath ( ) ) ) { formatFile ( file , codeFormatter ) ; } } } private void formatFile ( File file , CodeFormatter codeFormatter ) { IDocument doc = new Document ( ) ; try { if ( this . verbose ) { System . out . println ( Messages . bind ( Messages . CommandLineFormatting , file . getAbsolutePath ( ) ) ) ; } String contents = new String ( org . eclipse . jdt . internal . compiler . util . Util . getFileCharContent ( file , null ) ) ; doc . set ( contents ) ; TextEdit edit = codeFormatter . format ( CodeFormatter . K_COMPILATION_UNIT | CodeFormatter . F_INCLUDE_COMMENTS , contents , <NUM_LIT:0> , contents . length ( ) , <NUM_LIT:0> , null ) ; if ( edit != null ) { edit . apply ( doc ) ; } else { System . err . println ( Messages . bind ( Messages . FormatProblem , file . getAbsolutePath ( ) ) ) ; return ; } final BufferedWriter out = new BufferedWriter ( new FileWriter ( file ) ) ; try { out . write ( doc . get ( ) ) ; out . flush ( ) ; } finally { try { out . close ( ) ; } catch ( IOException e ) { } } } catch ( IOException e ) { String errorMessage = Messages . bind ( Messages . CaughtException , "<STR_LIT>" , e . getLocalizedMessage ( ) ) ; Util . log ( e , errorMessage ) ; System . err . println ( Messages . bind ( Messages . ExceptionSkip , errorMessage ) ) ; } catch ( BadLocationException e ) { String errorMessage = Messages . bind ( Messages . CaughtException , "<STR_LIT>" , e . getLocalizedMessage ( ) ) ; Util . log ( e , errorMessage ) ; System . err . println ( Messages . bind ( Messages . ExceptionSkip , errorMessage ) ) ; } } private File [ ] processCommandLine ( String [ ] argsArray ) { ArrayList args = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> , max = argsArray . length ; i < max ; i ++ ) { args . add ( argsArray [ i ] ) ; } int index = <NUM_LIT:0> ; final int argCount = argsArray . length ; final int DEFAULT_MODE = <NUM_LIT:0> ; final int CONFIG_MODE = <NUM_LIT:1> ; int mode = DEFAULT_MODE ; final int INITIAL_SIZE = <NUM_LIT:1> ; int fileCounter = <NUM_LIT:0> ; File [ ] filesToFormat = new File [ INITIAL_SIZE ] ; loop : while ( index < argCount ) { String currentArg = argsArray [ index ++ ] ; switch ( mode ) { case DEFAULT_MODE : if ( PDE_LAUNCH . equals ( currentArg ) ) { continue loop ; } if ( ARG_HELP . equals ( currentArg ) ) { displayHelp ( ) ; return null ; } if ( ARG_VERBOSE . equals ( currentArg ) ) { this . verbose = true ; continue loop ; } if ( ARG_QUIET . equals ( currentArg ) ) { this . quiet = true ; continue loop ; } if ( ARG_CONFIG . equals ( currentArg ) ) { mode = CONFIG_MODE ; continue loop ; } File file = new File ( currentArg ) ; if ( file . exists ( ) ) { if ( filesToFormat . length == fileCounter ) { System . arraycopy ( filesToFormat , <NUM_LIT:0> , ( filesToFormat = new File [ fileCounter * <NUM_LIT:2> ] ) , <NUM_LIT:0> , fileCounter ) ; } filesToFormat [ fileCounter ++ ] = file ; } else { String canonicalPath ; try { canonicalPath = file . getCanonicalPath ( ) ; } catch ( IOException e2 ) { canonicalPath = file . getAbsolutePath ( ) ; } String errorMsg = file . isAbsolute ( ) ? Messages . bind ( Messages . CommandLineErrorFile , canonicalPath ) : Messages . bind ( Messages . CommandLineErrorFileTryFullPath , canonicalPath ) ; displayHelp ( errorMsg ) ; return null ; } break ; case CONFIG_MODE : this . configName = currentArg ; this . options = readConfig ( currentArg ) ; if ( this . options == null ) { displayHelp ( Messages . bind ( Messages . CommandLineErrorConfig , currentArg ) ) ; return null ; } mode = DEFAULT_MODE ; continue loop ; } } if ( mode == CONFIG_MODE || this . options == null ) { displayHelp ( Messages . bind ( Messages . CommandLineErrorNoConfigFile ) ) ; return null ; } if ( this . quiet && this . verbose ) { displayHelp ( Messages . bind ( Messages . CommandLineErrorQuietVerbose , new String [ ] { ARG_QUIET , ARG_VERBOSE } ) ) ; return null ; } if ( fileCounter == <NUM_LIT:0> ) { displayHelp ( Messages . bind ( Messages . CommandLineErrorFileDir ) ) ; return null ; } if ( filesToFormat . length != fileCounter ) { System . arraycopy ( filesToFormat , <NUM_LIT:0> , ( filesToFormat = new File [ fileCounter ] ) , <NUM_LIT:0> , fileCounter ) ; } return filesToFormat ; } private Properties readConfig ( String filename ) { BufferedInputStream stream = null ; File configFile = new File ( filename ) ; try { stream = new BufferedInputStream ( new FileInputStream ( configFile ) ) ; final Properties formatterOptions = new Properties ( ) ; formatterOptions . load ( stream ) ; return formatterOptions ; } catch ( IOException e ) { String canonicalPath = null ; try { canonicalPath = configFile . getCanonicalPath ( ) ; } catch ( IOException e2 ) { canonicalPath = configFile . getAbsolutePath ( ) ; } String errorMessage ; if ( ! configFile . exists ( ) && ! configFile . isAbsolute ( ) ) { errorMessage = Messages . bind ( Messages . ConfigFileNotFoundErrorTryFullPath , new Object [ ] { canonicalPath , System . getProperty ( "<STR_LIT>" ) } ) ; } else { errorMessage = Messages . bind ( Messages . ConfigFileReadingError , canonicalPath ) ; } Util . log ( e , errorMessage ) ; System . err . println ( errorMessage ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { } } } return null ; } public Object start ( IApplicationContext context ) throws Exception { File [ ] filesToFormat = processCommandLine ( ( String [ ] ) context . getArguments ( ) . get ( IApplicationContext . APPLICATION_ARGS ) ) ; if ( filesToFormat == null ) { return IApplication . EXIT_OK ; } if ( ! this . quiet ) { if ( this . configName != null ) { System . out . println ( Messages . bind ( Messages . CommandLineConfigFile , this . configName ) ) ; } System . out . println ( Messages . bind ( Messages . CommandLineStart ) ) ; } final CodeFormatter codeFormatter = ToolFactory . createCodeFormatter ( this . options ) ; for ( int i = <NUM_LIT:0> , max = filesToFormat . length ; i < max ; i ++ ) { final File file = filesToFormat [ i ] ; if ( file . isDirectory ( ) ) { formatDirTree ( file , codeFormatter ) ; } else if ( Util . isJavaLikeFileName ( file . getPath ( ) ) ) { formatFile ( file , codeFormatter ) ; } } if ( ! this . quiet ) { System . out . println ( Messages . bind ( Messages . CommandLineDone ) ) ; } return IApplication . EXIT_OK ; } public void stop ( ) { } } </s>
<s> package org . eclipse . jdt . core . formatter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Map ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . DefaultLineTracker ; import org . eclipse . jface . text . ILineTracker ; import org . eclipse . jface . text . IRegion ; import org . eclipse . text . edits . ReplaceEdit ; public final class IndentManipulation { private IndentManipulation ( ) { } public static boolean isIndentChar ( char ch ) { return ScannerHelper . isWhitespace ( ch ) && ! isLineDelimiterChar ( ch ) ; } public static boolean isLineDelimiterChar ( char ch ) { return ch == '<STR_LIT:\n>' || ch == '<STR_LIT>' ; } public static int measureIndentUnits ( CharSequence line , int tabWidth , int indentWidth ) { if ( indentWidth < <NUM_LIT:0> || tabWidth < <NUM_LIT:0> || line == null ) { throw new IllegalArgumentException ( ) ; } if ( indentWidth == <NUM_LIT:0> ) return <NUM_LIT:0> ; int visualLength = measureIndentInSpaces ( line , tabWidth ) ; return visualLength / indentWidth ; } public static int measureIndentInSpaces ( CharSequence line , int tabWidth ) { if ( tabWidth < <NUM_LIT:0> || line == null ) { throw new IllegalArgumentException ( ) ; } int length = <NUM_LIT:0> ; int max = line . length ( ) ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { char ch = line . charAt ( i ) ; if ( ch == '<STR_LIT:\t>' ) { length = calculateSpaceEquivalents ( tabWidth , length ) ; } else if ( isIndentChar ( ch ) ) { length ++ ; } else { return length ; } } return length ; } public static String extractIndentString ( String line , int tabWidth , int indentWidth ) { if ( tabWidth < <NUM_LIT:0> || indentWidth < <NUM_LIT:0> || line == null ) { throw new IllegalArgumentException ( ) ; } int size = line . length ( ) ; int end = <NUM_LIT:0> ; int spaceEquivs = <NUM_LIT:0> ; int characters = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { char c = line . charAt ( i ) ; if ( c == '<STR_LIT:\t>' ) { spaceEquivs = calculateSpaceEquivalents ( tabWidth , spaceEquivs ) ; characters ++ ; } else if ( isIndentChar ( c ) ) { spaceEquivs ++ ; characters ++ ; } else { break ; } if ( spaceEquivs >= indentWidth ) { end += characters ; characters = <NUM_LIT:0> ; if ( indentWidth == <NUM_LIT:0> ) { spaceEquivs = <NUM_LIT:0> ; } else { spaceEquivs = spaceEquivs % indentWidth ; } } } if ( end == <NUM_LIT:0> ) { return Util . EMPTY_STRING ; } else if ( end == size ) { return line ; } else { return line . substring ( <NUM_LIT:0> , end ) ; } } public static String trimIndent ( String line , int indentUnitsToRemove , int tabWidth , int indentWidth ) { if ( tabWidth < <NUM_LIT:0> || indentWidth < <NUM_LIT:0> || line == null ) { throw new IllegalArgumentException ( ) ; } if ( indentUnitsToRemove <= <NUM_LIT:0> || indentWidth == <NUM_LIT:0> ) { return line ; } final int spaceEquivalentsToRemove = indentUnitsToRemove * indentWidth ; int start = <NUM_LIT:0> ; int spaceEquivalents = <NUM_LIT:0> ; int size = line . length ( ) ; String prefix = null ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { char c = line . charAt ( i ) ; if ( c == '<STR_LIT:\t>' ) { spaceEquivalents = calculateSpaceEquivalents ( tabWidth , spaceEquivalents ) ; } else if ( isIndentChar ( c ) ) { spaceEquivalents ++ ; } else { start = i ; break ; } if ( spaceEquivalents == spaceEquivalentsToRemove ) { start = i + <NUM_LIT:1> ; break ; } if ( spaceEquivalents > spaceEquivalentsToRemove ) { start = i + <NUM_LIT:1> ; char [ ] missing = new char [ spaceEquivalents - spaceEquivalentsToRemove ] ; Arrays . fill ( missing , '<CHAR_LIT:U+0020>' ) ; prefix = new String ( missing ) ; break ; } } String trimmed ; if ( start == size ) trimmed = Util . EMPTY_STRING ; else trimmed = line . substring ( start ) ; if ( prefix == null ) return trimmed ; return prefix + trimmed ; } public static String changeIndent ( String code , int indentUnitsToRemove , int tabWidth , int indentWidth , String newIndentString , String lineDelim ) { if ( tabWidth < <NUM_LIT:0> || indentWidth < <NUM_LIT:0> || code == null || indentUnitsToRemove < <NUM_LIT:0> || newIndentString == null || lineDelim == null ) { throw new IllegalArgumentException ( ) ; } try { ILineTracker tracker = new DefaultLineTracker ( ) ; tracker . set ( code ) ; int nLines = tracker . getNumberOfLines ( ) ; if ( nLines == <NUM_LIT:1> ) { return code ; } StringBuffer buf = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> ; i < nLines ; i ++ ) { IRegion region = tracker . getLineInformation ( i ) ; int start = region . getOffset ( ) ; int end = start + region . getLength ( ) ; String line = code . substring ( start , end ) ; if ( i == <NUM_LIT:0> ) { buf . append ( line ) ; } else { buf . append ( lineDelim ) ; buf . append ( newIndentString ) ; if ( indentWidth != <NUM_LIT:0> ) { buf . append ( trimIndent ( line , indentUnitsToRemove , tabWidth , indentWidth ) ) ; } else { buf . append ( line ) ; } } } return buf . toString ( ) ; } catch ( BadLocationException e ) { return code ; } } public static ReplaceEdit [ ] getChangeIndentEdits ( String source , int indentUnitsToRemove , int tabWidth , int indentWidth , String newIndentString ) { if ( tabWidth < <NUM_LIT:0> || indentWidth < <NUM_LIT:0> || source == null || indentUnitsToRemove < <NUM_LIT:0> || newIndentString == null ) { throw new IllegalArgumentException ( ) ; } ArrayList result = new ArrayList ( ) ; try { ILineTracker tracker = new DefaultLineTracker ( ) ; tracker . set ( source ) ; int nLines = tracker . getNumberOfLines ( ) ; if ( nLines == <NUM_LIT:1> ) return ( ReplaceEdit [ ] ) result . toArray ( new ReplaceEdit [ result . size ( ) ] ) ; for ( int i = <NUM_LIT:1> ; i < nLines ; i ++ ) { IRegion region = tracker . getLineInformation ( i ) ; int offset = region . getOffset ( ) ; String line = source . substring ( offset , offset + region . getLength ( ) ) ; int length = indexOfIndent ( line , indentUnitsToRemove , tabWidth , indentWidth ) ; if ( length >= <NUM_LIT:0> ) { result . add ( new ReplaceEdit ( offset , length , newIndentString ) ) ; } else { length = measureIndentUnits ( line , tabWidth , indentWidth ) ; result . add ( new ReplaceEdit ( offset , length , "<STR_LIT>" ) ) ; } } } catch ( BadLocationException cannotHappen ) { } return ( ReplaceEdit [ ] ) result . toArray ( new ReplaceEdit [ result . size ( ) ] ) ; } private static int indexOfIndent ( CharSequence line , int numberOfIndentUnits , int tabWidth , int indentWidth ) { int spaceEquivalents = numberOfIndentUnits * indentWidth ; int size = line . length ( ) ; int result = - <NUM_LIT:1> ; int blanks = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < size && blanks < spaceEquivalents ; i ++ ) { char c = line . charAt ( i ) ; if ( c == '<STR_LIT:\t>' ) { blanks = calculateSpaceEquivalents ( tabWidth , blanks ) ; } else if ( isIndentChar ( c ) ) { blanks ++ ; } else { break ; } result = i ; } if ( blanks < spaceEquivalents ) return - <NUM_LIT:1> ; return result + <NUM_LIT:1> ; } private static int calculateSpaceEquivalents ( int tabWidth , int spaceEquivalents ) { if ( tabWidth == <NUM_LIT:0> ) { return spaceEquivalents ; } int remainder = spaceEquivalents % tabWidth ; spaceEquivalents += tabWidth - remainder ; return spaceEquivalents ; } public static int getTabWidth ( Map options ) { if ( options == null ) { throw new IllegalArgumentException ( ) ; } return getIntValue ( options , DefaultCodeFormatterConstants . FORMATTER_TAB_SIZE , <NUM_LIT:4> ) ; } public static int getIndentWidth ( Map options ) { if ( options == null ) { throw new IllegalArgumentException ( ) ; } int tabWidth = getTabWidth ( options ) ; boolean isMixedMode = DefaultCodeFormatterConstants . MIXED . equals ( options . get ( DefaultCodeFormatterConstants . FORMATTER_TAB_CHAR ) ) ; if ( isMixedMode ) { return getIntValue ( options , DefaultCodeFormatterConstants . FORMATTER_INDENTATION_SIZE , tabWidth ) ; } return tabWidth ; } private static int getIntValue ( Map options , String key , int def ) { try { return Integer . parseInt ( ( String ) options . get ( key ) ) ; } catch ( NumberFormatException e ) { return def ; } } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . Compiler ; 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 . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; public class CodeSnippetCompiler extends Compiler { EvaluationContext evaluationContext ; int codeSnippetStart ; int codeSnippetEnd ; public CodeSnippetCompiler ( INameEnvironment environment , IErrorHandlingPolicy policy , CompilerOptions compilerOptions , ICompilerRequestor requestor , IProblemFactory problemFactory , EvaluationContext evaluationContext , int codeSnippetStart , int codeSnippetEnd ) { super ( environment , policy , compilerOptions , requestor , problemFactory ) ; this . codeSnippetStart = codeSnippetStart ; this . codeSnippetEnd = codeSnippetEnd ; this . evaluationContext = evaluationContext ; this . parser = new CodeSnippetParser ( this . problemReporter , evaluationContext , this . options . parseLiteralExpressionsAsConstants , codeSnippetStart , codeSnippetEnd ) ; this . parseThreshold = <NUM_LIT:1> ; } public void initializeParser ( ) { this . parser = new CodeSnippetParser ( this . problemReporter , this . evaluationContext , this . options . parseLiteralExpressionsAsConstants , this . codeSnippetStart , this . codeSnippetEnd ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . internal . compiler . ClassFile ; public interface IRequestor { boolean acceptClassFiles ( ClassFile [ ] classFiles , char [ ] codeSnippetClassName ) ; void acceptProblem ( CategorizedProblem problem , char [ ] fragmentSource , int fragmentKind ) ; } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ast . SuperReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . InvocationSite ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CodeSnippetSuperReference extends SuperReference implements EvaluationConstants , InvocationSite { public CodeSnippetSuperReference ( int pos , int sourceEnd ) { super ( pos , sourceEnd ) ; } public TypeBinding [ ] genericTypeArguments ( ) { return null ; } public TypeBinding resolveType ( BlockScope scope ) { scope . problemReporter ( ) . cannotUseSuperInCodeSnippet ( this . sourceStart , this . sourceEnd ) ; return null ; } public boolean isSuperAccess ( ) { return false ; } public boolean isTypeAccess ( ) { return false ; } public void setActualReceiverType ( ReferenceBinding receiverType ) { } public void setDepth ( int depth ) { } public void setFieldIndex ( int index ) { } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . env . IBinaryField ; import org . eclipse . jdt . internal . compiler . env . IBinaryMethod ; import org . eclipse . jdt . internal . compiler . env . IBinaryNestedType ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . core . util . Util ; public class CodeSnippetSkeleton implements IBinaryType , EvaluationConstants { public static class BinaryMethodSkeleton implements IBinaryMethod { char [ ] [ ] exceptionTypeNames ; char [ ] methodDescriptor ; char [ ] selector ; boolean isConstructor ; public BinaryMethodSkeleton ( char [ ] selector , char [ ] methodDescriptor , char [ ] [ ] exceptionTypeNames , boolean isConstructor ) { this . selector = selector ; this . methodDescriptor = methodDescriptor ; this . exceptionTypeNames = exceptionTypeNames ; this . isConstructor = isConstructor ; } public IBinaryAnnotation [ ] getAnnotations ( ) { return null ; } public char [ ] [ ] getArgumentNames ( ) { return null ; } public Object getDefaultValue ( ) { return null ; } public char [ ] [ ] getExceptionTypeNames ( ) { return this . exceptionTypeNames ; } public char [ ] getGenericSignature ( ) { return null ; } public char [ ] getMethodDescriptor ( ) { return this . methodDescriptor ; } public int getModifiers ( ) { return ClassFileConstants . AccPublic ; } public IBinaryAnnotation [ ] getParameterAnnotations ( int index ) { return null ; } public char [ ] getSelector ( ) { return this . selector ; } public long getTagBits ( ) { return <NUM_LIT:0> ; } public boolean isClinit ( ) { return false ; } public boolean isConstructor ( ) { return this . isConstructor ; } } IBinaryMethod [ ] methods = new IBinaryMethod [ ] { new BinaryMethodSkeleton ( "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , new char [ ] [ ] { } , true ) , new BinaryMethodSkeleton ( "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , new char [ ] [ ] { "<STR_LIT>" . toCharArray ( ) } , false ) , new BinaryMethodSkeleton ( "<STR_LIT>" . toCharArray ( ) , "<STR_LIT>" . toCharArray ( ) , new char [ ] [ ] { } , false ) } ; public CodeSnippetSkeleton ( ) { super ( ) ; } public IBinaryAnnotation [ ] getAnnotations ( ) { return null ; } public char [ ] getEnclosingMethod ( ) { return null ; } public char [ ] getEnclosingTypeName ( ) { return null ; } public IBinaryField [ ] getFields ( ) { return null ; } public char [ ] getFileName ( ) { return CharOperation . concat ( CODE_SNIPPET_NAME , Util . defaultJavaExtension ( ) . toCharArray ( ) ) ; } public char [ ] getGenericSignature ( ) { return null ; } public char [ ] [ ] getInterfaceNames ( ) { return null ; } public String getJavadocContents ( ) { return null ; } public String getJavadocContents ( IProgressMonitor monitor , String defaultEncoding ) throws JavaModelException { return null ; } public IBinaryNestedType [ ] getMemberTypes ( ) { return null ; } public IBinaryMethod [ ] getMethods ( ) { return this . methods ; } public int getModifiers ( ) { return ClassFileConstants . AccPublic ; } public char [ ] [ ] [ ] getMissingTypeNames ( ) { return null ; } public char [ ] getName ( ) { return CODE_SNIPPET_NAME ; } public char [ ] getSourceName ( ) { return ROOT_CLASS_NAME ; } public char [ ] getSuperclassName ( ) { return null ; } public long getTagBits ( ) { return <NUM_LIT:0> ; } public String getURLContents ( String docUrlValue , String defaultEncoding ) { return null ; } public boolean isAnonymous ( ) { return false ; } public boolean isBinaryType ( ) { return true ; } public boolean isLocal ( ) { return false ; } public boolean isMember ( ) { return false ; } public char [ ] sourceFileName ( ) { return null ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ast . Assignment ; import org . eclipse . jdt . internal . compiler . ast . BinaryExpression ; import org . eclipse . jdt . internal . compiler . ast . CompoundAssignment ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . IntLiteral ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . Opcodes ; import org . eclipse . jdt . internal . compiler . flow . FlowContext ; import org . eclipse . jdt . internal . compiler . flow . FlowInfo ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . LocalVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ParameterizedFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; import org . eclipse . jdt . internal . compiler . lookup . VariableBinding ; import org . eclipse . jdt . internal . compiler . problem . AbortMethod ; public class CodeSnippetSingleNameReference extends SingleNameReference implements EvaluationConstants , ProblemReasons { EvaluationContext evaluationContext ; FieldBinding delegateThis ; public CodeSnippetSingleNameReference ( char [ ] source , long pos , EvaluationContext evaluationContext ) { super ( source , pos ) ; this . evaluationContext = evaluationContext ; } public FlowInfo analyseCode ( BlockScope currentScope , FlowContext flowContext , FlowInfo flowInfo , boolean valueRequired ) { switch ( this . bits & RestrictiveFlagMASK ) { case Binding . FIELD : FieldBinding fieldBinding ; if ( ( fieldBinding = ( FieldBinding ) this . binding ) . isBlankFinal ( ) && currentScope . needBlankFinalFieldInitializationCheck ( fieldBinding ) ) { FlowInfo fieldInits = flowContext . getInitsForFinalBlankInitializationCheck ( fieldBinding . declaringClass . original ( ) , flowInfo ) ; if ( ! fieldInits . isDefinitelyAssigned ( fieldBinding ) ) { currentScope . problemReporter ( ) . uninitializedBlankFinalField ( fieldBinding , this ) ; } } break ; case Binding . LOCAL : LocalVariableBinding localBinding ; if ( ! flowInfo . isDefinitelyAssigned ( localBinding = ( LocalVariableBinding ) this . binding ) ) { currentScope . problemReporter ( ) . uninitializedLocalVariable ( localBinding , this ) ; } if ( ( flowInfo . tagBits & FlowInfo . UNREACHABLE ) == <NUM_LIT:0> ) { localBinding . useFlag = LocalVariableBinding . USED ; } else if ( localBinding . useFlag == LocalVariableBinding . UNUSED ) { localBinding . useFlag = LocalVariableBinding . FAKE_USED ; } } return flowInfo ; } public TypeBinding checkFieldAccess ( BlockScope scope ) { if ( this . delegateThis == null ) { return super . checkFieldAccess ( scope ) ; } FieldBinding fieldBinding = ( FieldBinding ) this . binding ; this . bits &= ~ RestrictiveFlagMASK ; this . bits |= Binding . FIELD ; if ( ! fieldBinding . isStatic ( ) ) { if ( this . evaluationContext . isStatic ) { scope . problemReporter ( ) . staticFieldAccessToNonStaticVariable ( this , fieldBinding ) ; this . constant = Constant . NotAConstant ; return null ; } } this . constant = fieldBinding . constant ( ) ; if ( isFieldUseDeprecated ( fieldBinding , scope , this . bits ) ) { scope . problemReporter ( ) . deprecatedField ( fieldBinding , this ) ; } return fieldBinding . type ; } public void generateAssignment ( BlockScope currentScope , CodeStream codeStream , Assignment assignment , boolean valueRequired ) { if ( assignment . expression . isCompactableOperation ( ) ) { BinaryExpression operation = ( BinaryExpression ) assignment . expression ; int operator = ( operation . bits & OperatorMASK ) > > OperatorSHIFT ; SingleNameReference variableReference ; if ( ( operation . left instanceof SingleNameReference ) && ( ( variableReference = ( SingleNameReference ) operation . left ) . binding == this . binding ) ) { variableReference . generateCompoundAssignment ( currentScope , codeStream , this . syntheticAccessors == null ? null : this . syntheticAccessors [ WRITE ] , operation . right , operator , operation . implicitConversion , valueRequired ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } return ; } if ( ( operation . right instanceof SingleNameReference ) && ( ( operator == PLUS ) || ( operator == MULTIPLY ) ) && ( ( variableReference = ( SingleNameReference ) operation . right ) . binding == this . binding ) && ( operation . left . constant != Constant . NotAConstant ) && ( ( ( operation . left . implicitConversion & IMPLICIT_CONVERSION_MASK ) > > <NUM_LIT:4> ) != T_JavaLangString ) && ( ( ( operation . right . implicitConversion & IMPLICIT_CONVERSION_MASK ) > > <NUM_LIT:4> ) != T_JavaLangString ) ) { variableReference . generateCompoundAssignment ( currentScope , codeStream , this . syntheticAccessors == null ? null : this . syntheticAccessors [ WRITE ] , operation . left , operator , operation . implicitConversion , valueRequired ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } return ; } } switch ( this . bits & RestrictiveFlagMASK ) { case Binding . FIELD : FieldBinding codegenField = ( ( FieldBinding ) this . binding ) . original ( ) ; if ( codegenField . canBeSeenBy ( getReceiverType ( currentScope ) , this , currentScope ) ) { if ( ! codegenField . isStatic ( ) ) { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { ReferenceBinding targetType = currentScope . enclosingSourceType ( ) . enclosingTypeAt ( ( this . bits & DepthMASK ) > > DepthSHIFT ) ; Object [ ] emulationPath = currentScope . getEmulationPath ( targetType , true , false ) ; codeStream . generateOuterAccess ( emulationPath , this , targetType , currentScope ) ; } else { generateReceiver ( codeStream ) ; } } assignment . expression . generateCode ( currentScope , codeStream , true ) ; fieldStore ( currentScope , codeStream , codegenField , null , this . actualReceiverType , this . delegateThis == null , valueRequired ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } } else { codeStream . generateEmulationForField ( codegenField ) ; if ( ! codegenField . isStatic ( ) ) { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { currentScope . problemReporter ( ) . needImplementation ( this ) ; } else { generateReceiver ( codeStream ) ; } } else { codeStream . aconst_null ( ) ; } assignment . expression . generateCode ( currentScope , codeStream , true ) ; if ( valueRequired ) { if ( ( codegenField . type == TypeBinding . LONG ) || ( codegenField . type == TypeBinding . DOUBLE ) ) { codeStream . dup2_x2 ( ) ; } else { codeStream . dup_x2 ( ) ; } } codeStream . generateEmulatedWriteAccessForField ( codegenField ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } } return ; case Binding . LOCAL : LocalVariableBinding localBinding = ( LocalVariableBinding ) this . binding ; if ( localBinding . resolvedPosition != - <NUM_LIT:1> ) { assignment . expression . generateCode ( currentScope , codeStream , true ) ; } else { if ( assignment . expression . constant != Constant . NotAConstant ) { if ( valueRequired ) { codeStream . generateConstant ( assignment . expression . constant , assignment . implicitConversion ) ; } } else { assignment . expression . generateCode ( currentScope , codeStream , true ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } else { if ( ( localBinding . type == TypeBinding . LONG ) || ( localBinding . type == TypeBinding . DOUBLE ) ) { codeStream . pop2 ( ) ; } else { codeStream . pop ( ) ; } } } return ; } codeStream . store ( localBinding , valueRequired ) ; if ( ( this . bits & FirstAssignmentToLocal ) != <NUM_LIT:0> ) { localBinding . recordInitializationStartPC ( codeStream . position ) ; } if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } } } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; if ( this . constant != Constant . NotAConstant ) { if ( valueRequired ) { codeStream . generateConstant ( this . constant , this . implicitConversion ) ; } } else { switch ( this . bits & RestrictiveFlagMASK ) { case Binding . FIELD : if ( ! valueRequired ) break ; FieldBinding codegenField = ( ( FieldBinding ) this . binding ) . original ( ) ; Constant fieldConstant = codegenField . constant ( ) ; if ( fieldConstant == Constant . NotAConstant ) { if ( codegenField . canBeSeenBy ( getReceiverType ( currentScope ) , this , currentScope ) ) { TypeBinding someReceiverType = this . delegateThis != null ? this . delegateThis . type : this . actualReceiverType ; TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , codegenField , someReceiverType , true ) ; if ( codegenField . isStatic ( ) ) { codeStream . fieldAccess ( Opcodes . OPC_getstatic , codegenField , constantPoolDeclaringClass ) ; } else { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { ReferenceBinding targetType = currentScope . enclosingSourceType ( ) . enclosingTypeAt ( ( this . bits & DepthMASK ) > > DepthSHIFT ) ; Object [ ] emulationPath = currentScope . getEmulationPath ( targetType , true , false ) ; codeStream . generateOuterAccess ( emulationPath , this , targetType , currentScope ) ; } else { generateReceiver ( codeStream ) ; } codeStream . fieldAccess ( Opcodes . OPC_getfield , codegenField , constantPoolDeclaringClass ) ; } } else { if ( ! codegenField . isStatic ( ) ) { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { currentScope . problemReporter ( ) . needImplementation ( this ) ; } else { generateReceiver ( codeStream ) ; } } else { codeStream . aconst_null ( ) ; } codeStream . generateEmulatedReadAccessForField ( codegenField ) ; } if ( this . genericCast != null ) codeStream . checkcast ( this . genericCast ) ; codeStream . generateImplicitConversion ( this . implicitConversion ) ; } else { codeStream . generateConstant ( fieldConstant , this . implicitConversion ) ; } break ; case Binding . LOCAL : LocalVariableBinding localBinding = ( LocalVariableBinding ) this . binding ; if ( localBinding . resolvedPosition == - <NUM_LIT:1> ) { if ( valueRequired ) { localBinding . useFlag = LocalVariableBinding . USED ; throw new AbortMethod ( CodeStream . RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE , null ) ; } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; return ; } if ( ! valueRequired ) break ; if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { VariableBinding [ ] path = currentScope . getEmulationPath ( localBinding ) ; codeStream . generateOuterAccess ( path , this , localBinding , currentScope ) ; } else { codeStream . load ( localBinding ) ; } codeStream . generateImplicitConversion ( this . implicitConversion ) ; break ; } } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public void generateCompoundAssignment ( BlockScope currentScope , CodeStream codeStream , MethodBinding writeAccessor , Expression expression , int operator , int assignmentImplicitConversion , boolean valueRequired ) { switch ( this . bits & RestrictiveFlagMASK ) { case Binding . FIELD : FieldBinding codegenField = ( ( FieldBinding ) this . binding ) . original ( ) ; if ( codegenField . isStatic ( ) ) { if ( codegenField . canBeSeenBy ( getReceiverType ( currentScope ) , this , currentScope ) ) { TypeBinding someReceiverType = this . delegateThis != null ? this . delegateThis . type : this . actualReceiverType ; TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , codegenField , someReceiverType , true ) ; codeStream . fieldAccess ( Opcodes . OPC_getstatic , codegenField , constantPoolDeclaringClass ) ; } else { codeStream . generateEmulationForField ( codegenField ) ; codeStream . aconst_null ( ) ; codeStream . aconst_null ( ) ; codeStream . generateEmulatedReadAccessForField ( codegenField ) ; } } else { if ( codegenField . canBeSeenBy ( getReceiverType ( currentScope ) , this , currentScope ) ) { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { ReferenceBinding targetType = currentScope . enclosingSourceType ( ) . enclosingTypeAt ( ( this . bits & DepthMASK ) > > DepthSHIFT ) ; Object [ ] emulationPath = currentScope . getEmulationPath ( targetType , true , false ) ; codeStream . generateOuterAccess ( emulationPath , this , targetType , currentScope ) ; } else { generateReceiver ( codeStream ) ; } codeStream . dup ( ) ; TypeBinding someReceiverType = this . delegateThis != null ? this . delegateThis . type : this . actualReceiverType ; TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , codegenField , someReceiverType , true ) ; codeStream . fieldAccess ( Opcodes . OPC_getfield , codegenField , constantPoolDeclaringClass ) ; } else { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { currentScope . problemReporter ( ) . needImplementation ( this ) ; } codeStream . generateEmulationForField ( codegenField ) ; generateReceiver ( codeStream ) ; codeStream . dup ( ) ; codeStream . generateEmulatedReadAccessForField ( codegenField ) ; } } break ; case Binding . LOCAL : LocalVariableBinding localBinding = ( LocalVariableBinding ) this . binding ; Constant assignConstant ; switch ( localBinding . type . id ) { case T_JavaLangString : codeStream . generateStringConcatenationAppend ( currentScope , this , expression ) ; if ( valueRequired ) { codeStream . dup ( ) ; } codeStream . store ( localBinding , false ) ; return ; case T_int : assignConstant = expression . constant ; if ( localBinding . resolvedPosition == - <NUM_LIT:1> ) { if ( valueRequired ) { localBinding . useFlag = LocalVariableBinding . USED ; throw new AbortMethod ( CodeStream . RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE , null ) ; } else if ( assignConstant == Constant . NotAConstant ) { expression . generateCode ( currentScope , codeStream , false ) ; } return ; } if ( ( assignConstant != Constant . NotAConstant ) && ( assignConstant . typeID ( ) != TypeIds . T_float ) && ( assignConstant . typeID ( ) != TypeIds . T_double ) ) { switch ( operator ) { case PLUS : int increment = assignConstant . intValue ( ) ; if ( increment != ( short ) increment ) break ; codeStream . iinc ( localBinding . resolvedPosition , increment ) ; if ( valueRequired ) { codeStream . load ( localBinding ) ; } return ; case MINUS : increment = - assignConstant . intValue ( ) ; if ( increment != ( short ) increment ) break ; codeStream . iinc ( localBinding . resolvedPosition , increment ) ; if ( valueRequired ) { codeStream . load ( localBinding ) ; } return ; } } default : if ( localBinding . resolvedPosition == - <NUM_LIT:1> ) { assignConstant = expression . constant ; if ( valueRequired ) { localBinding . useFlag = LocalVariableBinding . USED ; throw new AbortMethod ( CodeStream . RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE , null ) ; } else if ( assignConstant == Constant . NotAConstant ) { expression . generateCode ( currentScope , codeStream , false ) ; } return ; } codeStream . load ( localBinding ) ; } } int operationTypeID ; switch ( operationTypeID = ( this . implicitConversion & IMPLICIT_CONVERSION_MASK ) > > <NUM_LIT:4> ) { case T_JavaLangString : case T_JavaLangObject : case T_undefined : codeStream . generateStringConcatenationAppend ( currentScope , null , expression ) ; break ; default : codeStream . generateImplicitConversion ( this . implicitConversion ) ; if ( expression == IntLiteral . One ) { codeStream . generateConstant ( expression . constant , this . implicitConversion ) ; } else { expression . generateCode ( currentScope , codeStream , true ) ; } codeStream . sendOperator ( operator , operationTypeID ) ; codeStream . generateImplicitConversion ( assignmentImplicitConversion ) ; } switch ( this . bits & RestrictiveFlagMASK ) { case Binding . FIELD : FieldBinding codegenField = ( ( FieldBinding ) this . binding ) . original ( ) ; if ( codegenField . canBeSeenBy ( getReceiverType ( currentScope ) , this , currentScope ) ) { fieldStore ( currentScope , codeStream , codegenField , writeAccessor , this . actualReceiverType , this . delegateThis == null , valueRequired ) ; } else { if ( valueRequired ) { switch ( codegenField . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2_x2 ( ) ; break ; default : codeStream . dup_x2 ( ) ; break ; } } codeStream . generateEmulatedWriteAccessForField ( codegenField ) ; } return ; case Binding . LOCAL : LocalVariableBinding localBinding = ( LocalVariableBinding ) this . binding ; if ( valueRequired ) { switch ( localBinding . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2 ( ) ; break ; default : codeStream . dup ( ) ; break ; } } codeStream . store ( localBinding , false ) ; } } public void generatePostIncrement ( BlockScope currentScope , CodeStream codeStream , CompoundAssignment postIncrement , boolean valueRequired ) { switch ( this . bits & RestrictiveFlagMASK ) { case Binding . FIELD : FieldBinding codegenField = ( ( FieldBinding ) this . binding ) . original ( ) ; if ( codegenField . canBeSeenBy ( getReceiverType ( currentScope ) , this , currentScope ) ) { super . generatePostIncrement ( currentScope , codeStream , postIncrement , valueRequired ) ; } else { if ( codegenField . isStatic ( ) ) { codeStream . aconst_null ( ) ; } else { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { currentScope . problemReporter ( ) . needImplementation ( this ) ; } else { generateReceiver ( codeStream ) ; } } codeStream . generateEmulatedReadAccessForField ( codegenField ) ; if ( valueRequired ) { switch ( codegenField . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2 ( ) ; break ; default : codeStream . dup ( ) ; break ; } } codeStream . generateEmulationForField ( codegenField ) ; switch ( codegenField . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup_x2 ( ) ; codeStream . pop ( ) ; if ( codegenField . isStatic ( ) ) { codeStream . aconst_null ( ) ; } else { generateReceiver ( codeStream ) ; } codeStream . dup_x2 ( ) ; codeStream . pop ( ) ; break ; default : codeStream . dup_x1 ( ) ; codeStream . pop ( ) ; if ( codegenField . isStatic ( ) ) { codeStream . aconst_null ( ) ; } else { generateReceiver ( codeStream ) ; } codeStream . dup_x1 ( ) ; codeStream . pop ( ) ; break ; } codeStream . generateConstant ( postIncrement . expression . constant , this . implicitConversion ) ; codeStream . sendOperator ( postIncrement . operator , codegenField . type . id ) ; codeStream . generateImplicitConversion ( postIncrement . preAssignImplicitConversion ) ; codeStream . generateEmulatedWriteAccessForField ( codegenField ) ; } return ; case Binding . LOCAL : super . generatePostIncrement ( currentScope , codeStream , postIncrement , valueRequired ) ; } } public void generateReceiver ( CodeStream codeStream ) { codeStream . aload_0 ( ) ; if ( this . delegateThis != null ) { codeStream . fieldAccess ( Opcodes . OPC_getfield , this . delegateThis , null ) ; } } public TypeBinding getReceiverType ( BlockScope currentScope ) { Scope scope = currentScope . parent ; while ( true ) { switch ( scope . kind ) { case Scope . CLASS_SCOPE : return ( ( ClassScope ) scope ) . referenceContext . binding ; default : scope = scope . parent ; } } } public void manageSyntheticAccessIfNecessary ( BlockScope currentScope , FlowInfo flowInfo , boolean isReadAccess ) { if ( this . delegateThis == null ) { super . manageSyntheticAccessIfNecessary ( currentScope , flowInfo , isReadAccess ) ; return ; } if ( ( flowInfo . tagBits & FlowInfo . UNREACHABLE_OR_DEAD ) != <NUM_LIT:0> ) return ; if ( this . constant != Constant . NotAConstant ) return ; if ( this . binding instanceof ParameterizedFieldBinding ) { ParameterizedFieldBinding parameterizedField = ( ParameterizedFieldBinding ) this . binding ; FieldBinding codegenField = parameterizedField . originalField ; if ( ( codegenField . type . tagBits & TagBits . HasTypeVariable ) != <NUM_LIT:0> ) { this . genericCast = codegenField . type . genericCast ( currentScope . boxing ( parameterizedField . type ) ) ; } } } public TypeBinding reportError ( BlockScope scope ) { this . constant = Constant . NotAConstant ; if ( this . binding instanceof ProblemFieldBinding && ( ( ProblemFieldBinding ) this . binding ) . problemId ( ) == NotFound ) { if ( this . evaluationContext . declaringTypeName != null ) { this . delegateThis = scope . getField ( scope . enclosingSourceType ( ) , DELEGATE_THIS , this ) ; if ( this . delegateThis != null ) { this . actualReceiverType = this . delegateThis . type ; this . binding = scope . getField ( this . delegateThis . type , this . token , this ) ; if ( ! this . binding . isValidBinding ( ) ) { return super . reportError ( scope ) ; } return checkFieldAccess ( scope ) ; } } } if ( this . binding instanceof ProblemBinding && ( ( ProblemBinding ) this . binding ) . problemId ( ) == NotFound ) { if ( this . evaluationContext . declaringTypeName != null ) { this . delegateThis = scope . getField ( scope . enclosingSourceType ( ) , DELEGATE_THIS , this ) ; if ( this . delegateThis != null ) { this . actualReceiverType = this . delegateThis . type ; FieldBinding fieldBinding = scope . getField ( this . delegateThis . type , this . token , this ) ; if ( ! fieldBinding . isValidBinding ( ) ) { if ( ( ( ProblemFieldBinding ) fieldBinding ) . problemId ( ) == NotVisible ) { CodeSnippetScope localScope = new CodeSnippetScope ( scope ) ; this . binding = localScope . getFieldForCodeSnippet ( this . delegateThis . type , this . token , this ) ; return checkFieldAccess ( scope ) ; } else { return super . reportError ( scope ) ; } } this . binding = fieldBinding ; return checkFieldAccess ( scope ) ; } } } return super . reportError ( scope ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import java . util . Map ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ClassFile ; import org . eclipse . jdt . internal . compiler . Compiler ; import org . eclipse . jdt . internal . compiler . ICompilerRequestor ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; public class VariablesEvaluator extends Evaluator implements EvaluationConstants { VariablesEvaluator ( EvaluationContext context , INameEnvironment environment , Map options , IRequestor requestor , IProblemFactory problemFactory ) { super ( context , environment , options , requestor , problemFactory ) ; } protected void addEvaluationResultForCompilationProblem ( Map resultsByIDs , CategorizedProblem problem , char [ ] cuSource ) { char [ ] evaluationID = cuSource ; int evaluationType = EvaluationResult . T_INTERNAL ; int pbLine = problem . getSourceLineNumber ( ) ; int currentLine = <NUM_LIT:1> ; char [ ] packageName = getPackageName ( ) ; if ( packageName . length > <NUM_LIT:0> ) { if ( pbLine == <NUM_LIT:1> ) { evaluationID = packageName ; evaluationType = EvaluationResult . T_PACKAGE ; problem . setSourceLineNumber ( <NUM_LIT:1> ) ; problem . setSourceStart ( <NUM_LIT:0> ) ; problem . setSourceEnd ( evaluationID . length - <NUM_LIT:1> ) ; } currentLine ++ ; } char [ ] [ ] imports = this . context . imports ; if ( ( currentLine <= pbLine ) && ( pbLine < ( currentLine + imports . length ) ) ) { evaluationID = imports [ pbLine - currentLine ] ; evaluationType = EvaluationResult . T_IMPORT ; problem . setSourceLineNumber ( <NUM_LIT:1> ) ; problem . setSourceStart ( <NUM_LIT:0> ) ; problem . setSourceEnd ( evaluationID . length - <NUM_LIT:1> ) ; } currentLine += imports . length + <NUM_LIT:1> ; int varCount = this . context . variableCount ; if ( ( currentLine <= pbLine ) && ( pbLine < currentLine + varCount ) ) { GlobalVariable var = this . context . variables [ pbLine - currentLine ] ; evaluationID = var . getName ( ) ; evaluationType = EvaluationResult . T_VARIABLE ; int pbStart = problem . getSourceStart ( ) - var . declarationStart ; int pbEnd = problem . getSourceEnd ( ) - var . declarationStart ; int typeLength = var . getTypeName ( ) . length ; if ( ( <NUM_LIT:0> <= pbStart ) && ( pbEnd < typeLength ) ) { problem . setSourceLineNumber ( - <NUM_LIT:1> ) ; } else { pbStart -= typeLength + <NUM_LIT:1> ; pbEnd -= typeLength + <NUM_LIT:1> ; problem . setSourceLineNumber ( <NUM_LIT:0> ) ; } problem . setSourceStart ( pbStart ) ; problem . setSourceEnd ( pbEnd ) ; } currentLine = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < varCount ; i ++ ) { GlobalVariable var = this . context . variables [ i ] ; char [ ] initializer = var . getInitializer ( ) ; int initializerLength = initializer == null ? <NUM_LIT:0> : initializer . length ; if ( ( var . initializerStart <= problem . getSourceStart ( ) ) && ( problem . getSourceEnd ( ) < var . initializerStart + var . name . length ) ) { return ; } else if ( ( var . initExpressionStart <= problem . getSourceStart ( ) ) && ( problem . getSourceEnd ( ) < var . initExpressionStart + initializerLength ) ) { evaluationID = var . name ; evaluationType = EvaluationResult . T_VARIABLE ; problem . setSourceLineNumber ( pbLine - var . initializerLineStart + <NUM_LIT:1> ) ; problem . setSourceStart ( problem . getSourceStart ( ) - var . initExpressionStart ) ; problem . setSourceEnd ( problem . getSourceEnd ( ) - var . initExpressionStart ) ; break ; } } EvaluationResult result = ( EvaluationResult ) resultsByIDs . get ( evaluationID ) ; if ( result == null ) { resultsByIDs . put ( evaluationID , new EvaluationResult ( evaluationID , evaluationType , new CategorizedProblem [ ] { problem } ) ) ; } else { result . addProblem ( problem ) ; } } protected char [ ] getClassName ( ) { return CharOperation . concat ( EvaluationConstants . GLOBAL_VARS_CLASS_NAME_PREFIX , Integer . toString ( EvaluationContext . VAR_CLASS_COUNTER + <NUM_LIT:1> ) . toCharArray ( ) ) ; } Compiler getCompiler ( ICompilerRequestor compilerRequestor ) { Compiler compiler = super . getCompiler ( compilerRequestor ) ; IBinaryType binaryType = this . context . getRootCodeSnippetBinary ( ) ; if ( binaryType != null ) { compiler . lookupEnvironment . cacheBinaryType ( binaryType , null ) ; } VariablesInfo installedVars = this . context . installedVars ; if ( installedVars != null ) { ClassFile [ ] classFiles = installedVars . classFiles ; for ( int i = <NUM_LIT:0> ; i < classFiles . length ; i ++ ) { ClassFile classFile = classFiles [ i ] ; IBinaryType binary = null ; try { binary = new ClassFileReader ( classFile . getBytes ( ) , null ) ; } catch ( ClassFormatException e ) { e . printStackTrace ( ) ; } compiler . lookupEnvironment . cacheBinaryType ( binary , null ) ; } } return compiler ; } protected char [ ] getPackageName ( ) { return this . context . packageName ; } protected char [ ] getSource ( ) { StringBuffer buffer = new StringBuffer ( ) ; int lineNumberOffset = <NUM_LIT:1> ; char [ ] packageName = getPackageName ( ) ; if ( packageName . length != <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( packageName ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( this . context . lineSeparator ) ; lineNumberOffset ++ ; } char [ ] [ ] imports = this . context . imports ; for ( int i = <NUM_LIT:0> ; i < imports . length ; i ++ ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( imports [ i ] ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( this . context . lineSeparator ) ; lineNumberOffset ++ ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( getClassName ( ) ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( PACKAGE_NAME ) ; buffer . append ( "<STR_LIT:.>" ) ; buffer . append ( ROOT_CLASS_NAME ) ; buffer . append ( "<STR_LIT>" ) . append ( this . context . lineSeparator ) ; lineNumberOffset ++ ; GlobalVariable [ ] vars = this . context . variables ; VariablesInfo installedVars = this . context . installedVars ; for ( int i = <NUM_LIT:0> ; i < this . context . variableCount ; i ++ ) { GlobalVariable var = vars [ i ] ; buffer . append ( "<STR_LIT>" ) ; var . declarationStart = buffer . length ( ) ; buffer . append ( var . typeName ) ; buffer . append ( "<STR_LIT:U+0020>" ) ; char [ ] varName = var . name ; buffer . append ( varName ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( this . context . lineSeparator ) ; lineNumberOffset ++ ; } buffer . append ( "<STR_LIT>" ) . append ( this . context . lineSeparator ) ; lineNumberOffset ++ ; for ( int i = <NUM_LIT:0> ; i < this . context . variableCount ; i ++ ) { GlobalVariable var = vars [ i ] ; char [ ] varName = var . name ; GlobalVariable installedVar = installedVars == null ? null : installedVars . varNamed ( varName ) ; if ( installedVar == null || ! CharOperation . equals ( installedVar . typeName , var . typeName ) ) { char [ ] initializer = var . initializer ; if ( initializer != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . context . lineSeparator ) ; lineNumberOffset ++ ; var . initializerLineStart = lineNumberOffset ; buffer . append ( "<STR_LIT>" ) ; var . initializerStart = buffer . length ( ) ; buffer . append ( varName ) ; buffer . append ( "<STR_LIT>" ) ; var . initExpressionStart = buffer . length ( ) ; buffer . append ( initializer ) ; lineNumberOffset += numberOfCRs ( initializer ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( this . context . lineSeparator ) ; buffer . append ( "<STR_LIT>" ) . append ( this . context . lineSeparator ) ; buffer . append ( "<STR_LIT>" ) . append ( this . context . lineSeparator ) ; buffer . append ( "<STR_LIT>" ) . append ( this . context . lineSeparator ) ; lineNumberOffset += <NUM_LIT:4> ; } } else { buffer . append ( "<STR_LIT>" ) ; buffer . append ( varName ) ; buffer . append ( "<STR_LIT>" ) ; char [ ] installedPackageName = installedVars . packageName ; if ( installedPackageName != null && installedPackageName . length != <NUM_LIT:0> ) { buffer . append ( installedPackageName ) ; buffer . append ( "<STR_LIT:.>" ) ; } buffer . append ( installedVars . className ) ; buffer . append ( "<STR_LIT:.>" ) ; buffer . append ( varName ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( this . context . lineSeparator ) ; lineNumberOffset ++ ; } } buffer . append ( "<STR_LIT>" ) . append ( this . context . lineSeparator ) ; buffer . append ( '<CHAR_LIT:}>' ) . append ( this . context . lineSeparator ) ; int length = buffer . length ( ) ; char [ ] result = new char [ length ] ; buffer . getChars ( <NUM_LIT:0> , length , result , <NUM_LIT:0> ) ; return result ; } private int numberOfCRs ( char [ ] source ) { int numberOfCRs = <NUM_LIT:0> ; boolean lastWasCR = false ; for ( int i = <NUM_LIT:0> ; i < source . length ; i ++ ) { char currentChar = source [ i ] ; switch ( currentChar ) { case '<STR_LIT>' : lastWasCR = true ; numberOfCRs ++ ; break ; case '<STR_LIT:\n>' : if ( ! lastWasCR ) numberOfCRs ++ ; lastWasCR = false ; break ; default : lastWasCR = false ; } } return numberOfCRs ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . internal . compiler . ClassFile ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . ConstantPool ; import org . eclipse . jdt . internal . compiler . codegen . StackMapFrameCodeStream ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . SourceTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . lookup . TypeVariableBinding ; import org . eclipse . jdt . internal . compiler . util . Util ; public class CodeSnippetClassFile extends ClassFile { public CodeSnippetClassFile ( org . eclipse . jdt . internal . compiler . lookup . SourceTypeBinding aType , org . eclipse . jdt . internal . compiler . ClassFile enclosingClassFile , boolean creatingProblemType ) { this . referenceBinding = aType ; initByteArrays ( ) ; this . header [ this . headerOffset ++ ] = ( byte ) ( <NUM_LIT> > > <NUM_LIT:24> ) ; this . header [ this . headerOffset ++ ] = ( byte ) ( <NUM_LIT> > > <NUM_LIT:16> ) ; this . header [ this . headerOffset ++ ] = ( byte ) ( <NUM_LIT> > > <NUM_LIT:8> ) ; this . header [ this . headerOffset ++ ] = ( byte ) ( <NUM_LIT> > > <NUM_LIT:0> ) ; long targetVersion = this . targetJDK = this . referenceBinding . scope . compilerOptions ( ) . targetJDK ; this . header [ this . headerOffset ++ ] = ( byte ) ( targetVersion > > <NUM_LIT:8> ) ; this . header [ this . headerOffset ++ ] = ( byte ) ( targetVersion > > <NUM_LIT:0> ) ; this . header [ this . headerOffset ++ ] = ( byte ) ( targetVersion > > <NUM_LIT:24> ) ; this . header [ this . headerOffset ++ ] = ( byte ) ( targetVersion > > <NUM_LIT:16> ) ; this . constantPoolOffset = this . headerOffset ; this . headerOffset += <NUM_LIT:2> ; this . constantPool = new ConstantPool ( this ) ; int accessFlags = aType . getAccessFlags ( ) ; if ( ! aType . isInterface ( ) ) { accessFlags |= ClassFileConstants . AccSuper ; } if ( aType . isNestedType ( ) ) { if ( aType . isStatic ( ) ) { accessFlags &= ~ ClassFileConstants . AccStatic ; } if ( aType . isPrivate ( ) ) { accessFlags &= ~ ( ClassFileConstants . AccPrivate | ClassFileConstants . AccPublic ) ; } if ( aType . isProtected ( ) ) { accessFlags &= ~ ClassFileConstants . AccProtected ; accessFlags |= ClassFileConstants . AccPublic ; } } accessFlags &= ~ ClassFileConstants . AccStrictfp ; this . enclosingClassFile = enclosingClassFile ; this . contents [ this . contentsOffset ++ ] = ( byte ) ( accessFlags > > <NUM_LIT:8> ) ; this . contents [ this . contentsOffset ++ ] = ( byte ) accessFlags ; int classNameIndex = this . constantPool . literalIndexForType ( aType ) ; this . contents [ this . contentsOffset ++ ] = ( byte ) ( classNameIndex > > <NUM_LIT:8> ) ; this . contents [ this . contentsOffset ++ ] = ( byte ) classNameIndex ; int superclassNameIndex ; if ( aType . isInterface ( ) ) { superclassNameIndex = this . constantPool . literalIndexForType ( ConstantPool . JavaLangObjectConstantPoolName ) ; } else { superclassNameIndex = ( aType . superclass == null ? <NUM_LIT:0> : this . constantPool . literalIndexForType ( aType . superclass ) ) ; } this . contents [ this . contentsOffset ++ ] = ( byte ) ( superclassNameIndex > > <NUM_LIT:8> ) ; this . contents [ this . contentsOffset ++ ] = ( byte ) superclassNameIndex ; ReferenceBinding [ ] superInterfacesBinding = aType . superInterfaces ( ) ; int interfacesCount = superInterfacesBinding . length ; this . contents [ this . contentsOffset ++ ] = ( byte ) ( interfacesCount > > <NUM_LIT:8> ) ; this . contents [ this . contentsOffset ++ ] = ( byte ) interfacesCount ; for ( int i = <NUM_LIT:0> ; i < interfacesCount ; i ++ ) { int interfaceIndex = this . constantPool . literalIndexForType ( superInterfacesBinding [ i ] ) ; this . contents [ this . contentsOffset ++ ] = ( byte ) ( interfaceIndex > > <NUM_LIT:8> ) ; this . contents [ this . contentsOffset ++ ] = ( byte ) interfaceIndex ; } this . produceAttributes = this . referenceBinding . scope . compilerOptions ( ) . produceDebugAttributes ; this . creatingProblemType = creatingProblemType ; if ( this . targetJDK >= ClassFileConstants . JDK1_6 ) { this . codeStream = new StackMapFrameCodeStream ( this ) ; this . produceAttributes |= ClassFileConstants . ATTR_STACK_MAP_TABLE ; } else if ( this . targetJDK == ClassFileConstants . CLDC_1_1 ) { this . targetJDK = ClassFileConstants . JDK1_1 ; this . produceAttributes |= ClassFileConstants . ATTR_STACK_MAP ; this . codeStream = new StackMapFrameCodeStream ( this ) ; } else { this . codeStream = new CodeStream ( this ) ; } this . codeStream . maxFieldCount = aType . scope . outerMostClassScope ( ) . referenceType ( ) . maxFieldCount ; } public static void createProblemType ( TypeDeclaration typeDeclaration , CompilationResult unitResult ) { SourceTypeBinding typeBinding = typeDeclaration . binding ; ClassFile classFile = new CodeSnippetClassFile ( typeBinding , null , true ) ; if ( typeBinding . hasMemberTypes ( ) ) { ReferenceBinding [ ] members = typeBinding . memberTypes ; for ( int i = <NUM_LIT:0> , l = members . length ; i < l ; i ++ ) classFile . recordInnerClasses ( members [ i ] ) ; } if ( typeBinding . isNestedType ( ) ) { classFile . recordInnerClasses ( typeBinding ) ; } TypeVariableBinding [ ] typeVariables = typeBinding . typeVariables ( ) ; for ( int i = <NUM_LIT:0> , max = typeVariables . length ; i < max ; i ++ ) { TypeVariableBinding typeVariableBinding = typeVariables [ i ] ; if ( ( typeVariableBinding . tagBits & TagBits . ContainsNestedTypeReferences ) != <NUM_LIT:0> ) { Util . recordNestedType ( classFile , typeVariableBinding ) ; } } FieldBinding [ ] fields = typeBinding . fields ( ) ; if ( ( fields != null ) && ( fields != Binding . NO_FIELDS ) ) { classFile . addFieldInfos ( ) ; } else { classFile . contents [ classFile . contentsOffset ++ ] = <NUM_LIT:0> ; classFile . contents [ classFile . contentsOffset ++ ] = <NUM_LIT:0> ; } classFile . setForMethodInfos ( ) ; int problemsLength ; CategorizedProblem [ ] problems = unitResult . getErrors ( ) ; if ( problems == null ) { problems = new CategorizedProblem [ <NUM_LIT:0> ] ; } CategorizedProblem [ ] problemsCopy = new CategorizedProblem [ problemsLength = problems . length ] ; System . arraycopy ( problems , <NUM_LIT:0> , problemsCopy , <NUM_LIT:0> , problemsLength ) ; AbstractMethodDeclaration [ ] methodDecls = typeDeclaration . methods ; if ( methodDecls != null ) { if ( typeBinding . isInterface ( ) ) { classFile . addProblemClinit ( problemsCopy ) ; for ( int i = <NUM_LIT:0> , length = methodDecls . length ; i < length ; i ++ ) { AbstractMethodDeclaration methodDecl = methodDecls [ i ] ; MethodBinding method = methodDecl . binding ; if ( method == null || method . isConstructor ( ) ) continue ; method . modifiers = ClassFileConstants . AccPublic | ClassFileConstants . AccAbstract ; classFile . addAbstractMethod ( methodDecl , method ) ; } } else { for ( int i = <NUM_LIT:0> , length = methodDecls . length ; i < length ; i ++ ) { AbstractMethodDeclaration methodDecl = methodDecls [ i ] ; MethodBinding method = methodDecl . binding ; if ( method == null ) continue ; if ( method . isConstructor ( ) ) { classFile . addProblemConstructor ( methodDecl , method , problemsCopy ) ; } else if ( method . isAbstract ( ) ) { classFile . addAbstractMethod ( methodDecl , method ) ; } else { classFile . addProblemMethod ( methodDecl , method , problemsCopy ) ; } } } classFile . addDefaultAbstractMethods ( ) ; } if ( typeDeclaration . memberTypes != null ) { for ( int i = <NUM_LIT:0> , max = typeDeclaration . memberTypes . length ; i < max ; i ++ ) { TypeDeclaration memberType = typeDeclaration . memberTypes [ i ] ; if ( memberType . binding != null ) { ClassFile . createProblemType ( memberType , unitResult ) ; } } } classFile . addAttributes ( ) ; unitResult . record ( typeBinding . constantPoolName ( ) , classFile ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Iterator ; import java . util . Map ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ClassFile ; 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 . IProblemFactory ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class Evaluator { EvaluationContext context ; INameEnvironment environment ; Map options ; IRequestor requestor ; IProblemFactory problemFactory ; Evaluator ( EvaluationContext context , INameEnvironment environment , Map options , IRequestor requestor , IProblemFactory problemFactory ) { this . context = context ; this . environment = environment ; this . options = options ; this . requestor = requestor ; this . problemFactory = problemFactory ; } protected abstract void addEvaluationResultForCompilationProblem ( Map resultsByIDs , CategorizedProblem problem , char [ ] cuSource ) ; protected EvaluationResult [ ] evaluationResultsForCompilationProblems ( CompilationResult result , char [ ] cuSource ) { CategorizedProblem [ ] problems = result . getAllProblems ( ) ; HashMap resultsByIDs = new HashMap ( <NUM_LIT:5> ) ; for ( int i = <NUM_LIT:0> ; i < problems . length ; i ++ ) { addEvaluationResultForCompilationProblem ( resultsByIDs , problems [ i ] , cuSource ) ; } int size = resultsByIDs . size ( ) ; EvaluationResult [ ] evalResults = new EvaluationResult [ size ] ; Iterator results = resultsByIDs . values ( ) . iterator ( ) ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { evalResults [ i ] = ( EvaluationResult ) results . next ( ) ; } return evalResults ; } ClassFile [ ] getClasses ( ) { final char [ ] source = getSource ( ) ; final ArrayList classDefinitions = new ArrayList ( ) ; class CompilerRequestor implements ICompilerRequestor { boolean hasErrors = false ; public void acceptResult ( CompilationResult result ) { if ( result . hasProblems ( ) ) { EvaluationResult [ ] evalResults = evaluationResultsForCompilationProblems ( result , source ) ; for ( int i = <NUM_LIT:0> ; i < evalResults . length ; i ++ ) { EvaluationResult evalResult = evalResults [ i ] ; CategorizedProblem [ ] problems = evalResult . getProblems ( ) ; for ( int j = <NUM_LIT:0> ; j < problems . length ; j ++ ) { Evaluator . this . requestor . acceptProblem ( problems [ j ] , evalResult . getEvaluationID ( ) , evalResult . getEvaluationType ( ) ) ; } } } if ( result . hasErrors ( ) ) { this . hasErrors = true ; } else { ClassFile [ ] classFiles = result . getClassFiles ( ) ; for ( int i = <NUM_LIT:0> ; i < classFiles . length ; i ++ ) { ClassFile classFile = classFiles [ i ] ; classDefinitions . add ( classFile ) ; } } } } CompilerRequestor compilerRequestor = new CompilerRequestor ( ) ; Compiler compiler = getCompiler ( compilerRequestor ) ; compiler . compile ( new ICompilationUnit [ ] { new ICompilationUnit ( ) { public char [ ] getFileName ( ) { return CharOperation . concat ( Evaluator . this . getClassName ( ) , Util . defaultJavaExtension ( ) . toCharArray ( ) ) ; } public char [ ] getContents ( ) { return source ; } public char [ ] getMainTypeName ( ) { return Evaluator . this . getClassName ( ) ; } public char [ ] [ ] getPackageName ( ) { return null ; } } } ) ; if ( compilerRequestor . hasErrors ) { return null ; } else { ClassFile [ ] result = new ClassFile [ classDefinitions . size ( ) ] ; classDefinitions . toArray ( result ) ; return result ; } } protected abstract char [ ] getClassName ( ) ; Compiler getCompiler ( ICompilerRequestor compilerRequestor ) { CompilerOptions compilerOptions = new CompilerOptions ( this . options ) ; compilerOptions . performMethodsFullRecovery = true ; compilerOptions . performStatementsRecovery = true ; return new Compiler ( this . environment , DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , compilerOptions , compilerRequestor , this . problemFactory ) ; } protected abstract char [ ] getSource ( ) ; } </s>
<s> package org . eclipse . jdt . internal . eval ; import java . util . Map ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ClassFile ; 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 . IProblemFactory ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; public class CodeSnippetEvaluator extends Evaluator implements EvaluationConstants { static final boolean DEVELOPMENT_MODE = false ; char [ ] codeSnippet ; CodeSnippetToCuMapper mapper ; CodeSnippetEvaluator ( char [ ] codeSnippet , EvaluationContext context , INameEnvironment environment , Map options , IRequestor requestor , IProblemFactory problemFactory ) { super ( context , environment , options , requestor , problemFactory ) ; this . codeSnippet = codeSnippet ; } protected void addEvaluationResultForCompilationProblem ( Map resultsByIDs , CategorizedProblem problem , char [ ] cuSource ) { CodeSnippetToCuMapper sourceMapper = getMapper ( ) ; int pbLineNumber = problem . getSourceLineNumber ( ) ; int evaluationType = sourceMapper . getEvaluationType ( pbLineNumber ) ; char [ ] evaluationID = null ; switch ( evaluationType ) { case EvaluationResult . T_PACKAGE : evaluationID = this . context . packageName ; problem . setSourceLineNumber ( <NUM_LIT:1> ) ; problem . setSourceStart ( <NUM_LIT:0> ) ; problem . setSourceEnd ( evaluationID . length - <NUM_LIT:1> ) ; break ; case EvaluationResult . T_IMPORT : evaluationID = sourceMapper . getImport ( pbLineNumber ) ; problem . setSourceLineNumber ( <NUM_LIT:1> ) ; problem . setSourceStart ( <NUM_LIT:0> ) ; problem . setSourceEnd ( evaluationID . length - <NUM_LIT:1> ) ; break ; case EvaluationResult . T_CODE_SNIPPET : evaluationID = this . codeSnippet ; problem . setSourceLineNumber ( pbLineNumber - this . mapper . lineNumberOffset ) ; problem . setSourceStart ( problem . getSourceStart ( ) - this . mapper . startPosOffset ) ; problem . setSourceEnd ( problem . getSourceEnd ( ) - this . mapper . startPosOffset ) ; break ; case EvaluationResult . T_INTERNAL : evaluationID = cuSource ; break ; } EvaluationResult result = ( EvaluationResult ) resultsByIDs . get ( evaluationID ) ; if ( result == null ) { resultsByIDs . put ( evaluationID , new EvaluationResult ( evaluationID , evaluationType , new CategorizedProblem [ ] { problem } ) ) ; } else { result . addProblem ( problem ) ; } } protected char [ ] getClassName ( ) { return CharOperation . concat ( CODE_SNIPPET_CLASS_NAME_PREFIX , Integer . toString ( EvaluationContext . CODE_SNIPPET_COUNTER + <NUM_LIT:1> ) . toCharArray ( ) ) ; } Compiler getCompiler ( ICompilerRequestor compilerRequestor ) { Compiler compiler = null ; if ( ! DEVELOPMENT_MODE ) { CompilerOptions compilerOptions = new CompilerOptions ( this . options ) ; compilerOptions . performMethodsFullRecovery = true ; compilerOptions . performStatementsRecovery = true ; compiler = new CodeSnippetCompiler ( this . environment , DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , compilerOptions , compilerRequestor , this . problemFactory , this . context , getMapper ( ) . startPosOffset , getMapper ( ) . startPosOffset + this . codeSnippet . length - <NUM_LIT:1> ) ; ( ( CodeSnippetParser ) compiler . parser ) . lineSeparatorLength = this . context . lineSeparator . length ( ) ; IBinaryType binary = this . context . getRootCodeSnippetBinary ( ) ; if ( binary != null ) { compiler . lookupEnvironment . cacheBinaryType ( binary , null ) ; } VariablesInfo installedVars = this . context . installedVars ; if ( installedVars != null ) { ClassFile [ ] globalClassFiles = installedVars . classFiles ; for ( int i = <NUM_LIT:0> ; i < globalClassFiles . length ; i ++ ) { ClassFileReader binaryType = null ; try { binaryType = new ClassFileReader ( globalClassFiles [ i ] . getBytes ( ) , null ) ; } catch ( ClassFormatException e ) { e . printStackTrace ( ) ; } compiler . lookupEnvironment . cacheBinaryType ( binaryType , null ) ; } } } else { CompilerOptions compilerOptions = new CompilerOptions ( this . options ) ; compilerOptions . performMethodsFullRecovery = true ; compilerOptions . performStatementsRecovery = true ; compiler = new Compiler ( getWrapperEnvironment ( ) , DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , compilerOptions , compilerRequestor , this . problemFactory ) ; } return compiler ; } private CodeSnippetToCuMapper getMapper ( ) { if ( this . mapper == null ) { char [ ] varClassName = null ; VariablesInfo installedVars = this . context . installedVars ; if ( installedVars != null ) { char [ ] superPackageName = installedVars . packageName ; if ( superPackageName != null && superPackageName . length != <NUM_LIT:0> ) { varClassName = CharOperation . concat ( superPackageName , installedVars . className , '<CHAR_LIT:.>' ) ; } else { varClassName = installedVars . className ; } } this . mapper = new CodeSnippetToCuMapper ( this . codeSnippet , this . context . packageName , this . context . imports , getClassName ( ) , varClassName , this . context . localVariableNames , this . context . localVariableTypeNames , this . context . localVariableModifiers , this . context . declaringTypeName , this . context . lineSeparator , CompilerOptions . versionToJdkLevel ( this . options . get ( JavaCore . COMPILER_COMPLIANCE ) ) ) ; } return this . mapper ; } protected char [ ] getSource ( ) { return getMapper ( ) . cuSource ; } private INameEnvironment getWrapperEnvironment ( ) { return new CodeSnippetEnvironment ( this . environment , this . context ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CharOperation ; public interface EvaluationConstants { public static final char [ ] CODE_SNIPPET_CLASS_NAME_PREFIX = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] GLOBAL_VARS_CLASS_NAME_PREFIX = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] PACKAGE_NAME = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] CODE_SNIPPET_NAME = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] ROOT_CLASS_NAME = "<STR_LIT>" . toCharArray ( ) ; public static final String ROOT_FULL_CLASS_NAME = new String ( PACKAGE_NAME ) + "<STR_LIT:.>" + new String ( ROOT_CLASS_NAME ) ; public static final char [ ] SETRESULT_SELECTOR = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] SETRESULT_ARGUMENTS = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] [ ] ROOT_COMPOUND_NAME = CharOperation . arrayConcat ( CharOperation . splitOn ( '<CHAR_LIT:.>' , PACKAGE_NAME ) , ROOT_CLASS_NAME ) ; public static final String RUN_METHOD = "<STR_LIT>" ; public static final String RESULT_VALUE_FIELD = "<STR_LIT>" ; public static final String RESULT_TYPE_FIELD = "<STR_LIT>" ; public static final char [ ] LOCAL_VAR_PREFIX = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] DELEGATE_THIS = "<STR_LIT>" . toCharArray ( ) ; } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ReturnStatement ; import org . eclipse . jdt . internal . compiler . ast . TryStatement ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . Opcodes ; import org . eclipse . jdt . internal . compiler . flow . FlowContext ; import org . eclipse . jdt . internal . compiler . flow . FlowInfo ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . InvocationSite ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CodeSnippetReturnStatement extends ReturnStatement implements InvocationSite , EvaluationConstants { MethodBinding setResultMethod ; public CodeSnippetReturnStatement ( Expression expr , int s , int e ) { super ( expr , s , e ) ; } public FlowInfo analyseCode ( BlockScope currentScope , FlowContext flowContext , FlowInfo flowInfo ) { FlowInfo info = super . analyseCode ( currentScope , flowContext , flowInfo ) ; this . expression . bits &= ~ IsReturnedValue ; return info ; } public void generateReturnBytecode ( CodeStream codeStream ) { codeStream . return_ ( ) ; } public void generateStoreSaveValueIfNecessary ( CodeStream codeStream ) { codeStream . aload_0 ( ) ; if ( this . expression == null || this . expression . resolvedType == TypeBinding . VOID ) { codeStream . aconst_null ( ) ; codeStream . generateClassLiteralAccessForType ( TypeBinding . VOID , null ) ; } else { int valueTypeID = this . expression . resolvedType . id ; if ( valueTypeID == T_long || valueTypeID == T_double ) { codeStream . dup_x2 ( ) ; codeStream . pop ( ) ; } else { codeStream . swap ( ) ; } if ( this . expression . resolvedType . isBaseType ( ) && this . expression . resolvedType != TypeBinding . NULL ) { codeStream . generateBoxingConversion ( this . expression . resolvedType . id ) ; } codeStream . generateClassLiteralAccessForType ( this . expression . resolvedType , null ) ; } codeStream . invoke ( Opcodes . OPC_invokevirtual , this . setResultMethod , null ) ; } public TypeBinding [ ] genericTypeArguments ( ) { return null ; } public boolean isSuperAccess ( ) { return false ; } public boolean isTypeAccess ( ) { return false ; } public boolean needValue ( ) { return true ; } public void prepareSaveValueLocation ( TryStatement targetTryStatement ) { } public void resolve ( BlockScope scope ) { if ( this . expression != null ) { if ( this . expression . resolveType ( scope ) != null ) { TypeBinding javaLangClass = scope . getJavaLangClass ( ) ; if ( ! javaLangClass . isValidBinding ( ) ) { scope . problemReporter ( ) . codeSnippetMissingClass ( "<STR_LIT>" , this . sourceStart , this . sourceEnd ) ; return ; } TypeBinding javaLangObject = scope . getJavaLangObject ( ) ; if ( ! javaLangObject . isValidBinding ( ) ) { scope . problemReporter ( ) . codeSnippetMissingClass ( "<STR_LIT>" , this . sourceStart , this . sourceEnd ) ; return ; } TypeBinding [ ] argumentTypes = new TypeBinding [ ] { javaLangObject , javaLangClass } ; this . setResultMethod = scope . getImplicitMethod ( SETRESULT_SELECTOR , argumentTypes , this ) ; if ( ! this . setResultMethod . isValidBinding ( ) ) { scope . problemReporter ( ) . codeSnippetMissingMethod ( ROOT_FULL_CLASS_NAME , new String ( SETRESULT_SELECTOR ) , new String ( SETRESULT_ARGUMENTS ) , this . sourceStart , this . sourceEnd ) ; return ; } if ( this . expression . constant != Constant . NotAConstant ) { this . expression . implicitConversion = this . expression . constant . typeID ( ) << <NUM_LIT:4> ; } } } } public void setActualReceiverType ( ReferenceBinding receiverType ) { } public void setDepth ( int depth ) { } public void setFieldIndex ( int depth ) { } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . CompletionContext ; import org . eclipse . jdt . core . CompletionProposal ; import org . eclipse . jdt . core . CompletionRequestor ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . codeassist . ISelectionRequestor ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; class CodeSnippetToCuMapper implements EvaluationConstants { public char [ ] cuSource ; public int lineNumberOffset = <NUM_LIT:0> ; public int startPosOffset = <NUM_LIT:0> ; char [ ] codeSnippet ; char [ ] snippetPackageName ; char [ ] [ ] snippetImports ; char [ ] snippetClassName ; char [ ] snippetVarClassName ; char [ ] snippetDeclaringTypeName ; char [ ] [ ] localVarNames ; char [ ] [ ] localVarTypeNames ; long complianceVersion ; public CodeSnippetToCuMapper ( char [ ] codeSnippet , char [ ] packageName , char [ ] [ ] imports , char [ ] className , char [ ] varClassName , char [ ] [ ] localVarNames , char [ ] [ ] localVarTypeNames , int [ ] localVarModifiers , char [ ] declaringTypeName , String lineSeparator , long complianceVersion ) { this . codeSnippet = codeSnippet ; this . snippetPackageName = packageName ; this . snippetImports = imports ; this . snippetClassName = className ; this . snippetVarClassName = varClassName ; this . localVarNames = localVarNames ; this . localVarTypeNames = localVarTypeNames ; this . snippetDeclaringTypeName = declaringTypeName ; this . complianceVersion = complianceVersion ; buildCUSource ( lineSeparator ) ; } private void buildCUSource ( String lineSeparator ) { StringBuffer buffer = new StringBuffer ( ) ; if ( this . snippetPackageName != null && this . snippetPackageName . length != <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . snippetPackageName ) ; buffer . append ( "<STR_LIT:;>" ) . append ( lineSeparator ) ; this . lineNumberOffset ++ ; } char [ ] [ ] imports = this . snippetImports ; for ( int i = <NUM_LIT:0> ; i < imports . length ; i ++ ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( imports [ i ] ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( lineSeparator ) ; this . lineNumberOffset ++ ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . snippetClassName ) ; if ( this . snippetVarClassName != null ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . snippetVarClassName ) ; } else { buffer . append ( "<STR_LIT>" ) ; buffer . append ( PACKAGE_NAME ) ; buffer . append ( "<STR_LIT:.>" ) ; buffer . append ( ROOT_CLASS_NAME ) ; } buffer . append ( "<STR_LIT>" ) . append ( lineSeparator ) ; this . lineNumberOffset ++ ; if ( this . snippetDeclaringTypeName != null ) { buffer . append ( "<STR_LIT:U+0020U+0020>" ) ; buffer . append ( this . snippetDeclaringTypeName ) ; buffer . append ( "<STR_LIT:U+0020>" ) ; buffer . append ( DELEGATE_THIS ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( lineSeparator ) ; this . lineNumberOffset ++ ; } if ( this . localVarNames != null ) { for ( int i = <NUM_LIT:0> , max = this . localVarNames . length ; i < max ; i ++ ) { buffer . append ( "<STR_LIT:U+0020U+0020U+0020U+0020>" ) ; buffer . append ( this . localVarTypeNames [ i ] ) ; buffer . append ( "<STR_LIT:U+0020>" ) ; buffer . append ( LOCAL_VAR_PREFIX ) ; buffer . append ( this . localVarNames [ i ] ) ; buffer . append ( '<CHAR_LIT:;>' ) . append ( lineSeparator ) ; this . lineNumberOffset ++ ; } } if ( this . complianceVersion >= ClassFileConstants . JDK1_5 ) { buffer . append ( "<STR_LIT>" ) ; } buffer . append ( "<STR_LIT>" ) . append ( lineSeparator ) ; this . lineNumberOffset ++ ; this . startPosOffset = buffer . length ( ) ; buffer . append ( this . codeSnippet ) ; buffer . append ( lineSeparator ) . append ( '<CHAR_LIT:}>' ) . append ( lineSeparator ) ; buffer . append ( '<CHAR_LIT:}>' ) . append ( lineSeparator ) ; int length = buffer . length ( ) ; this . cuSource = new char [ length ] ; buffer . getChars ( <NUM_LIT:0> , length , this . cuSource , <NUM_LIT:0> ) ; } public CompletionRequestor getCompletionRequestor ( final CompletionRequestor originalRequestor ) { return new CompletionRequestor ( ) { public void accept ( CompletionProposal proposal ) { switch ( proposal . getKind ( ) ) { case CompletionProposal . TYPE_REF : int flags = proposal . getFlags ( ) ; if ( ( flags & Flags . AccEnum ) == <NUM_LIT:0> && ( flags & Flags . AccInterface ) == <NUM_LIT:0> ) { char [ ] packageName = proposal . getDeclarationSignature ( ) ; char [ ] className = Signature . getSignatureSimpleName ( proposal . getSignature ( ) ) ; if ( CharOperation . equals ( packageName , CodeSnippetToCuMapper . this . snippetPackageName ) && ( CharOperation . equals ( className , CodeSnippetToCuMapper . this . snippetClassName ) || CharOperation . equals ( className , CodeSnippetToCuMapper . this . snippetVarClassName ) ) ) return ; if ( CharOperation . equals ( packageName , PACKAGE_NAME ) && CharOperation . equals ( className , ROOT_CLASS_NAME ) ) return ; } break ; case CompletionProposal . METHOD_REF : case CompletionProposal . METHOD_DECLARATION : case CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER : char [ ] declaringTypePackageName = Signature . getSignatureQualifier ( proposal . getDeclarationSignature ( ) ) ; char [ ] declaringTypeName = Signature . getSignatureSimpleName ( proposal . getDeclarationSignature ( ) ) ; if ( CharOperation . equals ( declaringTypePackageName , CodeSnippetToCuMapper . this . snippetPackageName ) && CharOperation . equals ( declaringTypeName , CodeSnippetToCuMapper . this . snippetClassName ) ) return ; if ( CharOperation . equals ( declaringTypePackageName , PACKAGE_NAME ) && CharOperation . equals ( declaringTypeName , ROOT_CLASS_NAME ) ) return ; break ; } originalRequestor . accept ( proposal ) ; } public void completionFailure ( IProblem problem ) { problem . setSourceStart ( problem . getSourceStart ( ) - CodeSnippetToCuMapper . this . startPosOffset ) ; problem . setSourceEnd ( problem . getSourceEnd ( ) - CodeSnippetToCuMapper . this . startPosOffset ) ; problem . setSourceLineNumber ( problem . getSourceLineNumber ( ) - CodeSnippetToCuMapper . this . lineNumberOffset ) ; originalRequestor . completionFailure ( problem ) ; } public void acceptContext ( CompletionContext context ) { originalRequestor . acceptContext ( context ) ; } public void beginReporting ( ) { originalRequestor . beginReporting ( ) ; } public void endReporting ( ) { originalRequestor . endReporting ( ) ; } public boolean isIgnored ( int completionProposalKind ) { return originalRequestor . isIgnored ( completionProposalKind ) ; } public void setIgnored ( int completionProposalKind , boolean ignore ) { originalRequestor . setIgnored ( completionProposalKind , ignore ) ; } public boolean isAllowingRequiredProposals ( int mainKind , int requiredKind ) { return originalRequestor . isAllowingRequiredProposals ( mainKind , requiredKind ) ; } public void setAllowsRequiredProposals ( int mainKind , int requiredKind , boolean allow ) { originalRequestor . setAllowsRequiredProposals ( mainKind , requiredKind , allow ) ; } } ; } public char [ ] getCUSource ( String lineSeparator ) { if ( this . cuSource == null ) { buildCUSource ( lineSeparator ) ; } return this . cuSource ; } public int getEvaluationType ( int lineNumber ) { int currentLine = <NUM_LIT:1> ; if ( this . snippetPackageName != null && this . snippetPackageName . length != <NUM_LIT:0> ) { if ( lineNumber == <NUM_LIT:1> ) { return EvaluationResult . T_PACKAGE ; } currentLine ++ ; } char [ ] [ ] imports = this . snippetImports ; if ( ( currentLine <= lineNumber ) && ( lineNumber < ( currentLine + imports . length ) ) ) { return EvaluationResult . T_IMPORT ; } currentLine += imports . length + <NUM_LIT:1> ; currentLine += ( this . snippetDeclaringTypeName == null ? <NUM_LIT:0> : <NUM_LIT:1> ) + ( this . localVarNames == null ? <NUM_LIT:0> : this . localVarNames . length ) ; if ( currentLine > lineNumber ) { return EvaluationResult . T_INTERNAL ; } currentLine ++ ; if ( currentLine >= this . lineNumberOffset ) { return EvaluationResult . T_CODE_SNIPPET ; } return EvaluationResult . T_INTERNAL ; } public char [ ] getImport ( int lineNumber ) { int importStartLine = this . lineNumberOffset - <NUM_LIT:1> - this . snippetImports . length ; return this . snippetImports [ lineNumber - importStartLine ] ; } public ISelectionRequestor getSelectionRequestor ( final ISelectionRequestor originalRequestor ) { return new ISelectionRequestor ( ) { public void acceptType ( char [ ] packageName , char [ ] typeName , int modifiers , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { originalRequestor . acceptType ( packageName , typeName , modifiers , isDeclaration , uniqueKey , start , end ) ; } public void acceptError ( CategorizedProblem error ) { error . setSourceLineNumber ( error . getSourceLineNumber ( ) - CodeSnippetToCuMapper . this . lineNumberOffset ) ; error . setSourceStart ( error . getSourceStart ( ) - CodeSnippetToCuMapper . this . startPosOffset ) ; error . setSourceEnd ( error . getSourceEnd ( ) - CodeSnippetToCuMapper . this . startPosOffset ) ; originalRequestor . acceptError ( error ) ; } public void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] name , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { originalRequestor . acceptField ( declaringTypePackageName , declaringTypeName , name , isDeclaration , uniqueKey , start , end ) ; } public void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , String enclosingDeclaringTypeSignature , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , String [ ] parameterSignatures , char [ ] [ ] typeParameterNames , char [ ] [ ] [ ] typeParameterBoundNames , boolean isConstructor , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { originalRequestor . acceptMethod ( declaringTypePackageName , declaringTypeName , enclosingDeclaringTypeSignature , selector , parameterPackageNames , parameterTypeNames , parameterSignatures , typeParameterNames , typeParameterBoundNames , isConstructor , isDeclaration , uniqueKey , start , end ) ; } public void acceptPackage ( char [ ] packageName ) { originalRequestor . acceptPackage ( packageName ) ; } public void acceptTypeParameter ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] typeParameterName , boolean isDeclaration , int start , int end ) { originalRequestor . acceptTypeParameter ( declaringTypePackageName , declaringTypeName , typeParameterName , isDeclaration , start , end ) ; } public void acceptMethodTypeParameter ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , int selectorStart , int selectorEnd , char [ ] typeParameterName , boolean isDeclaration , int start , int end ) { originalRequestor . acceptMethodTypeParameter ( declaringTypePackageName , declaringTypeName , selector , selectorStart , selectorEnd , typeParameterName , isDeclaration , start , end ) ; } } ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ClassFile ; public class VariablesInfo { GlobalVariable [ ] variables ; int variableCount ; char [ ] packageName ; char [ ] className ; ClassFile [ ] classFiles ; public VariablesInfo ( char [ ] packageName , char [ ] className , ClassFile [ ] classFiles , GlobalVariable [ ] variables , int variableCount ) { this . packageName = packageName ; this . className = className ; this . classFiles = classFiles ; this . variables = variables ; this . variableCount = variableCount ; } int indexOf ( GlobalVariable var ) { for ( int i = <NUM_LIT:0> ; i < this . variableCount ; i ++ ) { if ( var . equals ( this . variables [ i ] ) ) { return i ; } } return - <NUM_LIT:1> ; } GlobalVariable varNamed ( char [ ] name ) { GlobalVariable [ ] vars = this . variables ; for ( int i = <NUM_LIT:0> ; i < this . variableCount ; i ++ ) { GlobalVariable var = vars [ i ] ; if ( CharOperation . equals ( name , var . name ) ) { return var ; } } return null ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; public class CodeSnippetParser extends Parser implements EvaluationConstants { int codeSnippetStart , codeSnippetEnd ; EvaluationContext evaluationContext ; boolean hasRecoveredOnExpression ; int lastStatement = - <NUM_LIT:1> ; int lineSeparatorLength ; int problemCountBeforeRecovery = <NUM_LIT:0> ; public CodeSnippetParser ( ProblemReporter problemReporter , EvaluationContext evaluationContext , boolean optimizeStringLiterals , int codeSnippetStart , int codeSnippetEnd ) { super ( problemReporter , optimizeStringLiterals ) ; this . codeSnippetStart = codeSnippetStart ; this . codeSnippetEnd = codeSnippetEnd ; this . evaluationContext = evaluationContext ; this . reportOnlyOneSyntaxError = true ; this . javadocParser . checkDocComment = false ; } protected void classInstanceCreation ( boolean alwaysQualified ) { AllocationExpression alloc ; int length ; if ( ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) == <NUM_LIT:1> ) && ( this . astStack [ this . astPtr ] == null ) ) { this . astPtr -- ; if ( alwaysQualified ) { alloc = new QualifiedAllocationExpression ( ) ; } else { alloc = new CodeSnippetAllocationExpression ( this . evaluationContext ) ; } alloc . sourceEnd = this . endPosition ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , alloc . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } alloc . type = getTypeReference ( <NUM_LIT:0> ) ; checkForDiamond ( alloc . type ) ; alloc . sourceStart = this . intStack [ this . intPtr -- ] ; pushOnExpressionStack ( alloc ) ; } else { dispatchDeclarationInto ( length ) ; TypeDeclaration anonymousTypeDeclaration = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; anonymousTypeDeclaration . declarationSourceEnd = this . endStatementPosition ; if ( anonymousTypeDeclaration . allocation != null ) { anonymousTypeDeclaration . allocation . sourceEnd = this . endStatementPosition ; } this . astPtr -- ; this . astLengthPtr -- ; } } protected void consumeClassInstanceCreationExpressionWithTypeArguments ( ) { AllocationExpression alloc ; int length ; if ( ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) == <NUM_LIT:1> ) && ( this . astStack [ this . astPtr ] == null ) ) { this . astPtr -- ; alloc = new CodeSnippetAllocationExpression ( this . evaluationContext ) ; alloc . sourceEnd = this . endPosition ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , alloc . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } alloc . type = getTypeReference ( <NUM_LIT:0> ) ; length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , alloc . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; this . intPtr -- ; alloc . sourceStart = this . intStack [ this . intPtr -- ] ; pushOnExpressionStack ( alloc ) ; } else { dispatchDeclarationInto ( length ) ; TypeDeclaration anonymousTypeDeclaration = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; anonymousTypeDeclaration . declarationSourceEnd = this . endStatementPosition ; anonymousTypeDeclaration . bodyEnd = this . endStatementPosition ; if ( length == <NUM_LIT:0> && ! containsComment ( anonymousTypeDeclaration . bodyStart , anonymousTypeDeclaration . bodyEnd ) ) { anonymousTypeDeclaration . bits |= ASTNode . UndocumentedEmptyBlock ; } this . astPtr -- ; this . astLengthPtr -- ; QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration . allocation ; if ( allocationExpression != null ) { allocationExpression . sourceEnd = this . endStatementPosition ; length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , allocationExpression . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; allocationExpression . sourceStart = this . intStack [ this . intPtr -- ] ; } } } protected void consumeClassDeclaration ( ) { super . consumeClassDeclaration ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeClassHeaderName1 ( ) { TypeDeclaration typeDecl ; if ( this . nestedMethod [ this . nestedType ] == <NUM_LIT:0> ) { if ( this . nestedType != <NUM_LIT:0> ) { typeDecl = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; typeDecl . bits |= ASTNode . IsMemberType ; } else { typeDecl = new CodeSnippetTypeDeclaration ( this . compilationUnit . compilationResult ) ; } } else { typeDecl = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; typeDecl . bits |= ASTNode . IsLocalType ; markEnclosingMemberWithLocalType ( ) ; blockReal ( ) ; } long pos = this . identifierPositionStack [ this . identifierPtr ] ; typeDecl . sourceEnd = ( int ) pos ; typeDecl . sourceStart = ( int ) ( pos > > > <NUM_LIT:32> ) ; typeDecl . name = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; typeDecl . declarationSourceStart = this . intStack [ this . intPtr -- ] ; this . intPtr -- ; typeDecl . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiers = this . intStack [ this . intPtr -- ] ; if ( typeDecl . modifiersSourceStart >= <NUM_LIT:0> ) { typeDecl . declarationSourceStart = typeDecl . modifiersSourceStart ; } typeDecl . bodyStart = typeDecl . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( typeDecl ) ; this . listLength = <NUM_LIT:0> ; if ( this . currentElement != null ) { this . lastCheckPoint = typeDecl . bodyStart ; this . currentElement = this . currentElement . add ( typeDecl , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; } typeDecl . javadoc = this . javadoc ; this . javadoc = null ; } protected void consumeEmptyStatement ( ) { super . consumeEmptyStatement ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeEnhancedForStatement ( ) { super . consumeEnhancedForStatement ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeExpressionStatement ( ) { super . consumeExpressionStatement ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeFieldAccess ( boolean isSuperAccess ) { FieldReference fr = new CodeSnippetFieldReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] , this . evaluationContext ) ; this . identifierLengthPtr -- ; if ( isSuperAccess ) { fr . sourceStart = this . intStack [ this . intPtr -- ] ; problemReporter ( ) . codeSnippetMissingClass ( null , <NUM_LIT:0> , <NUM_LIT:0> ) ; fr . receiver = new CodeSnippetSuperReference ( fr . sourceStart , this . endPosition ) ; pushOnExpressionStack ( fr ) ; } else { if ( ( fr . receiver = this . expressionStack [ this . expressionPtr ] ) . isThis ( ) ) { fr . sourceStart = fr . receiver . sourceStart ; } this . expressionStack [ this . expressionPtr ] = fr ; } } protected void consumeInternalCompilationUnit ( ) { } protected void consumeInternalCompilationUnitWithTypes ( ) { int length ; if ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) != <NUM_LIT:0> ) { this . compilationUnit . types = new TypeDeclaration [ length ] ; this . astPtr -= length ; System . arraycopy ( this . astStack , this . astPtr + <NUM_LIT:1> , this . compilationUnit . types , <NUM_LIT:0> , length ) ; } } protected void consumeLocalVariableDeclarationStatement ( ) { super . consumeLocalVariableDeclarationStatement ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeMethodDeclaration ( boolean isNotAbstract ) { super . consumeMethodDeclaration ( isNotAbstract ) ; MethodDeclaration methodDecl = ( MethodDeclaration ) this . astStack [ this . astPtr ] ; if ( isTopLevelType ( ) ) { int last = methodDecl . statements == null ? - <NUM_LIT:1> : methodDecl . statements . length - <NUM_LIT:1> ; if ( last >= <NUM_LIT:0> && methodDecl . statements [ last ] instanceof Expression ) { Expression lastExpression = ( Expression ) methodDecl . statements [ last ] ; methodDecl . statements [ last ] = new CodeSnippetReturnStatement ( lastExpression , lastExpression . sourceStart , lastExpression . sourceEnd ) ; } } int start = methodDecl . bodyStart - <NUM_LIT:1> , end = start ; long position = ( ( long ) start << <NUM_LIT:32> ) + end ; long [ ] positions = new long [ ] { position } ; if ( this . evaluationContext . localVariableNames != null ) { int varCount = this . evaluationContext . localVariableNames . length ; Statement [ ] newStatements = new Statement [ varCount + <NUM_LIT:1> ] ; for ( int i = <NUM_LIT:0> ; i < varCount ; i ++ ) { char [ ] trimmedTypeName = this . evaluationContext . localVariableTypeNames [ i ] ; int nameEnd = CharOperation . indexOf ( '<CHAR_LIT:[>' , trimmedTypeName ) ; if ( nameEnd >= <NUM_LIT:0> ) { trimmedTypeName = CharOperation . subarray ( trimmedTypeName , <NUM_LIT:0> , nameEnd ) ; } nameEnd = CharOperation . indexOf ( '<CHAR_LIT:U+0020>' , trimmedTypeName ) ; if ( nameEnd >= <NUM_LIT:0> ) { trimmedTypeName = CharOperation . subarray ( trimmedTypeName , <NUM_LIT:0> , nameEnd ) ; } TypeReference typeReference ; if ( CharOperation . indexOf ( '<CHAR_LIT:.>' , trimmedTypeName ) == - <NUM_LIT:1> ) { typeReference = new SingleTypeReference ( trimmedTypeName , position ) ; } else { typeReference = new QualifiedTypeReference ( CharOperation . splitOn ( '<CHAR_LIT:.>' , trimmedTypeName ) , positions ) ; } int dimCount = CharOperation . occurencesOf ( '<CHAR_LIT:[>' , this . evaluationContext . localVariableTypeNames [ i ] ) ; if ( dimCount > <NUM_LIT:0> ) { typeReference = copyDims ( typeReference , dimCount ) ; } NameReference init = new SingleNameReference ( CharOperation . concat ( LOCAL_VAR_PREFIX , this . evaluationContext . localVariableNames [ i ] ) , position ) ; LocalDeclaration declaration = new LocalDeclaration ( this . evaluationContext . localVariableNames [ i ] , start , end ) ; declaration . initialization = init ; declaration . type = typeReference ; declaration . modifiers = this . evaluationContext . localVariableModifiers [ i ] ; newStatements [ i ] = declaration ; } TryStatement tryStatement = new TryStatement ( ) ; Block tryBlock = new Block ( methodDecl . explicitDeclarations ) ; tryBlock . sourceStart = start ; tryBlock . sourceEnd = end ; tryBlock . statements = methodDecl . statements ; tryStatement . tryBlock = tryBlock ; Block finallyBlock = new Block ( <NUM_LIT:0> ) ; finallyBlock . sourceStart = start ; finallyBlock . sourceEnd = end ; finallyBlock . statements = new Statement [ varCount ] ; for ( int i = <NUM_LIT:0> ; i < varCount ; i ++ ) { SingleNameReference nameRef = new SingleNameReference ( this . evaluationContext . localVariableNames [ i ] , position ) ; finallyBlock . statements [ i ] = new Assignment ( new SingleNameReference ( CharOperation . concat ( LOCAL_VAR_PREFIX , this . evaluationContext . localVariableNames [ i ] ) , position ) , nameRef , nameRef . sourceEnd ) ; } tryStatement . finallyBlock = finallyBlock ; newStatements [ varCount ] = tryStatement ; methodDecl . statements = newStatements ; } } protected void consumeMethodInvocationName ( ) { if ( this . scanner . startPosition >= this . codeSnippetStart && this . scanner . startPosition <= this . codeSnippetEnd + <NUM_LIT:1> + this . lineSeparatorLength && isTopLevelType ( ) ) { MessageSend m = newMessageSend ( ) ; m . sourceEnd = this . rParenPos ; m . sourceStart = ( int ) ( ( m . nameSourcePosition = this . identifierPositionStack [ this . identifierPtr ] ) > > > <NUM_LIT:32> ) ; m . selector = this . identifierStack [ this . identifierPtr -- ] ; if ( this . identifierLengthStack [ this . identifierLengthPtr ] == <NUM_LIT:1> ) { m . receiver = new CodeSnippetThisReference ( <NUM_LIT:0> , <NUM_LIT:0> , this . evaluationContext , true ) ; this . identifierLengthPtr -- ; } else { this . identifierLengthStack [ this . identifierLengthPtr ] -- ; m . receiver = getUnspecifiedReference ( ) ; m . sourceStart = m . receiver . sourceStart ; } pushOnExpressionStack ( m ) ; } else { super . consumeMethodInvocationName ( ) ; } } protected void consumeMethodInvocationNameWithTypeArguments ( ) { if ( this . scanner . startPosition >= this . codeSnippetStart && this . scanner . startPosition <= this . codeSnippetEnd + <NUM_LIT:1> + this . lineSeparatorLength && isTopLevelType ( ) ) { MessageSend m = newMessageSendWithTypeArguments ( ) ; m . sourceEnd = this . rParenPos ; m . sourceStart = ( int ) ( ( m . nameSourcePosition = this . identifierPositionStack [ this . identifierPtr ] ) > > > <NUM_LIT:32> ) ; m . selector = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , m . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; this . intPtr -- ; m . receiver = getUnspecifiedReference ( ) ; m . sourceStart = m . receiver . sourceStart ; pushOnExpressionStack ( m ) ; } else { super . consumeMethodInvocationNameWithTypeArguments ( ) ; } } protected void consumeMethodInvocationSuper ( ) { MessageSend m = newMessageSend ( ) ; m . sourceStart = this . intStack [ this . intPtr -- ] ; m . sourceEnd = this . rParenPos ; m . nameSourcePosition = this . identifierPositionStack [ this . identifierPtr ] ; m . selector = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; m . receiver = new CodeSnippetSuperReference ( m . sourceStart , this . endPosition ) ; pushOnExpressionStack ( m ) ; } protected void consumeMethodInvocationSuperWithTypeArguments ( ) { MessageSend m = newMessageSendWithTypeArguments ( ) ; this . intPtr -- ; m . sourceEnd = this . rParenPos ; m . nameSourcePosition = this . identifierPositionStack [ this . identifierPtr ] ; m . selector = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , m . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; m . sourceStart = this . intStack [ this . intPtr -- ] ; m . receiver = new CodeSnippetSuperReference ( m . sourceStart , this . endPosition ) ; pushOnExpressionStack ( m ) ; } protected void consumePrimaryNoNewArrayThis ( ) { if ( this . scanner . startPosition >= this . codeSnippetStart && this . scanner . startPosition <= this . codeSnippetEnd + <NUM_LIT:1> + this . lineSeparatorLength && isTopLevelType ( ) ) { pushOnExpressionStack ( new CodeSnippetThisReference ( this . intStack [ this . intPtr -- ] , this . endPosition , this . evaluationContext , false ) ) ; } else { super . consumePrimaryNoNewArrayThis ( ) ; } } protected void consumeStatementBreak ( ) { super . consumeStatementBreak ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementBreakWithLabel ( ) { super . consumeStatementBreakWithLabel ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementCatch ( ) { super . consumeStatementCatch ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementContinue ( ) { super . consumeStatementContinue ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementContinueWithLabel ( ) { super . consumeStatementContinueWithLabel ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementDo ( ) { super . consumeStatementDo ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementFor ( ) { super . consumeStatementFor ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementIfNoElse ( ) { super . consumeStatementIfNoElse ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementIfWithElse ( ) { super . consumeStatementIfWithElse ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementLabel ( ) { super . consumeStatementLabel ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementReturn ( ) { if ( ( this . hasRecoveredOnExpression || ( this . scanner . startPosition >= this . codeSnippetStart && this . scanner . startPosition <= this . codeSnippetEnd + <NUM_LIT:1> + this . lineSeparatorLength ) ) && this . expressionLengthStack [ this . expressionLengthPtr ] != <NUM_LIT:0> && isTopLevelType ( ) ) { this . expressionLengthPtr -- ; Expression expression = this . expressionStack [ this . expressionPtr -- ] ; pushOnAstStack ( new CodeSnippetReturnStatement ( expression , expression . sourceStart , expression . sourceEnd ) ) ; } else { super . consumeStatementReturn ( ) ; } recordLastStatementIfNeeded ( ) ; } protected void consumeStatementSwitch ( ) { super . consumeStatementSwitch ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementSynchronized ( ) { super . consumeStatementSynchronized ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementThrow ( ) { super . consumeStatementThrow ( ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementTry ( boolean arg_0 , boolean arg_1 ) { super . consumeStatementTry ( arg_0 , arg_1 ) ; recordLastStatementIfNeeded ( ) ; } protected void consumeStatementWhile ( ) { super . consumeStatementWhile ( ) ; recordLastStatementIfNeeded ( ) ; } protected CompilationUnitDeclaration endParse ( int act ) { if ( this . hasRecoveredOnExpression ) { CompilationResult unitResult = this . compilationUnit . compilationResult ; if ( act != ERROR_ACTION ) { for ( int i = <NUM_LIT:0> ; i < unitResult . problemCount ; i ++ ) { unitResult . problems [ i ] = null ; } unitResult . problemCount = <NUM_LIT:0> ; if ( this . referenceContext instanceof AbstractMethodDeclaration ) { ( ( AbstractMethodDeclaration ) this . referenceContext ) . ignoreFurtherInvestigation = false ; } if ( this . referenceContext instanceof CompilationUnitDeclaration ) { ( ( CompilationUnitDeclaration ) this . referenceContext ) . ignoreFurtherInvestigation = false ; } consumeStatementReturn ( ) ; int fieldsCount = ( this . evaluationContext . localVariableNames == null ? <NUM_LIT:0> : this . evaluationContext . localVariableNames . length ) + ( this . evaluationContext . declaringTypeName == null ? <NUM_LIT:0> : <NUM_LIT:1> ) ; if ( this . astPtr > ( this . diet ? <NUM_LIT:0> : <NUM_LIT:2> + fieldsCount ) ) { consumeBlockStatements ( ) ; } consumeMethodBody ( ) ; if ( ! this . diet ) { consumeMethodDeclaration ( true ) ; if ( fieldsCount > <NUM_LIT:0> ) { consumeClassBodyDeclarations ( ) ; } consumeClassBodyDeclarationsopt ( ) ; consumeClassDeclaration ( ) ; consumeInternalCompilationUnitWithTypes ( ) ; consumeCompilationUnit ( ) ; } this . lastAct = ACCEPT_ACTION ; } else { int maxRegularPos = <NUM_LIT:0> , problemCount = unitResult . problemCount ; for ( int i = <NUM_LIT:0> ; i < this . problemCountBeforeRecovery ; i ++ ) { if ( unitResult . problems [ i ] . getID ( ) == IProblem . UnmatchedBracket ) continue ; int start = unitResult . problems [ i ] . getSourceStart ( ) ; if ( start > maxRegularPos && start <= this . codeSnippetEnd ) { maxRegularPos = start ; } } int maxRecoveryPos = <NUM_LIT:0> ; for ( int i = this . problemCountBeforeRecovery ; i < problemCount ; i ++ ) { if ( unitResult . problems [ i ] . getID ( ) == IProblem . UnmatchedBracket ) continue ; int start = unitResult . problems [ i ] . getSourceStart ( ) ; if ( start > maxRecoveryPos && start <= this . codeSnippetEnd ) { maxRecoveryPos = start ; } } if ( maxRecoveryPos > maxRegularPos ) { System . arraycopy ( unitResult . problems , this . problemCountBeforeRecovery , unitResult . problems , <NUM_LIT:0> , problemCount - this . problemCountBeforeRecovery ) ; unitResult . problemCount -= this . problemCountBeforeRecovery ; } else { unitResult . problemCount -= ( problemCount - this . problemCountBeforeRecovery ) ; } for ( int i = unitResult . problemCount ; i < problemCount ; i ++ ) { unitResult . problems [ i ] = null ; } } } return super . endParse ( act ) ; } protected NameReference getUnspecifiedReference ( ) { if ( this . scanner . startPosition >= this . codeSnippetStart && this . scanner . startPosition <= this . codeSnippetEnd + <NUM_LIT:1> + this . lineSeparatorLength ) { int length ; NameReference ref ; if ( ( length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ) == <NUM_LIT:1> ) { ref = new CodeSnippetSingleNameReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] , this . evaluationContext ) ; } else { char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ref = new CodeSnippetQualifiedNameReference ( tokens , positions , ( int ) ( this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ this . identifierPtr + length ] , this . evaluationContext ) ; } return ref ; } else { return super . getUnspecifiedReference ( ) ; } } protected NameReference getUnspecifiedReferenceOptimized ( ) { if ( this . scanner . startPosition >= this . codeSnippetStart && this . scanner . startPosition <= this . codeSnippetEnd + <NUM_LIT:1> + this . lineSeparatorLength ) { int length ; NameReference ref ; if ( ( length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ) == <NUM_LIT:1> ) { ref = new CodeSnippetSingleNameReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] , this . evaluationContext ) ; ref . bits &= ~ ASTNode . RestrictiveFlagMASK ; ref . bits |= Binding . LOCAL | Binding . FIELD ; return ref ; } char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ref = new CodeSnippetQualifiedNameReference ( tokens , positions , ( int ) ( this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ this . identifierPtr + length ] , this . evaluationContext ) ; ref . bits &= ~ ASTNode . RestrictiveFlagMASK ; ref . bits |= Binding . LOCAL | Binding . FIELD ; return ref ; } else { return super . getUnspecifiedReferenceOptimized ( ) ; } } protected void ignoreExpressionAssignment ( ) { super . ignoreExpressionAssignment ( ) ; recordLastStatementIfNeeded ( ) ; } private boolean isTopLevelType ( ) { return this . nestedType == ( this . diet ? <NUM_LIT:0> : <NUM_LIT:1> ) ; } protected MessageSend newMessageSend ( ) { CodeSnippetMessageSend m = new CodeSnippetMessageSend ( this . evaluationContext ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , m . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } return m ; } protected MessageSend newMessageSendWithTypeArguments ( ) { CodeSnippetMessageSend m = new CodeSnippetMessageSend ( this . evaluationContext ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , m . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } return m ; } private void recordLastStatementIfNeeded ( ) { if ( ( isTopLevelType ( ) ) && ( this . scanner . startPosition <= this . codeSnippetEnd + this . lineSeparatorLength ) ) { this . lastStatement = this . scanner . startPosition ; } } protected void reportSyntaxErrors ( boolean isDietParse , int oldFirstToken ) { if ( ! isDietParse ) { this . scanner . initialPosition = this . lastStatement ; this . scanner . eofPosition = this . codeSnippetEnd + <NUM_LIT:1> ; oldFirstToken = TokenNameTWIDDLE ; } super . reportSyntaxErrors ( isDietParse , oldFirstToken ) ; } protected boolean resumeOnSyntaxError ( ) { if ( this . diet || this . hasRecoveredOnExpression ) { return false ; } this . problemCountBeforeRecovery = this . compilationUnit . compilationResult . problemCount ; if ( this . lastStatement < <NUM_LIT:0> ) { this . lastStatement = this . codeSnippetStart ; } this . scanner . initialPosition = this . lastStatement ; this . scanner . startPosition = this . lastStatement ; this . scanner . currentPosition = this . lastStatement ; this . scanner . eofPosition = this . codeSnippetEnd < Integer . MAX_VALUE ? this . codeSnippetEnd + <NUM_LIT:1> : this . codeSnippetEnd ; this . scanner . commentPtr = - <NUM_LIT:1> ; this . expressionPtr = - <NUM_LIT:1> ; this . identifierPtr = - <NUM_LIT:1> ; this . identifierLengthPtr = - <NUM_LIT:1> ; goForExpression ( ) ; this . hasRecoveredOnExpression = true ; this . hasReportedError = false ; this . hasError = false ; return true ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; public class EvaluationResult { static final CategorizedProblem [ ] NO_PROBLEMS = new CategorizedProblem [ <NUM_LIT:0> ] ; char [ ] evaluationID ; int evaluationType ; CategorizedProblem [ ] problems ; char [ ] displayString ; char [ ] typeName ; public static final int T_VARIABLE = <NUM_LIT:1> ; public static final int T_CODE_SNIPPET = <NUM_LIT:2> ; public static final int T_IMPORT = <NUM_LIT:3> ; public static final int T_PACKAGE = <NUM_LIT:4> ; public static final int T_INTERNAL = <NUM_LIT:5> ; public EvaluationResult ( char [ ] evaluationID , int evaluationType , char [ ] displayString , char [ ] typeName ) { this . evaluationID = evaluationID ; this . evaluationType = evaluationType ; this . displayString = displayString ; this . typeName = typeName ; this . problems = NO_PROBLEMS ; } public EvaluationResult ( char [ ] evaluationID , int evaluationType , CategorizedProblem [ ] problems ) { this . evaluationID = evaluationID ; this . evaluationType = evaluationType ; this . problems = problems ; } void addProblem ( CategorizedProblem problem ) { CategorizedProblem [ ] existingProblems = this . problems ; int existingLength = existingProblems . length ; this . problems = new CategorizedProblem [ existingLength + <NUM_LIT:1> ] ; System . arraycopy ( existingProblems , <NUM_LIT:0> , this . problems , <NUM_LIT:0> , existingLength ) ; this . problems [ existingLength ] = problem ; } public char [ ] getEvaluationID ( ) { return this . evaluationID ; } public int getEvaluationType ( ) { return this . evaluationType ; } public CategorizedProblem [ ] getProblems ( ) { return this . problems ; } public Object getValue ( ) { return null ; } public char [ ] getValueDisplayString ( ) { return this . displayString ; } public char [ ] getValueTypeName ( ) { return this . typeName ; } public boolean hasErrors ( ) { if ( this . problems == null ) { return false ; } else { for ( int i = <NUM_LIT:0> ; i < this . problems . length ; i ++ ) { if ( this . problems [ i ] . isError ( ) ) { return true ; } } return false ; } } public boolean hasProblems ( ) { return ( this . problems != null ) && ( this . problems . length != <NUM_LIT:0> ) ; } public boolean hasValue ( ) { return this . displayString != null ; } public boolean hasWarnings ( ) { if ( this . problems == null ) { return false ; } else { for ( int i = <NUM_LIT:0> ; i < this . problems . length ; i ++ ) { if ( this . problems [ i ] . isWarning ( ) ) { return true ; } } return false ; } } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; switch ( this . evaluationType ) { case T_CODE_SNIPPET : buffer . append ( "<STR_LIT>" ) ; break ; case T_IMPORT : buffer . append ( "<STR_LIT>" ) ; break ; case T_INTERNAL : buffer . append ( "<STR_LIT>" ) ; break ; case T_PACKAGE : buffer . append ( "<STR_LIT>" ) ; break ; case T_VARIABLE : buffer . append ( "<STR_LIT>" ) ; break ; } buffer . append ( "<STR_LIT::U+0020>" ) ; buffer . append ( this . evaluationID == null ? "<STR_LIT>" . toCharArray ( ) : this . evaluationID ) ; buffer . append ( "<STR_LIT:n>" ) ; if ( hasProblems ( ) ) { buffer . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . problems . length ; i ++ ) { buffer . append ( this . problems [ i ] . toString ( ) ) ; } } else { if ( hasValue ( ) ) { buffer . append ( "<STR_LIT:(>" ) ; buffer . append ( this . typeName ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . displayString ) ; } else { buffer . append ( "<STR_LIT>" ) ; } } return buffer . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . ArrayBinding ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . InvocationSite ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . PackageBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemMethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . lookup . VariableBinding ; public class CodeSnippetScope extends BlockScope { protected CodeSnippetScope ( int kind , Scope parent ) { super ( kind , parent ) ; } public CodeSnippetScope ( BlockScope parent ) { super ( parent ) ; } public CodeSnippetScope ( BlockScope parent , int variableCount ) { super ( parent , variableCount ) ; } public final boolean canBeSeenByForCodeSnippet ( FieldBinding fieldBinding , TypeBinding receiverType , InvocationSite invocationSite , Scope scope ) { if ( fieldBinding . isPublic ( ) ) return true ; ReferenceBinding invocationType = ( ReferenceBinding ) receiverType ; if ( invocationType == fieldBinding . declaringClass ) return true ; if ( fieldBinding . isProtected ( ) ) { if ( invocationType == fieldBinding . declaringClass ) return true ; if ( invocationType . fPackage == fieldBinding . declaringClass . fPackage ) return true ; if ( fieldBinding . declaringClass . isSuperclassOf ( invocationType ) ) { if ( invocationSite . isSuperAccess ( ) ) return true ; if ( receiverType instanceof ArrayBinding ) return false ; if ( invocationType . isSuperclassOf ( ( ReferenceBinding ) receiverType ) ) return true ; if ( fieldBinding . isStatic ( ) ) return true ; } return false ; } if ( fieldBinding . isPrivate ( ) ) { if ( receiverType != fieldBinding . declaringClass ) return false ; if ( invocationType != fieldBinding . declaringClass ) { ReferenceBinding outerInvocationType = invocationType ; ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } ReferenceBinding outerDeclaringClass = fieldBinding . declaringClass ; temp = outerDeclaringClass . enclosingType ( ) ; while ( temp != null ) { outerDeclaringClass = temp ; temp = temp . enclosingType ( ) ; } if ( outerInvocationType != outerDeclaringClass ) return false ; } return true ; } if ( invocationType . fPackage != fieldBinding . declaringClass . fPackage ) return false ; if ( receiverType instanceof ArrayBinding ) return false ; ReferenceBinding type = ( ReferenceBinding ) receiverType ; PackageBinding declaringPackage = fieldBinding . declaringClass . fPackage ; TypeBinding originalDeclaringClass = fieldBinding . declaringClass . original ( ) ; do { if ( type . isCapture ( ) ) { if ( originalDeclaringClass == type . erasure ( ) . original ( ) ) return true ; } else { if ( originalDeclaringClass == type . original ( ) ) return true ; } if ( declaringPackage != type . fPackage ) return false ; } while ( ( type = type . superclass ( ) ) != null ) ; return false ; } public final boolean canBeSeenByForCodeSnippet ( MethodBinding methodBinding , TypeBinding receiverType , InvocationSite invocationSite , Scope scope ) { if ( methodBinding . isPublic ( ) ) return true ; ReferenceBinding invocationType = ( ReferenceBinding ) receiverType ; if ( invocationType == methodBinding . declaringClass ) return true ; if ( methodBinding . isProtected ( ) ) { if ( invocationType == methodBinding . declaringClass ) return true ; if ( invocationType . fPackage == methodBinding . declaringClass . fPackage ) return true ; if ( methodBinding . declaringClass . isSuperclassOf ( invocationType ) ) { if ( invocationSite . isSuperAccess ( ) ) return true ; if ( receiverType instanceof ArrayBinding ) return false ; if ( invocationType . isSuperclassOf ( ( ReferenceBinding ) receiverType ) ) return true ; if ( methodBinding . isStatic ( ) ) return true ; } return false ; } if ( methodBinding . isPrivate ( ) ) { if ( receiverType != methodBinding . declaringClass ) return false ; if ( invocationType != methodBinding . declaringClass ) { ReferenceBinding outerInvocationType = invocationType ; ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } ReferenceBinding outerDeclaringClass = methodBinding . declaringClass ; temp = outerDeclaringClass . enclosingType ( ) ; while ( temp != null ) { outerDeclaringClass = temp ; temp = temp . enclosingType ( ) ; } if ( outerInvocationType != outerDeclaringClass ) return false ; } return true ; } if ( invocationType . fPackage != methodBinding . declaringClass . fPackage ) return false ; if ( receiverType instanceof ArrayBinding ) return false ; ReferenceBinding type = ( ReferenceBinding ) receiverType ; PackageBinding declaringPackage = methodBinding . declaringClass . fPackage ; TypeBinding originalDeclaringClass = methodBinding . declaringClass . original ( ) ; do { if ( type . isCapture ( ) ) { if ( originalDeclaringClass == type . erasure ( ) . original ( ) ) return true ; } else { if ( originalDeclaringClass == type . original ( ) ) return true ; } if ( declaringPackage != type . fPackage ) return false ; } while ( ( type = type . superclass ( ) ) != null ) ; return false ; } public final boolean canBeSeenByForCodeSnippet ( ReferenceBinding referenceBinding , ReferenceBinding receiverType ) { if ( referenceBinding . isPublic ( ) ) return true ; if ( receiverType == referenceBinding ) return true ; if ( referenceBinding . isProtected ( ) ) { return receiverType . fPackage == referenceBinding . fPackage || referenceBinding . isSuperclassOf ( receiverType ) || referenceBinding . enclosingType ( ) . isSuperclassOf ( receiverType ) ; } if ( referenceBinding . isPrivate ( ) ) { ReferenceBinding outerInvocationType = receiverType ; ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } ReferenceBinding outerDeclaringClass = referenceBinding ; temp = outerDeclaringClass . enclosingType ( ) ; while ( temp != null ) { outerDeclaringClass = temp ; temp = temp . enclosingType ( ) ; } return outerInvocationType == outerDeclaringClass ; } return receiverType . fPackage == referenceBinding . fPackage ; } public MethodBinding findExactMethod ( ReferenceBinding receiverType , char [ ] selector , TypeBinding [ ] argumentTypes , InvocationSite invocationSite ) { MethodBinding exactMethod = receiverType . getExactMethod ( selector , argumentTypes , null ) ; if ( exactMethod != null ) { if ( receiverType . isInterface ( ) || canBeSeenByForCodeSnippet ( exactMethod , receiverType , invocationSite , this ) ) return exactMethod ; } return null ; } public FieldBinding findFieldForCodeSnippet ( TypeBinding receiverType , char [ ] fieldName , InvocationSite invocationSite ) { if ( receiverType . isBaseType ( ) ) return null ; if ( receiverType . isArrayType ( ) ) { TypeBinding leafType = receiverType . leafComponentType ( ) ; if ( leafType instanceof ReferenceBinding ) if ( ! ( ( ReferenceBinding ) leafType ) . canBeSeenBy ( this ) ) { return new ProblemFieldBinding ( ( ReferenceBinding ) leafType , fieldName , ProblemReasons . ReceiverTypeNotVisible ) ; } if ( CharOperation . equals ( fieldName , TypeConstants . LENGTH ) ) return ArrayBinding . ArrayLength ; return null ; } ReferenceBinding currentType = ( ReferenceBinding ) receiverType ; if ( ! currentType . canBeSeenBy ( this ) ) return new ProblemFieldBinding ( currentType , fieldName , ProblemReasons . ReceiverTypeNotVisible ) ; FieldBinding field = currentType . getField ( fieldName , true ) ; if ( field != null ) { if ( canBeSeenByForCodeSnippet ( field , currentType , invocationSite , this ) ) return field ; else return new ProblemFieldBinding ( field , field . declaringClass , fieldName , ProblemReasons . NotVisible ) ; } ReferenceBinding [ ] [ ] interfacesToVisit = null ; int lastPosition = - <NUM_LIT:1> ; FieldBinding visibleField = null ; boolean keepLooking = true ; boolean notVisible = false ; while ( keepLooking ) { ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( interfacesToVisit == null ) interfacesToVisit = new ReferenceBinding [ <NUM_LIT:5> ] [ ] ; if ( ++ lastPosition == interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ lastPosition * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , lastPosition ) ; interfacesToVisit [ lastPosition ] = itsInterfaces ; } if ( ( currentType = currentType . superclass ( ) ) == null ) break ; if ( ( field = currentType . getField ( fieldName , true ) ) != null ) { keepLooking = false ; if ( canBeSeenByForCodeSnippet ( field , receiverType , invocationSite , this ) ) { if ( visibleField == null ) visibleField = field ; else return new ProblemFieldBinding ( visibleField , visibleField . declaringClass , fieldName , ProblemReasons . Ambiguous ) ; } else { notVisible = true ; } } } if ( interfacesToVisit != null ) { ProblemFieldBinding ambiguous = null ; org . eclipse . jdt . internal . compiler . util . SimpleSet interfacesSeen = new org . eclipse . jdt . internal . compiler . util . SimpleSet ( lastPosition * <NUM_LIT:2> ) ; done : for ( int i = <NUM_LIT:0> ; i <= lastPosition ; i ++ ) { ReferenceBinding [ ] interfaces = interfacesToVisit [ i ] ; for ( int j = <NUM_LIT:0> , length = interfaces . length ; j < length ; j ++ ) { ReferenceBinding anInterface = interfaces [ j ] ; if ( interfacesSeen . addIfNotIncluded ( anInterface ) == anInterface ) { if ( ( field = anInterface . getField ( fieldName , true ) ) != null ) { if ( visibleField == null ) { visibleField = field ; } else { ambiguous = new ProblemFieldBinding ( visibleField , visibleField . declaringClass , fieldName , ProblemReasons . Ambiguous ) ; break done ; } } else { ReferenceBinding [ ] itsInterfaces = anInterface . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( ++ lastPosition == interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ lastPosition * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , lastPosition ) ; interfacesToVisit [ lastPosition ] = itsInterfaces ; } } } } } if ( ambiguous != null ) return ambiguous ; } if ( visibleField != null ) return visibleField ; if ( notVisible ) return new ProblemFieldBinding ( currentType , fieldName , ProblemReasons . NotVisible ) ; return null ; } public MethodBinding findMethod ( ReferenceBinding receiverType , char [ ] selector , TypeBinding [ ] argumentTypes , InvocationSite invocationSite ) { MethodBinding methodBinding = super . findMethod ( receiverType , selector , argumentTypes , invocationSite ) ; if ( methodBinding != null && methodBinding . isValidBinding ( ) ) if ( ! canBeSeenByForCodeSnippet ( methodBinding , receiverType , invocationSite , this ) ) return new ProblemMethodBinding ( methodBinding , selector , argumentTypes , ProblemReasons . NotVisible ) ; return methodBinding ; } public MethodBinding findMethodForArray ( ArrayBinding receiverType , char [ ] selector , TypeBinding [ ] argumentTypes , InvocationSite invocationSite ) { ReferenceBinding object = getJavaLangObject ( ) ; MethodBinding methodBinding = object . getExactMethod ( selector , argumentTypes , null ) ; if ( methodBinding != null ) { if ( argumentTypes == Binding . NO_PARAMETERS && CharOperation . equals ( selector , TypeConstants . CLONE ) ) return new MethodBinding ( ( methodBinding . modifiers & ~ ClassFileConstants . AccProtected ) | ClassFileConstants . AccPublic , TypeConstants . CLONE , methodBinding . returnType , argumentTypes , null , object ) ; if ( canBeSeenByForCodeSnippet ( methodBinding , receiverType , invocationSite , this ) ) return methodBinding ; } methodBinding = findMethod ( object , selector , argumentTypes , invocationSite ) ; if ( methodBinding == null ) return new ProblemMethodBinding ( selector , argumentTypes , ProblemReasons . NotFound ) ; if ( methodBinding . isValidBinding ( ) ) { MethodBinding compatibleMethod = computeCompatibleMethod ( methodBinding , argumentTypes , invocationSite ) ; if ( compatibleMethod == null ) return new ProblemMethodBinding ( methodBinding , selector , argumentTypes , ProblemReasons . NotFound ) ; methodBinding = compatibleMethod ; if ( ! canBeSeenByForCodeSnippet ( methodBinding , receiverType , invocationSite , this ) ) return new ProblemMethodBinding ( methodBinding , selector , methodBinding . parameters , ProblemReasons . NotVisible ) ; } return methodBinding ; } public Binding getBinding ( char [ ] [ ] compoundName , int mask , InvocationSite invocationSite , ReferenceBinding receiverType ) { Binding binding = getBinding ( compoundName [ <NUM_LIT:0> ] , mask | Binding . TYPE | Binding . PACKAGE , invocationSite , true ) ; invocationSite . setFieldIndex ( <NUM_LIT:1> ) ; if ( ! binding . isValidBinding ( ) || binding instanceof VariableBinding ) return binding ; int length = compoundName . length ; int currentIndex = <NUM_LIT:1> ; foundType : if ( binding instanceof PackageBinding ) { PackageBinding packageBinding = ( PackageBinding ) binding ; while ( currentIndex < length ) { binding = packageBinding . getTypeOrPackage ( compoundName [ currentIndex ++ ] ) ; invocationSite . setFieldIndex ( currentIndex ) ; if ( binding == null ) { if ( currentIndex == length ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , null , ProblemReasons . NotFound ) ; else return new ProblemBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , ProblemReasons . NotFound ) ; } if ( binding instanceof ReferenceBinding ) { if ( ! binding . isValidBinding ( ) ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , ( ReferenceBinding ) ( ( ReferenceBinding ) binding ) . closestMatch ( ) , binding . problemId ( ) ) ; if ( ! this . canBeSeenByForCodeSnippet ( ( ReferenceBinding ) binding , receiverType ) ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , ( ReferenceBinding ) binding , ProblemReasons . NotVisible ) ; break foundType ; } packageBinding = ( PackageBinding ) binding ; } return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , null , ProblemReasons . NotFound ) ; } while ( currentIndex < length ) { ReferenceBinding typeBinding = ( ReferenceBinding ) binding ; char [ ] nextName = compoundName [ currentIndex ++ ] ; invocationSite . setFieldIndex ( currentIndex ) ; if ( ( binding = findFieldForCodeSnippet ( typeBinding , nextName , invocationSite ) ) != null ) { if ( ! binding . isValidBinding ( ) ) { return new ProblemFieldBinding ( ( FieldBinding ) binding , ( ( FieldBinding ) binding ) . declaringClass , CharOperation . concatWith ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , '<CHAR_LIT:.>' ) , binding . problemId ( ) ) ; } break ; } if ( ( binding = findMemberType ( nextName , typeBinding ) ) == null ) return new ProblemBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , typeBinding , ProblemReasons . NotFound ) ; if ( ! binding . isValidBinding ( ) ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , ( ReferenceBinding ) ( ( ReferenceBinding ) binding ) . closestMatch ( ) , binding . problemId ( ) ) ; } if ( ( mask & Binding . FIELD ) != <NUM_LIT:0> && ( binding instanceof FieldBinding ) ) { FieldBinding field = ( FieldBinding ) binding ; if ( ! field . isStatic ( ) ) { return new ProblemFieldBinding ( field , field . declaringClass , CharOperation . concatWith ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , '<CHAR_LIT:.>' ) , ProblemReasons . NonStaticReferenceInStaticContext ) ; } return binding ; } if ( ( mask & Binding . TYPE ) != <NUM_LIT:0> && ( binding instanceof ReferenceBinding ) ) { return binding ; } return new ProblemBinding ( CharOperation . subarray ( compoundName , <NUM_LIT:0> , currentIndex ) , ProblemReasons . NotFound ) ; } public MethodBinding getConstructor ( ReferenceBinding receiverType , TypeBinding [ ] argumentTypes , InvocationSite invocationSite ) { MethodBinding methodBinding = receiverType . getExactConstructor ( argumentTypes ) ; if ( methodBinding != null ) { if ( canBeSeenByForCodeSnippet ( methodBinding , receiverType , invocationSite , this ) ) { return methodBinding ; } } MethodBinding [ ] methods = receiverType . getMethods ( TypeConstants . INIT ) ; if ( methods == Binding . NO_METHODS ) { return new ProblemMethodBinding ( TypeConstants . INIT , argumentTypes , ProblemReasons . NotFound ) ; } MethodBinding [ ] compatible = new MethodBinding [ methods . length ] ; int compatibleIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , length = methods . length ; i < length ; i ++ ) { MethodBinding compatibleMethod = computeCompatibleMethod ( methods [ i ] , argumentTypes , invocationSite ) ; if ( compatibleMethod != null ) compatible [ compatibleIndex ++ ] = compatibleMethod ; } if ( compatibleIndex == <NUM_LIT:0> ) return new ProblemMethodBinding ( TypeConstants . INIT , argumentTypes , ProblemReasons . NotFound ) ; MethodBinding [ ] visible = new MethodBinding [ compatibleIndex ] ; int visibleIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < compatibleIndex ; i ++ ) { MethodBinding method = compatible [ i ] ; if ( canBeSeenByForCodeSnippet ( method , receiverType , invocationSite , this ) ) { visible [ visibleIndex ++ ] = method ; } } if ( visibleIndex == <NUM_LIT:1> ) { return visible [ <NUM_LIT:0> ] ; } if ( visibleIndex == <NUM_LIT:0> ) { return new ProblemMethodBinding ( compatible [ <NUM_LIT:0> ] , TypeConstants . INIT , compatible [ <NUM_LIT:0> ] . parameters , ProblemReasons . NotVisible ) ; } return mostSpecificClassMethodBinding ( visible , visibleIndex , invocationSite ) ; } public FieldBinding getFieldForCodeSnippet ( TypeBinding receiverType , char [ ] fieldName , InvocationSite invocationSite ) { FieldBinding field = findFieldForCodeSnippet ( receiverType , fieldName , invocationSite ) ; if ( field == null ) return new ProblemFieldBinding ( receiverType instanceof ReferenceBinding ? ( ReferenceBinding ) receiverType : null , fieldName , ProblemReasons . NotFound ) ; else return field ; } public MethodBinding getImplicitMethod ( ReferenceBinding receiverType , char [ ] selector , TypeBinding [ ] argumentTypes , InvocationSite invocationSite ) { MethodBinding methodBinding = findExactMethod ( receiverType , selector , argumentTypes , invocationSite ) ; if ( methodBinding == null ) methodBinding = findMethod ( receiverType , selector , argumentTypes , invocationSite ) ; if ( methodBinding != null ) { if ( methodBinding . isValidBinding ( ) ) if ( ! canBeSeenByForCodeSnippet ( methodBinding , receiverType , invocationSite , this ) ) return new ProblemMethodBinding ( methodBinding , selector , argumentTypes , ProblemReasons . NotVisible ) ; return methodBinding ; } return new ProblemMethodBinding ( selector , argumentTypes , ProblemReasons . NotFound ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . CastExpression ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . Opcodes ; import org . eclipse . jdt . internal . compiler . flow . FlowInfo ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ParameterizedTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemMethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; public class CodeSnippetAllocationExpression extends AllocationExpression implements ProblemReasons , EvaluationConstants { EvaluationContext evaluationContext ; FieldBinding delegateThis ; public CodeSnippetAllocationExpression ( EvaluationContext evaluationContext ) { this . evaluationContext = evaluationContext ; } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; MethodBinding codegenBinding = this . binding . original ( ) ; ReferenceBinding allocatedType = codegenBinding . declaringClass ; if ( codegenBinding . canBeSeenBy ( allocatedType , this , currentScope ) ) { codeStream . new_ ( allocatedType ) ; if ( valueRequired ) { codeStream . dup ( ) ; } codeStream . recordPositionsFrom ( pc , this . type . sourceStart ) ; if ( allocatedType . isNestedType ( ) ) { codeStream . generateSyntheticEnclosingInstanceValues ( currentScope , allocatedType , enclosingInstance ( ) , this ) ; } if ( this . arguments != null ) { for ( int i = <NUM_LIT:0> , count = this . arguments . length ; i < count ; i ++ ) { this . arguments [ i ] . generateCode ( currentScope , codeStream , true ) ; } } if ( allocatedType . isNestedType ( ) ) { codeStream . generateSyntheticOuterArgumentValues ( currentScope , allocatedType , this ) ; } codeStream . invoke ( Opcodes . OPC_invokespecial , codegenBinding , null ) ; } else { codeStream . generateEmulationForConstructor ( currentScope , codegenBinding ) ; if ( this . arguments != null ) { int argsLength = this . arguments . length ; codeStream . generateInlinedValue ( argsLength ) ; codeStream . newArray ( currentScope . createArrayType ( currentScope . getType ( TypeConstants . JAVA_LANG_OBJECT , <NUM_LIT:3> ) , <NUM_LIT:1> ) ) ; codeStream . dup ( ) ; for ( int i = <NUM_LIT:0> ; i < argsLength ; i ++ ) { codeStream . generateInlinedValue ( i ) ; this . arguments [ i ] . generateCode ( currentScope , codeStream , true ) ; TypeBinding parameterBinding = codegenBinding . parameters [ i ] ; if ( parameterBinding . isBaseType ( ) && parameterBinding != TypeBinding . NULL ) { codeStream . generateBoxingConversion ( codegenBinding . parameters [ i ] . id ) ; } codeStream . aastore ( ) ; if ( i < argsLength - <NUM_LIT:1> ) { codeStream . dup ( ) ; } } } else { codeStream . generateInlinedValue ( <NUM_LIT:0> ) ; codeStream . newArray ( currentScope . createArrayType ( currentScope . getType ( TypeConstants . JAVA_LANG_OBJECT , <NUM_LIT:3> ) , <NUM_LIT:1> ) ) ; } codeStream . invokeJavaLangReflectConstructorNewInstance ( ) ; codeStream . checkcast ( allocatedType ) ; } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public void manageEnclosingInstanceAccessIfNecessary ( BlockScope currentScope , FlowInfo flowInfo ) { } public void manageSyntheticAccessIfNecessary ( BlockScope currentScope , FlowInfo flowInfo ) { } public TypeBinding resolveType ( BlockScope scope ) { this . constant = Constant . NotAConstant ; this . resolvedType = this . type . resolveType ( scope , true ) ; checkParameterizedAllocation : { if ( this . type instanceof ParameterizedQualifiedTypeReference ) { ReferenceBinding currentType = ( ReferenceBinding ) this . resolvedType ; if ( currentType == null ) return currentType ; do { if ( ( currentType . modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ) break checkParameterizedAllocation ; if ( currentType . isRawType ( ) ) break checkParameterizedAllocation ; } while ( ( currentType = currentType . enclosingType ( ) ) != null ) ; ParameterizedQualifiedTypeReference qRef = ( ParameterizedQualifiedTypeReference ) this . type ; for ( int i = qRef . typeArguments . length - <NUM_LIT:2> ; i >= <NUM_LIT:0> ; i -- ) { if ( qRef . typeArguments [ i ] != null ) { scope . problemReporter ( ) . illegalQualifiedParameterizedTypeAllocation ( this . type , this . resolvedType ) ; break ; } } } } final boolean isDiamond = this . type != null && ( this . type . bits & ASTNode . IsDiamond ) != <NUM_LIT:0> ; if ( this . typeArguments != null ) { int length = this . typeArguments . length ; boolean argHasError = scope . compilerOptions ( ) . sourceLevel < ClassFileConstants . JDK1_5 ; this . genericTypeArguments = new TypeBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeReference typeReference = this . typeArguments [ i ] ; if ( ( this . genericTypeArguments [ i ] = typeReference . resolveType ( scope , true ) ) == null ) { argHasError = true ; } if ( argHasError && typeReference instanceof Wildcard ) { scope . problemReporter ( ) . illegalUsageOfWildcard ( typeReference ) ; } } if ( isDiamond ) { scope . problemReporter ( ) . diamondNotWithExplicitTypeArguments ( this . typeArguments ) ; return null ; } if ( argHasError ) { if ( this . arguments != null ) { for ( int i = <NUM_LIT:0> , max = this . arguments . length ; i < max ; i ++ ) { this . arguments [ i ] . resolveType ( scope ) ; } } return null ; } } boolean argsContainCast = false ; TypeBinding [ ] argumentTypes = Binding . NO_PARAMETERS ; if ( this . arguments != null ) { boolean argHasError = false ; int length = this . arguments . length ; argumentTypes = new TypeBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { Expression argument = this . arguments [ i ] ; if ( argument instanceof CastExpression ) { argument . bits |= DisableUnnecessaryCastCheck ; argsContainCast = true ; } if ( ( argumentTypes [ i ] = argument . resolveType ( scope ) ) == null ) { argHasError = true ; } } if ( argHasError ) { return this . resolvedType ; } } if ( this . resolvedType == null ) { return null ; } if ( ! this . resolvedType . canBeInstantiated ( ) ) { scope . problemReporter ( ) . cannotInstantiate ( this . type , this . resolvedType ) ; return this . resolvedType ; } if ( isDiamond ) { TypeBinding [ ] inferredTypes = inferElidedTypes ( ( ( ParameterizedTypeBinding ) this . resolvedType ) . genericType ( ) , null , argumentTypes , scope ) ; if ( inferredTypes == null ) { scope . problemReporter ( ) . cannotInferElidedTypes ( this ) ; return this . resolvedType = null ; } this . resolvedType = this . type . resolvedType = scope . environment ( ) . createParameterizedType ( ( ( ParameterizedTypeBinding ) this . resolvedType ) . genericType ( ) , inferredTypes , ( ( ParameterizedTypeBinding ) this . resolvedType ) . enclosingType ( ) ) ; } ReferenceBinding allocatedType = ( ReferenceBinding ) this . resolvedType ; if ( ! ( this . binding = scope . getConstructor ( allocatedType , argumentTypes , this ) ) . isValidBinding ( ) ) { if ( this . binding instanceof ProblemMethodBinding && ( ( ProblemMethodBinding ) this . binding ) . problemId ( ) == NotVisible ) { if ( this . evaluationContext . declaringTypeName != null ) { this . delegateThis = scope . getField ( scope . enclosingSourceType ( ) , DELEGATE_THIS , this ) ; if ( this . delegateThis == null ) { if ( this . binding . declaringClass == null ) { this . binding . declaringClass = allocatedType ; } if ( this . type != null && ! this . type . resolvedType . isValidBinding ( ) ) { return null ; } scope . problemReporter ( ) . invalidConstructor ( this , this . binding ) ; return this . resolvedType ; } } else { if ( this . binding . declaringClass == null ) { this . binding . declaringClass = allocatedType ; } if ( this . type != null && ! this . type . resolvedType . isValidBinding ( ) ) { return null ; } scope . problemReporter ( ) . invalidConstructor ( this , this . binding ) ; return this . resolvedType ; } CodeSnippetScope localScope = new CodeSnippetScope ( scope ) ; MethodBinding privateBinding = localScope . getConstructor ( ( ReferenceBinding ) this . delegateThis . type , argumentTypes , this ) ; if ( ! privateBinding . isValidBinding ( ) ) { if ( this . binding . declaringClass == null ) { this . binding . declaringClass = allocatedType ; } if ( this . type != null && ! this . type . resolvedType . isValidBinding ( ) ) { return null ; } scope . problemReporter ( ) . invalidConstructor ( this , this . binding ) ; return this . resolvedType ; } else { this . binding = privateBinding ; } } else { if ( this . binding . declaringClass == null ) { this . binding . declaringClass = allocatedType ; } if ( this . type != null && ! this . type . resolvedType . isValidBinding ( ) ) { return null ; } scope . problemReporter ( ) . invalidConstructor ( this , this . binding ) ; return this . resolvedType ; } } if ( isMethodUseDeprecated ( this . binding , scope , true ) ) { scope . problemReporter ( ) . deprecatedMethod ( this . binding , this ) ; } if ( this . arguments != null ) { for ( int i = <NUM_LIT:0> ; i < this . arguments . length ; i ++ ) { TypeBinding parameterType = this . binding . parameters [ i ] ; TypeBinding argumentType = argumentTypes [ i ] ; this . arguments [ i ] . computeConversion ( scope , parameterType , argumentType ) ; if ( argumentType . needsUncheckedConversion ( parameterType ) ) { scope . problemReporter ( ) . unsafeTypeConversion ( this . arguments [ i ] , argumentType , parameterType ) ; } } if ( argsContainCast ) { CastExpression . checkNeedForArgumentCasts ( scope , null , allocatedType , this . binding , this . arguments , argumentTypes , this ) ; } } if ( allocatedType . isRawType ( ) && this . binding . hasSubstitutedParameters ( ) ) { scope . problemReporter ( ) . unsafeRawInvocation ( this , this . binding ) ; } if ( this . typeArguments != null && this . binding . original ( ) . typeVariables == Binding . NO_TYPE_VARIABLES ) { scope . problemReporter ( ) . unnecessaryTypeArgumentsForMethodInvocation ( this . binding , this . genericTypeArguments , this . typeArguments ) ; } return allocatedType ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ClassFile ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . lookup . TypeVariableBinding ; import org . eclipse . jdt . internal . compiler . problem . AbortType ; import org . eclipse . jdt . internal . compiler . util . Util ; public class CodeSnippetTypeDeclaration extends TypeDeclaration { public CodeSnippetTypeDeclaration ( CompilationResult compilationResult ) { super ( compilationResult ) ; } public void generateCode ( ClassFile enclosingClassFile ) { if ( ( this . bits & ASTNode . HasBeenGenerated ) != <NUM_LIT:0> ) return ; this . bits |= ASTNode . HasBeenGenerated ; if ( this . ignoreFurtherInvestigation ) { if ( this . binding == null ) return ; CodeSnippetClassFile . createProblemType ( this , this . scope . referenceCompilationUnit ( ) . compilationResult ) ; return ; } try { ClassFile classFile = new CodeSnippetClassFile ( this . binding , enclosingClassFile , false ) ; classFile . addFieldInfos ( ) ; if ( this . binding . isMemberType ( ) ) { classFile . recordInnerClasses ( this . binding ) ; } else if ( this . binding . isLocalType ( ) ) { enclosingClassFile . recordInnerClasses ( this . binding ) ; classFile . recordInnerClasses ( this . binding ) ; } TypeVariableBinding [ ] typeVariables = this . binding . typeVariables ( ) ; for ( int i = <NUM_LIT:0> , max = typeVariables . length ; i < max ; i ++ ) { TypeVariableBinding typeVariableBinding = typeVariables [ i ] ; if ( ( typeVariableBinding . tagBits & TagBits . ContainsNestedTypeReferences ) != <NUM_LIT:0> ) { Util . recordNestedType ( classFile , typeVariableBinding ) ; } } if ( this . memberTypes != null ) { for ( int i = <NUM_LIT:0> , max = this . memberTypes . length ; i < max ; i ++ ) { TypeDeclaration memberType = this . memberTypes [ i ] ; classFile . recordInnerClasses ( memberType . binding ) ; memberType . generateCode ( this . scope , classFile ) ; } } classFile . setForMethodInfos ( ) ; if ( this . methods != null ) { for ( int i = <NUM_LIT:0> , max = this . methods . length ; i < max ; i ++ ) { this . methods [ i ] . generateCode ( this . scope , classFile ) ; } } classFile . addSpecialMethods ( ) ; if ( this . ignoreFurtherInvestigation ) { throw new AbortType ( this . scope . referenceCompilationUnit ( ) . compilationResult , null ) ; } classFile . addAttributes ( ) ; this . scope . referenceCompilationUnit ( ) . compilationResult . record ( this . binding . constantPoolName ( ) , classFile ) ; } catch ( AbortType e ) { if ( this . binding == null ) return ; CodeSnippetClassFile . createProblemType ( this , this . scope . referenceCompilationUnit ( ) . compilationResult ) ; } } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ast . ThisReference ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . Opcodes ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . InvocationSite ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CodeSnippetThisReference extends ThisReference implements EvaluationConstants , InvocationSite { EvaluationContext evaluationContext ; FieldBinding delegateThis ; boolean isImplicit ; public CodeSnippetThisReference ( int s , int sourceEnd , EvaluationContext evaluationContext , boolean isImplicit ) { super ( s , sourceEnd ) ; this . evaluationContext = evaluationContext ; this . isImplicit = isImplicit ; } public boolean checkAccess ( MethodScope methodScope ) { if ( this . evaluationContext . isConstructorCall ) { methodScope . problemReporter ( ) . fieldsOrThisBeforeConstructorInvocation ( this ) ; return false ; } if ( this . evaluationContext . declaringTypeName == null || this . evaluationContext . isStatic ) { methodScope . problemReporter ( ) . errorThisSuperInStatic ( this ) ; return false ; } return true ; } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; if ( valueRequired ) { codeStream . aload_0 ( ) ; codeStream . fieldAccess ( Opcodes . OPC_getfield , this . delegateThis , null ) ; } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public TypeBinding [ ] genericTypeArguments ( ) { return null ; } public boolean isSuperAccess ( ) { return false ; } public boolean isTypeAccess ( ) { return false ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { char [ ] declaringType = this . evaluationContext . declaringTypeName ; output . append ( '<CHAR_LIT:(>' ) ; if ( declaringType == null ) output . append ( "<STR_LIT>" ) ; else output . append ( declaringType ) ; return output . append ( "<STR_LIT>" ) ; } public TypeBinding resolveType ( BlockScope scope ) { this . constant = Constant . NotAConstant ; TypeBinding snippetType = null ; MethodScope methodScope = scope . methodScope ( ) ; if ( ! this . isImplicit && ! checkAccess ( methodScope ) ) { return null ; } snippetType = scope . enclosingSourceType ( ) ; this . delegateThis = scope . getField ( snippetType , DELEGATE_THIS , this ) ; if ( this . delegateThis == null || ! this . delegateThis . isValidBinding ( ) ) { methodScope . problemReporter ( ) . errorThisSuperInStatic ( this ) ; return null ; } return this . resolvedType = this . delegateThis . type ; } public void setActualReceiverType ( ReferenceBinding receiverType ) { } public void setDepth ( int depth ) { } public void setFieldIndex ( int index ) { } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ClassFile ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; public class CodeSnippetEnvironment implements INameEnvironment , EvaluationConstants { INameEnvironment env ; EvaluationContext context ; public CodeSnippetEnvironment ( INameEnvironment env , EvaluationContext context ) { this . env = env ; this . context = context ; } public NameEnvironmentAnswer findType ( char [ ] [ ] compoundTypeName ) { NameEnvironmentAnswer result = this . env . findType ( compoundTypeName ) ; if ( result != null ) { return result ; } if ( CharOperation . equals ( compoundTypeName , ROOT_COMPOUND_NAME ) ) { IBinaryType binary = this . context . getRootCodeSnippetBinary ( ) ; if ( binary == null ) { return null ; } else { return new NameEnvironmentAnswer ( binary , null ) ; } } VariablesInfo installedVars = this . context . installedVars ; ClassFile [ ] classFiles = installedVars . classFiles ; for ( int i = <NUM_LIT:0> ; i < classFiles . length ; i ++ ) { ClassFile classFile = classFiles [ i ] ; if ( CharOperation . equals ( compoundTypeName , classFile . getCompoundName ( ) ) ) { ClassFileReader binary = null ; try { binary = new ClassFileReader ( classFile . getBytes ( ) , null ) ; } catch ( ClassFormatException e ) { e . printStackTrace ( ) ; return null ; } return new NameEnvironmentAnswer ( binary , null ) ; } } return null ; } public NameEnvironmentAnswer findType ( char [ ] typeName , char [ ] [ ] packageName ) { NameEnvironmentAnswer result = this . env . findType ( typeName , packageName ) ; if ( result != null ) { return result ; } return findType ( CharOperation . arrayConcat ( packageName , typeName ) ) ; } public boolean isPackage ( char [ ] [ ] parentPackageName , char [ ] packageName ) { return this . env . isPackage ( parentPackageName , packageName ) ; } public void cleanup ( ) { this . env . cleanup ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . Assignment ; import org . eclipse . jdt . internal . compiler . ast . CompoundAssignment ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . IntLiteral ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . Opcodes ; import org . eclipse . jdt . internal . compiler . flow . FlowInfo ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . LocalVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . ProblemBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; import org . eclipse . jdt . internal . compiler . lookup . VariableBinding ; public class CodeSnippetQualifiedNameReference extends QualifiedNameReference implements EvaluationConstants , ProblemReasons { EvaluationContext evaluationContext ; FieldBinding delegateThis ; public CodeSnippetQualifiedNameReference ( char [ ] [ ] sources , long [ ] positions , int sourceStart , int sourceEnd , EvaluationContext evaluationContext ) { super ( sources , positions , sourceStart , sourceEnd ) ; this . evaluationContext = evaluationContext ; } public TypeBinding checkFieldAccess ( BlockScope scope ) { FieldBinding fieldBinding = ( FieldBinding ) this . binding ; MethodScope methodScope = scope . methodScope ( ) ; TypeBinding declaringClass = fieldBinding . original ( ) . declaringClass ; if ( ( this . indexOfFirstFieldBinding == <NUM_LIT:1> || declaringClass . isEnum ( ) ) && methodScope . enclosingSourceType ( ) == declaringClass && methodScope . lastVisibleFieldID >= <NUM_LIT:0> && fieldBinding . id >= methodScope . lastVisibleFieldID && ( ! fieldBinding . isStatic ( ) || methodScope . isStatic ) ) { scope . problemReporter ( ) . forwardReference ( this , this . indexOfFirstFieldBinding - <NUM_LIT:1> , fieldBinding ) ; } this . bits &= ~ ASTNode . RestrictiveFlagMASK ; this . bits |= Binding . FIELD ; return getOtherFieldBindings ( scope ) ; } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; if ( ( this . bits & Binding . VARIABLE ) == <NUM_LIT:0> ) { codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; return ; } FieldBinding lastFieldBinding = this . otherBindings == null ? ( FieldBinding ) this . binding : this . otherBindings [ this . otherBindings . length - <NUM_LIT:1> ] ; if ( lastFieldBinding . canBeSeenBy ( getFinalReceiverType ( ) , this , currentScope ) ) { super . generateCode ( currentScope , codeStream , valueRequired ) ; return ; } lastFieldBinding = generateReadSequence ( currentScope , codeStream ) ; if ( lastFieldBinding != null ) { boolean isStatic = lastFieldBinding . isStatic ( ) ; Constant fieldConstant = lastFieldBinding . constant ( ) ; if ( fieldConstant != Constant . NotAConstant ) { if ( ! isStatic ) { codeStream . invokeObjectGetClass ( ) ; codeStream . pop ( ) ; } if ( valueRequired ) { codeStream . generateConstant ( fieldConstant , this . implicitConversion ) ; } } else { boolean isFirst = lastFieldBinding == this . binding && ( this . indexOfFirstFieldBinding == <NUM_LIT:1> || lastFieldBinding . declaringClass == currentScope . enclosingReceiverType ( ) ) && this . otherBindings == null ; TypeBinding requiredGenericCast = getGenericCast ( this . otherBindings == null ? <NUM_LIT:0> : this . otherBindings . length ) ; if ( valueRequired || ( ! isFirst && currentScope . compilerOptions ( ) . complianceLevel >= ClassFileConstants . JDK1_4 ) || ( ( this . implicitConversion & TypeIds . UNBOXING ) != <NUM_LIT:0> ) || requiredGenericCast != null ) { int lastFieldPc = codeStream . position ; if ( lastFieldBinding . declaringClass == null ) { codeStream . arraylength ( ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( this . implicitConversion ) ; } else { codeStream . pop ( ) ; } } else { codeStream . generateEmulatedReadAccessForField ( lastFieldBinding ) ; if ( requiredGenericCast != null ) codeStream . checkcast ( requiredGenericCast ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( this . implicitConversion ) ; } else { boolean isUnboxing = ( this . implicitConversion & TypeIds . UNBOXING ) != <NUM_LIT:0> ; if ( isUnboxing ) codeStream . generateImplicitConversion ( this . implicitConversion ) ; switch ( isUnboxing ? postConversionType ( currentScope ) . id : lastFieldBinding . type . id ) { case T_long : case T_double : codeStream . pop2 ( ) ; break ; default : codeStream . pop ( ) ; } } } int fieldPosition = ( int ) ( this . sourcePositions [ this . sourcePositions . length - <NUM_LIT:1> ] > > > <NUM_LIT:32> ) ; codeStream . recordPositionsFrom ( lastFieldPc , fieldPosition ) ; } else { if ( ! isStatic ) { codeStream . invokeObjectGetClass ( ) ; codeStream . pop ( ) ; } } } } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public void generateAssignment ( BlockScope currentScope , CodeStream codeStream , Assignment assignment , boolean valueRequired ) { FieldBinding lastFieldBinding = this . otherBindings == null ? ( FieldBinding ) this . binding : this . otherBindings [ this . otherBindings . length - <NUM_LIT:1> ] ; if ( lastFieldBinding . canBeSeenBy ( getFinalReceiverType ( ) , this , currentScope ) ) { super . generateAssignment ( currentScope , codeStream , assignment , valueRequired ) ; return ; } lastFieldBinding = generateReadSequence ( currentScope , codeStream ) ; codeStream . generateEmulationForField ( lastFieldBinding ) ; codeStream . swap ( ) ; assignment . expression . generateCode ( currentScope , codeStream , true ) ; if ( valueRequired ) { switch ( lastFieldBinding . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2_x2 ( ) ; break ; default : codeStream . dup_x2 ( ) ; break ; } } codeStream . generateEmulatedWriteAccessForField ( lastFieldBinding ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } } public void generateCompoundAssignment ( BlockScope currentScope , CodeStream codeStream , Expression expression , int operator , int assignmentImplicitConversion , boolean valueRequired ) { FieldBinding lastFieldBinding = this . otherBindings == null ? ( FieldBinding ) this . binding : this . otherBindings [ this . otherBindings . length - <NUM_LIT:1> ] ; if ( lastFieldBinding . canBeSeenBy ( getFinalReceiverType ( ) , this , currentScope ) ) { super . generateCompoundAssignment ( currentScope , codeStream , expression , operator , assignmentImplicitConversion , valueRequired ) ; return ; } lastFieldBinding = generateReadSequence ( currentScope , codeStream ) ; if ( lastFieldBinding . isStatic ( ) ) { codeStream . generateEmulationForField ( lastFieldBinding ) ; codeStream . swap ( ) ; codeStream . aconst_null ( ) ; codeStream . swap ( ) ; codeStream . generateEmulatedReadAccessForField ( lastFieldBinding ) ; } else { codeStream . generateEmulationForField ( lastFieldBinding ) ; codeStream . swap ( ) ; codeStream . dup ( ) ; codeStream . generateEmulatedReadAccessForField ( lastFieldBinding ) ; } int operationTypeID ; if ( ( operationTypeID = ( this . implicitConversion & IMPLICIT_CONVERSION_MASK ) > > <NUM_LIT:4> ) == T_JavaLangString ) { codeStream . generateStringConcatenationAppend ( currentScope , null , expression ) ; } else { codeStream . generateImplicitConversion ( this . implicitConversion ) ; if ( expression == IntLiteral . One ) { codeStream . generateConstant ( expression . constant , this . implicitConversion ) ; } else { expression . generateCode ( currentScope , codeStream , true ) ; } codeStream . sendOperator ( operator , operationTypeID ) ; codeStream . generateImplicitConversion ( assignmentImplicitConversion ) ; } if ( valueRequired ) { switch ( lastFieldBinding . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2_x2 ( ) ; break ; default : codeStream . dup_x2 ( ) ; break ; } } codeStream . generateEmulatedWriteAccessForField ( lastFieldBinding ) ; } public void generatePostIncrement ( BlockScope currentScope , CodeStream codeStream , CompoundAssignment postIncrement , boolean valueRequired ) { FieldBinding lastFieldBinding = this . otherBindings == null ? ( FieldBinding ) this . binding : this . otherBindings [ this . otherBindings . length - <NUM_LIT:1> ] ; if ( lastFieldBinding . canBeSeenBy ( getFinalReceiverType ( ) , this , currentScope ) ) { super . generatePostIncrement ( currentScope , codeStream , postIncrement , valueRequired ) ; return ; } lastFieldBinding = generateReadSequence ( currentScope , codeStream ) ; codeStream . generateEmulatedReadAccessForField ( lastFieldBinding ) ; if ( valueRequired ) { switch ( lastFieldBinding . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2 ( ) ; break ; default : codeStream . dup ( ) ; break ; } } codeStream . generateEmulationForField ( lastFieldBinding ) ; if ( ( lastFieldBinding . type == TypeBinding . LONG ) || ( lastFieldBinding . type == TypeBinding . DOUBLE ) ) { codeStream . dup_x2 ( ) ; codeStream . pop ( ) ; if ( lastFieldBinding . isStatic ( ) ) { codeStream . aconst_null ( ) ; } else { generateReadSequence ( currentScope , codeStream ) ; } codeStream . dup_x2 ( ) ; codeStream . pop ( ) ; } else { codeStream . dup_x1 ( ) ; codeStream . pop ( ) ; if ( lastFieldBinding . isStatic ( ) ) { codeStream . aconst_null ( ) ; } else { generateReadSequence ( currentScope , codeStream ) ; } codeStream . dup_x1 ( ) ; codeStream . pop ( ) ; } codeStream . generateConstant ( postIncrement . expression . constant , this . implicitConversion ) ; codeStream . sendOperator ( postIncrement . operator , lastFieldBinding . type . id ) ; codeStream . generateImplicitConversion ( postIncrement . preAssignImplicitConversion ) ; codeStream . generateEmulatedWriteAccessForField ( lastFieldBinding ) ; } public FieldBinding generateReadSequence ( BlockScope currentScope , CodeStream codeStream ) { int otherBindingsCount = this . otherBindings == null ? <NUM_LIT:0> : this . otherBindings . length ; boolean needValue = otherBindingsCount == <NUM_LIT:0> || ! this . otherBindings [ <NUM_LIT:0> ] . isStatic ( ) ; FieldBinding lastFieldBinding ; TypeBinding lastGenericCast ; TypeBinding lastReceiverType ; boolean complyTo14 = currentScope . compilerOptions ( ) . complianceLevel >= ClassFileConstants . JDK1_4 ; switch ( this . bits & RestrictiveFlagMASK ) { case Binding . FIELD : lastFieldBinding = ( ( FieldBinding ) this . binding ) . original ( ) ; lastGenericCast = this . genericCast ; lastReceiverType = this . actualReceiverType ; if ( lastFieldBinding . constant ( ) != Constant . NotAConstant ) { break ; } if ( needValue ) { if ( lastFieldBinding . canBeSeenBy ( this . actualReceiverType , this , currentScope ) ) { if ( ! lastFieldBinding . isStatic ( ) ) { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { ReferenceBinding targetType = currentScope . enclosingSourceType ( ) . enclosingTypeAt ( ( this . bits & DepthMASK ) > > DepthSHIFT ) ; Object [ ] emulationPath = currentScope . getEmulationPath ( targetType , true , false ) ; codeStream . generateOuterAccess ( emulationPath , this , targetType , currentScope ) ; } else { generateReceiver ( codeStream ) ; } } } else { if ( ! lastFieldBinding . isStatic ( ) ) { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { currentScope . problemReporter ( ) . needImplementation ( this ) ; } else { generateReceiver ( codeStream ) ; } } else { codeStream . aconst_null ( ) ; } } } break ; case Binding . LOCAL : lastFieldBinding = null ; lastGenericCast = null ; LocalVariableBinding localBinding = ( LocalVariableBinding ) this . binding ; lastReceiverType = localBinding . type ; if ( ! needValue ) break ; Constant localConstant = localBinding . constant ( ) ; if ( localConstant != Constant . NotAConstant ) { codeStream . generateConstant ( localConstant , <NUM_LIT:0> ) ; } else { if ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) { VariableBinding [ ] path = currentScope . getEmulationPath ( localBinding ) ; codeStream . generateOuterAccess ( path , this , localBinding , currentScope ) ; } else { codeStream . load ( localBinding ) ; } } break ; default : return null ; } int positionsLength = this . sourcePositions . length ; FieldBinding initialFieldBinding = lastFieldBinding ; if ( this . otherBindings != null ) { for ( int i = <NUM_LIT:0> ; i < otherBindingsCount ; i ++ ) { int pc = codeStream . position ; FieldBinding nextField = this . otherBindings [ i ] . original ( ) ; TypeBinding nextGenericCast = this . otherGenericCasts == null ? null : this . otherGenericCasts [ i ] ; if ( lastFieldBinding != null ) { needValue = ! nextField . isStatic ( ) ; Constant fieldConstant = lastFieldBinding . constant ( ) ; if ( fieldConstant != Constant . NotAConstant ) { if ( i > <NUM_LIT:0> && ! lastFieldBinding . isStatic ( ) ) { codeStream . invokeObjectGetClass ( ) ; codeStream . pop ( ) ; } if ( needValue ) { codeStream . generateConstant ( fieldConstant , <NUM_LIT:0> ) ; } } else { if ( needValue || ( i > <NUM_LIT:0> && complyTo14 ) || lastGenericCast != null ) { if ( lastFieldBinding . canBeSeenBy ( lastReceiverType , this , currentScope ) ) { MethodBinding accessor = this . syntheticReadAccessors == null ? null : this . syntheticReadAccessors [ i ] ; if ( accessor == null ) { TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , lastFieldBinding , lastReceiverType , i == <NUM_LIT:0> && this . indexOfFirstFieldBinding == <NUM_LIT:1> ) ; if ( lastFieldBinding . isStatic ( ) ) { codeStream . fieldAccess ( Opcodes . OPC_getstatic , lastFieldBinding , constantPoolDeclaringClass ) ; } else { codeStream . fieldAccess ( Opcodes . OPC_getfield , lastFieldBinding , constantPoolDeclaringClass ) ; } } else { codeStream . invoke ( Opcodes . OPC_invokestatic , accessor , null ) ; } } else { codeStream . generateEmulatedReadAccessForField ( lastFieldBinding ) ; } if ( lastGenericCast != null ) { codeStream . checkcast ( lastGenericCast ) ; lastReceiverType = lastGenericCast ; } else { lastReceiverType = lastFieldBinding . type ; } if ( ! needValue ) codeStream . pop ( ) ; } else { if ( lastFieldBinding == initialFieldBinding ) { if ( lastFieldBinding . isStatic ( ) ) { if ( initialFieldBinding . declaringClass != this . actualReceiverType . erasure ( ) ) { if ( lastFieldBinding . canBeSeenBy ( lastReceiverType , this , currentScope ) ) { MethodBinding accessor = this . syntheticReadAccessors == null ? null : this . syntheticReadAccessors [ i ] ; if ( accessor == null ) { TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , lastFieldBinding , lastReceiverType , i == <NUM_LIT:0> && this . indexOfFirstFieldBinding == <NUM_LIT:1> ) ; codeStream . fieldAccess ( Opcodes . OPC_getstatic , lastFieldBinding , constantPoolDeclaringClass ) ; } else { codeStream . invoke ( Opcodes . OPC_invokestatic , accessor , null ) ; } } else { codeStream . generateEmulatedReadAccessForField ( lastFieldBinding ) ; } codeStream . pop ( ) ; } } } else if ( ! lastFieldBinding . isStatic ( ) ) { codeStream . invokeObjectGetClass ( ) ; codeStream . pop ( ) ; } lastReceiverType = lastFieldBinding . type ; } if ( ( positionsLength - otherBindingsCount + i - <NUM_LIT:1> ) >= <NUM_LIT:0> ) { int fieldPosition = ( int ) ( this . sourcePositions [ positionsLength - otherBindingsCount + i - <NUM_LIT:1> ] > > > <NUM_LIT:32> ) ; codeStream . recordPositionsFrom ( pc , fieldPosition ) ; } } } lastFieldBinding = nextField ; lastGenericCast = nextGenericCast ; if ( lastFieldBinding != null && ! lastFieldBinding . canBeSeenBy ( lastReceiverType , this , currentScope ) ) { if ( lastFieldBinding . isStatic ( ) ) { codeStream . aconst_null ( ) ; } } } } return lastFieldBinding ; } public void generateReceiver ( CodeStream codeStream ) { codeStream . aload_0 ( ) ; if ( this . delegateThis != null ) { codeStream . fieldAccess ( Opcodes . OPC_getfield , this . delegateThis , null ) ; } } public TypeBinding getOtherFieldBindings ( BlockScope scope ) { int length = this . tokens . length ; if ( ( this . bits & Binding . FIELD ) != <NUM_LIT:0> ) { if ( ! ( ( FieldBinding ) this . binding ) . isStatic ( ) ) { if ( this . indexOfFirstFieldBinding == <NUM_LIT:1> ) { if ( scope . methodScope ( ) . isStatic ) { scope . problemReporter ( ) . staticFieldAccessToNonStaticVariable ( this , ( FieldBinding ) this . binding ) ; return null ; } } else { scope . problemReporter ( ) . staticFieldAccessToNonStaticVariable ( this , ( FieldBinding ) this . binding ) ; return null ; } } if ( isFieldUseDeprecated ( ( FieldBinding ) this . binding , scope , this . indexOfFirstFieldBinding == length ? this . bits : <NUM_LIT:0> ) ) { scope . problemReporter ( ) . deprecatedField ( ( FieldBinding ) this . binding , this ) ; } } TypeBinding type = ( ( VariableBinding ) this . binding ) . type ; int index = this . indexOfFirstFieldBinding ; if ( index == length ) { this . constant = ( ( FieldBinding ) this . binding ) . constant ( ) ; return type ; } int otherBindingsLength = length - index ; this . otherBindings = new FieldBinding [ otherBindingsLength ] ; this . constant = ( ( VariableBinding ) this . binding ) . constant ( ) ; while ( index < length ) { char [ ] token = this . tokens [ index ] ; if ( type == null ) return null ; FieldBinding field = scope . getField ( type , token , this ) ; int place = index - this . indexOfFirstFieldBinding ; this . otherBindings [ place ] = field ; if ( ! field . isValidBinding ( ) ) { CodeSnippetScope localScope = new CodeSnippetScope ( scope ) ; if ( this . delegateThis == null ) { if ( this . evaluationContext . declaringTypeName != null ) { this . delegateThis = scope . getField ( scope . enclosingSourceType ( ) , DELEGATE_THIS , this ) ; if ( this . delegateThis == null ) { return super . reportError ( scope ) ; } this . actualReceiverType = this . delegateThis . type ; } else { this . constant = Constant . NotAConstant ; scope . problemReporter ( ) . invalidField ( this , field , index , type ) ; return null ; } } field = localScope . getFieldForCodeSnippet ( this . delegateThis . type , token , this ) ; this . otherBindings [ place ] = field ; } if ( field . isValidBinding ( ) ) { if ( isFieldUseDeprecated ( field , scope , index + <NUM_LIT:1> == length ? this . bits : <NUM_LIT:0> ) ) { scope . problemReporter ( ) . deprecatedField ( field , this ) ; } if ( this . constant != Constant . NotAConstant ) { this . constant = field . constant ( ) ; } type = field . type ; index ++ ; } else { this . constant = Constant . NotAConstant ; scope . problemReporter ( ) . invalidField ( this , field , index , type ) ; return null ; } } return ( this . otherBindings [ otherBindingsLength - <NUM_LIT:1> ] ) . type ; } public void manageSyntheticAccessIfNecessary ( BlockScope currentScope , FieldBinding fieldBinding , int index , FlowInfo flowInfo ) { } public TypeBinding reportError ( BlockScope scope ) { if ( this . evaluationContext . declaringTypeName != null ) { this . delegateThis = scope . getField ( scope . enclosingSourceType ( ) , DELEGATE_THIS , this ) ; if ( this . delegateThis == null ) { return super . reportError ( scope ) ; } this . actualReceiverType = this . delegateThis . type ; } else { return super . reportError ( scope ) ; } if ( ( this . binding instanceof ProblemFieldBinding && ( ( ProblemFieldBinding ) this . binding ) . problemId ( ) == NotFound ) || ( this . binding instanceof ProblemBinding && ( ( ProblemBinding ) this . binding ) . problemId ( ) == NotFound ) ) { FieldBinding fieldBinding = scope . getField ( this . delegateThis . type , this . tokens [ <NUM_LIT:0> ] , this ) ; if ( ! fieldBinding . isValidBinding ( ) ) { if ( ( ( ProblemFieldBinding ) fieldBinding ) . problemId ( ) == NotVisible ) { CodeSnippetScope localScope = new CodeSnippetScope ( scope ) ; this . binding = localScope . getFieldForCodeSnippet ( this . delegateThis . type , this . tokens [ <NUM_LIT:0> ] , this ) ; if ( this . binding . isValidBinding ( ) ) { return checkFieldAccess ( scope ) ; } else { return super . reportError ( scope ) ; } } else { return super . reportError ( scope ) ; } } this . binding = fieldBinding ; return checkFieldAccess ( scope ) ; } TypeBinding result ; if ( this . binding instanceof ProblemFieldBinding && ( ( ProblemFieldBinding ) this . binding ) . problemId ( ) == NotVisible ) { CodeSnippetScope localScope = new CodeSnippetScope ( scope ) ; if ( ( this . binding = localScope . getBinding ( this . tokens , this . bits & RestrictiveFlagMASK , this , ( ReferenceBinding ) this . delegateThis . type ) ) . isValidBinding ( ) ) { this . bits &= ~ RestrictiveFlagMASK ; this . bits |= Binding . FIELD ; result = getOtherFieldBindings ( scope ) ; } else { return super . reportError ( scope ) ; } if ( result != null && result . isValidBinding ( ) ) { return result ; } } return super . reportError ( scope ) ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . CastExpression ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . NameReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . Opcodes ; import org . eclipse . jdt . internal . compiler . flow . FlowInfo ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemMethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; import org . eclipse . jdt . internal . compiler . lookup . TypeVariableBinding ; public class CodeSnippetMessageSend extends MessageSend { EvaluationContext evaluationContext ; FieldBinding delegateThis ; public CodeSnippetMessageSend ( EvaluationContext evaluationContext ) { this . evaluationContext = evaluationContext ; } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; MethodBinding codegenBinding = this . binding . original ( ) ; if ( codegenBinding . canBeSeenBy ( this . actualReceiverType , this , currentScope ) ) { boolean isStatic = codegenBinding . isStatic ( ) ; if ( ! isStatic && ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) ) { ReferenceBinding targetType = currentScope . enclosingSourceType ( ) . enclosingTypeAt ( ( this . bits & DepthMASK ) > > DepthSHIFT ) ; Object [ ] path = currentScope . getEmulationPath ( targetType , true , false ) ; if ( path == null ) { currentScope . problemReporter ( ) . needImplementation ( this ) ; } else { codeStream . generateOuterAccess ( path , this , targetType , currentScope ) ; } } else { this . receiver . generateCode ( currentScope , codeStream , ! isStatic ) ; if ( ( this . bits & NeedReceiverGenericCast ) != <NUM_LIT:0> ) { codeStream . checkcast ( this . actualReceiverType ) ; } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } generateArguments ( this . binding , this . arguments , currentScope , codeStream ) ; TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , codegenBinding , this . actualReceiverType , this . receiver . isImplicitThis ( ) ) ; if ( isStatic ) { codeStream . invoke ( Opcodes . OPC_invokestatic , codegenBinding , constantPoolDeclaringClass ) ; } else if ( ( this . receiver . isSuper ( ) ) || codegenBinding . isPrivate ( ) ) { codeStream . invoke ( Opcodes . OPC_invokespecial , codegenBinding , constantPoolDeclaringClass ) ; } else { if ( constantPoolDeclaringClass . isInterface ( ) ) { codeStream . invoke ( Opcodes . OPC_invokeinterface , codegenBinding , constantPoolDeclaringClass ) ; } else { codeStream . invoke ( Opcodes . OPC_invokevirtual , codegenBinding , constantPoolDeclaringClass ) ; } } } else { codeStream . generateEmulationForMethod ( currentScope , codegenBinding ) ; boolean isStatic = codegenBinding . isStatic ( ) ; if ( ! isStatic && ( ( this . bits & DepthMASK ) != <NUM_LIT:0> ) ) { currentScope . problemReporter ( ) . needImplementation ( this ) ; } else { this . receiver . generateCode ( currentScope , codeStream , ! isStatic ) ; if ( ( this . bits & NeedReceiverGenericCast ) != <NUM_LIT:0> ) { codeStream . checkcast ( this . actualReceiverType ) ; } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } if ( isStatic ) { codeStream . aconst_null ( ) ; } if ( this . arguments != null ) { int argsLength = this . arguments . length ; codeStream . generateInlinedValue ( argsLength ) ; codeStream . newArray ( currentScope . createArrayType ( currentScope . getType ( TypeConstants . JAVA_LANG_OBJECT , <NUM_LIT:3> ) , <NUM_LIT:1> ) ) ; codeStream . dup ( ) ; for ( int i = <NUM_LIT:0> ; i < argsLength ; i ++ ) { codeStream . generateInlinedValue ( i ) ; this . arguments [ i ] . generateCode ( currentScope , codeStream , true ) ; TypeBinding parameterBinding = codegenBinding . parameters [ i ] ; if ( parameterBinding . isBaseType ( ) && parameterBinding != TypeBinding . NULL ) { codeStream . generateBoxingConversion ( codegenBinding . parameters [ i ] . id ) ; } codeStream . aastore ( ) ; if ( i < argsLength - <NUM_LIT:1> ) { codeStream . dup ( ) ; } } } else { codeStream . generateInlinedValue ( <NUM_LIT:0> ) ; codeStream . newArray ( currentScope . createArrayType ( currentScope . getType ( TypeConstants . JAVA_LANG_OBJECT , <NUM_LIT:3> ) , <NUM_LIT:1> ) ) ; } codeStream . invokeJavaLangReflectMethodInvoke ( ) ; if ( codegenBinding . returnType . isBaseType ( ) ) { int typeID = codegenBinding . returnType . id ; if ( typeID == T_void ) { codeStream . pop ( ) ; } codeStream . checkcast ( typeID ) ; codeStream . getBaseTypeValue ( typeID ) ; } else { codeStream . checkcast ( codegenBinding . returnType ) ; } } if ( this . valueCast != null ) codeStream . checkcast ( this . valueCast ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( this . implicitConversion ) ; } else { boolean isUnboxing = ( this . implicitConversion & TypeIds . UNBOXING ) != <NUM_LIT:0> ; if ( isUnboxing ) codeStream . generateImplicitConversion ( this . implicitConversion ) ; switch ( isUnboxing ? postConversionType ( currentScope ) . id : codegenBinding . returnType . id ) { case T_long : case T_double : codeStream . pop2 ( ) ; break ; case T_void : break ; default : codeStream . pop ( ) ; } } codeStream . recordPositionsFrom ( pc , ( int ) ( this . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } public void manageSyntheticAccessIfNecessary ( BlockScope currentScope , FlowInfo flowInfo ) { if ( ( flowInfo . tagBits & FlowInfo . UNREACHABLE_OR_DEAD ) == <NUM_LIT:0> ) { MethodBinding codegenBinding = this . binding . original ( ) ; if ( codegenBinding != this . binding ) { if ( codegenBinding . returnType . isTypeVariable ( ) ) { TypeVariableBinding variableReturnType = ( TypeVariableBinding ) codegenBinding . returnType ; if ( variableReturnType . firstBound != this . binding . returnType ) { this . valueCast = this . binding . returnType ; } } } } } public TypeBinding resolveType ( BlockScope scope ) { this . constant = Constant . NotAConstant ; boolean receiverCast = false , argsContainCast = false ; if ( this . receiver instanceof CastExpression ) { this . receiver . bits |= DisableUnnecessaryCastCheck ; receiverCast = true ; } this . actualReceiverType = this . receiver . resolveType ( scope ) ; if ( receiverCast && this . actualReceiverType != null ) { if ( ( ( CastExpression ) this . receiver ) . expression . resolvedType == this . actualReceiverType ) { scope . problemReporter ( ) . unnecessaryCast ( ( CastExpression ) this . receiver ) ; } } if ( this . typeArguments != null ) { int length = this . typeArguments . length ; boolean argHasError = false ; this . genericTypeArguments = new TypeBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( ( this . genericTypeArguments [ i ] = this . typeArguments [ i ] . resolveType ( scope , true ) ) == null ) { argHasError = true ; } } if ( argHasError ) { return null ; } } TypeBinding [ ] argumentTypes = Binding . NO_PARAMETERS ; if ( this . arguments != null ) { boolean argHasError = false ; int length = this . arguments . length ; argumentTypes = new TypeBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { Expression argument = this . arguments [ i ] ; if ( argument instanceof CastExpression ) { argument . bits |= DisableUnnecessaryCastCheck ; argsContainCast = true ; } if ( ( argumentTypes [ i ] = this . arguments [ i ] . resolveType ( scope ) ) == null ) argHasError = true ; } if ( argHasError ) { if ( this . actualReceiverType instanceof ReferenceBinding ) { this . binding = scope . findMethod ( ( ReferenceBinding ) this . actualReceiverType , this . selector , new TypeBinding [ ] { } , this ) ; } return null ; } } if ( this . actualReceiverType == null ) { return null ; } if ( this . actualReceiverType . isBaseType ( ) ) { scope . problemReporter ( ) . errorNoMethodFor ( this , this . actualReceiverType , argumentTypes ) ; return null ; } this . binding = this . receiver . isImplicitThis ( ) ? scope . getImplicitMethod ( this . selector , argumentTypes , this ) : scope . getMethod ( this . actualReceiverType , this . selector , argumentTypes , this ) ; if ( ! this . binding . isValidBinding ( ) ) { if ( this . binding instanceof ProblemMethodBinding && ( ( ProblemMethodBinding ) this . binding ) . problemId ( ) == ProblemReasons . NotVisible ) { if ( this . evaluationContext . declaringTypeName != null ) { this . delegateThis = scope . getField ( scope . enclosingSourceType ( ) , EvaluationConstants . DELEGATE_THIS , this ) ; if ( this . delegateThis == null ) { this . constant = Constant . NotAConstant ; scope . problemReporter ( ) . invalidMethod ( this , this . binding ) ; return null ; } } else { this . constant = Constant . NotAConstant ; scope . problemReporter ( ) . invalidMethod ( this , this . binding ) ; return null ; } CodeSnippetScope localScope = new CodeSnippetScope ( scope ) ; MethodBinding privateBinding = this . receiver instanceof CodeSnippetThisReference && ( ( CodeSnippetThisReference ) this . receiver ) . isImplicit ? localScope . getImplicitMethod ( ( ReferenceBinding ) this . delegateThis . type , this . selector , argumentTypes , this ) : localScope . getMethod ( this . delegateThis . type , this . selector , argumentTypes , this ) ; if ( ! privateBinding . isValidBinding ( ) ) { if ( this . binding . declaringClass == null ) { if ( this . actualReceiverType instanceof ReferenceBinding ) { this . binding . declaringClass = ( ReferenceBinding ) this . actualReceiverType ; } else { scope . problemReporter ( ) . errorNoMethodFor ( this , this . actualReceiverType , argumentTypes ) ; return null ; } } scope . problemReporter ( ) . invalidMethod ( this , this . binding ) ; return null ; } else { this . binding = privateBinding ; } } else { if ( this . binding . declaringClass == null ) { if ( this . actualReceiverType instanceof ReferenceBinding ) { this . binding . declaringClass = ( ReferenceBinding ) this . actualReceiverType ; } else { scope . problemReporter ( ) . errorNoMethodFor ( this , this . actualReceiverType , argumentTypes ) ; return null ; } } scope . problemReporter ( ) . invalidMethod ( this , this . binding ) ; return null ; } } if ( ! this . binding . isStatic ( ) ) { if ( this . receiver instanceof NameReference && ( ( ( NameReference ) this . receiver ) . bits & Binding . TYPE ) != <NUM_LIT:0> ) { scope . problemReporter ( ) . mustUseAStaticMethod ( this , this . binding ) ; } else { TypeBinding oldReceiverType = this . actualReceiverType ; this . actualReceiverType = this . actualReceiverType . getErasureCompatibleType ( this . binding . declaringClass ) ; this . receiver . computeConversion ( scope , this . actualReceiverType , this . actualReceiverType ) ; if ( this . actualReceiverType != oldReceiverType && this . receiver . postConversionType ( scope ) != this . actualReceiverType ) { this . bits |= NeedReceiverGenericCast ; } } } if ( checkInvocationArguments ( scope , this . receiver , this . actualReceiverType , this . binding , this . arguments , argumentTypes , argsContainCast , this ) ) { this . bits |= ASTNode . Unchecked ; } if ( this . binding . isAbstract ( ) ) { if ( this . receiver . isSuper ( ) ) { scope . problemReporter ( ) . cannotDireclyInvokeAbstractMethod ( this , this . binding ) ; } } if ( isMethodUseDeprecated ( this . binding , scope , true ) ) scope . problemReporter ( ) . deprecatedMethod ( this . binding , this ) ; if ( this . actualReceiverType . isArrayType ( ) && this . binding . parameters == Binding . NO_PARAMETERS && scope . compilerOptions ( ) . complianceLevel >= ClassFileConstants . JDK1_5 && CharOperation . equals ( this . binding . selector , CLONE ) ) { this . resolvedType = this . actualReceiverType ; } else { TypeBinding returnType = this . binding . returnType ; if ( returnType != null ) { if ( ( this . bits & ASTNode . Unchecked ) != <NUM_LIT:0> && this . genericTypeArguments == null ) { returnType = scope . environment ( ) . convertToRawType ( returnType . erasure ( ) , true ) ; } returnType = returnType . capture ( scope , this . sourceEnd ) ; } this . resolvedType = returnType ; } return this . resolvedType ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import java . util . Locale ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . CompletionRequestor ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . codeassist . CompletionEngine ; import org . eclipse . jdt . internal . codeassist . ISelectionRequestor ; import org . eclipse . jdt . internal . codeassist . SelectionEngine ; import org . eclipse . jdt . internal . compiler . ClassFile ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . problem . DefaultProblemFactory ; import org . eclipse . jdt . internal . compiler . problem . ProblemSeverities ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . SearchableEnvironment ; import org . eclipse . jdt . internal . core . util . Util ; public class EvaluationContext implements EvaluationConstants , SuffixConstants { static int VAR_CLASS_COUNTER = <NUM_LIT:0> ; static int CODE_SNIPPET_COUNTER = <NUM_LIT:0> ; GlobalVariable [ ] variables ; int variableCount ; char [ ] [ ] imports ; char [ ] packageName ; boolean varsChanged ; VariablesInfo installedVars ; IBinaryType codeSnippetBinary ; String lineSeparator ; char [ ] declaringTypeName ; int [ ] localVariableModifiers ; char [ ] [ ] localVariableTypeNames ; char [ ] [ ] localVariableNames ; boolean isStatic ; boolean isConstructorCall ; public EvaluationContext ( ) { this . variables = new GlobalVariable [ <NUM_LIT:5> ] ; this . variableCount = <NUM_LIT:0> ; this . imports = CharOperation . NO_CHAR_CHAR ; this . packageName = CharOperation . NO_CHAR ; this . varsChanged = true ; this . isStatic = true ; this . isConstructorCall = false ; this . lineSeparator = org . eclipse . jdt . internal . compiler . util . Util . LINE_SEPARATOR ; } public GlobalVariable [ ] allVariables ( ) { GlobalVariable [ ] result = new GlobalVariable [ this . variableCount ] ; System . arraycopy ( this . variables , <NUM_LIT:0> , result , <NUM_LIT:0> , this . variableCount ) ; return result ; } public void complete ( char [ ] codeSnippet , int completionPosition , SearchableEnvironment environment , CompletionRequestor requestor , Map options , final IJavaProject project , WorkingCopyOwner owner , IProgressMonitor monitor ) { try { IRequestor variableRequestor = new IRequestor ( ) { public boolean acceptClassFiles ( ClassFile [ ] classFiles , char [ ] codeSnippetClassName ) { return true ; } public void acceptProblem ( CategorizedProblem problem , char [ ] fragmentSource , int fragmentKind ) { } } ; evaluateVariables ( environment , options , variableRequestor , new DefaultProblemFactory ( Locale . getDefault ( ) ) ) ; } catch ( InstallException e ) { } final char [ ] className = "<STR_LIT>" . toCharArray ( ) ; final long complianceVersion = CompilerOptions . versionToJdkLevel ( options . get ( JavaCore . COMPILER_COMPLIANCE ) ) ; final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper ( codeSnippet , this . packageName , this . imports , className , this . installedVars == null ? null : this . installedVars . className , this . localVariableNames , this . localVariableTypeNames , this . localVariableModifiers , this . declaringTypeName , this . lineSeparator , complianceVersion ) ; ICompilationUnit sourceUnit = new ICompilationUnit ( ) { public char [ ] getFileName ( ) { return CharOperation . concat ( className , Util . defaultJavaExtension ( ) . toCharArray ( ) ) ; } public char [ ] getContents ( ) { return mapper . getCUSource ( EvaluationContext . this . lineSeparator ) ; } public char [ ] getMainTypeName ( ) { return className ; } public char [ ] [ ] getPackageName ( ) { return null ; } } ; CompletionEngine engine = new CompletionEngine ( environment , mapper . getCompletionRequestor ( requestor ) , options , project , owner , monitor ) ; if ( this . installedVars != null ) { IBinaryType binaryType = getRootCodeSnippetBinary ( ) ; if ( binaryType != null ) { engine . lookupEnvironment . cacheBinaryType ( binaryType , null ) ; } ClassFile [ ] classFiles = this . installedVars . classFiles ; for ( int i = <NUM_LIT:0> ; i < classFiles . length ; i ++ ) { ClassFile classFile = classFiles [ i ] ; IBinaryType binary = null ; try { binary = new ClassFileReader ( classFile . getBytes ( ) , null ) ; } catch ( ClassFormatException e ) { e . printStackTrace ( ) ; } engine . lookupEnvironment . cacheBinaryType ( binary , null ) ; } } engine . complete ( sourceUnit , mapper . startPosOffset + completionPosition , mapper . startPosOffset , null ) ; } public void deleteVariable ( GlobalVariable variable ) { GlobalVariable [ ] vars = this . variables ; int index = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < this . variableCount ; i ++ ) { if ( vars [ i ] . equals ( variable ) ) { index = i ; break ; } } if ( index == - <NUM_LIT:1> ) { return ; } int elementCount = this . variableCount -- ; int j = elementCount - index - <NUM_LIT:1> ; if ( j > <NUM_LIT:0> ) { System . arraycopy ( vars , index + <NUM_LIT:1> , vars , index , j ) ; } vars [ elementCount - <NUM_LIT:1> ] = null ; this . varsChanged = true ; } private void deployCodeSnippetClassIfNeeded ( IRequestor requestor ) throws InstallException { if ( this . codeSnippetBinary == null ) { if ( ! requestor . acceptClassFiles ( new ClassFile [ ] { new ClassFile ( ) { public byte [ ] getBytes ( ) { return getCodeSnippetBytes ( ) ; } public char [ ] [ ] getCompoundName ( ) { return EvaluationConstants . ROOT_COMPOUND_NAME ; } } } , null ) ) throw new InstallException ( ) ; } } public void evaluate ( char [ ] codeSnippet , char [ ] [ ] contextLocalVariableTypeNames , char [ ] [ ] contextLocalVariableNames , int [ ] contextLocalVariableModifiers , char [ ] contextDeclaringTypeName , boolean contextIsStatic , boolean contextIsConstructorCall , INameEnvironment environment , Map options , final IRequestor requestor , IProblemFactory problemFactory ) throws InstallException { this . localVariableTypeNames = contextLocalVariableTypeNames ; this . localVariableNames = contextLocalVariableNames ; this . localVariableModifiers = contextLocalVariableModifiers ; this . declaringTypeName = contextDeclaringTypeName ; this . isStatic = contextIsStatic ; this . isConstructorCall = contextIsConstructorCall ; deployCodeSnippetClassIfNeeded ( requestor ) ; try { class ForwardingRequestor implements IRequestor { boolean hasErrors = false ; public boolean acceptClassFiles ( ClassFile [ ] classFiles , char [ ] codeSnippetClassName ) { return requestor . acceptClassFiles ( classFiles , codeSnippetClassName ) ; } public void acceptProblem ( CategorizedProblem problem , char [ ] fragmentSource , int fragmentKind ) { requestor . acceptProblem ( problem , fragmentSource , fragmentKind ) ; if ( problem . isError ( ) ) { this . hasErrors = true ; } } } ForwardingRequestor forwardingRequestor = new ForwardingRequestor ( ) ; if ( this . varsChanged ) { evaluateVariables ( environment , options , forwardingRequestor , problemFactory ) ; } if ( ! forwardingRequestor . hasErrors ) { Evaluator evaluator = new CodeSnippetEvaluator ( codeSnippet , this , environment , options , requestor , problemFactory ) ; ClassFile [ ] classes = evaluator . getClasses ( ) ; if ( classes != null && classes . length > <NUM_LIT:0> ) { char [ ] simpleClassName = evaluator . getClassName ( ) ; char [ ] pkgName = getPackageName ( ) ; char [ ] qualifiedClassName = pkgName . length == <NUM_LIT:0> ? simpleClassName : CharOperation . concat ( pkgName , simpleClassName , '<CHAR_LIT:.>' ) ; CODE_SNIPPET_COUNTER ++ ; if ( ! requestor . acceptClassFiles ( classes , qualifiedClassName ) ) throw new InstallException ( ) ; } } } finally { this . localVariableTypeNames = null ; this . localVariableNames = null ; this . localVariableModifiers = null ; this . declaringTypeName = null ; this . isStatic = true ; this . isConstructorCall = false ; } } public void evaluate ( char [ ] codeSnippet , INameEnvironment environment , Map options , final IRequestor requestor , IProblemFactory problemFactory ) throws InstallException { this . evaluate ( codeSnippet , null , null , null , null , true , false , environment , options , requestor , problemFactory ) ; } public void evaluateImports ( INameEnvironment environment , IRequestor requestor , IProblemFactory problemFactory ) { for ( int i = <NUM_LIT:0> ; i < this . imports . length ; i ++ ) { CategorizedProblem [ ] problems = new CategorizedProblem [ ] { null } ; char [ ] importDeclaration = this . imports [ i ] ; char [ ] [ ] splitDeclaration = CharOperation . splitOn ( '<CHAR_LIT:.>' , importDeclaration ) ; int splitLength = splitDeclaration . length ; if ( splitLength > <NUM_LIT:0> ) { char [ ] pkgName = splitDeclaration [ splitLength - <NUM_LIT:1> ] ; if ( pkgName . length == <NUM_LIT:1> && pkgName [ <NUM_LIT:0> ] == '<CHAR_LIT>' ) { char [ ] [ ] parentName ; switch ( splitLength ) { case <NUM_LIT:1> : parentName = null ; break ; case <NUM_LIT:2> : parentName = null ; pkgName = splitDeclaration [ splitLength - <NUM_LIT:2> ] ; break ; default : parentName = CharOperation . subarray ( splitDeclaration , <NUM_LIT:0> , splitLength - <NUM_LIT:2> ) ; pkgName = splitDeclaration [ splitLength - <NUM_LIT:2> ] ; } if ( ! environment . isPackage ( parentName , pkgName ) ) { String [ ] arguments = new String [ ] { new String ( importDeclaration ) } ; problems [ <NUM_LIT:0> ] = problemFactory . createProblem ( importDeclaration , IProblem . ImportNotFound , arguments , arguments , ProblemSeverities . Warning , <NUM_LIT:0> , importDeclaration . length - <NUM_LIT:1> , i , <NUM_LIT:0> ) ; } } else { if ( environment . findType ( splitDeclaration ) == null ) { String [ ] arguments = new String [ ] { new String ( importDeclaration ) } ; problems [ <NUM_LIT:0> ] = problemFactory . createProblem ( importDeclaration , IProblem . ImportNotFound , arguments , arguments , ProblemSeverities . Warning , <NUM_LIT:0> , importDeclaration . length - <NUM_LIT:1> , i , <NUM_LIT:0> ) ; } } } else { String [ ] arguments = new String [ ] { new String ( importDeclaration ) } ; problems [ <NUM_LIT:0> ] = problemFactory . createProblem ( importDeclaration , IProblem . ImportNotFound , arguments , arguments , ProblemSeverities . Warning , <NUM_LIT:0> , importDeclaration . length - <NUM_LIT:1> , i , <NUM_LIT:0> ) ; } if ( problems [ <NUM_LIT:0> ] != null ) { requestor . acceptProblem ( problems [ <NUM_LIT:0> ] , importDeclaration , EvaluationResult . T_IMPORT ) ; } } } public void evaluateVariable ( GlobalVariable variable , INameEnvironment environment , Map options , IRequestor requestor , IProblemFactory problemFactory ) throws InstallException { this . evaluate ( variable . getName ( ) , environment , options , requestor , problemFactory ) ; } public void evaluateVariables ( INameEnvironment environment , Map options , IRequestor requestor , IProblemFactory problemFactory ) throws InstallException { deployCodeSnippetClassIfNeeded ( requestor ) ; VariablesEvaluator evaluator = new VariablesEvaluator ( this , environment , options , requestor , problemFactory ) ; ClassFile [ ] classes = evaluator . getClasses ( ) ; if ( classes != null ) { if ( classes . length > <NUM_LIT:0> ) { Util . sort ( classes , new Util . Comparer ( ) { public int compare ( Object a , Object b ) { if ( a == b ) return <NUM_LIT:0> ; ClassFile enclosing = ( ( ClassFile ) a ) . enclosingClassFile ; while ( enclosing != null ) { if ( enclosing == b ) return <NUM_LIT:1> ; enclosing = enclosing . enclosingClassFile ; } return - <NUM_LIT:1> ; } } ) ; if ( ! requestor . acceptClassFiles ( classes , null ) ) { throw new InstallException ( ) ; } int count = this . variableCount ; GlobalVariable [ ] variablesCopy = new GlobalVariable [ count ] ; System . arraycopy ( this . variables , <NUM_LIT:0> , variablesCopy , <NUM_LIT:0> , count ) ; this . installedVars = new VariablesInfo ( evaluator . getPackageName ( ) , evaluator . getClassName ( ) , classes , variablesCopy , count ) ; VAR_CLASS_COUNTER ++ ; } this . varsChanged = false ; } } byte [ ] getCodeSnippetBytes ( ) { return new byte [ ] { - <NUM_LIT> , - <NUM_LIT:2> , - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:16> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:7> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:9> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:10> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:16> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT:9> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT:9> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:9> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:16> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:0> , <NUM_LIT:9> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:15> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:20> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:24> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:16> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:24> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:24> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:30> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:30> , <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:31> , <NUM_LIT:0> , <NUM_LIT:32> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:24> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT> } ; } public static String getCodeSnippetSource ( ) { return "<STR_LIT>" + "<STR_LIT:n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ; } public char [ ] [ ] getImports ( ) { return this . imports ; } public char [ ] getPackageName ( ) { return this . packageName ; } IBinaryType getRootCodeSnippetBinary ( ) { if ( this . codeSnippetBinary == null ) { this . codeSnippetBinary = new CodeSnippetSkeleton ( ) ; } return this . codeSnippetBinary ; } public char [ ] getVarClassName ( ) { if ( this . installedVars == null ) return CharOperation . NO_CHAR ; return CharOperation . concat ( this . installedVars . packageName , this . installedVars . className , '<CHAR_LIT:.>' ) ; } public GlobalVariable newVariable ( char [ ] typeName , char [ ] name , char [ ] initializer ) { GlobalVariable var = new GlobalVariable ( typeName , name , initializer ) ; if ( this . variableCount >= this . variables . length ) System . arraycopy ( this . variables , <NUM_LIT:0> , this . variables = new GlobalVariable [ this . variableCount * <NUM_LIT:2> ] , <NUM_LIT:0> , this . variableCount ) ; this . variables [ this . variableCount ++ ] = var ; this . varsChanged = true ; return var ; } public void select ( char [ ] codeSnippet , int selectionSourceStart , int selectionSourceEnd , SearchableEnvironment environment , ISelectionRequestor requestor , Map options , WorkingCopyOwner owner ) { final char [ ] className = "<STR_LIT>" . toCharArray ( ) ; final long complianceVersion = CompilerOptions . versionToJdkLevel ( options . get ( JavaCore . COMPILER_COMPLIANCE ) ) ; final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper ( codeSnippet , this . packageName , this . imports , className , this . installedVars == null ? null : this . installedVars . className , this . localVariableNames , this . localVariableTypeNames , this . localVariableModifiers , this . declaringTypeName , this . lineSeparator , complianceVersion ) ; ICompilationUnit sourceUnit = new ICompilationUnit ( ) { public char [ ] getFileName ( ) { return CharOperation . concat ( className , Util . defaultJavaExtension ( ) . toCharArray ( ) ) ; } public char [ ] getContents ( ) { return mapper . getCUSource ( EvaluationContext . this . lineSeparator ) ; } public char [ ] getMainTypeName ( ) { return className ; } public char [ ] [ ] getPackageName ( ) { return null ; } } ; SelectionEngine engine = new SelectionEngine ( environment , mapper . getSelectionRequestor ( requestor ) , options , owner ) ; engine . select ( sourceUnit , mapper . startPosOffset + selectionSourceStart , mapper . startPosOffset + selectionSourceEnd ) ; } public void setImports ( char [ ] [ ] imports ) { this . imports = imports ; this . varsChanged = true ; } public void setLineSeparator ( String lineSeparator ) { this . lineSeparator = lineSeparator ; } public void setPackageName ( char [ ] packageName ) { this . packageName = packageName ; this . varsChanged = true ; } } </s>
<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . internal . compiler . ast . Assignment ; import org . eclipse . jdt . internal . compiler . ast . CompoundAssignment ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . FieldReference ; import org . eclipse . jdt . internal . compiler . ast . IntLiteral ; import org . eclipse . jdt . internal . compiler . codegen . CodeStream ; import org . eclipse . jdt . internal . compiler . codegen . Opcodes ; import org . eclipse . jdt . internal . compiler . flow . FlowInfo ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; public class CodeSnippetFieldReference extends FieldReference implements ProblemReasons , EvaluationConstants { EvaluationContext evaluationContext ; FieldBinding delegateThis ; public CodeSnippetFieldReference ( char [ ] source , long pos , EvaluationContext evaluationContext ) { super ( source , pos ) ; this . evaluationContext = evaluationContext ; } public void generateAssignment ( BlockScope currentScope , CodeStream codeStream , Assignment assignment , boolean valueRequired ) { FieldBinding codegenBinding = this . binding . original ( ) ; if ( codegenBinding . canBeSeenBy ( this . actualReceiverType , this , currentScope ) ) { this . receiver . generateCode ( currentScope , codeStream , ! codegenBinding . isStatic ( ) ) ; assignment . expression . generateCode ( currentScope , codeStream , true ) ; fieldStore ( currentScope , codeStream , codegenBinding , null , this . actualReceiverType , this . receiver . isImplicitThis ( ) , valueRequired ) ; } else { codeStream . generateEmulationForField ( codegenBinding ) ; this . receiver . generateCode ( currentScope , codeStream , ! codegenBinding . isStatic ( ) ) ; if ( codegenBinding . isStatic ( ) ) { codeStream . aconst_null ( ) ; } assignment . expression . generateCode ( currentScope , codeStream , true ) ; if ( valueRequired ) { switch ( codegenBinding . type . id ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2_x2 ( ) ; break ; default : codeStream . dup_x2 ( ) ; break ; } } codeStream . generateEmulatedWriteAccessForField ( codegenBinding ) ; } if ( valueRequired ) { codeStream . generateImplicitConversion ( assignment . implicitConversion ) ; } } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; if ( this . constant != Constant . NotAConstant ) { if ( valueRequired ) { codeStream . generateConstant ( this . constant , this . implicitConversion ) ; } } else { FieldBinding codegenBinding = this . binding . original ( ) ; boolean isStatic = codegenBinding . isStatic ( ) ; this . receiver . generateCode ( currentScope , codeStream , ! isStatic ) ; if ( valueRequired ) { Constant fieldConstant = codegenBinding . constant ( ) ; if ( fieldConstant == Constant . NotAConstant ) { if ( codegenBinding . declaringClass == null ) { codeStream . arraylength ( ) ; } else { if ( codegenBinding . canBeSeenBy ( this . actualReceiverType , this , currentScope ) ) { TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , codegenBinding , this . actualReceiverType , this . receiver . isImplicitThis ( ) ) ; if ( isStatic ) { codeStream . fieldAccess ( Opcodes . OPC_getstatic , codegenBinding , constantPoolDeclaringClass ) ; } else { codeStream . fieldAccess ( Opcodes . OPC_getfield , codegenBinding , constantPoolDeclaringClass ) ; } } else { if ( isStatic ) { codeStream . aconst_null ( ) ; } codeStream . generateEmulatedReadAccessForField ( codegenBinding ) ; } } codeStream . generateImplicitConversion ( this . implicitConversion ) ; } else { if ( ! isStatic ) { codeStream . invokeObjectGetClass ( ) ; codeStream . pop ( ) ; } codeStream . generateConstant ( fieldConstant , this . implicitConversion ) ; } } else { if ( ! isStatic ) { codeStream . invokeObjectGetClass ( ) ; codeStream . pop ( ) ; } } } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public void generateCompoundAssignment ( BlockScope currentScope , CodeStream codeStream , Expression expression , int operator , int assignmentImplicitConversion , boolean valueRequired ) { boolean isStatic ; FieldBinding codegenBinding = this . binding . original ( ) ; if ( codegenBinding . canBeSeenBy ( this . actualReceiverType , this , currentScope ) ) { this . receiver . generateCode ( currentScope , codeStream , ! ( isStatic = codegenBinding . isStatic ( ) ) ) ; TypeBinding constantPoolDeclaringClass = CodeStream . getConstantPoolDeclaringClass ( currentScope , codegenBinding , this . actualReceiverType , this . receiver . isImplicitThis ( ) ) ; if ( isStatic ) { codeStream . fieldAccess ( Opcodes . OPC_getstatic , codegenBinding , constantPoolDeclaringClass ) ; } else { codeStream . dup ( ) ; codeStream . fieldAccess ( Opcodes . OPC_getfield , codegenBinding , constantPoolDeclaringClass ) ; } int operationTypeID ; switch ( operationTypeID = ( this . implicitConversion & IMPLICIT_CONVERSION_MASK ) > > <NUM_LIT:4> ) { case T_JavaLangString : case T_JavaLangObject : case T_undefined : codeStream . generateStringConcatenationAppend ( currentScope , null , expression ) ; break ; default : codeStream . generateImplicitConversion ( this . implicitConversion ) ; if ( expression == IntLiteral . One ) { codeStream . generateConstant ( expression . constant , this . implicitConversion ) ; } else { expression . generateCode ( currentScope , codeStream , true ) ; } codeStream . sendOperator ( operator , operationTypeID ) ; codeStream . generateImplicitConversion ( assignmentImplicitConversion ) ; } fieldStore ( currentScope , codeStream , codegenBinding , null , this . actualReceiverType , this . receiver . isImplicitThis ( ) , valueRequired ) ; } else { this . receiver . generateCode ( currentScope , codeStream , ! ( isStatic = codegenBinding . isStatic ( ) ) ) ; if ( isStatic ) { codeStream . generateEmulationForField ( codegenBinding ) ; codeStream . aconst_null ( ) ; codeStream . aconst_null ( ) ; codeStream . generateEmulatedReadAccessForField ( codegenBinding ) ; } else { codeStream . generateEmulationForField ( this . binding ) ; this . receiver . generateCode ( currentScope , codeStream , ! isStatic ) ; codeStream . dup ( ) ; codeStream . generateEmulatedReadAccessForField ( codegenBinding ) ; } int operationTypeID ; if ( ( operationTypeID = ( this . implicitConversion & IMPLICIT_CONVERSION_MASK ) > > <NUM_LIT:4> ) == T_JavaLangString ) { codeStream . generateStringConcatenationAppend ( currentScope , null , expression ) ; } else { codeStream . generateImplicitConversion ( this . implicitConversion ) ; if ( expression == IntLiteral . One ) { codeStream . generateConstant ( expression . constant , this . implicitConversion ) ; } else { expression . generateCode ( currentScope , codeStream , true ) ; } codeStream . sendOperator ( operator , operationTypeID ) ; codeStream . generateImplicitConversion ( assignmentImplicitConversion ) ; } if ( valueRequired ) { if ( ( codegenBinding . type == TypeBinding . LONG ) || ( codegenBinding . type == TypeBinding . DOUBLE ) ) { codeStream . dup2_x2 ( ) ; } else { codeStream . dup_x2 ( ) ; } } codeStream . generateEmulatedWriteAccessForField ( codegenBinding ) ; } } public void generatePostIncrement ( BlockScope currentScope , CodeStream codeStream , CompoundAssignment postIncrement , boolean valueRequired ) { boolean isStatic ; FieldBinding codegenBinding = this . binding . original ( ) ; if ( codegenBinding . canBeSeenBy ( this . actualReceiverType , this , currentScope ) ) { super . generatePostIncrement ( currentScope , codeStream , postIncrement , valueRequired ) ; } else { this . receiver . generateCode ( currentScope , codeStream , ! ( isStatic = codegenBinding . isStatic ( ) ) ) ; if ( isStatic ) { codeStream . aconst_null ( ) ; } codeStream . dup ( ) ; codeStream . generateEmulatedReadAccessForField ( codegenBinding ) ; int typeID ; switch ( typeID = codegenBinding . type . id ) { case TypeIds . T_long : case TypeIds . T_double : if ( valueRequired ) { codeStream . dup2_x1 ( ) ; } codeStream . dup2_x1 ( ) ; codeStream . pop2 ( ) ; break ; default : if ( valueRequired ) { codeStream . dup_x1 ( ) ; } codeStream . dup_x1 ( ) ; codeStream . pop ( ) ; break ; } codeStream . generateEmulationForField ( codegenBinding ) ; codeStream . swap ( ) ; switch ( typeID ) { case TypeIds . T_long : case TypeIds . T_double : codeStream . dup2_x2 ( ) ; break ; default : codeStream . dup2_x1 ( ) ; break ; } codeStream . pop2 ( ) ; codeStream . generateConstant ( postIncrement . expression . constant , this . implicitConversion ) ; codeStream . sendOperator ( postIncrement . operator , codegenBinding . type . id ) ; codeStream . generateImplicitConversion ( postIncrement . preAssignImplicitConversion ) ; codeStream . generateEmulatedWriteAccessForField ( codegenBinding ) ; } } public void manageSyntheticAccessIfNecessary ( BlockScope currentScope , FlowInfo flowInfo , boolean isReadAccess ) { if ( ( flowInfo . tagBits & FlowInfo . UNREACHABLE_OR_DEAD ) != <NUM_LIT:0> ) return ; } public TypeBinding resolveType ( BlockScope scope ) { this . actualReceiverType = this . receiver . resolveType ( scope ) ; if ( this . actualReceiverType == null ) { this . constant = Constant . NotAConstant ; return null ; } this . binding = scope . getField ( this . actualReceiverType , this . token , this ) ; FieldBinding firstAttempt = this . binding ; boolean isNotVisible = false ; if ( ! this . binding . isValidBinding ( ) ) { if ( this . binding instanceof ProblemFieldBinding && ( ( ProblemFieldBinding ) this . binding ) . problemId ( ) == NotVisible ) { isNotVisible = true ; if ( this . evaluationContext . declaringTypeName != null ) { this . delegateThis = scope . getField ( scope . enclosingSourceType ( ) , DELEGATE_THIS , this ) ; if ( this . delegateThis == null ) { this . constant = Constant . NotAConstant ; scope . problemReporter ( ) . invalidField ( this , this . actualReceiverType ) ; return null ; } this . actualReceiverType = this . delegateThis . type ; } else { this . constant = Constant . NotAConstant ; scope . problemReporter ( ) . invalidField ( this , this . actualReceiverType ) ; return null ; } CodeSnippetScope localScope = new CodeSnippetScope ( scope ) ; this . binding = localScope . getFieldForCodeSnippet ( this . delegateThis . type , this . token , this ) ; } } if ( ! this . binding . isValidBinding ( ) ) { this . constant = Constant . NotAConstant ; if ( isNotVisible ) { this . binding = firstAttempt ; } scope . problemReporter ( ) . invalidField ( this , this . actualReceiverType ) ; return null ; } if ( isFieldUseDeprecated ( this . binding , scope , this . bits ) ) { scope . problemReporter ( ) . deprecatedField ( this . binding , this ) ; } this . constant = this . receiver . isImplicitThis ( ) ? this . binding . constant ( ) : Constant . NotAConstant ; if ( ! this . receiver . isThis ( ) ) { this . constant = Constant . NotAConstant ; } return this . resolvedType = this . binding . type ; } } </s>