2006-09-01から1ヶ月間の記事一覧

Generate Empty Source Code

ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setSource(new char[0]); CompilationUnit unit = (CompilationUnit) parser.createAST(null); // 変更点を保存する設定 unit.recordModification…

CompilationUnit

Eclipse JDTを使う第1段階 <eclipse-userlibraries version="2"> <library name="Eclipse JDT" systemlibrary="false"> <archive path="D:/Software/Eclipse3.2/plugins/org.eclipse.jdt.core_3.2.0.v_671.jar"/> </archive></library></eclipse-userlibraries>

The Java AST Builder

まだ検証中 /** * = a / b * @param a dividend * @param b divider * @throws ArithmeticException */ @Override public int divide(int a, @NotZero int b) throws ArithmeticException { return a / b; }as Method m = AstBuilder .javadoc("= a / b") .t…

Parse Annotations using Eclipse JDT

もっと単純な実装望む… private static Annotation annotation(String str) { Map<String, String> options = new HashMap<String, String>(); options.put(JavaCore.COMPILER_SOURCE, "1.5"); ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setCompilerOptions(options); parse</string,></string,>…