@@ -23,69 +23,96 @@ func ExampleDumper() {
23
23
24
24
nodes , comments , positions := php7 .Parse (bytes .NewBufferString (src ), "test.php" )
25
25
26
+ nsResolver := visitor .NewNamespaceResolver ()
27
+ nodes .Walk (nsResolver )
28
+
26
29
dumper := visitor.Dumper {
27
- Indent : "| " ,
28
- Comments : comments ,
29
- Positions : positions ,
30
+ Indent : "| " ,
31
+ Comments : comments ,
32
+ Positions : positions ,
33
+ NsResolver : nsResolver ,
30
34
}
31
35
nodes .Walk (dumper )
32
36
33
37
// Unordered output:
34
- //| *stmt.StmtList Pos{Line: 3-11 Pos: 10-143}
38
+ //| [*stmt.StmtList]
39
+ //| "Position": Pos{Line: 3-11 Pos: 10-143};
35
40
//| "Stmts":
36
- //| *stmt.Namespace Pos{Line: 3-11 Pos: 10-143}
41
+ //| [*stmt.Namespace]
42
+ //| "Position": Pos{Line: 3-11 Pos: 10-143};
37
43
//| "NamespaceName":
38
- //| *name.Name Pos{Line: 3-3 Pos: 20-22}
44
+ //| [*name.Name]
45
+ //| "Position": Pos{Line: 3-3 Pos: 20-22};
39
46
//| "Parts":
40
- //| *name.NamePart Pos{Line: 3-3 Pos: 20-22}
47
+ //| [*name.NamePart]
48
+ //| "Position": Pos{Line: 3-3 Pos: 20-22};
41
49
//| "Value": Foo;
42
50
//| "Stmts":
43
- //| *stmt.Class Pos{Line: 4-10 Pos: 29-139}
51
+ //| [*stmt.Class]
52
+ //| "Position": Pos{Line: 4-10 Pos: 29-139};
53
+ //| "NamespacedName": Foo\Bar;
44
54
//| "PhpDocComment": ;
45
55
//| "ClassName":
46
- //| *node.Identifier Pos{Line: 4-4 Pos: 35-37}
56
+ //| [*node.Identifier]
57
+ //| "Position": Pos{Line: 4-4 Pos: 35-37};
47
58
//| "Value": Bar;
48
59
//| "Stmts":
49
- //| *stmt.ClassMethod Pos{Line: 5-9 Pos: 45-134}
50
- //| "ReturnsRef ": false ;
60
+ //| [ *stmt.ClassMethod]
61
+ //| "Position ": Pos{Line: 5-9 Pos: 45-134} ;
51
62
//| "PhpDocComment": ;
63
+ //| "ReturnsRef": false;
52
64
//| "MethodName":
53
- //| *node.Identifier Pos{Line: 5-5 Pos: 61-72}
65
+ //| [*node.Identifier]
66
+ //| "Position": Pos{Line: 5-5 Pos: 61-72};
54
67
//| "Value": FunctionName;
55
68
//| "Modifiers":
56
- //| *node.Identifier Pos{Line: 5-5 Pos: 45-50}
69
+ //| [*node.Identifier]
70
+ //| "Position": Pos{Line: 5-5 Pos: 45-50};
57
71
//| "Value": public;
58
72
//| "Params":
59
- //| *node.Parameter Pos{Line: 5-5 Pos: 74-89}
73
+ //| [*node.Parameter]
74
+ //| "Position": Pos{Line: 5-5 Pos: 74-89};
60
75
//| "ByRef": false;
61
76
//| "Variadic": false;
62
77
//| "VariableType":
63
- //| *name.Name Pos{Line: 5-5 Pos: 74-77}
78
+ //| [*name.Name]
79
+ //| "Position": Pos{Line: 5-5 Pos: 74-77};
80
+ //| "NamespacedName": Foo\Type;
64
81
//| "Parts":
65
- //| *name.NamePart Pos{Line: 5-5 Pos: 74-77}
82
+ //| [*name.NamePart]
83
+ //| "Position": Pos{Line: 5-5 Pos: 74-77};
66
84
//| "Value": Type;
67
85
//| "Variable":
68
- //| *expr.Variable Pos{Line: 5-5 Pos: 79-82}
86
+ //| [*expr.Variable]
87
+ //| "Position": Pos{Line: 5-5 Pos: 79-82};
69
88
//| "VarName":
70
- //| *node.Identifier Pos{Line: 5-5 Pos: 79-82}
89
+ //| [*node.Identifier]
90
+ //| "Position": Pos{Line: 5-5 Pos: 79-82};
71
91
//| "Value": $var;
72
92
//| "DefaultValue":
73
- //| *expr.ConstFetch Pos{Line: 5-5 Pos: 86-89}
93
+ //| [*expr.ConstFetch]
94
+ //| "Position": Pos{Line: 5-5 Pos: 86-89};
74
95
//| "Constant":
75
- //| *name.Name Pos{Line: 5-5 Pos: 86-89}
96
+ //| [*name.Name]
97
+ //| "Position": Pos{Line: 5-5 Pos: 86-89};
98
+ //| "NamespacedName": Foo\null;
76
99
//| "Parts":
77
- //| *name.NamePart Pos{Line: 5-5 Pos: 86-89}
100
+ //| [*name.NamePart]
101
+ //| "Position": Pos{Line: 5-5 Pos: 86-89};
78
102
//| "Value": null;
79
103
//| "Stmts":
80
- //| *stmt.Expression Pos{Line: 8-8 Pos: 124-128}
104
+ //| [*stmt.Expression]
105
+ //| "Position": Pos{Line: 8-8 Pos: 124-128};
81
106
//| "Comments":
82
107
//| "// some comment\n"
83
108
//| "Expr":
84
- //| *expr.Variable Pos{Line: 8-8 Pos: 124-127}
109
+ //| [*expr.Variable]
110
+ //| "Position": Pos{Line: 8-8 Pos: 124-127};
85
111
//| "Comments":
86
112
//| "// some comment\n"
87
113
//| "VarName":
88
- //| *node.Identifier Pos{Line: 8-8 Pos: 124-127}
114
+ //| [*node.Identifier]
115
+ //| "Position": Pos{Line: 8-8 Pos: 124-127};
89
116
//| "Value": $var;
90
117
//| "Comments":
91
118
//| "// some comment\n"
0 commit comments