Java Code Examples for org.eclipse.jdt.internal.compiler.parser.Parser#parse()
The following examples show how to use
org.eclipse.jdt.internal.compiler.parser.Parser#parse() .
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: CompilationUtils.java From steady with Apache License 2.0 | 6 votes |
/** * <p>compileSource.</p> * * @param source a {@link java.lang.String} object. * @return a {@link ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation} object. */ public static JavaCompilation compileSource(String source) { //Compiler Options CompilerOptions options = getDefaultCompilerOptions(); //CommentRecorder Parser parser = createCommentRecorderParser(options); //Create Compilation Unit from Source ICompilationUnit cu = createCompilationunit(source, ""); //Compilation Result CompilationResult compilationResult = createDefaultCompilationResult(cu, options); return new JavaCompilation(parser.parse(cu, compilationResult), parser.scanner); }
Example 2
Source File: CompilationUtils.java From steady with Apache License 2.0 | 5 votes |
/** * Returns the generated {@link JavaCompilation} from the file identified by the given filename. * * @param _filename * of the file to compile * @return the compilation of the file */ public static JavaCompilation compileFile(String _filename) { JavaCompilation jc = null; try { final String src = FileUtil.readFile(_filename); final CompilerOptions options = getDefaultCompilerOptions(); final Parser parser = createCommentRecorderParser(options); final ICompilationUnit cu = createCompilationunit(src, _filename); final CompilationResult compilationResult = createDefaultCompilationResult(cu, options); jc = new JavaCompilation(parser.parse(cu, compilationResult), parser.scanner); } catch (IOException e) { log.error(e); } return jc; }
Example 3
Source File: MethodDeclaration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void parseStatements(Parser parser, CompilationUnitDeclaration unit) { //fill up the method body with statement parser.parse(this, unit); }