Skip to content

Commit

Permalink
Add FileName and DirName to Node
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mizutani committed Sep 19, 2022
1 parent 470d7f6 commit 20c43f3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package goast
import (
"go/ast"
"go/token"
"path/filepath"
"reflect"
)

type Node struct {
Path string
Path string
FileName string
DirName string

Node ast.Node
Kind string

Expand All @@ -16,7 +20,10 @@ type Node struct {

func newNode(fpath string, node ast.Node, fset *token.FileSet) *Node {
return &Node{
Path: fpath,
Path: fpath,
DirName: filepath.Dir(fpath),
FileName: filepath.Base(fpath),

Node: node,
Kind: reflect.ValueOf(node).Elem().Type().Name(),
fileSet: fset,
Expand Down

0 comments on commit 20c43f3

Please sign in to comment.