7192073: (javac) minor refactoring of tree maker to help IDEs
authorksrini
Fri, 14 Sep 2012 09:21:55 -0700
changeset 13845 bbb35ad7a9c1
parent 13844 56339cf983a3
child 13847 98fd1ba7dced
7192073: (javac) minor refactoring of tree maker to help IDEs Reviewed-by: jjg Contributed-by: jan.lahoda@oracle.com
langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Thu Sep 13 14:29:36 2012 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Fri Sep 14 09:21:55 2012 -0700
@@ -117,7 +117,7 @@
         return instance;
     }
 
-    private JavacTrees(Context context) {
+    protected JavacTrees(Context context) {
         context.put(JavacTrees.class, this);
         init(context);
     }
@@ -286,7 +286,7 @@
 
 
         JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit();
-        Copier copier = new Copier(treeMaker.forToplevel(unit));
+        Copier copier = createCopier(treeMaker.forToplevel(unit));
 
         Env<AttrContext> env = null;
         JCMethodDecl method = null;
@@ -372,10 +372,10 @@
     /**
      * Makes a copy of a tree, noting the value resulting from copying a particular leaf.
      **/
-    static class Copier extends TreeCopier<JCTree> {
+    protected static class Copier extends TreeCopier<JCTree> {
         JCTree leafCopy = null;
 
-        Copier(TreeMaker M) {
+        protected Copier(TreeMaker M) {
             super(M);
         }
 
@@ -388,6 +388,10 @@
         }
     }
 
+    protected Copier createCopier(TreeMaker maker) {
+        return new Copier(maker);
+    }
+
     /**
      * Gets the original type from the ErrorType object.
      * @param errorType The errorType for which we want to get the original type.
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Sep 13 14:29:36 2012 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Fri Sep 14 09:21:55 2012 -0700
@@ -87,7 +87,7 @@
 
     /** Create a tree maker with a given toplevel and FIRSTPOS as initial position.
      */
-    TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) {
+    protected TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) {
         this.pos = Position.FIRSTPOS;
         this.toplevel = toplevel;
         this.names = names;