aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/JavacAST.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-11-29 19:46:47 +0100
committerReinier Zwitserloot <reinier@tipit.to>2009-11-29 19:46:47 +0100
commit64f47685ca8fee174d87688e8c5d33de4c153c9b (patch)
treeab6c6fcfdbf648801256f78db829808eb1bb965d /src/core/lombok/javac/JavacAST.java
parent96b7c8ed471745366378d5b7cec8890d16532dee (diff)
parenteb1a51588779ca55c9855651f9eefed9459f0874 (diff)
downloadlombok-64f47685ca8fee174d87688e8c5d33de4c153c9b.tar.gz
lombok-64f47685ca8fee174d87688e8c5d33de4c153c9b.tar.bz2
lombok-64f47685ca8fee174d87688e8c5d33de4c153c9b.zip
Merge branch 'master' into netbeans
Diffstat (limited to 'src/core/lombok/javac/JavacAST.java')
-rw-r--r--src/core/lombok/javac/JavacAST.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java
index e231f1d8..33c167f9 100644
--- a/src/core/lombok/javac/JavacAST.java
+++ b/src/core/lombok/javac/JavacAST.java
@@ -71,7 +71,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
* @param top The compilation unit, which serves as the top level node in the tree to be built.
*/
public JavacAST(Messager messager, Context context, JCCompilationUnit top) {
- super(top.sourcefile == null ? null : top.sourcefile.toString());
+ super(sourceName(top), packageDeclaration(top), imports(top));
setTop(buildCompilationUnit(top));
this.context = context;
this.messager = messager;
@@ -81,30 +81,29 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
this.symtab = Symtab.instance(context);
clearChanged();
}
-
- public Context getContext() {
- return context;
+
+ private static String sourceName(JCCompilationUnit cu) {
+ return cu.sourcefile == null ? null : cu.sourcefile.toString();
}
- /** {@inheritDoc} */
- @Override public String getPackageDeclaration() {
- JCCompilationUnit unit = (JCCompilationUnit)top().get();
- return unit.pid instanceof JCFieldAccess ? unit.pid.toString() : null;
+ private static String packageDeclaration(JCCompilationUnit cu) {
+ return cu.pid instanceof JCFieldAccess ? cu.pid.toString() : null;
}
- /** {@inheritDoc} */
- @Override public Collection<String> getImportStatements() {
+ private static Collection<String> imports(JCCompilationUnit cu) {
List<String> imports = new ArrayList<String>();
- JCCompilationUnit unit = (JCCompilationUnit)top().get();
- for (JCTree def : unit.defs) {
+ for (JCTree def : cu.defs) {
if (def instanceof JCImport) {
imports.add(((JCImport)def).qualid.toString());
}
}
-
return imports;
}
+ public Context getContext() {
+ return context;
+ }
+
/**
* Runs through the entire AST, starting at the compilation unit, calling the provided visitor's visit methods
* for each node, depth first.