01: /**
02: *
03: */package core;
04:
05: import org.eclipse.jdt.core.ICompilationUnit;
06: import org.eclipse.jdt.core.dom.AST;
07: import org.eclipse.jdt.core.dom.ASTNode;
08: import org.eclipse.jdt.core.dom.ASTParser;
09: import org.eclipse.jdt.core.dom.CompilationUnit;
10:
11: /**
12: * @author sh
13: *
14: */
15: public abstract class AbstractAST {
16: /**
17: * Called from Refactorings.
18: *
19: * @param lwUnit the Java Model handle
20: * to the compilation unit that has to be processed.
21: */
22: protected CompilationUnit parse(ICompilationUnit lwUnit) {
23: ASTParser parser = ASTParser.newParser(AST.JLS3);
24: parser.setKind(ASTParser.K_COMPILATION_UNIT);
25: parser.setSource(lwUnit);
26: parser.setResolveBindings(true);
27: ASTNode root = parser.createAST(null);
28: CompilationUnit cu = (CompilationUnit) root;
29: cu.recordModifications();
30: return cu;
31: }
32: }
|