Add simple comments to exported methods

This commit is contained in:
z7zmey 2018-02-19 13:24:56 +02:00
parent 4dda4fe7af
commit 9b674c2c12
6 changed files with 11 additions and 1 deletions

View File

@ -28,6 +28,7 @@ func (n *AltIf) Attributes() map[string]interface{} {
return nil
}
// AddElseIf add AltElseIf node and returns AltIf node
func (n *AltIf) AddElseIf(ElseIf node.Node) node.Node {
if n.ElseIf == nil {
n.ElseIf = make([]node.Node, 0)
@ -38,6 +39,7 @@ func (n *AltIf) AddElseIf(ElseIf node.Node) node.Node {
return n
}
// SetElse set AltElse node and returns AltIf node
func (n *AltIf) SetElse(Else node.Node) node.Node {
n.Else = Else

View File

@ -26,6 +26,7 @@ func (n *GroupUse) Attributes() map[string]interface{} {
return nil
}
// SetUseType set use type and returns node
func (n *GroupUse) SetUseType(UseType node.Node) node.Node {
n.UseType = UseType
return n

View File

@ -28,6 +28,7 @@ func (n *If) Attributes() map[string]interface{} {
return nil
}
// AddElseIf add ElseIf node and returns AltIf node
func (n *If) AddElseIf(ElseIf node.Node) node.Node {
if n.ElseIf == nil {
n.ElseIf = make([]node.Node, 0)
@ -38,6 +39,7 @@ func (n *If) AddElseIf(ElseIf node.Node) node.Node {
return n
}
// SetElse set Else node and returns AltIf node
func (n *If) SetElse(Else node.Node) node.Node {
n.Else = Else

View File

@ -26,6 +26,7 @@ func (n *Use) Attributes() map[string]interface{} {
return nil
}
// SetUseType set use type and returns node
func (n *Use) SetUseType(UseType node.Node) node.Node {
n.UseType = UseType
return n

View File

@ -19,17 +19,19 @@ var positionBuilder position.Builder
var parentNode node.Node
// Parse the php5 parser entrypoint
func Parse(src io.Reader, fName string) (node.Node, comment.Comments, position.Positions) {
yyDebug = 0
yyErrorVerbose = true
rootnode = stmt.NewStmtList([]node.Node{}) //reset
comments = comment.Comments{}
positions = position.Positions{}
positionBuilder = position.Builder{&positions}
positionBuilder = position.Builder{Positions: &positions}
yyParse(newLexer(src, fName))
return rootnode, comments, positions
}
// ListGetFirstNodeComments returns comments of a first node in the list
func ListGetFirstNodeComments(list []node.Node) []comment.Comment {
if len(list) == 0 {
return nil

View File

@ -15,6 +15,7 @@ var comments comment.Comments
var positions position.Positions
var positionBuilder position.Builder
// Parse the php7 parser entrypoint
func Parse(src io.Reader, fName string) (node.Node, comment.Comments, position.Positions) {
yyDebug = 0
yyErrorVerbose = true
@ -26,6 +27,7 @@ func Parse(src io.Reader, fName string) (node.Node, comment.Comments, position.P
return rootnode, comments, positions
}
// ListGetFirstNodeComments returns comments of a first node in the list
func ListGetFirstNodeComments(list []node.Node) []comment.Comment {
if len(list) == 0 {
return nil