text
stringlengths 30
1.67M
|
|---|
<s> package org . codehaus . groovy . m2eclipse ; import org . apache . maven . model . Dependency ; import org . apache . maven . model . Plugin ; import org . apache . maven . model . PluginExecution ; import org . apache . maven . project . MavenProject ; import org . codehaus . groovy . eclipse . core . model . GroovyRuntime ; import org . codehaus . jdt . groovy . model . GroovyNature ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IProjectDescription ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . Path ; 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 . m2e . core . project . IMavenProjectFacade ; import org . eclipse . m2e . core . project . configurator . ProjectConfigurationRequest ; import org . eclipse . m2e . jdt . IClasspathDescriptor ; import org . eclipse . m2e . jdt . IJavaProjectConfigurator ; import org . eclipse . m2e . jdt . internal . AbstractJavaProjectConfigurator ; public class GroovyProjectConfigurator extends AbstractJavaProjectConfigurator implements IJavaProjectConfigurator { @ Override public void configure ( ProjectConfigurationRequest request , IProgressMonitor monitor ) throws CoreException { super . configure ( request , monitor ) ; IProject project = request . getProject ( ) ; if ( getSourceType ( request . getMavenProjectFacade ( ) ) != null ) { if ( ! project . hasNature ( GroovyNature . GROOVY_NATURE ) ) { if ( ! project . hasNature ( JavaCore . NATURE_ID ) ) { addJavaNature ( project ) ; } GroovyRuntime . addGroovyNature ( project ) ; } IJavaProject javaProject = JavaCore . create ( project ) ; if ( ! GroovyRuntime . hasClasspathContainer ( javaProject , GroovyRuntime . DSLD_CONTAINER_ID ) ) { GroovyRuntime . addLibraryToClasspath ( javaProject , GroovyRuntime . DSLD_CONTAINER_ID , false ) ; } } else { GroovyRuntime . removeGroovyNature ( project ) ; } } public void configureClasspath ( IMavenProjectFacade facade , IClasspathDescriptor classpath , IProgressMonitor monitor ) throws CoreException { SourceType sourceType = getSourceType ( facade ) ; if ( sourceType != null ) { IJavaProject javaProject = JavaCore . create ( facade . getProject ( ) ) ; IPath projectPath = facade . getFullPath ( ) ; if ( sourceType == SourceType . TEST || sourceType == SourceType . BOTH ) { IPath testPath = projectPath . append ( "<STR_LIT>" ) ; IPath testOutPath = projectPath . append ( "<STR_LIT>" ) ; if ( ! hasEntry ( javaProject , testPath ) ) { GroovyRuntime . addClassPathEntryToFront ( javaProject , JavaCore . newSourceEntry ( testPath , new Path [ <NUM_LIT:0> ] , testOutPath ) ) ; } } if ( sourceType == SourceType . MAIN || sourceType == SourceType . BOTH ) { IPath sourcePath = projectPath . append ( "<STR_LIT>" ) ; IPath sourceOutPath = projectPath . append ( "<STR_LIT>" ) ; if ( ! hasEntry ( javaProject , sourcePath ) ) { GroovyRuntime . addClassPathEntryToFront ( javaProject , JavaCore . newSourceEntry ( sourcePath , new Path [ <NUM_LIT:0> ] , sourceOutPath ) ) ; } } IClasspathEntry [ ] allEntries = javaProject . getRawClasspath ( ) ; for ( IClasspathEntry entry : allEntries ) { if ( entry . getPath ( ) . equals ( javaProject . getProject ( ) . getFolder ( "<STR_LIT>" ) . getFullPath ( ) ) ) { GroovyRuntime . removeClassPathEntry ( javaProject , entry ) ; break ; } } } } private boolean hasEntry ( IJavaProject javaProject , IPath path ) throws JavaModelException { IClasspathEntry [ ] entries = javaProject . getRawClasspath ( ) ; for ( IClasspathEntry entry : entries ) { if ( entry . getPath ( ) . equals ( path ) ) { return true ; } } return false ; } public void configureRawClasspath ( ProjectConfigurationRequest request , IClasspathDescriptor classpath , IProgressMonitor monitor ) throws CoreException { } private SourceType getSourceType ( IMavenProjectFacade facade ) { MavenProject mavenProject = facade . getMavenProject ( ) ; Plugin plugin = getGMavenPlugin ( mavenProject ) ; if ( plugin != null ) { return getSourceTypeInGMavenProject ( plugin ) ; } if ( compilerPluginUsesGroovyEclipseAdapter ( mavenProject ) ) { return getSourceTypeInGECProject ( facade ) ; } return null ; } private SourceType getSourceTypeInGMavenProject ( Plugin plugin ) { SourceType result = SourceType . NONE ; if ( plugin != null && plugin . getExecutions ( ) != null && ! plugin . getExecutions ( ) . isEmpty ( ) ) { for ( PluginExecution execution : plugin . getExecutions ( ) ) { if ( execution . getGoals ( ) . contains ( COMPILE ) ) { switch ( result ) { case NONE : result = SourceType . MAIN ; break ; case TEST : result = SourceType . BOTH ; break ; } } if ( execution . getGoals ( ) . contains ( TEST_COMPILE ) ) { switch ( result ) { case NONE : result = SourceType . TEST ; break ; case MAIN : result = SourceType . BOTH ; break ; } } } } return result ; } private SourceType getSourceTypeInGECProject ( IMavenProjectFacade facade ) { IProject project = facade . getProject ( ) ; boolean srcMainGroovy = project . getFolder ( "<STR_LIT>" ) . exists ( ) ; boolean srcTestGroovy = project . getFolder ( "<STR_LIT>" ) . exists ( ) ; if ( srcMainGroovy ) { if ( srcTestGroovy ) { return SourceType . BOTH ; } else { return SourceType . MAIN ; } } else if ( srcTestGroovy ) { return SourceType . TEST ; } else { return SourceType . NONE ; } } private Plugin getGMavenPlugin ( MavenProject mavenProject ) { Plugin p = mavenProject . getPlugin ( "<STR_LIT>" ) ; if ( p == null ) { p = mavenProject . getPlugin ( "<STR_LIT>" ) ; } return p ; } private boolean compilerPluginUsesGroovyEclipseAdapter ( MavenProject mavenProject ) { for ( Plugin buildPlugin : mavenProject . getBuildPlugins ( ) ) { if ( "<STR_LIT>" . equals ( buildPlugin . getArtifactId ( ) ) && "<STR_LIT>" . equals ( buildPlugin . getGroupId ( ) ) ) { for ( Dependency dependency : buildPlugin . getDependencies ( ) ) { if ( "<STR_LIT>" . equals ( dependency . getArtifactId ( ) ) && "<STR_LIT>" . equals ( dependency . getGroupId ( ) ) ) { return true ; } } } } return false ; } private static final String COMPILE = "<STR_LIT>" ; private static final String TEST_COMPILE = "<STR_LIT>" ; private enum SourceType { MAIN , TEST , BOTH , NONE } public static void addJavaNature ( final IProject project ) throws CoreException { final IProjectDescription description = project . getDescription ( ) ; final String [ ] ids = description . getNatureIds ( ) ; final String [ ] newIds = new String [ ids == null ? <NUM_LIT:1> : ids . length + <NUM_LIT:1> ] ; newIds [ <NUM_LIT:0> ] = JavaCore . NATURE_ID ; if ( ids != null ) { for ( int i = <NUM_LIT:1> ; i < newIds . length ; i ++ ) { newIds [ i ] = ids [ i - <NUM_LIT:1> ] ; } } description . setNatureIds ( newIds ) ; project . setDescription ( description , null ) ; } } </s>
|
<s> package org . codehaus . groovy . eclipse . compiler ; import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . PrintWriter ; import java . io . StringReader ; import java . io . UnsupportedEncodingException ; import java . net . URL ; import java . net . URLDecoder ; import java . security . CodeSource ; import java . security . ProtectionDomain ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashSet ; import java . util . List ; import java . util . Map . Entry ; import java . util . NoSuchElementException ; import java . util . Properties ; import java . util . Set ; import java . util . StringTokenizer ; import org . codehaus . plexus . compiler . AbstractCompiler ; import org . codehaus . plexus . compiler . CompilerConfiguration ; import org . codehaus . plexus . compiler . CompilerError ; import org . codehaus . plexus . compiler . CompilerException ; import org . codehaus . plexus . compiler . CompilerOutputStyle ; import org . codehaus . plexus . compiler . util . scan . InclusionScanException ; import org . codehaus . plexus . compiler . util . scan . SourceInclusionScanner ; import org . codehaus . plexus . compiler . util . scan . StaleSourceScanner ; import org . codehaus . plexus . compiler . util . scan . mapping . SourceMapping ; import org . codehaus . plexus . compiler . util . scan . mapping . SuffixMapping ; import org . codehaus . plexus . util . FileUtils ; import org . codehaus . plexus . util . Os ; import org . codehaus . plexus . util . StringUtils ; import org . codehaus . plexus . util . cli . CommandLineException ; import org . codehaus . plexus . util . cli . CommandLineUtils ; import org . codehaus . plexus . util . cli . Commandline ; import org . eclipse . jdt . core . compiler . CompilationProgress ; import org . eclipse . jdt . internal . compiler . batch . Main ; public class GroovyEclipseCompiler extends AbstractCompiler { private static final String [ ] WARNING_PREFIXES = { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ; private static final String [ ] NOTE_PREFIXES = { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ; private static final String JAVA_AGENT_CLASS_PARAM_NAME = "<STR_LIT>" ; private String javaAgentClass = "<STR_LIT>" ; private class Progress extends CompilationProgress { private int count = <NUM_LIT:0> ; public void begin ( int remainingWork ) { } public void done ( ) { if ( verbose ) { getLogger ( ) . info ( "<STR_LIT>" + count + "<STR_LIT>" ) ; } } public boolean isCanceled ( ) { return false ; } public void setTaskName ( String newTaskName ) { } public void worked ( int workIncrement , int remainingWork ) { if ( verbose ) { String file = remainingWork == <NUM_LIT:1> ? "<STR_LIT:file>" : "<STR_LIT>" ; getLogger ( ) . info ( remainingWork + "<STR_LIT:U+0020>" + file + "<STR_LIT>" ) ; count ++ ; } } } boolean verbose ; public GroovyEclipseCompiler ( ) { super ( CompilerOutputStyle . ONE_OUTPUT_FILE_PER_INPUT_FILE , "<STR_LIT>" , "<STR_LIT:.class>" , null ) ; } @ SuppressWarnings ( "<STR_LIT:rawtypes>" ) public List compile ( CompilerConfiguration config ) throws CompilerException { String [ ] args = createCommandLine ( config ) ; if ( args . length == <NUM_LIT:0> ) { getLogger ( ) . info ( "<STR_LIT>" ) ; return Collections . emptyList ( ) ; } List < CompilerError > messages ; if ( config . isFork ( ) ) { String executable = config . getExecutable ( ) ; if ( StringUtils . isEmpty ( executable ) ) { try { executable = getJavaExecutable ( ) ; } catch ( IOException e ) { getLogger ( ) . warn ( "<STR_LIT>" ) ; executable = "<STR_LIT>" ; } } String groovyEclipseLocation = getGroovyEclipseBatchLocation ( ) ; messages = compileOutOfProcess ( config , executable , groovyEclipseLocation , args ) ; } else { Progress progress = new Progress ( ) ; Main main = new Main ( new PrintWriter ( System . out ) , new PrintWriter ( System . err ) , false , null , progress ) ; boolean result = main . compile ( args ) ; messages = formatResult ( main , result ) ; } return messages ; } private File [ ] recalculateStaleFiles ( CompilerConfiguration config ) throws CompilerException { config . setSourceFiles ( null ) ; long staleMillis = <NUM_LIT:0> ; Set < String > includes = config . getIncludes ( ) ; if ( includes == null || includes . isEmpty ( ) ) { includes = Collections . singleton ( "<STR_LIT>" ) ; } StaleSourceScanner scanner = new StaleSourceScanner ( staleMillis , includes , config . getExcludes ( ) ) ; Set < File > staleSources = computeStaleSources ( config , scanner ) ; config . setSourceFiles ( staleSources ) ; File [ ] sourceFiles = staleSources . toArray ( new File [ <NUM_LIT:0> ] ) ; return sourceFiles ; } private boolean startsWithHyphen ( Object key ) { return null != key && String . class . isInstance ( key ) && ( ( String ) key ) . startsWith ( "<STR_LIT:->" ) ; } private List < CompilerError > formatResult ( Main main , boolean result ) { if ( result ) { return Collections . EMPTY_LIST ; } else { String error = main . globalErrorsCount == <NUM_LIT:1> ? "<STR_LIT:error>" : "<STR_LIT>" ; String warning = main . globalWarningsCount == <NUM_LIT:1> ? "<STR_LIT>" : "<STR_LIT>" ; return Collections . singletonList ( new CompilerError ( "<STR_LIT>" + main . globalErrorsCount + "<STR_LIT:U+0020>" + error + "<STR_LIT:U+0020andU+0020>" + main . globalWarningsCount + "<STR_LIT:U+0020>" + warning + "<STR_LIT:.>" , true ) ) ; } } private List < String > composeSourceFiles ( File [ ] sourceFiles ) { List < String > sources = new ArrayList < String > ( sourceFiles . length ) ; for ( int i = <NUM_LIT:0> ; i < sourceFiles . length ; i ++ ) { sources . add ( sourceFiles [ i ] . getPath ( ) ) ; } return sources ; } public String [ ] createCommandLine ( CompilerConfiguration config ) throws CompilerException { File destinationDir = new File ( config . getOutputLocation ( ) ) ; if ( ! destinationDir . exists ( ) ) { destinationDir . mkdirs ( ) ; } File workingDirectory = config . getWorkingDirectory ( ) ; if ( destinationDir . getName ( ) . equals ( "<STR_LIT>" ) ) { File srcMainGroovy = new File ( workingDirectory , "<STR_LIT>" ) ; if ( srcMainGroovy . exists ( ) && ! config . getSourceLocations ( ) . contains ( srcMainGroovy . getAbsolutePath ( ) ) ) { config . addSourceLocation ( srcMainGroovy . getAbsolutePath ( ) ) ; } } if ( destinationDir . getName ( ) . equals ( "<STR_LIT>" ) ) { File srcTestGroovy = new File ( workingDirectory , "<STR_LIT>" ) ; if ( srcTestGroovy . exists ( ) && ! config . getSourceLocations ( ) . contains ( srcTestGroovy . getAbsolutePath ( ) ) ) { config . addSourceLocation ( srcTestGroovy . getAbsolutePath ( ) ) ; } } File [ ] sourceFiles = recalculateStaleFiles ( config ) ; if ( sourceFiles . length == <NUM_LIT:0> ) { return new String [ <NUM_LIT:0> ] ; } getLogger ( ) . info ( "<STR_LIT>" ) ; getLogger ( ) . debug ( "<STR_LIT>" + sourceFiles . length + "<STR_LIT:U+0020>" + "<STR_LIT>" + ( sourceFiles . length == <NUM_LIT:1> ? "<STR_LIT>" : "<STR_LIT:s>" ) + "<STR_LIT:U+0020toU+0020>" + destinationDir . getAbsolutePath ( ) ) ; List < String > args = new ArrayList < String > ( ) ; String cp = super . getPathString ( config . getClasspathEntries ( ) ) ; verbose = config . isVerbose ( ) ; if ( verbose ) { getLogger ( ) . info ( "<STR_LIT>" + cp ) ; } if ( cp . length ( ) > <NUM_LIT:0> ) { args . add ( "<STR_LIT>" ) ; args . add ( cp ) ; } if ( config . getOutputLocation ( ) != null && config . getOutputLocation ( ) . length ( ) > <NUM_LIT:0> ) { args . add ( "<STR_LIT>" ) ; args . add ( config . getOutputLocation ( ) ) ; } if ( config . isDebug ( ) ) { if ( config . getDebugLevel ( ) != null && config . getDebugLevel ( ) . trim ( ) . length ( ) > <NUM_LIT:0> ) { args . add ( "<STR_LIT>" + config . getDebugLevel ( ) ) ; } else { args . add ( "<STR_LIT>" ) ; } } if ( "<STR_LIT:none>" . equals ( config . getProc ( ) ) ) { args . add ( "<STR_LIT>" ) ; } else if ( "<STR_LIT>" . equals ( config . getProc ( ) ) ) { args . add ( "<STR_LIT>" ) ; } if ( config . getGeneratedSourcesDirectory ( ) != null ) { args . add ( "<STR_LIT>" ) ; args . add ( config . getGeneratedSourcesDirectory ( ) . getAbsolutePath ( ) ) ; } String source = config . getSourceVersion ( ) ; args . add ( "<STR_LIT>" ) ; if ( source != null && source . length ( ) > <NUM_LIT:0> ) { args . add ( source ) ; } else { args . add ( "<STR_LIT>" ) ; } String target = config . getTargetVersion ( ) ; args . add ( "<STR_LIT>" ) ; if ( target != null && target . length ( ) > <NUM_LIT:0> ) { args . add ( target ) ; } else { args . add ( "<STR_LIT>" ) ; } if ( config . isShowDeprecation ( ) ) { args . add ( "<STR_LIT>" ) ; } if ( ! config . isShowWarnings ( ) ) { args . add ( "<STR_LIT>" ) ; } if ( config . getAnnotationProcessors ( ) != null ) { StringBuilder procArg = new StringBuilder ( ) ; for ( String proc : config . getAnnotationProcessors ( ) ) { if ( proc != null && proc . trim ( ) . length ( ) > <NUM_LIT:0> ) { procArg . append ( proc ) ; procArg . append ( "<STR_LIT:U+002C>" ) ; } } if ( procArg . length ( ) > <NUM_LIT:0> ) { args . add ( "<STR_LIT>" ) ; procArg . replace ( procArg . length ( ) - <NUM_LIT:1> , procArg . length ( ) , "<STR_LIT>" ) ; args . add ( "<STR_LIT:\">" + procArg . toString ( ) + "<STR_LIT:\">" ) ; } } if ( verbose ) { args . add ( "<STR_LIT>" ) ; } if ( config . getSourceEncoding ( ) != null ) { args . add ( "<STR_LIT>" ) ; args . add ( config . getSourceEncoding ( ) ) ; } for ( Entry < Object , Object > entry : ( Iterable < Entry < Object , Object > > ) config . getCustomCompilerArguments ( ) . entrySet ( ) ) { Object key = entry . getKey ( ) ; if ( startsWithHyphen ( key ) ) { if ( JAVA_AGENT_CLASS_PARAM_NAME . equals ( key ) ) { setJavaAgentClass ( ( String ) entry . getValue ( ) ) ; } else { args . add ( ( String ) key ) ; } } else if ( key != null && ! key . equals ( "<STR_LIT>" ) ) { args . add ( "<STR_LIT:->" + key ) ; if ( null != entry . getValue ( ) ) { args . add ( "<STR_LIT:\">" + entry . getValue ( ) + "<STR_LIT:\">" ) ; } } } args . addAll ( composeSourceFiles ( sourceFiles ) ) ; if ( verbose ) { getLogger ( ) . info ( "<STR_LIT>" + args ) ; } return args . toArray ( new String [ args . size ( ) ] ) ; } private Set < File > computeStaleSources ( CompilerConfiguration compilerConfiguration , SourceInclusionScanner scanner ) throws CompilerException { SourceMapping mappingGroovy = new SuffixMapping ( "<STR_LIT>" , "<STR_LIT:.class>" ) ; SourceMapping mappingJava = new SuffixMapping ( "<STR_LIT>" , "<STR_LIT:.class>" ) ; scanner . addSourceMapping ( mappingGroovy ) ; scanner . addSourceMapping ( mappingJava ) ; File outputDirectory = new File ( compilerConfiguration . getOutputLocation ( ) ) ; Set < File > staleSources = new HashSet < File > ( ) ; for ( String sourceRoot : ( List < String > ) compilerConfiguration . getSourceLocations ( ) ) { if ( verbose ) { getLogger ( ) . info ( "<STR_LIT>" + sourceRoot ) ; } File rootFile = new File ( sourceRoot ) ; if ( ! rootFile . isDirectory ( ) ) { continue ; } try { staleSources . addAll ( scanner . getIncludedSources ( rootFile , outputDirectory ) ) ; } catch ( InclusionScanException e ) { throw new CompilerException ( "<STR_LIT>" + sourceRoot + "<STR_LIT>" + "<STR_LIT>" , e ) ; } } return staleSources ; } private List < CompilerError > compileOutOfProcess ( CompilerConfiguration config , String executable , String groovyEclipseLocation , String [ ] args ) throws CompilerException { Commandline cli = new Commandline ( ) ; cli . setWorkingDirectory ( config . getWorkingDirectory ( ) . getAbsolutePath ( ) ) ; cli . setExecutable ( executable ) ; try { if ( ! StringUtils . isEmpty ( javaAgentClass ) ) { cli . addArguments ( new String [ ] { "<STR_LIT>" + getAdditionnalJavaAgentLocation ( ) } ) ; } else { getLogger ( ) . info ( "<STR_LIT>" ) ; } cli . addArguments ( new String [ ] { "<STR_LIT>" , groovyEclipseLocation } ) ; File argumentsFile = createFileWithArguments ( args , config . getOutputLocation ( ) ) ; cli . addArguments ( new String [ ] { "<STR_LIT:@>" + argumentsFile . getCanonicalPath ( ) . replace ( File . separatorChar , '<CHAR_LIT:/>' ) } ) ; if ( ! StringUtils . isEmpty ( config . getMaxmem ( ) ) ) { cli . addArguments ( new String [ ] { "<STR_LIT>" + config . getMaxmem ( ) } ) ; } if ( ! StringUtils . isEmpty ( config . getMeminitial ( ) ) ) { cli . addArguments ( new String [ ] { "<STR_LIT>" + config . getMeminitial ( ) } ) ; } } catch ( IOException e ) { throw new CompilerException ( "<STR_LIT>" , e ) ; } CommandLineUtils . StringStreamConsumer out = new CommandLineUtils . StringStreamConsumer ( ) ; CommandLineUtils . StringStreamConsumer err = new CommandLineUtils . StringStreamConsumer ( ) ; int returnCode ; List < CompilerError > messages ; if ( ( getLogger ( ) != null ) && getLogger ( ) . isDebugEnabled ( ) ) { File commandLineFile = new File ( config . getOutputLocation ( ) , "<STR_LIT>" + ( Os . isFamily ( Os . FAMILY_WINDOWS ) ? "<STR_LIT>" : "<STR_LIT>" ) ) ; try { FileUtils . fileWrite ( commandLineFile . getAbsolutePath ( ) , cli . toString ( ) . replaceAll ( "<STR_LIT:'>" , "<STR_LIT>" ) ) ; if ( ! Os . isFamily ( Os . FAMILY_WINDOWS ) ) { Runtime . getRuntime ( ) . exec ( new String [ ] { "<STR_LIT>" , "<STR_LIT>" , commandLineFile . getAbsolutePath ( ) } ) ; } } catch ( IOException e ) { if ( ( getLogger ( ) != null ) && getLogger ( ) . isWarnEnabled ( ) ) { getLogger ( ) . warn ( "<STR_LIT>" + commandLineFile . getName ( ) + "<STR_LIT>" , e ) ; } } } try { getLogger ( ) . info ( "<STR_LIT>" + groovyEclipseLocation ) ; returnCode = CommandLineUtils . executeCommandLine ( cli , out , err ) ; messages = parseModernStream ( returnCode , new BufferedReader ( new StringReader ( err . getOutput ( ) ) ) ) ; } catch ( CommandLineException e ) { throw new CompilerException ( "<STR_LIT>" , e ) ; } catch ( IOException e ) { throw new CompilerException ( "<STR_LIT>" , e ) ; } if ( ( returnCode != <NUM_LIT:0> ) && messages . isEmpty ( ) ) { if ( err . getOutput ( ) . length ( ) == <NUM_LIT:0> ) { throw new CompilerException ( "<STR_LIT>" + EOL + cli . toString ( ) ) ; } else { messages . add ( new CompilerError ( "<STR_LIT>" + EOL + err . getOutput ( ) , true ) ) ; } } return messages ; } List < CompilerError > parseModernStream ( int exitCode , BufferedReader input ) throws IOException { List < CompilerError > errors = new ArrayList < CompilerError > ( ) ; String line ; StringBuffer buffer ; while ( true ) { buffer = new StringBuffer ( ) ; do { line = input . readLine ( ) ; if ( line == null ) { return errors ; } if ( ( buffer . length ( ) == <NUM_LIT:0> ) && line . startsWith ( "<STR_LIT>" ) ) { errors . add ( new CompilerError ( line , true ) ) ; } else if ( ( buffer . length ( ) == <NUM_LIT:0> ) && isNote ( line ) ) { } else { buffer . append ( line ) ; buffer . append ( EOL ) ; } } while ( ! line . endsWith ( "<STR_LIT>" ) ) ; errors . add ( parseModernError ( exitCode , buffer . toString ( ) ) ) ; } } private static boolean isNote ( String line ) { for ( int i = <NUM_LIT:0> ; i < NOTE_PREFIXES . length ; i ++ ) { if ( line . startsWith ( NOTE_PREFIXES [ i ] ) ) { return true ; } } return false ; } static CompilerError parseModernError ( int exitCode , String error ) { StringTokenizer tokens = new StringTokenizer ( error , "<STR_LIT::>" ) ; boolean isError = exitCode != <NUM_LIT:0> ; StringBuffer msgBuffer ; try { boolean tokenIsAnInteger ; String previousToken = null ; String currentToken = null ; do { previousToken = currentToken ; currentToken = tokens . nextToken ( ) ; tokenIsAnInteger = true ; try { Integer . parseInt ( currentToken ) ; } catch ( NumberFormatException e ) { tokenIsAnInteger = false ; } } while ( ! tokenIsAnInteger ) ; String file = previousToken ; String lineIndicator = currentToken ; int startOfFileName = previousToken . lastIndexOf ( "<STR_LIT:]>" ) ; if ( startOfFileName > - <NUM_LIT:1> ) { file = file . substring ( startOfFileName + <NUM_LIT:2> ) ; } if ( file . length ( ) == <NUM_LIT:1> ) { file = new StringBuffer ( file ) . append ( "<STR_LIT::>" ) . append ( tokens . nextToken ( ) ) . toString ( ) ; } int line = Integer . parseInt ( lineIndicator ) ; msgBuffer = new StringBuffer ( ) ; String msg = tokens . nextToken ( EOL ) . substring ( <NUM_LIT:2> ) ; isError = exitCode != <NUM_LIT:0> ; String warnPrefix = getWarnPrefix ( msg ) ; if ( warnPrefix != null ) { isError = false ; msg = msg . substring ( warnPrefix . length ( ) ) ; } msgBuffer . append ( msg ) ; msgBuffer . append ( EOL ) ; String context = tokens . nextToken ( EOL ) ; String pointer = tokens . nextToken ( EOL ) ; if ( tokens . hasMoreTokens ( ) ) { msgBuffer . append ( context ) ; msgBuffer . append ( EOL ) ; msgBuffer . append ( pointer ) ; msgBuffer . append ( EOL ) ; context = tokens . nextToken ( EOL ) ; try { pointer = tokens . nextToken ( EOL ) ; } catch ( NoSuchElementException e ) { pointer = context ; context = null ; } } String message = msgBuffer . toString ( ) ; int startcolumn = pointer . indexOf ( "<STR_LIT>" ) ; int endcolumn = context == null ? startcolumn : context . indexOf ( "<STR_LIT:U+0020>" , startcolumn ) ; if ( endcolumn == - <NUM_LIT:1> ) { endcolumn = context . length ( ) ; } return new CompilerError ( file , isError , line , startcolumn , line , endcolumn , message . trim ( ) ) ; } catch ( NoSuchElementException e ) { return new CompilerError ( "<STR_LIT>" + error , isError ) ; } catch ( NumberFormatException e ) { return new CompilerError ( "<STR_LIT>" + error , isError ) ; } catch ( Exception e ) { return new CompilerError ( "<STR_LIT>" + error , isError ) ; } } private static String getWarnPrefix ( String msg ) { for ( int i = <NUM_LIT:0> ; i < WARNING_PREFIXES . length ; i ++ ) { if ( msg . startsWith ( WARNING_PREFIXES [ i ] ) ) { return WARNING_PREFIXES [ i ] ; } } return null ; } private File createFileWithArguments ( String [ ] args , String outputDirectory ) throws IOException { PrintWriter writer = null ; try { File tempFile ; if ( ( getLogger ( ) != null ) && getLogger ( ) . isDebugEnabled ( ) ) { tempFile = File . createTempFile ( GroovyEclipseCompiler . class . getName ( ) , "<STR_LIT>" , new File ( outputDirectory ) ) ; } else { tempFile = File . createTempFile ( GroovyEclipseCompiler . class . getName ( ) , "<STR_LIT>" ) ; tempFile . deleteOnExit ( ) ; } writer = new PrintWriter ( new FileWriter ( tempFile ) ) ; for ( int i = <NUM_LIT:0> ; i < args . length ; i ++ ) { String argValue = args [ i ] . replace ( File . separatorChar , '<CHAR_LIT:/>' ) ; writer . write ( "<STR_LIT:\">" + argValue + "<STR_LIT:\">" ) ; writer . println ( ) ; } writer . flush ( ) ; return tempFile ; } finally { if ( writer != null ) { writer . close ( ) ; } } } private String getAdditionnalJavaAgentLocation ( ) throws CompilerException { return getClassLocation ( getJavaAgentClass ( ) ) ; } private String getGroovyEclipseBatchLocation ( ) throws CompilerException { return getClassLocation ( Main . class . getName ( ) ) ; } private String getClassLocation ( String className ) throws CompilerException { Class < ? > cls ; try { cls = Class . forName ( className ) ; } catch ( ClassNotFoundException e ) { throw new CompilerException ( "<STR_LIT>" + className + "<STR_LIT>" ) ; } ProtectionDomain pDomain = cls . getProtectionDomain ( ) ; CodeSource cSource = pDomain . getCodeSource ( ) ; if ( cSource != null ) { URL loc = cSource . getLocation ( ) ; File file ; try { file = new File ( URLDecoder . decode ( loc . getPath ( ) , "<STR_LIT:UTF-8>" ) ) ; } catch ( UnsupportedEncodingException e ) { getLogger ( ) . warn ( "<STR_LIT>" + loc , e ) ; file = new File ( loc . getPath ( ) ) ; } getLogger ( ) . info ( "<STR_LIT>" + file . getPath ( ) + "<STR_LIT>" + className + "<STR_LIT:>>" ) ; return file . getPath ( ) ; } else { throw new CompilerException ( "<STR_LIT>" + className + "<STR_LIT>" ) ; } } private String getJavaExecutable ( ) throws IOException { String javaCommand = "<STR_LIT>" + ( Os . isFamily ( Os . FAMILY_WINDOWS ) ? "<STR_LIT>" : "<STR_LIT>" ) ; String javaHome = System . getProperty ( "<STR_LIT>" ) ; File javaExe ; if ( Os . isName ( "<STR_LIT>" ) ) { javaExe = new File ( javaHome + File . separator + "<STR_LIT>" + File . separator + "<STR_LIT>" , javaCommand ) ; } else if ( Os . isName ( "<STR_LIT>" ) ) { javaExe = new File ( javaHome + File . separator + "<STR_LIT>" , javaCommand ) ; } else { javaExe = new File ( javaHome + File . separator + "<STR_LIT>" + File . separator + "<STR_LIT>" , javaCommand ) ; } if ( ! javaExe . isFile ( ) ) { Properties env = CommandLineUtils . getSystemEnvVars ( ) ; javaHome = env . getProperty ( "<STR_LIT>" ) ; if ( StringUtils . isEmpty ( javaHome ) ) { throw new IOException ( "<STR_LIT>" ) ; } if ( ! new File ( javaHome ) . isDirectory ( ) ) { throw new IOException ( "<STR_LIT>" + javaHome + "<STR_LIT>" ) ; } javaExe = new File ( env . getProperty ( "<STR_LIT>" ) + File . separator + "<STR_LIT>" , javaCommand ) ; } if ( ! javaExe . isFile ( ) ) { throw new IOException ( "<STR_LIT>" + javaExe + "<STR_LIT>" ) ; } return javaExe . getAbsolutePath ( ) ; } public String getJavaAgentClass ( ) { return javaAgentClass ; } public void setJavaAgentClass ( String className ) { this . javaAgentClass = className ; } } </s>
|
<s> package org . codehaus . groovy . eclipse . compiler ; import org . apache . maven . plugin . AbstractMojo ; import org . apache . maven . plugin . MojoExecutionException ; import org . apache . maven . plugin . MojoFailureException ; import org . apache . maven . project . MavenProject ; public class AddGroovySourceFolders extends AbstractMojo { private MavenProject project ; public void execute ( ) throws MojoExecutionException , MojoFailureException { getLog ( ) . info ( "<STR_LIT>" ) ; this . project . addCompileSourceRoot ( project . getBasedir ( ) + "<STR_LIT>" ) ; getLog ( ) . info ( "<STR_LIT>" ) ; this . project . addTestCompileSourceRoot ( project . getBasedir ( ) + "<STR_LIT>" ) ; } } </s>
|
<s> import org . junit . Test ; import org . junit . Assert ; public class JavaTest { @ Test public void testMethod ( ) { JavaMain . main ( new String [ ] { } ) ; Assert . assertTrue ( true ) ; } } </s>
|
<s> import org . junit . Test ; import org . junit . Assert ; public class JavaTest { @ Test public void testMethod ( ) { JavaMain . main ( null ) ; Assert . assertTrue ( true ) ; } } </s>
|
<s> public class JavaMain { public static void main ( String [ ] args ) { new JavaHello ( ) . sayHello ( ) ; } } </s>
|
<s> interface Helloable { void sayHello ( ) ; } </s>
|
<s> class JavaHello implements Helloable { public void sayHello ( ) { System . out . println ( "<STR_LIT>" ) ; } } </s>
|
<s> public class JavaMain { public static void main ( String ... args ) { new GroovyHello ( ) . sayHello ( ) ; new JavaHello ( ) . sayHello ( ) ; } } </s>
|
<s> public class JavaHello implements Helloable { public void sayHello ( ) { System . out . println ( "<STR_LIT>" ) ; } } </s>
|
<s> package org . codehaus . groovy . eclipse . maven . testing ; import junit . framework . TestCase ; public class HelperTest extends TestCase { public void testHelper ( ) throws Exception { new Helper ( ) . help ( new Example ( ) ) ; } } </s>
|
<s> package org . codehaus . groovy . eclipse . maven . testing ; public class JavaClass { Example e ; Helper h ; private int unused ; } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; public abstract class RewriteEvent { public static final int INSERTED = <NUM_LIT:1> ; public static final int REMOVED = <NUM_LIT:2> ; public static final int REPLACED = <NUM_LIT:4> ; public static final int CHILDREN_CHANGED = <NUM_LIT:8> ; public static final int UNCHANGED = <NUM_LIT:0> ; public abstract int getChangeKind ( ) ; public abstract boolean isListRewrite ( ) ; public abstract Object getOriginalValue ( ) ; public abstract Object getNewValue ( ) ; public abstract RewriteEvent [ ] getChildren ( ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . text . edits . TextEditGroup ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . rewrite . ITrackedNodePosition ; import org . eclipse . jface . text . IRegion ; public class TrackedNodePosition implements ITrackedNodePosition { private final TextEditGroup group ; private final ASTNode node ; public TrackedNodePosition ( TextEditGroup group , ASTNode node ) { this . group = group ; this . node = node ; } public int getStartPosition ( ) { if ( this . group . isEmpty ( ) ) { return this . node . getStartPosition ( ) ; } IRegion coverage = TextEdit . getCoverage ( this . group . getTextEdits ( ) ) ; if ( coverage == null ) { return this . node . getStartPosition ( ) ; } return coverage . getOffset ( ) ; } public int getLength ( ) { if ( this . group . isEmpty ( ) ) { return this . node . getLength ( ) ; } IRegion coverage = TextEdit . getCoverage ( this . group . getTextEdits ( ) ) ; if ( coverage == null ) { return this . node . getLength ( ) ; } return coverage . getLength ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . text . edits . ISourceModifier ; import org . eclipse . text . edits . ReplaceEdit ; public class SourceModifier implements ISourceModifier { private final String destinationIndent ; private final int sourceIndentLevel ; private final int tabWidth ; private final int indentWidth ; public SourceModifier ( int sourceIndentLevel , String destinationIndent , int tabWidth , int indentWidth ) { this . destinationIndent = destinationIndent ; this . sourceIndentLevel = sourceIndentLevel ; this . tabWidth = tabWidth ; this . indentWidth = indentWidth ; } public ISourceModifier copy ( ) { return this ; } public ReplaceEdit [ ] getModifications ( String source ) { List result = new ArrayList ( ) ; int destIndentLevel = IndentManipulation . measureIndentUnits ( this . destinationIndent , this . tabWidth , this . indentWidth ) ; if ( destIndentLevel == this . sourceIndentLevel ) { return ( ReplaceEdit [ ] ) result . toArray ( new ReplaceEdit [ result . size ( ) ] ) ; } return IndentManipulation . getChangeIndentEdits ( source , this . sourceIndentLevel , this . tabWidth , this . indentWidth , this . destinationIndent ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . List ; import org . eclipse . jdt . core . dom . * ; import org . eclipse . jdt . internal . compiler . util . Util ; public class ASTRewriteFlattener extends ASTVisitor { static final int JLS2_INTERNAL = AST . JLS2 ; static final int JLS3_INTERNAL = AST . JLS3 ; public static String asString ( ASTNode node , RewriteEventStore store ) { ASTRewriteFlattener flattener = new ASTRewriteFlattener ( store ) ; node . accept ( flattener ) ; return flattener . getResult ( ) ; } protected StringBuffer result ; private RewriteEventStore store ; public ASTRewriteFlattener ( RewriteEventStore store ) { this . store = store ; this . result = new StringBuffer ( ) ; } public String getResult ( ) { return new String ( this . result . toString ( ) ) ; } public void reset ( ) { this . result . setLength ( <NUM_LIT:0> ) ; } public static void printModifiers ( int modifiers , StringBuffer buf ) { if ( Modifier . isPublic ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isProtected ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isPrivate ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isStatic ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isAbstract ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isFinal ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isSynchronized ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isVolatile ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isNative ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isStrictfp ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isTransient ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } } protected List getChildList ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( List ) getAttribute ( parent , childProperty ) ; } protected ASTNode getChildNode ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( ASTNode ) getAttribute ( parent , childProperty ) ; } protected int getIntAttribute ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( ( Integer ) getAttribute ( parent , childProperty ) ) . intValue ( ) ; } protected boolean getBooleanAttribute ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( ( Boolean ) getAttribute ( parent , childProperty ) ) . booleanValue ( ) ; } protected Object getAttribute ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return this . store . getNewValue ( parent , childProperty ) ; } protected void visitList ( ASTNode parent , StructuralPropertyDescriptor childProperty , String separator ) { List list = getChildList ( parent , childProperty ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { if ( separator != null && i > <NUM_LIT:0> ) { this . result . append ( separator ) ; } ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } } protected void visitList ( ASTNode parent , StructuralPropertyDescriptor childProperty , String separator , String lead , String post ) { List list = getChildList ( parent , childProperty ) ; if ( ! list . isEmpty ( ) ) { this . result . append ( lead ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { if ( separator != null && i > <NUM_LIT:0> ) { this . result . append ( separator ) ; } ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } this . result . append ( post ) ; } } public boolean visit ( AnonymousClassDeclaration node ) { this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , AnonymousClassDeclaration . BODY_DECLARATIONS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( ArrayAccess node ) { getChildNode ( node , ArrayAccess . ARRAY_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:[>' ) ; getChildNode ( node , ArrayAccess . INDEX_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:]>' ) ; return false ; } public boolean visit ( ArrayCreation node ) { this . result . append ( "<STR_LIT>" ) ; ArrayType arrayType = ( ArrayType ) getChildNode ( node , ArrayCreation . TYPE_PROPERTY ) ; Type elementType = ( Type ) getChildNode ( arrayType , ArrayType . COMPONENT_TYPE_PROPERTY ) ; int dimensions = <NUM_LIT:1> ; while ( elementType . isArrayType ( ) ) { dimensions ++ ; elementType = ( Type ) getChildNode ( elementType , ArrayType . COMPONENT_TYPE_PROPERTY ) ; } elementType . accept ( this ) ; List list = getChildList ( node , ArrayCreation . DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { this . result . append ( '<CHAR_LIT:[>' ) ; ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:]>' ) ; dimensions -- ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } ASTNode initializer = getChildNode ( node , ArrayCreation . INITIALIZER_PROPERTY ) ; if ( initializer != null ) { getChildNode ( node , ArrayCreation . INITIALIZER_PROPERTY ) . accept ( this ) ; } return false ; } public boolean visit ( ArrayInitializer node ) { this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , ArrayInitializer . EXPRESSIONS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( ArrayType node ) { getChildNode ( node , ArrayType . COMPONENT_TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT:[]>" ) ; return false ; } public boolean visit ( AssertStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , AssertStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; ASTNode message = getChildNode ( node , AssertStatement . MESSAGE_PROPERTY ) ; if ( message != null ) { this . result . append ( '<CHAR_LIT::>' ) ; message . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( Assignment node ) { getChildNode ( node , Assignment . LEFT_HAND_SIDE_PROPERTY ) . accept ( this ) ; this . result . append ( getAttribute ( node , Assignment . OPERATOR_PROPERTY ) . toString ( ) ) ; getChildNode ( node , Assignment . RIGHT_HAND_SIDE_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Block node ) { this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , Block . STATEMENTS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( BooleanLiteral node ) { if ( node . booleanValue ( ) == true ) { this . result . append ( "<STR_LIT:true>" ) ; } else { this . result . append ( "<STR_LIT:false>" ) ; } return false ; } public boolean visit ( BreakStatement node ) { this . result . append ( "<STR_LIT>" ) ; ASTNode label = getChildNode ( node , BreakStatement . LABEL_PROPERTY ) ; if ( label != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; label . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( CastExpression node ) { this . result . append ( '<CHAR_LIT:(>' ) ; getChildNode ( node , CastExpression . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , CastExpression . EXPRESSION_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( CatchClause node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , CatchClause . EXCEPTION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , CatchClause . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( CharacterLiteral node ) { this . result . append ( getAttribute ( node , CharacterLiteral . ESCAPED_VALUE_PROPERTY ) ) ; return false ; } public boolean visit ( ClassInstanceCreation node ) { ASTNode expression = getChildNode ( node , ClassInstanceCreation . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { getChildNode ( node , ClassInstanceCreation . NAME_PROPERTY ) . accept ( this ) ; } else { visitList ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; getChildNode ( node , ClassInstanceCreation . TYPE_PROPERTY ) . accept ( this ) ; } this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; ASTNode decl = getChildNode ( node , ClassInstanceCreation . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( decl != null ) { decl . accept ( this ) ; } return false ; } public boolean visit ( CompilationUnit node ) { ASTNode pack = getChildNode ( node , CompilationUnit . PACKAGE_PROPERTY ) ; if ( pack != null ) { pack . accept ( this ) ; } visitList ( node , CompilationUnit . IMPORTS_PROPERTY , null ) ; visitList ( node , CompilationUnit . TYPES_PROPERTY , null ) ; return false ; } public boolean visit ( ConditionalExpression node ) { getChildNode ( node , ConditionalExpression . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , ConditionalExpression . THEN_EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT::>' ) ; getChildNode ( node , ConditionalExpression . ELSE_EXPRESSION_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( ConstructorInvocation node ) { if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { visitList ( node , ConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } this . result . append ( "<STR_LIT>" ) ; visitList ( node , ConstructorInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ContinueStatement node ) { this . result . append ( "<STR_LIT>" ) ; ASTNode label = getChildNode ( node , ContinueStatement . LABEL_PROPERTY ) ; if ( label != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; label . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( DoStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , DoStatement . BODY_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , DoStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( EmptyStatement node ) { this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( ExpressionStatement node ) { getChildNode ( node , ExpressionStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( FieldAccess node ) { getChildNode ( node , FieldAccess . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; getChildNode ( node , FieldAccess . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( FieldDeclaration node ) { ASTNode javadoc = getChildNode ( node , FieldDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , FieldDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , FieldDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , FieldDeclaration . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , FieldDeclaration . FRAGMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( ForStatement node ) { this . result . append ( "<STR_LIT>" ) ; visitList ( node , ForStatement . INITIALIZERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:;>' ) ; ASTNode expression = getChildNode ( node , ForStatement . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; visitList ( node , ForStatement . UPDATERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , ForStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( IfStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , IfStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , IfStatement . THEN_STATEMENT_PROPERTY ) . accept ( this ) ; ASTNode elseStatement = getChildNode ( node , IfStatement . ELSE_STATEMENT_PROPERTY ) ; if ( elseStatement != null ) { this . result . append ( "<STR_LIT>" ) ; elseStatement . accept ( this ) ; } return false ; } public boolean visit ( ImportDeclaration node ) { this . result . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { if ( getBooleanAttribute ( node , ImportDeclaration . STATIC_PROPERTY ) ) { this . result . append ( "<STR_LIT>" ) ; } } getChildNode ( node , ImportDeclaration . NAME_PROPERTY ) . accept ( this ) ; if ( getBooleanAttribute ( node , ImportDeclaration . ON_DEMAND_PROPERTY ) ) { this . result . append ( "<STR_LIT>" ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( InfixExpression node ) { getChildNode ( node , InfixExpression . LEFT_OPERAND_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; String operator = getAttribute ( node , InfixExpression . OPERATOR_PROPERTY ) . toString ( ) ; this . result . append ( operator ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; getChildNode ( node , InfixExpression . RIGHT_OPERAND_PROPERTY ) . accept ( this ) ; List list = getChildList ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { this . result . append ( operator ) ; ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } return false ; } public boolean visit ( InstanceofExpression node ) { getChildNode ( node , InstanceofExpression . LEFT_OPERAND_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , InstanceofExpression . RIGHT_OPERAND_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Initializer node ) { ASTNode javadoc = getChildNode ( node , Initializer . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , Initializer . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , Initializer . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , Initializer . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Javadoc node ) { this . result . append ( "<STR_LIT>" ) ; List list = getChildList ( node , Javadoc . TAGS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { this . result . append ( "<STR_LIT>" ) ; ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( LabeledStatement node ) { getChildNode ( node , LabeledStatement . LABEL_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT::U+0020>" ) ; getChildNode ( node , LabeledStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( MethodDeclaration node ) { ASTNode javadoc = getChildNode ( node , MethodDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , MethodDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , MethodDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; visitList ( node , MethodDeclaration . TYPE_PARAMETERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } if ( ! getBooleanAttribute ( node , MethodDeclaration . CONSTRUCTOR_PROPERTY ) ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { getChildNode ( node , MethodDeclaration . RETURN_TYPE_PROPERTY ) . accept ( this ) ; } else { ASTNode returnType = getChildNode ( node , MethodDeclaration . RETURN_TYPE2_PROPERTY ) ; if ( returnType != null ) { returnType . accept ( this ) ; } else { this . result . append ( "<STR_LIT>" ) ; } } this . result . append ( '<CHAR_LIT:U+0020>' ) ; } getChildNode ( node , MethodDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , MethodDeclaration . PARAMETERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; int extraDims = getIntAttribute ( node , MethodDeclaration . EXTRA_DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extraDims ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } visitList ( node , MethodDeclaration . THROWN_EXCEPTIONS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , "<STR_LIT>" , Util . EMPTY_STRING ) ; ASTNode body = getChildNode ( node , MethodDeclaration . BODY_PROPERTY ) ; if ( body == null ) { this . result . append ( '<CHAR_LIT:;>' ) ; } else { body . accept ( this ) ; } return false ; } public boolean visit ( MethodInvocation node ) { ASTNode expression = getChildNode ( node , MethodInvocation . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { visitList ( node , MethodInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } getChildNode ( node , MethodInvocation . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , MethodInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( NullLiteral node ) { this . result . append ( "<STR_LIT:null>" ) ; return false ; } public boolean visit ( NumberLiteral node ) { this . result . append ( getAttribute ( node , NumberLiteral . TOKEN_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( PackageDeclaration node ) { if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { ASTNode javadoc = getChildNode ( node , PackageDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , PackageDeclaration . ANNOTATIONS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , PackageDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( ParenthesizedExpression node ) { this . result . append ( '<CHAR_LIT:(>' ) ; getChildNode ( node , ParenthesizedExpression . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( PostfixExpression node ) { getChildNode ( node , PostfixExpression . OPERAND_PROPERTY ) . accept ( this ) ; this . result . append ( getAttribute ( node , PostfixExpression . OPERATOR_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( PrefixExpression node ) { this . result . append ( getAttribute ( node , PrefixExpression . OPERATOR_PROPERTY ) . toString ( ) ) ; getChildNode ( node , PrefixExpression . OPERAND_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( PrimitiveType node ) { this . result . append ( getAttribute ( node , PrimitiveType . PRIMITIVE_TYPE_CODE_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( QualifiedName node ) { getChildNode ( node , QualifiedName . QUALIFIER_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; getChildNode ( node , QualifiedName . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( ReturnStatement node ) { this . result . append ( "<STR_LIT>" ) ; ASTNode expression = getChildNode ( node , ReturnStatement . EXPRESSION_PROPERTY ) ; if ( expression != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; expression . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( SimpleName node ) { this . result . append ( getAttribute ( node , SimpleName . IDENTIFIER_PROPERTY ) ) ; return false ; } public boolean visit ( SimpleType node ) { return true ; } public boolean visit ( SingleVariableDeclaration node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , SingleVariableDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , SingleVariableDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , SingleVariableDeclaration . TYPE_PROPERTY ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { if ( getBooleanAttribute ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) { this . result . append ( "<STR_LIT:...>" ) ; } } this . result . append ( '<CHAR_LIT:U+0020>' ) ; getChildNode ( node , SingleVariableDeclaration . NAME_PROPERTY ) . accept ( this ) ; int extraDimensions = getIntAttribute ( node , SingleVariableDeclaration . EXTRA_DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } ASTNode initializer = getChildNode ( node , SingleVariableDeclaration . INITIALIZER_PROPERTY ) ; if ( initializer != null ) { this . result . append ( '<CHAR_LIT:=>' ) ; initializer . accept ( this ) ; } return false ; } public boolean visit ( StringLiteral node ) { this . result . append ( getAttribute ( node , StringLiteral . ESCAPED_VALUE_PROPERTY ) ) ; return false ; } public boolean visit ( SuperConstructorInvocation node ) { ASTNode expression = getChildNode ( node , SuperConstructorInvocation . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { visitList ( node , SuperConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } this . result . append ( "<STR_LIT>" ) ; visitList ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SuperFieldAccess node ) { ASTNode qualifier = getChildNode ( node , SuperFieldAccess . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , SuperFieldAccess . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( SuperMethodInvocation node ) { ASTNode qualifier = getChildNode ( node , SuperMethodInvocation . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { visitList ( node , SuperMethodInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } getChildNode ( node , SuperMethodInvocation . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( SwitchCase node ) { ASTNode expression = getChildNode ( node , SwitchCase . EXPRESSION_PROPERTY ) ; if ( expression == null ) { this . result . append ( "<STR_LIT:default>" ) ; } else { this . result . append ( "<STR_LIT>" ) ; expression . accept ( this ) ; } this . result . append ( '<CHAR_LIT::>' ) ; return false ; } public boolean visit ( SwitchStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , SwitchStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , SwitchStatement . STATEMENTS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( SynchronizedStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , SynchronizedStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , SynchronizedStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( ThisExpression node ) { ASTNode qualifier = getChildNode ( node , ThisExpression . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ThrowStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , ThrowStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( TryStatement node ) { this . result . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS4 ) { visitList ( node , TryStatement . RESOURCES_PROPERTY , String . valueOf ( '<CHAR_LIT:;>' ) , String . valueOf ( '<CHAR_LIT:(>' ) , String . valueOf ( '<CHAR_LIT:)>' ) ) ; } getChildNode ( node , TryStatement . BODY_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , TryStatement . CATCH_CLAUSES_PROPERTY , null ) ; ASTNode finallyClause = getChildNode ( node , TryStatement . FINALLY_PROPERTY ) ; if ( finallyClause != null ) { this . result . append ( "<STR_LIT>" ) ; finallyClause . accept ( this ) ; } return false ; } public boolean visit ( TypeDeclaration node ) { int apiLevel = node . getAST ( ) . apiLevel ( ) ; ASTNode javadoc = getChildNode ( node , TypeDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( apiLevel == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , TypeDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , TypeDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } boolean isInterface = getBooleanAttribute ( node , TypeDeclaration . INTERFACE_PROPERTY ) ; this . result . append ( isInterface ? "<STR_LIT>" : "<STR_LIT>" ) ; getChildNode ( node , TypeDeclaration . NAME_PROPERTY ) . accept ( this ) ; if ( apiLevel >= JLS3_INTERNAL ) { visitList ( node , TypeDeclaration . TYPE_PARAMETERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } this . result . append ( '<CHAR_LIT:U+0020>' ) ; ChildPropertyDescriptor superClassProperty = ( apiLevel == JLS2_INTERNAL ) ? TypeDeclaration . SUPERCLASS_PROPERTY : TypeDeclaration . SUPERCLASS_TYPE_PROPERTY ; ASTNode superclass = getChildNode ( node , superClassProperty ) ; if ( superclass != null ) { this . result . append ( "<STR_LIT>" ) ; superclass . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; } ChildListPropertyDescriptor superInterfaceProperty = ( apiLevel == JLS2_INTERNAL ) ? TypeDeclaration . SUPER_INTERFACES_PROPERTY : TypeDeclaration . SUPER_INTERFACE_TYPES_PROPERTY ; String lead = isInterface ? "<STR_LIT>" : "<STR_LIT>" ; visitList ( node , superInterfaceProperty , String . valueOf ( '<CHAR_LIT:U+002C>' ) , lead , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , TypeDeclaration . BODY_DECLARATIONS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( TypeDeclarationStatement node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { getChildNode ( node , TypeDeclarationStatement . TYPE_DECLARATION_PROPERTY ) . accept ( this ) ; } else { getChildNode ( node , TypeDeclarationStatement . DECLARATION_PROPERTY ) . accept ( this ) ; } return false ; } public boolean visit ( TypeLiteral node ) { getChildNode ( node , TypeLiteral . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT:.class>" ) ; return false ; } public boolean visit ( UnionType node ) { visitList ( node , UnionType . TYPES_PROPERTY , "<STR_LIT>" , Util . EMPTY_STRING , Util . EMPTY_STRING ) ; return false ; } public boolean visit ( VariableDeclarationExpression node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , VariableDeclarationExpression . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , VariableDeclarationExpression . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , VariableDeclarationExpression . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , VariableDeclarationExpression . FRAGMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; return false ; } public boolean visit ( VariableDeclarationFragment node ) { getChildNode ( node , VariableDeclarationFragment . NAME_PROPERTY ) . accept ( this ) ; int extraDimensions = getIntAttribute ( node , VariableDeclarationFragment . EXTRA_DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } ASTNode initializer = getChildNode ( node , VariableDeclarationFragment . INITIALIZER_PROPERTY ) ; if ( initializer != null ) { this . result . append ( '<CHAR_LIT:=>' ) ; initializer . accept ( this ) ; } return false ; } public boolean visit ( VariableDeclarationStatement node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , VariableDeclarationStatement . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , VariableDeclarationStatement . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , VariableDeclarationStatement . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , VariableDeclarationStatement . FRAGMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( WhileStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , WhileStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , WhileStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( BlockComment node ) { return false ; } public boolean visit ( LineComment node ) { return false ; } public boolean visit ( MemberRef node ) { ASTNode qualifier = getChildNode ( node , MemberRef . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; } this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , MemberRef . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( MethodRef node ) { ASTNode qualifier = getChildNode ( node , MethodRef . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; } this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , MethodRef . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , MethodRef . PARAMETERS_PROPERTY , "<STR_LIT:U+002C>" ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( MethodRefParameter node ) { getChildNode ( node , MethodRefParameter . TYPE_PROPERTY ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { if ( getBooleanAttribute ( node , MethodRefParameter . VARARGS_PROPERTY ) ) { this . result . append ( "<STR_LIT:...>" ) ; } } ASTNode name = getChildNode ( node , MethodRefParameter . NAME_PROPERTY ) ; if ( name != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; name . accept ( this ) ; } return false ; } public boolean visit ( TagElement node ) { Object tagName = getAttribute ( node , TagElement . TAG_NAME_PROPERTY ) ; if ( tagName != null ) { this . result . append ( ( String ) tagName ) ; } List list = getChildList ( node , TagElement . FRAGMENTS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { if ( i > <NUM_LIT:0> || tagName != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; } ASTNode curr = ( ASTNode ) list . get ( i ) ; if ( curr instanceof TagElement ) { this . result . append ( '<CHAR_LIT>' ) ; curr . accept ( this ) ; this . result . append ( '<CHAR_LIT:}>' ) ; } else { curr . accept ( this ) ; } } return false ; } public boolean visit ( TextElement node ) { this . result . append ( getAttribute ( node , TextElement . TEXT_PROPERTY ) ) ; return false ; } public boolean visit ( AnnotationTypeDeclaration node ) { ASTNode javadoc = getChildNode ( node , AnnotationTypeDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , AnnotationTypeDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , AnnotationTypeDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , AnnotationTypeDeclaration . BODY_DECLARATIONS_PROPERTY , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { ASTNode javadoc = getChildNode ( node , AnnotationTypeMemberDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , AnnotationTypeMemberDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; getChildNode ( node , AnnotationTypeMemberDeclaration . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; getChildNode ( node , AnnotationTypeMemberDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; ASTNode def = getChildNode ( node , AnnotationTypeMemberDeclaration . DEFAULT_PROPERTY ) ; if ( def != null ) { this . result . append ( "<STR_LIT>" ) ; def . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( EnhancedForStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , EnhancedForStatement . PARAMETER_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT::>' ) ; getChildNode ( node , EnhancedForStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , EnhancedForStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( EnumConstantDeclaration node ) { ASTNode javadoc = getChildNode ( node , EnumConstantDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , EnumConstantDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; getChildNode ( node , EnumConstantDeclaration . NAME_PROPERTY ) . accept ( this ) ; visitList ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT:(>' ) , String . valueOf ( '<CHAR_LIT:)>' ) ) ; ASTNode classDecl = getChildNode ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( classDecl != null ) { classDecl . accept ( this ) ; } return false ; } public boolean visit ( EnumDeclaration node ) { ASTNode javadoc = getChildNode ( node , EnumDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , EnumDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , EnumDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , EnumDeclaration . SUPER_INTERFACE_TYPES_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , "<STR_LIT>" , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , Util . EMPTY_STRING , Util . EMPTY_STRING ) ; visitList ( node , EnumDeclaration . BODY_DECLARATIONS_PROPERTY , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:;>' ) , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( MarkerAnnotation node ) { this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , MarkerAnnotation . TYPE_NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( MemberValuePair node ) { getChildNode ( node , MemberValuePair . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:=>' ) ; getChildNode ( node , MemberValuePair . VALUE_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Modifier node ) { this . result . append ( getAttribute ( node , Modifier . KEYWORD_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( NormalAnnotation node ) { this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , NormalAnnotation . TYPE_NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , NormalAnnotation . VALUES_PROPERTY , "<STR_LIT:U+002CU+0020>" ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( ParameterizedType node ) { getChildNode ( node , ParameterizedType . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY , "<STR_LIT:U+002CU+0020>" ) ; this . result . append ( '<CHAR_LIT:>>' ) ; return false ; } public boolean visit ( QualifiedType node ) { getChildNode ( node , QualifiedType . QUALIFIER_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; getChildNode ( node , QualifiedType . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( SingleMemberAnnotation node ) { this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , SingleMemberAnnotation . TYPE_NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; getChildNode ( node , SingleMemberAnnotation . VALUE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( TypeParameter node ) { getChildNode ( node , TypeParameter . NAME_PROPERTY ) . accept ( this ) ; visitList ( node , TypeParameter . TYPE_BOUNDS_PROPERTY , "<STR_LIT>" , "<STR_LIT>" , Util . EMPTY_STRING ) ; return false ; } public boolean visit ( WildcardType node ) { this . result . append ( '<CHAR_LIT>' ) ; ASTNode bound = getChildNode ( node , WildcardType . BOUND_PROPERTY ) ; if ( bound != null ) { if ( getBooleanAttribute ( node , WildcardType . UPPER_BOUND_PROPERTY ) ) { this . result . append ( "<STR_LIT>" ) ; } else { this . result . append ( "<STR_LIT>" ) ; } bound . accept ( this ) ; } return false ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . Arrays ; import java . util . List ; import org . eclipse . jdt . core . dom . LineComment ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . jdt . internal . compiler . util . Util ; public class LineCommentEndOffsets { private int [ ] offsets ; private final List commentList ; public LineCommentEndOffsets ( List commentList ) { this . commentList = commentList ; this . offsets = null ; } private int [ ] getOffsets ( ) { if ( this . offsets == null ) { if ( this . commentList != null ) { int nComments = this . commentList . size ( ) ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < nComments ; i ++ ) { Object curr = this . commentList . get ( i ) ; if ( curr instanceof LineComment ) { count ++ ; } } this . offsets = new int [ count ] ; for ( int i = <NUM_LIT:0> , k = <NUM_LIT:0> ; i < nComments ; i ++ ) { Object curr = this . commentList . get ( i ) ; if ( curr instanceof LineComment ) { LineComment comment = ( LineComment ) curr ; this . offsets [ k ++ ] = comment . getStartPosition ( ) + comment . getLength ( ) ; } } } else { this . offsets = Util . EMPTY_INT_ARRAY ; } } return this . offsets ; } public boolean isEndOfLineComment ( int offset ) { return offset >= <NUM_LIT:0> && Arrays . binarySearch ( getOffsets ( ) , offset ) >= <NUM_LIT:0> ; } public boolean isEndOfLineComment ( int offset , char [ ] content ) { if ( offset < <NUM_LIT:0> || ( offset < content . length && ! IndentManipulation . isLineDelimiterChar ( content [ offset ] ) ) ) { return false ; } return Arrays . binarySearch ( getOffsets ( ) , offset ) >= <NUM_LIT:0> ; } public boolean remove ( int offset ) { int [ ] offsetArray = getOffsets ( ) ; int index = Arrays . binarySearch ( offsetArray , offset ) ; if ( index >= <NUM_LIT:0> ) { if ( index > <NUM_LIT:0> ) { System . arraycopy ( offsetArray , <NUM_LIT:0> , offsetArray , <NUM_LIT:1> , index ) ; } offsetArray [ <NUM_LIT:0> ] = - <NUM_LIT:1> ; return true ; } return false ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Set ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . NullProgressMonitor ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Comment ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . ImportDeclaration ; import org . eclipse . jdt . core . dom . LineComment ; import org . eclipse . jdt . core . dom . PackageDeclaration ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchEngine ; import org . eclipse . jdt . core . search . TypeNameRequestor ; import org . eclipse . jdt . internal . core . JavaProject ; import org . eclipse . jface . text . IRegion ; import org . eclipse . jface . text . Region ; import org . eclipse . text . edits . DeleteEdit ; import org . eclipse . text . edits . InsertEdit ; import org . eclipse . text . edits . MultiTextEdit ; public final class ImportRewriteAnalyzer { private final ICompilationUnit compilationUnit ; private final ArrayList packageEntries ; private final List importsCreated ; private final List staticImportsCreated ; private final IRegion replaceRange ; private final int importOnDemandThreshold ; private final int staticImportOnDemandThreshold ; private boolean filterImplicitImports ; private boolean useContextToFilterImplicitImports ; private boolean findAmbiguousImports ; private IRegion [ ] preserveExistingCommentsRanges ; private int flags = <NUM_LIT:0> ; private static final int F_NEEDS_LEADING_DELIM = <NUM_LIT:2> ; private static final int F_NEEDS_TRAILING_DELIM = <NUM_LIT:4> ; private static final String JAVA_LANG = "<STR_LIT>" ; public ImportRewriteAnalyzer ( ICompilationUnit cu , CompilationUnit root , String [ ] importOrder , int threshold , int staticThreshold , boolean restoreExistingImports , boolean useContextToFilterImplicitImports ) { this . compilationUnit = cu ; this . importOnDemandThreshold = threshold ; this . staticImportOnDemandThreshold = staticThreshold ; this . useContextToFilterImplicitImports = useContextToFilterImplicitImports ; this . filterImplicitImports = true ; this . findAmbiguousImports = true ; this . packageEntries = new ArrayList ( <NUM_LIT:20> ) ; this . importsCreated = new ArrayList ( ) ; this . staticImportsCreated = new ArrayList ( ) ; this . flags = <NUM_LIT:0> ; this . replaceRange = evaluateReplaceRange ( root ) ; if ( restoreExistingImports ) { addExistingImports ( root ) ; } else { this . preserveExistingCommentsRanges = retrieveExistingCommentsInImports ( root ) ; } PackageEntry [ ] order = new PackageEntry [ importOrder . length ] ; for ( int i = <NUM_LIT:0> ; i < order . length ; i ++ ) { String curr = importOrder [ i ] ; if ( curr . length ( ) > <NUM_LIT:0> && curr . charAt ( <NUM_LIT:0> ) == '<CHAR_LIT>' ) { curr = curr . substring ( <NUM_LIT:1> ) ; order [ i ] = new PackageEntry ( curr , curr , true ) ; } else { order [ i ] = new PackageEntry ( curr , curr , false ) ; } } addPreferenceOrderHolders ( order ) ; } private int getSpacesBetweenImportGroups ( ) { try { int num = Integer . parseInt ( this . compilationUnit . getJavaProject ( ) . getOption ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS , true ) ) ; if ( num >= <NUM_LIT:0> ) return num ; } catch ( NumberFormatException e ) { } return <NUM_LIT:1> ; } private boolean insertSpaceBeforeSemicolon ( ) { return JavaCore . INSERT . equals ( this . compilationUnit . getJavaProject ( ) . getOption ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON , true ) ) ; } private void addPreferenceOrderHolders ( PackageEntry [ ] preferenceOrder ) { if ( this . packageEntries . isEmpty ( ) ) { for ( int i = <NUM_LIT:0> ; i < preferenceOrder . length ; i ++ ) { this . packageEntries . add ( preferenceOrder [ i ] ) ; } } else { PackageEntry [ ] lastAssigned = new PackageEntry [ preferenceOrder . length ] ; for ( int k = <NUM_LIT:0> ; k < this . packageEntries . size ( ) ; k ++ ) { PackageEntry entry = ( PackageEntry ) this . packageEntries . get ( k ) ; if ( ! entry . isComment ( ) ) { String currName = entry . getName ( ) ; int currNameLen = currName . length ( ) ; int bestGroupIndex = - <NUM_LIT:1> ; int bestGroupLen = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < preferenceOrder . length ; i ++ ) { boolean currPrevStatic = preferenceOrder [ i ] . isStatic ( ) ; if ( currPrevStatic == entry . isStatic ( ) ) { String currPrefEntry = preferenceOrder [ i ] . getName ( ) ; int currPrefLen = currPrefEntry . length ( ) ; if ( currName . startsWith ( currPrefEntry ) && currPrefLen >= bestGroupLen ) { if ( currPrefLen == currNameLen || currName . charAt ( currPrefLen ) == '<CHAR_LIT:.>' ) { if ( bestGroupIndex == - <NUM_LIT:1> || currPrefLen > bestGroupLen ) { bestGroupLen = currPrefLen ; bestGroupIndex = i ; } } } } } if ( bestGroupIndex != - <NUM_LIT:1> ) { entry . setGroupID ( preferenceOrder [ bestGroupIndex ] . getName ( ) ) ; lastAssigned [ bestGroupIndex ] = entry ; } } } int currAppendIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < lastAssigned . length ; i ++ ) { PackageEntry entry = lastAssigned [ i ] ; if ( entry == null ) { PackageEntry newEntry = preferenceOrder [ i ] ; if ( currAppendIndex == <NUM_LIT:0> && ! newEntry . isStatic ( ) ) { currAppendIndex = getIndexAfterStatics ( ) ; } this . packageEntries . add ( currAppendIndex , newEntry ) ; currAppendIndex ++ ; } else { currAppendIndex = this . packageEntries . indexOf ( entry ) + <NUM_LIT:1> ; } } } } private String getQualifier ( ImportDeclaration decl ) { String name = decl . getName ( ) . getFullyQualifiedName ( ) ; if ( decl . isOnDemand ( ) ) { return name ; } return getQualifier ( name , decl . isStatic ( ) ) ; } private String getQualifier ( String name , boolean isStatic ) { if ( isStatic || ! this . useContextToFilterImplicitImports ) { return Signature . getQualifier ( name ) ; } char [ ] searchedName = name . toCharArray ( ) ; int index = name . length ( ) ; JavaProject project = ( JavaProject ) this . compilationUnit . getJavaProject ( ) ; do { String testedName = new String ( searchedName , <NUM_LIT:0> , index ) ; IJavaElement fragment = null ; try { fragment = project . findPackageFragment ( testedName ) ; } catch ( JavaModelException e ) { return name ; } if ( fragment != null ) { return testedName ; } try { fragment = project . findType ( testedName ) ; } catch ( JavaModelException e ) { return name ; } if ( fragment != null ) { index = CharOperation . lastIndexOf ( Signature . C_DOT , searchedName , <NUM_LIT:0> , index - <NUM_LIT:1> ) ; } else { index = CharOperation . lastIndexOf ( Signature . C_DOT , searchedName , <NUM_LIT:0> , index - <NUM_LIT:1> ) ; if ( Character . isLowerCase ( searchedName [ index + <NUM_LIT:1> ] ) ) { return testedName ; } } } while ( index >= <NUM_LIT:0> ) ; return name ; } private static String getFullName ( ImportDeclaration decl ) { String name = decl . getName ( ) . getFullyQualifiedName ( ) ; return decl . isOnDemand ( ) ? name + "<STR_LIT>" : name ; } private void addExistingImports ( CompilationUnit root ) { List decls = root . imports ( ) ; if ( decls . isEmpty ( ) ) { return ; } PackageEntry currPackage = null ; ImportDeclaration curr = ( ImportDeclaration ) decls . get ( <NUM_LIT:0> ) ; int currOffset = curr . getStartPosition ( ) ; int currLength = curr . getLength ( ) ; int currEndLine = root . getLineNumber ( currOffset + currLength ) ; for ( int i = <NUM_LIT:1> ; i < decls . size ( ) ; i ++ ) { boolean isStatic = curr . isStatic ( ) ; String name = getFullName ( curr ) ; String packName = getQualifier ( curr ) ; if ( currPackage == null || currPackage . compareTo ( packName , isStatic ) != <NUM_LIT:0> ) { currPackage = new PackageEntry ( packName , null , isStatic ) ; this . packageEntries . add ( currPackage ) ; } ImportDeclaration next = ( ImportDeclaration ) decls . get ( i ) ; int nextOffset = next . getStartPosition ( ) ; int nextLength = next . getLength ( ) ; int nextOffsetLine = root . getLineNumber ( nextOffset ) ; int extendedStart = root . getExtendedStartPosition ( curr ) ; if ( extendedStart < this . replaceRange . getOffset ( ) ) { extendedStart = currOffset ; } int extendedLength = root . getExtendedLength ( curr ) ; int nextLineOffset = nextOffset ; if ( currEndLine < nextOffsetLine ) { currEndLine ++ ; nextLineOffset = root . getPosition ( currEndLine , <NUM_LIT:0> ) ; } IRegion rangeBefore = null ; IRegion rangeAfter = null ; if ( currOffset > extendedStart ) { rangeBefore = new Region ( extendedStart , currOffset - extendedStart ) ; } int currLen = curr . getLength ( ) ; if ( currLen < extendedLength - ( currOffset - extendedStart ) ) { int currEndOffset = currOffset + currLen ; int rangeBeforeLen = rangeBefore != null ? rangeBefore . getLength ( ) : <NUM_LIT:0> ; rangeAfter = new Region ( currEndOffset , extendedLength - rangeBeforeLen - currLen ) ; } currPackage . add ( new ImportDeclEntry ( packName . length ( ) , name , isStatic , new Region ( currOffset , nextLineOffset - currOffset ) , rangeBefore , rangeAfter ) ) ; currOffset = nextOffset ; curr = next ; if ( currEndLine < nextOffsetLine ) { nextOffset = root . getPosition ( nextOffsetLine , <NUM_LIT:0> ) ; currPackage = new PackageEntry ( ) ; this . packageEntries . add ( currPackage ) ; currPackage . add ( new ImportDeclEntry ( packName . length ( ) , null , false , new Region ( nextLineOffset , nextOffset - nextLineOffset ) ) ) ; currOffset = nextOffset ; } currEndLine = root . getLineNumber ( nextOffset + nextLength ) ; } boolean isStatic = curr . isStatic ( ) ; String name = getFullName ( curr ) ; String packName = getQualifier ( curr ) ; if ( currPackage == null || currPackage . compareTo ( packName , isStatic ) != <NUM_LIT:0> ) { currPackage = new PackageEntry ( packName , null , isStatic ) ; this . packageEntries . add ( currPackage ) ; } int currStartOffset = curr . getStartPosition ( ) ; int currLen = curr . getLength ( ) ; int extendedStartOffset = root . getExtendedStartPosition ( curr ) ; IRegion leadingComments = null ; IRegion allTrailingComments = null ; if ( currStartOffset > extendedStartOffset ) { leadingComments = new Region ( extendedStartOffset , currOffset - extendedStartOffset ) ; } int length = this . replaceRange . getOffset ( ) + this . replaceRange . getLength ( ) - currStartOffset ; int extendedLength = root . getExtendedLength ( curr ) ; if ( currLen < extendedLength - ( currOffset - extendedStartOffset ) ) { int currEndOffset = currOffset + currLen ; int leadingCommentsLen = leadingComments != null ? leadingComments . getLength ( ) : <NUM_LIT:0> ; allTrailingComments = new Region ( currEndOffset , extendedLength - leadingCommentsLen - currLen ) ; } currPackage . add ( new ImportDeclEntry ( packName . length ( ) , name , isStatic , new Region ( curr . getStartPosition ( ) , length ) , leadingComments , allTrailingComments ) ) ; } private IRegion [ ] retrieveExistingCommentsInImports ( CompilationUnit root ) { List decls = root . imports ( ) ; if ( decls . isEmpty ( ) ) { return null ; } List commentList = root . getCommentList ( ) ; int numberOfComments = commentList . size ( ) ; List regions = null ; int currentExtendedEnd = - <NUM_LIT:1> ; int currEndLine = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < decls . size ( ) ; i ++ ) { ImportDeclaration next = ( ImportDeclaration ) decls . get ( i ) ; int nextOffset = next . getStartPosition ( ) ; int nextLength = next . getLength ( ) ; int extendedStart = root . getExtendedStartPosition ( next ) ; int extendedLength = root . getExtendedLength ( next ) ; int nextOffsetLine = root . getLineNumber ( nextOffset ) ; if ( nextOffset != extendedStart ) { int lengthOfPrecedingComment = nextOffset - extendedStart ; if ( i != <NUM_LIT:0> ) { if ( regions == null ) { regions = new ArrayList ( ) ; } regions . add ( new Region ( extendedStart , lengthOfPrecedingComment ) ) ; } if ( extendedLength != ( nextLength + lengthOfPrecedingComment ) ) { int regionLength = extendedLength - ( nextLength + lengthOfPrecedingComment ) ; if ( regions == null ) { regions = new ArrayList ( ) ; } regions . add ( new Region ( nextOffset + nextLength , regionLength ) ) ; } } else if ( nextLength != extendedLength ) { int regionLength = extendedLength - nextLength ; if ( regions == null ) { regions = new ArrayList ( ) ; } regions . add ( new Region ( nextOffset + nextLength , regionLength ) ) ; } if ( i > <NUM_LIT:0> ) { if ( ( nextOffsetLine - currEndLine ) > <NUM_LIT:1> ) { LineComment comment = root . getAST ( ) . newLineComment ( ) ; comment . setSourceRange ( currentExtendedEnd + <NUM_LIT:1> , <NUM_LIT:0> ) ; int index = Collections . binarySearch ( commentList , comment , new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { return ( ( Comment ) o1 ) . getStartPosition ( ) - ( ( Comment ) o2 ) . getStartPosition ( ) ; } } ) ; if ( index < <NUM_LIT:0> ) { loop : for ( int j = - ( index + <NUM_LIT:1> ) ; j < numberOfComments ; j ++ ) { Comment currentComment = ( Comment ) commentList . get ( j ) ; int commentStartPosition = currentComment . getStartPosition ( ) ; int commentLength = currentComment . getLength ( ) ; if ( ( commentStartPosition > currentExtendedEnd ) && ( ( commentStartPosition + commentLength - <NUM_LIT:1> ) < extendedStart ) ) { if ( regions == null ) { regions = new ArrayList ( ) ; } regions . add ( new Region ( commentStartPosition , commentLength ) ) ; } else { break loop ; } } } } } currentExtendedEnd = extendedStart + extendedLength - <NUM_LIT:1> ; currEndLine = root . getLineNumber ( currentExtendedEnd ) ; } if ( regions == null ) { return null ; } IRegion [ ] result = ( IRegion [ ] ) regions . toArray ( new IRegion [ regions . size ( ) ] ) ; Arrays . sort ( result , new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { return ( ( IRegion ) o1 ) . getOffset ( ) - ( ( IRegion ) o2 ) . getOffset ( ) ; } } ) ; return result ; } public void setFilterImplicitImports ( boolean filterImplicitImports ) { this . filterImplicitImports = filterImplicitImports ; } public void setFindAmbiguousImports ( boolean findAmbiguousImports ) { this . findAmbiguousImports = findAmbiguousImports ; } private static class PackageMatcher { private String newName ; private String bestName ; private int bestMatchLen ; public PackageMatcher ( ) { } public void initialize ( String newImportName , String bestImportName ) { this . newName = newImportName ; this . bestName = bestImportName ; this . bestMatchLen = getCommonPrefixLength ( bestImportName , newImportName ) ; } public boolean isBetterMatch ( String currName , boolean preferCurr ) { boolean isBetter ; int currMatchLen = getCommonPrefixLength ( currName , this . newName ) ; int matchDiff = currMatchLen - this . bestMatchLen ; if ( matchDiff == <NUM_LIT:0> ) { if ( currMatchLen == this . newName . length ( ) && currMatchLen == currName . length ( ) && currMatchLen == this . bestName . length ( ) ) { isBetter = preferCurr ; } else { isBetter = sameMatchLenTest ( currName ) ; } } else { isBetter = ( matchDiff > <NUM_LIT:0> ) ; } if ( isBetter ) { this . bestName = currName ; this . bestMatchLen = currMatchLen ; } return isBetter ; } private boolean sameMatchLenTest ( String currName ) { int matchLen = this . bestMatchLen ; char newChar = getCharAt ( this . newName , matchLen ) ; char currChar = getCharAt ( currName , matchLen ) ; char bestChar = getCharAt ( this . bestName , matchLen ) ; if ( newChar < currChar ) { if ( bestChar < newChar ) { return ( currChar - newChar ) < ( newChar - bestChar ) ; } else { if ( currChar == bestChar ) { return false ; } else { return currChar < bestChar ; } } } else { if ( bestChar > newChar ) { return ( newChar - currChar ) < ( bestChar - newChar ) ; } else { if ( currChar == bestChar ) { return true ; } else { return currChar > bestChar ; } } } } } static int getCommonPrefixLength ( String s , String t ) { int len = Math . min ( s . length ( ) , t . length ( ) ) ; for ( int i = <NUM_LIT:0> ; i < len ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) { return i ; } } return len ; } static char getCharAt ( String str , int index ) { if ( str . length ( ) > index ) { return str . charAt ( index ) ; } return <NUM_LIT:0> ; } private PackageEntry findBestMatch ( String newName , boolean isStatic ) { if ( this . packageEntries . isEmpty ( ) ) { return null ; } String groupId = null ; int longestPrefix = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < this . packageEntries . size ( ) ; i ++ ) { PackageEntry curr = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( isStatic == curr . isStatic ( ) ) { String currGroup = curr . getGroupID ( ) ; if ( currGroup != null && newName . startsWith ( currGroup ) ) { int prefixLen = currGroup . length ( ) ; if ( prefixLen == newName . length ( ) ) { return curr ; } if ( ( newName . charAt ( prefixLen ) == '<CHAR_LIT:.>' || prefixLen == <NUM_LIT:0> ) && prefixLen > longestPrefix ) { longestPrefix = prefixLen ; groupId = currGroup ; } } } } PackageEntry bestMatch = null ; PackageMatcher matcher = new PackageMatcher ( ) ; matcher . initialize ( newName , "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . packageEntries . size ( ) ; i ++ ) { PackageEntry curr = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( ! curr . isComment ( ) && curr . isStatic ( ) == isStatic ) { if ( groupId == null || groupId . equals ( curr . getGroupID ( ) ) ) { boolean preferrCurr = ( bestMatch == null ) || ( curr . getNumberOfImports ( ) > bestMatch . getNumberOfImports ( ) ) ; if ( matcher . isBetterMatch ( curr . getName ( ) , preferrCurr ) ) { bestMatch = curr ; } } } } return bestMatch ; } private boolean isImplicitImport ( String qualifier ) { if ( JAVA_LANG . equals ( qualifier ) ) { return true ; } ICompilationUnit cu = this . compilationUnit ; String packageName = cu . getParent ( ) . getElementName ( ) ; if ( qualifier . equals ( packageName ) ) { return true ; } String mainTypeName = JavaCore . removeJavaLikeExtension ( cu . getElementName ( ) ) ; if ( packageName . length ( ) == <NUM_LIT:0> ) { return qualifier . equals ( mainTypeName ) ; } return qualifier . equals ( packageName + '<CHAR_LIT:.>' + mainTypeName ) ; } public void addImport ( String fullTypeName , boolean isStatic ) { String typeContainerName = getQualifier ( fullTypeName , isStatic ) ; ImportDeclEntry decl = new ImportDeclEntry ( typeContainerName . length ( ) , fullTypeName , isStatic , null ) ; sortIn ( typeContainerName , decl , isStatic ) ; } public boolean removeImport ( String qualifiedName , boolean isStatic ) { String containerName = getQualifier ( qualifiedName , isStatic ) ; int nPackages = this . packageEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nPackages ; i ++ ) { PackageEntry entry = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( entry . compareTo ( containerName , isStatic ) == <NUM_LIT:0> ) { if ( entry . remove ( qualifiedName , isStatic ) ) { return true ; } } } return false ; } private int getIndexAfterStatics ( ) { for ( int i = <NUM_LIT:0> ; i < this . packageEntries . size ( ) ; i ++ ) { if ( ! ( ( PackageEntry ) this . packageEntries . get ( i ) ) . isStatic ( ) ) { return i ; } } return this . packageEntries . size ( ) ; } private void sortIn ( String typeContainerName , ImportDeclEntry decl , boolean isStatic ) { PackageEntry bestMatch = findBestMatch ( typeContainerName , isStatic ) ; if ( bestMatch == null ) { PackageEntry packEntry = new PackageEntry ( typeContainerName , null , isStatic ) ; packEntry . add ( decl ) ; int insertPos = packEntry . isStatic ( ) ? <NUM_LIT:0> : getIndexAfterStatics ( ) ; this . packageEntries . add ( insertPos , packEntry ) ; } else { int cmp = typeContainerName . compareTo ( bestMatch . getName ( ) ) ; if ( cmp == <NUM_LIT:0> ) { bestMatch . sortIn ( decl ) ; } else { String group = bestMatch . getGroupID ( ) ; if ( group != null ) { if ( ! typeContainerName . startsWith ( group ) ) { group = null ; } } PackageEntry packEntry = new PackageEntry ( typeContainerName , group , isStatic ) ; packEntry . add ( decl ) ; int index = this . packageEntries . indexOf ( bestMatch ) ; if ( cmp < <NUM_LIT:0> ) { this . packageEntries . add ( index , packEntry ) ; } else { this . packageEntries . add ( index + <NUM_LIT:1> , packEntry ) ; } } } } private IRegion evaluateReplaceRange ( CompilationUnit root ) { List imports = root . imports ( ) ; if ( ! imports . isEmpty ( ) ) { ImportDeclaration first = ( ImportDeclaration ) imports . get ( <NUM_LIT:0> ) ; ImportDeclaration last = ( ImportDeclaration ) imports . get ( imports . size ( ) - <NUM_LIT:1> ) ; int startPos = first . getStartPosition ( ) ; int endPos = root . getExtendedStartPosition ( last ) + root . getExtendedLength ( last ) ; int endLine = root . getLineNumber ( endPos ) ; if ( endLine > <NUM_LIT:0> ) { int nextLinePos = root . getPosition ( endLine + <NUM_LIT:1> , <NUM_LIT:0> ) ; if ( nextLinePos >= <NUM_LIT:0> ) { int firstTypePos = getFirstTypeBeginPos ( root ) ; if ( firstTypePos != - <NUM_LIT:1> && firstTypePos < nextLinePos ) { endPos = firstTypePos ; } else { endPos = nextLinePos ; } } } return new Region ( startPos , endPos - startPos ) ; } else { int start = getPackageStatementEndPos ( root ) ; return new Region ( start , <NUM_LIT:0> ) ; } } public MultiTextEdit getResultingEdits ( IProgressMonitor monitor ) throws JavaModelException { if ( monitor == null ) { monitor = new NullProgressMonitor ( ) ; } try { int importsStart = this . replaceRange . getOffset ( ) ; int importsLen = this . replaceRange . getLength ( ) ; String lineDelim = this . compilationUnit . findRecommendedLineSeparator ( ) ; IBuffer buffer = this . compilationUnit . getBuffer ( ) ; int currPos = importsStart ; MultiTextEdit resEdit = new MultiTextEdit ( ) ; if ( ( this . flags & F_NEEDS_LEADING_DELIM ) != <NUM_LIT:0> ) { resEdit . addChild ( new InsertEdit ( currPos , lineDelim ) ) ; } PackageEntry lastPackage = null ; Set onDemandConflicts = null ; if ( this . findAmbiguousImports ) { onDemandConflicts = evaluateStarImportConflicts ( monitor ) ; } int spacesBetweenGroups = getSpacesBetweenImportGroups ( ) ; ArrayList stringsToInsert = new ArrayList ( ) ; int nPackageEntries = this . packageEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nPackageEntries ; i ++ ) { PackageEntry pack = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( this . filterImplicitImports && ! pack . isStatic ( ) && isImplicitImport ( pack . getName ( ) ) ) { pack . filterImplicitImports ( this . useContextToFilterImplicitImports ) ; } int nImports = pack . getNumberOfImports ( ) ; if ( nImports == <NUM_LIT:0> ) { continue ; } if ( spacesBetweenGroups > <NUM_LIT:0> ) { if ( lastPackage != null && ! pack . isComment ( ) && ! pack . isSameGroup ( lastPackage ) ) { ImportDeclEntry last = lastPackage . getImportAt ( lastPackage . getNumberOfImports ( ) - <NUM_LIT:1> ) ; ImportDeclEntry first = pack . getImportAt ( <NUM_LIT:0> ) ; if ( ! lastPackage . isComment ( ) && ( last . isNew ( ) || first . isNew ( ) ) ) { for ( int k = spacesBetweenGroups ; k > <NUM_LIT:0> ; k -- ) { stringsToInsert . add ( lineDelim ) ; } } } } lastPackage = pack ; boolean isStatic = pack . isStatic ( ) ; int threshold = isStatic ? this . staticImportOnDemandThreshold : this . importOnDemandThreshold ; boolean doStarImport = pack . hasStarImport ( threshold , onDemandConflicts ) ; if ( doStarImport && ( pack . find ( "<STR_LIT:*>" ) == null ) ) { String [ ] imports = getNewImportStrings ( buffer , pack , isStatic , lineDelim ) ; for ( int j = <NUM_LIT:0> , max = imports . length ; j < max ; j ++ ) { stringsToInsert . add ( imports [ j ] ) ; } } for ( int k = <NUM_LIT:0> ; k < nImports ; k ++ ) { ImportDeclEntry currDecl = pack . getImportAt ( k ) ; IRegion region = currDecl . getSourceRange ( ) ; if ( region == null ) { if ( ! doStarImport || currDecl . isOnDemand ( ) || ( onDemandConflicts != null && onDemandConflicts . contains ( currDecl . getSimpleName ( ) ) ) ) { String str = getNewImportString ( currDecl . getElementName ( ) , isStatic , lineDelim ) ; stringsToInsert . add ( str ) ; } else if ( doStarImport && ! currDecl . isOnDemand ( ) ) { String simpleName = currDecl . getTypeQualifiedName ( ) ; if ( simpleName . indexOf ( '<CHAR_LIT:.>' ) != - <NUM_LIT:1> ) { String str = getNewImportString ( currDecl . getElementName ( ) , isStatic , lineDelim ) ; if ( stringsToInsert . indexOf ( str ) == - <NUM_LIT:1> ) { stringsToInsert . add ( str ) ; } } } } else if ( ! doStarImport || currDecl . isOnDemand ( ) || onDemandConflicts == null || onDemandConflicts . contains ( currDecl . getSimpleName ( ) ) ) { int offset = region . getOffset ( ) ; IRegion rangeBefore = currDecl . getPrecedingCommentRange ( ) ; if ( rangeBefore != null && currPos > rangeBefore . getOffset ( ) ) { currPos = rangeBefore . getOffset ( ) ; } if ( rangeBefore != null ) { stringsToInsert . add ( buffer . getText ( rangeBefore . getOffset ( ) , rangeBefore . getLength ( ) ) ) ; } removeAndInsertNew ( buffer , currPos , offset , stringsToInsert , resEdit ) ; stringsToInsert . clear ( ) ; currPos = offset + region . getLength ( ) ; } else if ( doStarImport && ! currDecl . isOnDemand ( ) ) { String simpleName = currDecl . getTypeQualifiedName ( ) ; if ( simpleName . indexOf ( '<CHAR_LIT:.>' ) != - <NUM_LIT:1> ) { IRegion rangeBefore = currDecl . getPrecedingCommentRange ( ) ; if ( rangeBefore != null && currPos > rangeBefore . getOffset ( ) ) { currPos = rangeBefore . getOffset ( ) ; } if ( rangeBefore != null ) { stringsToInsert . add ( buffer . getText ( rangeBefore . getOffset ( ) , rangeBefore . getLength ( ) ) ) ; } IRegion rangeAfter = currDecl . getTrailingCommentRange ( ) ; String trailingComment = null ; if ( rangeAfter != null ) { trailingComment = buffer . getText ( rangeAfter . getOffset ( ) , rangeAfter . getLength ( ) ) ; } String str = getNewImportString ( currDecl . getElementName ( ) , isStatic , trailingComment , lineDelim ) ; if ( stringsToInsert . indexOf ( str ) == - <NUM_LIT:1> ) { stringsToInsert . add ( str ) ; } } } } } if ( this . preserveExistingCommentsRanges != null ) { for ( int i = <NUM_LIT:0> , max = this . preserveExistingCommentsRanges . length ; i < max ; i ++ ) { IRegion region = this . preserveExistingCommentsRanges [ i ] ; String text = buffer . getText ( region . getOffset ( ) , region . getLength ( ) ) ; int index = <NUM_LIT:0> ; int length = text . length ( ) ; loop : while ( index < length ) { if ( Character . isWhitespace ( text . charAt ( index ) ) ) { index ++ ; } else { break loop ; } } if ( index != <NUM_LIT:0> ) { text = text . substring ( index ) ; } if ( ! text . endsWith ( lineDelim ) ) { text += lineDelim ; } stringsToInsert . add ( text ) ; } } int end = importsStart + importsLen ; removeAndInsertNew ( buffer , currPos , end , stringsToInsert , resEdit ) ; if ( importsLen == <NUM_LIT:0> ) { if ( ! this . importsCreated . isEmpty ( ) || ! this . staticImportsCreated . isEmpty ( ) ) { if ( ( this . flags & F_NEEDS_TRAILING_DELIM ) != <NUM_LIT:0> ) { resEdit . addChild ( new InsertEdit ( currPos , lineDelim ) ) ; } } else { return new MultiTextEdit ( ) ; } } return resEdit ; } finally { monitor . done ( ) ; } } private void removeAndInsertNew ( IBuffer buffer , int contentOffset , int contentEnd , ArrayList stringsToInsert , MultiTextEdit resEdit ) { int pos = contentOffset ; for ( int i = <NUM_LIT:0> ; i < stringsToInsert . size ( ) ; i ++ ) { String curr = ( String ) stringsToInsert . get ( i ) ; int idx = findInBuffer ( buffer , curr , pos , contentEnd ) ; if ( idx != - <NUM_LIT:1> ) { if ( idx != pos ) { resEdit . addChild ( new DeleteEdit ( pos , idx - pos ) ) ; } pos = idx + curr . length ( ) ; } else { resEdit . addChild ( new InsertEdit ( pos , curr ) ) ; } } if ( pos < contentEnd ) { resEdit . addChild ( new DeleteEdit ( pos , contentEnd - pos ) ) ; } } private int findInBuffer ( IBuffer buffer , String str , int start , int end ) { int pos = start ; int len = str . length ( ) ; if ( pos + len > end || str . length ( ) == <NUM_LIT:0> ) { return - <NUM_LIT:1> ; } char first = str . charAt ( <NUM_LIT:0> ) ; int step = str . indexOf ( first , <NUM_LIT:1> ) ; if ( step == - <NUM_LIT:1> ) { step = len ; } while ( pos + len <= end ) { if ( buffer . getChar ( pos ) == first ) { int k = <NUM_LIT:1> ; while ( k < len && buffer . getChar ( pos + k ) == str . charAt ( k ) ) { k ++ ; } if ( k == len ) { return pos ; } if ( k < step ) { pos += k ; } else { pos += step ; } } else { pos ++ ; } } return - <NUM_LIT:1> ; } private Set evaluateStarImportConflicts ( IProgressMonitor monitor ) throws JavaModelException { final HashSet onDemandConflicts = new HashSet ( ) ; IJavaSearchScope scope = SearchEngine . createJavaSearchScope ( new IJavaElement [ ] { this . compilationUnit . getJavaProject ( ) } ) ; ArrayList starImportPackages = new ArrayList ( ) ; ArrayList simpleTypeNames = new ArrayList ( ) ; int nPackageEntries = this . packageEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nPackageEntries ; i ++ ) { PackageEntry pack = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( ! pack . isStatic ( ) && pack . hasStarImport ( this . importOnDemandThreshold , null ) ) { starImportPackages . add ( pack . getName ( ) . toCharArray ( ) ) ; for ( int k = <NUM_LIT:0> ; k < pack . getNumberOfImports ( ) ; k ++ ) { ImportDeclEntry curr = pack . getImportAt ( k ) ; if ( ! curr . isOnDemand ( ) && ! curr . isComment ( ) ) { simpleTypeNames . add ( curr . getSimpleName ( ) . toCharArray ( ) ) ; } } } } if ( starImportPackages . isEmpty ( ) ) { return null ; } starImportPackages . add ( this . compilationUnit . getParent ( ) . getElementName ( ) . toCharArray ( ) ) ; starImportPackages . add ( JAVA_LANG . toCharArray ( ) ) ; char [ ] [ ] allPackages = ( char [ ] [ ] ) starImportPackages . toArray ( new char [ starImportPackages . size ( ) ] [ ] ) ; char [ ] [ ] allTypes = ( char [ ] [ ] ) simpleTypeNames . toArray ( new char [ simpleTypeNames . size ( ) ] [ ] ) ; TypeNameRequestor requestor = new TypeNameRequestor ( ) { HashMap foundTypes = new HashMap ( ) ; private String getTypeContainerName ( char [ ] packageName , char [ ] [ ] enclosingTypeNames ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( packageName ) ; for ( int i = <NUM_LIT:0> ; i < enclosingTypeNames . length ; i ++ ) { if ( buf . length ( ) > <NUM_LIT:0> ) buf . append ( '<CHAR_LIT:.>' ) ; buf . append ( enclosingTypeNames [ i ] ) ; } return buf . toString ( ) ; } public void acceptType ( int modifiers , char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , String path ) { String name = new String ( simpleTypeName ) ; String containerName = getTypeContainerName ( packageName , enclosingTypeNames ) ; String oldContainer = ( String ) this . foundTypes . put ( name , containerName ) ; if ( oldContainer != null && ! oldContainer . equals ( containerName ) ) { onDemandConflicts . add ( name ) ; } } } ; new SearchEngine ( ) . searchAllTypeNames ( allPackages , allTypes , scope , requestor , IJavaSearchConstants . WAIT_UNTIL_READY_TO_SEARCH , monitor ) ; return onDemandConflicts ; } private String getNewImportString ( String importName , boolean isStatic , String lineDelim ) { return getNewImportString ( importName , isStatic , null , lineDelim ) ; } private String getNewImportString ( String importName , boolean isStatic , String trailingComment , String lineDelim ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "<STR_LIT>" ) ; if ( isStatic ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( importName ) ; if ( insertSpaceBeforeSemicolon ( ) ) buf . append ( '<CHAR_LIT:U+0020>' ) ; buf . append ( '<CHAR_LIT:;>' ) ; if ( trailingComment != null ) { buf . append ( trailingComment ) ; } buf . append ( lineDelim ) ; if ( isStatic ) { this . staticImportsCreated . add ( importName ) ; } else { this . importsCreated . add ( importName ) ; } return buf . toString ( ) ; } private String [ ] getNewImportStrings ( IBuffer buffer , PackageEntry packageEntry , boolean isStatic , String lineDelim ) { boolean isStarImportAdded = false ; List allImports = new ArrayList ( ) ; int nImports = packageEntry . getNumberOfImports ( ) ; StringBuffer allComments = null ; for ( int i = <NUM_LIT:0> ; i < nImports ; i ++ ) { ImportDeclEntry curr = packageEntry . getImportAt ( i ) ; String simpleName = curr . getTypeQualifiedName ( ) ; if ( simpleName . indexOf ( '<CHAR_LIT:.>' ) != - <NUM_LIT:1> ) { IRegion rangeBefore = curr . getPrecedingCommentRange ( ) ; if ( rangeBefore != null ) { allImports . add ( buffer . getText ( rangeBefore . getOffset ( ) , rangeBefore . getLength ( ) ) ) ; } IRegion rangeAfter = curr . getTrailingCommentRange ( ) ; String trailingComment = null ; if ( rangeAfter != null ) { trailingComment = buffer . getText ( rangeAfter . getOffset ( ) , rangeAfter . getLength ( ) ) ; } allImports . add ( getNewImportString ( curr . getElementName ( ) , isStatic , trailingComment , lineDelim ) ) ; } else if ( ! isStarImportAdded ) { String starImportString = packageEntry . getName ( ) + "<STR_LIT>" ; allImports . add ( getNewImportString ( starImportString , isStatic , lineDelim ) ) ; isStarImportAdded = true ; } else { IRegion rangeBefore = curr . getPrecedingCommentRange ( ) ; if ( rangeBefore != null ) { if ( allComments == null ) { allComments = new StringBuffer ( ) ; } allComments . append ( buffer . getText ( rangeBefore . getOffset ( ) , rangeBefore . getLength ( ) ) ) . append ( lineDelim ) ; } IRegion rangeAfter = curr . getTrailingCommentRange ( ) ; if ( rangeAfter != null ) { if ( allComments == null ) { allComments = new StringBuffer ( ) ; } allComments . append ( buffer . getText ( rangeAfter . getOffset ( ) , rangeAfter . getLength ( ) ) ) . append ( lineDelim ) ; } } } if ( allComments != null ) { allImports . add ( <NUM_LIT:0> , String . valueOf ( allComments ) ) ; } return ( String [ ] ) allImports . toArray ( new String [ allImports . size ( ) ] ) ; } private static int getFirstTypeBeginPos ( CompilationUnit root ) { List types = root . types ( ) ; if ( ! types . isEmpty ( ) ) { return root . getExtendedStartPosition ( ( ( ASTNode ) types . get ( <NUM_LIT:0> ) ) ) ; } return - <NUM_LIT:1> ; } private int getPackageStatementEndPos ( CompilationUnit root ) { PackageDeclaration packDecl = root . getPackage ( ) ; if ( packDecl != null ) { int afterPackageStatementPos = - <NUM_LIT:1> ; int lineNumber = root . getLineNumber ( packDecl . getStartPosition ( ) + packDecl . getLength ( ) ) ; if ( lineNumber >= <NUM_LIT:0> ) { int lineAfterPackage = lineNumber + <NUM_LIT:1> ; afterPackageStatementPos = root . getPosition ( lineAfterPackage , <NUM_LIT:0> ) ; } if ( afterPackageStatementPos < <NUM_LIT:0> ) { this . flags |= F_NEEDS_LEADING_DELIM ; return packDecl . getStartPosition ( ) + packDecl . getLength ( ) ; } int firstTypePos = getFirstTypeBeginPos ( root ) ; if ( firstTypePos != - <NUM_LIT:1> && firstTypePos <= afterPackageStatementPos ) { this . flags |= F_NEEDS_TRAILING_DELIM ; if ( firstTypePos == afterPackageStatementPos ) { this . flags |= F_NEEDS_LEADING_DELIM ; } return firstTypePos ; } this . flags |= F_NEEDS_LEADING_DELIM ; return afterPackageStatementPos ; } this . flags |= F_NEEDS_TRAILING_DELIM ; return <NUM_LIT:0> ; } public String toString ( ) { int nPackages = this . packageEntries . size ( ) ; StringBuffer buf = new StringBuffer ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < nPackages ; i ++ ) { PackageEntry entry = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( entry . isStatic ( ) ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( entry . toString ( ) ) ; } return buf . toString ( ) ; } private static final class ImportDeclEntry { private String elementName ; private IRegion sourceRange ; private final boolean isStatic ; private int containerNameLength ; private IRegion precedingCommentRange ; private IRegion trailingCommentRange ; public ImportDeclEntry ( int containerNameLength , String elementName , boolean isStatic , IRegion sourceRange , IRegion precedingCommentRange , IRegion trailingCommentRange ) { this ( containerNameLength , elementName , isStatic , sourceRange ) ; this . precedingCommentRange = precedingCommentRange ; this . trailingCommentRange = trailingCommentRange ; } public ImportDeclEntry ( int containerNameLength , String elementName , boolean isStatic , IRegion sourceRange ) { this . elementName = elementName ; this . sourceRange = sourceRange ; this . isStatic = isStatic ; this . containerNameLength = containerNameLength ; } public String getElementName ( ) { return this . elementName ; } public int compareTo ( String fullName , boolean isStaticImport ) { int cmp = this . elementName . compareTo ( fullName ) ; if ( cmp == <NUM_LIT:0> ) { if ( this . isStatic == isStaticImport ) { return <NUM_LIT:0> ; } return this . isStatic ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return cmp ; } public String getSimpleName ( ) { return Signature . getSimpleName ( this . elementName ) ; } public String getTypeQualifiedName ( ) { return this . elementName . substring ( this . containerNameLength + <NUM_LIT:1> ) ; } public boolean isOnDemand ( ) { return this . elementName != null && this . elementName . endsWith ( "<STR_LIT>" ) ; } public boolean isStatic ( ) { return this . isStatic ; } public boolean isNew ( ) { return this . sourceRange == null ; } public boolean isComment ( ) { return this . elementName == null ; } public IRegion getSourceRange ( ) { return this . sourceRange ; } public IRegion getPrecedingCommentRange ( ) { return this . precedingCommentRange ; } public IRegion getTrailingCommentRange ( ) { return this . trailingCommentRange ; } } private final static class PackageEntry { private String name ; private ArrayList importEntries ; private String group ; private boolean isStatic ; public PackageEntry ( ) { this ( "<STR_LIT:!>" , null , false ) ; } public PackageEntry ( String name , String group , boolean isStatic ) { this . name = name ; this . importEntries = new ArrayList ( <NUM_LIT:5> ) ; this . group = group ; this . isStatic = isStatic ; } public boolean isStatic ( ) { return this . isStatic ; } public int compareTo ( String otherName , boolean isOtherStatic ) { int cmp = this . name . compareTo ( otherName ) ; if ( cmp == <NUM_LIT:0> ) { if ( this . isStatic == isOtherStatic ) { return <NUM_LIT:0> ; } return this . isStatic ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return cmp ; } public void sortIn ( ImportDeclEntry imp ) { String fullImportName = imp . getElementName ( ) ; int insertPosition = - <NUM_LIT:1> ; int nInports = this . importEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nInports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( ! curr . isComment ( ) ) { int cmp = curr . compareTo ( fullImportName , imp . isStatic ( ) ) ; if ( cmp == <NUM_LIT:0> ) { return ; } else if ( cmp > <NUM_LIT:0> && insertPosition == - <NUM_LIT:1> ) { insertPosition = i ; } } } if ( insertPosition == - <NUM_LIT:1> ) { this . importEntries . add ( imp ) ; } else { this . importEntries . add ( insertPosition , imp ) ; } } public void add ( ImportDeclEntry imp ) { this . importEntries . add ( imp ) ; } public ImportDeclEntry find ( String simpleName ) { int nInports = this . importEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nInports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( ! curr . isComment ( ) ) { String currName = curr . getElementName ( ) ; if ( currName . endsWith ( simpleName ) ) { int dotPos = currName . length ( ) - simpleName . length ( ) - <NUM_LIT:1> ; if ( ( dotPos == - <NUM_LIT:1> ) || ( dotPos > <NUM_LIT:0> && currName . charAt ( dotPos ) == '<CHAR_LIT:.>' ) ) { return curr ; } } } } return null ; } public boolean remove ( String fullName , boolean isStaticImport ) { int nInports = this . importEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nInports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( ! curr . isComment ( ) && curr . compareTo ( fullName , isStaticImport ) == <NUM_LIT:0> ) { this . importEntries . remove ( i ) ; return true ; } } return false ; } public void filterImplicitImports ( boolean useContextToFilterImplicitImports ) { int nInports = this . importEntries . size ( ) ; for ( int i = nInports - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( curr . isNew ( ) ) { if ( ! useContextToFilterImplicitImports ) { this . importEntries . remove ( i ) ; } else { String elementName = curr . getElementName ( ) ; int lastIndexOf = elementName . lastIndexOf ( '<CHAR_LIT:.>' ) ; boolean internalClassImport = lastIndexOf > getName ( ) . length ( ) ; if ( ! internalClassImport ) { this . importEntries . remove ( i ) ; } } } } } public ImportDeclEntry getImportAt ( int index ) { return ( ImportDeclEntry ) this . importEntries . get ( index ) ; } public boolean hasStarImport ( int threshold , Set explicitImports ) { if ( isComment ( ) || isDefaultPackage ( ) ) { return false ; } int nImports = getNumberOfImports ( ) ; int count = <NUM_LIT:0> ; boolean containsNew = false ; for ( int i = <NUM_LIT:0> ; i < nImports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( curr . isOnDemand ( ) ) { return true ; } if ( ! curr . isComment ( ) ) { count ++ ; boolean isExplicit = ! curr . isStatic ( ) && ( explicitImports != null ) && explicitImports . contains ( curr . getSimpleName ( ) ) ; containsNew |= curr . isNew ( ) && ! isExplicit ; } } return ( count >= threshold ) && containsNew ; } public int getNumberOfImports ( ) { return this . importEntries . size ( ) ; } public String getName ( ) { return this . name ; } public String getGroupID ( ) { return this . group ; } public void setGroupID ( String groupID ) { this . group = groupID ; } public boolean isSameGroup ( PackageEntry other ) { if ( this . group == null ) { return other . getGroupID ( ) == null ; } else { return this . group . equals ( other . getGroupID ( ) ) && ( this . isStatic == other . isStatic ( ) ) ; } } public boolean isComment ( ) { return "<STR_LIT:!>" . equals ( this . name ) ; } public boolean isDefaultPackage ( ) { return this . name . length ( ) == <NUM_LIT:0> ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( isComment ( ) ) { buf . append ( "<STR_LIT>" ) ; } else { buf . append ( this . name ) ; buf . append ( "<STR_LIT>" ) ; buf . append ( this . group ) ; buf . append ( "<STR_LIT:n>" ) ; int nImports = getNumberOfImports ( ) ; for ( int i = <NUM_LIT:0> ; i < nImports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; buf . append ( "<STR_LIT:U+0020>" ) ; if ( curr . isStatic ( ) ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( curr . getTypeQualifiedName ( ) ) ; if ( curr . isNew ( ) ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( "<STR_LIT:n>" ) ; } } return buf . toString ( ) ; } } public String [ ] getCreatedImports ( ) { return ( String [ ] ) this . importsCreated . toArray ( new String [ this . importsCreated . size ( ) ] ) ; } public String [ ] getCreatedStaticImports ( ) { return ( String [ ] ) this . staticImportsCreated . toArray ( new String [ this . staticImportsCreated . size ( ) ] ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . Collection ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Annotation ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . BodyDeclaration ; import org . eclipse . jdt . core . dom . Expression ; import org . eclipse . jdt . core . dom . Statement ; import org . eclipse . jdt . core . formatter . CodeFormatter ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . core . formatter . IndentManipulation ; 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 . text . edits . DeleteEdit ; import org . eclipse . text . edits . InsertEdit ; import org . eclipse . text . edits . MultiTextEdit ; import org . eclipse . text . edits . ReplaceEdit ; import org . eclipse . text . edits . TextEdit ; final class ASTRewriteFormatter { public static class NodeMarker extends Position { public Object data ; } private class ExtendedFlattener extends ASTRewriteFlattener { private ArrayList positions ; public ExtendedFlattener ( RewriteEventStore store ) { super ( store ) ; this . positions = new ArrayList ( ) ; } public void preVisit ( ASTNode node ) { Object trackData = getEventStore ( ) . getTrackedNodeData ( node ) ; if ( trackData != null ) { addMarker ( trackData , this . result . length ( ) , <NUM_LIT:0> ) ; } Object placeholderData = getPlaceholders ( ) . getPlaceholderData ( node ) ; if ( placeholderData != null ) { addMarker ( placeholderData , this . result . length ( ) , <NUM_LIT:0> ) ; } } public void postVisit ( ASTNode node ) { Object placeholderData = getPlaceholders ( ) . getPlaceholderData ( node ) ; if ( placeholderData != null ) { fixupLength ( placeholderData , this . result . length ( ) ) ; } Object trackData = getEventStore ( ) . getTrackedNodeData ( node ) ; if ( trackData != null ) { fixupLength ( trackData , this . result . length ( ) ) ; } } public boolean visit ( Block node ) { if ( getPlaceholders ( ) . isCollapsed ( node ) ) { visitList ( node , Block . STATEMENTS_PROPERTY , null ) ; return false ; } return super . visit ( node ) ; } private NodeMarker addMarker ( Object annotation , int startOffset , int length ) { NodeMarker marker = new NodeMarker ( ) ; marker . offset = startOffset ; marker . length = length ; marker . data = annotation ; this . positions . add ( marker ) ; return marker ; } private void fixupLength ( Object data , int endOffset ) { for ( int i = this . positions . size ( ) - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { NodeMarker marker = ( NodeMarker ) this . positions . get ( i ) ; if ( marker . data == data ) { marker . length = endOffset - marker . offset ; return ; } } } public NodeMarker [ ] getMarkers ( ) { return ( NodeMarker [ ] ) this . positions . toArray ( new NodeMarker [ this . positions . size ( ) ] ) ; } } private final String lineDelimiter ; private final int tabWidth ; private final int indentWidth ; private final NodeInfoStore placeholders ; private final RewriteEventStore eventStore ; private final Map options ; public ASTRewriteFormatter ( NodeInfoStore placeholders , RewriteEventStore eventStore , Map options , String lineDelimiter ) { this . placeholders = placeholders ; this . eventStore = eventStore ; this . options = options == null ? JavaCore . getOptions ( ) : ( Map ) new HashMap ( options ) ; this . options . put ( DefaultCodeFormatterConstants . FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY , DefaultCodeFormatterConstants . createAlignmentValue ( true , DefaultCodeFormatterConstants . WRAP_NEXT_PER_LINE , DefaultCodeFormatterConstants . INDENT_DEFAULT ) ) ; this . lineDelimiter = lineDelimiter ; this . tabWidth = IndentManipulation . getTabWidth ( options ) ; this . indentWidth = IndentManipulation . getIndentWidth ( options ) ; } public NodeInfoStore getPlaceholders ( ) { return this . placeholders ; } public RewriteEventStore getEventStore ( ) { return this . eventStore ; } public int getTabWidth ( ) { return this . tabWidth ; } public int getIndentWidth ( ) { return this . indentWidth ; } public String getLineDelimiter ( ) { return this . lineDelimiter ; } public String getFormattedResult ( ASTNode node , int initialIndentationLevel , Collection resultingMarkers ) { ExtendedFlattener flattener = new ExtendedFlattener ( this . eventStore ) ; node . accept ( flattener ) ; NodeMarker [ ] markers = flattener . getMarkers ( ) ; for ( int i = <NUM_LIT:0> ; i < markers . length ; i ++ ) { resultingMarkers . add ( markers [ i ] ) ; } String unformatted = flattener . getResult ( ) ; TextEdit edit = formatNode ( node , unformatted , initialIndentationLevel ) ; if ( edit == null ) { if ( initialIndentationLevel > <NUM_LIT:0> ) { String indentString = createIndentString ( initialIndentationLevel ) ; ReplaceEdit [ ] edits = IndentManipulation . getChangeIndentEdits ( unformatted , <NUM_LIT:0> , this . tabWidth , this . indentWidth , indentString ) ; edit = new MultiTextEdit ( ) ; edit . addChild ( new InsertEdit ( <NUM_LIT:0> , indentString ) ) ; edit . addChildren ( edits ) ; } else { return unformatted ; } } return evaluateFormatterEdit ( unformatted , edit , markers ) ; } public String createIndentString ( int indentationUnits ) { return ToolFactory . createCodeFormatter ( this . options ) . createIndentationString ( indentationUnits ) ; } public String getIndentString ( String currentLine ) { return IndentManipulation . extractIndentString ( currentLine , this . tabWidth , this . indentWidth ) ; } public String changeIndent ( String code , int codeIndentLevel , String newIndent ) { return IndentManipulation . changeIndent ( code , codeIndentLevel , this . tabWidth , this . indentWidth , newIndent , this . lineDelimiter ) ; } public int computeIndentUnits ( String line ) { return IndentManipulation . measureIndentUnits ( line , this . tabWidth , this . indentWidth ) ; } 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 ) { Assert . isTrue ( false , "<STR_LIT>" + e . getMessage ( ) ) ; } return null ; } public TextEdit formatString ( int kind , String string , int offset , int length , int indentationLevel ) { return ToolFactory . createCodeFormatter ( this . options ) . format ( kind , string , offset , length , indentationLevel , this . lineDelimiter ) ; } private TextEdit formatNode ( ASTNode node , String str , int indentationLevel ) { int code ; String prefix = "<STR_LIT>" ; String suffix = "<STR_LIT>" ; if ( node instanceof Statement ) { code = CodeFormatter . K_STATEMENTS ; if ( node . getNodeType ( ) == ASTNode . SWITCH_CASE ) { prefix = "<STR_LIT>" ; suffix = "<STR_LIT:}>" ; code = CodeFormatter . K_STATEMENTS ; } } else if ( node instanceof Expression && node . getNodeType ( ) != ASTNode . VARIABLE_DECLARATION_EXPRESSION ) { if ( node instanceof Annotation ) { suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; } else { code = CodeFormatter . K_EXPRESSION ; } } else if ( node instanceof BodyDeclaration ) { code = CodeFormatter . K_CLASS_BODY_DECLARATIONS ; } else { switch ( node . getNodeType ( ) ) { case ASTNode . ARRAY_TYPE : case ASTNode . PARAMETERIZED_TYPE : case ASTNode . PRIMITIVE_TYPE : case ASTNode . QUALIFIED_TYPE : case ASTNode . SIMPLE_TYPE : suffix = "<STR_LIT>" ; code = CodeFormatter . K_CLASS_BODY_DECLARATIONS ; break ; case ASTNode . WILDCARD_TYPE : prefix = "<STR_LIT>" ; suffix = "<STR_LIT>" ; code = CodeFormatter . K_CLASS_BODY_DECLARATIONS ; break ; case ASTNode . COMPILATION_UNIT : code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . VARIABLE_DECLARATION_EXPRESSION : case ASTNode . SINGLE_VARIABLE_DECLARATION : suffix = "<STR_LIT:;>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . VARIABLE_DECLARATION_FRAGMENT : prefix = "<STR_LIT>" ; suffix = "<STR_LIT:;>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . PACKAGE_DECLARATION : case ASTNode . IMPORT_DECLARATION : suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . JAVADOC : suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . CATCH_CLAUSE : prefix = "<STR_LIT>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . ANONYMOUS_CLASS_DECLARATION : prefix = "<STR_LIT>" ; suffix = "<STR_LIT:;>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . MEMBER_VALUE_PAIR : prefix = "<STR_LIT>" ; suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . MODIFIER : suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . TYPE_PARAMETER : prefix = "<STR_LIT>" ; suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . MEMBER_REF : case ASTNode . METHOD_REF : case ASTNode . METHOD_REF_PARAMETER : case ASTNode . TAG_ELEMENT : case ASTNode . TEXT_ELEMENT : return null ; default : return null ; } } String concatStr = prefix + str + suffix ; TextEdit edit = formatString ( code , concatStr , prefix . length ( ) , str . length ( ) , indentationLevel ) ; if ( prefix . length ( ) > <NUM_LIT:0> ) { edit = shifEdit ( edit , prefix . length ( ) ) ; } return edit ; } private static TextEdit shifEdit ( TextEdit oldEdit , int diff ) { TextEdit newEdit ; if ( oldEdit instanceof ReplaceEdit ) { ReplaceEdit edit = ( ReplaceEdit ) oldEdit ; newEdit = new ReplaceEdit ( edit . getOffset ( ) - diff , edit . getLength ( ) , edit . getText ( ) ) ; } else if ( oldEdit instanceof InsertEdit ) { InsertEdit edit = ( InsertEdit ) oldEdit ; newEdit = new InsertEdit ( edit . getOffset ( ) - diff , edit . getText ( ) ) ; } else if ( oldEdit instanceof DeleteEdit ) { DeleteEdit edit = ( DeleteEdit ) oldEdit ; newEdit = new DeleteEdit ( edit . getOffset ( ) - diff , edit . getLength ( ) ) ; } else if ( oldEdit instanceof MultiTextEdit ) { newEdit = new MultiTextEdit ( ) ; } else { return null ; } TextEdit [ ] children = oldEdit . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { TextEdit shifted = shifEdit ( children [ i ] , diff ) ; if ( shifted != null ) { newEdit . addChild ( shifted ) ; } } return newEdit ; } private static Document createDocument ( String string , Position [ ] positions ) throws IllegalArgumentException { Document doc = new Document ( string ) ; try { if ( positions != null ) { final String POS_CATEGORY = "<STR_LIT>" ; doc . addPositionCategory ( POS_CATEGORY ) ; doc . addPositionUpdater ( new DefaultPositionUpdater ( POS_CATEGORY ) { protected boolean notDeleted ( ) { int start = this . fOffset ; int end = start + this . fLength ; if ( start < this . fPosition . offset && ( this . fPosition . offset + this . fPosition . length < end ) ) { this . fPosition . offset = end ; 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>" + string . length ( ) ) ; } } } } catch ( BadPositionCategoryException cannotHappen ) { } return doc ; } public static interface Prefix { String getPrefix ( int indent ) ; } public static interface BlockContext { String [ ] getPrefixAndSuffix ( int indent , ASTNode node , RewriteEventStore events ) ; } public static class ConstPrefix implements Prefix { private String prefix ; public ConstPrefix ( String prefix ) { this . prefix = prefix ; } public String getPrefix ( int indent ) { return this . prefix ; } } private class FormattingPrefix implements Prefix { private int kind ; private String string ; private int start ; private int length ; public FormattingPrefix ( String string , String sub , int kind ) { this . start = string . indexOf ( sub ) ; this . length = sub . length ( ) ; this . string = string ; this . kind = kind ; } public String getPrefix ( int indent ) { Position pos = new Position ( this . start , this . length ) ; String str = this . string ; TextEdit res = formatString ( this . kind , str , <NUM_LIT:0> , str . length ( ) , indent ) ; if ( res != null ) { str = evaluateFormatterEdit ( str , res , new Position [ ] { pos } ) ; } return str . substring ( pos . offset + <NUM_LIT:1> , pos . offset + pos . length - <NUM_LIT:1> ) ; } } private class BlockFormattingPrefix implements BlockContext { private String prefix ; private int start ; public BlockFormattingPrefix ( String prefix , int start ) { this . start = start ; this . prefix = prefix ; } public String [ ] getPrefixAndSuffix ( int indent , ASTNode node , RewriteEventStore events ) { String nodeString = ASTRewriteFlattener . asString ( node , events ) ; String str = this . prefix + nodeString ; Position pos = new Position ( this . start , this . prefix . length ( ) + <NUM_LIT:1> - this . start ) ; TextEdit res = formatString ( CodeFormatter . K_STATEMENTS , str , <NUM_LIT:0> , str . length ( ) , indent ) ; if ( res != null ) { str = evaluateFormatterEdit ( str , res , new Position [ ] { pos } ) ; } return new String [ ] { str . substring ( pos . offset + <NUM_LIT:1> , pos . offset + pos . length - <NUM_LIT:1> ) , "<STR_LIT>" } ; } } private class BlockFormattingPrefixSuffix implements BlockContext { private String prefix ; private String suffix ; private int start ; public BlockFormattingPrefixSuffix ( String prefix , String suffix , int start ) { this . start = start ; this . suffix = suffix ; this . prefix = prefix ; } public String [ ] getPrefixAndSuffix ( int indent , ASTNode node , RewriteEventStore events ) { String nodeString = ASTRewriteFlattener . asString ( node , events ) ; int nodeStart = this . prefix . length ( ) ; int nodeEnd = nodeStart + nodeString . length ( ) - <NUM_LIT:1> ; String str = this . prefix + nodeString + this . suffix ; Position pos1 = new Position ( this . start , nodeStart + <NUM_LIT:1> - this . start ) ; Position pos2 = new Position ( nodeEnd , <NUM_LIT:2> ) ; TextEdit res = formatString ( CodeFormatter . K_STATEMENTS , str , <NUM_LIT:0> , str . length ( ) , indent ) ; if ( res != null ) { str = evaluateFormatterEdit ( str , res , new Position [ ] { pos1 , pos2 } ) ; } return new String [ ] { str . substring ( pos1 . offset + <NUM_LIT:1> , pos1 . offset + pos1 . length - <NUM_LIT:1> ) , str . substring ( pos2 . offset + <NUM_LIT:1> , pos2 . offset + pos2 . length - <NUM_LIT:1> ) } ; } } public final static Prefix NONE = new ConstPrefix ( "<STR_LIT>" ) ; public final static Prefix SPACE = new ConstPrefix ( "<STR_LIT:U+0020>" ) ; public final static Prefix ASSERT_COMMENT = new ConstPrefix ( "<STR_LIT:U+0020:U+0020>" ) ; public final Prefix VAR_INITIALIZER = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final Prefix METHOD_BODY = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix FINALLY_BLOCK = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final Prefix CATCH_BLOCK = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final Prefix ANNOT_MEMBER_DEFAULT = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix ENUM_BODY_START = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix ENUM_BODY_END = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix WILDCARD_EXTENDS = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix WILDCARD_SUPER = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix FIRST_ENUM_CONST = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix ANNOTATION_SEPARATION = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix PARAM_ANNOTATION_SEPARATION = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix TRY_RESOURCES = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final Prefix TRY_RESOURCES_PAREN = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final BlockContext IF_BLOCK_WITH_ELSE = new BlockFormattingPrefixSuffix ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:8> ) ; public final BlockContext IF_BLOCK_NO_ELSE = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:8> ) ; public final BlockContext ELSE_AFTER_STATEMENT = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:15> ) ; public final BlockContext ELSE_AFTER_BLOCK = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:11> ) ; public final BlockContext FOR_BLOCK = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:7> ) ; public final BlockContext WHILE_BLOCK = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:11> ) ; public final BlockContext DO_BLOCK = new BlockFormattingPrefixSuffix ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; public class NodeRewriteEvent extends RewriteEvent { private Object originalValue ; private Object newValue ; public NodeRewriteEvent ( Object originalValue , Object newValue ) { this . originalValue = originalValue ; this . newValue = newValue ; } public Object getNewValue ( ) { return this . newValue ; } public Object getOriginalValue ( ) { return this . originalValue ; } public int getChangeKind ( ) { if ( this . originalValue == this . newValue ) { return UNCHANGED ; } if ( this . originalValue == null ) { return INSERTED ; } if ( this . newValue == null ) { return REMOVED ; } if ( this . originalValue . equals ( this . newValue ) ) { return UNCHANGED ; } return REPLACED ; } public boolean isListRewrite ( ) { return false ; } public void setNewValue ( Object newValue ) { this . newValue = newValue ; } public RewriteEvent [ ] getChildren ( ) { return null ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; switch ( getChangeKind ( ) ) { case INSERTED : buf . append ( "<STR_LIT>" ) ; buf . append ( getNewValue ( ) ) ; buf . append ( '<CHAR_LIT:]>' ) ; break ; case REPLACED : buf . append ( "<STR_LIT>" ) ; buf . append ( getOriginalValue ( ) ) ; buf . append ( "<STR_LIT>" ) ; buf . append ( getNewValue ( ) ) ; buf . append ( '<CHAR_LIT:]>' ) ; break ; case REMOVED : buf . append ( "<STR_LIT>" ) ; buf . append ( getOriginalValue ( ) ) ; buf . append ( '<CHAR_LIT:]>' ) ; break ; default : buf . append ( "<STR_LIT>" ) ; } return buf . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . IdentityHashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import java . util . Stack ; import org . eclipse . core . runtime . Assert ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . dom . * ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer . SourceRange ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScanner ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScannerData ; 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 . dom . rewrite . ASTRewriteFormatter . BlockContext ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteFormatter . NodeMarker ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteFormatter . Prefix ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore . CopyPlaceholderData ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore . StringPlaceholderData ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; import org . eclipse . text . edits . CopySourceEdit ; import org . eclipse . text . edits . CopyTargetEdit ; import org . eclipse . text . edits . DeleteEdit ; import org . eclipse . text . edits . InsertEdit ; import org . eclipse . text . edits . MoveSourceEdit ; import org . eclipse . text . edits . MoveTargetEdit ; import org . eclipse . text . edits . RangeMarker ; import org . eclipse . text . edits . ReplaceEdit ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . text . edits . TextEditGroup ; public final class ASTRewriteAnalyzer extends ASTVisitor { static final int JLS2_INTERNAL = AST . JLS2 ; static final int JLS3_INTERNAL = AST . JLS3 ; TextEdit currentEdit ; final RewriteEventStore eventStore ; private TokenScanner tokenScanner ; private final Map sourceCopyInfoToEdit ; private final Stack sourceCopyEndNodes ; private final char [ ] content ; private final LineInformation lineInfo ; private final ASTRewriteFormatter formatter ; private final NodeInfoStore nodeInfos ; private final TargetSourceRangeComputer extendedSourceRangeComputer ; private final LineCommentEndOffsets lineCommentEndOffsets ; private int beforeRequiredSpaceIndex = - <NUM_LIT:1> ; Map options ; private RecoveryScannerData recoveryScannerData ; public ASTRewriteAnalyzer ( char [ ] content , LineInformation lineInfo , String lineDelim , TextEdit rootEdit , RewriteEventStore eventStore , NodeInfoStore nodeInfos , List comments , Map options , TargetSourceRangeComputer extendedSourceRangeComputer , RecoveryScannerData recoveryScannerData ) { this . eventStore = eventStore ; this . content = content ; this . lineInfo = lineInfo ; this . nodeInfos = nodeInfos ; this . tokenScanner = null ; this . currentEdit = rootEdit ; this . sourceCopyInfoToEdit = new IdentityHashMap ( ) ; this . sourceCopyEndNodes = new Stack ( ) ; this . formatter = new ASTRewriteFormatter ( nodeInfos , eventStore , options , lineDelim ) ; this . extendedSourceRangeComputer = extendedSourceRangeComputer ; this . lineCommentEndOffsets = new LineCommentEndOffsets ( comments ) ; this . options = options ; this . recoveryScannerData = recoveryScannerData ; } final TokenScanner getScanner ( ) { if ( this . tokenScanner == null ) { CompilerOptions compilerOptions = new CompilerOptions ( this . options ) ; Scanner scanner ; if ( this . recoveryScannerData == null ) { scanner = new Scanner ( true , false , false , compilerOptions . sourceLevel , compilerOptions . complianceLevel , null , null , true ) ; } else { scanner = new RecoveryScanner ( false , false , compilerOptions . sourceLevel , compilerOptions . complianceLevel , null , null , true , this . recoveryScannerData ) ; } scanner . setSource ( this . content ) ; this . tokenScanner = new TokenScanner ( scanner ) ; } return this . tokenScanner ; } final char [ ] getContent ( ) { return this . content ; } final LineInformation getLineInformation ( ) { return this . lineInfo ; } final SourceRange getExtendedRange ( ASTNode node ) { if ( this . eventStore . isRangeCopyPlaceholder ( node ) ) { return new SourceRange ( node . getStartPosition ( ) , node . getLength ( ) ) ; } return this . extendedSourceRangeComputer . computeSourceRange ( node ) ; } final int getExtendedOffset ( ASTNode node ) { return getExtendedRange ( node ) . getStartPosition ( ) ; } final int getExtendedEnd ( ASTNode node ) { TargetSourceRangeComputer . SourceRange range = getExtendedRange ( node ) ; return range . getStartPosition ( ) + range . getLength ( ) ; } final TextEdit getCopySourceEdit ( CopySourceInfo info ) { TextEdit edit = ( TextEdit ) this . sourceCopyInfoToEdit . get ( info ) ; if ( edit == null ) { SourceRange range = getExtendedRange ( info . getNode ( ) ) ; int start = range . getStartPosition ( ) ; int end = start + range . getLength ( ) ; if ( info . isMove ) { MoveSourceEdit moveSourceEdit = new MoveSourceEdit ( start , end - start ) ; moveSourceEdit . setTargetEdit ( new MoveTargetEdit ( <NUM_LIT:0> ) ) ; edit = moveSourceEdit ; } else { CopySourceEdit copySourceEdit = new CopySourceEdit ( start , end - start ) ; copySourceEdit . setTargetEdit ( new CopyTargetEdit ( <NUM_LIT:0> ) ) ; edit = copySourceEdit ; } this . sourceCopyInfoToEdit . put ( info , edit ) ; } return edit ; } private final int getChangeKind ( ASTNode node , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( node , property ) ; if ( event != null ) { return event . getChangeKind ( ) ; } return RewriteEvent . UNCHANGED ; } private final boolean hasChildrenChanges ( ASTNode node ) { return this . eventStore . hasChangedProperties ( node ) ; } private final boolean isChanged ( ASTNode node , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( node , property ) ; if ( event != null ) { return event . getChangeKind ( ) != RewriteEvent . UNCHANGED ; } return false ; } private final boolean isCollapsed ( ASTNode node ) { return this . nodeInfos . isCollapsed ( node ) ; } final boolean isInsertBoundToPrevious ( ASTNode node ) { return this . eventStore . isInsertBoundToPrevious ( node ) ; } private final TextEditGroup getEditGroup ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { return getEditGroup ( event ) ; } return null ; } final RewriteEvent getEvent ( ASTNode parent , StructuralPropertyDescriptor property ) { return this . eventStore . getEvent ( parent , property ) ; } final TextEditGroup getEditGroup ( RewriteEvent change ) { return this . eventStore . getEventEditGroup ( change ) ; } private final Object getOriginalValue ( ASTNode parent , StructuralPropertyDescriptor property ) { return this . eventStore . getOriginalValue ( parent , property ) ; } private final Object getNewValue ( ASTNode parent , StructuralPropertyDescriptor property ) { return this . eventStore . getNewValue ( parent , property ) ; } final void addEdit ( TextEdit edit ) { this . currentEdit . addChild ( edit ) ; } final String getLineDelimiter ( ) { return this . formatter . getLineDelimiter ( ) ; } final String createIndentString ( int indent ) { return this . formatter . createIndentString ( indent ) ; } final private String getIndentOfLine ( int pos ) { int line = getLineInformation ( ) . getLineOfOffset ( pos ) ; if ( line >= <NUM_LIT:0> ) { char [ ] cont = getContent ( ) ; int lineStart = getLineInformation ( ) . getLineOffset ( line ) ; int i = lineStart ; while ( i < cont . length && IndentManipulation . isIndentChar ( this . content [ i ] ) ) { i ++ ; } return new String ( cont , lineStart , i - lineStart ) ; } return Util . EMPTY_STRING ; } final String getIndentAtOffset ( int pos ) { return this . formatter . getIndentString ( getIndentOfLine ( pos ) ) ; } final void doTextInsert ( int offset , String insertString , TextEditGroup editGroup ) { if ( insertString . length ( ) > <NUM_LIT:0> ) { if ( this . lineCommentEndOffsets . isEndOfLineComment ( offset , this . content ) ) { if ( ! insertString . startsWith ( getLineDelimiter ( ) ) ) { TextEdit edit = new InsertEdit ( offset , getLineDelimiter ( ) ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } } this . lineCommentEndOffsets . remove ( offset ) ; } TextEdit edit = new InsertEdit ( offset , insertString ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } } } final void addEditGroup ( TextEditGroup editGroup , TextEdit edit ) { editGroup . addTextEdit ( edit ) ; } final TextEdit doTextRemove ( int offset , int len , TextEditGroup editGroup ) { if ( len == <NUM_LIT:0> ) { return null ; } TextEdit edit = new DeleteEdit ( offset , len ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } return edit ; } final void doTextRemoveAndVisit ( int offset , int len , ASTNode node , TextEditGroup editGroup ) { TextEdit edit = doTextRemove ( offset , len , editGroup ) ; if ( edit != null ) { this . currentEdit = edit ; voidVisit ( node ) ; this . currentEdit = edit . getParent ( ) ; } else { voidVisit ( node ) ; } } final int doVisit ( ASTNode node ) { node . accept ( this ) ; return getExtendedEnd ( node ) ; } private final int doVisit ( ASTNode parent , StructuralPropertyDescriptor property , int offset ) { Object node = getOriginalValue ( parent , property ) ; if ( property . isChildProperty ( ) && node != null ) { return doVisit ( ( ASTNode ) node ) ; } else if ( property . isChildListProperty ( ) ) { return doVisitList ( ( List ) node , offset ) ; } return offset ; } private int doVisitList ( List list , int offset ) { int endPos = offset ; for ( Iterator iter = list . iterator ( ) ; iter . hasNext ( ) ; ) { ASTNode curr = ( ( ASTNode ) iter . next ( ) ) ; endPos = doVisit ( curr ) ; } return endPos ; } final void voidVisit ( ASTNode node ) { node . accept ( this ) ; } private final void voidVisit ( ASTNode parent , StructuralPropertyDescriptor property ) { Object node = getOriginalValue ( parent , property ) ; if ( property . isChildProperty ( ) && node != null ) { voidVisit ( ( ASTNode ) node ) ; } else if ( property . isChildListProperty ( ) ) { voidVisitList ( ( List ) node ) ; } } private void voidVisitList ( List list ) { for ( Iterator iter = list . iterator ( ) ; iter . hasNext ( ) ; ) { doVisit ( ( ( ASTNode ) iter . next ( ) ) ) ; } } private final boolean doVisitUnchangedChildren ( ASTNode parent ) { List properties = parent . structuralPropertiesForType ( ) ; for ( int i = <NUM_LIT:0> ; i < properties . size ( ) ; i ++ ) { voidVisit ( parent , ( StructuralPropertyDescriptor ) properties . get ( i ) ) ; } return false ; } private final void doTextReplace ( int offset , int len , String insertString , TextEditGroup editGroup ) { if ( len > <NUM_LIT:0> || insertString . length ( ) > <NUM_LIT:0> ) { TextEdit edit = new ReplaceEdit ( offset , len , insertString ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } } } private final TextEdit doTextCopy ( TextEdit sourceEdit , int destOffset , int sourceIndentLevel , String destIndentString , TextEditGroup editGroup ) { TextEdit targetEdit ; SourceModifier modifier = new SourceModifier ( sourceIndentLevel , destIndentString , this . formatter . getTabWidth ( ) , this . formatter . getIndentWidth ( ) ) ; if ( sourceEdit instanceof MoveSourceEdit ) { MoveSourceEdit moveEdit = ( MoveSourceEdit ) sourceEdit ; moveEdit . setSourceModifier ( modifier ) ; targetEdit = new MoveTargetEdit ( destOffset , moveEdit ) ; addEdit ( targetEdit ) ; } else { CopySourceEdit copyEdit = ( CopySourceEdit ) sourceEdit ; copyEdit . setSourceModifier ( modifier ) ; targetEdit = new CopyTargetEdit ( destOffset , copyEdit ) ; addEdit ( targetEdit ) ; } if ( editGroup != null ) { addEditGroup ( editGroup , sourceEdit ) ; addEditGroup ( editGroup , targetEdit ) ; } return targetEdit ; } private void changeNotSupported ( ASTNode node ) { Assert . isTrue ( false , "<STR_LIT>" + node . getClass ( ) . getName ( ) ) ; } class ListRewriter { protected String constantSeparator ; protected int startPos ; protected RewriteEvent [ ] list ; protected final ASTNode getOriginalNode ( int index ) { return ( ASTNode ) this . list [ index ] . getOriginalValue ( ) ; } protected final ASTNode getNewNode ( int index ) { return ( ASTNode ) this . list [ index ] . getNewValue ( ) ; } protected String getSeparatorString ( int nodeIndex ) { return this . constantSeparator ; } protected int getInitialIndent ( ) { return getIndent ( this . startPos ) ; } protected int getNodeIndent ( int nodeIndex ) { ASTNode node = getOriginalNode ( nodeIndex ) ; if ( node == null ) { for ( int i = nodeIndex - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { ASTNode curr = getOriginalNode ( i ) ; if ( curr != null ) { return getIndent ( curr . getStartPosition ( ) ) ; } } return getInitialIndent ( ) ; } return getIndent ( node . getStartPosition ( ) ) ; } protected int getStartOfNextNode ( int nextIndex , int defaultPos ) { for ( int i = nextIndex ; i < this . list . length ; i ++ ) { RewriteEvent elem = this . list [ i ] ; if ( elem . getChangeKind ( ) != RewriteEvent . INSERTED ) { ASTNode node = ( ASTNode ) elem . getOriginalValue ( ) ; return getExtendedOffset ( node ) ; } } return defaultPos ; } protected int getEndOfNode ( ASTNode node ) { return getExtendedEnd ( node ) ; } public final int rewriteList ( ASTNode parent , StructuralPropertyDescriptor property , int offset , String keyword , String separator ) { this . constantSeparator = separator ; return rewriteList ( parent , property , keyword , null , offset ) ; } private boolean insertAfterSeparator ( ASTNode node ) { return ! isInsertBoundToPrevious ( node ) ; } protected boolean mustRemoveSeparator ( int originalOffset , int nodeIndex ) { return true ; } private int rewriteList ( ASTNode parent , StructuralPropertyDescriptor property , String keyword , String endKeyword , int offset ) { this . startPos = offset ; this . list = getEvent ( parent , property ) . getChildren ( ) ; int total = this . list . length ; if ( total == <NUM_LIT:0> ) { return this . startPos ; } int currPos = - <NUM_LIT:1> ; int lastNonInsert = - <NUM_LIT:1> ; int lastNonDelete = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < total ; i ++ ) { int currMark = this . list [ i ] . getChangeKind ( ) ; if ( currMark != RewriteEvent . INSERTED ) { lastNonInsert = i ; if ( currPos == - <NUM_LIT:1> ) { ASTNode elem = ( ASTNode ) this . list [ i ] . getOriginalValue ( ) ; currPos = getExtendedOffset ( elem ) ; } } if ( currMark != RewriteEvent . REMOVED ) { lastNonDelete = i ; } } boolean insertNew = currPos == - <NUM_LIT:1> ; if ( insertNew ) { if ( keyword . length ( ) > <NUM_LIT:0> ) { TextEditGroup editGroup = getEditGroup ( this . list [ <NUM_LIT:0> ] ) ; doTextInsert ( offset , keyword , editGroup ) ; } currPos = offset ; } if ( lastNonDelete == - <NUM_LIT:1> ) { currPos = offset ; } int prevEnd = currPos ; int prevMark = RewriteEvent . UNCHANGED ; final int NONE = <NUM_LIT:0> , NEW = <NUM_LIT:1> , EXISTING = <NUM_LIT:2> ; int separatorState = NEW ; for ( int i = <NUM_LIT:0> ; i < total ; i ++ ) { RewriteEvent currEvent = this . list [ i ] ; int currMark = currEvent . getChangeKind ( ) ; int nextIndex = i + <NUM_LIT:1> ; if ( currMark == RewriteEvent . INSERTED ) { TextEditGroup editGroup = getEditGroup ( currEvent ) ; ASTNode node = ( ASTNode ) currEvent . getNewValue ( ) ; if ( separatorState == NONE ) { doTextInsert ( currPos , getSeparatorString ( i - <NUM_LIT:1> ) , editGroup ) ; separatorState = NEW ; } if ( separatorState == NEW || insertAfterSeparator ( node ) ) { if ( separatorState == EXISTING ) { updateIndent ( prevMark , currPos , i , editGroup ) ; } doTextInsert ( currPos , node , getNodeIndent ( i ) , true , editGroup ) ; separatorState = NEW ; if ( i != lastNonDelete ) { if ( this . list [ nextIndex ] . getChangeKind ( ) != RewriteEvent . INSERTED ) { doTextInsert ( currPos , getSeparatorString ( i ) , editGroup ) ; } else { separatorState = NONE ; } } } else { doTextInsert ( prevEnd , getSeparatorString ( i - <NUM_LIT:1> ) , editGroup ) ; doTextInsert ( prevEnd , node , getNodeIndent ( i ) , true , editGroup ) ; } if ( insertNew ) { if ( endKeyword != null && endKeyword . length ( ) > <NUM_LIT:0> ) { doTextInsert ( currPos , endKeyword , editGroup ) ; } } } else if ( currMark == RewriteEvent . REMOVED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( currEvent ) ; int currEnd = getEndOfNode ( node ) ; try { TokenScanner scanner = getScanner ( ) ; int newOffset = prevEnd ; int extendedOffset = getExtendedOffset ( node ) ; while ( TokenScanner . isComment ( scanner . readNext ( newOffset , false ) ) ) { int tempOffset = scanner . getNextEndOffset ( newOffset , false ) ; if ( tempOffset < extendedOffset ) { newOffset = tempOffset ; } else { break ; } } if ( currPos < newOffset ) { currPos = extendedOffset ; } prevEnd = newOffset ; } catch ( CoreException e ) { } if ( i > lastNonDelete && separatorState == EXISTING ) { doTextRemove ( prevEnd , currPos - prevEnd , editGroup ) ; doTextRemoveAndVisit ( currPos , currEnd - currPos , node , editGroup ) ; currPos = currEnd ; prevEnd = currEnd ; } else { if ( i < lastNonDelete ) { updateIndent ( prevMark , currPos , i , editGroup ) ; } int end = getStartOfNextNode ( nextIndex , currEnd ) ; try { TokenScanner scanner = getScanner ( ) ; int nextToken = scanner . readNext ( currEnd , false ) ; if ( TokenScanner . isComment ( nextToken ) ) { if ( end != scanner . getNextStartOffset ( currEnd , false ) ) { end = currEnd ; } } } catch ( CoreException e ) { } doTextRemoveAndVisit ( currPos , currEnd - currPos , node , getEditGroup ( currEvent ) ) ; if ( mustRemoveSeparator ( currPos , i ) ) { doTextRemove ( currEnd , end - currEnd , editGroup ) ; } currPos = end ; prevEnd = currEnd ; separatorState = NEW ; } } else { if ( currMark == RewriteEvent . REPLACED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; int currEnd = getEndOfNode ( node ) ; TextEditGroup editGroup = getEditGroup ( currEvent ) ; ASTNode changed = ( ASTNode ) currEvent . getNewValue ( ) ; updateIndent ( prevMark , currPos , i , editGroup ) ; try { TokenScanner scanner = getScanner ( ) ; int newOffset = prevEnd ; int extendedOffset = getExtendedOffset ( node ) ; while ( TokenScanner . isComment ( scanner . readNext ( newOffset , false ) ) ) { int tempOffset = scanner . getNextEndOffset ( newOffset , false ) ; if ( tempOffset < extendedOffset ) { newOffset = tempOffset ; } else { break ; } } if ( currPos < newOffset ) { currPos = extendedOffset ; } } catch ( CoreException e ) { } doTextRemoveAndVisit ( currPos , currEnd - currPos , node , editGroup ) ; doTextInsert ( currPos , changed , getNodeIndent ( i ) , true , editGroup ) ; prevEnd = currEnd ; } else { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; voidVisit ( node ) ; } if ( i == lastNonInsert ) { separatorState = NONE ; if ( currMark == RewriteEvent . UNCHANGED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; prevEnd = getEndOfNode ( node ) ; } currPos = prevEnd ; } else if ( this . list [ nextIndex ] . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { if ( currMark == RewriteEvent . UNCHANGED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; prevEnd = getEndOfNode ( node ) ; } currPos = getStartOfNextNode ( nextIndex , prevEnd ) ; separatorState = EXISTING ; } } prevMark = currMark ; } return currPos ; } public final int rewriteList ( ASTNode parent , StructuralPropertyDescriptor property , int offset , String keyword ) { return rewriteList ( parent , property , keyword , null , offset ) ; } protected void updateIndent ( int prevMark , int originalOffset , int nodeIndex , TextEditGroup editGroup ) { } public final int rewriteList ( ASTNode parent , StructuralPropertyDescriptor property , int offset , String keyword , String endKeyword , String separator ) { this . constantSeparator = separator ; return rewriteList ( parent , property , keyword , endKeyword , offset ) ; } } private int rewriteRequiredNode ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) == RewriteEvent . REPLACED ) { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( node ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemoveAndVisit ( offset , length , node , editGroup ) ; doTextInsert ( offset , ( ASTNode ) event . getNewValue ( ) , getIndent ( offset ) , true , editGroup ) ; return offset + length ; } return doVisit ( parent , property , <NUM_LIT:0> ) ; } private int rewriteNode ( ASTNode parent , StructuralPropertyDescriptor property , int offset , Prefix prefix ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { ASTNode node = ( ASTNode ) event . getNewValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; int indent = getIndent ( offset ) ; doTextInsert ( offset , prefix . getPrefix ( indent ) , editGroup ) ; doTextInsert ( offset , node , indent , true , editGroup ) ; return offset ; } case RewriteEvent . REMOVED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; int nodeEnd ; int len ; if ( offset == <NUM_LIT:0> ) { SourceRange range = getExtendedRange ( node ) ; offset = range . getStartPosition ( ) ; len = range . getLength ( ) ; nodeEnd = offset + len ; } else { nodeEnd = getExtendedEnd ( node ) ; len = nodeEnd - offset ; } doTextRemoveAndVisit ( offset , len , node , editGroup ) ; return nodeEnd ; } case RewriteEvent . REPLACED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( node ) ; int nodeOffset = range . getStartPosition ( ) ; int nodeLen = range . getLength ( ) ; doTextRemoveAndVisit ( nodeOffset , nodeLen , node , editGroup ) ; doTextInsert ( nodeOffset , ( ASTNode ) event . getNewValue ( ) , getIndent ( offset ) , true , editGroup ) ; return nodeOffset + nodeLen ; } } } return doVisit ( parent , property , offset ) ; } private int rewriteJavadoc ( ASTNode node , StructuralPropertyDescriptor property ) { int pos = rewriteNode ( node , property , node . getStartPosition ( ) , ASTRewriteFormatter . NONE ) ; int changeKind = getChangeKind ( node , property ) ; if ( changeKind == RewriteEvent . INSERTED ) { String indent = getLineDelimiter ( ) + getIndentAtOffset ( pos ) ; doTextInsert ( pos , indent , getEditGroup ( node , property ) ) ; } else if ( changeKind == RewriteEvent . REMOVED ) { try { getScanner ( ) . readNext ( pos , false ) ; doTextRemove ( pos , getScanner ( ) . getCurrentStartOffset ( ) - pos , getEditGroup ( node , property ) ) ; pos = getScanner ( ) . getCurrentStartOffset ( ) ; } catch ( CoreException e ) { handleException ( e ) ; } } return pos ; } private int rewriteBodyNode ( ASTNode parent , StructuralPropertyDescriptor property , int offset , int endPos , int indent , BlockContext context ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { ASTNode node = ( ASTNode ) event . getNewValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; String [ ] strings = context . getPrefixAndSuffix ( indent , node , this . eventStore ) ; doTextInsert ( offset , strings [ <NUM_LIT:0> ] , editGroup ) ; doTextInsert ( offset , node , indent , true , editGroup ) ; doTextInsert ( offset , strings [ <NUM_LIT:1> ] , editGroup ) ; return offset ; } case RewriteEvent . REMOVED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; if ( endPos == - <NUM_LIT:1> ) { endPos = getExtendedEnd ( node ) ; } TextEditGroup editGroup = getEditGroup ( event ) ; int len = endPos - offset ; doTextRemoveAndVisit ( offset , len , node , editGroup ) ; return endPos ; } case RewriteEvent . REPLACED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; boolean insertNewLine = false ; if ( endPos == - <NUM_LIT:1> ) { int previousEnd = node . getStartPosition ( ) + node . getLength ( ) ; endPos = getExtendedEnd ( node ) ; if ( endPos != previousEnd ) { int token = TokenScanner . END_OF_FILE ; try { token = getScanner ( ) . readNext ( previousEnd , false ) ; } catch ( CoreException e ) { } if ( token == TerminalTokens . TokenNameCOMMENT_LINE ) { insertNewLine = true ; } } } TextEditGroup editGroup = getEditGroup ( event ) ; int nodeLen = endPos - offset ; ASTNode replacingNode = ( ASTNode ) event . getNewValue ( ) ; String [ ] strings = context . getPrefixAndSuffix ( indent , replacingNode , this . eventStore ) ; doTextRemoveAndVisit ( offset , nodeLen , node , editGroup ) ; String prefix = strings [ <NUM_LIT:0> ] ; String insertedPrefix = prefix ; if ( insertNewLine ) { insertedPrefix = getLineDelimiter ( ) + this . formatter . createIndentString ( indent ) + insertedPrefix . trim ( ) + '<CHAR_LIT:U+0020>' ; } doTextInsert ( offset , insertedPrefix , editGroup ) ; int lineStart = getCurrentLineStart ( prefix , prefix . length ( ) ) ; if ( lineStart != <NUM_LIT:0> ) { indent = this . formatter . computeIndentUnits ( prefix . substring ( lineStart ) ) ; } doTextInsert ( offset , replacingNode , indent , true , editGroup ) ; doTextInsert ( offset , strings [ <NUM_LIT:1> ] , editGroup ) ; return endPos ; } } } int pos = doVisit ( parent , property , offset ) ; if ( endPos != - <NUM_LIT:1> ) { return endPos ; } return pos ; } private int rewriteOptionalQualifier ( ASTNode parent , StructuralPropertyDescriptor property , int startPos ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { ASTNode node = ( ASTNode ) event . getNewValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; doTextInsert ( startPos , node , getIndent ( startPos ) , true , editGroup ) ; doTextInsert ( startPos , "<STR_LIT:.>" , editGroup ) ; return startPos ; } case RewriteEvent . REMOVED : { try { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; int dotEnd = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , node . getStartPosition ( ) + node . getLength ( ) ) ; doTextRemoveAndVisit ( startPos , dotEnd - startPos , node , editGroup ) ; return dotEnd ; } catch ( CoreException e ) { handleException ( e ) ; } break ; } case RewriteEvent . REPLACED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( node ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemoveAndVisit ( offset , length , node , editGroup ) ; doTextInsert ( offset , ( ASTNode ) event . getNewValue ( ) , getIndent ( startPos ) , true , editGroup ) ; try { return getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , offset + length ) ; } catch ( CoreException e ) { handleException ( e ) ; } break ; } } } Object node = getOriginalValue ( parent , property ) ; if ( node == null ) { return startPos ; } int pos = doVisit ( ( ASTNode ) node ) ; try { return getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } return pos ; } class ParagraphListRewriter extends ListRewriter { public final static int DEFAULT_SPACING = <NUM_LIT:1> ; private int initialIndent ; private int separatorLines ; public ParagraphListRewriter ( int initialIndent , int separator ) { this . initialIndent = initialIndent ; this . separatorLines = separator ; } protected int getInitialIndent ( ) { return this . initialIndent ; } protected String getSeparatorString ( int nodeIndex ) { return getSeparatorString ( nodeIndex , nodeIndex + <NUM_LIT:1> ) ; } protected String getSeparatorString ( int nodeIndex , int nextNodeIndex ) { int newLines = this . separatorLines == - <NUM_LIT:1> ? getNewLines ( nodeIndex ) : this . separatorLines ; String lineDelim = getLineDelimiter ( ) ; StringBuffer buf = new StringBuffer ( lineDelim ) ; for ( int i = <NUM_LIT:0> ; i < newLines ; i ++ ) { buf . append ( lineDelim ) ; } buf . append ( createIndentString ( getNodeIndent ( nextNodeIndex ) ) ) ; return buf . toString ( ) ; } private ASTNode getNode ( int nodeIndex ) { ASTNode elem = ( ASTNode ) this . list [ nodeIndex ] . getOriginalValue ( ) ; if ( elem == null ) { elem = ( ASTNode ) this . list [ nodeIndex ] . getNewValue ( ) ; } return elem ; } private int getNewLines ( int nodeIndex ) { ASTNode curr = getNode ( nodeIndex ) ; ASTNode next = getNode ( nodeIndex + <NUM_LIT:1> ) ; int currKind = curr . getNodeType ( ) ; int nextKind = next . getNodeType ( ) ; ASTNode last = null ; ASTNode secondLast = null ; for ( int i = <NUM_LIT:0> ; i < this . list . length ; i ++ ) { ASTNode elem = ( ASTNode ) this . list [ i ] . getOriginalValue ( ) ; if ( elem != null ) { if ( last != null ) { if ( elem . getNodeType ( ) == nextKind && last . getNodeType ( ) == currKind ) { return countEmptyLines ( last ) ; } secondLast = last ; } last = elem ; } } if ( currKind == ASTNode . FIELD_DECLARATION && nextKind == ASTNode . FIELD_DECLARATION ) { return <NUM_LIT:0> ; } if ( secondLast != null ) { return countEmptyLines ( secondLast ) ; } return DEFAULT_SPACING ; } private int countEmptyLines ( ASTNode last ) { LineInformation lineInformation = getLineInformation ( ) ; int lastLine = lineInformation . getLineOfOffset ( getExtendedEnd ( last ) ) ; if ( lastLine >= <NUM_LIT:0> ) { int startLine = lastLine + <NUM_LIT:1> ; int start = lineInformation . getLineOffset ( startLine ) ; if ( start < <NUM_LIT:0> ) { return <NUM_LIT:0> ; } char [ ] cont = getContent ( ) ; int i = start ; while ( i < cont . length && ScannerHelper . isWhitespace ( cont [ i ] ) ) { i ++ ; } if ( i > start ) { lastLine = lineInformation . getLineOfOffset ( i ) ; if ( lastLine > startLine ) { return lastLine - startLine ; } } } return <NUM_LIT:0> ; } protected boolean mustRemoveSeparator ( int originalOffset , int nodeIndex ) { int previousNonRemovedNodeIndex = nodeIndex - <NUM_LIT:1> ; while ( previousNonRemovedNodeIndex >= <NUM_LIT:0> && this . list [ previousNonRemovedNodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { previousNonRemovedNodeIndex -- ; } if ( previousNonRemovedNodeIndex > - <NUM_LIT:1> ) { LineInformation lineInformation = getLineInformation ( ) ; RewriteEvent prevEvent = this . list [ previousNonRemovedNodeIndex ] ; int prevKind = prevEvent . getChangeKind ( ) ; if ( prevKind == RewriteEvent . UNCHANGED || prevKind == RewriteEvent . REPLACED ) { ASTNode prevNode = ( ASTNode ) this . list [ previousNonRemovedNodeIndex ] . getOriginalValue ( ) ; int prevEndPosition = prevNode . getStartPosition ( ) + prevNode . getLength ( ) ; int prevLine = lineInformation . getLineOfOffset ( prevEndPosition ) ; int line = lineInformation . getLineOfOffset ( originalOffset ) ; if ( prevLine == line && nodeIndex + <NUM_LIT:1> < this . list . length ) { RewriteEvent nextEvent = this . list [ nodeIndex + <NUM_LIT:1> ] ; int nextKind = nextEvent . getChangeKind ( ) ; if ( nextKind == RewriteEvent . UNCHANGED || prevKind == RewriteEvent . REPLACED ) { ASTNode nextNode = ( ASTNode ) nextEvent . getOriginalValue ( ) ; int nextStartPosition = nextNode . getStartPosition ( ) ; int nextLine = lineInformation . getLineOfOffset ( nextStartPosition ) ; return nextLine == line ; } return false ; } } } return true ; } } private int rewriteParagraphList ( ASTNode parent , StructuralPropertyDescriptor property , int insertPos , int insertIndent , int separator , int lead ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event == null || event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { return doVisit ( parent , property , insertPos ) ; } RewriteEvent [ ] events = event . getChildren ( ) ; ParagraphListRewriter listRewriter = new ParagraphListRewriter ( insertIndent , separator ) ; StringBuffer leadString = new StringBuffer ( ) ; if ( isAllOfKind ( events , RewriteEvent . INSERTED ) ) { for ( int i = <NUM_LIT:0> ; i < lead ; i ++ ) { leadString . append ( getLineDelimiter ( ) ) ; } leadString . append ( createIndentString ( insertIndent ) ) ; } return listRewriter . rewriteList ( parent , property , insertPos , leadString . toString ( ) ) ; } private int rewriteOptionalTypeParameters ( ASTNode parent , StructuralPropertyDescriptor property , int offset , String keyword , boolean adjustOnNext , boolean needsSpaceOnRemoveAll ) { int pos = offset ; RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] children = event . getChildren ( ) ; try { boolean isAllInserted = isAllOfKind ( children , RewriteEvent . INSERTED ) ; if ( isAllInserted && adjustOnNext ) { pos = getScanner ( ) . getNextStartOffset ( pos , false ) ; } boolean isAllRemoved = ! isAllInserted && isAllOfKind ( children , RewriteEvent . REMOVED ) ; if ( isAllRemoved ) { int posBeforeOpenBracket = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameLESS , pos ) ; if ( posBeforeOpenBracket != pos ) { needsSpaceOnRemoveAll = false ; } pos = posBeforeOpenBracket ; } pos = new ListRewriter ( ) . rewriteList ( parent , property , pos , String . valueOf ( '<CHAR_LIT>' ) , "<STR_LIT:U+002CU+0020>" ) ; if ( isAllRemoved ) { int endPos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameGREATER , pos ) ; endPos = getScanner ( ) . getNextStartOffset ( endPos , false ) ; String replacement = needsSpaceOnRemoveAll ? String . valueOf ( '<CHAR_LIT:U+0020>' ) : Util . EMPTY_STRING ; doTextReplace ( pos , endPos - pos , replacement , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; return endPos ; } else if ( isAllInserted ) { doTextInsert ( pos , String . valueOf ( '<CHAR_LIT:>>' + keyword ) , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; return pos ; } } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = doVisit ( parent , property , pos ) ; } if ( pos != offset ) { try { return getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameGREATER , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } return pos ; } private boolean isAllOfKind ( RewriteEvent [ ] children , int kind ) { for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { if ( children [ i ] . getChangeKind ( ) != kind ) { return false ; } } return true ; } private int rewriteNodeList ( ASTNode parent , StructuralPropertyDescriptor property , int pos , String keyword , String endKeyword , String separator ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { return new ListRewriter ( ) . rewriteList ( parent , property , pos , keyword , endKeyword , separator ) ; } return doVisit ( parent , property , pos ) ; } private int rewriteNodeList ( ASTNode parent , StructuralPropertyDescriptor property , int pos , String keyword , String separator ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { return new ListRewriter ( ) . rewriteList ( parent , property , pos , keyword , separator ) ; } return doVisit ( parent , property , pos ) ; } private void rewriteMethodBody ( MethodDeclaration parent , int startPos ) { RewriteEvent event = getEvent ( parent , MethodDeclaration . BODY_PROPERTY ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { int endPos = parent . getStartPosition ( ) + parent . getLength ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; ASTNode body = ( ASTNode ) event . getNewValue ( ) ; doTextRemove ( startPos , endPos - startPos , editGroup ) ; int indent = getIndent ( parent . getStartPosition ( ) ) ; String prefix = this . formatter . METHOD_BODY . getPrefix ( indent ) ; doTextInsert ( startPos , prefix , editGroup ) ; doTextInsert ( startPos , body , indent , true , editGroup ) ; return ; } case RewriteEvent . REMOVED : { TextEditGroup editGroup = getEditGroup ( event ) ; ASTNode body = ( ASTNode ) event . getOriginalValue ( ) ; int endPos = parent . getStartPosition ( ) + parent . getLength ( ) ; doTextRemoveAndVisit ( startPos , endPos - startPos , body , editGroup ) ; doTextInsert ( startPos , "<STR_LIT:;>" , editGroup ) ; return ; } case RewriteEvent . REPLACED : { TextEditGroup editGroup = getEditGroup ( event ) ; ASTNode body = ( ASTNode ) event . getOriginalValue ( ) ; doTextRemoveAndVisit ( body . getStartPosition ( ) , body . getLength ( ) , body , editGroup ) ; doTextInsert ( body . getStartPosition ( ) , ( ASTNode ) event . getNewValue ( ) , getIndent ( body . getStartPosition ( ) ) , true , editGroup ) ; return ; } } } voidVisit ( parent , MethodDeclaration . BODY_PROPERTY ) ; } private int rewriteExtraDimensions ( ASTNode parent , StructuralPropertyDescriptor property , int pos ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event == null || event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { return ( ( Integer ) getOriginalValue ( parent , property ) ) . intValue ( ) ; } int oldDim = ( ( Integer ) event . getOriginalValue ( ) ) . intValue ( ) ; int newDim = ( ( Integer ) event . getNewValue ( ) ) . intValue ( ) ; if ( oldDim != newDim ) { TextEditGroup editGroup = getEditGroup ( event ) ; rewriteExtraDimensions ( oldDim , newDim , pos , editGroup ) ; } return oldDim ; } private void rewriteExtraDimensions ( int oldDim , int newDim , int pos , TextEditGroup editGroup ) { if ( oldDim < newDim ) { for ( int i = oldDim ; i < newDim ; i ++ ) { doTextInsert ( pos , "<STR_LIT:[]>" , editGroup ) ; } } else if ( newDim < oldDim ) { try { getScanner ( ) . setOffset ( pos ) ; for ( int i = newDim ; i < oldDim ; i ++ ) { getScanner ( ) . readToToken ( TerminalTokens . TokenNameRBRACKET ) ; } doTextRemove ( pos , getScanner ( ) . getCurrentEndOffset ( ) - pos , editGroup ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } private int getPosAfterLeftBrace ( int pos ) { try { int nextToken = getScanner ( ) . readNext ( pos , true ) ; if ( nextToken == TerminalTokens . TokenNameLBRACE ) { return getScanner ( ) . getCurrentEndOffset ( ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return pos ; } private int getPosAfterTry ( int pos ) { try { int nextToken = getScanner ( ) . readNext ( pos , true ) ; if ( nextToken == TerminalTokens . TokenNametry ) { return getScanner ( ) . getCurrentEndOffset ( ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return pos ; } final int getIndent ( int offset ) { return this . formatter . computeIndentUnits ( getIndentOfLine ( offset ) ) ; } final void doTextInsert ( int insertOffset , ASTNode node , int initialIndentLevel , boolean removeLeadingIndent , TextEditGroup editGroup ) { ArrayList markers = new ArrayList ( ) ; String formatted = this . formatter . getFormattedResult ( node , initialIndentLevel , markers ) ; int currPos = <NUM_LIT:0> ; if ( removeLeadingIndent ) { while ( currPos < formatted . length ( ) && ScannerHelper . isWhitespace ( formatted . charAt ( currPos ) ) ) { currPos ++ ; } } for ( int i = <NUM_LIT:0> ; i < markers . size ( ) ; i ++ ) { NodeMarker curr = ( NodeMarker ) markers . get ( i ) ; int offset = curr . offset ; if ( offset >= currPos ) { String insertStr = formatted . substring ( currPos , offset ) ; doTextInsert ( insertOffset , insertStr , editGroup ) ; } else { continue ; } Object data = curr . data ; if ( data instanceof TextEditGroup ) { TextEdit edit = new RangeMarker ( insertOffset , <NUM_LIT:0> ) ; addEditGroup ( ( TextEditGroup ) data , edit ) ; addEdit ( edit ) ; if ( curr . length != <NUM_LIT:0> ) { int end = offset + curr . length ; int k = i + <NUM_LIT:1> ; while ( k < markers . size ( ) && ( ( NodeMarker ) markers . get ( k ) ) . offset < end ) { k ++ ; } curr . offset = end ; curr . length = <NUM_LIT:0> ; markers . add ( k , curr ) ; } currPos = offset ; } else { int lineOffset = getCurrentLineStart ( formatted , offset ) ; String destIndentString = ( lineOffset == <NUM_LIT:0> ) ? this . formatter . createIndentString ( initialIndentLevel ) : this . formatter . getIndentString ( formatted . substring ( lineOffset , offset ) ) ; if ( data instanceof CopyPlaceholderData ) { CopySourceInfo copySource = ( ( CopyPlaceholderData ) data ) . copySource ; int srcIndentLevel = getIndent ( copySource . getNode ( ) . getStartPosition ( ) ) ; TextEdit sourceEdit = getCopySourceEdit ( copySource ) ; doTextCopy ( sourceEdit , insertOffset , srcIndentLevel , destIndentString , editGroup ) ; currPos = offset + curr . length ; if ( needsNewLineForLineComment ( copySource . getNode ( ) , formatted , currPos ) ) { doTextInsert ( insertOffset , getLineDelimiter ( ) , editGroup ) ; } } else if ( data instanceof StringPlaceholderData ) { String code = ( ( StringPlaceholderData ) data ) . code ; String str = this . formatter . changeIndent ( code , <NUM_LIT:0> , destIndentString ) ; doTextInsert ( insertOffset , str , editGroup ) ; currPos = offset + curr . length ; } } } if ( currPos < formatted . length ( ) ) { String insertStr = formatted . substring ( currPos ) ; doTextInsert ( insertOffset , insertStr , editGroup ) ; } } private boolean needsNewLineForLineComment ( ASTNode node , String formatted , int offset ) { if ( ! this . lineCommentEndOffsets . isEndOfLineComment ( getExtendedEnd ( node ) , this . content ) ) { return false ; } return offset < formatted . length ( ) && ! IndentManipulation . isLineDelimiterChar ( formatted . charAt ( offset ) ) ; } private int getCurrentLineStart ( String str , int pos ) { for ( int i = pos - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { char ch = str . charAt ( i ) ; if ( IndentManipulation . isLineDelimiterChar ( ch ) ) { return i + <NUM_LIT:1> ; } } return <NUM_LIT:0> ; } private void rewriteModifiers ( ASTNode parent , StructuralPropertyDescriptor property , int offset ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event == null || event . getChangeKind ( ) != RewriteEvent . REPLACED ) { return ; } try { int oldModifiers = ( ( Integer ) event . getOriginalValue ( ) ) . intValue ( ) ; int newModifiers = ( ( Integer ) event . getNewValue ( ) ) . intValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; TokenScanner scanner = getScanner ( ) ; int tok = scanner . readNext ( offset , false ) ; int startPos = scanner . getCurrentStartOffset ( ) ; int nextStart = startPos ; loop : while ( true ) { if ( TokenScanner . isComment ( tok ) ) { tok = scanner . readNext ( true ) ; } boolean keep = true ; switch ( tok ) { case TerminalTokens . TokenNamepublic : keep = Modifier . isPublic ( newModifiers ) ; break ; case TerminalTokens . TokenNameprotected : keep = Modifier . isProtected ( newModifiers ) ; break ; case TerminalTokens . TokenNameprivate : keep = Modifier . isPrivate ( newModifiers ) ; break ; case TerminalTokens . TokenNamestatic : keep = Modifier . isStatic ( newModifiers ) ; break ; case TerminalTokens . TokenNamefinal : keep = Modifier . isFinal ( newModifiers ) ; break ; case TerminalTokens . TokenNameabstract : keep = Modifier . isAbstract ( newModifiers ) ; break ; case TerminalTokens . TokenNamenative : keep = Modifier . isNative ( newModifiers ) ; break ; case TerminalTokens . TokenNamevolatile : keep = Modifier . isVolatile ( newModifiers ) ; break ; case TerminalTokens . TokenNamestrictfp : keep = Modifier . isStrictfp ( newModifiers ) ; break ; case TerminalTokens . TokenNametransient : keep = Modifier . isTransient ( newModifiers ) ; break ; case TerminalTokens . TokenNamesynchronized : keep = Modifier . isSynchronized ( newModifiers ) ; break ; default : break loop ; } tok = getScanner ( ) . readNext ( false ) ; int currPos = nextStart ; nextStart = getScanner ( ) . getCurrentStartOffset ( ) ; if ( ! keep ) { doTextRemove ( currPos , nextStart - currPos , editGroup ) ; } } int addedModifiers = newModifiers & ~ oldModifiers ; if ( addedModifiers != <NUM_LIT:0> ) { if ( startPos != nextStart ) { int visibilityModifiers = addedModifiers & ( Modifier . PUBLIC | Modifier . PRIVATE | Modifier . PROTECTED ) ; if ( visibilityModifiers != <NUM_LIT:0> ) { StringBuffer buf = new StringBuffer ( ) ; ASTRewriteFlattener . printModifiers ( visibilityModifiers , buf ) ; doTextInsert ( startPos , buf . toString ( ) , editGroup ) ; addedModifiers &= ~ visibilityModifiers ; } } StringBuffer buf = new StringBuffer ( ) ; ASTRewriteFlattener . printModifiers ( addedModifiers , buf ) ; doTextInsert ( nextStart , buf . toString ( ) , editGroup ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } class ModifierRewriter extends ListRewriter { private final Prefix annotationSeparation ; public ModifierRewriter ( Prefix annotationSeparation ) { this . annotationSeparation = annotationSeparation ; } protected String getSeparatorString ( int nodeIndex ) { ASTNode curr = getNewNode ( nodeIndex ) ; if ( curr instanceof Annotation ) { return this . annotationSeparation . getPrefix ( getNodeIndent ( nodeIndex + <NUM_LIT:1> ) ) ; } return super . getSeparatorString ( nodeIndex ) ; } } private int rewriteModifiers2 ( ASTNode node , ChildListPropertyDescriptor property , int pos ) { RewriteEvent event = getEvent ( node , property ) ; if ( event == null || event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { return doVisit ( node , property , pos ) ; } RewriteEvent [ ] children = event . getChildren ( ) ; boolean isAllInsert = isAllOfKind ( children , RewriteEvent . INSERTED ) ; boolean isAllRemove = isAllOfKind ( children , RewriteEvent . REMOVED ) ; if ( isAllInsert || isAllRemove ) { try { pos = getScanner ( ) . getNextStartOffset ( pos , false ) ; } catch ( CoreException e ) { handleException ( e ) ; } } Prefix formatterPrefix ; if ( property == SingleVariableDeclaration . MODIFIERS2_PROPERTY ) formatterPrefix = this . formatter . PARAM_ANNOTATION_SEPARATION ; else formatterPrefix = this . formatter . ANNOTATION_SEPARATION ; int endPos = new ModifierRewriter ( formatterPrefix ) . rewriteList ( node , property , pos , Util . EMPTY_STRING , "<STR_LIT:U+0020>" ) ; try { int nextPos = getScanner ( ) . getNextStartOffset ( endPos , false ) ; boolean lastUnchanged = children [ children . length - <NUM_LIT:1> ] . getChangeKind ( ) != RewriteEvent . UNCHANGED ; if ( isAllRemove ) { doTextRemove ( endPos , nextPos - endPos , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; return nextPos ; } else if ( isAllInsert || ( nextPos == endPos && lastUnchanged ) ) { RewriteEvent lastChild = children [ children . length - <NUM_LIT:1> ] ; String separator ; if ( lastChild . getNewValue ( ) instanceof Annotation ) { separator = formatterPrefix . getPrefix ( getIndent ( pos ) ) ; } else { separator = String . valueOf ( '<CHAR_LIT:U+0020>' ) ; } doTextInsert ( endPos , separator , getEditGroup ( lastChild ) ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return endPos ; } private void replaceOperation ( int posBeforeOperation , String newOperation , TextEditGroup editGroup ) { try { getScanner ( ) . readNext ( posBeforeOperation , true ) ; doTextReplace ( getScanner ( ) . getCurrentStartOffset ( ) , getScanner ( ) . getCurrentLength ( ) , newOperation , editGroup ) ; } catch ( CoreException e ) { handleException ( e ) ; } } private void rewriteOperation ( ASTNode parent , StructuralPropertyDescriptor property , int posBeforeOperation ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { try { String newOperation = event . getNewValue ( ) . toString ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; getScanner ( ) . readNext ( posBeforeOperation , true ) ; doTextReplace ( getScanner ( ) . getCurrentStartOffset ( ) , getScanner ( ) . getCurrentLength ( ) , newOperation , editGroup ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } public void postVisit ( ASTNode node ) { TextEditGroup editGroup = this . eventStore . getTrackedNodeData ( node ) ; if ( editGroup != null ) { this . currentEdit = this . currentEdit . getParent ( ) ; } doCopySourcePostVisit ( node , this . sourceCopyEndNodes ) ; } public void preVisit ( ASTNode node ) { CopySourceInfo [ ] infos = this . eventStore . getNodeCopySources ( node ) ; doCopySourcePreVisit ( infos , this . sourceCopyEndNodes ) ; TextEditGroup editGroup = this . eventStore . getTrackedNodeData ( node ) ; if ( editGroup != null ) { SourceRange range = getExtendedRange ( node ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; TextEdit edit = new RangeMarker ( offset , length ) ; addEditGroup ( editGroup , edit ) ; addEdit ( edit ) ; this . currentEdit = edit ; } ensureSpaceBeforeReplace ( node ) ; } final void doCopySourcePreVisit ( CopySourceInfo [ ] infos , Stack nodeEndStack ) { if ( infos != null ) { for ( int i = <NUM_LIT:0> ; i < infos . length ; i ++ ) { CopySourceInfo curr = infos [ i ] ; TextEdit edit = getCopySourceEdit ( curr ) ; addEdit ( edit ) ; this . currentEdit = edit ; nodeEndStack . push ( curr . getNode ( ) ) ; } } } final void doCopySourcePostVisit ( ASTNode node , Stack nodeEndStack ) { while ( ! nodeEndStack . isEmpty ( ) && nodeEndStack . peek ( ) == node ) { nodeEndStack . pop ( ) ; this . currentEdit = this . currentEdit . getParent ( ) ; } } public boolean visit ( CompilationUnit node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = rewriteNode ( node , CompilationUnit . PACKAGE_PROPERTY , <NUM_LIT:0> , ASTRewriteFormatter . NONE ) ; if ( getChangeKind ( node , CompilationUnit . PACKAGE_PROPERTY ) == RewriteEvent . INSERTED ) { doTextInsert ( <NUM_LIT:0> , getLineDelimiter ( ) , getEditGroup ( node , CompilationUnit . PACKAGE_PROPERTY ) ) ; } startPos = rewriteParagraphList ( node , CompilationUnit . IMPORTS_PROPERTY , startPos , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> ) ; rewriteParagraphList ( node , CompilationUnit . TYPES_PROPERTY , startPos , <NUM_LIT:0> , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( TypeDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int apiLevel = node . getAST ( ) . apiLevel ( ) ; int pos = rewriteJavadoc ( node , TypeDeclaration . JAVADOC_PROPERTY ) ; boolean isJLS2 = apiLevel == JLS2_INTERNAL ; if ( isJLS2 ) { rewriteModifiers ( node , TypeDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , TypeDeclaration . MODIFIERS2_PROPERTY , pos ) ; } boolean isInterface = ( ( Boolean ) getOriginalValue ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) . booleanValue ( ) ; boolean invertType = isChanged ( node , TypeDeclaration . INTERFACE_PROPERTY ) ; if ( invertType ) { try { int typeToken = isInterface ? TerminalTokens . TokenNameinterface : TerminalTokens . TokenNameclass ; int startPosition = node . getStartPosition ( ) ; if ( ! isJLS2 ) { List modifiers = node . modifiers ( ) ; final int size = modifiers . size ( ) ; if ( size != <NUM_LIT:0> ) { ASTNode modifierNode = ( ASTNode ) modifiers . get ( size - <NUM_LIT:1> ) ; startPosition = modifierNode . getStartPosition ( ) + modifierNode . getLength ( ) ; } } getScanner ( ) . readToToken ( typeToken , startPosition ) ; String str = isInterface ? "<STR_LIT:class>" : "<STR_LIT>" ; int start = getScanner ( ) . getCurrentStartOffset ( ) ; int end = getScanner ( ) . getCurrentEndOffset ( ) ; doTextReplace ( start , end - start , str , getEditGroup ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) ; } catch ( CoreException e ) { } } pos = rewriteRequiredNode ( node , TypeDeclaration . NAME_PROPERTY ) ; if ( ! isJLS2 ) { pos = rewriteOptionalTypeParameters ( node , TypeDeclaration . TYPE_PARAMETERS_PROPERTY , pos , Util . EMPTY_STRING , false , true ) ; } if ( ! isInterface || invertType ) { ChildPropertyDescriptor superClassProperty = isJLS2 ? TypeDeclaration . SUPERCLASS_PROPERTY : TypeDeclaration . SUPERCLASS_TYPE_PROPERTY ; RewriteEvent superClassEvent = getEvent ( node , superClassProperty ) ; int changeKind = superClassEvent != null ? superClassEvent . getChangeKind ( ) : RewriteEvent . UNCHANGED ; switch ( changeKind ) { case RewriteEvent . INSERTED : { doTextInsert ( pos , "<STR_LIT>" , getEditGroup ( superClassEvent ) ) ; doTextInsert ( pos , ( ASTNode ) superClassEvent . getNewValue ( ) , <NUM_LIT:0> , false , getEditGroup ( superClassEvent ) ) ; break ; } case RewriteEvent . REMOVED : { ASTNode superClass = ( ASTNode ) superClassEvent . getOriginalValue ( ) ; int endPos = getExtendedEnd ( superClass ) ; doTextRemoveAndVisit ( pos , endPos - pos , superClass , getEditGroup ( superClassEvent ) ) ; pos = endPos ; break ; } case RewriteEvent . REPLACED : { ASTNode superClass = ( ASTNode ) superClassEvent . getOriginalValue ( ) ; SourceRange range = getExtendedRange ( superClass ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemoveAndVisit ( offset , length , superClass , getEditGroup ( superClassEvent ) ) ; doTextInsert ( offset , ( ASTNode ) superClassEvent . getNewValue ( ) , <NUM_LIT:0> , false , getEditGroup ( superClassEvent ) ) ; pos = offset + length ; break ; } case RewriteEvent . UNCHANGED : { pos = doVisit ( node , superClassProperty , pos ) ; } } } ChildListPropertyDescriptor superInterfaceProperty = isJLS2 ? TypeDeclaration . SUPER_INTERFACES_PROPERTY : TypeDeclaration . SUPER_INTERFACE_TYPES_PROPERTY ; RewriteEvent interfaceEvent = getEvent ( node , superInterfaceProperty ) ; if ( interfaceEvent == null || interfaceEvent . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { if ( invertType ) { List originalNodes = ( List ) getOriginalValue ( node , superInterfaceProperty ) ; if ( ! originalNodes . isEmpty ( ) ) { String keyword = isInterface ? "<STR_LIT>" : "<STR_LIT>" ; ASTNode firstNode = ( ASTNode ) originalNodes . get ( <NUM_LIT:0> ) ; doTextReplace ( pos , firstNode . getStartPosition ( ) - pos , keyword , getEditGroup ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) ; } } pos = doVisit ( node , superInterfaceProperty , pos ) ; } else { String keyword = ( isInterface == invertType ) ? "<STR_LIT>" : "<STR_LIT>" ; if ( invertType ) { List newNodes = ( List ) interfaceEvent . getNewValue ( ) ; if ( ! newNodes . isEmpty ( ) ) { List origNodes = ( List ) interfaceEvent . getOriginalValue ( ) ; int firstStart = pos ; if ( ! origNodes . isEmpty ( ) ) { firstStart = ( ( ASTNode ) origNodes . get ( <NUM_LIT:0> ) ) . getStartPosition ( ) ; } doTextReplace ( pos , firstStart - pos , keyword , getEditGroup ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) ; keyword = Util . EMPTY_STRING ; pos = firstStart ; } } pos = rewriteNodeList ( node , superInterfaceProperty , pos , keyword , "<STR_LIT:U+002CU+0020>" ) ; } int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; int startPos = getPosAfterLeftBrace ( pos ) ; rewriteParagraphList ( node , TypeDeclaration . BODY_DECLARATIONS_PROPERTY , startPos , startIndent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } private void rewriteReturnType ( MethodDeclaration node , boolean isConstructor , boolean isConstructorChange ) { ChildPropertyDescriptor property = ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) ? MethodDeclaration . RETURN_TYPE_PROPERTY : MethodDeclaration . RETURN_TYPE2_PROPERTY ; ASTNode originalReturnType = ( ASTNode ) getOriginalValue ( node , property ) ; boolean returnTypeExists = originalReturnType != null && originalReturnType . getStartPosition ( ) != - <NUM_LIT:1> ; if ( ! isConstructorChange && returnTypeExists ) { rewriteRequiredNode ( node , property ) ; ensureSpaceAfterReplace ( node , property ) ; return ; } ASTNode newReturnType = ( ASTNode ) getNewValue ( node , property ) ; if ( isConstructorChange || ! returnTypeExists && newReturnType != originalReturnType ) { ASTNode originalMethodName = ( ASTNode ) getOriginalValue ( node , MethodDeclaration . NAME_PROPERTY ) ; int nextStart = originalMethodName . getStartPosition ( ) ; TextEditGroup editGroup = getEditGroup ( node , property ) ; if ( isConstructor || ! returnTypeExists ) { doTextInsert ( nextStart , newReturnType , getIndent ( nextStart ) , true , editGroup ) ; doTextInsert ( nextStart , "<STR_LIT:U+0020>" , editGroup ) ; } else { int offset = getExtendedOffset ( originalReturnType ) ; doTextRemoveAndVisit ( offset , nextStart - offset , originalReturnType , editGroup ) ; } } } public boolean visit ( MethodDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , MethodDeclaration . JAVADOC_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , MethodDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { pos = rewriteModifiers2 ( node , MethodDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteOptionalTypeParameters ( node , MethodDeclaration . TYPE_PARAMETERS_PROPERTY , pos , "<STR_LIT:U+0020>" , true , pos != node . getStartPosition ( ) ) ; } boolean isConstructorChange = isChanged ( node , MethodDeclaration . CONSTRUCTOR_PROPERTY ) ; boolean isConstructor = ( ( Boolean ) getOriginalValue ( node , MethodDeclaration . CONSTRUCTOR_PROPERTY ) ) . booleanValue ( ) ; if ( ! isConstructor || isConstructorChange ) { rewriteReturnType ( node , isConstructor , isConstructorChange ) ; } pos = rewriteRequiredNode ( node , MethodDeclaration . NAME_PROPERTY ) ; try { if ( isChanged ( node , MethodDeclaration . PARAMETERS_PROPERTY ) ) { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; pos = rewriteNodeList ( node , MethodDeclaration . PARAMETERS_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } else { pos = doVisit ( node , MethodDeclaration . PARAMETERS_PROPERTY , pos ) ; } pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; int extraDims = rewriteExtraDimensions ( node , MethodDeclaration . EXTRA_DIMENSIONS_PROPERTY , pos ) ; boolean hasExceptionChanges = isChanged ( node , MethodDeclaration . THROWN_EXCEPTIONS_PROPERTY ) ; int bodyChangeKind = getChangeKind ( node , MethodDeclaration . BODY_PROPERTY ) ; if ( ( extraDims > <NUM_LIT:0> ) && ( hasExceptionChanges || bodyChangeKind == RewriteEvent . INSERTED || bodyChangeKind == RewriteEvent . REMOVED ) ) { int dim = ( ( Integer ) getOriginalValue ( node , MethodDeclaration . EXTRA_DIMENSIONS_PROPERTY ) ) . intValue ( ) ; while ( dim > <NUM_LIT:0> ) { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRBRACKET , pos ) ; dim -- ; } } pos = rewriteNodeList ( node , MethodDeclaration . THROWN_EXCEPTIONS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; rewriteMethodBody ( node , pos ) ; } catch ( CoreException e ) { } return false ; } public boolean visit ( Block node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos ; if ( isCollapsed ( node ) ) { startPos = node . getStartPosition ( ) ; } else { startPos = getPosAfterLeftBrace ( node . getStartPosition ( ) ) ; } int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; rewriteParagraphList ( node , Block . STATEMENTS_PROPERTY , startPos , startIndent , <NUM_LIT:0> , <NUM_LIT:1> ) ; return false ; } public boolean visit ( ReturnStatement node ) { try { this . beforeRequiredSpaceIndex = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamereturn , node . getStartPosition ( ) ) ; if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ensureSpaceBeforeReplace ( node ) ; rewriteNode ( node , ReturnStatement . EXPRESSION_PROPERTY , this . beforeRequiredSpaceIndex , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( AnonymousClassDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = getPosAfterLeftBrace ( node . getStartPosition ( ) ) ; int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; rewriteParagraphList ( node , AnonymousClassDeclaration . BODY_DECLARATIONS_PROPERTY , startPos , startIndent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( ArrayAccess node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ArrayAccess . ARRAY_PROPERTY ) ; rewriteRequiredNode ( node , ArrayAccess . INDEX_PROPERTY ) ; return false ; } public boolean visit ( ArrayCreation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ArrayType arrayType = ( ArrayType ) getOriginalValue ( node , ArrayCreation . TYPE_PROPERTY ) ; int nOldBrackets = getDimensions ( arrayType ) ; int nNewBrackets = nOldBrackets ; TextEditGroup editGroup = null ; RewriteEvent typeEvent = getEvent ( node , ArrayCreation . TYPE_PROPERTY ) ; if ( typeEvent != null && typeEvent . getChangeKind ( ) == RewriteEvent . REPLACED ) { ArrayType replacingType = ( ArrayType ) typeEvent . getNewValue ( ) ; editGroup = getEditGroup ( typeEvent ) ; Type newType = replacingType . getElementType ( ) ; Type oldType = getElementType ( arrayType ) ; if ( ! newType . equals ( oldType ) ) { SourceRange range = getExtendedRange ( oldType ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemove ( offset , length , editGroup ) ; doTextInsert ( offset , newType , <NUM_LIT:0> , false , editGroup ) ; } nNewBrackets = replacingType . getDimensions ( ) ; } voidVisit ( arrayType ) ; try { int offset = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameLBRACKET , arrayType . getStartPosition ( ) ) ; RewriteEvent dimEvent = getEvent ( node , ArrayCreation . DIMENSIONS_PROPERTY ) ; boolean hasDimensionChanges = ( dimEvent != null && dimEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) ; if ( hasDimensionChanges ) { RewriteEvent [ ] events = dimEvent . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < events . length ; i ++ ) { RewriteEvent event = events [ i ] ; int changeKind = event . getChangeKind ( ) ; if ( changeKind == RewriteEvent . INSERTED ) { editGroup = getEditGroup ( event ) ; doTextInsert ( offset , "<STR_LIT:[>" , editGroup ) ; doTextInsert ( offset , ( ASTNode ) event . getNewValue ( ) , <NUM_LIT:0> , false , editGroup ) ; doTextInsert ( offset , "<STR_LIT:]>" , editGroup ) ; nNewBrackets -- ; } else { ASTNode elem = ( ASTNode ) event . getOriginalValue ( ) ; int elemEnd = elem . getStartPosition ( ) + elem . getLength ( ) ; int endPos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRBRACKET , elemEnd ) ; if ( changeKind == RewriteEvent . REMOVED ) { editGroup = getEditGroup ( event ) ; doTextRemoveAndVisit ( offset , endPos - offset , elem , editGroup ) ; } else if ( changeKind == RewriteEvent . REPLACED ) { editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( elem ) ; int elemOffset = range . getStartPosition ( ) ; int elemLength = range . getLength ( ) ; doTextRemoveAndVisit ( elemOffset , elemLength , elem , editGroup ) ; doTextInsert ( elemOffset , ( ASTNode ) event . getNewValue ( ) , <NUM_LIT:0> , false , editGroup ) ; nNewBrackets -- ; } else { voidVisit ( elem ) ; nNewBrackets -- ; } offset = endPos ; nOldBrackets -- ; } } } else { offset = doVisit ( node , ArrayCreation . DIMENSIONS_PROPERTY , offset ) ; } if ( nOldBrackets != nNewBrackets ) { if ( ! hasDimensionChanges ) { offset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRBRACKET , offset ) ; } rewriteExtraDimensions ( nOldBrackets , nNewBrackets , offset , editGroup ) ; } int kind = getChangeKind ( node , ArrayCreation . INITIALIZER_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { offset = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameLBRACE , offset ) ; } else { offset = node . getStartPosition ( ) + node . getLength ( ) ; } rewriteNode ( node , ArrayCreation . INITIALIZER_PROPERTY , offset , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } private Type getElementType ( ArrayType parent ) { Type t = ( Type ) getOriginalValue ( parent , ArrayType . COMPONENT_TYPE_PROPERTY ) ; while ( t . isArrayType ( ) ) { t = ( Type ) getOriginalValue ( t , ArrayType . COMPONENT_TYPE_PROPERTY ) ; } return t ; } private int getDimensions ( ArrayType parent ) { Type t = ( Type ) getOriginalValue ( parent , ArrayType . COMPONENT_TYPE_PROPERTY ) ; int dimensions = <NUM_LIT:1> ; while ( t . isArrayType ( ) ) { dimensions ++ ; t = ( Type ) getOriginalValue ( t , ArrayType . COMPONENT_TYPE_PROPERTY ) ; } return dimensions ; } public boolean visit ( ArrayInitializer node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = getPosAfterLeftBrace ( node . getStartPosition ( ) ) ; rewriteNodeList ( node , ArrayInitializer . EXPRESSIONS_PROPERTY , startPos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( ArrayType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ArrayType . COMPONENT_TYPE_PROPERTY ) ; return false ; } public boolean visit ( AssertStatement node ) { try { this . beforeRequiredSpaceIndex = getScanner ( ) . getNextEndOffset ( node . getStartPosition ( ) , true ) ; if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ensureSpaceBeforeReplace ( node ) ; int offset = rewriteRequiredNode ( node , AssertStatement . EXPRESSION_PROPERTY ) ; rewriteNode ( node , AssertStatement . MESSAGE_PROPERTY , offset , ASTRewriteFormatter . ASSERT_COMMENT ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( Assignment node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , Assignment . LEFT_HAND_SIDE_PROPERTY ) ; rewriteOperation ( node , Assignment . OPERATOR_PROPERTY , pos ) ; rewriteRequiredNode ( node , Assignment . RIGHT_HAND_SIDE_PROPERTY ) ; return false ; } public boolean visit ( BooleanLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } Boolean newLiteral = ( Boolean ) getNewValue ( node , BooleanLiteral . BOOLEAN_VALUE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , BooleanLiteral . BOOLEAN_VALUE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newLiteral . toString ( ) , group ) ; return false ; } public boolean visit ( BreakStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int offset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamebreak , node . getStartPosition ( ) ) ; rewriteNode ( node , BreakStatement . LABEL_PROPERTY , offset , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( CastExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , CastExpression . TYPE_PROPERTY ) ; rewriteRequiredNode ( node , CastExpression . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( CatchClause node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , CatchClause . EXCEPTION_PROPERTY ) ; rewriteRequiredNode ( node , CatchClause . BODY_PROPERTY ) ; return false ; } public boolean visit ( CharacterLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String escapedSeq = ( String ) getNewValue ( node , CharacterLiteral . ESCAPED_VALUE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , CharacterLiteral . ESCAPED_VALUE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , escapedSeq , group ) ; return false ; } public boolean visit ( ClassInstanceCreation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , ClassInstanceCreation . EXPRESSION_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { pos = rewriteRequiredNode ( node , ClassInstanceCreation . NAME_PROPERTY ) ; } else { if ( isChanged ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamenew , pos ) ; rewriteOptionalTypeParameters ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY , pos , "<STR_LIT:U+0020>" , true , true ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY ) ; } pos = rewriteRequiredNode ( node , ClassInstanceCreation . TYPE_PROPERTY ) ; } if ( isChanged ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY ) ) { try { int startpos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY , startpos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY ) ; } int kind = getChangeKind ( node , ClassInstanceCreation . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameLBRACE , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } rewriteNode ( node , ClassInstanceCreation . ANONYMOUS_CLASS_DECLARATION_PROPERTY , pos , ASTRewriteFormatter . SPACE ) ; return false ; } public boolean visit ( ConditionalExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ConditionalExpression . EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , ConditionalExpression . THEN_EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , ConditionalExpression . ELSE_EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( ConstructorInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { pos = rewriteOptionalTypeParameters ( node , ConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , pos , Util . EMPTY_STRING , false , false ) ; } try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , ConstructorInvocation . ARGUMENTS_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( ContinueStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int offset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamecontinue , node . getStartPosition ( ) ) ; rewriteNode ( node , ContinueStatement . LABEL_PROPERTY , offset , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( DoStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; try { RewriteEvent event = getEvent ( node , DoStatement . BODY_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) == RewriteEvent . REPLACED ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamedo , pos ) ; ASTNode body = ( ASTNode ) event . getOriginalValue ( ) ; int bodyEnd = body . getStartPosition ( ) + body . getLength ( ) ; int endPos = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNamewhile , bodyEnd ) ; rewriteBodyNode ( node , DoStatement . BODY_PROPERTY , startOffset , endPos , getIndent ( node . getStartPosition ( ) ) , this . formatter . DO_BLOCK ) ; } else { voidVisit ( node , DoStatement . BODY_PROPERTY ) ; } } catch ( CoreException e ) { handleException ( e ) ; } rewriteRequiredNode ( node , DoStatement . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( EmptyStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } changeNotSupported ( node ) ; return false ; } public boolean visit ( ExpressionStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ExpressionStatement . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( FieldAccess node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , FieldAccess . EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , FieldAccess . NAME_PROPERTY ) ; return false ; } public boolean visit ( FieldDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , FieldDeclaration . JAVADOC_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , FieldDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , FieldDeclaration . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , FieldDeclaration . TYPE_PROPERTY ) ; ensureSpaceAfterReplace ( node , FieldDeclaration . TYPE_PROPERTY ) ; rewriteNodeList ( node , FieldDeclaration . FRAGMENTS_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( ForStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int pos = node . getStartPosition ( ) ; if ( isChanged ( node , ForStatement . INITIALIZERS_PROPERTY ) ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; pos = rewriteNodeList ( node , ForStatement . INITIALIZERS_PROPERTY , startOffset , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } else { pos = doVisit ( node , ForStatement . INITIALIZERS_PROPERTY , pos ) ; } pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameSEMICOLON , pos ) ; pos = rewriteNode ( node , ForStatement . EXPRESSION_PROPERTY , pos , ASTRewriteFormatter . NONE ) ; if ( isChanged ( node , ForStatement . UPDATERS_PROPERTY ) ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameSEMICOLON , pos ) ; pos = rewriteNodeList ( node , ForStatement . UPDATERS_PROPERTY , startOffset , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } else { pos = doVisit ( node , ForStatement . UPDATERS_PROPERTY , pos ) ; } RewriteEvent bodyEvent = getEvent ( node , ForStatement . BODY_PROPERTY ) ; if ( bodyEvent != null && bodyEvent . getChangeKind ( ) == RewriteEvent . REPLACED ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; rewriteBodyNode ( node , ForStatement . BODY_PROPERTY , startOffset , - <NUM_LIT:1> , getIndent ( node . getStartPosition ( ) ) , this . formatter . FOR_BLOCK ) ; } else { voidVisit ( node , ForStatement . BODY_PROPERTY ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( IfStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , IfStatement . EXPRESSION_PROPERTY ) ; RewriteEvent thenEvent = getEvent ( node , IfStatement . THEN_STATEMENT_PROPERTY ) ; int elseChange = getChangeKind ( node , IfStatement . ELSE_STATEMENT_PROPERTY ) ; if ( thenEvent != null && thenEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { try { int tok = getScanner ( ) . readNext ( pos , true ) ; pos = ( tok == TerminalTokens . TokenNameRPAREN ) ? getScanner ( ) . getCurrentEndOffset ( ) : getScanner ( ) . getCurrentStartOffset ( ) ; int indent = getIndent ( node . getStartPosition ( ) ) ; int endPos = - <NUM_LIT:1> ; Object elseStatement = getOriginalValue ( node , IfStatement . ELSE_STATEMENT_PROPERTY ) ; if ( elseStatement != null ) { ASTNode thenStatement = ( ASTNode ) thenEvent . getOriginalValue ( ) ; endPos = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameelse , thenStatement . getStartPosition ( ) + thenStatement . getLength ( ) ) ; } if ( elseStatement == null || elseChange != RewriteEvent . UNCHANGED ) { pos = rewriteBodyNode ( node , IfStatement . THEN_STATEMENT_PROPERTY , pos , endPos , indent , this . formatter . IF_BLOCK_NO_ELSE ) ; } else { pos = rewriteBodyNode ( node , IfStatement . THEN_STATEMENT_PROPERTY , pos , endPos , indent , this . formatter . IF_BLOCK_WITH_ELSE ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = doVisit ( node , IfStatement . THEN_STATEMENT_PROPERTY , pos ) ; } if ( elseChange != RewriteEvent . UNCHANGED ) { int indent = getIndent ( node . getStartPosition ( ) ) ; Object newThen = getNewValue ( node , IfStatement . THEN_STATEMENT_PROPERTY ) ; if ( newThen instanceof Block ) { rewriteBodyNode ( node , IfStatement . ELSE_STATEMENT_PROPERTY , pos , - <NUM_LIT:1> , indent , this . formatter . ELSE_AFTER_BLOCK ) ; } else { rewriteBodyNode ( node , IfStatement . ELSE_STATEMENT_PROPERTY , pos , - <NUM_LIT:1> , indent , this . formatter . ELSE_AFTER_STATEMENT ) ; } } else { pos = doVisit ( node , IfStatement . ELSE_STATEMENT_PROPERTY , pos ) ; } return false ; } public boolean visit ( ImportDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { RewriteEvent event = getEvent ( node , ImportDeclaration . STATIC_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { try { int pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameimport , node . getStartPosition ( ) ) ; boolean wasStatic = ( ( Boolean ) event . getOriginalValue ( ) ) . booleanValue ( ) ; if ( wasStatic ) { int endPos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamestatic , pos ) ; doTextRemove ( pos , endPos - pos , getEditGroup ( event ) ) ; } else { doTextInsert ( pos , "<STR_LIT>" , getEditGroup ( event ) ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } } int pos = rewriteRequiredNode ( node , ImportDeclaration . NAME_PROPERTY ) ; RewriteEvent event = getEvent ( node , ImportDeclaration . ON_DEMAND_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { boolean isOnDemand = ( ( Boolean ) event . getOriginalValue ( ) ) . booleanValue ( ) ; if ( ! isOnDemand ) { doTextInsert ( pos , "<STR_LIT>" , getEditGroup ( event ) ) ; } else { try { int endPos = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameSEMICOLON , pos ) ; doTextRemove ( pos , endPos - pos , getEditGroup ( event ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } return false ; } public boolean visit ( InfixExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , InfixExpression . LEFT_OPERAND_PROPERTY ) ; boolean needsNewOperation = isChanged ( node , InfixExpression . OPERATOR_PROPERTY ) ; String operation = getNewValue ( node , InfixExpression . OPERATOR_PROPERTY ) . toString ( ) ; if ( needsNewOperation ) { replaceOperation ( pos , operation , getEditGroup ( node , InfixExpression . OPERATOR_PROPERTY ) ) ; } pos = rewriteRequiredNode ( node , InfixExpression . RIGHT_OPERAND_PROPERTY ) ; RewriteEvent event = getEvent ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY ) ; String prefixString = '<CHAR_LIT:U+0020>' + operation + '<CHAR_LIT:U+0020>' ; if ( needsNewOperation ) { int startPos = pos ; TextEditGroup editGroup = getEditGroup ( node , InfixExpression . OPERATOR_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] extendedOperands = event . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < extendedOperands . length ; i ++ ) { RewriteEvent curr = extendedOperands [ i ] ; ASTNode elem = ( ASTNode ) curr . getOriginalValue ( ) ; if ( elem != null ) { if ( curr . getChangeKind ( ) != RewriteEvent . REPLACED ) { replaceOperation ( startPos , operation , editGroup ) ; } startPos = elem . getStartPosition ( ) + elem . getLength ( ) ; } } } else { List extendedOperands = ( List ) getOriginalValue ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extendedOperands . size ( ) ; i ++ ) { ASTNode elem = ( ASTNode ) extendedOperands . get ( i ) ; replaceOperation ( startPos , operation , editGroup ) ; startPos = elem . getStartPosition ( ) + elem . getLength ( ) ; } } } rewriteNodeList ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY , pos , prefixString , prefixString ) ; return false ; } public boolean visit ( Initializer node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , Initializer . JAVADOC_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , Initializer . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , Initializer . MODIFIERS2_PROPERTY , pos ) ; } rewriteRequiredNode ( node , Initializer . BODY_PROPERTY ) ; return false ; } public boolean visit ( InstanceofExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , InstanceofExpression . LEFT_OPERAND_PROPERTY ) ; ensureSpaceAfterReplace ( node , InstanceofExpression . LEFT_OPERAND_PROPERTY ) ; rewriteRequiredNode ( node , InstanceofExpression . RIGHT_OPERAND_PROPERTY ) ; return false ; } public void ensureSpaceAfterReplace ( ASTNode node , ChildPropertyDescriptor desc ) { if ( getChangeKind ( node , desc ) == RewriteEvent . REPLACED ) { int leftOperandEnd = getExtendedEnd ( ( ASTNode ) getOriginalValue ( node , desc ) ) ; try { int offset = getScanner ( ) . getNextStartOffset ( leftOperandEnd , true ) ; if ( offset == leftOperandEnd ) { doTextInsert ( offset , String . valueOf ( '<CHAR_LIT:U+0020>' ) , getEditGroup ( node , desc ) ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } } public void ensureSpaceBeforeReplace ( ASTNode node ) { if ( this . beforeRequiredSpaceIndex == - <NUM_LIT:1> ) return ; List events = this . eventStore . getChangedPropertieEvents ( node ) ; for ( Iterator iterator = events . iterator ( ) ; iterator . hasNext ( ) ; ) { RewriteEvent event = ( RewriteEvent ) iterator . next ( ) ; if ( event . getChangeKind ( ) == RewriteEvent . REPLACED && event . getOriginalValue ( ) instanceof ASTNode ) { if ( this . beforeRequiredSpaceIndex == getExtendedOffset ( ( ASTNode ) event . getOriginalValue ( ) ) ) { doTextInsert ( this . beforeRequiredSpaceIndex , String . valueOf ( '<CHAR_LIT:U+0020>' ) , getEditGroup ( event ) ) ; this . beforeRequiredSpaceIndex = - <NUM_LIT:1> ; return ; } } } if ( this . beforeRequiredSpaceIndex < getExtendedOffset ( node ) ) { this . beforeRequiredSpaceIndex = - <NUM_LIT:1> ; } } public boolean visit ( Javadoc node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = node . getStartPosition ( ) + <NUM_LIT:3> ; String separator = getLineDelimiter ( ) + getIndentAtOffset ( node . getStartPosition ( ) ) + "<STR_LIT>" ; rewriteNodeList ( node , Javadoc . TAGS_PROPERTY , startPos , separator , separator ) ; return false ; } public boolean visit ( LabeledStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , LabeledStatement . LABEL_PROPERTY ) ; rewriteRequiredNode ( node , LabeledStatement . BODY_PROPERTY ) ; return false ; } public boolean visit ( MethodInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , MethodInvocation . EXPRESSION_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { pos = rewriteOptionalTypeParameters ( node , MethodInvocation . TYPE_ARGUMENTS_PROPERTY , pos , Util . EMPTY_STRING , false , false ) ; } pos = rewriteRequiredNode ( node , MethodInvocation . NAME_PROPERTY ) ; if ( isChanged ( node , MethodInvocation . ARGUMENTS_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , MethodInvocation . ARGUMENTS_PROPERTY , startOffset , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , MethodInvocation . ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( NullLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } changeNotSupported ( node ) ; return false ; } public boolean visit ( NumberLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newLiteral = ( String ) getNewValue ( node , NumberLiteral . TOKEN_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , NumberLiteral . TOKEN_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newLiteral , group ) ; return false ; } public boolean visit ( PackageDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { int pos = rewriteJavadoc ( node , PackageDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , PackageDeclaration . ANNOTATIONS_PROPERTY , pos ) ; } rewriteRequiredNode ( node , PackageDeclaration . NAME_PROPERTY ) ; return false ; } public boolean visit ( ParenthesizedExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ParenthesizedExpression . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( PostfixExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , PostfixExpression . OPERAND_PROPERTY ) ; rewriteOperation ( node , PostfixExpression . OPERATOR_PROPERTY , pos ) ; return false ; } public boolean visit ( PrefixExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteOperation ( node , PrefixExpression . OPERATOR_PROPERTY , node . getStartPosition ( ) ) ; rewriteRequiredNode ( node , PrefixExpression . OPERAND_PROPERTY ) ; return false ; } public boolean visit ( PrimitiveType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } PrimitiveType . Code newCode = ( PrimitiveType . Code ) getNewValue ( node , PrimitiveType . PRIMITIVE_TYPE_CODE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , PrimitiveType . PRIMITIVE_TYPE_CODE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newCode . toString ( ) , group ) ; return false ; } public boolean visit ( QualifiedName node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , QualifiedName . QUALIFIER_PROPERTY ) ; rewriteRequiredNode ( node , QualifiedName . NAME_PROPERTY ) ; return false ; } public boolean visit ( SimpleName node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newString = ( String ) getNewValue ( node , SimpleName . IDENTIFIER_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , SimpleName . IDENTIFIER_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newString , group ) ; return false ; } public boolean visit ( SimpleType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SimpleType . NAME_PROPERTY ) ; return false ; } public boolean visit ( SingleVariableDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , SingleVariableDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , SingleVariableDeclaration . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , SingleVariableDeclaration . TYPE_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { if ( isChanged ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) { if ( getNewValue ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) . equals ( Boolean . TRUE ) ) { doTextInsert ( pos , "<STR_LIT:...>" , getEditGroup ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) ; } else { try { int ellipsisEnd = getScanner ( ) . getNextEndOffset ( pos , true ) ; doTextRemove ( pos , ellipsisEnd - pos , getEditGroup ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } if ( ! node . isVarargs ( ) ) { ensureSpaceAfterReplace ( node , SingleVariableDeclaration . TYPE_PROPERTY ) ; } } else { ensureSpaceAfterReplace ( node , SingleVariableDeclaration . TYPE_PROPERTY ) ; } pos = rewriteRequiredNode ( node , SingleVariableDeclaration . NAME_PROPERTY ) ; int extraDims = rewriteExtraDimensions ( node , SingleVariableDeclaration . EXTRA_DIMENSIONS_PROPERTY , pos ) ; if ( extraDims > <NUM_LIT:0> ) { int kind = getChangeKind ( node , SingleVariableDeclaration . INITIALIZER_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameEQUAL , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } } rewriteNode ( node , SingleVariableDeclaration . INITIALIZER_PROPERTY , pos , this . formatter . VAR_INITIALIZER ) ; return false ; } public boolean visit ( StringLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String escapedSeq = ( String ) getNewValue ( node , StringLiteral . ESCAPED_VALUE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , StringLiteral . ESCAPED_VALUE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , escapedSeq , group ) ; return false ; } public boolean visit ( SuperConstructorInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , SuperConstructorInvocation . EXPRESSION_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { pos = rewriteOptionalTypeParameters ( node , SuperConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , pos , Util . EMPTY_STRING , false , false ) ; } if ( isChanged ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( SuperFieldAccess node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteOptionalQualifier ( node , SuperFieldAccess . QUALIFIER_PROPERTY , node . getStartPosition ( ) ) ; rewriteRequiredNode ( node , SuperFieldAccess . NAME_PROPERTY ) ; return false ; } public boolean visit ( SuperMethodInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , SuperMethodInvocation . QUALIFIER_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { if ( isChanged ( node , SuperMethodInvocation . TYPE_ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , pos ) ; rewriteOptionalTypeParameters ( node , SuperMethodInvocation . TYPE_ARGUMENTS_PROPERTY , pos , Util . EMPTY_STRING , false , false ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } pos = rewriteRequiredNode ( node , SuperMethodInvocation . NAME_PROPERTY ) ; if ( isChanged ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( SwitchCase node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SwitchCase . EXPRESSION_PROPERTY ) ; return false ; } class SwitchListRewriter extends ParagraphListRewriter { private boolean indentSwitchStatementsCompareToCases ; public SwitchListRewriter ( int initialIndent ) { super ( initialIndent , <NUM_LIT:0> ) ; this . indentSwitchStatementsCompareToCases = DefaultCodeFormatterConstants . TRUE . equals ( ASTRewriteAnalyzer . this . options . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES ) ) ; } protected int getNodeIndent ( int nodeIndex ) { int indent = getInitialIndent ( ) ; if ( this . indentSwitchStatementsCompareToCases ) { RewriteEvent event = this . list [ nodeIndex ] ; int changeKind = event . getChangeKind ( ) ; ASTNode node ; if ( changeKind == RewriteEvent . INSERTED || changeKind == RewriteEvent . REPLACED ) { node = ( ASTNode ) event . getNewValue ( ) ; } else { node = ( ASTNode ) event . getOriginalValue ( ) ; } if ( node . getNodeType ( ) != ASTNode . SWITCH_CASE ) { indent ++ ; } } return indent ; } protected String getSeparatorString ( int nodeIndex ) { int total = this . list . length ; int nextNodeIndex = nodeIndex + <NUM_LIT:1> ; while ( nextNodeIndex < total && this . list [ nextNodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { nextNodeIndex ++ ; } if ( nextNodeIndex == total ) { return super . getSeparatorString ( nodeIndex ) ; } return getSeparatorString ( nodeIndex , nextNodeIndex ) ; } protected void updateIndent ( int prevMark , int originalOffset , int nodeIndex , TextEditGroup editGroup ) { if ( prevMark != RewriteEvent . UNCHANGED && prevMark != RewriteEvent . REPLACED ) return ; int previousNonRemovedNodeIndex = nodeIndex - <NUM_LIT:1> ; while ( previousNonRemovedNodeIndex >= <NUM_LIT:0> && this . list [ previousNonRemovedNodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { previousNonRemovedNodeIndex -- ; } if ( previousNonRemovedNodeIndex > - <NUM_LIT:1> ) { LineInformation lineInformation = getLineInformation ( ) ; RewriteEvent prevEvent = this . list [ previousNonRemovedNodeIndex ] ; int prevKind = prevEvent . getChangeKind ( ) ; if ( prevKind == RewriteEvent . UNCHANGED || prevKind == RewriteEvent . REPLACED ) { ASTNode prevNode = ( ASTNode ) this . list [ previousNonRemovedNodeIndex ] . getOriginalValue ( ) ; int prevEndPosition = prevNode . getStartPosition ( ) + prevNode . getLength ( ) ; int prevLine = lineInformation . getLineOfOffset ( prevEndPosition ) ; int line = lineInformation . getLineOfOffset ( originalOffset ) ; if ( prevLine == line ) { return ; } } } int total = this . list . length ; while ( nodeIndex < total && this . list [ nodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { nodeIndex ++ ; } int originalIndent = getIndent ( originalOffset ) ; int newIndent = getNodeIndent ( nodeIndex ) ; if ( originalIndent != newIndent ) { int line = getLineInformation ( ) . getLineOfOffset ( originalOffset ) ; if ( line >= <NUM_LIT:0> ) { int lineStart = getLineInformation ( ) . getLineOffset ( line ) ; doTextRemove ( lineStart , originalOffset - lineStart , editGroup ) ; doTextInsert ( lineStart , createIndentString ( newIndent ) , editGroup ) ; } } } } public boolean visit ( SwitchStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , SwitchStatement . EXPRESSION_PROPERTY ) ; ChildListPropertyDescriptor property = SwitchStatement . STATEMENTS_PROPERTY ; if ( getChangeKind ( node , property ) != RewriteEvent . UNCHANGED ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLBRACE , pos ) ; int insertIndent = getIndent ( node . getStartPosition ( ) ) ; if ( DefaultCodeFormatterConstants . TRUE . equals ( this . options . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH ) ) ) { insertIndent ++ ; } ParagraphListRewriter listRewriter = new SwitchListRewriter ( insertIndent ) ; StringBuffer leadString = new StringBuffer ( ) ; leadString . append ( getLineDelimiter ( ) ) ; leadString . append ( createIndentString ( insertIndent ) ) ; listRewriter . rewriteList ( node , property , pos , leadString . toString ( ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , SwitchStatement . STATEMENTS_PROPERTY ) ; } return false ; } public boolean visit ( SynchronizedStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SynchronizedStatement . EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , SynchronizedStatement . BODY_PROPERTY ) ; return false ; } public boolean visit ( ThisExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteOptionalQualifier ( node , ThisExpression . QUALIFIER_PROPERTY , node . getStartPosition ( ) ) ; return false ; } public boolean visit ( ThrowStatement node ) { try { this . beforeRequiredSpaceIndex = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamethrow , node . getStartPosition ( ) ) ; if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ensureSpaceBeforeReplace ( node ) ; rewriteRequiredNode ( node , ThrowStatement . EXPRESSION_PROPERTY ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( TryStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS4 ) { if ( isChanged ( node , TryStatement . RESOURCES_PROPERTY ) ) { int indent = getIndent ( node . getStartPosition ( ) ) ; String prefix = this . formatter . TRY_RESOURCES . getPrefix ( indent ) ; String newParen = this . formatter . TRY_RESOURCES_PAREN . getPrefix ( indent ) + "<STR_LIT:(>" ; pos = rewriteNodeList ( node , TryStatement . RESOURCES_PROPERTY , getPosAfterTry ( pos ) , newParen , "<STR_LIT:)>" , "<STR_LIT:;>" + prefix ) ; } else { pos = doVisit ( node , TryStatement . RESOURCES_PROPERTY , pos ) ; } } pos = rewriteRequiredNode ( node , TryStatement . BODY_PROPERTY ) ; if ( isChanged ( node , TryStatement . CATCH_CLAUSES_PROPERTY ) ) { int indent = getIndent ( node . getStartPosition ( ) ) ; String prefix = this . formatter . CATCH_BLOCK . getPrefix ( indent ) ; pos = rewriteNodeList ( node , TryStatement . CATCH_CLAUSES_PROPERTY , pos , prefix , prefix ) ; } else { pos = doVisit ( node , TryStatement . CATCH_CLAUSES_PROPERTY , pos ) ; } rewriteNode ( node , TryStatement . FINALLY_PROPERTY , pos , this . formatter . FINALLY_BLOCK ) ; return false ; } public boolean visit ( TypeDeclarationStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteRequiredNode ( node , TypeDeclarationStatement . TYPE_DECLARATION_PROPERTY ) ; } else { rewriteRequiredNode ( node , TypeDeclarationStatement . DECLARATION_PROPERTY ) ; } return false ; } public boolean visit ( TypeLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , TypeLiteral . TYPE_PROPERTY ) ; return false ; } public boolean visit ( UnionType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( isChanged ( node , UnionType . TYPES_PROPERTY ) ) { pos = rewriteNodeList ( node , UnionType . TYPES_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT>" ) ; } else { pos = doVisit ( node , UnionType . TYPES_PROPERTY , pos ) ; } return false ; } public boolean visit ( VariableDeclarationExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , VariableDeclarationExpression . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , VariableDeclarationExpression . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , VariableDeclarationExpression . TYPE_PROPERTY ) ; rewriteNodeList ( node , VariableDeclarationExpression . FRAGMENTS_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( VariableDeclarationFragment node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , VariableDeclarationFragment . NAME_PROPERTY ) ; int extraDims = rewriteExtraDimensions ( node , VariableDeclarationFragment . EXTRA_DIMENSIONS_PROPERTY , pos ) ; if ( extraDims > <NUM_LIT:0> ) { int kind = getChangeKind ( node , VariableDeclarationFragment . INITIALIZER_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameEQUAL , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } } rewriteNode ( node , VariableDeclarationFragment . INITIALIZER_PROPERTY , pos , this . formatter . VAR_INITIALIZER ) ; return false ; } public boolean visit ( VariableDeclarationStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , VariableDeclarationStatement . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , VariableDeclarationStatement . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , VariableDeclarationStatement . TYPE_PROPERTY ) ; rewriteNodeList ( node , VariableDeclarationStatement . FRAGMENTS_PROPERTY , pos , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( WhileStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , WhileStatement . EXPRESSION_PROPERTY ) ; try { if ( isChanged ( node , WhileStatement . BODY_PROPERTY ) ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; rewriteBodyNode ( node , WhileStatement . BODY_PROPERTY , startOffset , - <NUM_LIT:1> , getIndent ( node . getStartPosition ( ) ) , this . formatter . WHILE_BLOCK ) ; } else { voidVisit ( node , WhileStatement . BODY_PROPERTY ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( MemberRef node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteNode ( node , MemberRef . QUALIFIER_PROPERTY , node . getStartPosition ( ) , ASTRewriteFormatter . NONE ) ; rewriteRequiredNode ( node , MemberRef . NAME_PROPERTY ) ; return false ; } public boolean visit ( MethodRef node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteNode ( node , MethodRef . QUALIFIER_PROPERTY , node . getStartPosition ( ) , ASTRewriteFormatter . NONE ) ; int pos = rewriteRequiredNode ( node , MethodRef . NAME_PROPERTY ) ; if ( isChanged ( node , MethodRef . PARAMETERS_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , MethodRef . PARAMETERS_PROPERTY , startOffset , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , MethodRef . PARAMETERS_PROPERTY ) ; } return false ; } public boolean visit ( MethodRefParameter node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , MethodRefParameter . TYPE_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3_INTERNAL ) { if ( isChanged ( node , MethodRefParameter . VARARGS_PROPERTY ) ) { if ( getNewValue ( node , MethodRefParameter . VARARGS_PROPERTY ) . equals ( Boolean . TRUE ) ) { doTextInsert ( pos , "<STR_LIT:...>" , getEditGroup ( node , MethodRefParameter . VARARGS_PROPERTY ) ) ; } else { try { int ellipsisEnd = getScanner ( ) . getNextEndOffset ( pos , true ) ; doTextRemove ( pos , ellipsisEnd - pos , getEditGroup ( node , MethodRefParameter . VARARGS_PROPERTY ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } } rewriteNode ( node , MethodRefParameter . NAME_PROPERTY , pos , ASTRewriteFormatter . SPACE ) ; return false ; } public boolean visit ( TagElement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int changeKind = getChangeKind ( node , TagElement . TAG_NAME_PROPERTY ) ; switch ( changeKind ) { case RewriteEvent . INSERTED : { String newTagName = ( String ) getNewValue ( node , TagElement . TAG_NAME_PROPERTY ) ; doTextInsert ( node . getStartPosition ( ) , newTagName , getEditGroup ( node , TagElement . TAG_NAME_PROPERTY ) ) ; break ; } case RewriteEvent . REMOVED : { doTextRemove ( node . getStartPosition ( ) , findTagNameEnd ( node ) - node . getStartPosition ( ) , getEditGroup ( node , TagElement . TAG_NAME_PROPERTY ) ) ; break ; } case RewriteEvent . REPLACED : { String newTagName = ( String ) getNewValue ( node , TagElement . TAG_NAME_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , findTagNameEnd ( node ) - node . getStartPosition ( ) , newTagName , getEditGroup ( node , TagElement . TAG_NAME_PROPERTY ) ) ; break ; } } if ( isChanged ( node , TagElement . FRAGMENTS_PROPERTY ) ) { int endOffset = findTagNameEnd ( node ) ; rewriteNodeList ( node , TagElement . FRAGMENTS_PROPERTY , endOffset , "<STR_LIT:U+0020>" , "<STR_LIT:U+0020>" ) ; } else { voidVisit ( node , TagElement . FRAGMENTS_PROPERTY ) ; } return false ; } private int findTagNameEnd ( TagElement tagNode ) { if ( tagNode . getTagName ( ) != null ) { char [ ] cont = getContent ( ) ; int len = cont . length ; int i = tagNode . getStartPosition ( ) ; while ( i < len && ! IndentManipulation . isIndentChar ( cont [ i ] ) ) { i ++ ; } return i ; } return tagNode . getStartPosition ( ) ; } public boolean visit ( TextElement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newText = ( String ) getNewValue ( node , TextElement . TEXT_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , TextElement . TEXT_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newText , group ) ; return false ; } public boolean visit ( AnnotationTypeDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , AnnotationTypeDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , AnnotationTypeDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteRequiredNode ( node , AnnotationTypeDeclaration . NAME_PROPERTY ) ; int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; int startPos = getPosAfterLeftBrace ( pos ) ; rewriteParagraphList ( node , AnnotationTypeDeclaration . BODY_DECLARATIONS_PROPERTY , startPos , startIndent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , AnnotationTypeMemberDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , AnnotationTypeMemberDeclaration . MODIFIERS2_PROPERTY , pos ) ; rewriteRequiredNode ( node , AnnotationTypeMemberDeclaration . TYPE_PROPERTY ) ; pos = rewriteRequiredNode ( node , AnnotationTypeMemberDeclaration . NAME_PROPERTY ) ; try { int changeKind = getChangeKind ( node , AnnotationTypeMemberDeclaration . DEFAULT_PROPERTY ) ; if ( changeKind == RewriteEvent . INSERTED || changeKind == RewriteEvent . REMOVED ) { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; } rewriteNode ( node , AnnotationTypeMemberDeclaration . DEFAULT_PROPERTY , pos , this . formatter . ANNOT_MEMBER_DEFAULT ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( EnhancedForStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , EnhancedForStatement . PARAMETER_PROPERTY ) ; int pos = rewriteRequiredNode ( node , EnhancedForStatement . EXPRESSION_PROPERTY ) ; RewriteEvent bodyEvent = getEvent ( node , EnhancedForStatement . BODY_PROPERTY ) ; if ( bodyEvent != null && bodyEvent . getChangeKind ( ) == RewriteEvent . REPLACED ) { int startOffset ; try { startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; rewriteBodyNode ( node , EnhancedForStatement . BODY_PROPERTY , startOffset , - <NUM_LIT:1> , getIndent ( node . getStartPosition ( ) ) , this . formatter . FOR_BLOCK ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , EnhancedForStatement . BODY_PROPERTY ) ; } return false ; } public boolean visit ( EnumConstantDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , EnumConstantDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , EnumConstantDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteRequiredNode ( node , EnumConstantDeclaration . NAME_PROPERTY ) ; RewriteEvent argsEvent = getEvent ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY ) ; if ( argsEvent != null && argsEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] children = argsEvent . getChildren ( ) ; try { int nextTok = getScanner ( ) . readNext ( pos , true ) ; boolean hasParents = ( nextTok == TerminalTokens . TokenNameLPAREN ) ; boolean isAllRemoved = hasParents && isAllOfKind ( children , RewriteEvent . REMOVED ) ; String prefix = Util . EMPTY_STRING ; if ( ! hasParents ) { prefix = "<STR_LIT:(>" ; } else if ( ! isAllRemoved ) { pos = getScanner ( ) . getCurrentEndOffset ( ) ; } pos = rewriteNodeList ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY , pos , prefix , "<STR_LIT:U+002CU+0020>" ) ; if ( ! hasParents ) { doTextInsert ( pos , "<STR_LIT:)>" , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; } else if ( isAllRemoved ) { int afterClosing = getScanner ( ) . getNextEndOffset ( pos , true ) ; doTextRemove ( pos , afterClosing - pos , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; pos = afterClosing ; } } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = doVisit ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY , pos ) ; } if ( isChanged ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ) { int kind = getChangeKind ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameLBRACE , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } rewriteNode ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY , pos , ASTRewriteFormatter . SPACE ) ; } return false ; } public boolean visit ( EnumDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , EnumDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , EnumDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteRequiredNode ( node , EnumDeclaration . NAME_PROPERTY ) ; pos = rewriteNodeList ( node , EnumDeclaration . SUPER_INTERFACE_TYPES_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; pos = getPosAfterLeftBrace ( pos ) ; String leadString = Util . EMPTY_STRING ; RewriteEvent constEvent = getEvent ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY ) ; if ( constEvent != null && constEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] events = constEvent . getChildren ( ) ; if ( isAllOfKind ( events , RewriteEvent . INSERTED ) ) { leadString = this . formatter . FIRST_ENUM_CONST . getPrefix ( getIndent ( node . getStartPosition ( ) ) ) ; } } pos = rewriteNodeList ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY , pos , leadString , "<STR_LIT:U+002CU+0020>" ) ; RewriteEvent bodyEvent = getEvent ( node , EnumDeclaration . BODY_DECLARATIONS_PROPERTY ) ; int indent = <NUM_LIT:0> ; if ( bodyEvent != null && bodyEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { boolean hasConstants = ! ( ( List ) getNewValue ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY ) ) . isEmpty ( ) ; RewriteEvent [ ] children = bodyEvent . getChildren ( ) ; try { if ( hasConstants ) { indent = getIndent ( pos ) ; } else { indent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; } int token = getScanner ( ) . readNext ( pos , true ) ; boolean hasSemicolon = token == TerminalTokens . TokenNameSEMICOLON ; if ( ! hasSemicolon && isAllOfKind ( children , RewriteEvent . INSERTED ) ) { if ( ! hasConstants ) { String str = this . formatter . FIRST_ENUM_CONST . getPrefix ( indent - <NUM_LIT:1> ) ; doTextInsert ( pos , str , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } if ( token == TerminalTokens . TokenNameCOMMA ) { int endPos = getScanner ( ) . getCurrentEndOffset ( ) ; int nextToken = getScanner ( ) . readNext ( endPos , true ) ; if ( nextToken != TerminalTokens . TokenNameSEMICOLON ) { doTextInsert ( endPos , "<STR_LIT:;>" , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } else { endPos = getScanner ( ) . getCurrentEndOffset ( ) ; if ( isAllOfKind ( children , RewriteEvent . REMOVED ) ) { doTextRemove ( pos , endPos - pos , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } } pos = endPos ; } else { doTextInsert ( pos , "<STR_LIT:;>" , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } } else if ( hasSemicolon ) { int endPos = getScanner ( ) . getCurrentEndOffset ( ) ; if ( isAllOfKind ( children , RewriteEvent . REMOVED ) ) { doTextRemove ( pos , endPos - pos , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } pos = endPos ; } } catch ( CoreException e ) { handleException ( e ) ; } } rewriteParagraphList ( node , EnumDeclaration . BODY_DECLARATIONS_PROPERTY , pos , indent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( MarkerAnnotation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , MarkerAnnotation . TYPE_NAME_PROPERTY ) ; return false ; } public boolean visit ( MemberValuePair node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , MemberValuePair . NAME_PROPERTY ) ; rewriteRequiredNode ( node , MemberValuePair . VALUE_PROPERTY ) ; return false ; } public boolean visit ( Modifier node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newText = getNewValue ( node , Modifier . KEYWORD_PROPERTY ) . toString ( ) ; TextEditGroup group = getEditGroup ( node , Modifier . KEYWORD_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newText , group ) ; return false ; } public boolean visit ( NormalAnnotation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , NormalAnnotation . TYPE_NAME_PROPERTY ) ; if ( isChanged ( node , NormalAnnotation . VALUES_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , NormalAnnotation . VALUES_PROPERTY , startOffset , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , NormalAnnotation . VALUES_PROPERTY ) ; } return false ; } public boolean visit ( ParameterizedType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , ParameterizedType . TYPE_PROPERTY ) ; if ( isChanged ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLESS , pos ) ; rewriteNodeList ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY , startOffset , Util . EMPTY_STRING , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( QualifiedType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , QualifiedType . QUALIFIER_PROPERTY ) ; rewriteRequiredNode ( node , QualifiedType . NAME_PROPERTY ) ; return false ; } public boolean visit ( SingleMemberAnnotation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SingleMemberAnnotation . TYPE_NAME_PROPERTY ) ; rewriteRequiredNode ( node , SingleMemberAnnotation . VALUE_PROPERTY ) ; return false ; } public boolean visit ( TypeParameter node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , TypeParameter . NAME_PROPERTY ) ; if ( isChanged ( node , TypeParameter . TYPE_BOUNDS_PROPERTY ) ) { rewriteNodeList ( node , TypeParameter . TYPE_BOUNDS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT>" ) ; } else { voidVisit ( node , TypeParameter . TYPE_BOUNDS_PROPERTY ) ; } return false ; } public boolean visit ( WildcardType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int pos = getScanner ( ) . getNextEndOffset ( node . getStartPosition ( ) , true ) ; Prefix prefix ; if ( Boolean . TRUE . equals ( getNewValue ( node , WildcardType . UPPER_BOUND_PROPERTY ) ) ) { prefix = this . formatter . WILDCARD_EXTENDS ; } else { prefix = this . formatter . WILDCARD_SUPER ; } int boundKindChange = getChangeKind ( node , WildcardType . UPPER_BOUND_PROPERTY ) ; if ( boundKindChange != RewriteEvent . UNCHANGED ) { int boundTypeChange = getChangeKind ( node , WildcardType . BOUND_PROPERTY ) ; if ( boundTypeChange != RewriteEvent . INSERTED && boundTypeChange != RewriteEvent . REMOVED ) { ASTNode type = ( ASTNode ) getOriginalValue ( node , WildcardType . BOUND_PROPERTY ) ; String str = prefix . getPrefix ( <NUM_LIT:0> ) ; doTextReplace ( pos , type . getStartPosition ( ) - pos , str , getEditGroup ( node , WildcardType . BOUND_PROPERTY ) ) ; } } rewriteNode ( node , WildcardType . BOUND_PROPERTY , pos , prefix ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } final void handleException ( Throwable e ) { IllegalArgumentException runtimeException = new IllegalArgumentException ( "<STR_LIT>" ) ; runtimeException . initCause ( e ) ; throw runtimeException ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . IDocument ; public abstract class LineInformation { public static LineInformation create ( final IDocument doc ) { return new LineInformation ( ) { public int getLineOfOffset ( int offset ) { try { return doc . getLineOfOffset ( offset ) ; } catch ( BadLocationException e ) { return - <NUM_LIT:1> ; } } public int getLineOffset ( int line ) { try { return doc . getLineOffset ( line ) ; } catch ( BadLocationException e ) { return - <NUM_LIT:1> ; } } } ; } public static LineInformation create ( final CompilationUnit astRoot ) { return new LineInformation ( ) { public int getLineOfOffset ( int offset ) { return astRoot . getLineNumber ( offset ) - <NUM_LIT:1> ; } public int getLineOffset ( int line ) { return astRoot . getPosition ( line + <NUM_LIT:1> , <NUM_LIT:0> ) ; } } ; } public abstract int getLineOfOffset ( int offset ) ; public abstract int getLineOffset ( int line ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . * ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer ; import org . eclipse . text . edits . TextEditGroup ; public final class RewriteEventStore { public static final class PropertyLocation { private final ASTNode parent ; private final StructuralPropertyDescriptor property ; public PropertyLocation ( ASTNode parent , StructuralPropertyDescriptor property ) { this . parent = parent ; this . property = property ; } public ASTNode getParent ( ) { return this . parent ; } public StructuralPropertyDescriptor getProperty ( ) { return this . property ; } public boolean equals ( Object obj ) { if ( obj != null && obj . getClass ( ) . equals ( getClass ( ) ) ) { PropertyLocation other = ( PropertyLocation ) obj ; return other . getParent ( ) . equals ( getParent ( ) ) && other . getProperty ( ) . equals ( getProperty ( ) ) ; } return false ; } public int hashCode ( ) { return getParent ( ) . hashCode ( ) + getProperty ( ) . hashCode ( ) ; } } public static interface INodePropertyMapper { Object getOriginalValue ( ASTNode parent , StructuralPropertyDescriptor childProperty ) ; } private static class EventHolder { public final ASTNode parent ; public final StructuralPropertyDescriptor childProperty ; public final RewriteEvent event ; public EventHolder ( ASTNode parent , StructuralPropertyDescriptor childProperty , RewriteEvent change ) { this . parent = parent ; this . childProperty = childProperty ; this . event = change ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( this . parent ) . append ( "<STR_LIT:U+0020-U+0020>" ) ; buf . append ( this . childProperty . getId ( ) ) . append ( "<STR_LIT::U+0020>" ) ; buf . append ( this . event ) . append ( '<STR_LIT:\n>' ) ; return buf . toString ( ) ; } } public static class CopySourceInfo implements Comparable { public final PropertyLocation location ; private final ASTNode node ; public final boolean isMove ; public CopySourceInfo ( PropertyLocation location , ASTNode node , boolean isMove ) { this . location = location ; this . node = node ; this . isMove = isMove ; } public ASTNode getNode ( ) { return this . node ; } public int compareTo ( Object o2 ) { CopySourceInfo r2 = ( CopySourceInfo ) o2 ; int startDiff = getNode ( ) . getStartPosition ( ) - r2 . getNode ( ) . getStartPosition ( ) ; if ( startDiff != <NUM_LIT:0> ) { return startDiff ; } if ( r2 . isMove != this . isMove ) { return this . isMove ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return <NUM_LIT:0> ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( this . isMove ) { buf . append ( "<STR_LIT>" ) ; } else { buf . append ( "<STR_LIT>" ) ; } buf . append ( this . node ) ; return buf . toString ( ) ; } } private static class NodeRangeInfo implements Comparable { private final ASTNode first ; private final ASTNode last ; public final CopySourceInfo copyInfo ; public final ASTNode replacingNode ; public final TextEditGroup editGroup ; public NodeRangeInfo ( ASTNode parent , StructuralPropertyDescriptor childProperty , ASTNode first , ASTNode last , CopySourceInfo copyInfo , ASTNode replacingNode , TextEditGroup editGroup ) { this . first = first ; this . last = last ; this . copyInfo = copyInfo ; this . replacingNode = replacingNode ; this . editGroup = editGroup ; } public ASTNode getStartNode ( ) { return this . first ; } public ASTNode getEndNode ( ) { return this . last ; } public boolean isMove ( ) { return this . copyInfo . isMove ; } public Block getInternalPlaceholder ( ) { return ( Block ) this . copyInfo . getNode ( ) ; } public int compareTo ( Object o2 ) { NodeRangeInfo r2 = ( NodeRangeInfo ) o2 ; int startDiff = getStartNode ( ) . getStartPosition ( ) - r2 . getStartNode ( ) . getStartPosition ( ) ; if ( startDiff != <NUM_LIT:0> ) { return startDiff ; } int endDiff = getEndNode ( ) . getStartPosition ( ) - r2 . getEndNode ( ) . getStartPosition ( ) ; if ( endDiff != <NUM_LIT:0> ) { return - endDiff ; } if ( r2 . isMove ( ) != isMove ( ) ) { return isMove ( ) ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return <NUM_LIT:0> ; } public void updatePlaceholderSourceRanges ( TargetSourceRangeComputer sourceRangeComputer ) { TargetSourceRangeComputer . SourceRange startRange = sourceRangeComputer . computeSourceRange ( getStartNode ( ) ) ; TargetSourceRangeComputer . SourceRange endRange = sourceRangeComputer . computeSourceRange ( getEndNode ( ) ) ; int startPos = startRange . getStartPosition ( ) ; int endPos = endRange . getStartPosition ( ) + endRange . getLength ( ) ; Block internalPlaceholder = getInternalPlaceholder ( ) ; internalPlaceholder . setSourceRange ( startPos , endPos - startPos ) ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( this . first != this . last ) { buf . append ( "<STR_LIT>" ) ; } if ( isMove ( ) ) { buf . append ( "<STR_LIT>" ) ; } else { buf . append ( "<STR_LIT>" ) ; } buf . append ( this . first ) ; buf . append ( "<STR_LIT:U+0020-U+0020>" ) ; buf . append ( this . last ) ; return buf . toString ( ) ; } } private class ParentIterator implements Iterator { private Iterator eventIter ; private Iterator sourceNodeIter ; private Iterator rangeNodeIter ; private Iterator trackedNodeIter ; public ParentIterator ( ) { this . eventIter = RewriteEventStore . this . eventLookup . keySet ( ) . iterator ( ) ; if ( RewriteEventStore . this . nodeCopySources != null ) { this . sourceNodeIter = RewriteEventStore . this . nodeCopySources . iterator ( ) ; } else { this . sourceNodeIter = Collections . EMPTY_LIST . iterator ( ) ; } if ( RewriteEventStore . this . nodeRangeInfos != null ) { this . rangeNodeIter = RewriteEventStore . this . nodeRangeInfos . keySet ( ) . iterator ( ) ; } else { this . rangeNodeIter = Collections . EMPTY_LIST . iterator ( ) ; } if ( RewriteEventStore . this . trackedNodes != null ) { this . trackedNodeIter = RewriteEventStore . this . trackedNodes . keySet ( ) . iterator ( ) ; } else { this . trackedNodeIter = Collections . EMPTY_LIST . iterator ( ) ; } } public boolean hasNext ( ) { return this . eventIter . hasNext ( ) || this . sourceNodeIter . hasNext ( ) || this . rangeNodeIter . hasNext ( ) || this . trackedNodeIter . hasNext ( ) ; } public Object next ( ) { if ( this . eventIter . hasNext ( ) ) { return this . eventIter . next ( ) ; } if ( this . sourceNodeIter . hasNext ( ) ) { return ( ( CopySourceInfo ) this . sourceNodeIter . next ( ) ) . getNode ( ) ; } if ( this . rangeNodeIter . hasNext ( ) ) { return ( ( PropertyLocation ) this . rangeNodeIter . next ( ) ) . getParent ( ) ; } return this . trackedNodeIter . next ( ) ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } public final static int NEW = <NUM_LIT:1> ; public final static int ORIGINAL = <NUM_LIT:2> ; public final static int BOTH = NEW | ORIGINAL ; final Map eventLookup ; private EventHolder lastEvent ; private Map editGroups ; List nodeCopySources ; Map nodeRangeInfos ; Map trackedNodes ; private Set insertBoundToPrevious ; private INodePropertyMapper nodePropertyMapper ; private static final String INTERNAL_PLACEHOLDER_PROPERTY = "<STR_LIT>" ; public RewriteEventStore ( ) { this . eventLookup = new HashMap ( ) ; this . lastEvent = null ; this . editGroups = null ; this . trackedNodes = null ; this . insertBoundToPrevious = null ; this . nodePropertyMapper = null ; this . nodeCopySources = null ; this . nodeRangeInfos = null ; } public void setNodePropertyMapper ( INodePropertyMapper nodePropertyMapper ) { this . nodePropertyMapper = nodePropertyMapper ; } public void clear ( ) { this . eventLookup . clear ( ) ; this . lastEvent = null ; this . trackedNodes = null ; this . editGroups = null ; this . insertBoundToPrevious = null ; this . nodeCopySources = null ; } public void addEvent ( ASTNode parent , StructuralPropertyDescriptor childProperty , RewriteEvent event ) { validateHasChildProperty ( parent , childProperty ) ; if ( event . isListRewrite ( ) ) { validateIsListProperty ( childProperty ) ; } EventHolder holder = new EventHolder ( parent , childProperty , event ) ; List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder curr = ( EventHolder ) entriesList . get ( i ) ; if ( curr . childProperty == childProperty ) { entriesList . set ( i , holder ) ; this . lastEvent = null ; return ; } } } else { entriesList = new ArrayList ( <NUM_LIT:3> ) ; this . eventLookup . put ( parent , entriesList ) ; } entriesList . add ( holder ) ; } public RewriteEvent getEvent ( ASTNode parent , StructuralPropertyDescriptor property ) { validateHasChildProperty ( parent , property ) ; if ( this . lastEvent != null && this . lastEvent . parent == parent && this . lastEvent . childProperty == property ) { return this . lastEvent . event ; } List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) entriesList . get ( i ) ; if ( holder . childProperty == property ) { this . lastEvent = holder ; return holder . event ; } } } return null ; } public NodeRewriteEvent getNodeEvent ( ASTNode parent , StructuralPropertyDescriptor childProperty , boolean forceCreation ) { validateIsNodeProperty ( childProperty ) ; NodeRewriteEvent event = ( NodeRewriteEvent ) getEvent ( parent , childProperty ) ; if ( event == null && forceCreation ) { Object originalValue = accessOriginalValue ( parent , childProperty ) ; event = new NodeRewriteEvent ( originalValue , originalValue ) ; addEvent ( parent , childProperty , event ) ; } return event ; } public ListRewriteEvent getListEvent ( ASTNode parent , StructuralPropertyDescriptor childProperty , boolean forceCreation ) { validateIsListProperty ( childProperty ) ; ListRewriteEvent event = ( ListRewriteEvent ) getEvent ( parent , childProperty ) ; if ( event == null && forceCreation ) { List originalValue = ( List ) accessOriginalValue ( parent , childProperty ) ; event = new ListRewriteEvent ( originalValue ) ; addEvent ( parent , childProperty , event ) ; } return event ; } public Iterator getChangeRootIterator ( ) { return new ParentIterator ( ) ; } public boolean hasChangedProperties ( ASTNode parent ) { List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) entriesList . get ( i ) ; if ( holder . event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { return true ; } } } return false ; } public PropertyLocation getPropertyLocation ( Object value , int kind ) { for ( Iterator iter = this . eventLookup . values ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { List events = ( List ) iter . next ( ) ; for ( int i = <NUM_LIT:0> ; i < events . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) events . get ( i ) ; RewriteEvent event = holder . event ; if ( isNodeInEvent ( event , value , kind ) ) { return new PropertyLocation ( holder . parent , holder . childProperty ) ; } if ( event . isListRewrite ( ) ) { RewriteEvent [ ] children = event . getChildren ( ) ; for ( int k = <NUM_LIT:0> ; k < children . length ; k ++ ) { if ( isNodeInEvent ( children [ k ] , value , kind ) ) { return new PropertyLocation ( holder . parent , holder . childProperty ) ; } } } } } if ( value instanceof ASTNode ) { ASTNode node = ( ASTNode ) value ; return new PropertyLocation ( node . getParent ( ) , node . getLocationInParent ( ) ) ; } return null ; } public RewriteEvent findEvent ( Object value , int kind ) { for ( Iterator iter = this . eventLookup . values ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { List events = ( List ) iter . next ( ) ; for ( int i = <NUM_LIT:0> ; i < events . size ( ) ; i ++ ) { RewriteEvent event = ( ( EventHolder ) events . get ( i ) ) . event ; if ( isNodeInEvent ( event , value , kind ) ) { return event ; } if ( event . isListRewrite ( ) ) { RewriteEvent [ ] children = event . getChildren ( ) ; for ( int k = <NUM_LIT:0> ; k < children . length ; k ++ ) { if ( isNodeInEvent ( children [ k ] , value , kind ) ) { return children [ k ] ; } } } } } return null ; } private boolean isNodeInEvent ( RewriteEvent event , Object value , int kind ) { if ( ( ( kind & NEW ) != <NUM_LIT:0> ) && event . getNewValue ( ) == value ) { return true ; } if ( ( ( kind & ORIGINAL ) != <NUM_LIT:0> ) && event . getOriginalValue ( ) == value ) { return true ; } return false ; } public Object getOriginalValue ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { return event . getOriginalValue ( ) ; } return accessOriginalValue ( parent , property ) ; } public Object getNewValue ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { return event . getNewValue ( ) ; } return accessOriginalValue ( parent , property ) ; } public List getChangedPropertieEvents ( ASTNode parent ) { List changedPropertiesEvent = new ArrayList ( ) ; List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) entriesList . get ( i ) ; if ( holder . event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { changedPropertiesEvent . add ( holder . event ) ; } } } return changedPropertiesEvent ; } public int getChangeKind ( ASTNode node ) { RewriteEvent event = findEvent ( node , ORIGINAL ) ; if ( event != null ) { return event . getChangeKind ( ) ; } return RewriteEvent . UNCHANGED ; } private Object accessOriginalValue ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { if ( this . nodePropertyMapper != null ) { return this . nodePropertyMapper . getOriginalValue ( parent , childProperty ) ; } return parent . getStructuralProperty ( childProperty ) ; } public TextEditGroup getEventEditGroup ( RewriteEvent event ) { if ( this . editGroups == null ) { return null ; } return ( TextEditGroup ) this . editGroups . get ( event ) ; } public void setEventEditGroup ( RewriteEvent event , TextEditGroup editGroup ) { if ( this . editGroups == null ) { this . editGroups = new IdentityHashMap ( <NUM_LIT:5> ) ; } this . editGroups . put ( event , editGroup ) ; } public final TextEditGroup getTrackedNodeData ( ASTNode node ) { if ( this . trackedNodes != null ) { return ( TextEditGroup ) this . trackedNodes . get ( node ) ; } return null ; } public void setTrackedNodeData ( ASTNode node , TextEditGroup editGroup ) { if ( this . trackedNodes == null ) { this . trackedNodes = new IdentityHashMap ( ) ; } this . trackedNodes . put ( node , editGroup ) ; } public final void markAsTracked ( ASTNode node , TextEditGroup editGroup ) { if ( getTrackedNodeData ( node ) != null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } setTrackedNodeData ( node , editGroup ) ; } private final CopySourceInfo createCopySourceInfo ( PropertyLocation location , ASTNode node , boolean isMove ) { CopySourceInfo copySource = new CopySourceInfo ( location , node , isMove ) ; if ( this . nodeCopySources == null ) { this . nodeCopySources = new ArrayList ( ) ; } this . nodeCopySources . add ( copySource ) ; return copySource ; } public final CopySourceInfo markAsCopySource ( ASTNode parent , StructuralPropertyDescriptor property , ASTNode node , boolean isMove ) { return createCopySourceInfo ( new PropertyLocation ( parent , property ) , node , isMove ) ; } public final boolean isRangeCopyPlaceholder ( ASTNode node ) { return node . getProperty ( INTERNAL_PLACEHOLDER_PROPERTY ) != null ; } public final CopySourceInfo createRangeCopy ( ASTNode parent , StructuralPropertyDescriptor childProperty , ASTNode first , ASTNode last , boolean isMove , ASTNode internalPlaceholder , ASTNode replacingNode , TextEditGroup editGroup ) { CopySourceInfo copyInfo = createCopySourceInfo ( null , internalPlaceholder , isMove ) ; internalPlaceholder . setProperty ( INTERNAL_PLACEHOLDER_PROPERTY , internalPlaceholder ) ; NodeRangeInfo copyRangeInfo = new NodeRangeInfo ( parent , childProperty , first , last , copyInfo , replacingNode , editGroup ) ; ListRewriteEvent listEvent = getListEvent ( parent , childProperty , true ) ; int indexFirst = listEvent . getIndex ( first , ListRewriteEvent . OLD ) ; if ( indexFirst == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } int indexLast = listEvent . getIndex ( last , ListRewriteEvent . OLD ) ; if ( indexLast == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( indexFirst > indexLast ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( this . nodeRangeInfos == null ) { this . nodeRangeInfos = new HashMap ( ) ; } PropertyLocation loc = new PropertyLocation ( parent , childProperty ) ; List innerList = ( List ) this . nodeRangeInfos . get ( loc ) ; if ( innerList == null ) { innerList = new ArrayList ( <NUM_LIT:2> ) ; this . nodeRangeInfos . put ( loc , innerList ) ; } else { assertNoOverlap ( listEvent , indexFirst , indexLast , innerList ) ; } innerList . add ( copyRangeInfo ) ; return copyInfo ; } public CopySourceInfo [ ] getNodeCopySources ( ASTNode node ) { if ( this . nodeCopySources == null ) { return null ; } return internalGetCopySources ( this . nodeCopySources , node ) ; } public CopySourceInfo [ ] internalGetCopySources ( List copySources , ASTNode node ) { ArrayList res = new ArrayList ( <NUM_LIT:3> ) ; for ( int i = <NUM_LIT:0> ; i < copySources . size ( ) ; i ++ ) { CopySourceInfo curr = ( CopySourceInfo ) copySources . get ( i ) ; if ( curr . getNode ( ) == node ) { res . add ( curr ) ; } } if ( res . isEmpty ( ) ) { return null ; } CopySourceInfo [ ] arr = ( CopySourceInfo [ ] ) res . toArray ( new CopySourceInfo [ res . size ( ) ] ) ; Arrays . sort ( arr ) ; return arr ; } private void assertNoOverlap ( ListRewriteEvent listEvent , int indexFirst , int indexLast , List innerList ) { for ( Iterator iter = innerList . iterator ( ) ; iter . hasNext ( ) ; ) { NodeRangeInfo curr = ( NodeRangeInfo ) iter . next ( ) ; int currStart = listEvent . getIndex ( curr . getStartNode ( ) , ListRewriteEvent . BOTH ) ; int currEnd = listEvent . getIndex ( curr . getEndNode ( ) , ListRewriteEvent . BOTH ) ; if ( currStart < indexFirst && currEnd < indexLast && currEnd >= indexFirst || currStart > indexFirst && currStart <= currEnd && currEnd > indexLast ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } } public void prepareMovedNodes ( TargetSourceRangeComputer sourceRangeComputer ) { if ( this . nodeCopySources != null ) { prepareSingleNodeCopies ( ) ; } if ( this . nodeRangeInfos != null ) { prepareNodeRangeCopies ( sourceRangeComputer ) ; } } public void revertMovedNodes ( ) { if ( this . nodeRangeInfos != null ) { removeMoveRangePlaceholders ( ) ; } } private void removeMoveRangePlaceholders ( ) { for ( Iterator iter = this . nodeRangeInfos . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; Set placeholders = new HashSet ( ) ; List rangeInfos = ( List ) entry . getValue ( ) ; for ( int i = <NUM_LIT:0> ; i < rangeInfos . size ( ) ; i ++ ) { placeholders . add ( ( ( NodeRangeInfo ) rangeInfos . get ( i ) ) . getInternalPlaceholder ( ) ) ; } PropertyLocation loc = ( PropertyLocation ) entry . getKey ( ) ; RewriteEvent [ ] children = getListEvent ( loc . getParent ( ) , loc . getProperty ( ) , true ) . getChildren ( ) ; List revertedChildren = new ArrayList ( ) ; revertListWithRanges ( children , placeholders , revertedChildren ) ; RewriteEvent [ ] revertedChildrenArr = ( RewriteEvent [ ] ) revertedChildren . toArray ( new RewriteEvent [ revertedChildren . size ( ) ] ) ; addEvent ( loc . getParent ( ) , loc . getProperty ( ) , new ListRewriteEvent ( revertedChildrenArr ) ) ; } } private void revertListWithRanges ( RewriteEvent [ ] childEvents , Set placeholders , List revertedChildren ) { for ( int i = <NUM_LIT:0> ; i < childEvents . length ; i ++ ) { RewriteEvent event = childEvents [ i ] ; ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; if ( placeholders . contains ( node ) ) { RewriteEvent [ ] placeholderChildren = getListEvent ( node , Block . STATEMENTS_PROPERTY , false ) . getChildren ( ) ; revertListWithRanges ( placeholderChildren , placeholders , revertedChildren ) ; } else { revertedChildren . add ( event ) ; } } } private void prepareNodeRangeCopies ( TargetSourceRangeComputer sourceRangeComputer ) { for ( Iterator iter = this . nodeRangeInfos . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; List rangeInfos = ( List ) entry . getValue ( ) ; Collections . sort ( rangeInfos ) ; PropertyLocation loc = ( PropertyLocation ) entry . getKey ( ) ; RewriteEvent [ ] children = getListEvent ( loc . getParent ( ) , loc . getProperty ( ) , true ) . getChildren ( ) ; RewriteEvent [ ] newChildren = processListWithRanges ( rangeInfos , children , sourceRangeComputer ) ; addEvent ( loc . getParent ( ) , loc . getProperty ( ) , new ListRewriteEvent ( newChildren ) ) ; } } private RewriteEvent [ ] processListWithRanges ( List rangeInfos , RewriteEvent [ ] childEvents , TargetSourceRangeComputer sourceRangeComputer ) { List newChildEvents = new ArrayList ( childEvents . length ) ; NodeRangeInfo topInfo = null ; Stack newChildrenStack = new Stack ( ) ; Stack topInfoStack = new Stack ( ) ; Iterator rangeInfoIterator = rangeInfos . iterator ( ) ; NodeRangeInfo nextInfo = ( NodeRangeInfo ) rangeInfoIterator . next ( ) ; for ( int k = <NUM_LIT:0> ; k < childEvents . length ; k ++ ) { RewriteEvent event = childEvents [ k ] ; ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; while ( nextInfo != null && node == nextInfo . getStartNode ( ) ) { nextInfo . updatePlaceholderSourceRanges ( sourceRangeComputer ) ; Block internalPlaceholder = nextInfo . getInternalPlaceholder ( ) ; RewriteEvent newEvent ; if ( nextInfo . isMove ( ) ) { newEvent = new NodeRewriteEvent ( internalPlaceholder , nextInfo . replacingNode ) ; } else { newEvent = new NodeRewriteEvent ( internalPlaceholder , internalPlaceholder ) ; } newChildEvents . add ( newEvent ) ; if ( nextInfo . editGroup != null ) { setEventEditGroup ( newEvent , nextInfo . editGroup ) ; } newChildrenStack . push ( newChildEvents ) ; topInfoStack . push ( topInfo ) ; newChildEvents = new ArrayList ( childEvents . length ) ; topInfo = nextInfo ; nextInfo = rangeInfoIterator . hasNext ( ) ? ( NodeRangeInfo ) rangeInfoIterator . next ( ) : null ; } newChildEvents . add ( event ) ; while ( topInfo != null && node == topInfo . getEndNode ( ) ) { RewriteEvent [ ] placeholderChildEvents = ( RewriteEvent [ ] ) newChildEvents . toArray ( new RewriteEvent [ newChildEvents . size ( ) ] ) ; Block internalPlaceholder = topInfo . getInternalPlaceholder ( ) ; addEvent ( internalPlaceholder , Block . STATEMENTS_PROPERTY , new ListRewriteEvent ( placeholderChildEvents ) ) ; newChildEvents = ( List ) newChildrenStack . pop ( ) ; topInfo = ( NodeRangeInfo ) topInfoStack . pop ( ) ; } } return ( RewriteEvent [ ] ) newChildEvents . toArray ( new RewriteEvent [ newChildEvents . size ( ) ] ) ; } private void prepareSingleNodeCopies ( ) { for ( int i = <NUM_LIT:0> ; i < this . nodeCopySources . size ( ) ; i ++ ) { CopySourceInfo curr = ( CopySourceInfo ) this . nodeCopySources . get ( i ) ; if ( curr . isMove && curr . location != null ) { doMarkMovedAsRemoved ( curr , curr . location . getParent ( ) , curr . location . getProperty ( ) ) ; } } } private void doMarkMovedAsRemoved ( CopySourceInfo curr , ASTNode parent , StructuralPropertyDescriptor childProperty ) { if ( childProperty . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( parent , childProperty , true ) ; int index = event . getIndex ( curr . getNode ( ) , ListRewriteEvent . OLD ) ; if ( index != - <NUM_LIT:1> && event . getChangeKind ( index ) == RewriteEvent . UNCHANGED ) { event . setNewValue ( null , index ) ; } } else { NodeRewriteEvent event = getNodeEvent ( parent , childProperty , true ) ; if ( event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { event . setNewValue ( null ) ; } } } public boolean isInsertBoundToPrevious ( ASTNode node ) { if ( this . insertBoundToPrevious != null ) { return this . insertBoundToPrevious . contains ( node ) ; } return false ; } public void setInsertBoundToPrevious ( ASTNode node ) { if ( this . insertBoundToPrevious == null ) { this . insertBoundToPrevious = new HashSet ( ) ; } this . insertBoundToPrevious . add ( node ) ; } private void validateIsListProperty ( StructuralPropertyDescriptor property ) { if ( ! property . isChildListProperty ( ) ) { String message = property . getId ( ) + "<STR_LIT>" ; throw new IllegalArgumentException ( message ) ; } } private void validateHasChildProperty ( ASTNode parent , StructuralPropertyDescriptor property ) { if ( ! parent . structuralPropertiesForType ( ) . contains ( property ) ) { String message = Signature . getSimpleName ( parent . getClass ( ) . getName ( ) ) + "<STR_LIT>" + property . getId ( ) ; throw new IllegalArgumentException ( message ) ; } } private void validateIsNodeProperty ( StructuralPropertyDescriptor property ) { if ( property . isChildListProperty ( ) ) { String message = property . getId ( ) + "<STR_LIT>" ; throw new IllegalArgumentException ( message ) ; } } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; for ( Iterator iter = this . eventLookup . values ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { List events = ( List ) iter . next ( ) ; for ( int i = <NUM_LIT:0> ; i < events . size ( ) ; i ++ ) { buf . append ( events . get ( i ) . toString ( ) ) . append ( '<STR_LIT:\n>' ) ; } } return buf . toString ( ) ; } public static boolean isNewNode ( ASTNode node ) { return ( node . getFlags ( ) & ASTNode . ORIGINAL ) == <NUM_LIT:0> ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . Status ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class TokenScanner { public static final int END_OF_FILE = <NUM_LIT> ; public static final int LEXICAL_ERROR = <NUM_LIT> ; public static final int DOCUMENT_ERROR = <NUM_LIT> ; private final Scanner scanner ; private final int endPosition ; public TokenScanner ( Scanner scanner ) { this . scanner = scanner ; this . endPosition = this . scanner . getSource ( ) . length - <NUM_LIT:1> ; } public Scanner getScanner ( ) { return this . scanner ; } public void setOffset ( int offset ) { this . scanner . resetTo ( offset , this . endPosition ) ; } public int getCurrentEndOffset ( ) { return this . scanner . getCurrentTokenEndPosition ( ) + <NUM_LIT:1> ; } public int getCurrentStartOffset ( ) { return this . scanner . getCurrentTokenStartPosition ( ) ; } public int getCurrentLength ( ) { return getCurrentEndOffset ( ) - getCurrentStartOffset ( ) ; } public int readNext ( boolean ignoreComments ) throws CoreException { int curr = <NUM_LIT:0> ; do { try { curr = this . scanner . getNextToken ( ) ; if ( curr == TerminalTokens . TokenNameEOF ) { throw new CoreException ( createError ( END_OF_FILE , "<STR_LIT>" , null ) ) ; } } catch ( InvalidInputException e ) { throw new CoreException ( createError ( LEXICAL_ERROR , e . getMessage ( ) , e ) ) ; } } while ( ignoreComments && isComment ( curr ) ) ; return curr ; } public int readNext ( int offset , boolean ignoreComments ) throws CoreException { setOffset ( offset ) ; return readNext ( ignoreComments ) ; } public int getNextStartOffset ( int offset , boolean ignoreComments ) throws CoreException { readNext ( offset , ignoreComments ) ; return getCurrentStartOffset ( ) ; } public int getNextEndOffset ( int offset , boolean ignoreComments ) throws CoreException { readNext ( offset , ignoreComments ) ; return getCurrentEndOffset ( ) ; } public void readToToken ( int tok ) throws CoreException { int curr = <NUM_LIT:0> ; do { curr = readNext ( false ) ; } while ( curr != tok ) ; } public void readToToken ( int tok , int offset ) throws CoreException { setOffset ( offset ) ; readToToken ( tok ) ; } public int getTokenStartOffset ( int token , int startOffset ) throws CoreException { readToToken ( token , startOffset ) ; return getCurrentStartOffset ( ) ; } public int getTokenEndOffset ( int token , int startOffset ) throws CoreException { readToToken ( token , startOffset ) ; return getCurrentEndOffset ( ) ; } public int getPreviousTokenEndOffset ( int token , int startOffset ) throws CoreException { setOffset ( startOffset ) ; int res = startOffset ; int curr = readNext ( false ) ; while ( curr != token ) { res = getCurrentEndOffset ( ) ; curr = readNext ( false ) ; } return res ; } public static boolean isComment ( int token ) { return token == TerminalTokens . TokenNameCOMMENT_BLOCK || token == TerminalTokens . TokenNameCOMMENT_JAVADOC || token == TerminalTokens . TokenNameCOMMENT_LINE ; } public static boolean isModifier ( int token ) { switch ( token ) { case TerminalTokens . TokenNamepublic : case TerminalTokens . TokenNameprotected : case TerminalTokens . TokenNameprivate : case TerminalTokens . TokenNamestatic : case TerminalTokens . TokenNamefinal : case TerminalTokens . TokenNameabstract : case TerminalTokens . TokenNamenative : case TerminalTokens . TokenNamevolatile : case TerminalTokens . TokenNamestrictfp : case TerminalTokens . TokenNametransient : case TerminalTokens . TokenNamesynchronized : return true ; default : return false ; } } public static IStatus createError ( int code , String message , Throwable throwable ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , code , message , throwable ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . dom . ASTNode ; public class ListRewriteEvent extends RewriteEvent { public final static int NEW = <NUM_LIT:1> ; public final static int OLD = <NUM_LIT:2> ; public final static int BOTH = NEW | OLD ; private List originalNodes ; private List listEntries ; public ListRewriteEvent ( List originalNodes ) { this . originalNodes = new ArrayList ( originalNodes ) ; } public ListRewriteEvent ( RewriteEvent [ ] children ) { this . listEntries = new ArrayList ( children . length * <NUM_LIT:2> ) ; this . originalNodes = new ArrayList ( children . length * <NUM_LIT:2> ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { RewriteEvent curr = children [ i ] ; this . listEntries . add ( curr ) ; if ( curr . getOriginalValue ( ) != null ) { this . originalNodes . add ( curr . getOriginalValue ( ) ) ; } } } private List getEntries ( ) { if ( this . listEntries == null ) { int nNodes = this . originalNodes . size ( ) ; this . listEntries = new ArrayList ( nNodes * <NUM_LIT:2> ) ; for ( int i = <NUM_LIT:0> ; i < nNodes ; i ++ ) { ASTNode node = ( ASTNode ) this . originalNodes . get ( i ) ; this . listEntries . add ( new NodeRewriteEvent ( node , node ) ) ; } } return this . listEntries ; } public int getChangeKind ( ) { if ( this . listEntries != null ) { for ( int i = <NUM_LIT:0> ; i < this . listEntries . size ( ) ; i ++ ) { RewriteEvent curr = ( RewriteEvent ) this . listEntries . get ( i ) ; if ( curr . getChangeKind ( ) != UNCHANGED ) { return CHILDREN_CHANGED ; } } } return UNCHANGED ; } public boolean isListRewrite ( ) { return true ; } public RewriteEvent [ ] getChildren ( ) { List entries = getEntries ( ) ; return ( RewriteEvent [ ] ) entries . toArray ( new RewriteEvent [ entries . size ( ) ] ) ; } public Object getOriginalValue ( ) { return this . originalNodes ; } public Object getNewValue ( ) { List entries = getEntries ( ) ; ArrayList res = new ArrayList ( entries . size ( ) ) ; for ( int i = <NUM_LIT:0> ; i < entries . size ( ) ; i ++ ) { RewriteEvent curr = ( RewriteEvent ) entries . get ( i ) ; Object newVal = curr . getNewValue ( ) ; if ( newVal != null ) { res . add ( newVal ) ; } } return res ; } public RewriteEvent removeEntry ( ASTNode originalEntry ) { return replaceEntry ( originalEntry , null ) ; } public RewriteEvent replaceEntry ( ASTNode entry , ASTNode newEntry ) { if ( entry == null ) { throw new IllegalArgumentException ( ) ; } List entries = getEntries ( ) ; int nEntries = entries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nEntries ; i ++ ) { NodeRewriteEvent curr = ( NodeRewriteEvent ) entries . get ( i ) ; if ( curr . getOriginalValue ( ) == entry || curr . getNewValue ( ) == entry ) { curr . setNewValue ( newEntry ) ; if ( curr . getNewValue ( ) == null && curr . getOriginalValue ( ) == null ) { entries . remove ( i ) ; return null ; } return curr ; } } return null ; } public void revertChange ( NodeRewriteEvent event ) { Object originalValue = event . getOriginalValue ( ) ; if ( originalValue == null ) { List entries = getEntries ( ) ; entries . remove ( event ) ; } else { event . setNewValue ( originalValue ) ; } } public int getIndex ( ASTNode node , int kind ) { List entries = getEntries ( ) ; for ( int i = entries . size ( ) - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { RewriteEvent curr = ( RewriteEvent ) entries . get ( i ) ; if ( ( ( kind & OLD ) != <NUM_LIT:0> ) && ( curr . getOriginalValue ( ) == node ) ) { return i ; } if ( ( ( kind & NEW ) != <NUM_LIT:0> ) && ( curr . getNewValue ( ) == node ) ) { return i ; } } return - <NUM_LIT:1> ; } public RewriteEvent insert ( ASTNode insertedNode , int insertIndex ) { NodeRewriteEvent change = new NodeRewriteEvent ( null , insertedNode ) ; if ( insertIndex != - <NUM_LIT:1> ) { getEntries ( ) . add ( insertIndex , change ) ; } else { getEntries ( ) . add ( change ) ; } return change ; } public void setNewValue ( ASTNode newValue , int insertIndex ) { NodeRewriteEvent curr = ( NodeRewriteEvent ) getEntries ( ) . get ( insertIndex ) ; curr . setNewValue ( newValue ) ; } public int getChangeKind ( int index ) { return ( ( NodeRewriteEvent ) getEntries ( ) . get ( index ) ) . getChangeKind ( ) ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "<STR_LIT>" ) ; RewriteEvent [ ] events = getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < events . length ; i ++ ) { if ( i != <NUM_LIT:0> ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( events [ i ] ) ; } buf . append ( "<STR_LIT>" ) ; return buf . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . HashSet ; import java . util . IdentityHashMap ; import java . util . Map ; import java . util . Set ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . FieldDeclaration ; import org . eclipse . jdt . core . dom . Modifier ; import org . eclipse . jdt . core . dom . ParameterizedType ; import org . eclipse . jdt . core . dom . TryStatement ; import org . eclipse . jdt . core . dom . VariableDeclarationExpression ; import org . eclipse . jdt . core . dom . VariableDeclarationStatement ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; public final class NodeInfoStore { private AST ast ; private Map placeholderNodes ; private Set collapsedNodes ; public NodeInfoStore ( AST ast ) { super ( ) ; this . ast = ast ; this . placeholderNodes = null ; this . collapsedNodes = null ; } public final void markAsStringPlaceholder ( ASTNode placeholder , String code ) { StringPlaceholderData data = new StringPlaceholderData ( ) ; data . code = code ; setPlaceholderData ( placeholder , data ) ; } public final void markAsCopyTarget ( ASTNode target , CopySourceInfo copySource ) { CopyPlaceholderData data = new CopyPlaceholderData ( ) ; data . copySource = copySource ; setPlaceholderData ( target , data ) ; } public final ASTNode newPlaceholderNode ( int nodeType ) { try { ASTNode node = this . ast . createInstance ( nodeType ) ; switch ( node . getNodeType ( ) ) { case ASTNode . FIELD_DECLARATION : ( ( FieldDeclaration ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . MODIFIER : ( ( Modifier ) node ) . setKeyword ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case ASTNode . TRY_STATEMENT : ( ( TryStatement ) node ) . setFinally ( this . ast . newBlock ( ) ) ; break ; case ASTNode . VARIABLE_DECLARATION_EXPRESSION : ( ( VariableDeclarationExpression ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : ( ( VariableDeclarationStatement ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . PARAMETERIZED_TYPE : ( ( ParameterizedType ) node ) . typeArguments ( ) . add ( this . ast . newWildcardType ( ) ) ; break ; } return node ; } catch ( IllegalArgumentException e ) { return null ; } } public Block createCollapsePlaceholder ( ) { Block placeHolder = this . ast . newBlock ( ) ; if ( this . collapsedNodes == null ) { this . collapsedNodes = new HashSet ( ) ; } this . collapsedNodes . add ( placeHolder ) ; return placeHolder ; } public boolean isCollapsed ( ASTNode node ) { if ( this . collapsedNodes != null ) { return this . collapsedNodes . contains ( node ) ; } return false ; } public Object getPlaceholderData ( ASTNode node ) { if ( this . placeholderNodes != null ) { return this . placeholderNodes . get ( node ) ; } return null ; } private void setPlaceholderData ( ASTNode node , PlaceholderData data ) { if ( this . placeholderNodes == null ) { this . placeholderNodes = new IdentityHashMap ( ) ; } this . placeholderNodes . put ( node , data ) ; } static class PlaceholderData { } protected static final class CopyPlaceholderData extends PlaceholderData { public CopySourceInfo copySource ; public String toString ( ) { return "<STR_LIT>" + this . copySource + "<STR_LIT:]>" ; } } protected static final class StringPlaceholderData extends PlaceholderData { public String code ; public String toString ( ) { return "<STR_LIT>" + this . code + "<STR_LIT:]>" ; } } public void clear ( ) { this . placeholderNodes = null ; this . collapsedNodes = null ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . dom ; import java . util . Iterator ; import java . util . List ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . ASTVisitor ; import org . eclipse . jdt . core . dom . AbstractTypeDeclaration ; import org . eclipse . jdt . core . dom . Annotation ; import org . eclipse . jdt . core . dom . AnnotationTypeDeclaration ; import org . eclipse . jdt . core . dom . AnnotationTypeMemberDeclaration ; import org . eclipse . jdt . core . dom . AnonymousClassDeclaration ; import org . eclipse . jdt . core . dom . ArrayAccess ; import org . eclipse . jdt . core . dom . ArrayCreation ; import org . eclipse . jdt . core . dom . ArrayInitializer ; import org . eclipse . jdt . core . dom . ArrayType ; import org . eclipse . jdt . core . dom . AssertStatement ; import org . eclipse . jdt . core . dom . Assignment ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . BlockComment ; import org . eclipse . jdt . core . dom . BodyDeclaration ; import org . eclipse . jdt . core . dom . BooleanLiteral ; import org . eclipse . jdt . core . dom . BreakStatement ; import org . eclipse . jdt . core . dom . CastExpression ; import org . eclipse . jdt . core . dom . CatchClause ; import org . eclipse . jdt . core . dom . CharacterLiteral ; import org . eclipse . jdt . core . dom . ClassInstanceCreation ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . ConditionalExpression ; import org . eclipse . jdt . core . dom . ConstructorInvocation ; import org . eclipse . jdt . core . dom . ContinueStatement ; import org . eclipse . jdt . core . dom . UnionType ; import org . eclipse . jdt . core . dom . DoStatement ; import org . eclipse . jdt . core . dom . EmptyStatement ; import org . eclipse . jdt . core . dom . EnhancedForStatement ; import org . eclipse . jdt . core . dom . EnumConstantDeclaration ; import org . eclipse . jdt . core . dom . EnumDeclaration ; import org . eclipse . jdt . core . dom . Expression ; import org . eclipse . jdt . core . dom . ExpressionStatement ; import org . eclipse . jdt . core . dom . FieldAccess ; import org . eclipse . jdt . core . dom . FieldDeclaration ; import org . eclipse . jdt . core . dom . ForStatement ; import org . eclipse . jdt . core . dom . IfStatement ; import org . eclipse . jdt . core . dom . ImportDeclaration ; import org . eclipse . jdt . core . dom . InfixExpression ; import org . eclipse . jdt . core . dom . Initializer ; import org . eclipse . jdt . core . dom . InstanceofExpression ; import org . eclipse . jdt . core . dom . Javadoc ; import org . eclipse . jdt . core . dom . LabeledStatement ; import org . eclipse . jdt . core . dom . LineComment ; import org . eclipse . jdt . core . dom . MarkerAnnotation ; import org . eclipse . jdt . core . dom . MemberRef ; import org . eclipse . jdt . core . dom . MemberValuePair ; import org . eclipse . jdt . core . dom . MethodDeclaration ; import org . eclipse . jdt . core . dom . MethodInvocation ; import org . eclipse . jdt . core . dom . MethodRef ; import org . eclipse . jdt . core . dom . MethodRefParameter ; import org . eclipse . jdt . core . dom . Modifier ; import org . eclipse . jdt . core . dom . Name ; import org . eclipse . jdt . core . dom . NormalAnnotation ; import org . eclipse . jdt . core . dom . NullLiteral ; import org . eclipse . jdt . core . dom . NumberLiteral ; import org . eclipse . jdt . core . dom . PackageDeclaration ; import org . eclipse . jdt . core . dom . ParameterizedType ; import org . eclipse . jdt . core . dom . ParenthesizedExpression ; import org . eclipse . jdt . core . dom . PostfixExpression ; import org . eclipse . jdt . core . dom . PrefixExpression ; import org . eclipse . jdt . core . dom . PrimitiveType ; import org . eclipse . jdt . core . dom . QualifiedName ; import org . eclipse . jdt . core . dom . QualifiedType ; import org . eclipse . jdt . core . dom . ReturnStatement ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . dom . SimpleType ; import org . eclipse . jdt . core . dom . SingleMemberAnnotation ; import org . eclipse . jdt . core . dom . SingleVariableDeclaration ; import org . eclipse . jdt . core . dom . Statement ; import org . eclipse . jdt . core . dom . StringLiteral ; import org . eclipse . jdt . core . dom . SuperConstructorInvocation ; import org . eclipse . jdt . core . dom . SuperFieldAccess ; import org . eclipse . jdt . core . dom . SuperMethodInvocation ; import org . eclipse . jdt . core . dom . SwitchCase ; import org . eclipse . jdt . core . dom . SwitchStatement ; import org . eclipse . jdt . core . dom . SynchronizedStatement ; import org . eclipse . jdt . core . dom . TagElement ; import org . eclipse . jdt . core . dom . TextElement ; import org . eclipse . jdt . core . dom . ThisExpression ; import org . eclipse . jdt . core . dom . ThrowStatement ; import org . eclipse . jdt . core . dom . TryStatement ; import org . eclipse . jdt . core . dom . Type ; import org . eclipse . jdt . core . dom . TypeDeclaration ; import org . eclipse . jdt . core . dom . TypeDeclarationStatement ; import org . eclipse . jdt . core . dom . TypeLiteral ; import org . eclipse . jdt . core . dom . TypeParameter ; import org . eclipse . jdt . core . dom . VariableDeclarationExpression ; import org . eclipse . jdt . core . dom . VariableDeclarationFragment ; import org . eclipse . jdt . core . dom . VariableDeclarationStatement ; import org . eclipse . jdt . core . dom . WhileStatement ; import org . eclipse . jdt . core . dom . WildcardType ; public class NaiveASTFlattener extends ASTVisitor { private static final int JLS2 = AST . JLS2 ; private static final int JLS3 = AST . JLS3 ; protected StringBuffer buffer ; private int indent = <NUM_LIT:0> ; public NaiveASTFlattener ( ) { this . buffer = new StringBuffer ( ) ; } private Name getName ( ClassInstanceCreation node ) { return node . getName ( ) ; } public String getResult ( ) { return this . buffer . toString ( ) ; } private Type getReturnType ( MethodDeclaration node ) { return node . getReturnType ( ) ; } private Name getSuperclass ( TypeDeclaration node ) { return node . getSuperclass ( ) ; } private TypeDeclaration getTypeDeclaration ( TypeDeclarationStatement node ) { return node . getTypeDeclaration ( ) ; } void printIndent ( ) { for ( int i = <NUM_LIT:0> ; i < this . indent ; i ++ ) this . buffer . append ( "<STR_LIT:U+0020U+0020>" ) ; } void printModifiers ( int modifiers ) { if ( Modifier . isPublic ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isProtected ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isPrivate ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isStatic ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isAbstract ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isFinal ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isSynchronized ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isVolatile ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isNative ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isStrictfp ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isTransient ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } } void printModifiers ( List ext ) { for ( Iterator it = ext . iterator ( ) ; it . hasNext ( ) ; ) { ASTNode p = ( ASTNode ) it . next ( ) ; p . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } public void reset ( ) { this . buffer . setLength ( <NUM_LIT:0> ) ; } private List superInterfaces ( TypeDeclaration node ) { return node . superInterfaces ( ) ; } public boolean visit ( AnnotationTypeDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration d = ( BodyDeclaration ) it . next ( ) ; d . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getDefault ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getDefault ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( AnonymousClassDeclaration node ) { this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration b = ( BodyDeclaration ) it . next ( ) ; b . accept ( this ) ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ArrayAccess node ) { node . getArray ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:[>" ) ; node . getIndex ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:]>" ) ; return false ; } public boolean visit ( ArrayCreation node ) { this . buffer . append ( "<STR_LIT>" ) ; ArrayType at = node . getType ( ) ; int dims = at . getDimensions ( ) ; Type elementType = at . getElementType ( ) ; elementType . accept ( this ) ; for ( Iterator it = node . dimensions ( ) . iterator ( ) ; it . hasNext ( ) ; ) { this . buffer . append ( "<STR_LIT:[>" ) ; Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; this . buffer . append ( "<STR_LIT:]>" ) ; dims -- ; } for ( int i = <NUM_LIT:0> ; i < dims ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( node . getInitializer ( ) != null ) { node . getInitializer ( ) . accept ( this ) ; } return false ; } public boolean visit ( ArrayInitializer node ) { this . buffer . append ( "<STR_LIT:{>" ) ; for ( Iterator it = node . expressions ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:}>" ) ; return false ; } public boolean visit ( ArrayType node ) { node . getComponentType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:[]>" ) ; return false ; } public boolean visit ( AssertStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; if ( node . getMessage ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020:U+0020>" ) ; node . getMessage ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( Assignment node ) { node . getLeftHandSide ( ) . accept ( this ) ; this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; node . getRightHandSide ( ) . accept ( this ) ; return false ; } public boolean visit ( Block node ) { this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . statements ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Statement s = ( Statement ) it . next ( ) ; s . accept ( this ) ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( BlockComment node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( BooleanLiteral node ) { if ( node . booleanValue ( ) == true ) { this . buffer . append ( "<STR_LIT:true>" ) ; } else { this . buffer . append ( "<STR_LIT:false>" ) ; } return false ; } public boolean visit ( BreakStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getLabel ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getLabel ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( CastExpression node ) { this . buffer . append ( "<STR_LIT:(>" ) ; node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:)>" ) ; node . getExpression ( ) . accept ( this ) ; return false ; } public boolean visit ( CatchClause node ) { this . buffer . append ( "<STR_LIT>" ) ; node . getException ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( CharacterLiteral node ) { this . buffer . append ( node . getEscapedValue ( ) ) ; return false ; } public boolean visit ( ClassInstanceCreation node ) { if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { getName ( node ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } node . getType ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; if ( node . getAnonymousClassDeclaration ( ) != null ) { node . getAnonymousClassDeclaration ( ) . accept ( this ) ; } return false ; } public boolean visit ( CompilationUnit node ) { if ( node . getPackage ( ) != null ) { node . getPackage ( ) . accept ( this ) ; } for ( Iterator it = node . imports ( ) . iterator ( ) ; it . hasNext ( ) ; ) { ImportDeclaration d = ( ImportDeclaration ) it . next ( ) ; d . accept ( this ) ; } for ( Iterator it = node . types ( ) . iterator ( ) ; it . hasNext ( ) ; ) { AbstractTypeDeclaration d = ( AbstractTypeDeclaration ) it . next ( ) ; d . accept ( this ) ; } return false ; } public boolean visit ( ConditionalExpression node ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getThenExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020:U+0020>" ) ; node . getElseExpression ( ) . accept ( this ) ; return false ; } public boolean visit ( ConstructorInvocation node ) { printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ContinueStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getLabel ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getLabel ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( DoStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( EmptyStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( EnhancedForStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getParameter ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020:U+0020>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( EnumConstantDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; node . getName ( ) . accept ( this ) ; if ( ! node . arguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; } if ( node . getAnonymousClassDeclaration ( ) != null ) { node . getAnonymousClassDeclaration ( ) . accept ( this ) ; } return false ; } public boolean visit ( EnumDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; if ( ! node . superInterfaceTypes ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . superInterfaceTypes ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } this . buffer . append ( "<STR_LIT:{>" ) ; for ( Iterator it = node . enumConstants ( ) . iterator ( ) ; it . hasNext ( ) ; ) { EnumConstantDeclaration d = ( EnumConstantDeclaration ) it . next ( ) ; d . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } if ( ! node . bodyDeclarations ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:;U+0020>" ) ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration d = ( BodyDeclaration ) it . next ( ) ; d . accept ( this ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ExpressionStatement node ) { printIndent ( ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( FieldAccess node ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( FieldDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { VariableDeclarationFragment f = ( VariableDeclarationFragment ) it . next ( ) ; f . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ForStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . initializers ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . buffer . append ( "<STR_LIT:;U+0020>" ) ; if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:;U+0020>" ) ; for ( Iterator it = node . updaters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( IfStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getThenStatement ( ) . accept ( this ) ; if ( node . getElseStatement ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getElseStatement ( ) . accept ( this ) ; } return false ; } public boolean visit ( ImportDeclaration node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( node . isStatic ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } } node . getName ( ) . accept ( this ) ; if ( node . isOnDemand ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( InfixExpression node ) { node . getLeftOperand ( ) . accept ( this ) ; this . buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; this . buffer . append ( '<CHAR_LIT:U+0020>' ) ; node . getRightOperand ( ) . accept ( this ) ; final List extendedOperands = node . extendedOperands ( ) ; if ( extendedOperands . size ( ) != <NUM_LIT:0> ) { this . buffer . append ( '<CHAR_LIT:U+0020>' ) ; for ( Iterator it = extendedOperands . iterator ( ) ; it . hasNext ( ) ; ) { this . buffer . append ( node . getOperator ( ) . toString ( ) ) . append ( '<CHAR_LIT:U+0020>' ) ; Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; } } return false ; } public boolean visit ( Initializer node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( InstanceofExpression node ) { node . getLeftOperand ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getRightOperand ( ) . accept ( this ) ; return false ; } public boolean visit ( Javadoc node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . tags ( ) . iterator ( ) ; it . hasNext ( ) ; ) { ASTNode e = ( ASTNode ) it . next ( ) ; e . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( LabeledStatement node ) { printIndent ( ) ; node . getLabel ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT::U+0020>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( LineComment node ) { this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( MarkerAnnotation node ) { this . buffer . append ( "<STR_LIT:@>" ) ; node . getTypeName ( ) . accept ( this ) ; return false ; } public boolean visit ( MemberRef node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:#>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( MemberValuePair node ) { node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:=>" ) ; node . getValue ( ) . accept ( this ) ; return false ; } public boolean visit ( MethodDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { printModifiers ( node . modifiers ( ) ) ; if ( ! node . typeParameters ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeParameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { TypeParameter t = ( TypeParameter ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } if ( ! node . isConstructor ( ) ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { getReturnType ( node ) . accept ( this ) ; } else { if ( node . getReturnType2 ( ) != null ) { node . getReturnType2 ( ) . accept ( this ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . parameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { SingleVariableDeclaration v = ( SingleVariableDeclaration ) it . next ( ) ; v . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; for ( int i = <NUM_LIT:0> ; i < node . getExtraDimensions ( ) ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( ! node . thrownExceptions ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . thrownExceptions ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Name n = ( Name ) it . next ( ) ; n . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } if ( node . getBody ( ) == null ) { this . buffer . append ( "<STR_LIT>" ) ; } else { node . getBody ( ) . accept ( this ) ; } return false ; } public boolean visit ( MethodInvocation node ) { if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( MethodRef node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:#>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . parameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { MethodRefParameter e = ( MethodRefParameter ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( MethodRefParameter node ) { node . getType ( ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( node . isVarargs ( ) ) { this . buffer . append ( "<STR_LIT:...>" ) ; } } if ( node . getName ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getName ( ) . accept ( this ) ; } return false ; } public boolean visit ( Modifier node ) { this . buffer . append ( node . getKeyword ( ) . toString ( ) ) ; return false ; } public boolean visit ( NormalAnnotation node ) { this . buffer . append ( "<STR_LIT:@>" ) ; node . getTypeName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . values ( ) . iterator ( ) ; it . hasNext ( ) ; ) { MemberValuePair p = ( MemberValuePair ) it . next ( ) ; p . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( NullLiteral node ) { this . buffer . append ( "<STR_LIT:null>" ) ; return false ; } public boolean visit ( NumberLiteral node ) { this . buffer . append ( node . getToken ( ) ) ; return false ; } public boolean visit ( PackageDeclaration node ) { if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } for ( Iterator it = node . annotations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Annotation p = ( Annotation ) it . next ( ) ; p . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ParameterizedType node ) { node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; return false ; } public boolean visit ( ParenthesizedExpression node ) { this . buffer . append ( "<STR_LIT:(>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( PostfixExpression node ) { node . getOperand ( ) . accept ( this ) ; this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; return false ; } public boolean visit ( PrefixExpression node ) { this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; node . getOperand ( ) . accept ( this ) ; return false ; } public boolean visit ( PrimitiveType node ) { this . buffer . append ( node . getPrimitiveTypeCode ( ) . toString ( ) ) ; return false ; } public boolean visit ( QualifiedName node ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( QualifiedType node ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( ReturnStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getExpression ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getExpression ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SimpleName node ) { this . buffer . append ( node . getIdentifier ( ) ) ; return false ; } public boolean visit ( SimpleType node ) { return true ; } public boolean visit ( SingleMemberAnnotation node ) { this . buffer . append ( "<STR_LIT:@>" ) ; node . getTypeName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; node . getValue ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( SingleVariableDeclaration node ) { printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( node . isVarargs ( ) ) { this . buffer . append ( "<STR_LIT:...>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getName ( ) . accept ( this ) ; for ( int i = <NUM_LIT:0> ; i < node . getExtraDimensions ( ) ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( node . getInitializer ( ) != null ) { this . buffer . append ( "<STR_LIT:=>" ) ; node . getInitializer ( ) . accept ( this ) ; } return false ; } public boolean visit ( StringLiteral node ) { this . buffer . append ( node . getEscapedValue ( ) ) ; return false ; } public boolean visit ( SuperConstructorInvocation node ) { printIndent ( ) ; if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SuperFieldAccess node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( SuperMethodInvocation node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( SwitchCase node ) { if ( node . isDefault ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; } this . indent ++ ; return false ; } public boolean visit ( SwitchStatement node ) { this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . statements ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Statement s = ( Statement ) it . next ( ) ; s . accept ( this ) ; this . indent -- ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SynchronizedStatement node ) { this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( TagElement node ) { if ( node . isNested ( ) ) { this . buffer . append ( "<STR_LIT:{>" ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; } boolean previousRequiresWhiteSpace = false ; if ( node . getTagName ( ) != null ) { this . buffer . append ( node . getTagName ( ) ) ; previousRequiresWhiteSpace = true ; } boolean previousRequiresNewLine = false ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { ASTNode e = ( ASTNode ) it . next ( ) ; boolean currentIncludesWhiteSpace = ( e instanceof TextElement ) ; if ( previousRequiresNewLine && currentIncludesWhiteSpace ) { this . buffer . append ( "<STR_LIT>" ) ; } previousRequiresNewLine = currentIncludesWhiteSpace ; if ( previousRequiresWhiteSpace && ! currentIncludesWhiteSpace ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; } e . accept ( this ) ; previousRequiresWhiteSpace = ! currentIncludesWhiteSpace && ! ( e instanceof TagElement ) ; } if ( node . isNested ( ) ) { this . buffer . append ( "<STR_LIT:}>" ) ; } return false ; } public boolean visit ( TextElement node ) { this . buffer . append ( node . getText ( ) ) ; return false ; } public boolean visit ( ThisExpression node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ThrowStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( TryStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS4 ) { List resources = node . resources ( ) ; if ( ! resources . isEmpty ( ) ) { this . buffer . append ( '<CHAR_LIT:(>' ) ; for ( Iterator it = resources . iterator ( ) ; it . hasNext ( ) ; ) { VariableDeclarationExpression variable = ( VariableDeclarationExpression ) it . next ( ) ; variable . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( '<CHAR_LIT:;>' ) ; } } this . buffer . append ( '<CHAR_LIT:)>' ) ; } } node . getBody ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . catchClauses ( ) . iterator ( ) ; it . hasNext ( ) ; ) { CatchClause cc = ( CatchClause ) it . next ( ) ; cc . accept ( this ) ; } if ( node . getFinally ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getFinally ( ) . accept ( this ) ; } return false ; } public boolean visit ( TypeDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } this . buffer . append ( node . isInterface ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( ! node . typeParameters ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeParameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { TypeParameter t = ( TypeParameter ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { if ( getSuperclass ( node ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; getSuperclass ( node ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } if ( ! superInterfaces ( node ) . isEmpty ( ) ) { this . buffer . append ( node . isInterface ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; for ( Iterator it = superInterfaces ( node ) . iterator ( ) ; it . hasNext ( ) ; ) { Name n = ( Name ) it . next ( ) ; n . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { if ( node . getSuperclassType ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getSuperclassType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } if ( ! node . superInterfaceTypes ( ) . isEmpty ( ) ) { this . buffer . append ( node . isInterface ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; for ( Iterator it = node . superInterfaceTypes ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration d = ( BodyDeclaration ) it . next ( ) ; d . accept ( this ) ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( TypeDeclarationStatement node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { getTypeDeclaration ( node ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { node . getDeclaration ( ) . accept ( this ) ; } return false ; } public boolean visit ( TypeLiteral node ) { node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.class>" ) ; return false ; } public boolean visit ( TypeParameter node ) { node . getName ( ) . accept ( this ) ; if ( ! node . typeBounds ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . typeBounds ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } } } return false ; } public boolean visit ( UnionType node ) { for ( Iterator it = node . types ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( '<CHAR_LIT>' ) ; } } return false ; } public boolean visit ( VariableDeclarationExpression node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { VariableDeclarationFragment f = ( VariableDeclarationFragment ) it . next ( ) ; f . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } return false ; } public boolean visit ( VariableDeclarationFragment node ) { node . getName ( ) . accept ( this ) ; for ( int i = <NUM_LIT:0> ; i < node . getExtraDimensions ( ) ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( node . getInitializer ( ) != null ) { this . buffer . append ( "<STR_LIT:=>" ) ; node . getInitializer ( ) . accept ( this ) ; } return false ; } public boolean visit ( VariableDeclarationStatement node ) { printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { VariableDeclarationFragment f = ( VariableDeclarationFragment ) it . next ( ) ; f . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( WhileStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( WildcardType node ) { this . buffer . append ( "<STR_LIT:?>" ) ; Type bound = node . getBound ( ) ; if ( bound != null ) { if ( node . isUpperBound ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; } bound . accept ( this ) ; } return false ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ForStatement extends Statement { public static final ChildListPropertyDescriptor INITIALIZERS_PROPERTY = new ChildListPropertyDescriptor ( ForStatement . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ForStatement . class , "<STR_LIT>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor UPDATERS_PROPERTY = new ChildListPropertyDescriptor ( ForStatement . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( ForStatement . class , "<STR_LIT:body>" , Statement . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( ForStatement . class , properyList ) ; addProperty ( INITIALIZERS_PROPERTY , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( UPDATERS_PROPERTY , properyList ) ; addProperty ( BODY_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ASTNode . NodeList initializers = new ASTNode . NodeList ( INITIALIZERS_PROPERTY ) ; private Expression optionalConditionExpression = null ; private ASTNode . NodeList updaters = new ASTNode . NodeList ( UPDATERS_PROPERTY ) ; private Statement body = null ; ForStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Statement ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == INITIALIZERS_PROPERTY ) { return initializers ( ) ; } if ( property == UPDATERS_PROPERTY ) { return updaters ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return FOR_STATEMENT ; } ASTNode clone0 ( AST target ) { ForStatement result = new ForStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . initializers ( ) . addAll ( ASTNode . copySubtrees ( target , initializers ( ) ) ) ; result . setExpression ( ( Expression ) ASTNode . copySubtree ( target , getExpression ( ) ) ) ; result . updaters ( ) . addAll ( ASTNode . copySubtrees ( target , updaters ( ) ) ) ; result . setBody ( ( Statement ) ASTNode . copySubtree ( target , getBody ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChildren ( visitor , this . initializers ) ; acceptChild ( visitor , getExpression ( ) ) ; acceptChildren ( visitor , this . updaters ) ; acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public List initializers ( ) { return this . initializers ; } public Expression getExpression ( ) { return this . optionalConditionExpression ; } public void setExpression ( Expression expression ) { ASTNode oldChild = this . optionalConditionExpression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . optionalConditionExpression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public List updaters ( ) { return this . updaters ; } public Statement getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new Block ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Statement statement ) { if ( statement == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; this . body = statement ; postReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:4> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + this . initializers . listSize ( ) + this . updaters . listSize ( ) + ( this . optionalConditionExpression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . dom . BindingResolver ; import org . eclipse . jdt . core . dom . IMethodBinding ; class DefaultValuePairBinding extends MemberValuePairBinding { private org . eclipse . jdt . internal . compiler . lookup . MethodBinding method ; DefaultValuePairBinding ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding binding , BindingResolver resolver ) { super ( null , resolver ) ; this . method = binding ; this . value = MemberValuePairBinding . buildDOMValue ( binding . getDefaultValue ( ) , resolver ) ; if ( binding . returnType != null && binding . returnType . isArrayType ( ) ) { if ( ! this . value . getClass ( ) . isArray ( ) ) { this . value = new Object [ ] { this . value } ; } } } public IMethodBinding getMethodBinding ( ) { return this . bindingResolver . getMethodBinding ( this . method ) ; } public String getName ( ) { return new String ( this . method . selector ) ; } public Object getValue ( ) { return this . value ; } public boolean isDefault ( ) { return true ; } public boolean isDeprecated ( ) { return this . method . isDeprecated ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class Assignment extends Expression { public static class Operator { private String op ; private Operator ( String op ) { this . op = op ; } public String toString ( ) { return this . op ; } public static final Operator ASSIGN = new Operator ( "<STR_LIT:=>" ) ; public static final Operator PLUS_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator MINUS_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator TIMES_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator DIVIDE_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator BIT_AND_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator BIT_OR_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator BIT_XOR_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator REMAINDER_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator LEFT_SHIFT_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator RIGHT_SHIFT_SIGNED_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static final Operator RIGHT_SHIFT_UNSIGNED_ASSIGN = new Operator ( "<STR_LIT>" ) ; public static Operator toOperator ( String token ) { return ( Operator ) CODES . get ( token ) ; } private static final Map CODES ; static { CODES = new HashMap ( <NUM_LIT:20> ) ; Operator [ ] ops = { ASSIGN , PLUS_ASSIGN , MINUS_ASSIGN , TIMES_ASSIGN , DIVIDE_ASSIGN , BIT_AND_ASSIGN , BIT_OR_ASSIGN , BIT_XOR_ASSIGN , REMAINDER_ASSIGN , LEFT_SHIFT_ASSIGN , RIGHT_SHIFT_SIGNED_ASSIGN , RIGHT_SHIFT_UNSIGNED_ASSIGN } ; for ( int i = <NUM_LIT:0> ; i < ops . length ; i ++ ) { CODES . put ( ops [ i ] . toString ( ) , ops [ i ] ) ; } } } public static final ChildPropertyDescriptor LEFT_HAND_SIDE_PROPERTY = new ChildPropertyDescriptor ( Assignment . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final SimplePropertyDescriptor OPERATOR_PROPERTY = new SimplePropertyDescriptor ( Assignment . class , "<STR_LIT>" , Assignment . Operator . class , MANDATORY ) ; public static final ChildPropertyDescriptor RIGHT_HAND_SIDE_PROPERTY = new ChildPropertyDescriptor ( Assignment . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( Assignment . class , properyList ) ; addProperty ( LEFT_HAND_SIDE_PROPERTY , properyList ) ; addProperty ( OPERATOR_PROPERTY , properyList ) ; addProperty ( RIGHT_HAND_SIDE_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Assignment . Operator assignmentOperator = Assignment . Operator . ASSIGN ; private Expression leftHandSide = null ; private Expression rightHandSide = null ; Assignment ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == OPERATOR_PROPERTY ) { if ( get ) { return getOperator ( ) ; } else { setOperator ( ( Operator ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LEFT_HAND_SIDE_PROPERTY ) { if ( get ) { return getLeftHandSide ( ) ; } else { setLeftHandSide ( ( Expression ) child ) ; return null ; } } if ( property == RIGHT_HAND_SIDE_PROPERTY ) { if ( get ) { return getRightHandSide ( ) ; } else { setRightHandSide ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return ASSIGNMENT ; } ASTNode clone0 ( AST target ) { Assignment result = new Assignment ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setOperator ( getOperator ( ) ) ; result . setLeftHandSide ( ( Expression ) getLeftHandSide ( ) . clone ( target ) ) ; result . setRightHandSide ( ( Expression ) getRightHandSide ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLeftHandSide ( ) ) ; acceptChild ( visitor , getRightHandSide ( ) ) ; } visitor . endVisit ( this ) ; } public Assignment . Operator getOperator ( ) { return this . assignmentOperator ; } public void setOperator ( Assignment . Operator assignmentOperator ) { if ( assignmentOperator == null ) { throw new IllegalArgumentException ( ) ; } preValueChange ( OPERATOR_PROPERTY ) ; this . assignmentOperator = assignmentOperator ; postValueChange ( OPERATOR_PROPERTY ) ; } public Expression getLeftHandSide ( ) { if ( this . leftHandSide == null ) { synchronized ( this ) { if ( this . leftHandSide == null ) { preLazyInit ( ) ; this . leftHandSide = new SimpleName ( this . ast ) ; postLazyInit ( this . leftHandSide , LEFT_HAND_SIDE_PROPERTY ) ; } } } return this . leftHandSide ; } public void setLeftHandSide ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . leftHandSide ; preReplaceChild ( oldChild , expression , LEFT_HAND_SIDE_PROPERTY ) ; this . leftHandSide = expression ; postReplaceChild ( oldChild , expression , LEFT_HAND_SIDE_PROPERTY ) ; } public Expression getRightHandSide ( ) { if ( this . rightHandSide == null ) { synchronized ( this ) { if ( this . rightHandSide == null ) { preLazyInit ( ) ; this . rightHandSide = new SimpleName ( this . ast ) ; postLazyInit ( this . rightHandSide , RIGHT_HAND_SIDE_PROPERTY ) ; } } } return this . rightHandSide ; } public void setRightHandSide ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . rightHandSide ; preReplaceChild ( oldChild , expression , RIGHT_HAND_SIDE_PROPERTY ) ; this . rightHandSide = expression ; postReplaceChild ( oldChild , expression , RIGHT_HAND_SIDE_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . leftHandSide == null ? <NUM_LIT:0> : getLeftHandSide ( ) . treeSize ( ) ) + ( this . rightHandSide == null ? <NUM_LIT:0> : getRightHandSide ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class InstanceofExpression extends Expression { public static final ChildPropertyDescriptor LEFT_OPERAND_PROPERTY = new ChildPropertyDescriptor ( InstanceofExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor RIGHT_OPERAND_PROPERTY = new ChildPropertyDescriptor ( InstanceofExpression . class , "<STR_LIT>" , Type . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( InstanceofExpression . class , properyList ) ; addProperty ( LEFT_OPERAND_PROPERTY , properyList ) ; addProperty ( RIGHT_OPERAND_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression leftOperand = null ; private Type rightOperand = null ; InstanceofExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LEFT_OPERAND_PROPERTY ) { if ( get ) { return getLeftOperand ( ) ; } else { setLeftOperand ( ( Expression ) child ) ; return null ; } } if ( property == RIGHT_OPERAND_PROPERTY ) { if ( get ) { return getRightOperand ( ) ; } else { setRightOperand ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return INSTANCEOF_EXPRESSION ; } ASTNode clone0 ( AST target ) { InstanceofExpression result = new InstanceofExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setLeftOperand ( ( Expression ) getLeftOperand ( ) . clone ( target ) ) ; result . setRightOperand ( ( Type ) getRightOperand ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLeftOperand ( ) ) ; acceptChild ( visitor , getRightOperand ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getLeftOperand ( ) { if ( this . leftOperand == null ) { synchronized ( this ) { if ( this . leftOperand == null ) { preLazyInit ( ) ; this . leftOperand = new SimpleName ( this . ast ) ; postLazyInit ( this . leftOperand , LEFT_OPERAND_PROPERTY ) ; } } } return this . leftOperand ; } public void setLeftOperand ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . leftOperand ; preReplaceChild ( oldChild , expression , LEFT_OPERAND_PROPERTY ) ; this . leftOperand = expression ; postReplaceChild ( oldChild , expression , LEFT_OPERAND_PROPERTY ) ; } public Type getRightOperand ( ) { if ( this . rightOperand == null ) { synchronized ( this ) { if ( this . rightOperand == null ) { preLazyInit ( ) ; this . rightOperand = new SimpleType ( this . ast ) ; postLazyInit ( this . rightOperand , RIGHT_OPERAND_PROPERTY ) ; } } } return this . rightOperand ; } public void setRightOperand ( Type referenceType ) { if ( referenceType == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . rightOperand ; preReplaceChild ( oldChild , referenceType , RIGHT_OPERAND_PROPERTY ) ; this . rightOperand = referenceType ; postReplaceChild ( oldChild , referenceType , RIGHT_OPERAND_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . leftOperand == null ? <NUM_LIT:0> : getLeftOperand ( ) . treeSize ( ) ) + ( this . rightOperand == null ? <NUM_LIT:0> : getRightOperand ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . internal . compiler . batch . FileSystem ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . core . INameEnvironmentWithProgress ; import org . eclipse . jdt . internal . core . NameLookup ; class NameEnvironmentWithProgress extends FileSystem implements INameEnvironmentWithProgress { IProgressMonitor monitor ; public NameEnvironmentWithProgress ( Classpath [ ] paths , String [ ] initialFileNames , IProgressMonitor monitor ) { super ( paths , initialFileNames ) ; setMonitor ( monitor ) ; } private void checkCanceled ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) ) { if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" ) ; } throw new AbortCompilation ( true , new OperationCanceledException ( ) ) ; } } public NameEnvironmentAnswer findType ( char [ ] typeName , char [ ] [ ] packageName ) { checkCanceled ( ) ; return super . findType ( typeName , packageName ) ; } public NameEnvironmentAnswer findType ( char [ ] [ ] compoundName ) { checkCanceled ( ) ; return super . findType ( compoundName ) ; } public boolean isPackage ( char [ ] [ ] compoundName , char [ ] packageName ) { checkCanceled ( ) ; return super . isPackage ( compoundName , packageName ) ; } public void setMonitor ( IProgressMonitor monitor ) { this . monitor = monitor ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public abstract class StructuralPropertyDescriptor { private final String propertyId ; private final Class nodeClass ; StructuralPropertyDescriptor ( Class nodeClass , String propertyId ) { if ( nodeClass == null || propertyId == null ) { throw new IllegalArgumentException ( ) ; } this . propertyId = propertyId ; this . nodeClass = nodeClass ; } public final String getId ( ) { return this . propertyId ; } public final Class getNodeClass ( ) { return this . nodeClass ; } public final boolean isSimpleProperty ( ) { return ( this instanceof SimplePropertyDescriptor ) ; } public final boolean isChildProperty ( ) { return ( this instanceof ChildPropertyDescriptor ) ; } public final boolean isChildListProperty ( ) { return ( this instanceof ChildListPropertyDescriptor ) ; } public String toString ( ) { StringBuffer b = new StringBuffer ( ) ; if ( isChildListProperty ( ) ) { b . append ( "<STR_LIT>" ) ; } if ( isChildProperty ( ) ) { b . append ( "<STR_LIT>" ) ; } if ( isSimpleProperty ( ) ) { b . append ( "<STR_LIT>" ) ; } b . append ( "<STR_LIT>" ) ; if ( this . nodeClass != null ) { b . append ( this . nodeClass . getName ( ) ) ; } b . append ( "<STR_LIT:U+002C>" ) ; if ( this . propertyId != null ) { b . append ( this . propertyId ) ; } b . append ( "<STR_LIT:]>" ) ; return b . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ArrayCreation extends Expression { public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( ArrayCreation . class , "<STR_LIT:type>" , ArrayType . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor DIMENSIONS_PROPERTY = new ChildListPropertyDescriptor ( ArrayCreation . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; public static final ChildPropertyDescriptor INITIALIZER_PROPERTY = new ChildPropertyDescriptor ( ArrayCreation . class , "<STR_LIT>" , ArrayInitializer . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( ArrayCreation . class , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( DIMENSIONS_PROPERTY , properyList ) ; addProperty ( INITIALIZER_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ArrayType arrayType = null ; private ASTNode . NodeList dimensions = new ASTNode . NodeList ( DIMENSIONS_PROPERTY ) ; private ArrayInitializer optionalInitializer = null ; ArrayCreation ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == INITIALIZER_PROPERTY ) { if ( get ) { return getInitializer ( ) ; } else { setInitializer ( ( ArrayInitializer ) child ) ; return null ; } } if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( ArrayType ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == DIMENSIONS_PROPERTY ) { return dimensions ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return ARRAY_CREATION ; } ASTNode clone0 ( AST target ) { ArrayCreation result = new ArrayCreation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setType ( ( ArrayType ) getType ( ) . clone ( target ) ) ; result . dimensions ( ) . addAll ( ASTNode . copySubtrees ( target , dimensions ( ) ) ) ; result . setInitializer ( ( ArrayInitializer ) ASTNode . copySubtree ( target , getInitializer ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getType ( ) ) ; acceptChildren ( visitor , this . dimensions ) ; acceptChild ( visitor , getInitializer ( ) ) ; } visitor . endVisit ( this ) ; } public ArrayType getType ( ) { if ( this . arrayType == null ) { synchronized ( this ) { if ( this . arrayType == null ) { preLazyInit ( ) ; this . arrayType = this . ast . newArrayType ( this . ast . newPrimitiveType ( PrimitiveType . INT ) ) ; postLazyInit ( this . arrayType , TYPE_PROPERTY ) ; } } } return this . arrayType ; } public void setType ( ArrayType type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . arrayType ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . arrayType = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public List dimensions ( ) { return this . dimensions ; } public ArrayInitializer getInitializer ( ) { return this . optionalInitializer ; } public void setInitializer ( ArrayInitializer initializer ) { ASTNode oldChild = this . optionalInitializer ; preReplaceChild ( oldChild , initializer , INITIALIZER_PROPERTY ) ; this . optionalInitializer = initializer ; postReplaceChild ( oldChild , initializer , INITIALIZER_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { int size = memSize ( ) + ( this . arrayType == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + ( this . optionalInitializer == null ? <NUM_LIT:0> : getInitializer ( ) . treeSize ( ) ) + this . dimensions . listSize ( ) ; return size ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public abstract class Expression extends ASTNode { Expression ( AST ast ) { super ( ast ) ; } public final Object resolveConstantExpressionValue ( ) { return this . ast . getBindingResolver ( ) . resolveConstantExpressionValue ( this ) ; } public final ITypeBinding resolveTypeBinding ( ) { return this . ast . getBindingResolver ( ) . resolveExpressionType ( this ) ; } public final boolean resolveBoxing ( ) { return this . ast . getBindingResolver ( ) . resolveBoxing ( this ) ; } public final boolean resolveUnboxing ( ) { return this . ast . getBindingResolver ( ) . resolveUnboxing ( this ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public interface IMethodBinding extends IBinding { public boolean isConstructor ( ) ; public boolean isDefaultConstructor ( ) ; public String getName ( ) ; public ITypeBinding getDeclaringClass ( ) ; public Object getDefaultValue ( ) ; public IAnnotationBinding [ ] getParameterAnnotations ( int paramIndex ) ; public ITypeBinding [ ] getParameterTypes ( ) ; public ITypeBinding getReturnType ( ) ; public ITypeBinding [ ] getExceptionTypes ( ) ; public ITypeBinding [ ] getTypeParameters ( ) ; public boolean isAnnotationMember ( ) ; public boolean isGenericMethod ( ) ; public boolean isParameterizedMethod ( ) ; public ITypeBinding [ ] getTypeArguments ( ) ; public IMethodBinding getMethodDeclaration ( ) ; public boolean isRawMethod ( ) ; public boolean isSubsignature ( IMethodBinding otherMethod ) ; public boolean isVarargs ( ) ; public boolean overrides ( IMethodBinding method ) ; } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class EnumDeclaration extends AbstractTypeDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( EnumDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( EnumDeclaration . class ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = internalNamePropertyFactory ( EnumDeclaration . class ) ; public static final ChildListPropertyDescriptor SUPER_INTERFACE_TYPES_PROPERTY = new ChildListPropertyDescriptor ( EnumDeclaration . class , "<STR_LIT>" , Type . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor ENUM_CONSTANTS_PROPERTY = new ChildListPropertyDescriptor ( EnumDeclaration . class , "<STR_LIT>" , EnumConstantDeclaration . class , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = internalBodyDeclarationPropertyFactory ( EnumDeclaration . class ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:6> ) ; createPropertyList ( EnumDeclaration . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS2_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( SUPER_INTERFACE_TYPES_PROPERTY , properyList ) ; addProperty ( ENUM_CONSTANTS_PROPERTY , properyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ASTNode . NodeList superInterfaceTypes = new ASTNode . NodeList ( SUPER_INTERFACE_TYPES_PROPERTY ) ; private ASTNode . NodeList enumConstants = new ASTNode . NodeList ( ENUM_CONSTANTS_PROPERTY ) ; EnumDeclaration ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == SUPER_INTERFACE_TYPES_PROPERTY ) { return superInterfaceTypes ( ) ; } if ( property == ENUM_CONSTANTS_PROPERTY ) { return enumConstants ( ) ; } if ( property == BODY_DECLARATIONS_PROPERTY ) { return bodyDeclarations ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return null ; } final ChildPropertyDescriptor internalNameProperty ( ) { return NAME_PROPERTY ; } final ChildListPropertyDescriptor internalBodyDeclarationsProperty ( ) { return BODY_DECLARATIONS_PROPERTY ; } final int getNodeType0 ( ) { return ENUM_DECLARATION ; } ASTNode clone0 ( AST target ) { EnumDeclaration result = new EnumDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . superInterfaceTypes ( ) . addAll ( ASTNode . copySubtrees ( target , superInterfaceTypes ( ) ) ) ; result . enumConstants ( ) . addAll ( ASTNode . copySubtrees ( target , enumConstants ( ) ) ) ; result . bodyDeclarations ( ) . addAll ( ASTNode . copySubtrees ( target , bodyDeclarations ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; acceptChildren ( visitor , this . modifiers ) ; acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . superInterfaceTypes ) ; acceptChildren ( visitor , this . enumConstants ) ; acceptChildren ( visitor , this . bodyDeclarations ) ; } visitor . endVisit ( this ) ; } public List superInterfaceTypes ( ) { return this . superInterfaceTypes ; } public List enumConstants ( ) { return this . enumConstants ; } ITypeBinding internalResolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveType ( this ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + this . modifiers . listSize ( ) + ( this . typeName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + this . superInterfaceTypes . listSize ( ) + this . enumConstants . listSize ( ) + this . bodyDeclarations . listSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public interface IAnnotationBinding extends IBinding { IMemberValuePairBinding [ ] getAllMemberValuePairs ( ) ; ITypeBinding getAnnotationType ( ) ; IMemberValuePairBinding [ ] getDeclaredMemberValuePairs ( ) ; public String getName ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class Block extends Statement { public static final ChildListPropertyDescriptor STATEMENTS_PROPERTY = new ChildListPropertyDescriptor ( Block . class , "<STR_LIT>" , Statement . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( Block . class , properyList ) ; addProperty ( STATEMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ASTNode . NodeList statements = new ASTNode . NodeList ( STATEMENTS_PROPERTY ) ; Block ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == STATEMENTS_PROPERTY ) { return statements ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return BLOCK ; } ASTNode clone0 ( AST target ) { Block result = new Block ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . statements ( ) . addAll ( ASTNode . copySubtrees ( target , statements ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChildren ( visitor , this . statements ) ; } visitor . endVisit ( this ) ; } public List statements ( ) { return this . statements ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + this . statements . listSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . Iterator ; import java . util . List ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . Status ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . lookup . BinaryTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . NameLookup ; import org . eclipse . jdt . internal . core . SearchableEnvironment ; class PackageBinding implements IPackageBinding { private static final String [ ] NO_NAME_COMPONENTS = CharOperation . NO_STRINGS ; private static final String UNNAMED = Util . EMPTY_STRING ; private static final char PACKAGE_NAME_SEPARATOR = '<CHAR_LIT:.>' ; private org . eclipse . jdt . internal . compiler . lookup . PackageBinding binding ; private String name ; private BindingResolver resolver ; private String [ ] components ; PackageBinding ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding binding , BindingResolver resolver ) { this . binding = binding ; this . resolver = resolver ; } public IAnnotationBinding [ ] getAnnotations ( ) { try { INameEnvironment nameEnvironment = this . binding . environment . nameEnvironment ; if ( ! ( nameEnvironment instanceof SearchableEnvironment ) ) return AnnotationBinding . NoAnnotations ; NameLookup nameLookup = ( ( SearchableEnvironment ) nameEnvironment ) . nameLookup ; if ( nameLookup == null ) return AnnotationBinding . NoAnnotations ; final String pkgName = getName ( ) ; IPackageFragment [ ] pkgs = nameLookup . findPackageFragments ( pkgName , false ) ; if ( pkgs == null ) return AnnotationBinding . NoAnnotations ; for ( int i = <NUM_LIT:0> , len = pkgs . length ; i < len ; i ++ ) { int fragType = pkgs [ i ] . getKind ( ) ; switch ( fragType ) { case IPackageFragmentRoot . K_SOURCE : String unitName = "<STR_LIT>" ; ICompilationUnit unit = pkgs [ i ] . getCompilationUnit ( unitName ) ; if ( unit != null && unit . exists ( ) ) { ASTParser p = ASTParser . newParser ( AST . JLS3_INTERNAL ) ; p . setSource ( unit ) ; p . setResolveBindings ( true ) ; p . setUnitName ( unitName ) ; p . setFocalPosition ( <NUM_LIT:0> ) ; p . setKind ( ASTParser . K_COMPILATION_UNIT ) ; CompilationUnit domUnit = ( CompilationUnit ) p . createAST ( null ) ; PackageDeclaration pkgDecl = domUnit . getPackage ( ) ; if ( pkgDecl != null ) { List annos = pkgDecl . annotations ( ) ; if ( annos == null || annos . isEmpty ( ) ) return AnnotationBinding . NoAnnotations ; IAnnotationBinding [ ] result = new IAnnotationBinding [ annos . size ( ) ] ; int index = <NUM_LIT:0> ; for ( Iterator it = annos . iterator ( ) ; it . hasNext ( ) ; index ++ ) { result [ index ] = ( ( Annotation ) it . next ( ) ) . resolveAnnotationBinding ( ) ; if ( result [ index ] == null ) return AnnotationBinding . NoAnnotations ; } return result ; } } break ; case IPackageFragmentRoot . K_BINARY : NameEnvironmentAnswer answer = nameEnvironment . findType ( TypeConstants . PACKAGE_INFO_NAME , this . binding . compoundName ) ; if ( answer != null && answer . isBinaryType ( ) ) { IBinaryType type = answer . getBinaryType ( ) ; char [ ] [ ] [ ] missingTypeNames = type . getMissingTypeNames ( ) ; IBinaryAnnotation [ ] binaryAnnotations = type . getAnnotations ( ) ; org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding [ ] binaryInstances = BinaryTypeBinding . createAnnotations ( binaryAnnotations , this . binding . environment , missingTypeNames ) ; org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding [ ] allInstances = org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding . addStandardAnnotations ( binaryInstances , type . getTagBits ( ) , this . binding . environment ) ; int total = allInstances . length ; IAnnotationBinding [ ] domInstances = new AnnotationBinding [ total ] ; for ( int a = <NUM_LIT:0> ; a < total ; a ++ ) { final IAnnotationBinding annotationInstance = this . resolver . getAnnotationInstance ( allInstances [ a ] ) ; if ( annotationInstance == null ) { return AnnotationBinding . NoAnnotations ; } domInstances [ a ] = annotationInstance ; } return domInstances ; } } } } catch ( JavaModelException e ) { return AnnotationBinding . NoAnnotations ; } return AnnotationBinding . NoAnnotations ; } public String getName ( ) { if ( this . name == null ) { computeNameAndComponents ( ) ; } return this . name ; } public boolean isUnnamed ( ) { return getName ( ) . equals ( UNNAMED ) ; } public String [ ] getNameComponents ( ) { if ( this . components == null ) { computeNameAndComponents ( ) ; } return this . components ; } public int getKind ( ) { return IBinding . PACKAGE ; } public int getModifiers ( ) { return Modifier . NONE ; } public boolean isDeprecated ( ) { return false ; } public boolean isRecovered ( ) { return false ; } public boolean isSynthetic ( ) { return false ; } public IJavaElement getJavaElement ( ) { INameEnvironment nameEnvironment = this . binding . environment . nameEnvironment ; if ( ! ( nameEnvironment instanceof SearchableEnvironment ) ) return null ; NameLookup nameLookup = ( ( SearchableEnvironment ) nameEnvironment ) . nameLookup ; if ( nameLookup == null ) return null ; IJavaElement [ ] pkgs = nameLookup . findPackageFragments ( getName ( ) , false ) ; if ( pkgs == null ) return null ; if ( pkgs . length == <NUM_LIT:0> ) { org . eclipse . jdt . internal . core . util . Util . log ( new Status ( IStatus . WARNING , JavaCore . PLUGIN_ID , "<STR_LIT>" + getName ( ) + "<STR_LIT>" ) ) ; return null ; } return pkgs [ <NUM_LIT:0> ] ; } public String getKey ( ) { return new String ( this . binding . computeUniqueKey ( ) ) ; } public boolean isEqualTo ( IBinding other ) { if ( other == this ) { return true ; } if ( other == null ) { return false ; } if ( ! ( other instanceof PackageBinding ) ) { return false ; } org . eclipse . jdt . internal . compiler . lookup . PackageBinding packageBinding2 = ( ( PackageBinding ) other ) . binding ; return CharOperation . equals ( this . binding . compoundName , packageBinding2 . compoundName ) ; } private void computeNameAndComponents ( ) { char [ ] [ ] compoundName = this . binding . compoundName ; if ( compoundName == CharOperation . NO_CHAR_CHAR || compoundName == null ) { this . name = UNNAMED ; this . components = NO_NAME_COMPONENTS ; } else { int length = compoundName . length ; this . components = new String [ length ] ; StringBuffer buffer = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { this . components [ i ] = new String ( compoundName [ i ] ) ; buffer . append ( compoundName [ i ] ) . append ( PACKAGE_NAME_SEPARATOR ) ; } this . components [ length - <NUM_LIT:1> ] = new String ( compoundName [ length - <NUM_LIT:1> ] ) ; buffer . append ( compoundName [ length - <NUM_LIT:1> ] ) ; this . name = buffer . toString ( ) ; } } public String toString ( ) { return this . binding . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class TypeParameter extends ASTNode { public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( TypeParameter . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor TYPE_BOUNDS_PROPERTY = new ChildListPropertyDescriptor ( TypeParameter . class , "<STR_LIT>" , Type . class , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( TypeParameter . class , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( TYPE_BOUNDS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName typeVariableName = null ; private ASTNode . NodeList typeBounds = new ASTNode . NodeList ( TYPE_BOUNDS_PROPERTY ) ; TypeParameter ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == TYPE_BOUNDS_PROPERTY ) { return typeBounds ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return TYPE_PARAMETER ; } ASTNode clone0 ( AST target ) { TypeParameter result = new TypeParameter ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setName ( ( SimpleName ) ( ( ASTNode ) getName ( ) ) . clone ( target ) ) ; result . typeBounds ( ) . addAll ( ASTNode . copySubtrees ( target , typeBounds ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . typeBounds ) ; } visitor . endVisit ( this ) ; } public SimpleName getName ( ) { if ( this . typeVariableName == null ) { synchronized ( this ) { if ( this . typeVariableName == null ) { preLazyInit ( ) ; this . typeVariableName = new SimpleName ( this . ast ) ; postLazyInit ( this . typeVariableName , NAME_PROPERTY ) ; } } } return this . typeVariableName ; } public final ITypeBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveTypeParameter ( this ) ; } public void setName ( SimpleName typeName ) { if ( typeName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . typeVariableName ; preReplaceChild ( oldChild , typeName , NAME_PROPERTY ) ; this . typeVariableName = typeName ; postReplaceChild ( oldChild , typeName , NAME_PROPERTY ) ; } public List typeBounds ( ) { return this . typeBounds ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeVariableName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + this . typeBounds . listSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class MemberValuePair extends ASTNode { public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( MemberValuePair . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor VALUE_PROPERTY = new ChildPropertyDescriptor ( MemberValuePair . class , "<STR_LIT:value>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( MemberValuePair . class , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( VALUE_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName name = null ; private Expression value = null ; MemberValuePair ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == VALUE_PROPERTY ) { if ( get ) { return getValue ( ) ; } else { setValue ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return MEMBER_VALUE_PAIR ; } ASTNode clone0 ( AST target ) { MemberValuePair result = new MemberValuePair ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setName ( ( SimpleName ) ASTNode . copySubtree ( target , getName ( ) ) ) ; result . setValue ( ( Expression ) ASTNode . copySubtree ( target , getValue ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getName ( ) ) ; acceptChild ( visitor , getValue ( ) ) ; } visitor . endVisit ( this ) ; } public SimpleName getName ( ) { if ( this . name == null ) { synchronized ( this ) { if ( this . name == null ) { preLazyInit ( ) ; this . name = new SimpleName ( this . ast ) ; postLazyInit ( this . name , NAME_PROPERTY ) ; } } } return this . name ; } public final IMemberValuePairBinding resolveMemberValuePairBinding ( ) { return this . ast . getBindingResolver ( ) . resolveMemberValuePair ( this ) ; } public void setName ( SimpleName name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . name ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . name = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } public Expression getValue ( ) { if ( this . value == null ) { synchronized ( this ) { if ( this . value == null ) { preLazyInit ( ) ; this . value = new SimpleName ( this . ast ) ; postLazyInit ( this . value , VALUE_PROPERTY ) ; } } } return this . value ; } public void setValue ( Expression value ) { if ( value == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . value ; preReplaceChild ( oldChild , value , VALUE_PROPERTY ) ; this . value = value ; postReplaceChild ( oldChild , value , VALUE_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . name == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . value == null ? <NUM_LIT:0> : getValue ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . ICompilationUnit ; public abstract class ASTRequestor { CompilationUnitResolver compilationUnitResolver = null ; protected ASTRequestor ( ) { } public void acceptAST ( ICompilationUnit source , CompilationUnit ast ) { } public void acceptBinding ( String bindingKey , IBinding binding ) { } public final IBinding [ ] createBindings ( String [ ] bindingKeys ) { int length = bindingKeys . length ; IBinding [ ] result = new IBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { result [ i ] = null ; if ( this . compilationUnitResolver != null ) { result [ i ] = this . compilationUnitResolver . createBinding ( bindingKeys [ i ] ) ; } } return result ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public final class NormalAnnotation extends Annotation { public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY = internalTypeNamePropertyFactory ( NormalAnnotation . class ) ; public static final ChildListPropertyDescriptor VALUES_PROPERTY = new ChildListPropertyDescriptor ( NormalAnnotation . class , "<STR_LIT>" , MemberValuePair . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( NormalAnnotation . class , propertyList ) ; addProperty ( TYPE_NAME_PROPERTY , propertyList ) ; addProperty ( VALUES_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ASTNode . NodeList values = new ASTNode . NodeList ( VALUES_PROPERTY ) ; NormalAnnotation ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_NAME_PROPERTY ) { if ( get ) { return getTypeName ( ) ; } else { setTypeName ( ( Name ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == VALUES_PROPERTY ) { return values ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalTypeNameProperty ( ) { return TYPE_NAME_PROPERTY ; } final int getNodeType0 ( ) { return NORMAL_ANNOTATION ; } ASTNode clone0 ( AST target ) { NormalAnnotation result = new NormalAnnotation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setTypeName ( ( Name ) ASTNode . copySubtree ( target , getTypeName ( ) ) ) ; result . values ( ) . addAll ( ASTNode . copySubtrees ( target , values ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getTypeName ( ) ) ; acceptChildren ( visitor , this . values ) ; } visitor . endVisit ( this ) ; } public List values ( ) { return this . values ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeName == null ? <NUM_LIT:0> : getTypeName ( ) . treeSize ( ) ) + this . values . listSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class AssertStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( AssertStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor MESSAGE_PROPERTY = new ChildPropertyDescriptor ( AssertStatement . class , "<STR_LIT:message>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( AssertStatement . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( MESSAGE_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; private Expression optionalMessageExpression = null ; AssertStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == MESSAGE_PROPERTY ) { if ( get ) { return getMessage ( ) ; } else { setMessage ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return ASSERT_STATEMENT ; } ASTNode clone0 ( AST target ) { AssertStatement result = new AssertStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) ASTNode . copySubtree ( target , getExpression ( ) ) ) ; result . setMessage ( ( Expression ) ASTNode . copySubtree ( target , getMessage ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; acceptChild ( visitor , getMessage ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public Expression getMessage ( ) { return this . optionalMessageExpression ; } public void setMessage ( Expression expression ) { ASTNode oldChild = this . optionalMessageExpression ; preReplaceChild ( oldChild , expression , MESSAGE_PROPERTY ) ; this . optionalMessageExpression = expression ; postReplaceChild ( oldChild , expression , MESSAGE_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . optionalMessageExpression == null ? <NUM_LIT:0> : getMessage ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public interface IExtendedModifier { public boolean isModifier ( ) ; public boolean isAnnotation ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . List ; import java . util . Map ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . ITypeRoot ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jface . text . IDocument ; import org . eclipse . text . edits . TextEdit ; public class CompilationUnit extends ASTNode { private static final Message [ ] EMPTY_MESSAGES = new Message [ <NUM_LIT:0> ] ; private static final IProblem [ ] EMPTY_PROBLEMS = new IProblem [ <NUM_LIT:0> ] ; public static final ChildListPropertyDescriptor IMPORTS_PROPERTY = new ChildListPropertyDescriptor ( CompilationUnit . class , "<STR_LIT>" , ImportDeclaration . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor PACKAGE_PROPERTY = new ChildPropertyDescriptor ( CompilationUnit . class , "<STR_LIT>" , PackageDeclaration . class , OPTIONAL , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; public static final ChildListPropertyDescriptor TYPES_PROPERTY = new ChildListPropertyDescriptor ( CompilationUnit . class , "<STR_LIT>" , AbstractTypeDeclaration . class , CYCLE_RISK ) ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( CompilationUnit . class , properyList ) ; addProperty ( PACKAGE_PROPERTY , properyList ) ; addProperty ( IMPORTS_PROPERTY , properyList ) ; addProperty ( TYPES_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private DefaultCommentMapper commentMapper = null ; private ITypeRoot typeRoot = null ; private ASTNode . NodeList imports = new ASTNode . NodeList ( IMPORTS_PROPERTY ) ; private int [ ] lineEndTable = Util . EMPTY_INT_ARRAY ; private Message [ ] messages ; private List optionalCommentList = null ; Comment [ ] optionalCommentTable = null ; private PackageDeclaration optionalPackageDeclaration = null ; private IProblem [ ] problems = EMPTY_PROBLEMS ; private Object statementsRecoveryData ; private ASTNode . NodeList types = new ASTNode . NodeList ( TYPES_PROPERTY ) ; protected CompilationUnit ( AST ast ) { super ( ast ) ; } protected void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getPackage ( ) ) ; acceptChildren ( visitor , this . imports ) ; acceptChildren ( visitor , this . types ) ; } visitor . endVisit ( this ) ; } ASTNode clone0 ( AST target ) { CompilationUnit result = new CompilationUnit ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setPackage ( ( PackageDeclaration ) ASTNode . copySubtree ( target , getPackage ( ) ) ) ; result . imports ( ) . addAll ( ASTNode . copySubtrees ( target , imports ( ) ) ) ; result . types ( ) . addAll ( ASTNode . copySubtrees ( target , types ( ) ) ) ; return result ; } public int getColumnNumber ( final int position ) { if ( this . lineEndTable == null ) return - <NUM_LIT:2> ; final int line = getLineNumber ( position ) ; if ( line == - <NUM_LIT:1> ) { return - <NUM_LIT:1> ; } if ( line == <NUM_LIT:1> ) { if ( position >= getStartPosition ( ) + getLength ( ) ) return - <NUM_LIT:1> ; return position ; } int length = this . lineEndTable . length ; final int previousLineOffset = this . lineEndTable [ line - <NUM_LIT:2> ] ; final int offsetForLine = previousLineOffset + <NUM_LIT:1> ; final int currentLineEnd = line == length + <NUM_LIT:1> ? getStartPosition ( ) + getLength ( ) - <NUM_LIT:1> : this . lineEndTable [ line - <NUM_LIT:1> ] ; if ( offsetForLine > currentLineEnd ) { return - <NUM_LIT:1> ; } else { return position - offsetForLine ; } } public ASTNode findDeclaringNode ( IBinding binding ) { return this . ast . getBindingResolver ( ) . findDeclaringNode ( binding ) ; } public ASTNode findDeclaringNode ( String key ) { return this . ast . getBindingResolver ( ) . findDeclaringNode ( key ) ; } public List getCommentList ( ) { return this . optionalCommentList ; } DefaultCommentMapper getCommentMapper ( ) { return this . commentMapper ; } public int getExtendedLength ( ASTNode node ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } if ( this . commentMapper == null || node . getAST ( ) != getAST ( ) ) { return node . getLength ( ) ; } else { return this . commentMapper . getExtendedLength ( node ) ; } } public int getExtendedStartPosition ( ASTNode node ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } if ( this . commentMapper == null || node . getAST ( ) != getAST ( ) ) { return node . getStartPosition ( ) ; } else { return this . commentMapper . getExtendedStartPosition ( node ) ; } } public IJavaElement getJavaElement ( ) { return this . typeRoot ; } public Message [ ] getMessages ( ) { if ( this . messages == null ) { int problemLength = this . problems . length ; if ( problemLength == <NUM_LIT:0> ) { this . messages = EMPTY_MESSAGES ; } else { this . messages = new Message [ problemLength ] ; for ( int i = <NUM_LIT:0> ; i < problemLength ; i ++ ) { IProblem problem = this . problems [ i ] ; int start = problem . getSourceStart ( ) ; int end = problem . getSourceEnd ( ) ; this . messages [ i ] = new Message ( problem . getMessage ( ) , start , end - start + <NUM_LIT:1> ) ; } } } return this . messages ; } final int getNodeType0 ( ) { return COMPILATION_UNIT ; } public PackageDeclaration getPackage ( ) { return this . optionalPackageDeclaration ; } public int getPosition ( int line , int column ) { if ( this . lineEndTable == null ) return - <NUM_LIT:2> ; if ( line < <NUM_LIT:1> || column < <NUM_LIT:0> ) return - <NUM_LIT:1> ; int length ; if ( ( length = this . lineEndTable . length ) == <NUM_LIT:0> ) { if ( line != <NUM_LIT:1> ) return - <NUM_LIT:1> ; return column >= getStartPosition ( ) + getLength ( ) ? - <NUM_LIT:1> : column ; } if ( line == <NUM_LIT:1> ) { final int endOfLine = this . lineEndTable [ <NUM_LIT:0> ] ; return column > endOfLine ? - <NUM_LIT:1> : column ; } else if ( line > length + <NUM_LIT:1> ) { return - <NUM_LIT:1> ; } final int previousLineOffset = this . lineEndTable [ line - <NUM_LIT:2> ] ; final int offsetForLine = previousLineOffset + <NUM_LIT:1> ; final int currentLineEnd = line == length + <NUM_LIT:1> ? getStartPosition ( ) + getLength ( ) - <NUM_LIT:1> : this . lineEndTable [ line - <NUM_LIT:1> ] ; if ( ( offsetForLine + column ) > currentLineEnd ) { return - <NUM_LIT:1> ; } else { return offsetForLine + column ; } } public IProblem [ ] getProblems ( ) { return this . problems ; } public Object getStatementsRecoveryData ( ) { return this . statementsRecoveryData ; } public ITypeRoot getTypeRoot ( ) { return this . typeRoot ; } public List imports ( ) { return this . imports ; } public int firstLeadingCommentIndex ( ASTNode node ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } if ( this . commentMapper == null || node . getAST ( ) != getAST ( ) ) { return - <NUM_LIT:1> ; } return this . commentMapper . firstLeadingCommentIndex ( node ) ; } public int lastTrailingCommentIndex ( ASTNode node ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } if ( this . commentMapper == null || node . getAST ( ) != getAST ( ) ) { return - <NUM_LIT:1> ; } return this . commentMapper . lastTrailingCommentIndex ( node ) ; } void initCommentMapper ( Scanner scanner ) { this . commentMapper = new DefaultCommentMapper ( this . optionalCommentTable ) ; this . commentMapper . initialize ( this , scanner ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == IMPORTS_PROPERTY ) { return imports ( ) ; } if ( property == TYPES_PROPERTY ) { return types ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == PACKAGE_PROPERTY ) { if ( get ) { return getPackage ( ) ; } else { setPackage ( ( PackageDeclaration ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } public int lineNumber ( int position ) { int lineNumber = getLineNumber ( position ) ; return lineNumber < <NUM_LIT:1> ? <NUM_LIT:1> : lineNumber ; } public int getLineNumber ( int position ) { if ( this . lineEndTable == null ) return - <NUM_LIT:2> ; int length ; if ( ( length = this . lineEndTable . length ) == <NUM_LIT:0> ) { if ( position >= getStartPosition ( ) + getLength ( ) ) { return - <NUM_LIT:1> ; } return <NUM_LIT:1> ; } int low = <NUM_LIT:0> ; if ( position < <NUM_LIT:0> ) { return - <NUM_LIT:1> ; } if ( position <= this . lineEndTable [ low ] ) { return <NUM_LIT:1> ; } int hi = length - <NUM_LIT:1> ; if ( position > this . lineEndTable [ hi ] ) { if ( position >= getStartPosition ( ) + getLength ( ) ) { return - <NUM_LIT:1> ; } else { return length + <NUM_LIT:1> ; } } while ( true ) { if ( low + <NUM_LIT:1> == hi ) { return low + <NUM_LIT:2> ; } int mid = low + ( hi - low ) / <NUM_LIT:2> ; if ( position <= this . lineEndTable [ mid ] ) { hi = mid ; } else { low = mid ; } } } int memSize ( ) { int size = BASE_NODE_SIZE + <NUM_LIT:8> * <NUM_LIT:4> ; if ( this . lineEndTable != null ) { size += HEADERS + <NUM_LIT:4> * this . lineEndTable . length ; } if ( this . optionalCommentTable != null ) { size += HEADERS + <NUM_LIT:4> * this . optionalCommentTable . length ; } return size ; } public void recordModifications ( ) { getAST ( ) . recordModifications ( this ) ; } public TextEdit rewrite ( IDocument document , Map options ) { return getAST ( ) . rewrite ( document , options ) ; } void setCommentTable ( Comment [ ] commentTable ) { if ( commentTable == null ) { this . optionalCommentList = null ; this . optionalCommentTable = null ; } else { int nextAvailablePosition = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < commentTable . length ; i ++ ) { Comment comment = commentTable [ i ] ; if ( comment == null ) { throw new IllegalArgumentException ( ) ; } int start = comment . getStartPosition ( ) ; int length = comment . getLength ( ) ; if ( start < <NUM_LIT:0> || length < <NUM_LIT:0> || start < nextAvailablePosition ) { throw new IllegalArgumentException ( ) ; } nextAvailablePosition = comment . getStartPosition ( ) + comment . getLength ( ) ; } this . optionalCommentTable = commentTable ; List commentList = Arrays . asList ( commentTable ) ; this . optionalCommentList = Collections . unmodifiableList ( commentList ) ; } } void setTypeRoot ( ITypeRoot typeRoot ) { this . typeRoot = typeRoot ; } void setLineEndTable ( int [ ] lineEndTable ) { if ( lineEndTable == null ) { throw new NullPointerException ( ) ; } checkModifiable ( ) ; this . lineEndTable = lineEndTable ; } public void setPackage ( PackageDeclaration pkgDecl ) { ASTNode oldChild = this . optionalPackageDeclaration ; preReplaceChild ( oldChild , pkgDecl , PACKAGE_PROPERTY ) ; this . optionalPackageDeclaration = pkgDecl ; postReplaceChild ( oldChild , pkgDecl , PACKAGE_PROPERTY ) ; } void setProblems ( IProblem [ ] problems ) { if ( problems == null ) { throw new IllegalArgumentException ( ) ; } this . problems = problems ; } void setStatementsRecoveryData ( Object data ) { this . statementsRecoveryData = data ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } int treeSize ( ) { int size = memSize ( ) ; if ( this . optionalPackageDeclaration != null ) { size += getPackage ( ) . treeSize ( ) ; } size += this . imports . listSize ( ) ; size += this . types . listSize ( ) ; if ( this . optionalCommentList != null ) { for ( int i = <NUM_LIT:0> ; i < this . optionalCommentList . size ( ) ; i ++ ) { Comment comment = ( Comment ) this . optionalCommentList . get ( i ) ; if ( comment != null && comment . getParent ( ) == null ) { size += comment . treeSize ( ) ; } } } return size ; } public List types ( ) { return this . types ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . CompilationUnitScope ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; class NodeSearcher extends ASTVisitor { public org . eclipse . jdt . internal . compiler . ast . ASTNode found ; public TypeDeclaration enclosingType ; public int position ; NodeSearcher ( int position ) { this . position = position ; } public boolean visit ( ConstructorDeclaration constructorDeclaration , ClassScope scope ) { if ( constructorDeclaration . declarationSourceStart <= this . position && this . position <= constructorDeclaration . declarationSourceEnd ) { this . found = constructorDeclaration ; return false ; } return true ; } public boolean visit ( FieldDeclaration fieldDeclaration , MethodScope scope ) { if ( fieldDeclaration . declarationSourceStart <= this . position && this . position <= fieldDeclaration . declarationSourceEnd ) { this . found = fieldDeclaration ; return false ; } return true ; } public boolean visit ( Initializer initializer , MethodScope scope ) { if ( initializer . declarationSourceStart <= this . position && this . position <= initializer . declarationSourceEnd ) { this . found = initializer ; return false ; } return true ; } public boolean visit ( TypeDeclaration memberTypeDeclaration , ClassScope scope ) { if ( memberTypeDeclaration . declarationSourceStart <= this . position && this . position <= memberTypeDeclaration . declarationSourceEnd ) { this . enclosingType = memberTypeDeclaration ; return true ; } return false ; } public boolean visit ( MethodDeclaration methodDeclaration , ClassScope scope ) { if ( methodDeclaration . declarationSourceStart <= this . position && this . position <= methodDeclaration . declarationSourceEnd ) { this . found = methodDeclaration ; return false ; } return true ; } public boolean visit ( TypeDeclaration typeDeclaration , CompilationUnitScope scope ) { if ( typeDeclaration . declarationSourceStart <= this . position && this . position <= typeDeclaration . declarationSourceEnd ) { this . enclosingType = typeDeclaration ; return true ; } return false ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ConditionalExpression extends Expression { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ConditionalExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor THEN_EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ConditionalExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor ELSE_EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ConditionalExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( ConditionalExpression . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( THEN_EXPRESSION_PROPERTY , properyList ) ; addProperty ( ELSE_EXPRESSION_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression conditionExpression = null ; private Expression thenExpression = null ; private Expression elseExpression = null ; ConditionalExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == THEN_EXPRESSION_PROPERTY ) { if ( get ) { return getThenExpression ( ) ; } else { setThenExpression ( ( Expression ) child ) ; return null ; } } if ( property == ELSE_EXPRESSION_PROPERTY ) { if ( get ) { return getElseExpression ( ) ; } else { setElseExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return CONDITIONAL_EXPRESSION ; } ASTNode clone0 ( AST target ) { ConditionalExpression result = new ConditionalExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . setThenExpression ( ( Expression ) getThenExpression ( ) . clone ( target ) ) ; result . setElseExpression ( ( Expression ) getElseExpression ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; acceptChild ( visitor , getThenExpression ( ) ) ; acceptChild ( visitor , getElseExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . conditionExpression == null ) { synchronized ( this ) { if ( this . conditionExpression == null ) { preLazyInit ( ) ; this . conditionExpression = new SimpleName ( this . ast ) ; postLazyInit ( this . conditionExpression , EXPRESSION_PROPERTY ) ; } } } return this . conditionExpression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . conditionExpression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . conditionExpression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public Expression getThenExpression ( ) { if ( this . thenExpression == null ) { synchronized ( this ) { if ( this . thenExpression == null ) { preLazyInit ( ) ; this . thenExpression = new SimpleName ( this . ast ) ; postLazyInit ( this . thenExpression , THEN_EXPRESSION_PROPERTY ) ; } } } return this . thenExpression ; } public void setThenExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . thenExpression ; preReplaceChild ( oldChild , expression , THEN_EXPRESSION_PROPERTY ) ; this . thenExpression = expression ; postReplaceChild ( oldChild , expression , THEN_EXPRESSION_PROPERTY ) ; } public Expression getElseExpression ( ) { if ( this . elseExpression == null ) { synchronized ( this ) { if ( this . elseExpression == null ) { preLazyInit ( ) ; this . elseExpression = new SimpleName ( this . ast ) ; postLazyInit ( this . elseExpression , ELSE_EXPRESSION_PROPERTY ) ; } } } return this . elseExpression ; } public void setElseExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . elseExpression ; preReplaceChild ( oldChild , expression , ELSE_EXPRESSION_PROPERTY ) ; this . elseExpression = expression ; postReplaceChild ( oldChild , expression , ELSE_EXPRESSION_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . conditionExpression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . thenExpression == null ? <NUM_LIT:0> : getThenExpression ( ) . treeSize ( ) ) + ( this . elseExpression == null ? <NUM_LIT:0> : getElseExpression ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public abstract class Type extends ASTNode { Type ( AST ast ) { super ( ast ) ; } public final boolean isPrimitiveType ( ) { return ( this instanceof PrimitiveType ) ; } public final boolean isSimpleType ( ) { return ( this instanceof SimpleType ) ; } public final boolean isArrayType ( ) { return ( this instanceof ArrayType ) ; } public final boolean isParameterizedType ( ) { return ( this instanceof ParameterizedType ) ; } public final boolean isQualifiedType ( ) { return ( this instanceof QualifiedType ) ; } public final boolean isUnionType ( ) { return ( this instanceof UnionType ) ; } public final boolean isWildcardType ( ) { return ( this instanceof WildcardType ) ; } public final ITypeBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveType ( this ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class MemberRef extends ASTNode implements IDocElement { public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = new ChildPropertyDescriptor ( MemberRef . class , "<STR_LIT>" , Name . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( MemberRef . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( MemberRef . class , propertyList ) ; addProperty ( QUALIFIER_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Name optionalQualifier = null ; private SimpleName memberName = null ; MemberRef ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == QUALIFIER_PROPERTY ) { if ( get ) { return getQualifier ( ) ; } else { setQualifier ( ( Name ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return MEMBER_REF ; } ASTNode clone0 ( AST target ) { MemberRef result = new MemberRef ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setQualifier ( ( Name ) ASTNode . copySubtree ( target , getQualifier ( ) ) ) ; result . setName ( ( SimpleName ) ASTNode . copySubtree ( target , getName ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getQualifier ( ) ) ; acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Name getQualifier ( ) { return this . optionalQualifier ; } public void setQualifier ( Name name ) { ASTNode oldChild = this . optionalQualifier ; preReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; this . optionalQualifier = name ; postReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; } public SimpleName getName ( ) { if ( this . memberName == null ) { synchronized ( this ) { if ( this . memberName == null ) { preLazyInit ( ) ; this . memberName = new SimpleName ( this . ast ) ; postLazyInit ( this . memberName , NAME_PROPERTY ) ; } } } return this . memberName ; } public void setName ( SimpleName name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . memberName ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . memberName = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } public final IBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveReference ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalQualifier == null ? <NUM_LIT:0> : getQualifier ( ) . treeSize ( ) ) + ( this . memberName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . StringLiteral ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . ArrayBinding ; import org . eclipse . jdt . internal . compiler . lookup . BaseTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . CaptureBinding ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . LocalTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . PackageBinding ; import org . eclipse . jdt . internal . compiler . lookup . ParameterizedTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . RawTypeBinding ; 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 . TypeConstants ; import org . eclipse . jdt . internal . compiler . lookup . TypeVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . WildcardBinding ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . PackageFragment ; class TypeBinding implements ITypeBinding { private static final StringLiteral EXPRESSION = new org . eclipse . jdt . internal . compiler . ast . StringLiteral ( <NUM_LIT:0> , <NUM_LIT:0> ) ; protected static final IMethodBinding [ ] NO_METHOD_BINDINGS = new IMethodBinding [ <NUM_LIT:0> ] ; private static final String NO_NAME = "<STR_LIT>" ; protected static final ITypeBinding [ ] NO_TYPE_BINDINGS = new ITypeBinding [ <NUM_LIT:0> ] ; protected static final IVariableBinding [ ] NO_VARIABLE_BINDINGS = new IVariableBinding [ <NUM_LIT:0> ] ; private static final int VALID_MODIFIERS = Modifier . PUBLIC | Modifier . PROTECTED | Modifier . PRIVATE | Modifier . ABSTRACT | Modifier . STATIC | Modifier . FINAL | Modifier . STRICTFP ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding ; private String key ; private BindingResolver resolver ; private IVariableBinding [ ] fields ; private IAnnotationBinding [ ] annotations ; private IMethodBinding [ ] methods ; private ITypeBinding [ ] members ; private ITypeBinding [ ] interfaces ; private ITypeBinding [ ] typeArguments ; private ITypeBinding [ ] bounds ; private ITypeBinding [ ] typeParameters ; public TypeBinding ( BindingResolver resolver , org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding ) { this . binding = binding ; this . resolver = resolver ; } public ITypeBinding createArrayType ( int dimension ) { int realDimensions = dimension ; realDimensions += getDimensions ( ) ; if ( realDimensions < <NUM_LIT:1> || realDimensions > <NUM_LIT:255> ) { throw new IllegalArgumentException ( ) ; } return this . resolver . resolveArrayType ( this , dimension ) ; } public IAnnotationBinding [ ] getAnnotations ( ) { if ( this . annotations != null ) { return this . annotations ; } org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding refType = null ; if ( this . binding instanceof ParameterizedTypeBinding ) { refType = ( ( ParameterizedTypeBinding ) this . binding ) . genericType ( ) ; } else if ( this . binding . isAnnotationType ( ) || this . binding . isClass ( ) || this . binding . isEnum ( ) || this . binding . isInterface ( ) ) { refType = ( org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ) this . binding ; } if ( refType != null ) { org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding [ ] internalAnnotations = refType . getAnnotations ( ) ; int length = internalAnnotations == null ? <NUM_LIT:0> : internalAnnotations . length ; if ( length != <NUM_LIT:0> ) { IAnnotationBinding [ ] tempAnnotations = new IAnnotationBinding [ length ] ; int convertedAnnotationCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding internalAnnotation = internalAnnotations [ i ] ; IAnnotationBinding annotationInstance = this . resolver . getAnnotationInstance ( internalAnnotation ) ; if ( annotationInstance == null ) { continue ; } tempAnnotations [ convertedAnnotationCount ++ ] = annotationInstance ; } if ( convertedAnnotationCount != length ) { if ( convertedAnnotationCount == <NUM_LIT:0> ) { return this . annotations = AnnotationBinding . NoAnnotations ; } System . arraycopy ( tempAnnotations , <NUM_LIT:0> , ( tempAnnotations = new IAnnotationBinding [ convertedAnnotationCount ] ) , <NUM_LIT:0> , convertedAnnotationCount ) ; } return this . annotations = tempAnnotations ; } } return this . annotations = AnnotationBinding . NoAnnotations ; } public String getBinaryName ( ) { if ( this . binding . isCapture ( ) ) { return null ; } else if ( this . binding . isTypeVariable ( ) ) { TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) this . binding ; org . eclipse . jdt . internal . compiler . lookup . Binding declaring = typeVariableBinding . declaringElement ; StringBuffer binaryName = new StringBuffer ( ) ; switch ( declaring . kind ( ) ) { case org . eclipse . jdt . internal . compiler . lookup . Binding . METHOD : MethodBinding methodBinding = ( MethodBinding ) declaring ; char [ ] constantPoolName = methodBinding . declaringClass . constantPoolName ( ) ; if ( constantPoolName == null ) return null ; binaryName . append ( CharOperation . replaceOnCopy ( constantPoolName , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) . append ( '<CHAR_LIT>' ) . append ( methodBinding . signature ( ) ) . append ( '<CHAR_LIT>' ) . append ( typeVariableBinding . sourceName ) ; break ; default : org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding = ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) declaring ; constantPoolName = typeBinding . constantPoolName ( ) ; if ( constantPoolName == null ) return null ; binaryName . append ( CharOperation . replaceOnCopy ( constantPoolName , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) . append ( '<CHAR_LIT>' ) . append ( typeVariableBinding . sourceName ) ; } return String . valueOf ( binaryName ) ; } char [ ] constantPoolName = this . binding . constantPoolName ( ) ; if ( constantPoolName == null ) return null ; char [ ] dotSeparated = CharOperation . replaceOnCopy ( constantPoolName , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; return new String ( dotSeparated ) ; } public ITypeBinding getBound ( ) { switch ( this . binding . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : WildcardBinding wildcardBinding = ( WildcardBinding ) this . binding ; if ( wildcardBinding . bound != null ) { return this . resolver . getTypeBinding ( wildcardBinding . bound ) ; } break ; } return null ; } public ITypeBinding getGenericTypeOfWildcardType ( ) { switch ( this . binding . kind ( ) ) { case Binding . WILDCARD_TYPE : WildcardBinding wildcardBinding = ( WildcardBinding ) this . binding ; if ( wildcardBinding . genericType != null ) { return this . resolver . getTypeBinding ( wildcardBinding . genericType ) ; } break ; } return null ; } public int getRank ( ) { switch ( this . binding . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : WildcardBinding wildcardBinding = ( WildcardBinding ) this . binding ; return wildcardBinding . rank ; default : return - <NUM_LIT:1> ; } } public ITypeBinding getComponentType ( ) { if ( ! isArray ( ) ) { return null ; } ArrayBinding arrayBinding = ( ArrayBinding ) this . binding ; return this . resolver . getTypeBinding ( arrayBinding . elementsType ( ) ) ; } public synchronized IVariableBinding [ ] getDeclaredFields ( ) { if ( this . fields != null ) { return this . fields ; } try { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; FieldBinding [ ] fieldBindings = referenceBinding . availableFields ( ) ; int length = fieldBindings . length ; if ( length != <NUM_LIT:0> ) { int convertedFieldCount = <NUM_LIT:0> ; IVariableBinding [ ] newFields = new IVariableBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { FieldBinding fieldBinding = fieldBindings [ i ] ; IVariableBinding variableBinding = this . resolver . getVariableBinding ( fieldBinding ) ; if ( variableBinding != null ) { newFields [ convertedFieldCount ++ ] = variableBinding ; } } if ( convertedFieldCount != length ) { if ( convertedFieldCount == <NUM_LIT:0> ) { return this . fields = NO_VARIABLE_BINDINGS ; } System . arraycopy ( newFields , <NUM_LIT:0> , ( newFields = new IVariableBinding [ convertedFieldCount ] ) , <NUM_LIT:0> , convertedFieldCount ) ; } return this . fields = newFields ; } } } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } return this . fields = NO_VARIABLE_BINDINGS ; } public synchronized IMethodBinding [ ] getDeclaredMethods ( ) { if ( this . methods != null ) { return this . methods ; } try { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; org . eclipse . jdt . internal . compiler . lookup . MethodBinding [ ] internalMethods = referenceBinding . availableMethods ( ) ; int length = internalMethods . length ; if ( length != <NUM_LIT:0> ) { int convertedMethodCount = <NUM_LIT:0> ; IMethodBinding [ ] newMethods = new IMethodBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding = internalMethods [ i ] ; if ( methodBinding . isDefaultAbstract ( ) || methodBinding . isSynthetic ( ) || ( methodBinding . isConstructor ( ) && isInterface ( ) ) ) { continue ; } IMethodBinding methodBinding2 = this . resolver . getMethodBinding ( methodBinding ) ; if ( methodBinding2 != null ) { newMethods [ convertedMethodCount ++ ] = methodBinding2 ; } } if ( convertedMethodCount != length ) { if ( convertedMethodCount == <NUM_LIT:0> ) { return this . methods = NO_METHOD_BINDINGS ; } System . arraycopy ( newMethods , <NUM_LIT:0> , ( newMethods = new IMethodBinding [ convertedMethodCount ] ) , <NUM_LIT:0> , convertedMethodCount ) ; } return this . methods = newMethods ; } } } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } return this . methods = NO_METHOD_BINDINGS ; } public int getDeclaredModifiers ( ) { return getModifiers ( ) ; } public synchronized ITypeBinding [ ] getDeclaredTypes ( ) { if ( this . members != null ) { return this . members ; } try { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; ReferenceBinding [ ] internalMembers = referenceBinding . memberTypes ( ) ; int length = internalMembers . length ; if ( length != <NUM_LIT:0> ) { ITypeBinding [ ] newMembers = new ITypeBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ITypeBinding typeBinding = this . resolver . getTypeBinding ( internalMembers [ i ] ) ; if ( typeBinding == null ) { return this . members = NO_TYPE_BINDINGS ; } newMembers [ i ] = typeBinding ; } return this . members = newMembers ; } } } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } return this . members = NO_TYPE_BINDINGS ; } public synchronized IMethodBinding getDeclaringMethod ( ) { if ( this . binding instanceof LocalTypeBinding ) { LocalTypeBinding localTypeBinding = ( LocalTypeBinding ) this . binding ; MethodBinding methodBinding = localTypeBinding . enclosingMethod ; if ( methodBinding != null ) { try { return this . resolver . getMethodBinding ( localTypeBinding . enclosingMethod ) ; } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } } } else if ( this . binding . isTypeVariable ( ) ) { TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) this . binding ; Binding declaringElement = typeVariableBinding . declaringElement ; if ( declaringElement instanceof MethodBinding ) { try { return this . resolver . getMethodBinding ( ( MethodBinding ) declaringElement ) ; } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } } } return null ; } public synchronized ITypeBinding getDeclaringClass ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; if ( referenceBinding . isNestedType ( ) ) { try { return this . resolver . getTypeBinding ( referenceBinding . enclosingType ( ) ) ; } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } } } else if ( this . binding . isTypeVariable ( ) ) { TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) this . binding ; Binding declaringElement = typeVariableBinding . isCapture ( ) ? ( ( CaptureBinding ) typeVariableBinding ) . sourceType : typeVariableBinding . declaringElement ; if ( declaringElement instanceof ReferenceBinding ) { try { return this . resolver . getTypeBinding ( ( ReferenceBinding ) declaringElement ) ; } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } } } return null ; } public int getDimensions ( ) { if ( ! isArray ( ) ) { return <NUM_LIT:0> ; } ArrayBinding arrayBinding = ( ArrayBinding ) this . binding ; return arrayBinding . dimensions ; } public ITypeBinding getElementType ( ) { if ( ! isArray ( ) ) { return null ; } ArrayBinding arrayBinding = ( ArrayBinding ) this . binding ; return this . resolver . getTypeBinding ( arrayBinding . leafComponentType ) ; } public ITypeBinding getTypeDeclaration ( ) { if ( this . binding instanceof ParameterizedTypeBinding ) return this . resolver . getTypeBinding ( ( ( ParameterizedTypeBinding ) this . binding ) . genericType ( ) ) ; return this ; } public ITypeBinding getErasure ( ) { return this . resolver . getTypeBinding ( this . binding . erasure ( ) ) ; } public synchronized ITypeBinding [ ] getInterfaces ( ) { if ( this . interfaces != null ) { return this . interfaces ; } if ( this . binding == null ) return this . interfaces = NO_TYPE_BINDINGS ; switch ( this . binding . kind ( ) ) { case Binding . ARRAY_TYPE : case Binding . BASE_TYPE : return this . interfaces = NO_TYPE_BINDINGS ; } ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; ReferenceBinding [ ] internalInterfaces = null ; try { internalInterfaces = referenceBinding . superInterfaces ( ) ; } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; } int length = internalInterfaces == null ? <NUM_LIT:0> : internalInterfaces . length ; if ( length != <NUM_LIT:0> ) { ITypeBinding [ ] newInterfaces = new ITypeBinding [ length ] ; int interfacesCounter = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ITypeBinding typeBinding = this . resolver . getTypeBinding ( internalInterfaces [ i ] ) ; if ( typeBinding == null ) { continue ; } newInterfaces [ interfacesCounter ++ ] = typeBinding ; } if ( length != interfacesCounter ) { System . arraycopy ( newInterfaces , <NUM_LIT:0> , ( newInterfaces = new ITypeBinding [ interfacesCounter ] ) , <NUM_LIT:0> , interfacesCounter ) ; } return this . interfaces = newInterfaces ; } return this . interfaces = NO_TYPE_BINDINGS ; } public IJavaElement getJavaElement ( ) { JavaElement element = getUnresolvedJavaElement ( ) ; if ( element != null ) return element . resolved ( this . binding ) ; if ( isRecovered ( ) ) { IPackageBinding packageBinding = getPackage ( ) ; if ( packageBinding != null ) { final IJavaElement javaElement = packageBinding . getJavaElement ( ) ; if ( javaElement != null && javaElement . getElementType ( ) == IJavaElement . PACKAGE_FRAGMENT ) { return ( ( PackageFragment ) javaElement ) . getCompilationUnit ( new String ( this . binding . sourceName ( ) ) + SuffixConstants . SUFFIX_STRING_java ) . getType ( this . getName ( ) ) ; } } return null ; } return null ; } private JavaElement getUnresolvedJavaElement ( ) { return getUnresolvedJavaElement ( this . binding ) ; } private JavaElement getUnresolvedJavaElement ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding ) { if ( JavaCore . getPlugin ( ) == null ) { return null ; } if ( this . resolver instanceof DefaultBindingResolver ) { DefaultBindingResolver defaultBindingResolver = ( DefaultBindingResolver ) this . resolver ; if ( ! defaultBindingResolver . fromJavaProject ) return null ; return org . eclipse . jdt . internal . core . util . Util . getUnresolvedJavaElement ( typeBinding , defaultBindingResolver . workingCopyOwner , defaultBindingResolver . getBindingsToNodesMap ( ) ) ; } return null ; } public String getKey ( ) { if ( this . key == null ) { this . key = new String ( this . binding . computeUniqueKey ( ) ) ; } return this . key ; } public int getKind ( ) { return IBinding . TYPE ; } public int getModifiers ( ) { if ( isClass ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; final int accessFlags = referenceBinding . getAccessFlags ( ) & VALID_MODIFIERS ; if ( referenceBinding . isAnonymousType ( ) ) { return accessFlags & ~ Modifier . FINAL ; } return accessFlags ; } else if ( isAnnotation ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; final int accessFlags = referenceBinding . getAccessFlags ( ) & VALID_MODIFIERS ; return accessFlags & ~ ( ClassFileConstants . AccAbstract | ClassFileConstants . AccInterface | ClassFileConstants . AccAnnotation ) ; } else if ( isInterface ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; final int accessFlags = referenceBinding . getAccessFlags ( ) & VALID_MODIFIERS ; return accessFlags & ~ ( ClassFileConstants . AccAbstract | ClassFileConstants . AccInterface ) ; } else if ( isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; final int accessFlags = referenceBinding . getAccessFlags ( ) & VALID_MODIFIERS ; return accessFlags & ~ ClassFileConstants . AccEnum ; } else { return Modifier . NONE ; } } public String getName ( ) { StringBuffer buffer ; switch ( this . binding . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : WildcardBinding wildcardBinding = ( WildcardBinding ) this . binding ; buffer = new StringBuffer ( ) ; buffer . append ( TypeConstants . WILDCARD_NAME ) ; if ( wildcardBinding . bound != null ) { switch ( wildcardBinding . boundKind ) { case Wildcard . SUPER : buffer . append ( TypeConstants . WILDCARD_SUPER ) ; break ; case Wildcard . EXTENDS : buffer . append ( TypeConstants . WILDCARD_EXTENDS ) ; } buffer . append ( getBound ( ) . getName ( ) ) ; } return String . valueOf ( buffer ) ; case Binding . TYPE_PARAMETER : if ( isCapture ( ) ) { return NO_NAME ; } TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) this . binding ; return new String ( typeVariableBinding . sourceName ) ; case Binding . PARAMETERIZED_TYPE : ParameterizedTypeBinding parameterizedTypeBinding = ( ParameterizedTypeBinding ) this . binding ; buffer = new StringBuffer ( ) ; buffer . append ( parameterizedTypeBinding . sourceName ( ) ) ; ITypeBinding [ ] tArguments = getTypeArguments ( ) ; final int typeArgumentsLength = tArguments . length ; if ( typeArgumentsLength != <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < typeArgumentsLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( tArguments [ i ] . getName ( ) ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } return String . valueOf ( buffer ) ; case Binding . RAW_TYPE : return getTypeDeclaration ( ) . getName ( ) ; case Binding . ARRAY_TYPE : ITypeBinding elementType = getElementType ( ) ; if ( elementType . isLocal ( ) || elementType . isAnonymous ( ) || elementType . isCapture ( ) ) { return NO_NAME ; } int dimensions = getDimensions ( ) ; char [ ] brackets = new char [ dimensions * <NUM_LIT:2> ] ; for ( int i = dimensions * <NUM_LIT:2> - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -= <NUM_LIT:2> ) { brackets [ i ] = '<CHAR_LIT:]>' ; brackets [ i - <NUM_LIT:1> ] = '<CHAR_LIT:[>' ; } buffer = new StringBuffer ( elementType . getName ( ) ) ; buffer . append ( brackets ) ; return String . valueOf ( buffer ) ; default : if ( isPrimitive ( ) || isNullType ( ) ) { BaseTypeBinding baseTypeBinding = ( BaseTypeBinding ) this . binding ; return new String ( baseTypeBinding . simpleName ) ; } if ( isAnonymous ( ) ) { return NO_NAME ; } return new String ( this . binding . sourceName ( ) ) ; } } public IPackageBinding getPackage ( ) { switch ( this . binding . kind ( ) ) { case Binding . BASE_TYPE : case Binding . ARRAY_TYPE : case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return null ; } ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; return this . resolver . getPackageBinding ( referenceBinding . getPackage ( ) ) ; } public String getQualifiedName ( ) { StringBuffer buffer ; switch ( this . binding . kind ( ) ) { case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : WildcardBinding wildcardBinding = ( WildcardBinding ) this . binding ; buffer = new StringBuffer ( ) ; buffer . append ( TypeConstants . WILDCARD_NAME ) ; final ITypeBinding bound = getBound ( ) ; if ( bound != null ) { switch ( wildcardBinding . boundKind ) { case Wildcard . SUPER : buffer . append ( TypeConstants . WILDCARD_SUPER ) ; break ; case Wildcard . EXTENDS : buffer . append ( TypeConstants . WILDCARD_EXTENDS ) ; } buffer . append ( bound . getQualifiedName ( ) ) ; } return String . valueOf ( buffer ) ; case Binding . RAW_TYPE : return getTypeDeclaration ( ) . getQualifiedName ( ) ; case Binding . ARRAY_TYPE : ITypeBinding elementType = getElementType ( ) ; if ( elementType . isLocal ( ) || elementType . isAnonymous ( ) || elementType . isCapture ( ) ) { return elementType . getQualifiedName ( ) ; } final int dimensions = getDimensions ( ) ; char [ ] brackets = new char [ dimensions * <NUM_LIT:2> ] ; for ( int i = dimensions * <NUM_LIT:2> - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -= <NUM_LIT:2> ) { brackets [ i ] = '<CHAR_LIT:]>' ; brackets [ i - <NUM_LIT:1> ] = '<CHAR_LIT:[>' ; } buffer = new StringBuffer ( elementType . getQualifiedName ( ) ) ; buffer . append ( brackets ) ; return String . valueOf ( buffer ) ; case Binding . TYPE_PARAMETER : if ( isCapture ( ) ) { return NO_NAME ; } TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) this . binding ; return new String ( typeVariableBinding . sourceName ) ; case Binding . PARAMETERIZED_TYPE : if ( this . binding . isLocalType ( ) ) { return NO_NAME ; } buffer = new StringBuffer ( ) ; if ( isMember ( ) ) { buffer . append ( getDeclaringClass ( ) . getQualifiedName ( ) ) . append ( '<CHAR_LIT:.>' ) ; ParameterizedTypeBinding parameterizedTypeBinding = ( ParameterizedTypeBinding ) this . binding ; buffer . append ( parameterizedTypeBinding . sourceName ( ) ) ; ITypeBinding [ ] tArguments = getTypeArguments ( ) ; final int typeArgumentsLength = tArguments . length ; if ( typeArgumentsLength != <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < typeArgumentsLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( tArguments [ i ] . getQualifiedName ( ) ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } return String . valueOf ( buffer ) ; } buffer . append ( getTypeDeclaration ( ) . getQualifiedName ( ) ) ; ITypeBinding [ ] tArguments = getTypeArguments ( ) ; final int typeArgumentsLength = tArguments . length ; if ( typeArgumentsLength != <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < typeArgumentsLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( tArguments [ i ] . getQualifiedName ( ) ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } return String . valueOf ( buffer ) ; default : if ( isAnonymous ( ) || this . binding . isLocalType ( ) ) { return NO_NAME ; } if ( isPrimitive ( ) || isNullType ( ) ) { BaseTypeBinding baseTypeBinding = ( BaseTypeBinding ) this . binding ; return new String ( baseTypeBinding . simpleName ) ; } if ( isMember ( ) ) { buffer = new StringBuffer ( ) ; buffer . append ( getDeclaringClass ( ) . getQualifiedName ( ) ) . append ( '<CHAR_LIT:.>' ) ; buffer . append ( getName ( ) ) ; return String . valueOf ( buffer ) ; } PackageBinding packageBinding = this . binding . getPackage ( ) ; buffer = new StringBuffer ( ) ; if ( packageBinding != null && packageBinding . compoundName != CharOperation . NO_CHAR_CHAR ) { buffer . append ( CharOperation . concatWith ( packageBinding . compoundName , '<CHAR_LIT:.>' ) ) . append ( '<CHAR_LIT:.>' ) ; } buffer . append ( getName ( ) ) ; return String . valueOf ( buffer ) ; } } public synchronized ITypeBinding getSuperclass ( ) { if ( this . binding == null ) return null ; switch ( this . binding . kind ( ) ) { case Binding . ARRAY_TYPE : case Binding . BASE_TYPE : return null ; default : if ( this . binding . isInterface ( ) ) return null ; } ReferenceBinding superclass = null ; try { superclass = ( ( ReferenceBinding ) this . binding ) . superclass ( ) ; } catch ( RuntimeException e ) { org . eclipse . jdt . internal . core . util . Util . log ( e , "<STR_LIT>" ) ; return this . resolver . resolveWellKnownType ( "<STR_LIT>" ) ; } if ( superclass == null ) { return null ; } return this . resolver . getTypeBinding ( superclass ) ; } public ITypeBinding [ ] getTypeArguments ( ) { if ( this . typeArguments != null ) { return this . typeArguments ; } if ( this . binding . isParameterizedTypeWithActualArguments ( ) ) { ParameterizedTypeBinding parameterizedTypeBinding = ( ParameterizedTypeBinding ) this . binding ; final org . eclipse . jdt . internal . compiler . lookup . TypeBinding [ ] arguments = parameterizedTypeBinding . arguments ; int argumentsLength = arguments . length ; ITypeBinding [ ] newTypeArguments = new ITypeBinding [ argumentsLength ] ; for ( int i = <NUM_LIT:0> ; i < argumentsLength ; i ++ ) { ITypeBinding typeBinding = this . resolver . getTypeBinding ( arguments [ i ] ) ; if ( typeBinding == null ) { return this . typeArguments = NO_TYPE_BINDINGS ; } newTypeArguments [ i ] = typeBinding ; } return this . typeArguments = newTypeArguments ; } return this . typeArguments = NO_TYPE_BINDINGS ; } public ITypeBinding [ ] getTypeBounds ( ) { if ( this . bounds != null ) { return this . bounds ; } if ( this . binding instanceof TypeVariableBinding ) { TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) this . binding ; ReferenceBinding varSuperclass = typeVariableBinding . superclass ( ) ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding firstClassOrArrayBound = typeVariableBinding . firstBound ; int boundsLength = <NUM_LIT:0> ; if ( firstClassOrArrayBound != null ) { if ( firstClassOrArrayBound == varSuperclass ) { boundsLength ++ ; } else if ( firstClassOrArrayBound . isArrayType ( ) ) { boundsLength ++ ; } else { firstClassOrArrayBound = null ; } } ReferenceBinding [ ] superinterfaces = typeVariableBinding . superInterfaces ( ) ; int superinterfacesLength = <NUM_LIT:0> ; if ( superinterfaces != null ) { superinterfacesLength = superinterfaces . length ; boundsLength += superinterfacesLength ; } if ( boundsLength != <NUM_LIT:0> ) { ITypeBinding [ ] typeBounds = new ITypeBinding [ boundsLength ] ; int boundsIndex = <NUM_LIT:0> ; if ( firstClassOrArrayBound != null ) { ITypeBinding typeBinding = this . resolver . getTypeBinding ( firstClassOrArrayBound ) ; if ( typeBinding == null ) { return this . bounds = NO_TYPE_BINDINGS ; } typeBounds [ boundsIndex ++ ] = typeBinding ; } if ( superinterfaces != null ) { for ( int i = <NUM_LIT:0> ; i < superinterfacesLength ; i ++ , boundsIndex ++ ) { ITypeBinding typeBinding = this . resolver . getTypeBinding ( superinterfaces [ i ] ) ; if ( typeBinding == null ) { return this . bounds = NO_TYPE_BINDINGS ; } typeBounds [ boundsIndex ] = typeBinding ; } } return this . bounds = typeBounds ; } } return this . bounds = NO_TYPE_BINDINGS ; } public ITypeBinding [ ] getTypeParameters ( ) { if ( this . typeParameters != null ) { return this . typeParameters ; } switch ( this . binding . kind ( ) ) { case Binding . RAW_TYPE : case Binding . PARAMETERIZED_TYPE : return this . typeParameters = NO_TYPE_BINDINGS ; } TypeVariableBinding [ ] typeVariableBindings = this . binding . typeVariables ( ) ; int typeVariableBindingsLength = typeVariableBindings == null ? <NUM_LIT:0> : typeVariableBindings . length ; if ( typeVariableBindingsLength != <NUM_LIT:0> ) { ITypeBinding [ ] newTypeParameters = new ITypeBinding [ typeVariableBindingsLength ] ; for ( int i = <NUM_LIT:0> ; i < typeVariableBindingsLength ; i ++ ) { ITypeBinding typeBinding = this . resolver . getTypeBinding ( typeVariableBindings [ i ] ) ; if ( typeBinding == null ) { return this . typeParameters = NO_TYPE_BINDINGS ; } newTypeParameters [ i ] = typeBinding ; } return this . typeParameters = newTypeParameters ; } return this . typeParameters = NO_TYPE_BINDINGS ; } public ITypeBinding getWildcard ( ) { if ( this . binding instanceof CaptureBinding ) { CaptureBinding captureBinding = ( CaptureBinding ) this . binding ; return this . resolver . getTypeBinding ( captureBinding . wildcard ) ; } return null ; } public boolean isGenericType ( ) { if ( isRawType ( ) ) { return false ; } TypeVariableBinding [ ] typeVariableBindings = this . binding . typeVariables ( ) ; return ( typeVariableBindings != null && typeVariableBindings . length > <NUM_LIT:0> ) ; } public boolean isAnnotation ( ) { return this . binding . isAnnotationType ( ) ; } public boolean isAnonymous ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; return referenceBinding . isAnonymousType ( ) ; } return false ; } public boolean isArray ( ) { return this . binding . isArrayType ( ) ; } public boolean isAssignmentCompatible ( ITypeBinding type ) { try { if ( this == type ) return true ; if ( ! ( type instanceof TypeBinding ) ) return false ; TypeBinding other = ( TypeBinding ) type ; Scope scope = this . resolver . scope ( ) ; if ( scope == null ) return false ; return this . binding . isCompatibleWith ( other . binding ) || scope . isBoxingCompatibleWith ( this . binding , other . binding ) ; } catch ( AbortCompilation e ) { return false ; } } public boolean isCapture ( ) { return this . binding . isCapture ( ) ; } public boolean isCastCompatible ( ITypeBinding type ) { try { Scope scope = this . resolver . scope ( ) ; if ( scope == null ) return false ; if ( ! ( type instanceof TypeBinding ) ) return false ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding expressionType = ( ( TypeBinding ) type ) . binding ; expressionType = expressionType . capture ( scope , <NUM_LIT:0> ) ; return TypeBinding . EXPRESSION . checkCastTypesCompatibility ( scope , this . binding , expressionType , null ) ; } catch ( AbortCompilation e ) { return false ; } } public boolean isClass ( ) { switch ( this . binding . kind ( ) ) { case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return false ; } return this . binding . isClass ( ) ; } public boolean isDeprecated ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; return referenceBinding . isDeprecated ( ) ; } return false ; } public boolean isEnum ( ) { return this . binding . isEnum ( ) ; } public boolean isEqualTo ( IBinding other ) { if ( other == this ) { return true ; } if ( other == null ) { return false ; } if ( ! ( other instanceof TypeBinding ) ) { return false ; } org . eclipse . jdt . internal . compiler . lookup . TypeBinding otherBinding = ( ( TypeBinding ) other ) . binding ; return BindingComparator . isEqual ( this . binding , otherBinding ) ; } public boolean isFromSource ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; if ( referenceBinding . isRawType ( ) ) { return ! ( ( RawTypeBinding ) referenceBinding ) . genericType ( ) . isBinaryBinding ( ) ; } else if ( referenceBinding . isParameterizedType ( ) ) { ParameterizedTypeBinding parameterizedTypeBinding = ( ParameterizedTypeBinding ) referenceBinding ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding erasure = parameterizedTypeBinding . erasure ( ) ; if ( erasure instanceof ReferenceBinding ) { return ! ( ( ReferenceBinding ) erasure ) . isBinaryBinding ( ) ; } return false ; } else { return ! referenceBinding . isBinaryBinding ( ) ; } } else if ( isTypeVariable ( ) ) { final TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) this . binding ; final Binding declaringElement = typeVariableBinding . declaringElement ; if ( declaringElement instanceof MethodBinding ) { MethodBinding methodBinding = ( MethodBinding ) declaringElement ; return ! methodBinding . declaringClass . isBinaryBinding ( ) ; } else { final org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding = ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) declaringElement ; if ( typeBinding instanceof ReferenceBinding ) { return ! ( ( ReferenceBinding ) typeBinding ) . isBinaryBinding ( ) ; } else if ( typeBinding instanceof ArrayBinding ) { final ArrayBinding arrayBinding = ( ArrayBinding ) typeBinding ; final org . eclipse . jdt . internal . compiler . lookup . TypeBinding leafComponentType = arrayBinding . leafComponentType ; if ( leafComponentType instanceof ReferenceBinding ) { return ! ( ( ReferenceBinding ) leafComponentType ) . isBinaryBinding ( ) ; } } } } else if ( isCapture ( ) ) { CaptureBinding captureBinding = ( CaptureBinding ) this . binding ; return ! captureBinding . sourceType . isBinaryBinding ( ) ; } return false ; } public boolean isInterface ( ) { switch ( this . binding . kind ( ) ) { case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return false ; } return this . binding . isInterface ( ) ; } public boolean isLocal ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; return referenceBinding . isLocalType ( ) && ! referenceBinding . isMemberType ( ) ; } return false ; } public boolean isMember ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; return referenceBinding . isMemberType ( ) ; } return false ; } public boolean isNested ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; return referenceBinding . isNestedType ( ) ; } return false ; } public boolean isNullType ( ) { return this . binding == org . eclipse . jdt . internal . compiler . lookup . TypeBinding . NULL ; } public boolean isParameterizedType ( ) { return this . binding . isParameterizedTypeWithActualArguments ( ) ; } public boolean isPrimitive ( ) { return ! isNullType ( ) && this . binding . isBaseType ( ) ; } public boolean isRawType ( ) { return this . binding . isRawType ( ) ; } public boolean isRecovered ( ) { return ( this . binding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ; } public boolean isSubTypeCompatible ( ITypeBinding type ) { try { if ( this == type ) return true ; if ( this . binding . isBaseType ( ) ) return false ; if ( ! ( type instanceof TypeBinding ) ) return false ; TypeBinding other = ( TypeBinding ) type ; if ( other . binding . isBaseType ( ) ) return false ; return this . binding . isCompatibleWith ( other . binding ) ; } catch ( AbortCompilation e ) { return false ; } } public boolean isSynthetic ( ) { return false ; } public boolean isTopLevel ( ) { if ( isClass ( ) || isInterface ( ) || isEnum ( ) ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) this . binding ; return ! referenceBinding . isNestedType ( ) ; } return false ; } public boolean isTypeVariable ( ) { return this . binding . isTypeVariable ( ) && ! this . binding . isCapture ( ) ; } public boolean isUpperbound ( ) { switch ( this . binding . kind ( ) ) { case Binding . WILDCARD_TYPE : return ( ( WildcardBinding ) this . binding ) . boundKind == Wildcard . EXTENDS ; case Binding . INTERSECTION_TYPE : return true ; } return false ; } public boolean isWildcardType ( ) { return this . binding . isWildcard ( ) ; } public String toString ( ) { return this . binding . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ContinueStatement extends Statement { public static final ChildPropertyDescriptor LABEL_PROPERTY = new ChildPropertyDescriptor ( ContinueStatement . class , "<STR_LIT:label>" , SimpleName . class , OPTIONAL , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ContinueStatement . class , properyList ) ; addProperty ( LABEL_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName optionalLabel = null ; ContinueStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LABEL_PROPERTY ) { if ( get ) { return getLabel ( ) ; } else { setLabel ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return CONTINUE_STATEMENT ; } ASTNode clone0 ( AST target ) { ContinueStatement result = new ContinueStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setLabel ( ( SimpleName ) ASTNode . copySubtree ( target , getLabel ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLabel ( ) ) ; } visitor . endVisit ( this ) ; } public SimpleName getLabel ( ) { return this . optionalLabel ; } public void setLabel ( SimpleName label ) { ASTNode oldChild = this . optionalLabel ; preReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; this . optionalLabel = label ; postReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalLabel == null ? <NUM_LIT:0> : getLabel ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ImportDeclaration extends ASTNode { public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( ImportDeclaration . class , "<STR_LIT:name>" , Name . class , MANDATORY , NO_CYCLE_RISK ) ; public static final SimplePropertyDescriptor ON_DEMAND_PROPERTY = new SimplePropertyDescriptor ( ImportDeclaration . class , "<STR_LIT>" , boolean . class , MANDATORY ) ; public static final SimplePropertyDescriptor STATIC_PROPERTY = new SimplePropertyDescriptor ( ImportDeclaration . class , "<STR_LIT>" , boolean . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( ImportDeclaration . class , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( ON_DEMAND_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( ImportDeclaration . class , properyList ) ; addProperty ( STATIC_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( ON_DEMAND_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Name importName = null ; private boolean onDemand = false ; private boolean isStatic = false ; ImportDeclaration ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { if ( property == ON_DEMAND_PROPERTY ) { if ( get ) { return isOnDemand ( ) ; } else { setOnDemand ( value ) ; return false ; } } if ( property == STATIC_PROPERTY ) { if ( get ) { return isStatic ( ) ; } else { setStatic ( value ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( Name ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return IMPORT_DECLARATION ; } ASTNode clone0 ( AST target ) { ImportDeclaration result = new ImportDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setOnDemand ( isOnDemand ( ) ) ; if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { result . setStatic ( isStatic ( ) ) ; } result . setName ( ( Name ) getName ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Name getName ( ) { if ( this . importName == null ) { synchronized ( this ) { if ( this . importName == null ) { preLazyInit ( ) ; this . importName = this . ast . newQualifiedName ( new SimpleName ( this . ast ) , new SimpleName ( this . ast ) ) ; postLazyInit ( this . importName , NAME_PROPERTY ) ; } } } return this . importName ; } public void setName ( Name name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . importName ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . importName = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } public boolean isOnDemand ( ) { return this . onDemand ; } public void setOnDemand ( boolean onDemand ) { preValueChange ( ON_DEMAND_PROPERTY ) ; this . onDemand = onDemand ; postValueChange ( ON_DEMAND_PROPERTY ) ; } public boolean isStatic ( ) { unsupportedIn2 ( ) ; return this . isStatic ; } public void setStatic ( boolean isStatic ) { unsupportedIn2 ( ) ; preValueChange ( STATIC_PROPERTY ) ; this . isStatic = isStatic ; postValueChange ( STATIC_PROPERTY ) ; } public IBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveImport ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . importName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class SuperMethodInvocation extends Expression { public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = new ChildPropertyDescriptor ( SuperMethodInvocation . class , "<STR_LIT>" , Name . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( SuperMethodInvocation . class , "<STR_LIT>" , Type . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( SuperMethodInvocation . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( SuperMethodInvocation . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( SuperMethodInvocation . class , propertyList ) ; addProperty ( QUALIFIER_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( ARGUMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( SuperMethodInvocation . class , propertyList ) ; addProperty ( QUALIFIER_PROPERTY , propertyList ) ; addProperty ( TYPE_ARGUMENTS_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( ARGUMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Name optionalQualifier = null ; private ASTNode . NodeList typeArguments = null ; private SimpleName methodName = null ; private ASTNode . NodeList arguments = new ASTNode . NodeList ( ARGUMENTS_PROPERTY ) ; SuperMethodInvocation ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3_INTERNAL ) { this . typeArguments = new ASTNode . NodeList ( TYPE_ARGUMENTS_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == QUALIFIER_PROPERTY ) { if ( get ) { return getQualifier ( ) ; } else { setQualifier ( ( Name ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == ARGUMENTS_PROPERTY ) { return arguments ( ) ; } if ( property == TYPE_ARGUMENTS_PROPERTY ) { return typeArguments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return SUPER_METHOD_INVOCATION ; } ASTNode clone0 ( AST target ) { SuperMethodInvocation result = new SuperMethodInvocation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . setQualifier ( ( Name ) ASTNode . copySubtree ( target , getQualifier ( ) ) ) ; if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { result . typeArguments ( ) . addAll ( ASTNode . copySubtrees ( target , typeArguments ( ) ) ) ; } result . arguments ( ) . addAll ( ASTNode . copySubtrees ( target , arguments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getQualifier ( ) ) ; if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { acceptChildren ( visitor , this . typeArguments ) ; } acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . arguments ) ; } visitor . endVisit ( this ) ; } public Name getQualifier ( ) { return this . optionalQualifier ; } public boolean isResolvedTypeInferredFromExpectedType ( ) { return this . ast . getBindingResolver ( ) . isResolvedTypeInferredFromExpectedType ( this ) ; } public void setQualifier ( Name name ) { ASTNode oldChild = this . optionalQualifier ; preReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; this . optionalQualifier = name ; postReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; } public List typeArguments ( ) { if ( this . typeArguments == null ) { unsupportedIn2 ( ) ; } return this . typeArguments ; } public SimpleName getName ( ) { if ( this . methodName == null ) { synchronized ( this ) { if ( this . methodName == null ) { preLazyInit ( ) ; this . methodName = new SimpleName ( this . ast ) ; postLazyInit ( this . methodName , NAME_PROPERTY ) ; } } } return this . methodName ; } public void setName ( SimpleName name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . methodName ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . methodName = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } public List arguments ( ) { return this . arguments ; } public IMethodBinding resolveMethodBinding ( ) { return this . ast . getBindingResolver ( ) . resolveMethod ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:4> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalQualifier == null ? <NUM_LIT:0> : getQualifier ( ) . treeSize ( ) ) + ( this . typeArguments == null ? <NUM_LIT:0> : this . typeArguments . listSize ( ) ) + ( this . methodName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . arguments == null ? <NUM_LIT:0> : this . arguments . listSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class QualifiedType extends Type { int index ; public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = new ChildPropertyDescriptor ( QualifiedType . class , "<STR_LIT>" , Type . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( QualifiedType . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( QualifiedType . class , propertyList ) ; addProperty ( QUALIFIER_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Type qualifier = null ; private SimpleName name = null ; QualifiedType ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == QUALIFIER_PROPERTY ) { if ( get ) { return getQualifier ( ) ; } else { setQualifier ( ( Type ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return QUALIFIED_TYPE ; } ASTNode clone0 ( AST target ) { QualifiedType result = new QualifiedType ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setQualifier ( ( Type ) ( ( ASTNode ) getQualifier ( ) ) . clone ( target ) ) ; result . setName ( ( SimpleName ) ( ( ASTNode ) getName ( ) ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getQualifier ( ) ) ; acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Type getQualifier ( ) { if ( this . qualifier == null ) { synchronized ( this ) { if ( this . qualifier == null ) { preLazyInit ( ) ; this . qualifier = new SimpleType ( this . ast ) ; postLazyInit ( this . qualifier , QUALIFIER_PROPERTY ) ; } } } return this . qualifier ; } public void setQualifier ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . qualifier ; preReplaceChild ( oldChild , type , QUALIFIER_PROPERTY ) ; this . qualifier = type ; postReplaceChild ( oldChild , type , QUALIFIER_PROPERTY ) ; } public SimpleName getName ( ) { if ( this . name == null ) { synchronized ( this ) { if ( this . name == null ) { preLazyInit ( ) ; this . name = new SimpleName ( this . ast ) ; postLazyInit ( this . name , NAME_PROPERTY ) ; } } } return this . name ; } public void setName ( SimpleName name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . name ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . name = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . qualifier == null ? <NUM_LIT:0> : getQualifier ( ) . treeSize ( ) ) + ( this . name == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class Initializer extends BodyDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( Initializer . class ) ; public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = internalModifiersPropertyFactory ( Initializer . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( Initializer . class ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( Initializer . class , "<STR_LIT:body>" , Block . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( Initializer . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS_PROPERTY , properyList ) ; addProperty ( BODY_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( Initializer . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS2_PROPERTY , properyList ) ; addProperty ( BODY_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Block body = null ; Initializer ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { internalSetModifiers ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Block ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return MODIFIERS_PROPERTY ; } final int getNodeType0 ( ) { return INITIALIZER ; } ASTNode clone0 ( AST target ) { Initializer result = new Initializer ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . internalSetModifiers ( getModifiers ( ) ) ; } if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; } result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; result . setBody ( ( Block ) getBody ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { acceptChildren ( visitor , this . modifiers ) ; } acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public Block getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new Block ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Block body ) { if ( body == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , body , BODY_PROPERTY ) ; this . body = body ; postReplaceChild ( oldChild , body , BODY_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + ( this . modifiers == null ? <NUM_LIT:0> : this . modifiers . listSize ( ) ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; interface IDocElement { } </s>
|
<s> package org . eclipse . jdt . core . dom ; public abstract class Comment extends ASTNode { private ASTNode alternateRoot = null ; Comment ( AST ast ) { super ( ast ) ; } public final boolean isBlockComment ( ) { return ( this instanceof BlockComment ) ; } public final boolean isLineComment ( ) { return ( this instanceof LineComment ) ; } public final boolean isDocComment ( ) { return ( this instanceof Javadoc ) ; } public final ASTNode getAlternateRoot ( ) { return this . alternateRoot ; } public final void setAlternateRoot ( ASTNode root ) { checkModifiable ( ) ; this . alternateRoot = root ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class PrefixExpression extends Expression { public static class Operator { private String token ; private Operator ( String token ) { this . token = token ; } public String toString ( ) { return this . token ; } public static final Operator INCREMENT = new Operator ( "<STR_LIT>" ) ; public static final Operator DECREMENT = new Operator ( "<STR_LIT:-->" ) ; public static final Operator PLUS = new Operator ( "<STR_LIT:+>" ) ; public static final Operator MINUS = new Operator ( "<STR_LIT:->" ) ; public static final Operator COMPLEMENT = new Operator ( "<STR_LIT>" ) ; public static final Operator NOT = new Operator ( "<STR_LIT:!>" ) ; private static final Map CODES ; static { CODES = new HashMap ( <NUM_LIT:20> ) ; Operator [ ] ops = { INCREMENT , DECREMENT , PLUS , MINUS , COMPLEMENT , NOT , } ; for ( int i = <NUM_LIT:0> ; i < ops . length ; i ++ ) { CODES . put ( ops [ i ] . toString ( ) , ops [ i ] ) ; } } public static Operator toOperator ( String token ) { return ( Operator ) CODES . get ( token ) ; } } public static final SimplePropertyDescriptor OPERATOR_PROPERTY = new SimplePropertyDescriptor ( PrefixExpression . class , "<STR_LIT>" , PrefixExpression . Operator . class , MANDATORY ) ; public static final ChildPropertyDescriptor OPERAND_PROPERTY = new ChildPropertyDescriptor ( PrefixExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( PrefixExpression . class , propertyList ) ; addProperty ( OPERATOR_PROPERTY , propertyList ) ; addProperty ( OPERAND_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private PrefixExpression . Operator operator = PrefixExpression . Operator . PLUS ; private Expression operand = null ; PrefixExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == OPERATOR_PROPERTY ) { if ( get ) { return getOperator ( ) ; } else { setOperator ( ( Operator ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == OPERAND_PROPERTY ) { if ( get ) { return getOperand ( ) ; } else { setOperand ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return PREFIX_EXPRESSION ; } ASTNode clone0 ( AST target ) { PrefixExpression result = new PrefixExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setOperator ( getOperator ( ) ) ; result . setOperand ( ( Expression ) getOperand ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getOperand ( ) ) ; } visitor . endVisit ( this ) ; } public PrefixExpression . Operator getOperator ( ) { return this . operator ; } public void setOperator ( PrefixExpression . Operator operator ) { if ( operator == null ) { throw new IllegalArgumentException ( ) ; } preValueChange ( OPERATOR_PROPERTY ) ; this . operator = operator ; postValueChange ( OPERATOR_PROPERTY ) ; } public Expression getOperand ( ) { if ( this . operand == null ) { synchronized ( this ) { if ( this . operand == null ) { preLazyInit ( ) ; this . operand = new SimpleName ( this . ast ) ; postLazyInit ( this . operand , OPERAND_PROPERTY ) ; } } } return this . operand ; } public void setOperand ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . operand ; preReplaceChild ( oldChild , expression , OPERAND_PROPERTY ) ; this . operand = expression ; postReplaceChild ( oldChild , expression , OPERAND_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . operand == null ? <NUM_LIT:0> : getOperand ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public abstract class ASTVisitor { private boolean visitDocTags ; public ASTVisitor ( ) { this ( false ) ; } public ASTVisitor ( boolean visitDocTags ) { this . visitDocTags = visitDocTags ; } public void preVisit ( ASTNode node ) { } public boolean preVisit2 ( ASTNode node ) { preVisit ( node ) ; return true ; } public void postVisit ( ASTNode node ) { } public boolean visit ( AnnotationTypeDeclaration node ) { return true ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { return true ; } public boolean visit ( AnonymousClassDeclaration node ) { return true ; } public boolean visit ( ArrayAccess node ) { return true ; } public boolean visit ( ArrayCreation node ) { return true ; } public boolean visit ( ArrayInitializer node ) { return true ; } public boolean visit ( ArrayType node ) { return true ; } public boolean visit ( AssertStatement node ) { return true ; } public boolean visit ( Assignment node ) { return true ; } public boolean visit ( Block node ) { return true ; } public boolean visit ( BlockComment node ) { return true ; } public boolean visit ( BooleanLiteral node ) { return true ; } public boolean visit ( BreakStatement node ) { return true ; } public boolean visit ( CastExpression node ) { return true ; } public boolean visit ( CatchClause node ) { return true ; } public boolean visit ( CharacterLiteral node ) { return true ; } public boolean visit ( ClassInstanceCreation node ) { return true ; } public boolean visit ( CompilationUnit node ) { return true ; } public boolean visit ( ConditionalExpression node ) { return true ; } public boolean visit ( ConstructorInvocation node ) { return true ; } public boolean visit ( ContinueStatement node ) { return true ; } public boolean visit ( DoStatement node ) { return true ; } public boolean visit ( EmptyStatement node ) { return true ; } public boolean visit ( EnhancedForStatement node ) { return true ; } public boolean visit ( EnumConstantDeclaration node ) { return true ; } public boolean visit ( EnumDeclaration node ) { return true ; } public boolean visit ( ExpressionStatement node ) { return true ; } public boolean visit ( FieldAccess node ) { return true ; } public boolean visit ( FieldDeclaration node ) { return true ; } public boolean visit ( ForStatement node ) { return true ; } public boolean visit ( IfStatement node ) { return true ; } public boolean visit ( ImportDeclaration node ) { return true ; } public boolean visit ( InfixExpression node ) { return true ; } public boolean visit ( InstanceofExpression node ) { return true ; } public boolean visit ( Initializer node ) { return true ; } public boolean visit ( Javadoc node ) { return this . visitDocTags ; } public boolean visit ( LabeledStatement node ) { return true ; } public boolean visit ( LineComment node ) { return true ; } public boolean visit ( MarkerAnnotation node ) { return true ; } public boolean visit ( MemberRef node ) { return true ; } public boolean visit ( MemberValuePair node ) { return true ; } public boolean visit ( MethodRef node ) { return true ; } public boolean visit ( MethodRefParameter node ) { return true ; } public boolean visit ( MethodDeclaration node ) { return true ; } public boolean visit ( MethodInvocation node ) { return true ; } public boolean visit ( Modifier node ) { return true ; } public boolean visit ( NormalAnnotation node ) { return true ; } public boolean visit ( NullLiteral node ) { return true ; } public boolean visit ( NumberLiteral node ) { return true ; } public boolean visit ( PackageDeclaration node ) { return true ; } public boolean visit ( ParameterizedType node ) { return true ; } public boolean visit ( ParenthesizedExpression node ) { return true ; } public boolean visit ( PostfixExpression node ) { return true ; } public boolean visit ( PrefixExpression node ) { return true ; } public boolean visit ( PrimitiveType node ) { return true ; } public boolean visit ( QualifiedName node ) { return true ; } public boolean visit ( QualifiedType node ) { return true ; } public boolean visit ( ReturnStatement node ) { return true ; } public boolean visit ( SimpleName node ) { return true ; } public boolean visit ( SimpleType node ) { return true ; } public boolean visit ( SingleMemberAnnotation node ) { return true ; } public boolean visit ( SingleVariableDeclaration node ) { return true ; } public boolean visit ( StringLiteral node ) { return true ; } public boolean visit ( SuperConstructorInvocation node ) { return true ; } public boolean visit ( SuperFieldAccess node ) { return true ; } public boolean visit ( SuperMethodInvocation node ) { return true ; } public boolean visit ( SwitchCase node ) { return true ; } public boolean visit ( SwitchStatement node ) { return true ; } public boolean visit ( SynchronizedStatement node ) { return true ; } public boolean visit ( TagElement node ) { return true ; } public boolean visit ( TextElement node ) { return true ; } public boolean visit ( ThisExpression node ) { return true ; } public boolean visit ( ThrowStatement node ) { return true ; } public boolean visit ( TryStatement node ) { return true ; } public boolean visit ( TypeDeclaration node ) { return true ; } public boolean visit ( TypeDeclarationStatement node ) { return true ; } public boolean visit ( TypeLiteral node ) { return true ; } public boolean visit ( TypeParameter node ) { return true ; } public boolean visit ( UnionType node ) { return true ; } public boolean visit ( VariableDeclarationExpression node ) { return true ; } public boolean visit ( VariableDeclarationStatement node ) { return true ; } public boolean visit ( VariableDeclarationFragment node ) { return true ; } public boolean visit ( WhileStatement node ) { return true ; } public boolean visit ( WildcardType node ) { return true ; } public void endVisit ( AnnotationTypeDeclaration node ) { } public void endVisit ( AnnotationTypeMemberDeclaration node ) { } public void endVisit ( AnonymousClassDeclaration node ) { } public void endVisit ( ArrayAccess node ) { } public void endVisit ( ArrayCreation node ) { } public void endVisit ( ArrayInitializer node ) { } public void endVisit ( ArrayType node ) { } public void endVisit ( AssertStatement node ) { } public void endVisit ( Assignment node ) { } public void endVisit ( Block node ) { } public void endVisit ( BlockComment node ) { } public void endVisit ( BooleanLiteral node ) { } public void endVisit ( BreakStatement node ) { } public void endVisit ( CastExpression node ) { } public void endVisit ( CatchClause node ) { } public void endVisit ( CharacterLiteral node ) { } public void endVisit ( ClassInstanceCreation node ) { } public void endVisit ( CompilationUnit node ) { } public void endVisit ( ConditionalExpression node ) { } public void endVisit ( ConstructorInvocation node ) { } public void endVisit ( ContinueStatement node ) { } public void endVisit ( DoStatement node ) { } public void endVisit ( EmptyStatement node ) { } public void endVisit ( EnhancedForStatement node ) { } public void endVisit ( EnumConstantDeclaration node ) { } public void endVisit ( EnumDeclaration node ) { } public void endVisit ( ExpressionStatement node ) { } public void endVisit ( FieldAccess node ) { } public void endVisit ( FieldDeclaration node ) { } public void endVisit ( ForStatement node ) { } public void endVisit ( IfStatement node ) { } public void endVisit ( ImportDeclaration node ) { } public void endVisit ( InfixExpression node ) { } public void endVisit ( InstanceofExpression node ) { } public void endVisit ( Initializer node ) { } public void endVisit ( Javadoc node ) { } public void endVisit ( LabeledStatement node ) { } public void endVisit ( LineComment node ) { } public void endVisit ( MarkerAnnotation node ) { } public void endVisit ( MemberRef node ) { } public void endVisit ( MemberValuePair node ) { } public void endVisit ( MethodRef node ) { } public void endVisit ( MethodRefParameter node ) { } public void endVisit ( MethodDeclaration node ) { } public void endVisit ( MethodInvocation node ) { } public void endVisit ( Modifier node ) { } public void endVisit ( NormalAnnotation node ) { } public void endVisit ( NullLiteral node ) { } public void endVisit ( NumberLiteral node ) { } public void endVisit ( PackageDeclaration node ) { } public void endVisit ( ParameterizedType node ) { } public void endVisit ( ParenthesizedExpression node ) { } public void endVisit ( PostfixExpression node ) { } public void endVisit ( PrefixExpression node ) { } public void endVisit ( PrimitiveType node ) { } public void endVisit ( QualifiedName node ) { } public void endVisit ( QualifiedType node ) { } public void endVisit ( ReturnStatement node ) { } public void endVisit ( SimpleName node ) { } public void endVisit ( SimpleType node ) { } public void endVisit ( SingleMemberAnnotation node ) { } public void endVisit ( SingleVariableDeclaration node ) { } public void endVisit ( StringLiteral node ) { } public void endVisit ( SuperConstructorInvocation node ) { } public void endVisit ( SuperFieldAccess node ) { } public void endVisit ( SuperMethodInvocation node ) { } public void endVisit ( SwitchCase node ) { } public void endVisit ( SwitchStatement node ) { } public void endVisit ( SynchronizedStatement node ) { } public void endVisit ( TagElement node ) { } public void endVisit ( TextElement node ) { } public void endVisit ( ThisExpression node ) { } public void endVisit ( ThrowStatement node ) { } public void endVisit ( TryStatement node ) { } public void endVisit ( TypeDeclaration node ) { } public void endVisit ( TypeDeclarationStatement node ) { } public void endVisit ( TypeLiteral node ) { } public void endVisit ( TypeParameter node ) { } public void endVisit ( UnionType node ) { } public void endVisit ( VariableDeclarationExpression node ) { } public void endVisit ( VariableDeclarationStatement node ) { } public void endVisit ( VariableDeclarationFragment node ) { } public void endVisit ( WhileStatement node ) { } public void endVisit ( WildcardType node ) { } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . List ; public abstract class AbstractTypeDeclaration extends BodyDeclaration { SimpleName typeName = null ; ASTNode . NodeList bodyDeclarations ; abstract ChildListPropertyDescriptor internalBodyDeclarationsProperty ( ) ; public final ChildListPropertyDescriptor getBodyDeclarationsProperty ( ) { return internalBodyDeclarationsProperty ( ) ; } abstract ChildPropertyDescriptor internalNameProperty ( ) ; public final ChildPropertyDescriptor getNameProperty ( ) { return internalNameProperty ( ) ; } static final ChildListPropertyDescriptor internalBodyDeclarationPropertyFactory ( Class nodeClass ) { return new ChildListPropertyDescriptor ( nodeClass , "<STR_LIT>" , BodyDeclaration . class , CYCLE_RISK ) ; } static final ChildPropertyDescriptor internalNamePropertyFactory ( Class nodeClass ) { return new ChildPropertyDescriptor ( nodeClass , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; } AbstractTypeDeclaration ( AST ast ) { super ( ast ) ; this . bodyDeclarations = new ASTNode . NodeList ( internalBodyDeclarationsProperty ( ) ) ; } public SimpleName getName ( ) { if ( this . typeName == null ) { synchronized ( this ) { if ( this . typeName == null ) { preLazyInit ( ) ; this . typeName = new SimpleName ( this . ast ) ; postLazyInit ( this . typeName , internalNameProperty ( ) ) ; } } } return this . typeName ; } public void setName ( SimpleName typeName ) { if ( typeName == null ) { throw new IllegalArgumentException ( ) ; } ChildPropertyDescriptor p = internalNameProperty ( ) ; ASTNode oldChild = this . typeName ; preReplaceChild ( oldChild , typeName , p ) ; this . typeName = typeName ; postReplaceChild ( oldChild , typeName , p ) ; } public List bodyDeclarations ( ) { return this . bodyDeclarations ; } public boolean isPackageMemberTypeDeclaration ( ) { ASTNode parent = getParent ( ) ; return ( parent instanceof CompilationUnit ) ; } public boolean isMemberTypeDeclaration ( ) { ASTNode parent = getParent ( ) ; return ( parent instanceof AbstractTypeDeclaration ) || ( parent instanceof AnonymousClassDeclaration ) ; } public boolean isLocalTypeDeclaration ( ) { ASTNode parent = getParent ( ) ; return ( parent instanceof TypeDeclarationStatement ) ; } public final ITypeBinding resolveBinding ( ) { return internalResolveBinding ( ) ; } abstract ITypeBinding internalResolveBinding ( ) ; int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . ITypeRoot ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . core . compiler . IScanner ; import org . eclipse . jdt . core . compiler . ITerminalSymbols ; import org . eclipse . jdt . core . compiler . InvalidInputException ; public final class NodeFinder { private static class NodeFinderVisitor extends ASTVisitor { private int fStart ; private int fEnd ; private ASTNode fCoveringNode ; private ASTNode fCoveredNode ; NodeFinderVisitor ( int offset , int length ) { super ( true ) ; this . fStart = offset ; this . fEnd = offset + length ; } public boolean preVisit2 ( ASTNode node ) { int nodeStart = node . getStartPosition ( ) ; int nodeEnd = nodeStart + node . getLength ( ) ; if ( nodeEnd < this . fStart || this . fEnd < nodeStart ) { return false ; } if ( nodeStart <= this . fStart && this . fEnd <= nodeEnd ) { this . fCoveringNode = node ; } if ( this . fStart <= nodeStart && nodeEnd <= this . fEnd ) { if ( this . fCoveringNode == node ) { this . fCoveredNode = node ; return true ; } else if ( this . fCoveredNode == null ) { this . fCoveredNode = node ; } return false ; } return true ; } public ASTNode getCoveredNode ( ) { return this . fCoveredNode ; } public ASTNode getCoveringNode ( ) { return this . fCoveringNode ; } } public static ASTNode perform ( ASTNode root , int start , int length ) { NodeFinder finder = new NodeFinder ( root , start , length ) ; ASTNode result = finder . getCoveredNode ( ) ; if ( result == null || result . getStartPosition ( ) != start || result . getLength ( ) != length ) { return finder . getCoveringNode ( ) ; } return result ; } public static ASTNode perform ( ASTNode root , ISourceRange range ) { return perform ( root , range . getOffset ( ) , range . getLength ( ) ) ; } public static ASTNode perform ( ASTNode root , int start , int length , ITypeRoot source ) throws JavaModelException { NodeFinder finder = new NodeFinder ( root , start , length ) ; ASTNode result = finder . getCoveredNode ( ) ; if ( result == null ) return null ; int nodeStart = result . getStartPosition ( ) ; if ( start <= nodeStart && ( ( nodeStart + result . getLength ( ) ) <= ( start + length ) ) ) { IBuffer buffer = source . getBuffer ( ) ; if ( buffer != null ) { IScanner scanner = ToolFactory . createScanner ( false , false , false , false ) ; try { scanner . setSource ( buffer . getText ( start , length ) . toCharArray ( ) ) ; int token = scanner . getNextToken ( ) ; if ( token != ITerminalSymbols . TokenNameEOF ) { int tStart = scanner . getCurrentTokenStartPosition ( ) ; if ( tStart == result . getStartPosition ( ) - start ) { scanner . resetTo ( tStart + result . getLength ( ) , length - <NUM_LIT:1> ) ; token = scanner . getNextToken ( ) ; if ( token == ITerminalSymbols . TokenNameEOF ) return result ; } } } catch ( InvalidInputException e ) { } catch ( IndexOutOfBoundsException e ) { return null ; } } } return finder . getCoveringNode ( ) ; } private ASTNode fCoveringNode ; private ASTNode fCoveredNode ; public NodeFinder ( ASTNode root , int start , int length ) { NodeFinderVisitor nodeFinderVisitor = new NodeFinderVisitor ( start , length ) ; root . accept ( nodeFinderVisitor ) ; this . fCoveredNode = nodeFinderVisitor . getCoveredNode ( ) ; this . fCoveringNode = nodeFinderVisitor . getCoveringNode ( ) ; } public ASTNode getCoveredNode ( ) { return this . fCoveredNode ; } public ASTNode getCoveringNode ( ) { return this . fCoveringNode ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public final class MarkerAnnotation extends Annotation { public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY = internalTypeNamePropertyFactory ( MarkerAnnotation . class ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( MarkerAnnotation . class , propertyList ) ; addProperty ( TYPE_NAME_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } MarkerAnnotation ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_NAME_PROPERTY ) { if ( get ) { return getTypeName ( ) ; } else { setTypeName ( ( Name ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final ChildPropertyDescriptor internalTypeNameProperty ( ) { return TYPE_NAME_PROPERTY ; } final int getNodeType0 ( ) { return MARKER_ANNOTATION ; } ASTNode clone0 ( AST target ) { MarkerAnnotation result = new MarkerAnnotation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setTypeName ( ( Name ) ASTNode . copySubtree ( target , getTypeName ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getTypeName ( ) ) ; } visitor . endVisit ( this ) ; } int memSize ( ) { return super . memSize ( ) ; } int treeSize ( ) { return memSize ( ) + ( this . typeName == null ? <NUM_LIT:0> : getTypeName ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class NumberLiteral extends Expression { public static final SimplePropertyDescriptor TOKEN_PROPERTY = new SimplePropertyDescriptor ( NumberLiteral . class , "<STR_LIT>" , String . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( NumberLiteral . class , propertyList ) ; addProperty ( TOKEN_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private String tokenValue = "<STR_LIT:0>" ; NumberLiteral ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == TOKEN_PROPERTY ) { if ( get ) { return getToken ( ) ; } else { setToken ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final int getNodeType0 ( ) { return NUMBER_LITERAL ; } ASTNode clone0 ( AST target ) { NumberLiteral result = new NumberLiteral ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setToken ( getToken ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } public String getToken ( ) { return this . tokenValue ; } public void setToken ( String token ) { if ( token == null || token . length ( ) == <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } Scanner scanner = this . ast . scanner ; char [ ] source = token . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( <NUM_LIT:0> , source . length ) ; scanner . tokenizeComments = false ; scanner . tokenizeWhiteSpace = false ; try { int tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameDoubleLiteral : case TerminalTokens . TokenNameIntegerLiteral : case TerminalTokens . TokenNameFloatingPointLiteral : case TerminalTokens . TokenNameLongLiteral : break ; case TerminalTokens . TokenNameMINUS : tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameDoubleLiteral : case TerminalTokens . TokenNameIntegerLiteral : case TerminalTokens . TokenNameFloatingPointLiteral : case TerminalTokens . TokenNameLongLiteral : break ; default : throw new IllegalArgumentException ( "<STR_LIT>" + token + "<STR_LIT:<>" ) ; } break ; default : throw new IllegalArgumentException ( "<STR_LIT>" + token + "<STR_LIT:<>" ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } finally { scanner . tokenizeComments = true ; scanner . tokenizeWhiteSpace = true ; } preValueChange ( TOKEN_PROPERTY ) ; this . tokenValue = token ; postValueChange ( TOKEN_PROPERTY ) ; } void internalSetToken ( String token ) { preValueChange ( TOKEN_PROPERTY ) ; this . tokenValue = token ; postValueChange ( TOKEN_PROPERTY ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> + stringSize ( this . tokenValue ) ; return size ; } int treeSize ( ) { return memSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class DoStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( DoStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( DoStatement . class , "<STR_LIT:body>" , Statement . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( DoStatement . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( BODY_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; private Statement body = null ; DoStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Statement ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return DO_STATEMENT ; } ASTNode clone0 ( AST target ) { DoStatement result = new DoStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . setBody ( ( Statement ) getBody ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getBody ( ) ) ; acceptChild ( visitor , getExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public Statement getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new Block ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Statement statement ) { if ( statement == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; this . body = statement ; postReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . internal . compiler . util . Util ; public final class TextElement extends ASTNode implements IDocElement { public static final SimplePropertyDescriptor TEXT_PROPERTY = new SimplePropertyDescriptor ( TextElement . class , "<STR_LIT:text>" , String . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( TextElement . class , propertyList ) ; addProperty ( TEXT_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private String text = Util . EMPTY_STRING ; TextElement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == TEXT_PROPERTY ) { if ( get ) { return getText ( ) ; } else { setText ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final int getNodeType0 ( ) { return TEXT_ELEMENT ; } ASTNode clone0 ( AST target ) { TextElement result = new TextElement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setText ( getText ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } public String getText ( ) { return this . text ; } public void setText ( String text ) { if ( text == null ) { throw new IllegalArgumentException ( ) ; } if ( text . indexOf ( "<STR_LIT>" ) > <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } preValueChange ( TEXT_PROPERTY ) ; this . text = text ; postValueChange ( TEXT_PROPERTY ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; if ( this . text != Util . EMPTY_STRING ) { size += stringSize ( this . text ) ; } return size ; } int treeSize ( ) { return memSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . ElementValuePair ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; class MemberValuePairBinding implements IMemberValuePairBinding { static final MemberValuePairBinding [ ] NoPair = new MemberValuePairBinding [ <NUM_LIT:0> ] ; private static final Object NoValue = new Object ( ) ; private static final Object [ ] EmptyArray = new Object [ <NUM_LIT:0> ] ; private ElementValuePair internalPair ; protected Object value = null ; protected BindingResolver bindingResolver ; static void appendValue ( Object value , StringBuffer buffer ) { if ( value instanceof Object [ ] ) { Object [ ] values = ( Object [ ] ) value ; buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> , l = values . length ; i < l ; i ++ ) { if ( i != <NUM_LIT:0> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; appendValue ( values [ i ] , buffer ) ; } buffer . append ( '<CHAR_LIT:}>' ) ; } else if ( value instanceof ITypeBinding ) { buffer . append ( ( ( ITypeBinding ) value ) . getName ( ) ) ; buffer . append ( "<STR_LIT:.class>" ) ; } else { buffer . append ( value ) ; } } static Object buildDOMValue ( final Object internalObject , BindingResolver resolver ) { if ( internalObject == null ) return null ; if ( internalObject instanceof Constant ) { Constant constant = ( Constant ) internalObject ; switch ( constant . typeID ( ) ) { case TypeIds . T_boolean : return Boolean . valueOf ( constant . booleanValue ( ) ) ; case TypeIds . T_byte : return new Byte ( constant . byteValue ( ) ) ; case TypeIds . T_char : return new Character ( constant . charValue ( ) ) ; case TypeIds . T_double : return new Double ( constant . doubleValue ( ) ) ; case TypeIds . T_float : return new Float ( constant . floatValue ( ) ) ; case TypeIds . T_int : return new Integer ( constant . intValue ( ) ) ; case TypeIds . T_long : return new Long ( constant . longValue ( ) ) ; case TypeIds . T_short : return new Short ( constant . shortValue ( ) ) ; default : return constant . stringValue ( ) ; } } else if ( internalObject instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { return resolver . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) internalObject ) ; } else if ( internalObject instanceof org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding ) { return resolver . getAnnotationInstance ( ( org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding ) internalObject ) ; } else if ( internalObject instanceof org . eclipse . jdt . internal . compiler . lookup . FieldBinding ) { return resolver . getVariableBinding ( ( org . eclipse . jdt . internal . compiler . lookup . FieldBinding ) internalObject ) ; } else if ( internalObject instanceof Object [ ] ) { Object [ ] elements = ( Object [ ] ) internalObject ; int length = elements . length ; Object [ ] values = length == <NUM_LIT:0> ? EmptyArray : new Object [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) values [ i ] = buildDOMValue ( elements [ i ] , resolver ) ; return values ; } return null ; } MemberValuePairBinding ( ElementValuePair pair , BindingResolver resolver ) { this . internalPair = pair ; this . bindingResolver = resolver ; } public IAnnotationBinding [ ] getAnnotations ( ) { return AnnotationBinding . NoAnnotations ; } public IJavaElement getJavaElement ( ) { return null ; } public String getKey ( ) { return null ; } public int getKind ( ) { return IBinding . MEMBER_VALUE_PAIR ; } public IMethodBinding getMethodBinding ( ) { return this . bindingResolver . getMethodBinding ( this . internalPair . getMethodBinding ( ) ) ; } public int getModifiers ( ) { return Modifier . NONE ; } public String getName ( ) { if ( this . internalPair == null ) return null ; final char [ ] membername = this . internalPair . getName ( ) ; return membername == null ? null : new String ( membername ) ; } public Object getValue ( ) { if ( this . value == null ) init ( ) ; return this . value == NoValue ? null : this . value ; } private void init ( ) { this . value = buildDOMValue ( this . internalPair . getValue ( ) , this . bindingResolver ) ; if ( this . value == null ) this . value = NoValue ; IMethodBinding methodBinding = getMethodBinding ( ) ; if ( methodBinding . getReturnType ( ) . isArray ( ) && ! this . value . getClass ( ) . isArray ( ) ) { this . value = new Object [ ] { this . value } ; } } char [ ] internalName ( ) { return this . internalPair == null ? null : this . internalPair . getName ( ) ; } public boolean isDefault ( ) { Object value2 = getValue ( ) ; Object defaultValue = getMethodBinding ( ) . getDefaultValue ( ) ; if ( value2 instanceof IBinding ) { if ( defaultValue instanceof IBinding ) { return ( ( IBinding ) value2 ) . isEqualTo ( ( IBinding ) defaultValue ) ; } return false ; } if ( defaultValue == null ) return false ; return defaultValue . equals ( value2 ) ; } public boolean isDeprecated ( ) { MethodBinding methodBinding = this . internalPair . getMethodBinding ( ) ; return methodBinding == null ? false : methodBinding . isDeprecated ( ) ; } public boolean isEqualTo ( IBinding binding ) { if ( this == binding ) return true ; if ( binding . getKind ( ) != IBinding . MEMBER_VALUE_PAIR ) return false ; IMemberValuePairBinding otherMemberValuePairBinding = ( IMemberValuePairBinding ) binding ; if ( ! getMethodBinding ( ) . isEqualTo ( otherMemberValuePairBinding . getMethodBinding ( ) ) ) { return false ; } Object otherValue = otherMemberValuePairBinding . getValue ( ) ; Object currentValue = getValue ( ) ; if ( currentValue == null ) { return otherValue == null ; } if ( currentValue instanceof IBinding ) { if ( otherValue instanceof IBinding ) { return ( ( IBinding ) currentValue ) . isEqualTo ( ( IBinding ) otherValue ) ; } return false ; } if ( currentValue . getClass ( ) . isArray ( ) ) { if ( ! otherValue . getClass ( ) . isArray ( ) ) { return false ; } Object [ ] currentValues = ( Object [ ] ) currentValue ; Object [ ] otherValues = ( Object [ ] ) otherValue ; final int length = currentValues . length ; if ( length != otherValues . length ) { return false ; } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { Object current = currentValues [ i ] ; Object other = otherValues [ i ] ; if ( current instanceof IBinding ) { if ( ! ( other instanceof IBinding ) ) { return false ; } if ( ! ( ( IBinding ) current ) . isEqualTo ( ( IBinding ) other ) ) { return false ; } } else if ( ! current . equals ( other ) ) { return false ; } } return true ; } else { return currentValue . equals ( otherValue ) ; } } public boolean isRecovered ( ) { return false ; } public boolean isSynthetic ( ) { return false ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( getName ( ) ) ; buffer . append ( "<STR_LIT:U+0020=U+0020>" ) ; appendValue ( getValue ( ) , buffer ) ; return buffer . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ClassInstanceCreation extends Expression { public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( ClassInstanceCreation . class , "<STR_LIT>" , Type . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ClassInstanceCreation . class , "<STR_LIT>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( ClassInstanceCreation . class , "<STR_LIT:name>" , Name . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( ClassInstanceCreation . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( ClassInstanceCreation . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; public static final ChildPropertyDescriptor ANONYMOUS_CLASS_DECLARATION_PROPERTY = new ChildPropertyDescriptor ( ClassInstanceCreation . class , "<STR_LIT>" , AnonymousClassDeclaration . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( ClassInstanceCreation . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( ARGUMENTS_PROPERTY , properyList ) ; addProperty ( ANONYMOUS_CLASS_DECLARATION_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:6> ) ; createPropertyList ( ClassInstanceCreation . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( TYPE_ARGUMENTS_PROPERTY , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( ARGUMENTS_PROPERTY , properyList ) ; addProperty ( ANONYMOUS_CLASS_DECLARATION_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Expression optionalExpression = null ; private ASTNode . NodeList typeArguments = null ; private Name typeName = null ; private Type type = null ; private ASTNode . NodeList arguments = new ASTNode . NodeList ( ARGUMENTS_PROPERTY ) ; private AnonymousClassDeclaration optionalAnonymousClassDeclaration = null ; ClassInstanceCreation ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3_INTERNAL ) { this . typeArguments = new ASTNode . NodeList ( TYPE_ARGUMENTS_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( Name ) child ) ; return null ; } } if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } if ( property == ANONYMOUS_CLASS_DECLARATION_PROPERTY ) { if ( get ) { return getAnonymousClassDeclaration ( ) ; } else { setAnonymousClassDeclaration ( ( AnonymousClassDeclaration ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == ARGUMENTS_PROPERTY ) { return arguments ( ) ; } if ( property == TYPE_ARGUMENTS_PROPERTY ) { return typeArguments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return CLASS_INSTANCE_CREATION ; } ASTNode clone0 ( AST target ) { ClassInstanceCreation result = new ClassInstanceCreation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setExpression ( ( Expression ) ASTNode . copySubtree ( target , getExpression ( ) ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . setName ( ( Name ) getName ( ) . clone ( target ) ) ; } if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { result . typeArguments ( ) . addAll ( ASTNode . copySubtrees ( target , typeArguments ( ) ) ) ; result . setType ( ( Type ) getType ( ) . clone ( target ) ) ; } result . arguments ( ) . addAll ( ASTNode . copySubtrees ( target , arguments ( ) ) ) ; result . setAnonymousClassDeclaration ( ( AnonymousClassDeclaration ) ASTNode . copySubtree ( target , getAnonymousClassDeclaration ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { acceptChild ( visitor , getName ( ) ) ; } if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { acceptChildren ( visitor , this . typeArguments ) ; acceptChild ( visitor , getType ( ) ) ; } acceptChildren ( visitor , this . arguments ) ; acceptChild ( visitor , getAnonymousClassDeclaration ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { return this . optionalExpression ; } public void setExpression ( Expression expression ) { ASTNode oldChild = this . optionalExpression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . optionalExpression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public List typeArguments ( ) { if ( this . typeArguments == null ) { unsupportedIn2 ( ) ; } return this . typeArguments ; } public Name getName ( ) { return internalGetName ( ) ; } Name internalGetName ( ) { supportedOnlyIn2 ( ) ; if ( this . typeName == null ) { synchronized ( this ) { if ( this . typeName == null ) { preLazyInit ( ) ; this . typeName = new SimpleName ( this . ast ) ; postLazyInit ( this . typeName , NAME_PROPERTY ) ; } } } return this . typeName ; } public void setName ( Name name ) { internalSetName ( name ) ; } void internalSetName ( Name name ) { supportedOnlyIn2 ( ) ; if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . typeName ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . typeName = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } public Type getType ( ) { unsupportedIn2 ( ) ; if ( this . type == null ) { synchronized ( this ) { if ( this . type == null ) { preLazyInit ( ) ; this . type = new SimpleType ( this . ast ) ; postLazyInit ( this . type , TYPE_PROPERTY ) ; } } } return this . type ; } public void setType ( Type type ) { unsupportedIn2 ( ) ; if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . type ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . type = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public List arguments ( ) { return this . arguments ; } public AnonymousClassDeclaration getAnonymousClassDeclaration ( ) { return this . optionalAnonymousClassDeclaration ; } public void setAnonymousClassDeclaration ( AnonymousClassDeclaration decl ) { ASTNode oldChild = this . optionalAnonymousClassDeclaration ; preReplaceChild ( oldChild , decl , ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; this . optionalAnonymousClassDeclaration = decl ; postReplaceChild ( oldChild , decl , ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; } public IMethodBinding resolveConstructorBinding ( ) { return this . ast . getBindingResolver ( ) . resolveConstructor ( this ) ; } public boolean isResolvedTypeInferredFromExpectedType ( ) { return this . ast . getBindingResolver ( ) . isResolvedTypeInferredFromExpectedType ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:6> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . type == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + ( this . optionalExpression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . typeArguments == null ? <NUM_LIT:0> : this . typeArguments . listSize ( ) ) + ( this . arguments == null ? <NUM_LIT:0> : this . arguments . listSize ( ) ) + ( this . optionalAnonymousClassDeclaration == null ? <NUM_LIT:0> : getAnonymousClassDeclaration ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom . rewrite ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . CompilationUnit ; public class TargetSourceRangeComputer { public static final class SourceRange { private int startPosition ; private int length ; public SourceRange ( int startPosition , int length ) { this . startPosition = startPosition ; this . length = length ; } public int getStartPosition ( ) { return this . startPosition ; } public int getLength ( ) { return this . length ; } } public TargetSourceRangeComputer ( ) { } public SourceRange computeSourceRange ( ASTNode node ) { ASTNode root = node . getRoot ( ) ; if ( root instanceof CompilationUnit ) { CompilationUnit cu = ( CompilationUnit ) root ; return new SourceRange ( cu . getExtendedStartPosition ( node ) , cu . getExtendedLength ( node ) ) ; } return new SourceRange ( node . getStartPosition ( ) , node . getLength ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom . rewrite ; import java . util . Collections ; import java . util . List ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . ChildListPropertyDescriptor ; import org . eclipse . jdt . core . dom . FieldDeclaration ; import org . eclipse . jdt . core . dom . Statement ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . internal . core . dom . rewrite . ListRewriteEvent ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEvent ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; import org . eclipse . text . edits . TextEditGroup ; public final class ListRewrite { private ASTNode parent ; private StructuralPropertyDescriptor childProperty ; private ASTRewrite rewriter ; ListRewrite ( ASTRewrite rewriter , ASTNode parent , StructuralPropertyDescriptor childProperty ) { this . rewriter = rewriter ; this . parent = parent ; this . childProperty = childProperty ; } private RewriteEventStore getRewriteStore ( ) { return this . rewriter . getRewriteEventStore ( ) ; } private ListRewriteEvent getEvent ( ) { return getRewriteStore ( ) . getListEvent ( this . parent , this . childProperty , true ) ; } public ASTNode getParent ( ) { return this . parent ; } public StructuralPropertyDescriptor getLocationInParent ( ) { return this . childProperty ; } public void remove ( ASTNode node , TextEditGroup editGroup ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } RewriteEvent event = getEvent ( ) . removeEntry ( node ) ; if ( editGroup != null ) { getRewriteStore ( ) . setEventEditGroup ( event , editGroup ) ; } } public ASTRewrite getASTRewrite ( ) { return this . rewriter ; } public void replace ( ASTNode node , ASTNode replacement , TextEditGroup editGroup ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } RewriteEvent event = getEvent ( ) . replaceEntry ( node , replacement ) ; if ( editGroup != null ) { getRewriteStore ( ) . setEventEditGroup ( event , editGroup ) ; } } public void insertAfter ( ASTNode node , ASTNode previousElement , TextEditGroup editGroup ) { if ( node == null || previousElement == null ) { throw new IllegalArgumentException ( ) ; } int index = getEvent ( ) . getIndex ( previousElement , ListRewriteEvent . BOTH ) ; if ( index == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } internalInsertAt ( node , index + <NUM_LIT:1> , true , editGroup ) ; } public void insertBefore ( ASTNode node , ASTNode nextElement , TextEditGroup editGroup ) { if ( node == null || nextElement == null ) { throw new IllegalArgumentException ( ) ; } int index = getEvent ( ) . getIndex ( nextElement , ListRewriteEvent . BOTH ) ; if ( index == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } internalInsertAt ( node , index , false , editGroup ) ; } public void insertFirst ( ASTNode node , TextEditGroup editGroup ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } internalInsertAt ( node , <NUM_LIT:0> , false , editGroup ) ; } public void insertLast ( ASTNode node , TextEditGroup editGroup ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } internalInsertAt ( node , - <NUM_LIT:1> , true , editGroup ) ; } public void insertAt ( ASTNode node , int index , TextEditGroup editGroup ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } internalInsertAt ( node , index , isInsertBoundToPreviousByDefault ( node ) , editGroup ) ; } private void internalInsertAt ( ASTNode node , int index , boolean boundToPrevious , TextEditGroup editGroup ) { RewriteEvent event = getEvent ( ) . insert ( node , index ) ; if ( boundToPrevious ) { getRewriteStore ( ) . setInsertBoundToPrevious ( node ) ; } if ( editGroup != null ) { getRewriteStore ( ) . setEventEditGroup ( event , editGroup ) ; } } private ASTNode createTargetNode ( ASTNode first , ASTNode last , boolean isMove , ASTNode replacingNode , TextEditGroup editGroup ) { if ( first == null || last == null ) { throw new IllegalArgumentException ( ) ; } NodeInfoStore nodeStore = this . rewriter . getNodeStore ( ) ; ASTNode placeholder = nodeStore . newPlaceholderNode ( first . getNodeType ( ) ) ; if ( placeholder == null ) { throw new IllegalArgumentException ( "<STR_LIT>" + first . getClass ( ) . getName ( ) ) ; } Block internalPlaceHolder = nodeStore . createCollapsePlaceholder ( ) ; CopySourceInfo info = getRewriteStore ( ) . createRangeCopy ( this . parent , this . childProperty , first , last , isMove , internalPlaceHolder , replacingNode , editGroup ) ; nodeStore . markAsCopyTarget ( placeholder , info ) ; return placeholder ; } public final ASTNode createCopyTarget ( ASTNode first , ASTNode last ) { if ( first == last ) { return this . rewriter . createCopyTarget ( first ) ; } else { return createTargetNode ( first , last , false , null , null ) ; } } public final ASTNode createMoveTarget ( ASTNode first , ASTNode last ) { return createMoveTarget ( first , last , null , null ) ; } public final ASTNode createMoveTarget ( ASTNode first , ASTNode last , ASTNode replacingNode , TextEditGroup editGroup ) { if ( first == last ) { replace ( first , replacingNode , editGroup ) ; return this . rewriter . createMoveTarget ( first ) ; } else { return createTargetNode ( first , last , true , replacingNode , editGroup ) ; } } private boolean isInsertBoundToPreviousByDefault ( ASTNode node ) { return ( node instanceof Statement || node instanceof FieldDeclaration ) ; } public List getOriginalList ( ) { List list = ( List ) getEvent ( ) . getOriginalValue ( ) ; return Collections . unmodifiableList ( list ) ; } public List getRewrittenList ( ) { List list = ( List ) getEvent ( ) . getNewValue ( ) ; return Collections . unmodifiableList ( list ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom . rewrite ; public interface ITrackedNodePosition { public int getStartPosition ( ) ; public int getLength ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . dom . rewrite ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . NullProgressMonitor ; import org . eclipse . core . runtime . SubProgressMonitor ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IImportDeclaration ; import org . eclipse . jdt . core . ITypeRoot ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . dom . * ; import org . eclipse . jdt . internal . core . dom . rewrite . ImportRewriteAnalyzer ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; import org . eclipse . text . edits . MultiTextEdit ; import org . eclipse . text . edits . TextEdit ; public final class ImportRewrite { public static abstract class ImportRewriteContext { public final static int RES_NAME_FOUND = <NUM_LIT:1> ; public final static int RES_NAME_UNKNOWN = <NUM_LIT:2> ; public final static int RES_NAME_CONFLICT = <NUM_LIT:3> ; public final static int KIND_TYPE = <NUM_LIT:1> ; public final static int KIND_STATIC_FIELD = <NUM_LIT:2> ; public final static int KIND_STATIC_METHOD = <NUM_LIT:3> ; public abstract int findInContext ( String qualifier , String name , int kind ) ; } private static final char STATIC_PREFIX = '<CHAR_LIT>' ; private static final char NORMAL_PREFIX = '<CHAR_LIT>' ; private final ImportRewriteContext defaultContext ; private final ICompilationUnit compilationUnit ; private final CompilationUnit astRoot ; private final boolean restoreExistingImports ; private final List existingImports ; private final Map importsKindMap ; private String [ ] importOrder ; private int importOnDemandThreshold ; private int staticImportOnDemandThreshold ; private List addedImports ; private List removedImports ; private String [ ] createdImports ; private String [ ] createdStaticImports ; private boolean filterImplicitImports ; private boolean useContextToFilterImplicitImports ; public static ImportRewrite create ( ICompilationUnit cu , boolean restoreExistingImports ) throws JavaModelException { if ( cu == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } List existingImport = null ; if ( restoreExistingImports ) { existingImport = new ArrayList ( ) ; IImportDeclaration [ ] imports = cu . getImports ( ) ; for ( int i = <NUM_LIT:0> ; i < imports . length ; i ++ ) { IImportDeclaration curr = imports [ i ] ; char prefix = Flags . isStatic ( curr . getFlags ( ) ) ? STATIC_PREFIX : NORMAL_PREFIX ; existingImport . add ( prefix + curr . getElementName ( ) ) ; } } return new ImportRewrite ( cu , null , existingImport ) ; } public static ImportRewrite create ( CompilationUnit astRoot , boolean restoreExistingImports ) { if ( astRoot == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } ITypeRoot typeRoot = astRoot . getTypeRoot ( ) ; if ( ! ( typeRoot instanceof ICompilationUnit ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } List existingImport = null ; if ( restoreExistingImports ) { existingImport = new ArrayList ( ) ; List imports = astRoot . imports ( ) ; for ( int i = <NUM_LIT:0> ; i < imports . size ( ) ; i ++ ) { ImportDeclaration curr = ( ImportDeclaration ) imports . get ( i ) ; StringBuffer buf = new StringBuffer ( ) ; buf . append ( curr . isStatic ( ) ? STATIC_PREFIX : NORMAL_PREFIX ) . append ( curr . getName ( ) . getFullyQualifiedName ( ) ) ; if ( curr . isOnDemand ( ) ) { if ( buf . length ( ) > <NUM_LIT:1> ) buf . append ( '<CHAR_LIT:.>' ) ; buf . append ( '<CHAR_LIT>' ) ; } existingImport . add ( buf . toString ( ) ) ; } } return new ImportRewrite ( ( ICompilationUnit ) typeRoot , astRoot , existingImport ) ; } private ImportRewrite ( ICompilationUnit cu , CompilationUnit astRoot , List existingImports ) { this . compilationUnit = cu ; this . astRoot = astRoot ; if ( existingImports != null ) { this . existingImports = existingImports ; this . restoreExistingImports = ! existingImports . isEmpty ( ) ; } else { this . existingImports = new ArrayList ( ) ; this . restoreExistingImports = false ; } this . filterImplicitImports = true ; this . useContextToFilterImplicitImports = false ; this . defaultContext = new ImportRewriteContext ( ) { public int findInContext ( String qualifier , String name , int kind ) { return findInImports ( qualifier , name , kind ) ; } } ; this . addedImports = null ; this . removedImports = null ; this . createdImports = null ; this . createdStaticImports = null ; this . importOrder = CharOperation . NO_STRINGS ; this . importOnDemandThreshold = <NUM_LIT> ; this . staticImportOnDemandThreshold = <NUM_LIT> ; this . importsKindMap = new HashMap ( ) ; } public void setImportOrder ( String [ ] order ) { if ( order == null ) throw new IllegalArgumentException ( "<STR_LIT>" ) ; this . importOrder = order ; } public void setOnDemandImportThreshold ( int threshold ) { if ( threshold <= <NUM_LIT:0> ) throw new IllegalArgumentException ( "<STR_LIT>" ) ; this . importOnDemandThreshold = threshold ; } public void setStaticOnDemandImportThreshold ( int threshold ) { if ( threshold <= <NUM_LIT:0> ) throw new IllegalArgumentException ( "<STR_LIT>" ) ; this . staticImportOnDemandThreshold = threshold ; } public ICompilationUnit getCompilationUnit ( ) { return this . compilationUnit ; } public ImportRewriteContext getDefaultImportRewriteContext ( ) { return this . defaultContext ; } public void setFilterImplicitImports ( boolean filterImplicitImports ) { this . filterImplicitImports = filterImplicitImports ; } public void setUseContextToFilterImplicitImports ( boolean useContextToFilterImplicitImports ) { this . useContextToFilterImplicitImports = useContextToFilterImplicitImports ; } private static int compareImport ( char prefix , String qualifier , String name , String curr ) { if ( curr . charAt ( <NUM_LIT:0> ) != prefix || ! curr . endsWith ( name ) ) { return ImportRewriteContext . RES_NAME_UNKNOWN ; } curr = curr . substring ( <NUM_LIT:1> ) ; if ( curr . length ( ) == name . length ( ) ) { if ( qualifier . length ( ) == <NUM_LIT:0> ) { return ImportRewriteContext . RES_NAME_FOUND ; } return ImportRewriteContext . RES_NAME_CONFLICT ; } int dotPos = curr . length ( ) - name . length ( ) - <NUM_LIT:1> ; if ( curr . charAt ( dotPos ) != '<CHAR_LIT:.>' ) { return ImportRewriteContext . RES_NAME_UNKNOWN ; } if ( qualifier . length ( ) != dotPos || ! curr . startsWith ( qualifier ) ) { return ImportRewriteContext . RES_NAME_CONFLICT ; } return ImportRewriteContext . RES_NAME_FOUND ; } final int findInImports ( String qualifier , String name , int kind ) { boolean allowAmbiguity = ( kind == ImportRewriteContext . KIND_STATIC_METHOD ) || ( name . length ( ) == <NUM_LIT:1> && name . charAt ( <NUM_LIT:0> ) == '<CHAR_LIT>' ) ; List imports = this . existingImports ; char prefix = ( kind == ImportRewriteContext . KIND_TYPE ) ? NORMAL_PREFIX : STATIC_PREFIX ; for ( int i = imports . size ( ) - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { String curr = ( String ) imports . get ( i ) ; int res = compareImport ( prefix , qualifier , name , curr ) ; if ( res != ImportRewriteContext . RES_NAME_UNKNOWN ) { if ( ! allowAmbiguity || res == ImportRewriteContext . RES_NAME_FOUND ) { if ( prefix != STATIC_PREFIX ) { return res ; } Object currKind = this . importsKindMap . get ( curr . substring ( <NUM_LIT:1> ) ) ; if ( currKind != null && currKind . equals ( this . importsKindMap . get ( qualifier + '<CHAR_LIT:.>' + name ) ) ) { return res ; } } } } if ( this . filterImplicitImports && this . useContextToFilterImplicitImports ) { String fPackageName = this . compilationUnit . getParent ( ) . getElementName ( ) ; String mainTypeSimpleName = JavaCore . removeJavaLikeExtension ( this . compilationUnit . getElementName ( ) ) ; String fMainTypeName = Util . concatenateName ( fPackageName , mainTypeSimpleName , '<CHAR_LIT:.>' ) ; if ( kind == ImportRewriteContext . KIND_TYPE && ( qualifier . equals ( fPackageName ) || fMainTypeName . equals ( Util . concatenateName ( qualifier , name , '<CHAR_LIT:.>' ) ) ) ) return ImportRewriteContext . RES_NAME_FOUND ; } return ImportRewriteContext . RES_NAME_UNKNOWN ; } public Type addImportFromSignature ( String typeSig , AST ast ) { return addImportFromSignature ( typeSig , ast , this . defaultContext ) ; } public Type addImportFromSignature ( String typeSig , AST ast , ImportRewriteContext context ) { if ( typeSig == null || typeSig . length ( ) == <NUM_LIT:0> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } int sigKind = Signature . getTypeSignatureKind ( typeSig ) ; switch ( sigKind ) { case Signature . BASE_TYPE_SIGNATURE : return ast . newPrimitiveType ( PrimitiveType . toCode ( Signature . toString ( typeSig ) ) ) ; case Signature . ARRAY_TYPE_SIGNATURE : Type elementType = addImportFromSignature ( Signature . getElementType ( typeSig ) , ast , context ) ; return ast . newArrayType ( elementType , Signature . getArrayCount ( typeSig ) ) ; case Signature . CLASS_TYPE_SIGNATURE : String erasureSig = Signature . getTypeErasure ( typeSig ) ; String erasureName = Signature . toString ( erasureSig ) ; if ( erasureSig . charAt ( <NUM_LIT:0> ) == Signature . C_RESOLVED ) { erasureName = internalAddImport ( erasureName , context ) ; } Type baseType = ast . newSimpleType ( ast . newName ( erasureName ) ) ; String [ ] typeArguments = Signature . getTypeArguments ( typeSig ) ; if ( typeArguments . length > <NUM_LIT:0> ) { ParameterizedType type = ast . newParameterizedType ( baseType ) ; List argNodes = type . typeArguments ( ) ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { String curr = typeArguments [ i ] ; if ( containsNestedCapture ( curr ) ) { argNodes . add ( ast . newWildcardType ( ) ) ; } else { argNodes . add ( addImportFromSignature ( curr , ast , context ) ) ; } } return type ; } return baseType ; case Signature . TYPE_VARIABLE_SIGNATURE : return ast . newSimpleType ( ast . newSimpleName ( Signature . toString ( typeSig ) ) ) ; case Signature . WILDCARD_TYPE_SIGNATURE : WildcardType wildcardType = ast . newWildcardType ( ) ; char ch = typeSig . charAt ( <NUM_LIT:0> ) ; if ( ch != Signature . C_STAR ) { Type bound = addImportFromSignature ( typeSig . substring ( <NUM_LIT:1> ) , ast , context ) ; wildcardType . setBound ( bound , ch == Signature . C_EXTENDS ) ; } return wildcardType ; case Signature . CAPTURE_TYPE_SIGNATURE : return addImportFromSignature ( typeSig . substring ( <NUM_LIT:1> ) , ast , context ) ; default : throw new IllegalArgumentException ( "<STR_LIT>" + typeSig ) ; } } public String addImport ( ITypeBinding binding ) { return addImport ( binding , this . defaultContext ) ; } public String addImport ( ITypeBinding binding , ImportRewriteContext context ) { if ( binding . isPrimitive ( ) || binding . isTypeVariable ( ) || binding . isRecovered ( ) ) { return binding . getName ( ) ; } ITypeBinding normalizedBinding = normalizeTypeBinding ( binding ) ; if ( normalizedBinding == null ) { return "<STR_LIT>" ; } if ( normalizedBinding . isWildcardType ( ) ) { StringBuffer res = new StringBuffer ( "<STR_LIT:?>" ) ; ITypeBinding bound = normalizedBinding . getBound ( ) ; if ( bound != null && ! bound . isWildcardType ( ) && ! bound . isCapture ( ) ) { if ( normalizedBinding . isUpperbound ( ) ) { res . append ( "<STR_LIT>" ) ; } else { res . append ( "<STR_LIT>" ) ; } res . append ( addImport ( bound , context ) ) ; } return res . toString ( ) ; } if ( normalizedBinding . isArray ( ) ) { StringBuffer res = new StringBuffer ( addImport ( normalizedBinding . getElementType ( ) , context ) ) ; for ( int i = normalizedBinding . getDimensions ( ) ; i > <NUM_LIT:0> ; i -- ) { res . append ( "<STR_LIT:[]>" ) ; } return res . toString ( ) ; } String qualifiedName = getRawQualifiedName ( normalizedBinding ) ; if ( qualifiedName . length ( ) > <NUM_LIT:0> ) { String str = internalAddImport ( qualifiedName , context ) ; ITypeBinding [ ] typeArguments = normalizedBinding . getTypeArguments ( ) ; if ( typeArguments . length > <NUM_LIT:0> ) { StringBuffer res = new StringBuffer ( str ) ; res . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( i > <NUM_LIT:0> ) { res . append ( '<CHAR_LIT:U+002C>' ) ; } ITypeBinding curr = typeArguments [ i ] ; if ( containsNestedCapture ( curr , false ) ) { res . append ( '<CHAR_LIT>' ) ; } else { res . append ( addImport ( curr , context ) ) ; } } res . append ( '<CHAR_LIT:>>' ) ; return res . toString ( ) ; } return str ; } return getRawName ( normalizedBinding ) ; } private boolean containsNestedCapture ( ITypeBinding binding , boolean isNested ) { if ( binding == null || binding . isPrimitive ( ) || binding . isTypeVariable ( ) ) { return false ; } if ( binding . isCapture ( ) ) { if ( isNested ) { return true ; } return containsNestedCapture ( binding . getWildcard ( ) , true ) ; } if ( binding . isWildcardType ( ) ) { return containsNestedCapture ( binding . getBound ( ) , true ) ; } if ( binding . isArray ( ) ) { return containsNestedCapture ( binding . getElementType ( ) , true ) ; } ITypeBinding [ ] typeArguments = binding . getTypeArguments ( ) ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( containsNestedCapture ( typeArguments [ i ] , true ) ) { return true ; } } return false ; } private boolean containsNestedCapture ( String signature ) { return signature . length ( ) > <NUM_LIT:1> && signature . indexOf ( Signature . C_CAPTURE , <NUM_LIT:1> ) != - <NUM_LIT:1> ; } private static ITypeBinding normalizeTypeBinding ( ITypeBinding binding ) { if ( binding != null && ! binding . isNullType ( ) && ! "<STR_LIT>" . equals ( binding . getName ( ) ) ) { if ( binding . isAnonymous ( ) ) { ITypeBinding [ ] baseBindings = binding . getInterfaces ( ) ; if ( baseBindings . length > <NUM_LIT:0> ) { return baseBindings [ <NUM_LIT:0> ] ; } return binding . getSuperclass ( ) ; } if ( binding . isCapture ( ) ) { return binding . getWildcard ( ) ; } return binding ; } return null ; } public Type addImport ( ITypeBinding binding , AST ast ) { return addImport ( binding , ast , this . defaultContext ) ; } public Type addImport ( ITypeBinding binding , AST ast , ImportRewriteContext context ) { if ( binding . isPrimitive ( ) ) { return ast . newPrimitiveType ( PrimitiveType . toCode ( binding . getName ( ) ) ) ; } ITypeBinding normalizedBinding = normalizeTypeBinding ( binding ) ; if ( normalizedBinding == null ) { return ast . newSimpleType ( ast . newSimpleName ( "<STR_LIT>" ) ) ; } if ( normalizedBinding . isTypeVariable ( ) ) { return ast . newSimpleType ( ast . newSimpleName ( binding . getName ( ) ) ) ; } if ( normalizedBinding . isWildcardType ( ) ) { WildcardType wcType = ast . newWildcardType ( ) ; ITypeBinding bound = normalizedBinding . getBound ( ) ; if ( bound != null && ! bound . isWildcardType ( ) && ! bound . isCapture ( ) ) { Type boundType = addImport ( bound , ast , context ) ; wcType . setBound ( boundType , normalizedBinding . isUpperbound ( ) ) ; } return wcType ; } if ( normalizedBinding . isArray ( ) ) { Type elementType = addImport ( normalizedBinding . getElementType ( ) , ast , context ) ; return ast . newArrayType ( elementType , normalizedBinding . getDimensions ( ) ) ; } String qualifiedName = getRawQualifiedName ( normalizedBinding ) ; if ( qualifiedName . length ( ) > <NUM_LIT:0> ) { String res = internalAddImport ( qualifiedName , context ) ; ITypeBinding [ ] typeArguments = normalizedBinding . getTypeArguments ( ) ; if ( typeArguments . length > <NUM_LIT:0> ) { Type erasureType = ast . newSimpleType ( ast . newName ( res ) ) ; ParameterizedType paramType = ast . newParameterizedType ( erasureType ) ; List arguments = paramType . typeArguments ( ) ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { ITypeBinding curr = typeArguments [ i ] ; if ( containsNestedCapture ( curr , false ) ) { arguments . add ( ast . newWildcardType ( ) ) ; } else { arguments . add ( addImport ( curr , ast , context ) ) ; } } return paramType ; } return ast . newSimpleType ( ast . newName ( res ) ) ; } return ast . newSimpleType ( ast . newName ( getRawName ( normalizedBinding ) ) ) ; } public String addImport ( String qualifiedTypeName , ImportRewriteContext context ) { int angleBracketOffset = qualifiedTypeName . indexOf ( '<CHAR_LIT>' ) ; if ( angleBracketOffset != - <NUM_LIT:1> ) { return internalAddImport ( qualifiedTypeName . substring ( <NUM_LIT:0> , angleBracketOffset ) , context ) + qualifiedTypeName . substring ( angleBracketOffset ) ; } int bracketOffset = qualifiedTypeName . indexOf ( '<CHAR_LIT:[>' ) ; if ( bracketOffset != - <NUM_LIT:1> ) { return internalAddImport ( qualifiedTypeName . substring ( <NUM_LIT:0> , bracketOffset ) , context ) + qualifiedTypeName . substring ( bracketOffset ) ; } return internalAddImport ( qualifiedTypeName , context ) ; } public String addImport ( String qualifiedTypeName ) { return addImport ( qualifiedTypeName , this . defaultContext ) ; } public String addStaticImport ( IBinding binding ) { return addStaticImport ( binding , this . defaultContext ) ; } public String addStaticImport ( IBinding binding , ImportRewriteContext context ) { if ( Modifier . isStatic ( binding . getModifiers ( ) ) ) { if ( binding instanceof IVariableBinding ) { IVariableBinding variableBinding = ( IVariableBinding ) binding ; if ( variableBinding . isField ( ) ) { ITypeBinding declaringType = variableBinding . getDeclaringClass ( ) ; return addStaticImport ( getRawQualifiedName ( declaringType ) , binding . getName ( ) , true , context ) ; } } else if ( binding instanceof IMethodBinding ) { ITypeBinding declaringType = ( ( IMethodBinding ) binding ) . getDeclaringClass ( ) ; return addStaticImport ( getRawQualifiedName ( declaringType ) , binding . getName ( ) , false , context ) ; } } throw new IllegalArgumentException ( "<STR_LIT>" ) ; } public String addStaticImport ( String declaringTypeName , String simpleName , boolean isField ) { return addStaticImport ( declaringTypeName , simpleName , isField , this . defaultContext ) ; } public String addStaticImport ( String declaringTypeName , String simpleName , boolean isField , ImportRewriteContext context ) { String key = declaringTypeName + '<CHAR_LIT:.>' + simpleName ; if ( declaringTypeName . indexOf ( '<CHAR_LIT:.>' ) == - <NUM_LIT:1> ) { return key ; } if ( context == null ) { context = this . defaultContext ; } int kind = isField ? ImportRewriteContext . KIND_STATIC_FIELD : ImportRewriteContext . KIND_STATIC_METHOD ; this . importsKindMap . put ( key , new Integer ( kind ) ) ; int res = context . findInContext ( declaringTypeName , simpleName , kind ) ; if ( res == ImportRewriteContext . RES_NAME_CONFLICT ) { return key ; } if ( res == ImportRewriteContext . RES_NAME_UNKNOWN ) { addEntry ( STATIC_PREFIX + key ) ; } return simpleName ; } private String internalAddImport ( String fullTypeName , ImportRewriteContext context ) { int idx = fullTypeName . lastIndexOf ( '<CHAR_LIT:.>' ) ; String typeContainerName , typeName ; if ( idx != - <NUM_LIT:1> ) { typeContainerName = fullTypeName . substring ( <NUM_LIT:0> , idx ) ; typeName = fullTypeName . substring ( idx + <NUM_LIT:1> ) ; } else { typeContainerName = "<STR_LIT>" ; typeName = fullTypeName ; } if ( typeContainerName . length ( ) == <NUM_LIT:0> && PrimitiveType . toCode ( typeName ) != null ) { return fullTypeName ; } if ( context == null ) context = this . defaultContext ; int res = context . findInContext ( typeContainerName , typeName , ImportRewriteContext . KIND_TYPE ) ; if ( res == ImportRewriteContext . RES_NAME_CONFLICT ) { return fullTypeName ; } if ( res == ImportRewriteContext . RES_NAME_UNKNOWN ) { addEntry ( NORMAL_PREFIX + fullTypeName ) ; } return typeName ; } private void addEntry ( String entry ) { this . existingImports . add ( entry ) ; if ( this . removedImports != null ) { if ( this . removedImports . remove ( entry ) ) { return ; } } if ( this . addedImports == null ) { this . addedImports = new ArrayList ( ) ; } this . addedImports . add ( entry ) ; } private boolean removeEntry ( String entry ) { if ( this . existingImports . remove ( entry ) ) { if ( this . addedImports != null ) { if ( this . addedImports . remove ( entry ) ) { return true ; } } if ( this . removedImports == null ) { this . removedImports = new ArrayList ( ) ; } this . removedImports . add ( entry ) ; return true ; } return false ; } public boolean removeImport ( String qualifiedName ) { return removeEntry ( NORMAL_PREFIX + qualifiedName ) ; } public boolean removeStaticImport ( String qualifiedName ) { return removeEntry ( STATIC_PREFIX + qualifiedName ) ; } private static String getRawName ( ITypeBinding normalizedBinding ) { return normalizedBinding . getTypeDeclaration ( ) . getName ( ) ; } private static String getRawQualifiedName ( ITypeBinding normalizedBinding ) { return normalizedBinding . getTypeDeclaration ( ) . getQualifiedName ( ) ; } public final TextEdit rewriteImports ( IProgressMonitor monitor ) throws CoreException { if ( monitor == null ) { monitor = new NullProgressMonitor ( ) ; } try { monitor . beginTask ( Messages . bind ( Messages . importRewrite_processDescription ) , <NUM_LIT:2> ) ; if ( ! hasRecordedChanges ( ) ) { this . createdImports = CharOperation . NO_STRINGS ; this . createdStaticImports = CharOperation . NO_STRINGS ; return new MultiTextEdit ( ) ; } CompilationUnit usedAstRoot = this . astRoot ; if ( usedAstRoot == null ) { ASTParser parser = ASTParser . newParser ( AST . JLS4 ) ; parser . setSource ( this . compilationUnit ) ; parser . setFocalPosition ( <NUM_LIT:0> ) ; parser . setResolveBindings ( false ) ; usedAstRoot = ( CompilationUnit ) parser . createAST ( new SubProgressMonitor ( monitor , <NUM_LIT:1> ) ) ; } ImportRewriteAnalyzer computer = new ImportRewriteAnalyzer ( this . compilationUnit , usedAstRoot , this . importOrder , this . importOnDemandThreshold , this . staticImportOnDemandThreshold , this . restoreExistingImports , this . useContextToFilterImplicitImports ) ; computer . setFilterImplicitImports ( this . filterImplicitImports ) ; if ( this . addedImports != null ) { for ( int i = <NUM_LIT:0> ; i < this . addedImports . size ( ) ; i ++ ) { String curr = ( String ) this . addedImports . get ( i ) ; computer . addImport ( curr . substring ( <NUM_LIT:1> ) , STATIC_PREFIX == curr . charAt ( <NUM_LIT:0> ) ) ; } } if ( this . removedImports != null ) { for ( int i = <NUM_LIT:0> ; i < this . removedImports . size ( ) ; i ++ ) { String curr = ( String ) this . removedImports . get ( i ) ; computer . removeImport ( curr . substring ( <NUM_LIT:1> ) , STATIC_PREFIX == curr . charAt ( <NUM_LIT:0> ) ) ; } } TextEdit result = computer . getResultingEdits ( new SubProgressMonitor ( monitor , <NUM_LIT:1> ) ) ; this . createdImports = computer . getCreatedImports ( ) ; this . createdStaticImports = computer . getCreatedStaticImports ( ) ; return result ; } finally { monitor . done ( ) ; } } public String [ ] getCreatedImports ( ) { return this . createdImports ; } public String [ ] getCreatedStaticImports ( ) { return this . createdStaticImports ; } public String [ ] getAddedImports ( ) { return filterFromList ( this . addedImports , NORMAL_PREFIX ) ; } public String [ ] getAddedStaticImports ( ) { return filterFromList ( this . addedImports , STATIC_PREFIX ) ; } public String [ ] getRemovedImports ( ) { return filterFromList ( this . removedImports , NORMAL_PREFIX ) ; } public String [ ] getRemovedStaticImports ( ) { return filterFromList ( this . removedImports , STATIC_PREFIX ) ; } public boolean hasRecordedChanges ( ) { return ! this . restoreExistingImports || ( this . addedImports != null && ! this . addedImports . isEmpty ( ) ) || ( this . removedImports != null && ! this . removedImports . isEmpty ( ) ) ; } private static String [ ] filterFromList ( List imports , char prefix ) { if ( imports == null ) { return CharOperation . NO_STRINGS ; } ArrayList res = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < imports . size ( ) ; i ++ ) { String curr = ( String ) imports . get ( i ) ; if ( prefix == curr . charAt ( <NUM_LIT:0> ) ) { res . add ( curr . substring ( <NUM_LIT:1> ) ) ; } } return ( String [ ] ) res . toArray ( new String [ res . size ( ) ] ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom . rewrite ; import java . util . HashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . ITypeRoot ; import org . eclipse . jdt . core . JavaCore ; 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 . Block ; import org . eclipse . jdt . core . dom . ChildListPropertyDescriptor ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScannerData ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteAnalyzer ; import org . eclipse . jdt . internal . core . dom . rewrite . LineInformation ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeRewriteEvent ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore ; import org . eclipse . jdt . internal . core . dom . rewrite . TrackedNodePosition ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . PropertyLocation ; import org . eclipse . jface . text . IDocument ; import org . eclipse . jface . text . TextUtilities ; import org . eclipse . text . edits . MultiTextEdit ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . text . edits . TextEditGroup ; public class ASTRewrite { private final AST ast ; private final RewriteEventStore eventStore ; private final NodeInfoStore nodeStore ; private TargetSourceRangeComputer targetSourceRangeComputer = null ; private Object property1 = null ; private Object property2 = null ; public static ASTRewrite create ( AST ast ) { return new ASTRewrite ( ast ) ; } protected ASTRewrite ( AST ast ) { this . ast = ast ; this . eventStore = new RewriteEventStore ( ) ; this . nodeStore = new NodeInfoStore ( ast ) ; } public final AST getAST ( ) { return this . ast ; } protected final RewriteEventStore getRewriteEventStore ( ) { return this . eventStore ; } protected final NodeInfoStore getNodeStore ( ) { return this . nodeStore ; } public TextEdit rewriteAST ( IDocument document , Map options ) throws IllegalArgumentException { if ( document == null ) { throw new IllegalArgumentException ( ) ; } ASTNode rootNode = getRootNode ( ) ; if ( rootNode == null ) { return new MultiTextEdit ( ) ; } char [ ] content = document . get ( ) . toCharArray ( ) ; LineInformation lineInfo = LineInformation . create ( document ) ; String lineDelim = TextUtilities . getDefaultLineDelimiter ( document ) ; ASTNode astRoot = rootNode . getRoot ( ) ; List commentNodes = astRoot instanceof CompilationUnit ? ( ( CompilationUnit ) astRoot ) . getCommentList ( ) : null ; Map currentOptions = options == null ? JavaCore . getOptions ( ) : options ; return internalRewriteAST ( content , lineInfo , lineDelim , commentNodes , currentOptions , rootNode , ( RecoveryScannerData ) ( ( CompilationUnit ) astRoot ) . getStatementsRecoveryData ( ) ) ; } public TextEdit rewriteAST ( ) throws JavaModelException , IllegalArgumentException { ASTNode rootNode = getRootNode ( ) ; if ( rootNode == null ) { return new MultiTextEdit ( ) ; } ASTNode root = rootNode . getRoot ( ) ; if ( ! ( root instanceof CompilationUnit ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } CompilationUnit astRoot = ( CompilationUnit ) root ; ITypeRoot typeRoot = astRoot . getTypeRoot ( ) ; if ( typeRoot == null || typeRoot . getBuffer ( ) == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } char [ ] content = typeRoot . getBuffer ( ) . getCharacters ( ) ; LineInformation lineInfo = LineInformation . create ( astRoot ) ; String lineDelim = typeRoot . findRecommendedLineSeparator ( ) ; Map options = typeRoot . getJavaProject ( ) . getOptions ( true ) ; return internalRewriteAST ( content , lineInfo , lineDelim , astRoot . getCommentList ( ) , options , rootNode , ( RecoveryScannerData ) astRoot . getStatementsRecoveryData ( ) ) ; } private TextEdit internalRewriteAST ( char [ ] content , LineInformation lineInfo , String lineDelim , List commentNodes , Map options , ASTNode rootNode , RecoveryScannerData recoveryScannerData ) { TextEdit result = new MultiTextEdit ( ) ; TargetSourceRangeComputer sourceRangeComputer = getExtendedSourceRangeComputer ( ) ; this . eventStore . prepareMovedNodes ( sourceRangeComputer ) ; ASTRewriteAnalyzer visitor = new ASTRewriteAnalyzer ( content , lineInfo , lineDelim , result , this . eventStore , this . nodeStore , commentNodes , options , sourceRangeComputer , recoveryScannerData ) ; rootNode . accept ( visitor ) ; this . eventStore . revertMovedNodes ( ) ; return result ; } private ASTNode getRootNode ( ) { ASTNode node = null ; int start = - <NUM_LIT:1> ; int end = - <NUM_LIT:1> ; for ( Iterator iter = getRewriteEventStore ( ) . getChangeRootIterator ( ) ; iter . hasNext ( ) ; ) { ASTNode curr = ( ASTNode ) iter . next ( ) ; if ( ! RewriteEventStore . isNewNode ( curr ) ) { int currStart = curr . getStartPosition ( ) ; int currEnd = currStart + curr . getLength ( ) ; if ( node == null || currStart < start && currEnd > end ) { start = currStart ; end = currEnd ; node = curr ; } else if ( currStart < start ) { start = currStart ; } else if ( currEnd > end ) { end = currEnd ; } } } if ( node != null ) { int currStart = node . getStartPosition ( ) ; int currEnd = currStart + node . getLength ( ) ; while ( start < currStart || end > currEnd ) { node = node . getParent ( ) ; currStart = node . getStartPosition ( ) ; currEnd = currStart + node . getLength ( ) ; } ASTNode parent = node . getParent ( ) ; while ( parent != null && parent . getStartPosition ( ) == node . getStartPosition ( ) && parent . getLength ( ) == node . getLength ( ) ) { node = parent ; parent = node . getParent ( ) ; } } return node ; } public final void remove ( ASTNode node , TextEditGroup editGroup ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } StructuralPropertyDescriptor property ; ASTNode parent ; if ( RewriteEventStore . isNewNode ( node ) ) { PropertyLocation location = this . eventStore . getPropertyLocation ( node , RewriteEventStore . NEW ) ; if ( location != null ) { property = location . getProperty ( ) ; parent = location . getParent ( ) ; } else { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } else { property = node . getLocationInParent ( ) ; parent = node . getParent ( ) ; } if ( property . isChildListProperty ( ) ) { getListRewrite ( parent , ( ChildListPropertyDescriptor ) property ) . remove ( node , editGroup ) ; } else { set ( parent , property , null , editGroup ) ; } } public final void replace ( ASTNode node , ASTNode replacement , TextEditGroup editGroup ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } StructuralPropertyDescriptor property ; ASTNode parent ; if ( RewriteEventStore . isNewNode ( node ) ) { PropertyLocation location = this . eventStore . getPropertyLocation ( node , RewriteEventStore . NEW ) ; if ( location != null ) { property = location . getProperty ( ) ; parent = location . getParent ( ) ; } else { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } else { property = node . getLocationInParent ( ) ; parent = node . getParent ( ) ; } if ( property . isChildListProperty ( ) ) { getListRewrite ( parent , ( ChildListPropertyDescriptor ) property ) . replace ( node , replacement , editGroup ) ; } else { set ( parent , property , replacement , editGroup ) ; } } public final void set ( ASTNode node , StructuralPropertyDescriptor property , Object value , TextEditGroup editGroup ) { if ( node == null || property == null ) { throw new IllegalArgumentException ( ) ; } validateIsCorrectAST ( node ) ; validatePropertyType ( property , value ) ; validateIsPropertyOfNode ( property , node ) ; NodeRewriteEvent nodeEvent = this . eventStore . getNodeEvent ( node , property , true ) ; nodeEvent . setNewValue ( value ) ; if ( editGroup != null ) { this . eventStore . setEventEditGroup ( nodeEvent , editGroup ) ; } } public Object get ( ASTNode node , StructuralPropertyDescriptor property ) { if ( node == null || property == null ) { throw new IllegalArgumentException ( ) ; } if ( property . isChildListProperty ( ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } return this . eventStore . getNewValue ( node , property ) ; } public final ListRewrite getListRewrite ( ASTNode node , ChildListPropertyDescriptor property ) { if ( node == null || property == null ) { throw new IllegalArgumentException ( ) ; } validateIsCorrectAST ( node ) ; validateIsListProperty ( property ) ; validateIsPropertyOfNode ( property , node ) ; return new ListRewrite ( this , node , property ) ; } public final Object getProperty ( String propertyName ) { if ( propertyName == null ) { throw new IllegalArgumentException ( ) ; } if ( this . property1 == null ) { return null ; } if ( this . property1 instanceof String ) { if ( propertyName . equals ( this . property1 ) ) { return this . property2 ; } else { return null ; } } Map m = ( Map ) this . property1 ; return m . get ( propertyName ) ; } public final ITrackedNodePosition track ( ASTNode node ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } TextEditGroup group = this . eventStore . getTrackedNodeData ( node ) ; if ( group == null ) { group = new TextEditGroup ( "<STR_LIT>" ) ; this . eventStore . setTrackedNodeData ( node , group ) ; } return new TrackedNodePosition ( group , node ) ; } private void validateIsExistingNode ( ASTNode node ) { if ( node . getStartPosition ( ) == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } private void validateIsCorrectAST ( ASTNode node ) { if ( node . getAST ( ) != getAST ( ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } private void validateIsListProperty ( StructuralPropertyDescriptor property ) { if ( ! property . isChildListProperty ( ) ) { String message = property . getId ( ) + "<STR_LIT>" ; throw new IllegalArgumentException ( message ) ; } } private void validateIsPropertyOfNode ( StructuralPropertyDescriptor property , ASTNode node ) { if ( ! property . getNodeClass ( ) . isInstance ( node ) ) { String message = property . getId ( ) + "<STR_LIT>" + node . getClass ( ) . getName ( ) ; throw new IllegalArgumentException ( message ) ; } } private void validatePropertyType ( StructuralPropertyDescriptor prop , Object node ) { if ( prop . isChildListProperty ( ) ) { String message = "<STR_LIT>" ; throw new IllegalArgumentException ( message ) ; } } public final ASTNode createStringPlaceholder ( String code , int nodeType ) { if ( code == null ) { throw new IllegalArgumentException ( ) ; } ASTNode placeholder = getNodeStore ( ) . newPlaceholderNode ( nodeType ) ; if ( placeholder == null ) { throw new IllegalArgumentException ( "<STR_LIT>" + nodeType ) ; } getNodeStore ( ) . markAsStringPlaceholder ( placeholder , code ) ; return placeholder ; } public final ASTNode createGroupNode ( ASTNode [ ] targetNodes ) { if ( targetNodes == null || targetNodes . length == <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } Block res = getNodeStore ( ) . createCollapsePlaceholder ( ) ; ListRewrite listRewrite = getListRewrite ( res , Block . STATEMENTS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < targetNodes . length ; i ++ ) { listRewrite . insertLast ( targetNodes [ i ] , null ) ; } return res ; } private ASTNode createTargetNode ( ASTNode node , boolean isMove ) { if ( node == null ) { throw new IllegalArgumentException ( ) ; } validateIsExistingNode ( node ) ; validateIsCorrectAST ( node ) ; CopySourceInfo info = getRewriteEventStore ( ) . markAsCopySource ( node . getParent ( ) , node . getLocationInParent ( ) , node , isMove ) ; ASTNode placeholder = getNodeStore ( ) . newPlaceholderNode ( node . getNodeType ( ) ) ; if ( placeholder == null ) { throw new IllegalArgumentException ( "<STR_LIT>" + node . getClass ( ) . getName ( ) ) ; } getNodeStore ( ) . markAsCopyTarget ( placeholder , info ) ; return placeholder ; } public final ASTNode createCopyTarget ( ASTNode node ) { return createTargetNode ( node , false ) ; } public final ASTNode createMoveTarget ( ASTNode node ) { return createTargetNode ( node , true ) ; } public final TargetSourceRangeComputer getExtendedSourceRangeComputer ( ) { if ( this . targetSourceRangeComputer == null ) { this . targetSourceRangeComputer = new TargetSourceRangeComputer ( ) ; } return this . targetSourceRangeComputer ; } public final void setProperty ( String propertyName , Object data ) { if ( propertyName == null ) { throw new IllegalArgumentException ( ) ; } if ( this . property1 == null ) { if ( data == null ) { return ; } this . property1 = propertyName ; this . property2 = data ; return ; } if ( this . property1 instanceof String ) { if ( propertyName . equals ( this . property1 ) ) { if ( data == null ) { this . property1 = null ; this . property2 = null ; } else { this . property2 = data ; } return ; } if ( data == null ) { return ; } Map m = new HashMap ( <NUM_LIT:3> ) ; m . put ( this . property1 , this . property2 ) ; m . put ( propertyName , data ) ; this . property1 = m ; this . property2 = null ; return ; } Map m = ( Map ) this . property1 ; if ( data == null ) { m . remove ( propertyName ) ; if ( m . size ( ) == <NUM_LIT:1> ) { Map . Entry [ ] entries = ( Map . Entry [ ] ) m . entrySet ( ) . toArray ( new Map . Entry [ <NUM_LIT:1> ] ) ; this . property1 = entries [ <NUM_LIT:0> ] . getKey ( ) ; this . property2 = entries [ <NUM_LIT:0> ] . getValue ( ) ; } return ; } else { m . put ( propertyName , data ) ; return ; } } public final void setTargetSourceRangeComputer ( TargetSourceRangeComputer computer ) { this . targetSourceRangeComputer = computer ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "<STR_LIT>" ) ; if ( this . eventStore != null ) { buf . append ( this . eventStore . toString ( ) ) ; } return buf . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ThrowStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ThrowStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ThrowStatement . class , propertyList ) ; addProperty ( EXPRESSION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; ThrowStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return THROW_STATEMENT ; } ASTNode clone0 ( AST target ) { ThrowStatement result = new ThrowStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class NullLiteral extends Expression { private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:1> ) ; createPropertyList ( NullLiteral . class , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } NullLiteral ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int getNodeType0 ( ) { return NULL_LITERAL ; } ASTNode clone0 ( AST target ) { NullLiteral result = new NullLiteral ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE ; } int treeSize ( ) { return memSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; public class TypeDeclaration extends AbstractTypeDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( TypeDeclaration . class ) ; public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = internalModifiersPropertyFactory ( TypeDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( TypeDeclaration . class ) ; public static final SimplePropertyDescriptor INTERFACE_PROPERTY = new SimplePropertyDescriptor ( TypeDeclaration . class , "<STR_LIT>" , boolean . class , MANDATORY ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = internalNamePropertyFactory ( TypeDeclaration . class ) ; public static final ChildPropertyDescriptor SUPERCLASS_PROPERTY = new ChildPropertyDescriptor ( TypeDeclaration . class , "<STR_LIT>" , Name . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor SUPER_INTERFACES_PROPERTY = new ChildListPropertyDescriptor ( TypeDeclaration . class , "<STR_LIT>" , Name . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor SUPERCLASS_TYPE_PROPERTY = new ChildPropertyDescriptor ( TypeDeclaration . class , "<STR_LIT>" , Type . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor SUPER_INTERFACE_TYPES_PROPERTY = new ChildListPropertyDescriptor ( TypeDeclaration . class , "<STR_LIT>" , Type . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor TYPE_PARAMETERS_PROPERTY = new ChildListPropertyDescriptor ( TypeDeclaration . class , "<STR_LIT>" , TypeParameter . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = internalBodyDeclarationPropertyFactory ( TypeDeclaration . class ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( <NUM_LIT:8> ) ; createPropertyList ( TypeDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS_PROPERTY , propertyList ) ; addProperty ( INTERFACE_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( SUPERCLASS_PROPERTY , propertyList ) ; addProperty ( SUPER_INTERFACES_PROPERTY , propertyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( <NUM_LIT:9> ) ; createPropertyList ( TypeDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS2_PROPERTY , propertyList ) ; addProperty ( INTERFACE_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( TYPE_PARAMETERS_PROPERTY , propertyList ) ; addProperty ( SUPERCLASS_TYPE_PROPERTY , propertyList ) ; addProperty ( SUPER_INTERFACE_TYPES_PROPERTY , propertyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private boolean isInterface = false ; private ASTNode . NodeList typeParameters = null ; private Name optionalSuperclassName = null ; private ASTNode . NodeList superInterfaceNames = null ; private Type optionalSuperclassType = null ; private ASTNode . NodeList superInterfaceTypes = null ; TypeDeclaration ( AST ast ) { super ( ast ) ; if ( ast . apiLevel == AST . JLS2_INTERNAL ) { this . superInterfaceNames = new ASTNode . NodeList ( SUPER_INTERFACES_PROPERTY ) ; } if ( ast . apiLevel >= AST . JLS3_INTERNAL ) { this . typeParameters = new ASTNode . NodeList ( TYPE_PARAMETERS_PROPERTY ) ; this . superInterfaceTypes = new ASTNode . NodeList ( SUPER_INTERFACE_TYPES_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { internalSetModifiers ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { if ( property == INTERFACE_PROPERTY ) { if ( get ) { return isInterface ( ) ; } else { setInterface ( value ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == SUPERCLASS_PROPERTY ) { if ( get ) { return getSuperclass ( ) ; } else { setSuperclass ( ( Name ) child ) ; return null ; } } if ( property == SUPERCLASS_TYPE_PROPERTY ) { if ( get ) { return getSuperclassType ( ) ; } else { setSuperclassType ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == TYPE_PARAMETERS_PROPERTY ) { return typeParameters ( ) ; } if ( property == SUPER_INTERFACES_PROPERTY ) { return superInterfaces ( ) ; } if ( property == SUPER_INTERFACE_TYPES_PROPERTY ) { return superInterfaceTypes ( ) ; } if ( property == BODY_DECLARATIONS_PROPERTY ) { return bodyDeclarations ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return MODIFIERS_PROPERTY ; } final ChildPropertyDescriptor internalNameProperty ( ) { return NAME_PROPERTY ; } final ChildListPropertyDescriptor internalBodyDeclarationsProperty ( ) { return BODY_DECLARATIONS_PROPERTY ; } final int getNodeType0 ( ) { return TYPE_DECLARATION ; } ASTNode clone0 ( AST target ) { TypeDeclaration result = new TypeDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . internalSetModifiers ( getModifiers ( ) ) ; result . setSuperclass ( ( Name ) ASTNode . copySubtree ( target , getSuperclass ( ) ) ) ; result . superInterfaces ( ) . addAll ( ASTNode . copySubtrees ( target , superInterfaces ( ) ) ) ; } result . setInterface ( isInterface ( ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; result . typeParameters ( ) . addAll ( ASTNode . copySubtrees ( target , typeParameters ( ) ) ) ; result . setSuperclassType ( ( Type ) ASTNode . copySubtree ( target , getSuperclassType ( ) ) ) ; result . superInterfaceTypes ( ) . addAll ( ASTNode . copySubtrees ( target , superInterfaceTypes ( ) ) ) ; } result . bodyDeclarations ( ) . addAll ( ASTNode . copySubtrees ( target , bodyDeclarations ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { acceptChild ( visitor , getJavadoc ( ) ) ; acceptChild ( visitor , getName ( ) ) ; acceptChild ( visitor , getSuperclass ( ) ) ; acceptChildren ( visitor , this . superInterfaceNames ) ; acceptChildren ( visitor , this . bodyDeclarations ) ; } if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { acceptChild ( visitor , getJavadoc ( ) ) ; acceptChildren ( visitor , this . modifiers ) ; acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . typeParameters ) ; acceptChild ( visitor , getSuperclassType ( ) ) ; acceptChildren ( visitor , this . superInterfaceTypes ) ; acceptChildren ( visitor , this . bodyDeclarations ) ; } } visitor . endVisit ( this ) ; } public boolean isInterface ( ) { return this . isInterface ; } public void setInterface ( boolean isInterface ) { preValueChange ( INTERFACE_PROPERTY ) ; this . isInterface = isInterface ; postValueChange ( INTERFACE_PROPERTY ) ; } public List typeParameters ( ) { if ( this . typeParameters == null ) { unsupportedIn2 ( ) ; } return this . typeParameters ; } public Name getSuperclass ( ) { return internalGetSuperclass ( ) ; } final Name internalGetSuperclass ( ) { supportedOnlyIn2 ( ) ; return this . optionalSuperclassName ; } public Type getSuperclassType ( ) { unsupportedIn2 ( ) ; return this . optionalSuperclassType ; } public void setSuperclass ( Name superclassName ) { internalSetSuperclass ( superclassName ) ; } final void internalSetSuperclass ( Name superclassName ) { supportedOnlyIn2 ( ) ; ASTNode oldChild = this . optionalSuperclassName ; preReplaceChild ( oldChild , superclassName , SUPERCLASS_PROPERTY ) ; this . optionalSuperclassName = superclassName ; postReplaceChild ( oldChild , superclassName , SUPERCLASS_PROPERTY ) ; } public void setSuperclassType ( Type superclassType ) { unsupportedIn2 ( ) ; ASTNode oldChild = this . optionalSuperclassType ; preReplaceChild ( oldChild , superclassType , SUPERCLASS_TYPE_PROPERTY ) ; this . optionalSuperclassType = superclassType ; postReplaceChild ( oldChild , superclassType , SUPERCLASS_TYPE_PROPERTY ) ; } public List superInterfaces ( ) { return internalSuperInterfaces ( ) ; } final List internalSuperInterfaces ( ) { if ( this . superInterfaceNames == null ) { supportedOnlyIn2 ( ) ; } return this . superInterfaceNames ; } public List superInterfaceTypes ( ) { if ( this . superInterfaceTypes == null ) { unsupportedIn2 ( ) ; } return this . superInterfaceTypes ; } public FieldDeclaration [ ] getFields ( ) { List bd = bodyDeclarations ( ) ; int fieldCount = <NUM_LIT:0> ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { if ( it . next ( ) instanceof FieldDeclaration ) { fieldCount ++ ; } } FieldDeclaration [ ] fields = new FieldDeclaration [ fieldCount ] ; int next = <NUM_LIT:0> ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { Object decl = it . next ( ) ; if ( decl instanceof FieldDeclaration ) { fields [ next ++ ] = ( FieldDeclaration ) decl ; } } return fields ; } public MethodDeclaration [ ] getMethods ( ) { List bd = bodyDeclarations ( ) ; int methodCount = <NUM_LIT:0> ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { if ( it . next ( ) instanceof MethodDeclaration ) { methodCount ++ ; } } MethodDeclaration [ ] methods = new MethodDeclaration [ methodCount ] ; int next = <NUM_LIT:0> ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { Object decl = it . next ( ) ; if ( decl instanceof MethodDeclaration ) { methods [ next ++ ] = ( MethodDeclaration ) decl ; } } return methods ; } public TypeDeclaration [ ] getTypes ( ) { List bd = bodyDeclarations ( ) ; int typeCount = <NUM_LIT:0> ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { if ( it . next ( ) instanceof TypeDeclaration ) { typeCount ++ ; } } TypeDeclaration [ ] memberTypes = new TypeDeclaration [ typeCount ] ; int next = <NUM_LIT:0> ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { Object decl = it . next ( ) ; if ( decl instanceof TypeDeclaration ) { memberTypes [ next ++ ] = ( TypeDeclaration ) decl ; } } return memberTypes ; } ITypeBinding internalResolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveType ( this ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:6> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + ( this . modifiers == null ? <NUM_LIT:0> : this . modifiers . listSize ( ) ) + ( this . typeName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . typeParameters == null ? <NUM_LIT:0> : this . typeParameters . listSize ( ) ) + ( this . optionalSuperclassName == null ? <NUM_LIT:0> : getSuperclass ( ) . treeSize ( ) ) + ( this . optionalSuperclassType == null ? <NUM_LIT:0> : getSuperclassType ( ) . treeSize ( ) ) + ( this . superInterfaceNames == null ? <NUM_LIT:0> : this . superInterfaceNames . listSize ( ) ) + ( this . superInterfaceTypes == null ? <NUM_LIT:0> : this . superInterfaceTypes . listSize ( ) ) + this . bodyDeclarations . listSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class StringLiteral extends Expression { public static final SimplePropertyDescriptor ESCAPED_VALUE_PROPERTY = new SimplePropertyDescriptor ( StringLiteral . class , "<STR_LIT>" , String . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( StringLiteral . class , propertyList ) ; addProperty ( ESCAPED_VALUE_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private String escapedValue = "<STR_LIT>" ; StringLiteral ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == ESCAPED_VALUE_PROPERTY ) { if ( get ) { return getEscapedValue ( ) ; } else { setEscapedValue ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final int getNodeType0 ( ) { return STRING_LITERAL ; } ASTNode clone0 ( AST target ) { StringLiteral result = new StringLiteral ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setEscapedValue ( getEscapedValue ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } public String getEscapedValue ( ) { return this . escapedValue ; } public void setEscapedValue ( String token ) { if ( token == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } Scanner scanner = this . ast . scanner ; char [ ] source = token . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( <NUM_LIT:0> , source . length ) ; try { int tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameStringLiteral : break ; default : throw new IllegalArgumentException ( "<STR_LIT>" + token + "<STR_LIT:<>" ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( "<STR_LIT>" + token + "<STR_LIT:<>" ) ; } preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = token ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } void internalSetEscapedValue ( String token ) { preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = token ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } public String getLiteralValue ( ) { String s = getEscapedValue ( ) ; int len = s . length ( ) ; if ( len < <NUM_LIT:2> || s . charAt ( <NUM_LIT:0> ) != '<STR_LIT:\">' || s . charAt ( len - <NUM_LIT:1> ) != '<STR_LIT:\">' ) { throw new IllegalArgumentException ( ) ; } Scanner scanner = this . ast . scanner ; char [ ] source = s . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( <NUM_LIT:0> , source . length ) ; try { int tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameStringLiteral : return scanner . getCurrentStringLiteral ( ) ; default : throw new IllegalArgumentException ( ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } } public void setLiteralValue ( String value ) { if ( value == null ) { throw new IllegalArgumentException ( ) ; } int len = value . length ( ) ; StringBuffer b = new StringBuffer ( len + <NUM_LIT:2> ) ; b . append ( "<STR_LIT:\">" ) ; for ( int i = <NUM_LIT:0> ; i < len ; i ++ ) { char c = value . charAt ( i ) ; switch ( c ) { case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\t>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\n>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\">' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\\>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; default : b . append ( c ) ; } } b . append ( "<STR_LIT:\">" ) ; setEscapedValue ( b . toString ( ) ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> + stringSize ( this . escapedValue ) ; return size ; } int treeSize ( ) { return memSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public abstract class VariableDeclaration extends ASTNode { abstract SimplePropertyDescriptor internalExtraDimensionsProperty ( ) ; public final SimplePropertyDescriptor getExtraDimensionsProperty ( ) { return internalExtraDimensionsProperty ( ) ; } abstract ChildPropertyDescriptor internalInitializerProperty ( ) ; public final ChildPropertyDescriptor getInitializerProperty ( ) { return internalInitializerProperty ( ) ; } abstract ChildPropertyDescriptor internalNameProperty ( ) ; public final ChildPropertyDescriptor getNameProperty ( ) { return internalNameProperty ( ) ; } VariableDeclaration ( AST ast ) { super ( ast ) ; } public abstract SimpleName getName ( ) ; public abstract void setName ( SimpleName variableName ) ; public abstract int getExtraDimensions ( ) ; public abstract void setExtraDimensions ( int dimensions ) ; public abstract Expression getInitializer ( ) ; public abstract void setInitializer ( Expression initializer ) ; public IVariableBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveVariable ( this ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class AnnotationTypeMemberDeclaration extends BodyDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( AnnotationTypeMemberDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( AnnotationTypeMemberDeclaration . class ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( AnnotationTypeMemberDeclaration . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( AnnotationTypeMemberDeclaration . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor DEFAULT_PROPERTY = new ChildPropertyDescriptor ( AnnotationTypeMemberDeclaration . class , "<STR_LIT:default>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:6> ) ; createPropertyList ( AnnotationTypeMemberDeclaration . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS2_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( DEFAULT_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName memberName = null ; private Type memberType = null ; private Expression optionalDefaultValue = null ; AnnotationTypeMemberDeclaration ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } if ( property == DEFAULT_PROPERTY ) { if ( get ) { return getDefault ( ) ; } else { setDefault ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return null ; } final int getNodeType0 ( ) { return ANNOTATION_TYPE_MEMBER_DECLARATION ; } ASTNode clone0 ( AST target ) { AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; result . setType ( ( Type ) ASTNode . copySubtree ( target , getType ( ) ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . setDefault ( ( Expression ) ASTNode . copySubtree ( target , getDefault ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; acceptChildren ( visitor , this . modifiers ) ; acceptChild ( visitor , getType ( ) ) ; acceptChild ( visitor , getName ( ) ) ; acceptChild ( visitor , getDefault ( ) ) ; } visitor . endVisit ( this ) ; } public SimpleName getName ( ) { if ( this . memberName == null ) { synchronized ( this ) { if ( this . memberName == null ) { preLazyInit ( ) ; this . memberName = new SimpleName ( this . ast ) ; postLazyInit ( this . memberName , NAME_PROPERTY ) ; } } } return this . memberName ; } public void setName ( SimpleName memberName ) { if ( memberName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . memberName ; preReplaceChild ( oldChild , memberName , NAME_PROPERTY ) ; this . memberName = memberName ; postReplaceChild ( oldChild , memberName , NAME_PROPERTY ) ; } public Type getType ( ) { if ( this . memberType == null ) { synchronized ( this ) { if ( this . memberType == null ) { preLazyInit ( ) ; this . memberType = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; postLazyInit ( this . memberType , TYPE_PROPERTY ) ; } } } return this . memberType ; } public void setType ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . memberType ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . memberType = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public Expression getDefault ( ) { return this . optionalDefaultValue ; } public void setDefault ( Expression defaultValue ) { ASTNode oldChild = this . optionalDefaultValue ; preReplaceChild ( oldChild , defaultValue , DEFAULT_PROPERTY ) ; this . optionalDefaultValue = defaultValue ; postReplaceChild ( oldChild , defaultValue , DEFAULT_PROPERTY ) ; } public IMethodBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveMember ( this ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + this . modifiers . listSize ( ) + ( this . memberName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . memberType == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + ( this . optionalDefaultValue == null ? <NUM_LIT:0> : getDefault ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class BreakStatement extends Statement { public static final ChildPropertyDescriptor LABEL_PROPERTY = new ChildPropertyDescriptor ( BreakStatement . class , "<STR_LIT:label>" , SimpleName . class , OPTIONAL , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( BreakStatement . class , properyList ) ; addProperty ( LABEL_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName optionalLabel = null ; BreakStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LABEL_PROPERTY ) { if ( get ) { return getLabel ( ) ; } else { setLabel ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return BREAK_STATEMENT ; } ASTNode clone0 ( AST target ) { BreakStatement result = new BreakStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setLabel ( ( SimpleName ) ASTNode . copySubtree ( target , getLabel ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLabel ( ) ) ; } visitor . endVisit ( this ) ; } public SimpleName getLabel ( ) { return this . optionalLabel ; } public void setLabel ( SimpleName label ) { ASTNode oldChild = this . optionalLabel ; preReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; this . optionalLabel = label ; postReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalLabel == null ? <NUM_LIT:0> : getLabel ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . List ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . lookup . ArrayBinding ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . CompilationUnitScope ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . PackageFragment ; class RecoveredTypeBinding implements ITypeBinding { private VariableDeclaration variableDeclaration ; private Type currentType ; private BindingResolver resolver ; private int dimensions ; private RecoveredTypeBinding innerTypeBinding ; private ITypeBinding [ ] typeArguments ; private org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding ; RecoveredTypeBinding ( BindingResolver resolver , VariableDeclaration variableDeclaration ) { this . variableDeclaration = variableDeclaration ; this . resolver = resolver ; this . currentType = getType ( ) ; this . dimensions = variableDeclaration . getExtraDimensions ( ) ; if ( this . currentType . isArrayType ( ) ) { this . dimensions += ( ( ArrayType ) this . currentType ) . getDimensions ( ) ; } } RecoveredTypeBinding ( BindingResolver resolver , org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding ) { this . resolver = resolver ; this . dimensions = typeBinding . dimensions ( ) ; this . binding = typeBinding ; } RecoveredTypeBinding ( BindingResolver resolver , Type type ) { this . currentType = type ; this . resolver = resolver ; this . dimensions = <NUM_LIT:0> ; if ( type . isArrayType ( ) ) { this . dimensions += ( ( ArrayType ) type ) . getDimensions ( ) ; } } RecoveredTypeBinding ( BindingResolver resolver , RecoveredTypeBinding typeBinding , int dimensions ) { this . innerTypeBinding = typeBinding ; this . dimensions = typeBinding . getDimensions ( ) + dimensions ; this . resolver = resolver ; } public ITypeBinding createArrayType ( int dims ) { return this . resolver . getTypeBinding ( this , dims ) ; } public String getBinaryName ( ) { return null ; } public ITypeBinding getBound ( ) { return null ; } public ITypeBinding getGenericTypeOfWildcardType ( ) { return null ; } public int getRank ( ) { return - <NUM_LIT:1> ; } public ITypeBinding getComponentType ( ) { if ( this . dimensions == <NUM_LIT:0> ) return null ; return this . resolver . getTypeBinding ( this , - <NUM_LIT:1> ) ; } public IVariableBinding [ ] getDeclaredFields ( ) { return TypeBinding . NO_VARIABLE_BINDINGS ; } public IMethodBinding [ ] getDeclaredMethods ( ) { return TypeBinding . NO_METHOD_BINDINGS ; } public int getDeclaredModifiers ( ) { return <NUM_LIT:0> ; } public ITypeBinding [ ] getDeclaredTypes ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding getDeclaringClass ( ) { return null ; } public IMethodBinding getDeclaringMethod ( ) { return null ; } public int getDimensions ( ) { return this . dimensions ; } public ITypeBinding getElementType ( ) { if ( this . binding != null ) { if ( this . binding . isArrayType ( ) ) { ArrayBinding arrayBinding = ( ArrayBinding ) this . binding ; return new RecoveredTypeBinding ( this . resolver , arrayBinding . leafComponentType ) ; } else { return new RecoveredTypeBinding ( this . resolver , this . binding ) ; } } if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getElementType ( ) ; } if ( this . currentType != null && this . currentType . isArrayType ( ) ) { return this . resolver . getTypeBinding ( ( ( ArrayType ) this . currentType ) . getElementType ( ) ) ; } if ( this . variableDeclaration != null && this . variableDeclaration . getExtraDimensions ( ) != <NUM_LIT:0> ) { return this . resolver . getTypeBinding ( getType ( ) ) ; } return null ; } public ITypeBinding getErasure ( ) { return this ; } public ITypeBinding [ ] getInterfaces ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public int getModifiers ( ) { return Modifier . NONE ; } public String getName ( ) { char [ ] brackets = new char [ this . dimensions * <NUM_LIT:2> ] ; for ( int i = this . dimensions * <NUM_LIT:2> - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -= <NUM_LIT:2> ) { brackets [ i ] = '<CHAR_LIT:]>' ; brackets [ i - <NUM_LIT:1> ] = '<CHAR_LIT:[>' ; } StringBuffer buffer = new StringBuffer ( getInternalName ( ) ) ; buffer . append ( brackets ) ; return String . valueOf ( buffer ) ; } private String getInternalName ( ) { if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getInternalName ( ) ; } ReferenceBinding referenceBinding = getReferenceBinding ( ) ; if ( referenceBinding != null ) { return new String ( referenceBinding . compoundName [ referenceBinding . compoundName . length - <NUM_LIT:1> ] ) ; } return getTypeNameFrom ( getType ( ) ) ; } public IPackageBinding getPackage ( ) { if ( this . binding != null ) { switch ( this . binding . kind ( ) ) { case Binding . BASE_TYPE : case Binding . ARRAY_TYPE : case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return null ; } IPackageBinding packageBinding = this . resolver . getPackageBinding ( this . binding . getPackage ( ) ) ; if ( packageBinding != null ) return packageBinding ; } if ( this . innerTypeBinding != null && this . dimensions > <NUM_LIT:0> ) { return null ; } CompilationUnitScope scope = this . resolver . scope ( ) ; if ( scope != null ) { return this . resolver . getPackageBinding ( scope . getCurrentPackage ( ) ) ; } return null ; } public String getQualifiedName ( ) { ReferenceBinding referenceBinding = getReferenceBinding ( ) ; if ( referenceBinding != null ) { StringBuffer buffer = new StringBuffer ( ) ; char [ ] brackets = new char [ this . dimensions * <NUM_LIT:2> ] ; for ( int i = this . dimensions * <NUM_LIT:2> - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -= <NUM_LIT:2> ) { brackets [ i ] = '<CHAR_LIT:]>' ; brackets [ i - <NUM_LIT:1> ] = '<CHAR_LIT:[>' ; } buffer . append ( CharOperation . toString ( referenceBinding . compoundName ) ) ; buffer . append ( brackets ) ; return String . valueOf ( buffer ) ; } else { return getName ( ) ; } } private ReferenceBinding getReferenceBinding ( ) { if ( this . binding != null ) { if ( this . binding . isArrayType ( ) ) { ArrayBinding arrayBinding = ( ArrayBinding ) this . binding ; if ( arrayBinding . leafComponentType instanceof ReferenceBinding ) { return ( ReferenceBinding ) arrayBinding . leafComponentType ; } } else if ( this . binding instanceof ReferenceBinding ) { return ( ReferenceBinding ) this . binding ; } } else if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getReferenceBinding ( ) ; } return null ; } public ITypeBinding getSuperclass ( ) { if ( getQualifiedName ( ) . equals ( "<STR_LIT>" ) ) { return null ; } return this . resolver . resolveWellKnownType ( "<STR_LIT>" ) ; } public ITypeBinding [ ] getTypeArguments ( ) { if ( this . binding != null ) { return this . typeArguments = TypeBinding . NO_TYPE_BINDINGS ; } if ( this . typeArguments != null ) { return this . typeArguments ; } if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getTypeArguments ( ) ; } if ( this . currentType . isParameterizedType ( ) ) { ParameterizedType parameterizedType = ( ParameterizedType ) this . currentType ; List typeArgumentsList = parameterizedType . typeArguments ( ) ; int size = typeArgumentsList . size ( ) ; ITypeBinding [ ] temp = new ITypeBinding [ size ] ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { ITypeBinding currentTypeBinding = ( ( Type ) typeArgumentsList . get ( i ) ) . resolveBinding ( ) ; if ( currentTypeBinding == null ) { return this . typeArguments = TypeBinding . NO_TYPE_BINDINGS ; } temp [ i ] = currentTypeBinding ; } return this . typeArguments = temp ; } return this . typeArguments = TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding [ ] getTypeBounds ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding getTypeDeclaration ( ) { return this ; } public ITypeBinding [ ] getTypeParameters ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding getWildcard ( ) { return null ; } public boolean isAnnotation ( ) { return false ; } public boolean isAnonymous ( ) { return false ; } public boolean isArray ( ) { return false ; } public boolean isAssignmentCompatible ( ITypeBinding typeBinding ) { if ( "<STR_LIT>" . equals ( typeBinding . getQualifiedName ( ) ) ) { return true ; } return isEqualTo ( typeBinding ) ; } public boolean isCapture ( ) { return false ; } public boolean isCastCompatible ( ITypeBinding typeBinding ) { if ( "<STR_LIT>" . equals ( typeBinding . getQualifiedName ( ) ) ) { return true ; } return isEqualTo ( typeBinding ) ; } public boolean isClass ( ) { return true ; } public boolean isEnum ( ) { return false ; } public boolean isFromSource ( ) { return false ; } public boolean isGenericType ( ) { return false ; } public boolean isInterface ( ) { return false ; } public boolean isLocal ( ) { return false ; } public boolean isMember ( ) { return false ; } public boolean isNested ( ) { return false ; } public boolean isNullType ( ) { return false ; } public boolean isParameterizedType ( ) { if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . isParameterizedType ( ) ; } if ( this . currentType != null ) { return this . currentType . isParameterizedType ( ) ; } return false ; } public boolean isPrimitive ( ) { return false ; } public boolean isRawType ( ) { return false ; } public boolean isSubTypeCompatible ( ITypeBinding typeBinding ) { if ( "<STR_LIT>" . equals ( typeBinding . getQualifiedName ( ) ) ) { return true ; } return isEqualTo ( typeBinding ) ; } public boolean isTopLevel ( ) { return true ; } public boolean isTypeVariable ( ) { return false ; } public boolean isUpperbound ( ) { return false ; } public boolean isWildcardType ( ) { return false ; } public IAnnotationBinding [ ] getAnnotations ( ) { return AnnotationBinding . NoAnnotations ; } public IJavaElement getJavaElement ( ) { IPackageBinding packageBinding = getPackage ( ) ; if ( packageBinding != null ) { final IJavaElement javaElement = packageBinding . getJavaElement ( ) ; if ( javaElement != null && javaElement . getElementType ( ) == IJavaElement . PACKAGE_FRAGMENT ) { return ( ( PackageFragment ) javaElement ) . getCompilationUnit ( getInternalName ( ) + SuffixConstants . SUFFIX_STRING_java ) . getType ( this . getName ( ) ) ; } } return null ; } public String getKey ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . innerTypeBinding != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . innerTypeBinding . getKey ( ) ) ; } else if ( this . currentType != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . currentType . toString ( ) ) ; } else if ( this . binding != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . binding . computeUniqueKey ( ) ) ; } else if ( this . variableDeclaration != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . variableDeclaration . getClass ( ) ) . append ( this . variableDeclaration . getName ( ) . getIdentifier ( ) ) . append ( this . variableDeclaration . getExtraDimensions ( ) ) ; } buffer . append ( getDimensions ( ) ) ; if ( this . typeArguments != null ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> , max = this . typeArguments . length ; i < max ; i ++ ) { if ( i != <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( this . typeArguments [ i ] . getKey ( ) ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } return String . valueOf ( buffer ) ; } public int getKind ( ) { return IBinding . TYPE ; } public boolean isDeprecated ( ) { return false ; } public boolean isEqualTo ( IBinding other ) { if ( ! other . isRecovered ( ) || other . getKind ( ) != IBinding . TYPE ) return false ; return getKey ( ) . equals ( other . getKey ( ) ) ; } public boolean isRecovered ( ) { return true ; } public boolean isSynthetic ( ) { return false ; } private String getTypeNameFrom ( Type type ) { if ( type == null ) return Util . EMPTY_STRING ; switch ( type . getNodeType0 ( ) ) { case ASTNode . ARRAY_TYPE : ArrayType arrayType = ( ArrayType ) type ; type = arrayType . getElementType ( ) ; return getTypeNameFrom ( type ) ; case ASTNode . PARAMETERIZED_TYPE : ParameterizedType parameterizedType = ( ParameterizedType ) type ; StringBuffer buffer = new StringBuffer ( getTypeNameFrom ( parameterizedType . getType ( ) ) ) ; ITypeBinding [ ] tArguments = getTypeArguments ( ) ; final int typeArgumentsLength = tArguments . length ; if ( typeArgumentsLength != <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < typeArgumentsLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( tArguments [ i ] . getName ( ) ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } return String . valueOf ( buffer ) ; case ASTNode . PRIMITIVE_TYPE : PrimitiveType primitiveType = ( PrimitiveType ) type ; return primitiveType . getPrimitiveTypeCode ( ) . toString ( ) ; case ASTNode . QUALIFIED_TYPE : QualifiedType qualifiedType = ( QualifiedType ) type ; return qualifiedType . getName ( ) . getIdentifier ( ) ; case ASTNode . SIMPLE_TYPE : SimpleType simpleType = ( SimpleType ) type ; Name name = simpleType . getName ( ) ; if ( name . isQualifiedName ( ) ) { QualifiedName qualifiedName = ( QualifiedName ) name ; return qualifiedName . getName ( ) . getIdentifier ( ) ; } return ( ( SimpleName ) name ) . getIdentifier ( ) ; } return Util . EMPTY_STRING ; } private Type getType ( ) { if ( this . currentType != null ) { return this . currentType ; } if ( this . variableDeclaration == null ) return null ; switch ( this . variableDeclaration . getNodeType ( ) ) { case ASTNode . SINGLE_VARIABLE_DECLARATION : SingleVariableDeclaration singleVariableDeclaration = ( SingleVariableDeclaration ) this . variableDeclaration ; return singleVariableDeclaration . getType ( ) ; default : ASTNode parent = this . variableDeclaration . getParent ( ) ; switch ( parent . getNodeType ( ) ) { case ASTNode . VARIABLE_DECLARATION_EXPRESSION : VariableDeclarationExpression variableDeclarationExpression = ( VariableDeclarationExpression ) parent ; return variableDeclarationExpression . getType ( ) ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : VariableDeclarationStatement statement = ( VariableDeclarationStatement ) parent ; return statement . getType ( ) ; case ASTNode . FIELD_DECLARATION : FieldDeclaration fieldDeclaration = ( FieldDeclaration ) parent ; return fieldDeclaration . getType ( ) ; } } return null ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class LabeledStatement extends Statement { public static final ChildPropertyDescriptor LABEL_PROPERTY = new ChildPropertyDescriptor ( LabeledStatement . class , "<STR_LIT:label>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( LabeledStatement . class , "<STR_LIT:body>" , Statement . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( LabeledStatement . class , propertyList ) ; addProperty ( LABEL_PROPERTY , propertyList ) ; addProperty ( BODY_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName labelName = null ; private Statement body = null ; LabeledStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LABEL_PROPERTY ) { if ( get ) { return getLabel ( ) ; } else { setLabel ( ( SimpleName ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Statement ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return LABELED_STATEMENT ; } ASTNode clone0 ( AST target ) { LabeledStatement result = new LabeledStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setLabel ( ( SimpleName ) ASTNode . copySubtree ( target , getLabel ( ) ) ) ; result . setBody ( ( Statement ) ASTNode . copySubtree ( target , getBody ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLabel ( ) ) ; acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public SimpleName getLabel ( ) { if ( this . labelName == null ) { synchronized ( this ) { if ( this . labelName == null ) { preLazyInit ( ) ; this . labelName = new SimpleName ( this . ast ) ; postLazyInit ( this . labelName , LABEL_PROPERTY ) ; } } } return this . labelName ; } public void setLabel ( SimpleName label ) { if ( label == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . labelName ; preReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; this . labelName = label ; postReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; } public Statement getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new EmptyStatement ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Statement statement ) { if ( statement == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; this . body = statement ; postReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . labelName == null ? <NUM_LIT:0> : getLabel ( ) . treeSize ( ) ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class FieldAccess extends Expression { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( FieldAccess . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( FieldAccess . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( FieldAccess . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; private SimpleName fieldName = null ; FieldAccess ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return FIELD_ACCESS ; } ASTNode clone0 ( AST target ) { FieldAccess result = new FieldAccess ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public SimpleName getName ( ) { if ( this . fieldName == null ) { synchronized ( this ) { if ( this . fieldName == null ) { preLazyInit ( ) ; this . fieldName = new SimpleName ( this . ast ) ; postLazyInit ( this . fieldName , NAME_PROPERTY ) ; } } } return this . fieldName ; } public void setName ( SimpleName fieldName ) { if ( fieldName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . fieldName ; preReplaceChild ( oldChild , fieldName , NAME_PROPERTY ) ; this . fieldName = fieldName ; postReplaceChild ( oldChild , fieldName , NAME_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } public IVariableBinding resolveFieldBinding ( ) { return this . ast . getBindingResolver ( ) . resolveField ( this ) ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . fieldName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; class NodeEventHandler { NodeEventHandler ( ) { } void preRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void postRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void preReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { } void postReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { } void preAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void postAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void preValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { } void postValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { } void preCloneNodeEvent ( ASTNode node ) { } void postCloneNodeEvent ( ASTNode node , ASTNode clone ) { } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class VariableDeclarationFragment extends VariableDeclaration { public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( VariableDeclarationFragment . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final SimplePropertyDescriptor EXTRA_DIMENSIONS_PROPERTY = new SimplePropertyDescriptor ( VariableDeclarationFragment . class , "<STR_LIT>" , int . class , MANDATORY ) ; public static final ChildPropertyDescriptor INITIALIZER_PROPERTY = new ChildPropertyDescriptor ( VariableDeclarationFragment . class , "<STR_LIT>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( VariableDeclarationFragment . class , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( EXTRA_DIMENSIONS_PROPERTY , propertyList ) ; addProperty ( INITIALIZER_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName variableName = null ; private int extraArrayDimensions = <NUM_LIT:0> ; private Expression optionalInitializer = null ; VariableDeclarationFragment ( AST ast ) { super ( ast ) ; } final SimplePropertyDescriptor internalExtraDimensionsProperty ( ) { return EXTRA_DIMENSIONS_PROPERTY ; } final ChildPropertyDescriptor internalInitializerProperty ( ) { return INITIALIZER_PROPERTY ; } final ChildPropertyDescriptor internalNameProperty ( ) { return NAME_PROPERTY ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == EXTRA_DIMENSIONS_PROPERTY ) { if ( get ) { return getExtraDimensions ( ) ; } else { setExtraDimensions ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == INITIALIZER_PROPERTY ) { if ( get ) { return getInitializer ( ) ; } else { setInitializer ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return VARIABLE_DECLARATION_FRAGMENT ; } ASTNode clone0 ( AST target ) { VariableDeclarationFragment result = new VariableDeclarationFragment ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . setExtraDimensions ( getExtraDimensions ( ) ) ; result . setInitializer ( ( Expression ) ASTNode . copySubtree ( target , getInitializer ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getName ( ) ) ; acceptChild ( visitor , getInitializer ( ) ) ; } visitor . endVisit ( this ) ; } public SimpleName getName ( ) { if ( this . variableName == null ) { synchronized ( this ) { if ( this . variableName == null ) { preLazyInit ( ) ; this . variableName = new SimpleName ( this . ast ) ; postLazyInit ( this . variableName , NAME_PROPERTY ) ; } } } return this . variableName ; } public void setName ( SimpleName variableName ) { if ( variableName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . variableName ; preReplaceChild ( oldChild , variableName , NAME_PROPERTY ) ; this . variableName = variableName ; postReplaceChild ( oldChild , variableName , NAME_PROPERTY ) ; } public int getExtraDimensions ( ) { return this . extraArrayDimensions ; } public void setExtraDimensions ( int dimensions ) { if ( dimensions < <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } preValueChange ( EXTRA_DIMENSIONS_PROPERTY ) ; this . extraArrayDimensions = dimensions ; postValueChange ( EXTRA_DIMENSIONS_PROPERTY ) ; } public Expression getInitializer ( ) { return this . optionalInitializer ; } public void setInitializer ( Expression initializer ) { ASTNode oldChild = this . optionalInitializer ; preReplaceChild ( oldChild , initializer , INITIALIZER_PROPERTY ) ; this . optionalInitializer = initializer ; postReplaceChild ( oldChild , initializer , INITIALIZER_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . variableName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . optionalInitializer == null ? <NUM_LIT:0> : getInitializer ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class CatchClause extends ASTNode { public static final ChildPropertyDescriptor EXCEPTION_PROPERTY = new ChildPropertyDescriptor ( CatchClause . class , "<STR_LIT>" , SingleVariableDeclaration . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( CatchClause . class , "<STR_LIT:body>" , Block . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( CatchClause . class , properyList ) ; addProperty ( EXCEPTION_PROPERTY , properyList ) ; addProperty ( BODY_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Block body = null ; private SingleVariableDeclaration exceptionDecl = null ; CatchClause ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXCEPTION_PROPERTY ) { if ( get ) { return getException ( ) ; } else { setException ( ( SingleVariableDeclaration ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Block ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return CATCH_CLAUSE ; } ASTNode clone0 ( AST target ) { CatchClause result = new CatchClause ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setBody ( ( Block ) getBody ( ) . clone ( target ) ) ; result . setException ( ( SingleVariableDeclaration ) ASTNode . copySubtree ( target , getException ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getException ( ) ) ; acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public SingleVariableDeclaration getException ( ) { if ( this . exceptionDecl == null ) { synchronized ( this ) { if ( this . exceptionDecl == null ) { preLazyInit ( ) ; this . exceptionDecl = new SingleVariableDeclaration ( this . ast ) ; postLazyInit ( this . exceptionDecl , EXCEPTION_PROPERTY ) ; } } } return this . exceptionDecl ; } public void setException ( SingleVariableDeclaration exception ) { if ( exception == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . exceptionDecl ; preReplaceChild ( oldChild , exception , EXCEPTION_PROPERTY ) ; this . exceptionDecl = exception ; postReplaceChild ( oldChild , exception , EXCEPTION_PROPERTY ) ; } public Block getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new Block ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Block body ) { if ( body == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , body , BODY_PROPERTY ) ; this . body = body ; postReplaceChild ( oldChild , body , BODY_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . exceptionDecl == null ? <NUM_LIT:0> : getException ( ) . treeSize ( ) ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . Hashtable ; import java . util . List ; import java . util . Map ; import org . eclipse . text . edits . MultiTextEdit ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . jface . text . IDocument ; import org . eclipse . jface . text . TextUtilities ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . dom . SimplePropertyDescriptor ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScannerData ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteAnalyzer ; import org . eclipse . jdt . internal . core . dom . rewrite . LineInformation ; import org . eclipse . jdt . internal . core . dom . rewrite . ListRewriteEvent ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeRewriteEvent ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . PropertyLocation ; class InternalASTRewrite extends NodeEventHandler { private CompilationUnit root ; protected final RewriteEventStore eventStore ; protected final NodeInfoStore nodeStore ; protected final Hashtable clonedNodes ; int cloneDepth = <NUM_LIT:0> ; public InternalASTRewrite ( CompilationUnit root ) { this . root = root ; this . eventStore = new RewriteEventStore ( ) ; this . nodeStore = new NodeInfoStore ( root . getAST ( ) ) ; this . clonedNodes = new Hashtable ( ) ; } public TextEdit rewriteAST ( IDocument document , Map options ) { TextEdit result = new MultiTextEdit ( ) ; final CompilationUnit rootNode = getRootNode ( ) ; if ( rootNode != null ) { TargetSourceRangeComputer xsrComputer = new TargetSourceRangeComputer ( ) { public SourceRange computeSourceRange ( ASTNode node ) { int extendedStartPosition = rootNode . getExtendedStartPosition ( node ) ; int extendedLength = rootNode . getExtendedLength ( node ) ; return new SourceRange ( extendedStartPosition , extendedLength ) ; } } ; char [ ] content = document . get ( ) . toCharArray ( ) ; LineInformation lineInfo = LineInformation . create ( document ) ; String lineDelim = TextUtilities . getDefaultLineDelimiter ( document ) ; List comments = rootNode . getCommentList ( ) ; Map currentOptions = options == null ? JavaCore . getOptions ( ) : options ; ASTRewriteAnalyzer visitor = new ASTRewriteAnalyzer ( content , lineInfo , lineDelim , result , this . eventStore , this . nodeStore , comments , currentOptions , xsrComputer , ( RecoveryScannerData ) rootNode . getStatementsRecoveryData ( ) ) ; rootNode . accept ( visitor ) ; } return result ; } private void markAsMoveOrCopyTarget ( ASTNode node , ASTNode newChild ) { ASTNode source = ( ASTNode ) this . clonedNodes . get ( newChild ) ; if ( source != null ) { if ( this . cloneDepth == <NUM_LIT:0> ) { PropertyLocation propertyLocation = this . eventStore . getPropertyLocation ( source , RewriteEventStore . ORIGINAL ) ; CopySourceInfo sourceInfo = this . eventStore . markAsCopySource ( propertyLocation . getParent ( ) , propertyLocation . getProperty ( ) , source , false ) ; this . nodeStore . markAsCopyTarget ( newChild , sourceInfo ) ; } } else if ( ( newChild . getFlags ( ) & ASTNode . ORIGINAL ) != <NUM_LIT:0> ) { PropertyLocation propertyLocation = this . eventStore . getPropertyLocation ( newChild , RewriteEventStore . ORIGINAL ) ; CopySourceInfo sourceInfo = this . eventStore . markAsCopySource ( propertyLocation . getParent ( ) , propertyLocation . getProperty ( ) , newChild , true ) ; this . nodeStore . markAsCopyTarget ( newChild , sourceInfo ) ; } } private CompilationUnit getRootNode ( ) { return this . root ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "<STR_LIT>" ) ; buf . append ( this . eventStore . toString ( ) ) ; return buf . toString ( ) ; } void preValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { getNodeEvent ( node , property ) ; } void postValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( node . getStructuralProperty ( property ) ) ; } void preAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { if ( property . isChildProperty ( ) ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( child ) ; if ( child != null ) { markAsMoveOrCopyTarget ( node , child ) ; } } else if ( property . isChildListProperty ( ) ) { getListEvent ( node , property ) ; } } void postAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { if ( property . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( node , property ) ; List list = ( List ) node . getStructuralProperty ( property ) ; int i = list . indexOf ( child ) ; int s = list . size ( ) ; int index ; if ( i + <NUM_LIT:1> < s ) { ASTNode nextNode = ( ASTNode ) list . get ( i + <NUM_LIT:1> ) ; index = event . getIndex ( nextNode , ListRewriteEvent . NEW ) ; } else { index = - <NUM_LIT:1> ; } event . insert ( child , index ) ; if ( child != null ) { markAsMoveOrCopyTarget ( node , child ) ; } } } void preRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { if ( property . isChildProperty ( ) ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( null ) ; } else if ( property . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( node , property ) ; int i = event . getIndex ( child , ListRewriteEvent . NEW ) ; NodeRewriteEvent nodeEvent = ( NodeRewriteEvent ) event . getChildren ( ) [ i ] ; if ( nodeEvent . getOriginalValue ( ) == null ) { event . revertChange ( nodeEvent ) ; } else { nodeEvent . setNewValue ( null ) ; } } } void preReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { if ( property . isChildProperty ( ) ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( newChild ) ; if ( newChild != null ) { markAsMoveOrCopyTarget ( node , newChild ) ; } } else if ( property . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( node , property ) ; int i = event . getIndex ( child , ListRewriteEvent . NEW ) ; NodeRewriteEvent nodeEvent = ( NodeRewriteEvent ) event . getChildren ( ) [ i ] ; nodeEvent . setNewValue ( newChild ) ; if ( newChild != null ) { markAsMoveOrCopyTarget ( node , newChild ) ; } } } void preCloneNodeEvent ( ASTNode node ) { this . cloneDepth ++ ; } void postCloneNodeEvent ( ASTNode node , ASTNode clone ) { if ( node . ast == this . root . ast && clone . ast == this . root . ast ) { if ( ( node . getFlags ( ) & ASTNode . ORIGINAL ) != <NUM_LIT:0> ) { this . clonedNodes . put ( clone , node ) ; } else { Object original = this . clonedNodes . get ( node ) ; if ( original != null ) { this . clonedNodes . put ( clone , original ) ; } } } this . cloneDepth -- ; } private NodeRewriteEvent getNodeEvent ( ASTNode node , StructuralPropertyDescriptor property ) { return this . eventStore . getNodeEvent ( node , property , true ) ; } private ListRewriteEvent getListEvent ( ASTNode node , StructuralPropertyDescriptor property ) { return this . eventStore . getListEvent ( node , property , true ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public interface IMemberValuePairBinding extends IBinding { public String getName ( ) ; public IMethodBinding getMethodBinding ( ) ; public Object getValue ( ) ; public boolean isDefault ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class SimpleType extends Type { public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( SimpleType . class , "<STR_LIT:name>" , Name . class , MANDATORY , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( SimpleType . class , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Name typeName = null ; SimpleType ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( Name ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return SIMPLE_TYPE ; } ASTNode clone0 ( AST target ) { SimpleType result = new SimpleType ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setName ( ( Name ) ( getName ( ) ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Name getName ( ) { if ( this . typeName == null ) { synchronized ( this ) { if ( this . typeName == null ) { preLazyInit ( ) ; this . typeName = new SimpleName ( this . ast ) ; postLazyInit ( this . typeName , NAME_PROPERTY ) ; } } } return this . typeName ; } public void setName ( Name typeName ) { if ( typeName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . typeName ; preReplaceChild ( oldChild , typeName , NAME_PROPERTY ) ; this . typeName = typeName ; postReplaceChild ( oldChild , typeName , NAME_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class TypeDeclarationStatement extends Statement { public static final ChildPropertyDescriptor TYPE_DECLARATION_PROPERTY = new ChildPropertyDescriptor ( TypeDeclarationStatement . class , "<STR_LIT>" , TypeDeclaration . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor DECLARATION_PROPERTY = new ChildPropertyDescriptor ( TypeDeclarationStatement . class , "<STR_LIT>" , AbstractTypeDeclaration . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( TypeDeclarationStatement . class , propertyList ) ; addProperty ( TYPE_DECLARATION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( TypeDeclarationStatement . class , propertyList ) ; addProperty ( DECLARATION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private AbstractTypeDeclaration typeDecl = null ; private ChildPropertyDescriptor typeDeclProperty ( ) { if ( getAST ( ) . apiLevel ( ) == AST . JLS2_INTERNAL ) { return TYPE_DECLARATION_PROPERTY ; } else { return DECLARATION_PROPERTY ; } } TypeDeclarationStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_DECLARATION_PROPERTY ) { if ( get ) { return getTypeDeclaration ( ) ; } else { setTypeDeclaration ( ( TypeDeclaration ) child ) ; return null ; } } if ( property == DECLARATION_PROPERTY ) { if ( get ) { return getDeclaration ( ) ; } else { setDeclaration ( ( AbstractTypeDeclaration ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return TYPE_DECLARATION_STATEMENT ; } ASTNode clone0 ( AST target ) { TypeDeclarationStatement result = new TypeDeclarationStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setDeclaration ( ( AbstractTypeDeclaration ) getDeclaration ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getDeclaration ( ) ) ; } visitor . endVisit ( this ) ; } public AbstractTypeDeclaration getDeclaration ( ) { if ( this . typeDecl == null ) { synchronized ( this ) { if ( this . typeDecl == null ) { preLazyInit ( ) ; this . typeDecl = new TypeDeclaration ( this . ast ) ; postLazyInit ( this . typeDecl , typeDeclProperty ( ) ) ; } } } return this . typeDecl ; } public void setDeclaration ( AbstractTypeDeclaration decl ) { if ( decl == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . typeDecl ; ChildPropertyDescriptor typeDeclProperty = typeDeclProperty ( ) ; preReplaceChild ( oldChild , decl , typeDeclProperty ) ; this . typeDecl = decl ; postReplaceChild ( oldChild , decl , typeDeclProperty ) ; } public TypeDeclaration getTypeDeclaration ( ) { return internalGetTypeDeclaration ( ) ; } final TypeDeclaration internalGetTypeDeclaration ( ) { supportedOnlyIn2 ( ) ; return ( TypeDeclaration ) getDeclaration ( ) ; } public void setTypeDeclaration ( TypeDeclaration decl ) { internalSetTypeDeclaration ( decl ) ; } final void internalSetTypeDeclaration ( TypeDeclaration decl ) { supportedOnlyIn2 ( ) ; setDeclaration ( decl ) ; } public ITypeBinding resolveBinding ( ) { AbstractTypeDeclaration d = getDeclaration ( ) ; if ( d instanceof TypeDeclaration ) { return ( ( TypeDeclaration ) d ) . resolveBinding ( ) ; } else if ( d instanceof AnnotationTypeDeclaration ) { return ( ( AnnotationTypeDeclaration ) d ) . resolveBinding ( ) ; } else { return null ; } } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeDecl == null ? <NUM_LIT:0> : getDeclaration ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . Iterator ; import java . util . List ; public class ASTMatcher { private boolean matchDocTags ; public ASTMatcher ( ) { this ( false ) ; } public ASTMatcher ( boolean matchDocTags ) { this . matchDocTags = matchDocTags ; } public final boolean safeSubtreeListMatch ( List list1 , List list2 ) { int size1 = list1 . size ( ) ; int size2 = list2 . size ( ) ; if ( size1 != size2 ) { return false ; } for ( Iterator it1 = list1 . iterator ( ) , it2 = list2 . iterator ( ) ; it1 . hasNext ( ) ; ) { ASTNode n1 = ( ASTNode ) it1 . next ( ) ; ASTNode n2 = ( ASTNode ) it2 . next ( ) ; if ( ! n1 . subtreeMatch ( this , n2 ) ) { return false ; } } return true ; } public final boolean safeSubtreeMatch ( Object node1 , Object node2 ) { if ( node1 == null && node2 == null ) { return true ; } if ( node1 == null || node2 == null ) { return false ; } return ( ( ASTNode ) node1 ) . subtreeMatch ( this , node2 ) ; } public static boolean safeEquals ( Object o1 , Object o2 ) { if ( o1 == o2 ) { return true ; } if ( o1 == null || o2 == null ) { return false ; } return o1 . equals ( o2 ) ; } public boolean match ( AnnotationTypeDeclaration node , Object other ) { if ( ! ( other instanceof AnnotationTypeDeclaration ) ) { return false ; } AnnotationTypeDeclaration o = ( AnnotationTypeDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ) ; } public boolean match ( AnnotationTypeMemberDeclaration node , Object other ) { if ( ! ( other instanceof AnnotationTypeMemberDeclaration ) ) { return false ; } AnnotationTypeMemberDeclaration o = ( AnnotationTypeMemberDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeMatch ( node . getDefault ( ) , o . getDefault ( ) ) ) ; } public boolean match ( AnonymousClassDeclaration node , Object other ) { if ( ! ( other instanceof AnonymousClassDeclaration ) ) { return false ; } AnonymousClassDeclaration o = ( AnonymousClassDeclaration ) other ; return safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ; } public boolean match ( ArrayAccess node , Object other ) { if ( ! ( other instanceof ArrayAccess ) ) { return false ; } ArrayAccess o = ( ArrayAccess ) other ; return ( safeSubtreeMatch ( node . getArray ( ) , o . getArray ( ) ) && safeSubtreeMatch ( node . getIndex ( ) , o . getIndex ( ) ) ) ; } public boolean match ( ArrayCreation node , Object other ) { if ( ! ( other instanceof ArrayCreation ) ) { return false ; } ArrayCreation o = ( ArrayCreation ) other ; return ( safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . dimensions ( ) , o . dimensions ( ) ) && safeSubtreeMatch ( node . getInitializer ( ) , o . getInitializer ( ) ) ) ; } public boolean match ( ArrayInitializer node , Object other ) { if ( ! ( other instanceof ArrayInitializer ) ) { return false ; } ArrayInitializer o = ( ArrayInitializer ) other ; return safeSubtreeListMatch ( node . expressions ( ) , o . expressions ( ) ) ; } public boolean match ( ArrayType node , Object other ) { if ( ! ( other instanceof ArrayType ) ) { return false ; } ArrayType o = ( ArrayType ) other ; return safeSubtreeMatch ( node . getComponentType ( ) , o . getComponentType ( ) ) ; } public boolean match ( AssertStatement node , Object other ) { if ( ! ( other instanceof AssertStatement ) ) { return false ; } AssertStatement o = ( AssertStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getMessage ( ) , o . getMessage ( ) ) ) ; } public boolean match ( Assignment node , Object other ) { if ( ! ( other instanceof Assignment ) ) { return false ; } Assignment o = ( Assignment ) other ; return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getLeftHandSide ( ) , o . getLeftHandSide ( ) ) && safeSubtreeMatch ( node . getRightHandSide ( ) , o . getRightHandSide ( ) ) ) ; } public boolean match ( Block node , Object other ) { if ( ! ( other instanceof Block ) ) { return false ; } Block o = ( Block ) other ; return safeSubtreeListMatch ( node . statements ( ) , o . statements ( ) ) ; } public boolean match ( BlockComment node , Object other ) { if ( ! ( other instanceof BlockComment ) ) { return false ; } return true ; } public boolean match ( BooleanLiteral node , Object other ) { if ( ! ( other instanceof BooleanLiteral ) ) { return false ; } BooleanLiteral o = ( BooleanLiteral ) other ; return node . booleanValue ( ) == o . booleanValue ( ) ; } public boolean match ( BreakStatement node , Object other ) { if ( ! ( other instanceof BreakStatement ) ) { return false ; } BreakStatement o = ( BreakStatement ) other ; return safeSubtreeMatch ( node . getLabel ( ) , o . getLabel ( ) ) ; } public boolean match ( CastExpression node , Object other ) { if ( ! ( other instanceof CastExpression ) ) { return false ; } CastExpression o = ( CastExpression ) other ; return ( safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ) ; } public boolean match ( CatchClause node , Object other ) { if ( ! ( other instanceof CatchClause ) ) { return false ; } CatchClause o = ( CatchClause ) other ; return ( safeSubtreeMatch ( node . getException ( ) , o . getException ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( CharacterLiteral node , Object other ) { if ( ! ( other instanceof CharacterLiteral ) ) { return false ; } CharacterLiteral o = ( CharacterLiteral ) other ; return safeEquals ( node . getEscapedValue ( ) , o . getEscapedValue ( ) ) ; } public boolean match ( ClassInstanceCreation node , Object other ) { if ( ! ( other instanceof ClassInstanceCreation ) ) { return false ; } ClassInstanceCreation o = ( ClassInstanceCreation ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( ! safeSubtreeMatch ( node . internalGetName ( ) , o . internalGetName ( ) ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } if ( ! safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) && safeSubtreeMatch ( node . getAnonymousClassDeclaration ( ) , o . getAnonymousClassDeclaration ( ) ) ; } public boolean match ( CompilationUnit node , Object other ) { if ( ! ( other instanceof CompilationUnit ) ) { return false ; } CompilationUnit o = ( CompilationUnit ) other ; return ( safeSubtreeMatch ( node . getPackage ( ) , o . getPackage ( ) ) && safeSubtreeListMatch ( node . imports ( ) , o . imports ( ) ) && safeSubtreeListMatch ( node . types ( ) , o . types ( ) ) ) ; } public boolean match ( ConditionalExpression node , Object other ) { if ( ! ( other instanceof ConditionalExpression ) ) { return false ; } ConditionalExpression o = ( ConditionalExpression ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getThenExpression ( ) , o . getThenExpression ( ) ) && safeSubtreeMatch ( node . getElseExpression ( ) , o . getElseExpression ( ) ) ) ; } public boolean match ( ConstructorInvocation node , Object other ) { if ( ! ( other instanceof ConstructorInvocation ) ) { return false ; } ConstructorInvocation o = ( ConstructorInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ; } public boolean match ( ContinueStatement node , Object other ) { if ( ! ( other instanceof ContinueStatement ) ) { return false ; } ContinueStatement o = ( ContinueStatement ) other ; return safeSubtreeMatch ( node . getLabel ( ) , o . getLabel ( ) ) ; } public boolean match ( UnionType node , Object other ) { if ( ! ( other instanceof UnionType ) ) { return false ; } UnionType o = ( UnionType ) other ; return safeSubtreeListMatch ( node . types ( ) , o . types ( ) ) ; } public boolean match ( DoStatement node , Object other ) { if ( ! ( other instanceof DoStatement ) ) { return false ; } DoStatement o = ( DoStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( EmptyStatement node , Object other ) { if ( ! ( other instanceof EmptyStatement ) ) { return false ; } return true ; } public boolean match ( EnhancedForStatement node , Object other ) { if ( ! ( other instanceof EnhancedForStatement ) ) { return false ; } EnhancedForStatement o = ( EnhancedForStatement ) other ; return ( safeSubtreeMatch ( node . getParameter ( ) , o . getParameter ( ) ) && safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( EnumConstantDeclaration node , Object other ) { if ( ! ( other instanceof EnumConstantDeclaration ) ) { return false ; } EnumConstantDeclaration o = ( EnumConstantDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) && safeSubtreeMatch ( node . getAnonymousClassDeclaration ( ) , o . getAnonymousClassDeclaration ( ) ) ) ; } public boolean match ( EnumDeclaration node , Object other ) { if ( ! ( other instanceof EnumDeclaration ) ) { return false ; } EnumDeclaration o = ( EnumDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . superInterfaceTypes ( ) , o . superInterfaceTypes ( ) ) && safeSubtreeListMatch ( node . enumConstants ( ) , o . enumConstants ( ) ) && safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ) ; } public boolean match ( ExpressionStatement node , Object other ) { if ( ! ( other instanceof ExpressionStatement ) ) { return false ; } ExpressionStatement o = ( ExpressionStatement ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( FieldAccess node , Object other ) { if ( ! ( other instanceof FieldAccess ) ) { return false ; } FieldAccess o = ( FieldAccess ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( FieldDeclaration node , Object other ) { if ( ! ( other instanceof FieldDeclaration ) ) { return false ; } FieldDeclaration o = ( FieldDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ; } public boolean match ( ForStatement node , Object other ) { if ( ! ( other instanceof ForStatement ) ) { return false ; } ForStatement o = ( ForStatement ) other ; return ( safeSubtreeListMatch ( node . initializers ( ) , o . initializers ( ) ) && safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . updaters ( ) , o . updaters ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( IfStatement node , Object other ) { if ( ! ( other instanceof IfStatement ) ) { return false ; } IfStatement o = ( IfStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getThenStatement ( ) , o . getThenStatement ( ) ) && safeSubtreeMatch ( node . getElseStatement ( ) , o . getElseStatement ( ) ) ) ; } public boolean match ( ImportDeclaration node , Object other ) { if ( ! ( other instanceof ImportDeclaration ) ) { return false ; } ImportDeclaration o = ( ImportDeclaration ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3_INTERNAL ) { if ( node . isStatic ( ) != o . isStatic ( ) ) { return false ; } } return ( safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && node . isOnDemand ( ) == o . isOnDemand ( ) ) ; } public boolean match ( InfixExpression node , Object other ) { if ( ! ( other instanceof InfixExpression ) ) { return false ; } InfixExpression o = ( InfixExpression ) other ; if ( node . hasExtendedOperands ( ) && o . hasExtendedOperands ( ) ) { if ( ! safeSubtreeListMatch ( node . extendedOperands ( ) , o . extendedOperands ( ) ) ) { return false ; } } if ( node . hasExtendedOperands ( ) != o . hasExtendedOperands ( ) ) { return false ; } return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getLeftOperand ( ) , o . getLeftOperand ( ) ) && safeSubtreeMatch ( node . getRightOperand ( ) , o . getRightOperand ( ) ) ) ; } public boolean match ( InstanceofExpression node , Object other ) { if ( ! ( other instanceof InstanceofExpression ) ) { return false ; } InstanceofExpression o = ( InstanceofExpression ) other ; return ( safeSubtreeMatch ( node . getLeftOperand ( ) , o . getLeftOperand ( ) ) && safeSubtreeMatch ( node . getRightOperand ( ) , o . getRightOperand ( ) ) ) ; } public boolean match ( Initializer node , Object other ) { if ( ! ( other instanceof Initializer ) ) { return false ; } Initializer o = ( Initializer ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( Javadoc node , Object other ) { if ( ! ( other instanceof Javadoc ) ) { return false ; } Javadoc o = ( Javadoc ) other ; if ( this . matchDocTags ) { return safeSubtreeListMatch ( node . tags ( ) , o . tags ( ) ) ; } else { return compareDeprecatedComment ( node , o ) ; } } private boolean compareDeprecatedComment ( Javadoc first , Javadoc second ) { if ( first . getAST ( ) . apiLevel == AST . JLS2_INTERNAL ) { return safeEquals ( first . getComment ( ) , second . getComment ( ) ) ; } else { return true ; } } public boolean match ( LabeledStatement node , Object other ) { if ( ! ( other instanceof LabeledStatement ) ) { return false ; } LabeledStatement o = ( LabeledStatement ) other ; return ( safeSubtreeMatch ( node . getLabel ( ) , o . getLabel ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( LineComment node , Object other ) { if ( ! ( other instanceof LineComment ) ) { return false ; } return true ; } public boolean match ( MarkerAnnotation node , Object other ) { if ( ! ( other instanceof MarkerAnnotation ) ) { return false ; } MarkerAnnotation o = ( MarkerAnnotation ) other ; return safeSubtreeMatch ( node . getTypeName ( ) , o . getTypeName ( ) ) ; } public boolean match ( MemberRef node , Object other ) { if ( ! ( other instanceof MemberRef ) ) { return false ; } MemberRef o = ( MemberRef ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( MemberValuePair node , Object other ) { if ( ! ( other instanceof MemberValuePair ) ) { return false ; } MemberValuePair o = ( MemberValuePair ) other ; return ( safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeMatch ( node . getValue ( ) , o . getValue ( ) ) ) ; } public boolean match ( MethodRef node , Object other ) { if ( ! ( other instanceof MethodRef ) ) { return false ; } MethodRef o = ( MethodRef ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . parameters ( ) , o . parameters ( ) ) ) ; } public boolean match ( MethodRefParameter node , Object other ) { if ( ! ( other instanceof MethodRefParameter ) ) { return false ; } MethodRefParameter o = ( MethodRefParameter ) other ; int level = node . getAST ( ) . apiLevel ; if ( level >= AST . JLS3_INTERNAL ) { if ( node . isVarargs ( ) != o . isVarargs ( ) ) { return false ; } } return ( safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( MethodDeclaration node , Object other ) { if ( ! ( other instanceof MethodDeclaration ) ) { return false ; } MethodDeclaration o = ( MethodDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } if ( ! safeSubtreeMatch ( node . internalGetReturnType ( ) , o . internalGetReturnType ( ) ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } if ( ! safeSubtreeMatch ( node . getReturnType2 ( ) , o . getReturnType2 ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . typeParameters ( ) , o . typeParameters ( ) ) ) { return false ; } } return ( ( node . isConstructor ( ) == o . isConstructor ( ) ) && safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . parameters ( ) , o . parameters ( ) ) && node . getExtraDimensions ( ) == o . getExtraDimensions ( ) && safeSubtreeListMatch ( node . thrownExceptions ( ) , o . thrownExceptions ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( MethodInvocation node , Object other ) { if ( ! ( other instanceof MethodInvocation ) ) { return false ; } MethodInvocation o = ( MethodInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ) ; } public boolean match ( Modifier node , Object other ) { if ( ! ( other instanceof Modifier ) ) { return false ; } Modifier o = ( Modifier ) other ; return ( node . getKeyword ( ) == o . getKeyword ( ) ) ; } public boolean match ( NormalAnnotation node , Object other ) { if ( ! ( other instanceof NormalAnnotation ) ) { return false ; } NormalAnnotation o = ( NormalAnnotation ) other ; return ( safeSubtreeMatch ( node . getTypeName ( ) , o . getTypeName ( ) ) && safeSubtreeListMatch ( node . values ( ) , o . values ( ) ) ) ; } public boolean match ( NullLiteral node , Object other ) { if ( ! ( other instanceof NullLiteral ) ) { return false ; } return true ; } public boolean match ( NumberLiteral node , Object other ) { if ( ! ( other instanceof NumberLiteral ) ) { return false ; } NumberLiteral o = ( NumberLiteral ) other ; return safeEquals ( node . getToken ( ) , o . getToken ( ) ) ; } public boolean match ( PackageDeclaration node , Object other ) { if ( ! ( other instanceof PackageDeclaration ) ) { return false ; } PackageDeclaration o = ( PackageDeclaration ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . annotations ( ) , o . annotations ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ; } public boolean match ( ParameterizedType node , Object other ) { if ( ! ( other instanceof ParameterizedType ) ) { return false ; } ParameterizedType o = ( ParameterizedType ) other ; return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ; } public boolean match ( ParenthesizedExpression node , Object other ) { if ( ! ( other instanceof ParenthesizedExpression ) ) { return false ; } ParenthesizedExpression o = ( ParenthesizedExpression ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( PostfixExpression node , Object other ) { if ( ! ( other instanceof PostfixExpression ) ) { return false ; } PostfixExpression o = ( PostfixExpression ) other ; return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getOperand ( ) , o . getOperand ( ) ) ) ; } public boolean match ( PrefixExpression node , Object other ) { if ( ! ( other instanceof PrefixExpression ) ) { return false ; } PrefixExpression o = ( PrefixExpression ) other ; return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getOperand ( ) , o . getOperand ( ) ) ) ; } public boolean match ( PrimitiveType node , Object other ) { if ( ! ( other instanceof PrimitiveType ) ) { return false ; } PrimitiveType o = ( PrimitiveType ) other ; return ( node . getPrimitiveTypeCode ( ) == o . getPrimitiveTypeCode ( ) ) ; } public boolean match ( QualifiedName node , Object other ) { if ( ! ( other instanceof QualifiedName ) ) { return false ; } QualifiedName o = ( QualifiedName ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( QualifiedType node , Object other ) { if ( ! ( other instanceof QualifiedType ) ) { return false ; } QualifiedType o = ( QualifiedType ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( ReturnStatement node , Object other ) { if ( ! ( other instanceof ReturnStatement ) ) { return false ; } ReturnStatement o = ( ReturnStatement ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( SimpleName node , Object other ) { if ( ! ( other instanceof SimpleName ) ) { return false ; } SimpleName o = ( SimpleName ) other ; return node . getIdentifier ( ) . equals ( o . getIdentifier ( ) ) ; } public boolean match ( SimpleType node , Object other ) { if ( ! ( other instanceof SimpleType ) ) { return false ; } SimpleType o = ( SimpleType ) other ; return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ; } public boolean match ( SingleMemberAnnotation node , Object other ) { if ( ! ( other instanceof SingleMemberAnnotation ) ) { return false ; } SingleMemberAnnotation o = ( SingleMemberAnnotation ) other ; return ( safeSubtreeMatch ( node . getTypeName ( ) , o . getTypeName ( ) ) && safeSubtreeMatch ( node . getValue ( ) , o . getValue ( ) ) ) ; } public boolean match ( SingleVariableDeclaration node , Object other ) { if ( ! ( other instanceof SingleVariableDeclaration ) ) { return false ; } SingleVariableDeclaration o = ( SingleVariableDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } if ( node . isVarargs ( ) != o . isVarargs ( ) ) { return false ; } } return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && node . getExtraDimensions ( ) == o . getExtraDimensions ( ) && safeSubtreeMatch ( node . getInitializer ( ) , o . getInitializer ( ) ) ; } public boolean match ( StringLiteral node , Object other ) { if ( ! ( other instanceof StringLiteral ) ) { return false ; } StringLiteral o = ( StringLiteral ) other ; return safeEquals ( node . getEscapedValue ( ) , o . getEscapedValue ( ) ) ; } public boolean match ( SuperConstructorInvocation node , Object other ) { if ( ! ( other instanceof SuperConstructorInvocation ) ) { return false ; } SuperConstructorInvocation o = ( SuperConstructorInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ) ; } public boolean match ( SuperFieldAccess node , Object other ) { if ( ! ( other instanceof SuperFieldAccess ) ) { return false ; } SuperFieldAccess o = ( SuperFieldAccess ) other ; return ( safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) ) ; } public boolean match ( SuperMethodInvocation node , Object other ) { if ( ! ( other instanceof SuperMethodInvocation ) ) { return false ; } SuperMethodInvocation o = ( SuperMethodInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ) ; } public boolean match ( SwitchCase node , Object other ) { if ( ! ( other instanceof SwitchCase ) ) { return false ; } SwitchCase o = ( SwitchCase ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( SwitchStatement node , Object other ) { if ( ! ( other instanceof SwitchStatement ) ) { return false ; } SwitchStatement o = ( SwitchStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . statements ( ) , o . statements ( ) ) ) ; } public boolean match ( SynchronizedStatement node , Object other ) { if ( ! ( other instanceof SynchronizedStatement ) ) { return false ; } SynchronizedStatement o = ( SynchronizedStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( TagElement node , Object other ) { if ( ! ( other instanceof TagElement ) ) { return false ; } TagElement o = ( TagElement ) other ; return ( safeEquals ( node . getTagName ( ) , o . getTagName ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ) ; } public boolean match ( TextElement node , Object other ) { if ( ! ( other instanceof TextElement ) ) { return false ; } TextElement o = ( TextElement ) other ; return safeEquals ( node . getText ( ) , o . getText ( ) ) ; } public boolean match ( ThisExpression node , Object other ) { if ( ! ( other instanceof ThisExpression ) ) { return false ; } ThisExpression o = ( ThisExpression ) other ; return safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) ; } public boolean match ( ThrowStatement node , Object other ) { if ( ! ( other instanceof ThrowStatement ) ) { return false ; } ThrowStatement o = ( ThrowStatement ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( TryStatement node , Object other ) { if ( ! ( other instanceof TryStatement ) ) { return false ; } TryStatement o = ( TryStatement ) other ; switch ( node . getAST ( ) . apiLevel ) { case AST . JLS2_INTERNAL : case AST . JLS3_INTERNAL : return ( safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) && safeSubtreeListMatch ( node . catchClauses ( ) , o . catchClauses ( ) ) && safeSubtreeMatch ( node . getFinally ( ) , o . getFinally ( ) ) ) ; } return ( safeSubtreeListMatch ( node . resources ( ) , o . resources ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) && safeSubtreeListMatch ( node . catchClauses ( ) , o . catchClauses ( ) ) && safeSubtreeMatch ( node . getFinally ( ) , o . getFinally ( ) ) ) ; } public boolean match ( TypeDeclaration node , Object other ) { if ( ! ( other instanceof TypeDeclaration ) ) { return false ; } TypeDeclaration o = ( TypeDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } if ( ! safeSubtreeMatch ( node . internalGetSuperclass ( ) , o . internalGetSuperclass ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . internalSuperInterfaces ( ) , o . internalSuperInterfaces ( ) ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . typeParameters ( ) , o . typeParameters ( ) ) ) { return false ; } if ( ! safeSubtreeMatch ( node . getSuperclassType ( ) , o . getSuperclassType ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . superInterfaceTypes ( ) , o . superInterfaceTypes ( ) ) ) { return false ; } } return ( ( node . isInterface ( ) == o . isInterface ( ) ) && safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ) ; } public boolean match ( TypeDeclarationStatement node , Object other ) { if ( ! ( other instanceof TypeDeclarationStatement ) ) { return false ; } TypeDeclarationStatement o = ( TypeDeclarationStatement ) other ; return safeSubtreeMatch ( node . getDeclaration ( ) , o . getDeclaration ( ) ) ; } public boolean match ( TypeLiteral node , Object other ) { if ( ! ( other instanceof TypeLiteral ) ) { return false ; } TypeLiteral o = ( TypeLiteral ) other ; return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) ; } public boolean match ( TypeParameter node , Object other ) { if ( ! ( other instanceof TypeParameter ) ) { return false ; } TypeParameter o = ( TypeParameter ) other ; return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . typeBounds ( ) , o . typeBounds ( ) ) ; } public boolean match ( VariableDeclarationExpression node , Object other ) { if ( ! ( other instanceof VariableDeclarationExpression ) ) { return false ; } VariableDeclarationExpression o = ( VariableDeclarationExpression ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ; } public boolean match ( VariableDeclarationFragment node , Object other ) { if ( ! ( other instanceof VariableDeclarationFragment ) ) { return false ; } VariableDeclarationFragment o = ( VariableDeclarationFragment ) other ; return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && node . getExtraDimensions ( ) == o . getExtraDimensions ( ) && safeSubtreeMatch ( node . getInitializer ( ) , o . getInitializer ( ) ) ; } public boolean match ( VariableDeclarationStatement node , Object other ) { if ( ! ( other instanceof VariableDeclarationStatement ) ) { return false ; } VariableDeclarationStatement o = ( VariableDeclarationStatement ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3_INTERNAL ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ; } public boolean match ( WhileStatement node , Object other ) { if ( ! ( other instanceof WhileStatement ) ) { return false ; } WhileStatement o = ( WhileStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( WildcardType node , Object other ) { if ( ! ( other instanceof WildcardType ) ) { return false ; } WildcardType o = ( WildcardType ) other ; return node . isUpperBound ( ) == o . isUpperBound ( ) && safeSubtreeMatch ( node . getBound ( ) , o . getBound ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; public interface ITypeBinding extends IBinding { public ITypeBinding createArrayType ( int dimension ) ; public String getBinaryName ( ) ; public ITypeBinding getBound ( ) ; public ITypeBinding getGenericTypeOfWildcardType ( ) ; public int getRank ( ) ; public ITypeBinding getComponentType ( ) ; public IVariableBinding [ ] getDeclaredFields ( ) ; public IMethodBinding [ ] getDeclaredMethods ( ) ; public int getDeclaredModifiers ( ) ; public ITypeBinding [ ] getDeclaredTypes ( ) ; public ITypeBinding getDeclaringClass ( ) ; public IMethodBinding getDeclaringMethod ( ) ; public int getDimensions ( ) ; public ITypeBinding getElementType ( ) ; public ITypeBinding getErasure ( ) ; public ITypeBinding [ ] getInterfaces ( ) ; public int getModifiers ( ) ; public String getName ( ) ; public IPackageBinding getPackage ( ) ; public String getQualifiedName ( ) ; public ITypeBinding getSuperclass ( ) ; public ITypeBinding [ ] getTypeArguments ( ) ; public ITypeBinding [ ] getTypeBounds ( ) ; public ITypeBinding getTypeDeclaration ( ) ; public ITypeBinding [ ] getTypeParameters ( ) ; public ITypeBinding getWildcard ( ) ; public boolean isAnnotation ( ) ; public boolean isAnonymous ( ) ; public boolean isArray ( ) ; public boolean isAssignmentCompatible ( ITypeBinding variableType ) ; public boolean isCapture ( ) ; public boolean isCastCompatible ( ITypeBinding type ) ; public boolean isClass ( ) ; public boolean isEnum ( ) ; public boolean isFromSource ( ) ; public boolean isGenericType ( ) ; public boolean isInterface ( ) ; public boolean isLocal ( ) ; public boolean isMember ( ) ; public boolean isNested ( ) ; public boolean isNullType ( ) ; public boolean isParameterizedType ( ) ; public boolean isPrimitive ( ) ; public boolean isRawType ( ) ; public boolean isSubTypeCompatible ( ITypeBinding type ) ; public boolean isTopLevel ( ) ; public boolean isTypeVariable ( ) ; public boolean isUpperbound ( ) ; public boolean isWildcardType ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . lang . reflect . Constructor ; import java . lang . reflect . InvocationTargetException ; import java . util . ArrayList ; import java . util . List ; import java . util . Map ; import java . util . StringTokenizer ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jface . text . IDocument ; import org . eclipse . text . edits . TextEdit ; public final class AST { private static final Class [ ] AST_CLASS = new Class [ ] { AST . class } ; public static final int JLS2 = <NUM_LIT:2> ; static final int JLS2_INTERNAL = JLS2 ; public static final int JLS3 = <NUM_LIT:3> ; static final int JLS3_INTERNAL = JLS3 ; public static final int JLS4 = <NUM_LIT:4> ; static final int RESOLVED_BINDINGS = <NUM_LIT> ; public static CompilationUnit convertCompilationUnit ( int level , org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration compilationUnitDeclaration , char [ ] source , Map options , boolean isResolved , org . eclipse . jdt . internal . core . CompilationUnit workingCopy , int reconcileFlags , IProgressMonitor monitor ) { return null ; } public static CompilationUnit convertCompilationUnit ( int level , org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration compilationUnitDeclaration , Map options , boolean isResolved , org . eclipse . jdt . internal . core . CompilationUnit workingCopy , int reconcileFlags , IProgressMonitor monitor ) { ASTConverter converter = new ASTConverter ( options , isResolved , monitor ) ; AST ast = AST . newAST ( level ) ; int savedDefaultNodeFlag = ast . getDefaultNodeFlag ( ) ; ast . setDefaultNodeFlag ( ASTNode . ORIGINAL ) ; BindingResolver resolver = null ; if ( isResolved ) { resolver = new DefaultBindingResolver ( compilationUnitDeclaration . scope , workingCopy . owner , new DefaultBindingResolver . BindingTables ( ) , false , true ) ; ( ( DefaultBindingResolver ) resolver ) . isRecoveringBindings = ( reconcileFlags & ICompilationUnit . ENABLE_BINDINGS_RECOVERY ) != <NUM_LIT:0> ; ast . setFlag ( AST . RESOLVED_BINDINGS ) ; } else { resolver = new BindingResolver ( ) ; } ast . setFlag ( reconcileFlags ) ; ast . setBindingResolver ( resolver ) ; converter . setAST ( ast ) ; CompilationUnit unit = converter . convert ( compilationUnitDeclaration , workingCopy . getContents ( ) ) ; unit . setLineEndTable ( compilationUnitDeclaration . compilationResult . getLineSeparatorPositions ( ) ) ; unit . setTypeRoot ( workingCopy . originalFromClone ( ) ) ; ast . setDefaultNodeFlag ( savedDefaultNodeFlag ) ; return unit ; } public static AST newAST ( int level ) { return new AST ( level ) ; } public static CompilationUnit parseCompilationUnit ( char [ ] source ) { if ( source == null ) { throw new IllegalArgumentException ( ) ; } ASTParser c = ASTParser . newParser ( AST . JLS2 ) ; c . setSource ( source ) ; ASTNode result = c . createAST ( null ) ; return ( CompilationUnit ) result ; } public static CompilationUnit parseCompilationUnit ( char [ ] source , String unitName , IJavaProject project ) { if ( source == null ) { throw new IllegalArgumentException ( ) ; } ASTParser astParser = ASTParser . newParser ( AST . JLS2 ) ; astParser . setSource ( source ) ; astParser . setUnitName ( unitName ) ; astParser . setProject ( project ) ; astParser . setResolveBindings ( project != null ) ; ASTNode result = astParser . createAST ( null ) ; return ( CompilationUnit ) result ; } public static CompilationUnit parseCompilationUnit ( IClassFile classFile , boolean resolveBindings ) { if ( classFile == null ) { throw new IllegalArgumentException ( ) ; } try { ASTParser c = ASTParser . newParser ( AST . JLS2 ) ; c . setSource ( classFile ) ; c . setResolveBindings ( resolveBindings ) ; ASTNode result = c . createAST ( null ) ; return ( CompilationUnit ) result ; } catch ( IllegalStateException e ) { throw new IllegalArgumentException ( ) ; } } public static CompilationUnit parseCompilationUnit ( ICompilationUnit unit , boolean resolveBindings ) { try { ASTParser c = ASTParser . newParser ( AST . JLS2 ) ; c . setSource ( unit ) ; c . setResolveBindings ( resolveBindings ) ; ASTNode result = c . createAST ( null ) ; return ( CompilationUnit ) result ; } catch ( IllegalStateException e ) { throw new IllegalArgumentException ( ) ; } } int apiLevel ; private int bits ; private int defaultNodeFlag = <NUM_LIT:0> ; private int disableEvents = <NUM_LIT:0> ; private NodeEventHandler eventHandler = new NodeEventHandler ( ) ; private final Object internalASTLock = new Object ( ) ; private long modificationCount = <NUM_LIT:0> ; private long originalModificationCount = <NUM_LIT:0> ; private BindingResolver resolver = new BindingResolver ( ) ; InternalASTRewrite rewriter ; Scanner scanner ; private final Object [ ] THIS_AST = new Object [ ] { this } ; public AST ( ) { this ( JavaCore . getDefaultOptions ( ) ) ; } private AST ( int level ) { switch ( level ) { case JLS2_INTERNAL : case JLS3_INTERNAL : this . apiLevel = level ; this . scanner = new Scanner ( true , true , false , ClassFileConstants . JDK1_3 , ClassFileConstants . JDK1_5 , null , null , true ) ; break ; case JLS4 : this . apiLevel = level ; this . scanner = new Scanner ( true , true , false , ClassFileConstants . JDK1_7 , ClassFileConstants . JDK1_7 , null , null , true ) ; break ; default : throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } public AST ( Map options ) { this ( JLS2 ) ; Object sourceLevelOption = options . get ( JavaCore . COMPILER_SOURCE ) ; long sourceLevel = ClassFileConstants . JDK1_3 ; if ( JavaCore . VERSION_1_4 . equals ( sourceLevelOption ) ) { sourceLevel = ClassFileConstants . JDK1_4 ; } else if ( JavaCore . VERSION_1_5 . equals ( sourceLevelOption ) ) { sourceLevel = ClassFileConstants . JDK1_5 ; } else if ( JavaCore . VERSION_1_7 . equals ( sourceLevelOption ) ) { sourceLevel = ClassFileConstants . JDK1_7 ; } Object complianceLevelOption = options . get ( JavaCore . COMPILER_COMPLIANCE ) ; long complianceLevel = ClassFileConstants . JDK1_3 ; if ( JavaCore . VERSION_1_4 . equals ( complianceLevelOption ) ) { complianceLevel = ClassFileConstants . JDK1_4 ; } else if ( JavaCore . VERSION_1_5 . equals ( complianceLevelOption ) ) { complianceLevel = ClassFileConstants . JDK1_5 ; } else if ( JavaCore . VERSION_1_7 . equals ( complianceLevelOption ) ) { complianceLevel = ClassFileConstants . JDK1_7 ; } this . scanner = new Scanner ( true , true , false , sourceLevel , complianceLevel , null , null , true ) ; } public int apiLevel ( ) { return this . apiLevel ; } public ASTNode createInstance ( Class nodeClass ) { if ( nodeClass == null ) { throw new IllegalArgumentException ( ) ; } try { Constructor c = nodeClass . getDeclaredConstructor ( AST_CLASS ) ; Object result = c . newInstance ( this . THIS_AST ) ; return ( ASTNode ) result ; } catch ( NoSuchMethodException e ) { throw new IllegalArgumentException ( ) ; } catch ( InstantiationException e ) { throw new IllegalArgumentException ( ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( ) ; } catch ( InvocationTargetException e ) { throw new IllegalArgumentException ( ) ; } } public ASTNode createInstance ( int nodeType ) { Class nodeClass = ASTNode . nodeClassForType ( nodeType ) ; return createInstance ( nodeClass ) ; } final void disableEvents ( ) { synchronized ( this . internalASTLock ) { this . disableEvents ++ ; } } BindingResolver getBindingResolver ( ) { return this . resolver ; } int getDefaultNodeFlag ( ) { return this . defaultNodeFlag ; } NodeEventHandler getEventHandler ( ) { return this . eventHandler ; } public boolean hasBindingsRecovery ( ) { return ( this . bits & ICompilationUnit . ENABLE_BINDINGS_RECOVERY ) != <NUM_LIT:0> ; } public boolean hasResolvedBindings ( ) { return ( this . bits & RESOLVED_BINDINGS ) != <NUM_LIT:0> ; } public boolean hasStatementsRecovery ( ) { return ( this . bits & ICompilationUnit . ENABLE_STATEMENTS_RECOVERY ) != <NUM_LIT:0> ; } Name internalNewName ( String [ ] identifiers ) { int count = identifiers . length ; if ( count == <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } final SimpleName simpleName = new SimpleName ( this ) ; simpleName . internalSetIdentifier ( identifiers [ <NUM_LIT:0> ] ) ; Name result = simpleName ; for ( int i = <NUM_LIT:1> ; i < count ; i ++ ) { SimpleName name = new SimpleName ( this ) ; name . internalSetIdentifier ( identifiers [ i ] ) ; result = newQualifiedName ( result , name ) ; } return result ; } public long modificationCount ( ) { return this . modificationCount ; } void modifying ( ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } this . modificationCount ++ ; } public AnnotationTypeDeclaration newAnnotationTypeDeclaration ( ) { AnnotationTypeDeclaration result = new AnnotationTypeDeclaration ( this ) ; return result ; } public AnnotationTypeMemberDeclaration newAnnotationTypeMemberDeclaration ( ) { AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration ( this ) ; return result ; } public AnonymousClassDeclaration newAnonymousClassDeclaration ( ) { AnonymousClassDeclaration result = new AnonymousClassDeclaration ( this ) ; return result ; } public ArrayAccess newArrayAccess ( ) { ArrayAccess result = new ArrayAccess ( this ) ; return result ; } public ArrayCreation newArrayCreation ( ) { ArrayCreation result = new ArrayCreation ( this ) ; return result ; } public ArrayInitializer newArrayInitializer ( ) { ArrayInitializer result = new ArrayInitializer ( this ) ; return result ; } public ArrayType newArrayType ( Type componentType ) { ArrayType result = new ArrayType ( this ) ; result . setComponentType ( componentType ) ; return result ; } public ArrayType newArrayType ( Type elementType , int dimensions ) { if ( elementType == null ) { throw new IllegalArgumentException ( ) ; } if ( dimensions < <NUM_LIT:1> || dimensions > <NUM_LIT:1000> ) { throw new IllegalArgumentException ( ) ; } ArrayType result = new ArrayType ( this ) ; result . setComponentType ( elementType ) ; for ( int i = <NUM_LIT:2> ; i <= dimensions ; i ++ ) { result = newArrayType ( result ) ; } return result ; } public AssertStatement newAssertStatement ( ) { return new AssertStatement ( this ) ; } public Assignment newAssignment ( ) { Assignment result = new Assignment ( this ) ; return result ; } public Block newBlock ( ) { return new Block ( this ) ; } public BlockComment newBlockComment ( ) { BlockComment result = new BlockComment ( this ) ; return result ; } public BooleanLiteral newBooleanLiteral ( boolean value ) { BooleanLiteral result = new BooleanLiteral ( this ) ; result . setBooleanValue ( value ) ; return result ; } public BreakStatement newBreakStatement ( ) { return new BreakStatement ( this ) ; } public CastExpression newCastExpression ( ) { CastExpression result = new CastExpression ( this ) ; return result ; } public CatchClause newCatchClause ( ) { return new CatchClause ( this ) ; } public CharacterLiteral newCharacterLiteral ( ) { return new CharacterLiteral ( this ) ; } public ClassInstanceCreation newClassInstanceCreation ( ) { ClassInstanceCreation result = new ClassInstanceCreation ( this ) ; return result ; } public CompilationUnit newCompilationUnit ( ) { return new CompilationUnit ( this ) ; } public ConditionalExpression newConditionalExpression ( ) { ConditionalExpression result = new ConditionalExpression ( this ) ; return result ; } public ConstructorInvocation newConstructorInvocation ( ) { ConstructorInvocation result = new ConstructorInvocation ( this ) ; return result ; } public ContinueStatement newContinueStatement ( ) { return new ContinueStatement ( this ) ; } public UnionType newUnionType ( ) { return new UnionType ( this ) ; } public DoStatement newDoStatement ( ) { return new DoStatement ( this ) ; } public EmptyStatement newEmptyStatement ( ) { return new EmptyStatement ( this ) ; } public EnhancedForStatement newEnhancedForStatement ( ) { return new EnhancedForStatement ( this ) ; } public EnumConstantDeclaration newEnumConstantDeclaration ( ) { EnumConstantDeclaration result = new EnumConstantDeclaration ( this ) ; return result ; } public EnumDeclaration newEnumDeclaration ( ) { EnumDeclaration result = new EnumDeclaration ( this ) ; return result ; } public ExpressionStatement newExpressionStatement ( Expression expression ) { ExpressionStatement result = new ExpressionStatement ( this ) ; result . setExpression ( expression ) ; return result ; } public FieldAccess newFieldAccess ( ) { FieldAccess result = new FieldAccess ( this ) ; return result ; } public FieldDeclaration newFieldDeclaration ( VariableDeclarationFragment fragment ) { if ( fragment == null ) { throw new IllegalArgumentException ( ) ; } FieldDeclaration result = new FieldDeclaration ( this ) ; result . fragments ( ) . add ( fragment ) ; return result ; } public ForStatement newForStatement ( ) { return new ForStatement ( this ) ; } public IfStatement newIfStatement ( ) { return new IfStatement ( this ) ; } public ImportDeclaration newImportDeclaration ( ) { ImportDeclaration result = new ImportDeclaration ( this ) ; return result ; } public InfixExpression newInfixExpression ( ) { InfixExpression result = new InfixExpression ( this ) ; return result ; } public Initializer newInitializer ( ) { Initializer result = new Initializer ( this ) ; return result ; } public InstanceofExpression newInstanceofExpression ( ) { InstanceofExpression result = new InstanceofExpression ( this ) ; return result ; } public Javadoc newJavadoc ( ) { Javadoc result = new Javadoc ( this ) ; return result ; } public LabeledStatement newLabeledStatement ( ) { return new LabeledStatement ( this ) ; } public LineComment newLineComment ( ) { LineComment result = new LineComment ( this ) ; return result ; } public MarkerAnnotation newMarkerAnnotation ( ) { MarkerAnnotation result = new MarkerAnnotation ( this ) ; return result ; } public MemberRef newMemberRef ( ) { MemberRef result = new MemberRef ( this ) ; return result ; } public MemberValuePair newMemberValuePair ( ) { MemberValuePair result = new MemberValuePair ( this ) ; return result ; } public MethodDeclaration newMethodDeclaration ( ) { MethodDeclaration result = new MethodDeclaration ( this ) ; result . setConstructor ( false ) ; return result ; } public MethodInvocation newMethodInvocation ( ) { MethodInvocation result = new MethodInvocation ( this ) ; return result ; } public MethodRef newMethodRef ( ) { MethodRef result = new MethodRef ( this ) ; return result ; } public MethodRefParameter newMethodRefParameter ( ) { MethodRefParameter result = new MethodRefParameter ( this ) ; return result ; } public Modifier newModifier ( Modifier . ModifierKeyword keyword ) { Modifier result = new Modifier ( this ) ; result . setKeyword ( keyword ) ; return result ; } public List newModifiers ( int flags ) { if ( this . apiLevel == AST . JLS2 ) { unsupportedIn2 ( ) ; } List result = new ArrayList ( <NUM_LIT:3> ) ; if ( Modifier . isPublic ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . PUBLIC_KEYWORD ) ) ; } if ( Modifier . isProtected ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . PROTECTED_KEYWORD ) ) ; } if ( Modifier . isPrivate ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . PRIVATE_KEYWORD ) ) ; } if ( Modifier . isAbstract ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ) ; } if ( Modifier . isStatic ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . STATIC_KEYWORD ) ) ; } if ( Modifier . isFinal ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . FINAL_KEYWORD ) ) ; } if ( Modifier . isSynchronized ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . SYNCHRONIZED_KEYWORD ) ) ; } if ( Modifier . isNative ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . NATIVE_KEYWORD ) ) ; } if ( Modifier . isStrictfp ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . STRICTFP_KEYWORD ) ) ; } if ( Modifier . isTransient ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . TRANSIENT_KEYWORD ) ) ; } if ( Modifier . isVolatile ( flags ) ) { result . add ( newModifier ( Modifier . ModifierKeyword . VOLATILE_KEYWORD ) ) ; } return result ; } public Name newName ( String qualifiedName ) { StringTokenizer t = new StringTokenizer ( qualifiedName , "<STR_LIT:.>" , true ) ; Name result = null ; int balance = <NUM_LIT:0> ; while ( t . hasMoreTokens ( ) ) { String s = t . nextToken ( ) ; if ( s . indexOf ( '<CHAR_LIT:.>' ) >= <NUM_LIT:0> ) { if ( s . length ( ) > <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } balance -- ; if ( balance < <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } } else { balance ++ ; SimpleName name = newSimpleName ( s ) ; if ( result == null ) { result = name ; } else { result = newQualifiedName ( result , name ) ; } } } if ( balance != <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } return result ; } public Name newName ( String [ ] identifiers ) { int count = identifiers . length ; if ( count == <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } Name result = newSimpleName ( identifiers [ <NUM_LIT:0> ] ) ; for ( int i = <NUM_LIT:1> ; i < count ; i ++ ) { SimpleName name = newSimpleName ( identifiers [ i ] ) ; result = newQualifiedName ( result , name ) ; } return result ; } public NormalAnnotation newNormalAnnotation ( ) { NormalAnnotation result = new NormalAnnotation ( this ) ; return result ; } public NullLiteral newNullLiteral ( ) { return new NullLiteral ( this ) ; } public NumberLiteral newNumberLiteral ( ) { NumberLiteral result = new NumberLiteral ( this ) ; return result ; } public NumberLiteral newNumberLiteral ( String literal ) { if ( literal == null ) { throw new IllegalArgumentException ( ) ; } NumberLiteral result = new NumberLiteral ( this ) ; result . setToken ( literal ) ; return result ; } public PackageDeclaration newPackageDeclaration ( ) { PackageDeclaration result = new PackageDeclaration ( this ) ; return result ; } public ParameterizedType newParameterizedType ( Type type ) { ParameterizedType result = new ParameterizedType ( this ) ; result . setType ( type ) ; return result ; } public ParenthesizedExpression newParenthesizedExpression ( ) { ParenthesizedExpression result = new ParenthesizedExpression ( this ) ; return result ; } public PostfixExpression newPostfixExpression ( ) { PostfixExpression result = new PostfixExpression ( this ) ; return result ; } public PrefixExpression newPrefixExpression ( ) { PrefixExpression result = new PrefixExpression ( this ) ; return result ; } public PrimitiveType newPrimitiveType ( PrimitiveType . Code typeCode ) { PrimitiveType result = new PrimitiveType ( this ) ; result . setPrimitiveTypeCode ( typeCode ) ; return result ; } public QualifiedName newQualifiedName ( Name qualifier , SimpleName name ) { QualifiedName result = new QualifiedName ( this ) ; result . setQualifier ( qualifier ) ; result . setName ( name ) ; return result ; } public QualifiedType newQualifiedType ( Type qualifier , SimpleName name ) { QualifiedType result = new QualifiedType ( this ) ; result . setQualifier ( qualifier ) ; result . setName ( name ) ; return result ; } public ReturnStatement newReturnStatement ( ) { return new ReturnStatement ( this ) ; } public SimpleName newSimpleName ( String identifier ) { if ( identifier == null ) { throw new IllegalArgumentException ( ) ; } SimpleName result = new SimpleName ( this ) ; result . setIdentifier ( identifier ) ; return result ; } public SimpleType newSimpleType ( Name typeName ) { SimpleType result = new SimpleType ( this ) ; result . setName ( typeName ) ; return result ; } public SingleMemberAnnotation newSingleMemberAnnotation ( ) { SingleMemberAnnotation result = new SingleMemberAnnotation ( this ) ; return result ; } public SingleVariableDeclaration newSingleVariableDeclaration ( ) { SingleVariableDeclaration result = new SingleVariableDeclaration ( this ) ; return result ; } public StringLiteral newStringLiteral ( ) { return new StringLiteral ( this ) ; } public SuperConstructorInvocation newSuperConstructorInvocation ( ) { SuperConstructorInvocation result = new SuperConstructorInvocation ( this ) ; return result ; } public SuperFieldAccess newSuperFieldAccess ( ) { SuperFieldAccess result = new SuperFieldAccess ( this ) ; return result ; } public SuperMethodInvocation newSuperMethodInvocation ( ) { SuperMethodInvocation result = new SuperMethodInvocation ( this ) ; return result ; } public SwitchCase newSwitchCase ( ) { return new SwitchCase ( this ) ; } public SwitchStatement newSwitchStatement ( ) { return new SwitchStatement ( this ) ; } public SynchronizedStatement newSynchronizedStatement ( ) { return new SynchronizedStatement ( this ) ; } public TagElement newTagElement ( ) { TagElement result = new TagElement ( this ) ; return result ; } public TextElement newTextElement ( ) { TextElement result = new TextElement ( this ) ; return result ; } public ThisExpression newThisExpression ( ) { ThisExpression result = new ThisExpression ( this ) ; return result ; } public ThrowStatement newThrowStatement ( ) { return new ThrowStatement ( this ) ; } public TryStatement newTryStatement ( ) { return new TryStatement ( this ) ; } public TypeDeclaration newTypeDeclaration ( ) { TypeDeclaration result = new TypeDeclaration ( this ) ; result . setInterface ( false ) ; return result ; } public TypeDeclarationStatement newTypeDeclarationStatement ( AbstractTypeDeclaration decl ) { TypeDeclarationStatement result = new TypeDeclarationStatement ( this ) ; if ( this . apiLevel == AST . JLS2 ) { result . internalSetTypeDeclaration ( ( TypeDeclaration ) decl ) ; } if ( this . apiLevel >= AST . JLS3 ) { result . setDeclaration ( decl ) ; } return result ; } public TypeDeclarationStatement newTypeDeclarationStatement ( TypeDeclaration decl ) { TypeDeclarationStatement result = new TypeDeclarationStatement ( this ) ; result . setDeclaration ( decl ) ; return result ; } public TypeLiteral newTypeLiteral ( ) { TypeLiteral result = new TypeLiteral ( this ) ; return result ; } public TypeParameter newTypeParameter ( ) { TypeParameter result = new TypeParameter ( this ) ; return result ; } public VariableDeclarationExpression newVariableDeclarationExpression ( VariableDeclarationFragment fragment ) { if ( fragment == null ) { throw new IllegalArgumentException ( ) ; } VariableDeclarationExpression result = new VariableDeclarationExpression ( this ) ; result . fragments ( ) . add ( fragment ) ; return result ; } public VariableDeclarationFragment newVariableDeclarationFragment ( ) { VariableDeclarationFragment result = new VariableDeclarationFragment ( this ) ; return result ; } public VariableDeclarationStatement newVariableDeclarationStatement ( VariableDeclarationFragment fragment ) { if ( fragment == null ) { throw new IllegalArgumentException ( ) ; } VariableDeclarationStatement result = new VariableDeclarationStatement ( this ) ; result . fragments ( ) . add ( fragment ) ; return result ; } public WhileStatement newWhileStatement ( ) { return new WhileStatement ( this ) ; } public WildcardType newWildcardType ( ) { WildcardType result = new WildcardType ( this ) ; return result ; } void postAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . postAddChildEvent ( node , child , property ) ; } finally { reenableEvents ( ) ; } } void postCloneNodeEvent ( ASTNode node , ASTNode clone ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . postCloneNodeEvent ( node , clone ) ; } finally { reenableEvents ( ) ; } } void postRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . postRemoveChildEvent ( node , child , property ) ; } finally { reenableEvents ( ) ; } } void postReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . postReplaceChildEvent ( node , child , newChild , property ) ; } finally { reenableEvents ( ) ; } } void postValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . postValueChangeEvent ( node , property ) ; } finally { reenableEvents ( ) ; } } void preAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . preAddChildEvent ( node , child , property ) ; } finally { reenableEvents ( ) ; } } void preCloneNodeEvent ( ASTNode node ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . preCloneNodeEvent ( node ) ; } finally { reenableEvents ( ) ; } } void preRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . preRemoveChildEvent ( node , child , property ) ; } finally { reenableEvents ( ) ; } } void preReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . preReplaceChildEvent ( node , child , newChild , property ) ; } finally { reenableEvents ( ) ; } } void preValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { synchronized ( this . internalASTLock ) { if ( this . disableEvents > <NUM_LIT:0> ) { return ; } else { disableEvents ( ) ; } } try { this . eventHandler . preValueChangeEvent ( node , property ) ; } finally { reenableEvents ( ) ; } } void recordModifications ( CompilationUnit root ) { if ( this . modificationCount != this . originalModificationCount ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } else if ( this . rewriter != null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } else if ( ( root . getFlags ( ) & ASTNode . PROTECT ) != <NUM_LIT:0> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } else if ( root . getAST ( ) != this ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } this . rewriter = new InternalASTRewrite ( root ) ; setEventHandler ( this . rewriter ) ; } final void reenableEvents ( ) { synchronized ( this . internalASTLock ) { this . disableEvents -- ; } } public ITypeBinding resolveWellKnownType ( String name ) { if ( name == null ) { return null ; } return getBindingResolver ( ) . resolveWellKnownType ( name ) ; } TextEdit rewrite ( IDocument document , Map options ) { if ( document == null ) { throw new IllegalArgumentException ( ) ; } if ( this . rewriter == null ) { throw new IllegalStateException ( "<STR_LIT>" ) ; } return this . rewriter . rewriteAST ( document , options ) ; } void setBindingResolver ( BindingResolver resolver ) { if ( resolver == null ) { throw new IllegalArgumentException ( ) ; } this . resolver = resolver ; } void setDefaultNodeFlag ( int flag ) { this . defaultNodeFlag = flag ; } void setEventHandler ( NodeEventHandler eventHandler ) { if ( this . eventHandler == null ) { throw new IllegalArgumentException ( ) ; } this . eventHandler = eventHandler ; } void setFlag ( int newValue ) { this . bits |= newValue ; } void setOriginalModificationCount ( long count ) { this . originalModificationCount = count ; } void supportedOnlyIn2 ( ) { if ( this . apiLevel != AST . JLS2 ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } } void unsupportedIn2 ( ) { if ( this . apiLevel == AST . JLS2 ) { throw new UnsupportedOperationException ( "<STR_LIT>" ) ; } } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ReturnStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ReturnStatement . class , "<STR_LIT>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ReturnStatement . class , propertyList ) ; addProperty ( EXPRESSION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression optionalExpression = null ; ReturnStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return RETURN_STATEMENT ; } ASTNode clone0 ( AST target ) { ReturnStatement result = new ReturnStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) ASTNode . copySubtree ( target , getExpression ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { return this . optionalExpression ; } public void setExpression ( Expression expression ) { ASTNode oldChild = this . optionalExpression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . optionalExpression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalExpression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class AnonymousClassDeclaration extends ASTNode { public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = new ChildListPropertyDescriptor ( AnonymousClassDeclaration . class , "<STR_LIT>" , BodyDeclaration . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( AnonymousClassDeclaration . class , properyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ASTNode . NodeList bodyDeclarations = new ASTNode . NodeList ( BODY_DECLARATIONS_PROPERTY ) ; AnonymousClassDeclaration ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == BODY_DECLARATIONS_PROPERTY ) { return bodyDeclarations ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return ANONYMOUS_CLASS_DECLARATION ; } ASTNode clone0 ( AST target ) { AnonymousClassDeclaration result = new AnonymousClassDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . bodyDeclarations ( ) . addAll ( ASTNode . copySubtrees ( target , bodyDeclarations ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChildren ( visitor , this . bodyDeclarations ) ; } visitor . endVisit ( this ) ; } public List bodyDeclarations ( ) { return this . bodyDeclarations ; } public ITypeBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveType ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + this . bodyDeclarations . listSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . IAnnotatable ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . internal . compiler . lookup . ElementValuePair ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . util . * ; class AnnotationBinding implements IAnnotationBinding { static final AnnotationBinding [ ] NoAnnotations = new AnnotationBinding [ <NUM_LIT:0> ] ; private org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding binding ; private BindingResolver bindingResolver ; private String key ; AnnotationBinding ( org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding annotation , BindingResolver resolver ) { if ( annotation == null ) throw new IllegalStateException ( ) ; this . binding = annotation ; this . bindingResolver = resolver ; } public IAnnotationBinding [ ] getAnnotations ( ) { return NoAnnotations ; } public ITypeBinding getAnnotationType ( ) { ITypeBinding typeBinding = this . bindingResolver . getTypeBinding ( this . binding . getAnnotationType ( ) ) ; if ( typeBinding == null ) return null ; return typeBinding ; } public IMemberValuePairBinding [ ] getDeclaredMemberValuePairs ( ) { ReferenceBinding typeBinding = this . binding . getAnnotationType ( ) ; if ( typeBinding == null || ( ( typeBinding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) ) { return MemberValuePairBinding . NoPair ; } ElementValuePair [ ] internalPairs = this . binding . getElementValuePairs ( ) ; int length = internalPairs . length ; IMemberValuePairBinding [ ] pairs = length == <NUM_LIT:0> ? MemberValuePairBinding . NoPair : new MemberValuePairBinding [ length ] ; int counter = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ElementValuePair valuePair = internalPairs [ i ] ; if ( valuePair . binding == null ) continue ; pairs [ counter ++ ] = this . bindingResolver . getMemberValuePairBinding ( valuePair ) ; } if ( counter == <NUM_LIT:0> ) return MemberValuePairBinding . NoPair ; if ( counter != length ) { System . arraycopy ( pairs , <NUM_LIT:0> , ( pairs = new MemberValuePairBinding [ counter ] ) , <NUM_LIT:0> , counter ) ; } return pairs ; } public IMemberValuePairBinding [ ] getAllMemberValuePairs ( ) { IMemberValuePairBinding [ ] pairs = getDeclaredMemberValuePairs ( ) ; ReferenceBinding typeBinding = this . binding . getAnnotationType ( ) ; if ( typeBinding == null || ( ( typeBinding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) ) return pairs ; MethodBinding [ ] methods = typeBinding . availableMethods ( ) ; int methodLength = methods == null ? <NUM_LIT:0> : methods . length ; if ( methodLength == <NUM_LIT:0> ) return pairs ; int declaredLength = pairs . length ; if ( declaredLength == methodLength ) return pairs ; HashtableOfObject table = new HashtableOfObject ( declaredLength ) ; for ( int i = <NUM_LIT:0> ; i < declaredLength ; i ++ ) { char [ ] internalName = ( ( MemberValuePairBinding ) pairs [ i ] ) . internalName ( ) ; if ( internalName == null ) continue ; table . put ( internalName , pairs [ i ] ) ; } IMemberValuePairBinding [ ] allPairs = new IMemberValuePairBinding [ methodLength ] ; for ( int i = <NUM_LIT:0> ; i < methodLength ; i ++ ) { Object pair = table . get ( methods [ i ] . selector ) ; allPairs [ i ] = pair == null ? new DefaultValuePairBinding ( methods [ i ] , this . bindingResolver ) : ( IMemberValuePairBinding ) pair ; } return allPairs ; } public IJavaElement getJavaElement ( ) { if ( ! ( this . bindingResolver instanceof DefaultBindingResolver ) ) return null ; ASTNode node = ( ASTNode ) ( ( DefaultBindingResolver ) this . bindingResolver ) . bindingsToAstNodes . get ( this ) ; if ( ! ( node instanceof Annotation ) ) return null ; ASTNode parent = node . getParent ( ) ; IJavaElement parentElement = null ; switch ( parent . getNodeType ( ) ) { case ASTNode . PACKAGE_DECLARATION : IJavaElement cu = ( ( CompilationUnit ) parent . getParent ( ) ) . getJavaElement ( ) ; if ( cu instanceof ICompilationUnit ) { String pkgName = ( ( PackageDeclaration ) parent ) . getName ( ) . getFullyQualifiedName ( ) ; parentElement = ( ( ICompilationUnit ) cu ) . getPackageDeclaration ( pkgName ) ; } break ; case ASTNode . ENUM_DECLARATION : case ASTNode . TYPE_DECLARATION : case ASTNode . ANNOTATION_TYPE_DECLARATION : parentElement = ( ( AbstractTypeDeclaration ) parent ) . resolveBinding ( ) . getJavaElement ( ) ; break ; case ASTNode . FIELD_DECLARATION : VariableDeclarationFragment fragment = ( VariableDeclarationFragment ) ( ( FieldDeclaration ) parent ) . fragments ( ) . get ( <NUM_LIT:0> ) ; IVariableBinding variableBinding = fragment . resolveBinding ( ) ; if ( variableBinding == null ) { return null ; } parentElement = variableBinding . getJavaElement ( ) ; break ; case ASTNode . METHOD_DECLARATION : IMethodBinding methodBinding = ( ( MethodDeclaration ) parent ) . resolveBinding ( ) ; if ( methodBinding == null ) return null ; parentElement = methodBinding . getJavaElement ( ) ; break ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : fragment = ( VariableDeclarationFragment ) ( ( VariableDeclarationStatement ) parent ) . fragments ( ) . get ( <NUM_LIT:0> ) ; variableBinding = fragment . resolveBinding ( ) ; if ( variableBinding == null ) { return null ; } parentElement = variableBinding . getJavaElement ( ) ; break ; default : return null ; } if ( ! ( parentElement instanceof IAnnotatable ) ) return null ; if ( ( parentElement instanceof IMember ) && ( ( IMember ) parentElement ) . isBinary ( ) ) { return ( ( IAnnotatable ) parentElement ) . getAnnotation ( getAnnotationType ( ) . getQualifiedName ( ) ) ; } return ( ( IAnnotatable ) parentElement ) . getAnnotation ( getName ( ) ) ; } public String getKey ( ) { if ( this . key == null ) { String recipientKey = getRecipientKey ( ) ; this . key = new String ( this . binding . computeUniqueKey ( recipientKey . toCharArray ( ) ) ) ; } return this . key ; } private String getRecipientKey ( ) { if ( ! ( this . bindingResolver instanceof DefaultBindingResolver ) ) return "<STR_LIT>" ; DefaultBindingResolver resolver = ( DefaultBindingResolver ) this . bindingResolver ; ASTNode node = ( ASTNode ) resolver . bindingsToAstNodes . get ( this ) ; if ( node == null ) { return "<STR_LIT>" ; } ASTNode recipient = node . getParent ( ) ; switch ( recipient . getNodeType ( ) ) { case ASTNode . PACKAGE_DECLARATION : String pkgName = ( ( PackageDeclaration ) recipient ) . getName ( ) . getFullyQualifiedName ( ) ; return pkgName . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ; case ASTNode . TYPE_DECLARATION : return ( ( TypeDeclaration ) recipient ) . resolveBinding ( ) . getKey ( ) ; case ASTNode . FIELD_DECLARATION : VariableDeclarationFragment fragment = ( VariableDeclarationFragment ) ( ( FieldDeclaration ) recipient ) . fragments ( ) . get ( <NUM_LIT:0> ) ; return fragment . resolveBinding ( ) . getKey ( ) ; case ASTNode . METHOD_DECLARATION : return ( ( MethodDeclaration ) recipient ) . resolveBinding ( ) . getKey ( ) ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : fragment = ( VariableDeclarationFragment ) ( ( VariableDeclarationStatement ) recipient ) . fragments ( ) . get ( <NUM_LIT:0> ) ; return fragment . resolveBinding ( ) . getKey ( ) ; default : return "<STR_LIT>" ; } } public int getKind ( ) { return IBinding . ANNOTATION ; } public int getModifiers ( ) { return Modifier . NONE ; } public String getName ( ) { ITypeBinding annotationType = getAnnotationType ( ) ; if ( annotationType == null ) { return new String ( this . binding . getAnnotationType ( ) . sourceName ( ) ) ; } else { return annotationType . getName ( ) ; } } public boolean isDeprecated ( ) { ReferenceBinding typeBinding = this . binding . getAnnotationType ( ) ; if ( typeBinding == null ) return false ; return typeBinding . isDeprecated ( ) ; } public boolean isEqualTo ( IBinding otherBinding ) { if ( this == otherBinding ) return true ; if ( otherBinding . getKind ( ) != IBinding . ANNOTATION ) return false ; IAnnotationBinding other = ( IAnnotationBinding ) otherBinding ; if ( ! getAnnotationType ( ) . isEqualTo ( other . getAnnotationType ( ) ) ) return false ; IMemberValuePairBinding [ ] memberValuePairs = getDeclaredMemberValuePairs ( ) ; IMemberValuePairBinding [ ] otherMemberValuePairs = other . getDeclaredMemberValuePairs ( ) ; if ( memberValuePairs . length != otherMemberValuePairs . length ) return false ; for ( int i = <NUM_LIT:0> , length = memberValuePairs . length ; i < length ; i ++ ) { if ( ! memberValuePairs [ i ] . isEqualTo ( otherMemberValuePairs [ i ] ) ) return false ; } return true ; } public boolean isRecovered ( ) { ReferenceBinding annotationType = this . binding . getAnnotationType ( ) ; return annotationType == null || ( annotationType . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ; } public boolean isSynthetic ( ) { return false ; } public String toString ( ) { ITypeBinding type = getAnnotationType ( ) ; final StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( '<CHAR_LIT>' ) ; if ( type != null ) buffer . append ( type . getName ( ) ) ; buffer . append ( '<CHAR_LIT:(>' ) ; IMemberValuePairBinding [ ] pairs = getDeclaredMemberValuePairs ( ) ; for ( int i = <NUM_LIT:0> , len = pairs . length ; i < len ; i ++ ) { if ( i != <NUM_LIT:0> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; buffer . append ( pairs [ i ] . toString ( ) ) ; } buffer . append ( '<CHAR_LIT:)>' ) ; return buffer . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class IfStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( IfStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor THEN_STATEMENT_PROPERTY = new ChildPropertyDescriptor ( IfStatement . class , "<STR_LIT>" , Statement . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor ELSE_STATEMENT_PROPERTY = new ChildPropertyDescriptor ( IfStatement . class , "<STR_LIT>" , Statement . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( IfStatement . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( THEN_STATEMENT_PROPERTY , properyList ) ; addProperty ( ELSE_STATEMENT_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; private Statement thenStatement = null ; private Statement optionalElseStatement = null ; IfStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == THEN_STATEMENT_PROPERTY ) { if ( get ) { return getThenStatement ( ) ; } else { setThenStatement ( ( Statement ) child ) ; return null ; } } if ( property == ELSE_STATEMENT_PROPERTY ) { if ( get ) { return getElseStatement ( ) ; } else { setElseStatement ( ( Statement ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return IF_STATEMENT ; } ASTNode clone0 ( AST target ) { IfStatement result = new IfStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . setThenStatement ( ( Statement ) getThenStatement ( ) . clone ( target ) ) ; result . setElseStatement ( ( Statement ) ASTNode . copySubtree ( target , getElseStatement ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; acceptChild ( visitor , getThenStatement ( ) ) ; acceptChild ( visitor , getElseStatement ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public Statement getThenStatement ( ) { if ( this . thenStatement == null ) { synchronized ( this ) { if ( this . thenStatement == null ) { preLazyInit ( ) ; this . thenStatement = new Block ( this . ast ) ; postLazyInit ( this . thenStatement , THEN_STATEMENT_PROPERTY ) ; } } } return this . thenStatement ; } public void setThenStatement ( Statement statement ) { if ( statement == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . thenStatement ; preReplaceChild ( oldChild , statement , THEN_STATEMENT_PROPERTY ) ; this . thenStatement = statement ; postReplaceChild ( oldChild , statement , THEN_STATEMENT_PROPERTY ) ; } public Statement getElseStatement ( ) { return this . optionalElseStatement ; } public void setElseStatement ( Statement statement ) { ASTNode oldChild = this . optionalElseStatement ; preReplaceChild ( oldChild , statement , ELSE_STATEMENT_PROPERTY ) ; this . optionalElseStatement = statement ; postReplaceChild ( oldChild , statement , ELSE_STATEMENT_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . thenStatement == null ? <NUM_LIT:0> : getThenStatement ( ) . treeSize ( ) ) + ( this . optionalElseStatement == null ? <NUM_LIT:0> : getElseStatement ( ) . treeSize ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class FieldDeclaration extends BodyDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( FieldDeclaration . class ) ; public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = internalModifiersPropertyFactory ( FieldDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( FieldDeclaration . class ) ; public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( FieldDeclaration . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor FRAGMENTS_PROPERTY = new ChildListPropertyDescriptor ( FieldDeclaration . class , "<STR_LIT>" , VariableDeclarationFragment . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( FieldDeclaration . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS_PROPERTY , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( FRAGMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( FieldDeclaration . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS2_PROPERTY , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( FRAGMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Type baseType = null ; private ASTNode . NodeList variableDeclarationFragments = new ASTNode . NodeList ( FRAGMENTS_PROPERTY ) ; FieldDeclaration ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { internalSetModifiers ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == FRAGMENTS_PROPERTY ) { return fragments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return MODIFIERS_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final int getNodeType0 ( ) { return FIELD_DECLARATION ; } ASTNode clone0 ( AST target ) { FieldDeclaration result = new FieldDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . internalSetModifiers ( getModifiers ( ) ) ; } if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; } result . setType ( ( Type ) getType ( ) . clone ( target ) ) ; result . fragments ( ) . addAll ( ASTNode . copySubtrees ( target , fragments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { acceptChildren ( visitor , this . modifiers ) ; } acceptChild ( visitor , getType ( ) ) ; acceptChildren ( visitor , this . variableDeclarationFragments ) ; } visitor . endVisit ( this ) ; } public Type getType ( ) { if ( this . baseType == null ) { synchronized ( this ) { if ( this . baseType == null ) { preLazyInit ( ) ; this . baseType = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; postLazyInit ( this . baseType , TYPE_PROPERTY ) ; } } } return this . baseType ; } public void setType ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . baseType ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . baseType = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public List fragments ( ) { return this . variableDeclarationFragments ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + ( this . modifiers == null ? <NUM_LIT:0> : this . modifiers . listSize ( ) ) + ( this . baseType == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + this . variableDeclarationFragments . listSize ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class MethodRefParameter extends ASTNode { public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( MethodRefParameter . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final SimplePropertyDescriptor VARARGS_PROPERTY = new SimplePropertyDescriptor ( MethodRefParameter . class , "<STR_LIT>" , boolean . class , MANDATORY ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( MethodRefParameter . class , "<STR_LIT:name>" , SimpleName . class , OPTIONAL , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( MethodRefParameter . class , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( MethodRefParameter . class , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( VARARGS_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Type type = null ; private boolean variableArity = false ; private SimpleName optionalParameterName = null ; MethodRefParameter ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { if ( property == VARARGS_PROPERTY ) { if ( get ) { return isVarargs ( ) ; } else { setVarargs ( value ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , value ) ; } final int getNodeType0 ( ) { return METHOD_REF_PARAMETER ; } ASTNode clone0 ( AST target ) { MethodRefParameter result = new MethodRefParameter ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setType ( ( Type ) ASTNode . copySubtree ( target , getType ( ) ) ) ; if ( this . ast . apiLevel >= AST . JLS3_INTERNAL ) { result . setVarargs ( isVarargs ( ) ) ; } result . setName ( ( SimpleName ) ASTNode . copySubtree ( target , getName ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getType ( ) ) ; acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Type getType ( ) { if ( this . type == null ) { synchronized ( this ) { if ( this . type == null ) { preLazyInit ( ) ; this . type = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; postLazyInit ( this . type , TYPE_PROPERTY ) ; } } } return this . type ; } public void setType ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . type ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . type = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public boolean isVarargs ( ) { unsupportedIn2 ( ) ; return this . variableArity ; } public void setVarargs ( boolean variableArity ) { unsupportedIn2 ( ) ; preValueChange ( VARARGS_PROPERTY ) ; this . variableArity = variableArity ; postValueChange ( VARARGS_PROPERTY ) ; } public SimpleName getName ( ) { return this . optionalParameterName ; } public void setName ( SimpleName name ) { ASTNode oldChild = this . optionalParameterName ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . optionalParameterName = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:5> ; } int treeSize ( ) { return memSize ( ) + ( this . type == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + ( this . optionalParameterName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.