#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

16
main.go
View File

@ -18,6 +18,7 @@ import (
"github.com/z7zmey/php-parser/parser"
"github.com/z7zmey/php-parser/php5"
"github.com/z7zmey/php-parser/php7"
"github.com/z7zmey/php-parser/printer"
"github.com/z7zmey/php-parser/visitor"
)
@ -27,6 +28,7 @@ var dumpType string
var profiler string
var withMeta *bool
var showResolvedNs *bool
var printBack *bool
type file struct {
path string
@ -37,6 +39,7 @@ func main() {
usePhp5 = flag.Bool("php5", false, "parse as PHP5")
withMeta = flag.Bool("meta", false, "show meta")
showResolvedNs = flag.Bool("r", false, "resolve names")
printBack = flag.Bool("pb", false, "print AST back into the parsed file")
flag.StringVar(&dumpType, "d", "", "dump format: [custom, go, json, pretty_json]")
flag.StringVar(&profiler, "prof", "", "start profiler: [cpu, mem, trace]")
@ -62,7 +65,7 @@ func main() {
}
// run printer goroutine
go printer(resultCh)
go printerWorker(resultCh)
// process files
processPath(flag.Args(), fileCh)
@ -133,7 +136,7 @@ func parserWorker(fileCh <-chan *file, result chan<- parser.Parser) {
}
}
func printer(result <-chan parser.Parser) {
func printerWorker(result <-chan parser.Parser) {
var counter int
w := bufio.NewWriter(os.Stdout)
@ -153,6 +156,15 @@ func printer(result <-chan parser.Parser) {
fmt.Fprintln(w, e)
}
if *printBack {
o := bytes.NewBuffer([]byte{})
p := printer.NewPrinter(o)
p.Print(parserWorker.GetRootNode())
err := ioutil.WriteFile(parserWorker.GetPath(), o.Bytes(), 0644)
checkErr(err)
}
var nsResolver *visitor.NamespaceResolver
if *showResolvedNs {
nsResolver = visitor.NewNamespaceResolver()

115
meta/collection.go Normal file
View File

@ -0,0 +1,115 @@
package meta
// Collection of Meta objects
type Collection []*Data
// SetTokenName sets TokenName for the all elements in the collection
func (mc *Collection) SetTokenName(tn TokenName) *Collection {
for _, m := range *mc {
m.TokenName = tn
}
return mc
}
// Push adds elements to the end of an Collection
func (mc *Collection) Push(mm ...*Data) *Collection {
*mc = append(*mc, mm...)
return mc
}
// Unshift prepends elements to the beginning of an Collection
func (mc *Collection) Unshift(mm ...*Data) *Collection {
*mc = append(mm, *mc...)
return mc
}
// AppendTo - appends elements of the collection to the end of the target collection
func (mc *Collection) AppendTo(target *Collection) *Collection {
if len(*mc) == 0 {
return mc
}
*target = append(*target, *mc...)
return mc
}
// PrependTo - prepends elements of the collection to the start of the target collection
func (mc *Collection) PrependTo(target *Collection) *Collection {
if len(*mc) == 0 {
return mc
}
*target = append(*mc, *target...)
return mc
}
// Cut elements by TokenName
func (mc *Collection) Cut(f Filter) *Collection {
collection := (*mc)[:0]
cutted := Collection{}
for _, m := range *mc {
if fr := f(m); fr {
cutted = append(cutted, m)
} else {
collection = append(collection, m)
}
}
*mc = collection
return &cutted
}
// Filter function signature
type Filter func(d *Data) bool
// TokenNameFilter generates filter function that returns true
// if data.TokenName exactly same as given
func TokenNameFilter(tn TokenName) Filter {
return func(d *Data) bool {
return d.TokenName == tn
}
}
// TypeFilter generates filter function that returns true
// if data.Type exactly same as given
func TypeFilter(t Type) Filter {
return func(d *Data) bool {
return d.Type == t
}
}
// AndFilter generates filter function that returns true
// if all given filters return true
func AndFilter(filters ...Filter) Filter {
return func(d *Data) bool {
for _, filter := range filters {
if result := filter(d); !result {
return false
}
}
return true
}
}
// OrFilter generates filter function that returns true
// if one of given filters return true
func OrFilter(filters ...Filter) Filter {
return func(d *Data) bool {
for _, filter := range filters {
if result := filter(d); result {
return true
}
}
return false
}
}
// NotFilter negates given filter
func NotFilter(f Filter) Filter {
return func(d *Data) bool {
return !f(d)
}
}

422
meta/collection_test.go Normal file
View File

@ -0,0 +1,422 @@
package meta_test
import (
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/meta"
)
func TestCollectionSetTokenName(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
comment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
}
baseCollection := meta.Collection{whiteSpace, comment}
// action
baseCollection.SetTokenName(meta.OpenParenthesisToken)
// check
for _, m := range baseCollection {
if m.TokenName != meta.OpenParenthesisToken {
t.Error("The TokenName must be set for all Meta objects")
}
}
}
func TestCollectionPush(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
comment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
}
actualCollection := meta.Collection{whiteSpace}
expectedCollection := meta.Collection{whiteSpace, comment}
// action
actualCollection.Push(comment)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
}
func TestCollectionUnshift(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
comment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
}
actualCollection := meta.Collection{comment}
expectedCollection := meta.Collection{whiteSpace, comment}
// action
actualCollection.Unshift(whiteSpace)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
}
func TestCollectionAppendTo(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
comment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
}
actualCollection := meta.Collection{whiteSpace}
expectedCollection := meta.Collection{whiteSpace, comment}
baseCollection := meta.Collection{comment}
// action
baseCollection.AppendTo(&actualCollection)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
}
func TestEmptyCollectionAppendTo(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
actualCollection := meta.Collection{whiteSpace}
expectedCollection := meta.Collection{whiteSpace}
var baseCollection meta.Collection = nil
// action
baseCollection.AppendTo(&actualCollection)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
}
func TestCollectionPrependTo(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
comment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
}
actualCollection := meta.Collection{comment}
expectedCollection := meta.Collection{whiteSpace, comment}
baseCollection := meta.Collection{whiteSpace}
// action
baseCollection.PrependTo(&actualCollection)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
}
func TestEmptyCollectionPrependTo(t *testing.T) {
// prepare
comment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
}
actualCollection := meta.Collection{comment}
expectedCollection := meta.Collection{comment}
baseCollection := meta.Collection{}
// action
baseCollection.PrependTo(&actualCollection)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
}
func TestCollectionCutByTokenName(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
OpenParenthesisComment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
TokenName: meta.OpenParenthesisToken,
}
OpenParenthesisToken := &meta.Data{
Type: meta.TokenType,
Value: "(",
TokenName: meta.OpenParenthesisToken,
}
CloseParenthesisToken := &meta.Data{
Type: meta.TokenType,
Value: ")",
TokenName: meta.CloseParenthesisToken,
}
actualCollection := meta.Collection{whiteSpace, OpenParenthesisComment, OpenParenthesisToken, CloseParenthesisToken}
expectedCollection := meta.Collection{whiteSpace, CloseParenthesisToken}
expectedCuttedCollection := &meta.Collection{OpenParenthesisComment, OpenParenthesisToken}
// action
actualCuttedCollection := actualCollection.Cut(
meta.TokenNameFilter(meta.OpenParenthesisToken),
)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
if !reflect.DeepEqual(expectedCuttedCollection, actualCuttedCollection) {
diff := pretty.Compare(expectedCuttedCollection, actualCuttedCollection)
if diff != "" {
t.Errorf("\nexpected and actual cutted collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual cutted collections are not equal\n")
}
}
}
func TestCollectionCutByTokenTypes(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
OpenParenthesisComment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
TokenName: meta.OpenParenthesisToken,
}
OpenParenthesisToken := &meta.Data{
Type: meta.TokenType,
Value: "(",
TokenName: meta.OpenParenthesisToken,
}
CloseParenthesisToken := &meta.Data{
Type: meta.TokenType,
Value: ")",
TokenName: meta.CloseParenthesisToken,
}
actualCollection := meta.Collection{whiteSpace, OpenParenthesisComment, OpenParenthesisToken, CloseParenthesisToken}
expectedCollection := meta.Collection{OpenParenthesisToken, CloseParenthesisToken}
expectedCuttedCollection := &meta.Collection{whiteSpace, OpenParenthesisComment}
// action
actualCuttedCollection := actualCollection.Cut(meta.OrFilter(
meta.TypeFilter(meta.CommentType),
meta.TypeFilter(meta.WhiteSpaceType)),
)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
if !reflect.DeepEqual(expectedCuttedCollection, actualCuttedCollection) {
diff := pretty.Compare(expectedCuttedCollection, actualCuttedCollection)
if diff != "" {
t.Errorf("\nexpected and actual cutted collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual cutted collections are not equal\n")
}
}
}
func TestCollectionCutByTokenNameButNotType(t *testing.T) {
// prepare
whiteSpace := &meta.Data{
Type: meta.WhiteSpaceType,
Value: "\n",
}
OpenParenthesisComment := &meta.Data{
Type: meta.CommentType,
Value: "// some comment",
TokenName: meta.OpenParenthesisToken,
}
OpenParenthesisToken := &meta.Data{
Type: meta.TokenType,
Value: "(",
TokenName: meta.OpenParenthesisToken,
}
CloseParenthesisToken := &meta.Data{
Type: meta.TokenType,
Value: ")",
TokenName: meta.CloseParenthesisToken,
}
actualCollection := meta.Collection{
whiteSpace,
OpenParenthesisComment,
OpenParenthesisToken,
CloseParenthesisToken,
}
expectedCollection := meta.Collection{
whiteSpace,
OpenParenthesisToken,
CloseParenthesisToken,
}
expectedCuttedCollection := &meta.Collection{
OpenParenthesisComment,
}
// action
actualCuttedCollection := actualCollection.Cut(meta.AndFilter(
meta.TokenNameFilter(meta.OpenParenthesisToken),
meta.NotFilter(meta.TypeFilter(meta.TokenType))),
)
// check
if !reflect.DeepEqual(expectedCollection, actualCollection) {
diff := pretty.Compare(expectedCollection, actualCollection)
if diff != "" {
t.Errorf("\nexpected and actual collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual collections are not equal\n")
}
}
if !reflect.DeepEqual(expectedCuttedCollection, actualCuttedCollection) {
diff := pretty.Compare(expectedCuttedCollection, actualCuttedCollection)
if diff != "" {
t.Errorf("\nexpected and actual cutted collections are not equal\ndiff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("\nexpected and actual cutted collections are not equal\n")
}
}
}

View File

@ -1,39 +0,0 @@
package meta
import (
"github.com/z7zmey/php-parser/position"
)
// Comment aggrigates information about comment /**
type Comment struct {
Value string
Position *position.Position
TokenName TokenName
}
// NewComment - Comment constructor
func NewComment(value string, pos *position.Position) *Comment {
return &Comment{
Value: value,
Position: pos,
TokenName: UnknownToken,
}
}
// SetTokenName sets token name
func (c *Comment) SetTokenName(tokenName TokenName) {
c.TokenName = tokenName
}
// GetTokenName returns token name
func (c *Comment) GetTokenName() TokenName {
return c.TokenName
}
func (c *Comment) String() string {
return c.Value
}
func (c *Comment) GetPosition() *position.Position {
return c.Position
}

View File

@ -1,44 +0,0 @@
package meta_test
import (
"testing"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/meta"
)
func TestCommentPrint(t *testing.T) {
expected := "/** hello world */"
comment := meta.NewComment(expected, nil)
actual := comment.String()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}
func TestCommentSetGetTokenName(t *testing.T) {
expected := meta.ArrayToken
c := meta.NewComment("/** hello world */", nil)
c.SetTokenName(expected)
actual := c.GetTokenName()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}
func TestCommentGetPosition(t *testing.T) {
expected := position.NewPosition(1, 1, 1, 1)
c := meta.NewComment("/** hello world */", expected)
actual := c.GetPosition()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}

17
meta/data.go Normal file
View File

@ -0,0 +1,17 @@
package meta
import (
"github.com/z7zmey/php-parser/position"
)
// Data contain additional information that isn't part of AST
type Data struct {
Value string
Type Type
Position *position.Position
TokenName TokenName
}
func (d *Data) String() string {
return d.Value
}

21
meta/data_test.go Normal file
View File

@ -0,0 +1,21 @@
package meta_test
import (
"testing"
"github.com/z7zmey/php-parser/meta"
)
func TestCommentPrint(t *testing.T) {
expected := "/** hello world */"
comment := meta.Data{
Value: expected,
}
actual := comment.String()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}

View File

@ -1,12 +0,0 @@
package meta
import (
"github.com/z7zmey/php-parser/position"
)
type Meta interface {
String() string
SetTokenName(tn TokenName)
GetTokenName() TokenName
GetPosition() *position.Position
}

View File

@ -36,7 +36,6 @@ const (
EnddeclareToken
AsToken
SwitchToken
SwitchSemicolonToken
EndswitchToken
CaseToken
DefaultToken
@ -68,9 +67,11 @@ const (
CallableToken
StartHeredocToken
DollarOpenCurlyBracesToken
DollarCloseCurlyBracesToken
CurlyOpenToken
PaamayimNekudotayimToken
NamespaceToken
UseLeadingNsSeparatorToken
NsSeparatorToken
EllipsisToken
EvalToken
@ -80,7 +81,7 @@ const (
LogicalXorToken
LogicalAndToken
InstanceofToken
NewToken
NewAnchor
CloneToken
ElseifToken
ElseToken

View File

@ -4,9 +4,9 @@ package meta
import "strconv"
const _TokenName_name = "UnknownTokenNodeStartNodeEndMagicConstantTokenIncludeTokenIncludeOnceTokenExitTokenIfTokenLnumberTokenDnumberTokenStringTokenStringVarnameTokenVariableTokenNumStringTokenInlineHTMLTokenEncapsedAndWhitespaceTokenConstantEncapsedStringTokenEchoTokenDoTokenWhileTokenEndwhileTokenForInitSemicolonTokenForCondSemicolonTokenForTokenEndforTokenForeachTokenEndforeachTokenDeclareTokenEnddeclareTokenAsTokenSwitchTokenSwitchSemicolonTokenEndswitchTokenCaseTokenDefaultTokenBreakTokenContinueTokenGotoTokenFunctionTokenConstTokenReturnTokenTryTokenCatchTokenFinallyTokenThrowTokenUseTokenInsteadofTokenGlobalTokenVarTokenUnsetTokenIssetTokenEmptyTokenClassTokenTraitTokenInterfaceTokenExtendsTokenImplementsTokenDoubleArrowTokenListTokenArrayTokenCallableTokenStartHeredocTokenDollarOpenCurlyBracesTokenCurlyOpenTokenPaamayimNekudotayimTokenNamespaceTokenNsSeparatorTokenEllipsisTokenEvalTokenRequireTokenRequireOnceTokenLogicalOrTokenLogicalXorTokenLogicalAndTokenInstanceofTokenNewTokenCloneTokenElseifTokenElseTokenEndifTokenPrintTokenYieldTokenStaticTokenAbstractTokenFinalTokenPrivateTokenProtectedTokenPublicTokenIncTokenDecTokenYieldFromTokenObjectOperatorTokenIntCastTokenDoubleCastTokenStringCastTokenArrayCastTokenObjectCastTokenBoolCastTokenUnsetCastTokenCoalesceTokenSpaceshipTokenPlusEqualTokenMinusEqualTokenMulEqualTokenPowEqualTokenDivEqualTokenConcatEqualTokenModEqualTokenAndEqualTokenOrEqualTokenXorEqualTokenSlEqualTokenSrEqualTokenBooleanOrTokenBooleanAndTokenPowTokenSlTokenSrTokenIsIdenticalTokenIsNotIdenticalTokenIsEqualTokenIsNotEqualTokenIsSmallerOrEqualTokenIsGreaterOrEqualTokenHaltCompilerTokenIdentifierTokenCaseSeparatorTokenDoubleQuoteTokenBackquoteTokenOpenCurlyBracesTokenCloseCurlyBracesTokenSemiColonTokenColonTokenOpenParenthesisTokenCloseParenthesisTokenOpenSquareBracketCloseSquareBracketQuestionMarkTokenAmpersandTokenMinusTokenPlusTokenExclamationMarkTokenTildeTokenAtTokenDollarTokenCommaTokenVerticalBarTokenEqualTokenCaretTokenAsteriskTokenSlashTokenPercentTokenLessTokenGreaterTokenDotToken"
const _TokenName_name = "UnknownTokenNodeStartNodeEndMagicConstantTokenIncludeTokenIncludeOnceTokenExitTokenIfTokenLnumberTokenDnumberTokenStringTokenStringVarnameTokenVariableTokenNumStringTokenInlineHTMLTokenEncapsedAndWhitespaceTokenConstantEncapsedStringTokenEchoTokenDoTokenWhileTokenEndwhileTokenForInitSemicolonTokenForCondSemicolonTokenForTokenEndforTokenForeachTokenEndforeachTokenDeclareTokenEnddeclareTokenAsTokenSwitchTokenEndswitchTokenCaseTokenDefaultTokenBreakTokenContinueTokenGotoTokenFunctionTokenConstTokenReturnTokenTryTokenCatchTokenFinallyTokenThrowTokenUseTokenInsteadofTokenGlobalTokenVarTokenUnsetTokenIssetTokenEmptyTokenClassTokenTraitTokenInterfaceTokenExtendsTokenImplementsTokenDoubleArrowTokenListTokenArrayTokenCallableTokenStartHeredocTokenDollarOpenCurlyBracesTokenDollarCloseCurlyBracesTokenCurlyOpenTokenPaamayimNekudotayimTokenNamespaceTokenUseLeadingNsSeparatorTokenNsSeparatorTokenEllipsisTokenEvalTokenRequireTokenRequireOnceTokenLogicalOrTokenLogicalXorTokenLogicalAndTokenInstanceofTokenNewAnchorCloneTokenElseifTokenElseTokenEndifTokenPrintTokenYieldTokenStaticTokenAbstractTokenFinalTokenPrivateTokenProtectedTokenPublicTokenIncTokenDecTokenYieldFromTokenObjectOperatorTokenIntCastTokenDoubleCastTokenStringCastTokenArrayCastTokenObjectCastTokenBoolCastTokenUnsetCastTokenCoalesceTokenSpaceshipTokenPlusEqualTokenMinusEqualTokenMulEqualTokenPowEqualTokenDivEqualTokenConcatEqualTokenModEqualTokenAndEqualTokenOrEqualTokenXorEqualTokenSlEqualTokenSrEqualTokenBooleanOrTokenBooleanAndTokenPowTokenSlTokenSrTokenIsIdenticalTokenIsNotIdenticalTokenIsEqualTokenIsNotEqualTokenIsSmallerOrEqualTokenIsGreaterOrEqualTokenHaltCompilerTokenIdentifierTokenCaseSeparatorTokenDoubleQuoteTokenBackquoteTokenOpenCurlyBracesTokenCloseCurlyBracesTokenSemiColonTokenColonTokenOpenParenthesisTokenCloseParenthesisTokenOpenSquareBracketCloseSquareBracketQuestionMarkTokenAmpersandTokenMinusTokenPlusTokenExclamationMarkTokenTildeTokenAtTokenDollarTokenCommaTokenVerticalBarTokenEqualTokenCaretTokenAsteriskTokenSlashTokenPercentTokenLessTokenGreaterTokenDotToken"
var _TokenName_index = [...]uint16{0, 12, 21, 28, 46, 58, 74, 83, 90, 102, 114, 125, 143, 156, 170, 185, 211, 238, 247, 254, 264, 277, 298, 319, 327, 338, 350, 365, 377, 392, 399, 410, 430, 444, 453, 465, 475, 488, 497, 510, 520, 531, 539, 549, 561, 571, 579, 593, 604, 612, 622, 632, 642, 652, 662, 676, 688, 703, 719, 728, 738, 751, 768, 794, 808, 832, 846, 862, 875, 884, 896, 912, 926, 941, 956, 971, 979, 989, 1000, 1009, 1019, 1029, 1039, 1050, 1063, 1073, 1085, 1099, 1110, 1118, 1126, 1140, 1159, 1171, 1186, 1201, 1215, 1230, 1243, 1257, 1270, 1284, 1298, 1313, 1326, 1339, 1352, 1368, 1381, 1394, 1406, 1419, 1431, 1443, 1457, 1472, 1480, 1487, 1494, 1510, 1529, 1541, 1556, 1577, 1598, 1615, 1630, 1648, 1664, 1678, 1698, 1719, 1733, 1743, 1763, 1784, 1801, 1819, 1836, 1850, 1860, 1869, 1889, 1899, 1906, 1917, 1927, 1943, 1953, 1963, 1976, 1986, 1998, 2007, 2019, 2027}
var _TokenName_index = [...]uint16{0, 12, 21, 28, 46, 58, 74, 83, 90, 102, 114, 125, 143, 156, 170, 185, 211, 238, 247, 254, 264, 277, 298, 319, 327, 338, 350, 365, 377, 392, 399, 410, 424, 433, 445, 455, 468, 477, 490, 500, 511, 519, 529, 541, 551, 559, 573, 584, 592, 602, 612, 622, 632, 642, 656, 668, 683, 699, 708, 718, 731, 748, 774, 801, 815, 839, 853, 879, 895, 908, 917, 929, 945, 959, 974, 989, 1004, 1013, 1023, 1034, 1043, 1053, 1063, 1073, 1084, 1097, 1107, 1119, 1133, 1144, 1152, 1160, 1174, 1193, 1205, 1220, 1235, 1249, 1264, 1277, 1291, 1304, 1318, 1332, 1347, 1360, 1373, 1386, 1402, 1415, 1428, 1440, 1453, 1465, 1477, 1491, 1506, 1514, 1521, 1528, 1544, 1563, 1575, 1590, 1611, 1632, 1649, 1664, 1682, 1698, 1712, 1732, 1753, 1767, 1777, 1797, 1818, 1835, 1853, 1870, 1884, 1894, 1903, 1923, 1933, 1940, 1951, 1961, 1977, 1987, 1997, 2010, 2020, 2032, 2041, 2053, 2061}
func (i TokenName) String() string {
if i < 0 || i >= TokenName(len(_TokenName_index)-1) {

11
meta/type.go Normal file
View File

@ -0,0 +1,11 @@
package meta
// Type TODO
type Type int
//go:generate stringer -type=Type -output ./type_string.go
const (
CommentType Type = iota
WhiteSpaceType
TokenType
)

16
meta/type_string.go Normal file
View File

@ -0,0 +1,16 @@
// Code generated by "stringer -type=Type -output ./type_string.go"; DO NOT EDIT.
package meta
import "strconv"
const _Type_name = "CommentTypeWhiteSpaceTypeTokenType"
var _Type_index = [...]uint8{0, 11, 25, 34}
func (i Type) String() string {
if i < 0 || i >= Type(len(_Type_index)-1) {
return "Type(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Type_name[_Type_index[i]:_Type_index[i+1]]
}

29
meta/type_test.go Normal file
View File

@ -0,0 +1,29 @@
package meta_test
import (
"testing"
"github.com/z7zmey/php-parser/meta"
)
func TestTypeString(t *testing.T) {
c := meta.CommentType
expected := "CommentType"
actual := c.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}
func TestWrongTypeString(t *testing.T) {
c := meta.Type(-1)
expected := "Type(-1)"
actual := c.String()
if expected != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
}
}

View File

@ -1,37 +0,0 @@
package meta
import (
"github.com/z7zmey/php-parser/position"
)
type WhiteSpace struct {
Value string
Position *position.Position
TokenName TokenName
}
func NewWhiteSpace(value string, pos *position.Position) *WhiteSpace {
return &WhiteSpace{
Value: value,
Position: pos,
TokenName: UnknownToken,
}
}
// SetTokenName sets token name
func (c *WhiteSpace) SetTokenName(tokenName TokenName) {
c.TokenName = tokenName
}
// GetTokenName returns token name
func (c *WhiteSpace) GetTokenName() TokenName {
return c.TokenName
}
func (el *WhiteSpace) String() string {
return el.Value
}
func (el *WhiteSpace) GetPosition() *position.Position {
return el.Position
}

View File

@ -1,44 +0,0 @@
package meta_test
import (
"testing"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/meta"
)
func TestWhiteSpacePrint(t *testing.T) {
expected := "\n "
w := meta.NewWhiteSpace(expected, nil)
actual := w.String()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}
func TestWhiteSpaceSetGetTokenName(t *testing.T) {
expected := meta.ArrayToken
w := meta.NewWhiteSpace("\n ", nil)
w.SetTokenName(expected)
actual := w.GetTokenName()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}
func TestWhiteSpaceGetPosition(t *testing.T) {
expected := position.NewPosition(1, 1, 1, 1)
q := meta.NewWhiteSpace("\n ", expected)
actual := q.GetPosition()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,12 +29,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)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,12 +41,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)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ import (
// String node
type String struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Expr node.Node
}
@ -31,12 +31,8 @@ func (n *String) GetPosition() *position.Position {
return n.Position
}
func (n *String) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *String) GetMeta() []meta.Meta {
return n.Meta
func (n *String) 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
Expr 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

@ -21,12 +21,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)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More