Java Code Examples for org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration#traverse()
The following examples show how to use
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration#traverse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoundEnvImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public RoundEnvImpl(CompilationUnitDeclaration[] units, ReferenceBinding[] binaryTypeBindings, boolean isLastRound, BaseProcessingEnvImpl env) { _processingEnv = env; _isLastRound = isLastRound; _units = units; _factory = _processingEnv.getFactory(); // Discover the annotations that will be passed to Processor.process() AnnotationDiscoveryVisitor visitor = new AnnotationDiscoveryVisitor(_processingEnv); if (_units != null) { for (CompilationUnitDeclaration unit : _units) { unit.scope.suppressImportErrors = true; unit.traverse(visitor, unit.scope); unit.scope.suppressImportErrors = false; } } _annoToUnit = visitor._annoToElement; if (binaryTypeBindings != null) collectAnnotations(binaryTypeBindings); _binaryTypes = binaryTypeBindings; }
Example 2
Source File: TypedefCollector.java From javaide with GNU General Public License v3.0 | 5 votes |
public TypedefCollector( @NonNull Collection<CompilationUnitDeclaration> units, boolean requireHide, boolean requireSourceRetention) { mRequireHide = requireHide; mRequireSourceRetention = requireSourceRetention; for (CompilationUnitDeclaration unit : units) { mCurrentUnit = unit; unit.traverse(this, unit.scope); mCurrentUnit = null; } }
Example 3
Source File: Extractor.java From javaide with GNU General Public License v3.0 | 5 votes |
private void analyze(CompilationUnitDeclaration unit) { if (processedFiles.contains(unit)) { // The code to process all roots seems to hit some of the same classes // repeatedly... so filter these out manually return; } processedFiles.add(unit); AnnotationVisitor visitor = new AnnotationVisitor(); unit.traverse(visitor, unit.scope); }
Example 4
Source File: CompilationUnitResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static CompilationUnitDeclaration parse( org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, NodeSearcher nodeSearcher, Map settings, int flags) { if (sourceUnit == null) { throw new IllegalStateException(); } CompilerOptions compilerOptions = new CompilerOptions(settings); boolean statementsRecovery = (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0; compilerOptions.performMethodsFullRecovery = statementsRecovery; compilerOptions.performStatementsRecovery = statementsRecovery; compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0; Parser parser = new CommentRecorderParser( new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory()), false); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult); if (compilationUnitDeclaration.ignoreMethodBodies) { compilationUnitDeclaration.ignoreFurtherInvestigation = true; // if initial diet parse did not work, no need to dig into method bodies. return compilationUnitDeclaration; } if (nodeSearcher != null) { char[] source = parser.scanner.getSource(); int searchPosition = nodeSearcher.position; if (searchPosition < 0 || searchPosition > source.length) { // the position is out of range. There is no need to search for a node. return compilationUnitDeclaration; } compilationUnitDeclaration.traverse(nodeSearcher, compilationUnitDeclaration.scope); org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found; if (node == null) { return compilationUnitDeclaration; } org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType; if (node instanceof AbstractMethodDeclaration) { ((AbstractMethodDeclaration)node).parseStatements(parser, compilationUnitDeclaration); } else if (enclosingTypeDeclaration != null) { if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) { ((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(parser, enclosingTypeDeclaration, compilationUnitDeclaration); } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { ((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethods(parser, compilationUnitDeclaration); } } } else { //fill the methods bodies in order for the code to be generated //real parse of the method.... org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types; if (types != null) { for (int j = 0, typeLength = types.length; j < typeLength; j++) { types[j].parseMethods(parser, compilationUnitDeclaration); } } } return compilationUnitDeclaration; }