#51 saving optional tokes and tokens that have different representation as meta

This commit is contained in:
z7zmey
2018-07-29 11:44:38 +03:00
parent 0138749c6d
commit 4989d31874
223 changed files with 9832 additions and 5976 deletions

View File

@@ -9,7 +9,7 @@ import (
// AltElse node
type AltElse struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Stmt node.Node
}
@@ -31,12 +31,8 @@ func (n *AltElse) GetPosition() *position.Position {
return n.Position
}
func (n *AltElse) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *AltElse) GetMeta() []meta.Meta {
return n.Meta
func (n *AltElse) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// AltElseIf node
type AltElseIf struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
@@ -33,12 +33,8 @@ func (n *AltElseIf) GetPosition() *position.Position {
return n.Position
}
func (n *AltElseIf) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *AltElseIf) GetMeta() []meta.Meta {
return n.Meta
func (n *AltElseIf) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// AltFor node
type AltFor struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Init []node.Node
Cond []node.Node
@@ -37,12 +37,8 @@ func (n *AltFor) GetPosition() *position.Position {
return n.Position
}
func (n *AltFor) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *AltFor) GetMeta() []meta.Meta {
return n.Meta
func (n *AltFor) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// AltForeach node
type AltForeach struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
Key node.Node
@@ -37,12 +37,8 @@ func (n *AltForeach) GetPosition() *position.Position {
return n.Position
}
func (n *AltForeach) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *AltForeach) GetMeta() []meta.Meta {
return n.Meta
func (n *AltForeach) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// AltIf node
type AltIf struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
@@ -37,12 +37,8 @@ func (n *AltIf) GetPosition() *position.Position {
return n.Position
}
func (n *AltIf) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *AltIf) GetMeta() []meta.Meta {
return n.Meta
func (n *AltIf) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// AltSwitch node
type AltSwitch struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
CaseList *CaseList
@@ -33,12 +33,8 @@ func (n *AltSwitch) GetPosition() *position.Position {
return n.Position
}
func (n *AltSwitch) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *AltSwitch) GetMeta() []meta.Meta {
return n.Meta
func (n *AltSwitch) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// AltWhile node
type AltWhile struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
@@ -33,12 +33,8 @@ func (n *AltWhile) GetPosition() *position.Position {
return n.Position
}
func (n *AltWhile) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *AltWhile) GetMeta() []meta.Meta {
return n.Meta
func (n *AltWhile) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Break node
type Break struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
}
@@ -31,12 +31,8 @@ func (n *Break) GetPosition() *position.Position {
return n.Position
}
func (n *Break) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Break) GetMeta() []meta.Meta {
return n.Meta
func (n *Break) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Case node
type Case struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmts []node.Node
@@ -33,12 +33,8 @@ func (n *Case) GetPosition() *position.Position {
return n.Position
}
func (n *Case) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Case) GetMeta() []meta.Meta {
return n.Meta
func (n *Case) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// CaseList node
type CaseList struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cases []node.Node
}
@@ -31,12 +31,8 @@ func (n *CaseList) GetPosition() *position.Position {
return n.Position
}
func (n *CaseList) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *CaseList) GetMeta() []meta.Meta {
return n.Meta
func (n *CaseList) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Catch node
type Catch struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Types []node.Node
Variable node.Node
@@ -35,12 +35,8 @@ func (n *Catch) GetPosition() *position.Position {
return n.Position
}
func (n *Catch) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Catch) GetMeta() []meta.Meta {
return n.Meta
func (n *Catch) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Class node
type Class struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
PhpDocComment string
ClassName node.Node
@@ -43,12 +43,8 @@ func (n *Class) GetPosition() *position.Position {
return n.Position
}
func (n *Class) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Class) GetMeta() []meta.Meta {
return n.Meta
func (n *Class) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ClassConstList node
type ClassConstList struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Modifiers []node.Node
Consts []node.Node
@@ -33,12 +33,8 @@ func (n *ClassConstList) GetPosition() *position.Position {
return n.Position
}
func (n *ClassConstList) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ClassConstList) GetMeta() []meta.Meta {
return n.Meta
func (n *ClassConstList) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ClassExtends node
type ClassExtends struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
ClassName node.Node
}
@@ -31,12 +31,8 @@ func (n *ClassExtends) GetPosition() *position.Position {
return n.Position
}
func (n *ClassExtends) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ClassExtends) GetMeta() []meta.Meta {
return n.Meta
func (n *ClassExtends) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ClassImplements node
type ClassImplements struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
InterfaceNames []node.Node
}
@@ -31,12 +31,8 @@ func (n *ClassImplements) GetPosition() *position.Position {
return n.Position
}
func (n *ClassImplements) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ClassImplements) GetMeta() []meta.Meta {
return n.Meta
func (n *ClassImplements) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ClassMethod node
type ClassMethod struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
ReturnsRef bool
PhpDocComment string
@@ -43,12 +43,8 @@ func (n *ClassMethod) GetPosition() *position.Position {
return n.Position
}
func (n *ClassMethod) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ClassMethod) GetMeta() []meta.Meta {
return n.Meta
func (n *ClassMethod) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ConstList node
type ConstList struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Consts []node.Node
}
@@ -31,12 +31,8 @@ func (n *ConstList) GetPosition() *position.Position {
return n.Position
}
func (n *ConstList) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ConstList) GetMeta() []meta.Meta {
return n.Meta
func (n *ConstList) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Constant node
type Constant struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
PhpDocComment string
ConstantName node.Node
@@ -35,12 +35,8 @@ func (n *Constant) GetPosition() *position.Position {
return n.Position
}
func (n *Constant) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Constant) GetMeta() []meta.Meta {
return n.Meta
func (n *Constant) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Continue node
type Continue struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
}
@@ -31,12 +31,8 @@ func (n *Continue) GetPosition() *position.Position {
return n.Position
}
func (n *Continue) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Continue) GetMeta() []meta.Meta {
return n.Meta
func (n *Continue) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,17 +9,19 @@ import (
// Declare node
type Declare struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Consts []node.Node
Stmt node.Node
Alt bool
}
// NewDeclare node constructor
func NewDeclare(Consts []node.Node, Stmt node.Node) *Declare {
func NewDeclare(Consts []node.Node, Stmt node.Node, alt bool) *Declare {
return &Declare{
Consts: Consts,
Stmt: Stmt,
Alt: alt,
}
}
@@ -33,12 +35,8 @@ func (n *Declare) GetPosition() *position.Position {
return n.Position
}
func (n *Declare) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Declare) GetMeta() []meta.Meta {
return n.Meta
func (n *Declare) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Default node
type Default struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Stmts []node.Node
}
@@ -31,12 +31,8 @@ func (n *Default) GetPosition() *position.Position {
return n.Position
}
func (n *Default) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Default) GetMeta() []meta.Meta {
return n.Meta
func (n *Default) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Do node
type Do struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Stmt node.Node
Cond node.Node
@@ -33,12 +33,8 @@ func (n *Do) GetPosition() *position.Position {
return n.Position
}
func (n *Do) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Do) GetMeta() []meta.Meta {
return n.Meta
func (n *Do) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Echo node
type Echo struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Exprs []node.Node
}
@@ -31,12 +31,8 @@ func (n *Echo) GetPosition() *position.Position {
return n.Position
}
func (n *Echo) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Echo) GetMeta() []meta.Meta {
return n.Meta
func (n *Echo) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Else node
type Else struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Stmt node.Node
}
@@ -31,12 +31,8 @@ func (n *Else) GetPosition() *position.Position {
return n.Position
}
func (n *Else) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Else) GetMeta() []meta.Meta {
return n.Meta
func (n *Else) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ElseIf node
type ElseIf struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
@@ -33,12 +33,8 @@ func (n *ElseIf) GetPosition() *position.Position {
return n.Position
}
func (n *ElseIf) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ElseIf) GetMeta() []meta.Meta {
return n.Meta
func (n *ElseIf) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Expression node
type Expression struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
}
@@ -31,12 +31,8 @@ func (n *Expression) GetPosition() *position.Position {
return n.Position
}
func (n *Expression) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Expression) GetMeta() []meta.Meta {
return n.Meta
func (n *Expression) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Finally node
type Finally struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Stmts []node.Node
}
@@ -31,12 +31,8 @@ func (n *Finally) GetPosition() *position.Position {
return n.Position
}
func (n *Finally) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Finally) GetMeta() []meta.Meta {
return n.Meta
func (n *Finally) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// For node
type For struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Init []node.Node
Cond []node.Node
@@ -37,12 +37,8 @@ func (n *For) GetPosition() *position.Position {
return n.Position
}
func (n *For) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *For) GetMeta() []meta.Meta {
return n.Meta
func (n *For) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Foreach node
type Foreach struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
Key node.Node
@@ -37,12 +37,8 @@ func (n *Foreach) GetPosition() *position.Position {
return n.Position
}
func (n *Foreach) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Foreach) GetMeta() []meta.Meta {
return n.Meta
func (n *Foreach) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Function node
type Function struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
ReturnsRef bool
PhpDocComment string
@@ -41,12 +41,8 @@ func (n *Function) GetPosition() *position.Position {
return n.Position
}
func (n *Function) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Function) GetMeta() []meta.Meta {
return n.Meta
func (n *Function) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Global node
type Global struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Vars []node.Node
}
@@ -31,12 +31,8 @@ func (n *Global) GetPosition() *position.Position {
return n.Position
}
func (n *Global) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Global) GetMeta() []meta.Meta {
return n.Meta
func (n *Global) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Goto node
type Goto struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Label node.Node
}
@@ -31,12 +31,8 @@ func (n *Goto) GetPosition() *position.Position {
return n.Position
}
func (n *Goto) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Goto) GetMeta() []meta.Meta {
return n.Meta
func (n *Goto) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// GroupUse node
type GroupUse struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
UseType node.Node
Prefix node.Node
@@ -35,12 +35,8 @@ func (n *GroupUse) GetPosition() *position.Position {
return n.Position
}
func (n *GroupUse) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *GroupUse) GetMeta() []meta.Meta {
return n.Meta
func (n *GroupUse) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -8,7 +8,7 @@ import (
// HaltCompiler node
type HaltCompiler struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
}
@@ -27,12 +27,8 @@ func (n *HaltCompiler) GetPosition() *position.Position {
return n.Position
}
func (n *HaltCompiler) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *HaltCompiler) GetMeta() []meta.Meta {
return n.Meta
func (n *HaltCompiler) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// If node
type If struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
@@ -37,12 +37,8 @@ func (n *If) GetPosition() *position.Position {
return n.Position
}
func (n *If) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *If) GetMeta() []meta.Meta {
return n.Meta
func (n *If) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -8,7 +8,7 @@ import (
// InlineHtml node
type InlineHtml struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Value string
}
@@ -30,12 +30,8 @@ func (n *InlineHtml) GetPosition() *position.Position {
return n.Position
}
func (n *InlineHtml) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *InlineHtml) GetMeta() []meta.Meta {
return n.Meta
func (n *InlineHtml) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Interface node
type Interface struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
PhpDocComment string
InterfaceName node.Node
@@ -37,12 +37,8 @@ func (n *Interface) GetPosition() *position.Position {
return n.Position
}
func (n *Interface) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Interface) GetMeta() []meta.Meta {
return n.Meta
func (n *Interface) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// InterfaceExtends node
type InterfaceExtends struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
InterfaceNames []node.Node
}
@@ -31,12 +31,8 @@ func (n *InterfaceExtends) GetPosition() *position.Position {
return n.Position
}
func (n *InterfaceExtends) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *InterfaceExtends) GetMeta() []meta.Meta {
return n.Meta
func (n *InterfaceExtends) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Label node
type Label struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
LabelName node.Node
}
@@ -31,12 +31,8 @@ func (n *Label) GetPosition() *position.Position {
return n.Position
}
func (n *Label) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Label) GetMeta() []meta.Meta {
return n.Meta
func (n *Label) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Namespace node
type Namespace struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
NamespaceName node.Node
Stmts []node.Node
@@ -33,12 +33,8 @@ func (n *Namespace) GetPosition() *position.Position {
return n.Position
}
func (n *Namespace) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Namespace) GetMeta() []meta.Meta {
return n.Meta
func (n *Namespace) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -8,7 +8,7 @@ import (
// Nop node
type Nop struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
}
@@ -27,12 +27,8 @@ func (n *Nop) GetPosition() *position.Position {
return n.Position
}
func (n *Nop) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Nop) GetMeta() []meta.Meta {
return n.Meta
func (n *Nop) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Property node
type Property struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
PhpDocComment string
Variable node.Node
@@ -35,12 +35,8 @@ func (n *Property) GetPosition() *position.Position {
return n.Position
}
func (n *Property) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Property) GetMeta() []meta.Meta {
return n.Meta
func (n *Property) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// PropertyList node
type PropertyList struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Modifiers []node.Node
Properties []node.Node
@@ -33,12 +33,8 @@ func (n *PropertyList) GetPosition() *position.Position {
return n.Position
}
func (n *PropertyList) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *PropertyList) GetMeta() []meta.Meta {
return n.Meta
func (n *PropertyList) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Return node
type Return struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
}
@@ -31,12 +31,8 @@ func (n *Return) GetPosition() *position.Position {
return n.Position
}
func (n *Return) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Return) GetMeta() []meta.Meta {
return n.Meta
func (n *Return) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Static node
type Static struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Vars []node.Node
}
@@ -31,12 +31,8 @@ func (n *Static) GetPosition() *position.Position {
return n.Position
}
func (n *Static) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Static) GetMeta() []meta.Meta {
return n.Meta
func (n *Static) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// StaticVar node
type StaticVar struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Variable node.Node
Expr node.Node
@@ -33,12 +33,8 @@ func (n *StaticVar) GetPosition() *position.Position {
return n.Position
}
func (n *StaticVar) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *StaticVar) GetMeta() []meta.Meta {
return n.Meta
func (n *StaticVar) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// StmtList node
type StmtList struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Stmts []node.Node
}
@@ -31,12 +31,8 @@ func (n *StmtList) GetPosition() *position.Position {
return n.Position
}
func (n *StmtList) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *StmtList) GetMeta() []meta.Meta {
return n.Meta
func (n *StmtList) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Switch node
type Switch struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
CaseList *CaseList
@@ -33,12 +33,8 @@ func (n *Switch) GetPosition() *position.Position {
return n.Position
}
func (n *Switch) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Switch) GetMeta() []meta.Meta {
return n.Meta
func (n *Switch) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Throw node
type Throw struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
}
@@ -31,12 +31,8 @@ func (n *Throw) GetPosition() *position.Position {
return n.Position
}
func (n *Throw) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Throw) GetMeta() []meta.Meta {
return n.Meta
func (n *Throw) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Trait node
type Trait struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
PhpDocComment string
TraitName node.Node
@@ -35,12 +35,8 @@ func (n *Trait) GetPosition() *position.Position {
return n.Position
}
func (n *Trait) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Trait) GetMeta() []meta.Meta {
return n.Meta
func (n *Trait) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// TraitAdaptationList node
type TraitAdaptationList struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Adaptations []node.Node
}
@@ -31,12 +31,8 @@ func (n *TraitAdaptationList) GetPosition() *position.Position {
return n.Position
}
func (n *TraitAdaptationList) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *TraitAdaptationList) GetMeta() []meta.Meta {
return n.Meta
func (n *TraitAdaptationList) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// TraitMethodRef node
type TraitMethodRef struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Trait node.Node
Method node.Node
@@ -33,12 +33,8 @@ func (n *TraitMethodRef) GetPosition() *position.Position {
return n.Position
}
func (n *TraitMethodRef) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *TraitMethodRef) GetMeta() []meta.Meta {
return n.Meta
func (n *TraitMethodRef) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// TraitUse node
type TraitUse struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Traits []node.Node
TraitAdaptationList node.Node
@@ -33,12 +33,8 @@ func (n *TraitUse) GetPosition() *position.Position {
return n.Position
}
func (n *TraitUse) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *TraitUse) GetMeta() []meta.Meta {
return n.Meta
func (n *TraitUse) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// TraitUseAlias node
type TraitUseAlias struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Ref node.Node
Modifier node.Node
@@ -35,12 +35,8 @@ func (n *TraitUseAlias) GetPosition() *position.Position {
return n.Position
}
func (n *TraitUseAlias) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *TraitUseAlias) GetMeta() []meta.Meta {
return n.Meta
func (n *TraitUseAlias) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// TraitUsePrecedence node
type TraitUsePrecedence struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Ref node.Node
Insteadof []node.Node
@@ -33,12 +33,8 @@ func (n *TraitUsePrecedence) GetPosition() *position.Position {
return n.Position
}
func (n *TraitUsePrecedence) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *TraitUsePrecedence) GetMeta() []meta.Meta {
return n.Meta
func (n *TraitUsePrecedence) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Try node
type Try struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Stmts []node.Node
Catches []node.Node
@@ -35,12 +35,8 @@ func (n *Try) GetPosition() *position.Position {
return n.Position
}
func (n *Try) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Try) GetMeta() []meta.Meta {
return n.Meta
func (n *Try) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Unset node
type Unset struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Vars []node.Node
}
@@ -31,12 +31,8 @@ func (n *Unset) GetPosition() *position.Position {
return n.Position
}
func (n *Unset) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Unset) GetMeta() []meta.Meta {
return n.Meta
func (n *Unset) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Use node
type Use struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
UseType node.Node
Use node.Node
@@ -35,12 +35,8 @@ func (n *Use) GetPosition() *position.Position {
return n.Position
}
func (n *Use) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Use) GetMeta() []meta.Meta {
return n.Meta
func (n *Use) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// UseList node
type UseList struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
UseType node.Node
Uses []node.Node
@@ -33,12 +33,8 @@ func (n *UseList) GetPosition() *position.Position {
return n.Position
}
func (n *UseList) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *UseList) GetMeta() []meta.Meta {
return n.Meta
func (n *UseList) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// While node
type While struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
@@ -33,12 +33,8 @@ func (n *While) GetPosition() *position.Position {
return n.Position
}
func (n *While) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *While) GetMeta() []meta.Meta {
return n.Meta
func (n *While) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -5,6 +5,8 @@ import (
"reflect"
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/position"
@@ -23,6 +25,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
t.Errorf("diff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("expected and actual are not equal\nexpectd: %+v\nactual: %+v\n", expected, actual)
t.Log(spew.Sdump(expected, actual))
}
}

View File

@@ -230,13 +230,14 @@ func TestAltDeclare(t *testing.T) {
},
Stmt: &stmt.StmtList{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 20,
EndPos: 32,
StartLine: -1,
EndLine: -1,
StartPos: -1,
EndPos: -1,
},
Stmts: []node.Node{},
},
Alt: true,
},
},
}

View File

@@ -74,12 +74,20 @@ var nodes = []node.Node{
}
func TestMeta(t *testing.T) {
expected := []meta.Meta{
meta.NewComment("//comment\n", nil),
meta.NewWhiteSpace(" ", nil),
expected := &meta.Collection{
&meta.Data{
Value: "//comment\n",
Type: meta.CommentType,
Position: nil,
},
&meta.Data{
Value: " ",
Type: meta.WhiteSpaceType,
Position: nil,
},
}
for _, n := range nodes {
n.AddMeta(expected)
n.GetMeta().Push(*expected...)
actual := n.GetMeta()
assertEqual(t, expected, actual)
}