diff --git a/comment/comment.go b/comment/comment.go index f9d7de1..f65f067 100644 --- a/comment/comment.go +++ b/comment/comment.go @@ -2,12 +2,15 @@ package comment import "github.com/z7zmey/php-parser/node" +// Comment represents comment lines in the code type Comment interface { String() string } +// Comments a collection of comment groups assigned to nodes type Comments map[node.Node][]Comment +// AddComments add comment group to the collection func (c Comments) AddComments(node node.Node, comments []Comment) { c[node] = append(c[node], comments...) } diff --git a/comment/doc_comment.go b/comment/doc_comment.go index 8988e64..c0b9a93 100644 --- a/comment/doc_comment.go +++ b/comment/doc_comment.go @@ -1,9 +1,11 @@ package comment +// DocComment represents comments that start /** type DocComment struct { value string } +// NewDocComment - DocComment constructor func NewDocComment(value string) *DocComment { return &DocComment{ value, diff --git a/comment/plain_comment.go b/comment/plain_comment.go index ea8a0c5..89371a8 100644 --- a/comment/plain_comment.go +++ b/comment/plain_comment.go @@ -1,9 +1,11 @@ package comment +// PlainComment represents comments that dont start /** type PlainComment struct { value string } +// NewPlainComment - PlainComment constructor func NewPlainComment(value string) *PlainComment { return &PlainComment{ value, diff --git a/position/position.go b/position/position.go index 7448cfa..f619e7b 100644 --- a/position/position.go +++ b/position/position.go @@ -6,6 +6,7 @@ import ( "github.com/z7zmey/php-parser/node" ) +// Position represents node position type Position struct { StartLine int EndLine int @@ -17,8 +18,10 @@ func (p Position) String() string { return fmt.Sprintf("Pos{Line: %d-%d Pos: %d-%d}", p.StartLine, p.EndLine, p.StartPos, p.EndPos) } +// Positions a collection of positions attached to nodes type Positions map[node.Node]*Position +// AddPosition attaches a position to a node func (p Positions) AddPosition(node node.Node, position *Position) { p[node] = position }