dump comment anchor

This commit is contained in:
z7zmey
2018-05-27 22:37:22 +03:00
parent 6b70d665d4
commit be3bdbfdc0
3 changed files with 163 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import (
"io"
"reflect"
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/parser"
@@ -44,7 +45,7 @@ func (d Dumper) EnterNode(w walker.Walkable) bool {
if c := d.Comments[n]; len(c) > 0 {
fmt.Fprintf(d.Writer, "%v\"Comments\":\n", d.Indent+" ")
for _, cc := range c {
fmt.Fprintf(d.Writer, "%v%q\n", d.Indent+" ", cc)
fmt.Fprintf(d.Writer, "%v%q before %q\n", d.Indent+" ", cc, comment.TokenNames[cc.TokenName()])
}
}
}

View File

@@ -111,7 +111,7 @@ func ExampleDumper() {
//| [*expr.Variable]
//| "Position": Pos{Line: 8-8 Pos: 124-127};
//| "Comments":
//| "// some comment\n"
//| "// some comment\n" before "VariableToken"
//| "VarName":
//| [*node.Identifier]
//| "Position": Pos{Line: 8-8 Pos: 124-127};