src/jdk.compiler/share/classes/com/sun/source/util/TreeBuilder.java
branchjlahoda-tree-builder
changeset 57296 464cc8d22d94
parent 57295 5497ee9d40f4
child 57297 ad0be596956b
equal deleted inserted replaced
57295:5497ee9d40f4 57296:464cc8d22d94
    55         CompilationUnit _class(String name, Consumer<Class> clazz);
    55         CompilationUnit _class(String name, Consumer<Class> clazz);
    56     }
    56     }
    57 
    57 
    58     interface Class extends WithModifiers<Class>, WithJavadoc<Class> {
    58     interface Class extends WithModifiers<Class>, WithJavadoc<Class> {
    59         //setters:
    59         //setters:
    60         Class superclass(Consumer<Expression> sup);
    60         Class superclass(Consumer<Type> sup);
    61         Class superinterface(Consumer<Expression> sup);
    61         Class superinterface(Consumer<Type> sup);
    62         //type parameters?
    62         //type parameters?
    63 
    63 
    64         //adders:
    64         //adders:
    65         default Class field(String name, Consumer<Type> type) {
    65         default Class field(String name, Consumer<Type> type) {
    66             //TODO: has this overload a meaning
    66             //TODO: has this overload a meaning
   103 
   103 
   104     interface Annotation {
   104     interface Annotation {
   105         //TODO...
   105         //TODO...
   106     }
   106     }
   107 
   107 
       
   108     //TODO: DeclaredType vs. Type?
       
   109 
   108     interface Type {
   110     interface Type {
   109         void _class(String simpleName); //TODO: type parameters - declaredtype???
   111         default void _class(String className) {
   110 //        void _class(String simpleName, Consumer<TypeArgs> targs);
   112             _class(N -> N.qualifiedName(className));
       
   113         }
       
   114         default void _class(Consumer<QualifiedName> className) {
       
   115             _class(className, A -> {});
       
   116         }
       
   117         void _class(Consumer<QualifiedName> className, Consumer<TypeArguments> typeArguments);
   111         void _int();
   118         void _int();
   112         void _float();
   119         void _float();
   113         void _void();
   120         void _void();
       
   121     }
       
   122 
       
   123     interface TypeArguments { //???
       
   124         TypeArguments type(Consumer<Type> t);
       
   125     }
       
   126 
       
   127     interface QualifiedName {
       
   128         void select(Consumer<QualifiedName> selected, String name);
       
   129         void ident(String simpleName);
       
   130         void ident(String... components);
       
   131         default void qualifiedName(String qualifiedName) {
       
   132             ident(qualifiedName.split("\\."));
       
   133         }
   114     }
   134     }
   115 
   135 
   116 //    interface TypeArgs { //???
   136 //    interface TypeArgs { //???
   117 //        TypeArgs type(Consumer<Type> t);
   137 //        TypeArgs type(Consumer<Type> t);
   118 //        TypeArgs _extends(Consumer<Type> t);
   138 //        TypeArgs _extends(Consumer<Type> t);
   119 //        TypeArgs _super(Consumer<Type> t);
   139 //        TypeArgs _super(Consumer<Type> t);
   120 //        TypeArgs unbound();
   140 //        TypeArgs unbound();
   121 //    }
   141 //    }
   122 
   142 //
   123     interface Expression {
   143     interface Expression {
   124         void minusminus(Consumer<Expression> expr);
   144         void minusminus(Consumer<Expression> expr);
   125         void plus(Consumer<Expression> lhs, Consumer<Expression> rhs);
   145         void plus(Consumer<Expression> lhs, Consumer<Expression> rhs);
   126         void cond(Consumer<Expression> cond, Consumer<Expression> truePart, Consumer<Expression> falsePart);
   146         void cond(Consumer<Expression> cond, Consumer<Expression> truePart, Consumer<Expression> falsePart);
   127         void ident(String... qnames);
   147         void select(Consumer<Expression> selected, String name);
       
   148         void ident(String qnames);
   128         void literal(Object value);
   149         void literal(Object value);
   129     }
   150     }
   130 
   151 
   131     interface Statements {
   152     interface Statements {
   132         Statements _if(Consumer<Expression> cond, Consumer<Statements> ifPart, Consumer<Statements> elsePart);
   153         Statements _if(Consumer<Expression> cond, Consumer<Statements> ifPart, Consumer<Statements> elsePart);
   139          U -> U._class("Foo", C -> C.field("x", Type::_int)
   160          U -> U._class("Foo", C -> C.field("x", Type::_int)
   140                                     .method("foo",
   161                                     .method("foo",
   141                                             Type::_void,
   162                                             Type::_void,
   142                                             M -> M.parameter(T -> T._class("Foo"))
   163                                             M -> M.parameter(T -> T._class("Foo"))
   143                                                   .parameter(T -> T._float(), P -> P.name("whatever"))
   164                                                   .parameter(T -> T._float(), P -> P.name("whatever"))
   144                                                   .body(B -> B._if(E -> E.minusminus(V -> V.ident("foo", "bar")),
   165                                                   .body(B -> B._if(E -> E.minusminus(V -> V.select(S -> S.ident("foo"), "bar")),
   145                                                                    Statements::skip,
   166                                                                    Statements::skip,
   146                                                                    Statements::skip
   167                                                                    Statements::skip
   147                                                                   )
   168                                                                   )
   148                                                        )
   169                                                        )
   149                                             )));
   170                                             )));