/** * Returns the generated {@link JavaCompilation} from the file identified by the given filename. This method assumes * that the filename is relative to <code>{@value #TEST_DATA_BASE_DIR}</code>. * * @param filename * of the file to compile (relative to {@value #TEST_DATA_BASE_DIR}). * @return the compilation of the file */ public void prepareCompilationFromFile(String _file) { fCompilation = CompilationUtils.compileFile(_file); }
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); }
public void prepareCompilationFromSource(String src){ fCompilation = CompilationUtils.compileSource(getSourceCodeWithSnippets(src)); }
public Node convertConstructBody(String methodName) { AbstractMethodDeclaration method = CompilationUtils.findMethod(fCompilation.getCompilationUnit(), methodName); fRoot = new Node(JavaEntityType.METHOD, methodName); fRoot.setEntity(new SourceCodeEntity(methodName, JavaEntityType.METHOD, new SourceRange( method.declarationSourceStart, method.declarationSourceEnd))); //List<Comment> comments = CompilationUtils.extractComments(fCompilation); //Here initialize the visitor with parameters //sMethodBodyConverter.initialize(fRoot, method, comments, fCompilation.getScanner()); //Removed the <<comments>> argument from the previous statement sMethodBodyConverter.initialize(fRoot, method, null, fCompilation.getScanner()); //AbstractMethodDeclaration.traverse(ASTVisitor,ClassScope) method.traverse(sMethodBodyConverter, (ClassScope) null); return fRoot; }
public ASTConstructBodySignature(Construct _construct){ super(JavaEntityType.METHOD, _construct.getId().getSimpleName()); sMethodBodyConverter = sInjector.getInstance(JavaMethodBodyConverter.class); this._construct = _construct; fCompilation = CompilationUtils.compileSource(getSourceCodeWithSnippets(_construct.getContent())); }
/** * Returns the generated {@link JavaCompilation} from the file identified by the given filename. This method assumes * that the filename is relative to <code>{@value #TEST_DATA_BASE_DIR}</code>. * * @param filename * of the file to compile * @return the compilation of the file */ public static JavaCompilation compileFile(String filename) { CompilerOptions options = getDefaultCompilerOptions(); Parser parser = createCommentRecorderParser(options); ICompilationUnit cu = createCompilationunit(getContentOfFile(filename), filename); CompilationResult compilationResult = createDefaultCompilationResult(cu, options); return new JavaCompilation(parser.parse(cu, compilationResult), parser.scanner); }