tests/TreeBuilder.vala
[app.Builder.js] / tests / TreeBuilder.vala
1
2
3
4 public class TreeBuilder : Vala.CodeVisitor {
5         
6         private Vala.CodeContext create_valac_tree (Settings settings) {
7                 // init context:
8                 var context = new Vala.CodeContext ();
9                 Vala.CodeContext.push (context);
10                 
11                 context.experimental = false;
12                 context.experimental_non_null = false;
13                 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
14                 context.report.enable_warnings = true;
15                 context.metadata_directories = { };
16                 context.gir_directories = {};
17
18                 
19                 context.basedir = realpath (".");
20                 
21                 context.directory = context.basedir;
22                 
23
24                 // add default packages:
25                 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
26                         context.profile = Vala.Profile.GOBJECT;
27                 //      context.add_define ("GOBJECT");
28                 //}
29
30                 Vala.Parser parser = new Vala.Parser ();
31                 parser.parse (context);
32                 gir_parser.parse (context);
33                 if (context.report.get_errors () > 0) {
34                         print("got errors");
35                         return context;
36                 }
37
38
39
40                 // check context:
41                 context.check ();
42                 if (context.report.get_errors () > 0) {
43                         return context;
44                 }
45         }
46 }
47
48 int main (string[] args) {
49
50         var a = new TreeBuilder();
51         a.create_valac_tree(