Merge pull request #74 from z7zmey/meta-refactoring
Rename package `meta` to `freefloating` and refactor
This commit is contained in:
commit
2f1834a2ee
16
freefloating/position_string.go
Normal file
16
freefloating/position_string.go
Normal file
@ -0,0 +1,16 @@
|
||||
// Code generated by "stringer -type=Position -output ./position_string.go"; DO NOT EDIT.
|
||||
|
||||
package freefloating
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _Position_name = "StartEndSlashColonSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken"
|
||||
|
||||
var _Position_index = [...]uint16{0, 5, 8, 13, 18, 27, 33, 39, 48, 52, 58, 61, 64, 71, 81, 93, 106, 117, 123, 126, 130, 134, 142, 150, 157, 161, 165, 178, 187, 193, 198, 201, 206, 209, 215, 220, 227, 234, 239, 246, 250, 257, 259, 265, 269, 277, 285, 290, 292, 297, 301, 306, 311, 316, 320, 324, 327, 332, 337, 342, 349, 358, 366, 375, 387, 400, 413, 424, 436, 448, 461, 475, 489, 507, 527, 548}
|
||||
|
||||
func (i Position) String() string {
|
||||
if i < 0 || i >= Position(len(_Position_index)-1) {
|
||||
return "Position(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Position_name[_Position_index[i]:_Position_index[i+1]]
|
||||
}
|
112
freefloating/string.go
Normal file
112
freefloating/string.go
Normal file
@ -0,0 +1,112 @@
|
||||
package freefloating
|
||||
|
||||
import "github.com/z7zmey/php-parser/position"
|
||||
|
||||
type StringType int
|
||||
|
||||
const (
|
||||
WhiteSpaceType StringType = iota
|
||||
CommentType
|
||||
TokenType
|
||||
)
|
||||
|
||||
type Position int
|
||||
|
||||
//go:generate stringer -type=Position -output ./position_string.go
|
||||
const (
|
||||
Start Position = iota
|
||||
End
|
||||
Slash
|
||||
Colon
|
||||
SemiColon
|
||||
AltEnd
|
||||
Dollar
|
||||
Ampersand
|
||||
Name
|
||||
Prefix
|
||||
Key
|
||||
Var
|
||||
UseType
|
||||
ReturnType
|
||||
OptionalType
|
||||
CaseSeparator
|
||||
LexicalVars
|
||||
Params
|
||||
Ref
|
||||
Cast
|
||||
Expr
|
||||
InitExpr
|
||||
CondExpr
|
||||
IncExpr
|
||||
True
|
||||
Cond
|
||||
|
||||
HaltCompiller
|
||||
Namespace
|
||||
Static
|
||||
Class
|
||||
Use
|
||||
While
|
||||
For
|
||||
Switch
|
||||
Break
|
||||
Foreach
|
||||
Declare
|
||||
Label
|
||||
Finally
|
||||
List
|
||||
Default
|
||||
If
|
||||
ElseIf
|
||||
Else
|
||||
Variadic
|
||||
Function
|
||||
Alias
|
||||
As
|
||||
Equal
|
||||
Exit
|
||||
Array
|
||||
Isset
|
||||
Empty
|
||||
Eval
|
||||
Echo
|
||||
Try
|
||||
Catch
|
||||
Unset
|
||||
|
||||
Stmts
|
||||
VarList
|
||||
ConstList
|
||||
NameList
|
||||
ParamList
|
||||
ModifierList
|
||||
ArrayPairList
|
||||
CaseListStart
|
||||
CaseListEnd
|
||||
ArgumentList
|
||||
PropertyList
|
||||
ParameterList
|
||||
AdaptationList
|
||||
LexicalVarList
|
||||
UseDeclarationList
|
||||
|
||||
OpenParenthesisToken
|
||||
CloseParenthesisToken
|
||||
)
|
||||
|
||||
type String struct {
|
||||
StringType StringType
|
||||
Value string
|
||||
Position *position.Position
|
||||
}
|
||||
|
||||
type Collection map[Position][]String
|
||||
|
||||
func (c Collection) IsEmpty() bool {
|
||||
for _, v := range c {
|
||||
if len(v) > 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
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
|
||||
}
|
||||
|
||||
// FindBy filter
|
||||
func (mc *Collection) FindBy(f Filter) Collection {
|
||||
found := Collection{}
|
||||
|
||||
for _, m := range *mc {
|
||||
if fr := f(m); fr {
|
||||
found = append(found, m)
|
||||
}
|
||||
}
|
||||
|
||||
return found
|
||||
}
|
||||
|
||||
// Filter function signature
|
||||
type Filter func(d *Data) bool
|
||||
|
||||
// TokenNameFilter generates filter function that returns true
|
||||
// if data.TokenName has in the arguments list
|
||||
func TokenNameFilter(tokenNames ...TokenName) Filter {
|
||||
return func(d *Data) bool {
|
||||
for _, tn := range tokenNames {
|
||||
if d.TokenName == tn {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// TypeFilter generates filter function that returns true
|
||||
// if data.Type has in the arguments list
|
||||
func TypeFilter(types ...Type) Filter {
|
||||
return func(d *Data) bool {
|
||||
for _, t := range types {
|
||||
if d.Type == t {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// ValueFilter generates filter function that returns true
|
||||
// if data.Value has in the arguments list
|
||||
func ValueFilter(values ...string) Filter {
|
||||
return func(d *Data) bool {
|
||||
for _, v := range values {
|
||||
if d.Value == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
// StopOnFailureFilter always returns false after first failure
|
||||
func StopOnFailureFilter(f Filter) Filter {
|
||||
stopFlag := false
|
||||
return func(d *Data) bool {
|
||||
if stopFlag == true {
|
||||
return false
|
||||
}
|
||||
|
||||
if !f(d) {
|
||||
stopFlag = true
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
@ -1,648 +0,0 @@
|
||||
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}
|
||||
expectedCutCollection := &meta.Collection{OpenParenthesisComment, OpenParenthesisToken}
|
||||
|
||||
// action
|
||||
|
||||
actualCutCollection := 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(expectedCutCollection, actualCutCollection) {
|
||||
diff := pretty.Compare(expectedCutCollection, actualCutCollection)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\ndiff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("\nexpected and actual Cut 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}
|
||||
expectedCutCollection := &meta.Collection{whiteSpace, OpenParenthesisComment}
|
||||
|
||||
// action
|
||||
|
||||
actualCutCollection := 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(expectedCutCollection, actualCutCollection) {
|
||||
diff := pretty.Compare(expectedCutCollection, actualCutCollection)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\ndiff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("\nexpected and actual Cut 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,
|
||||
}
|
||||
expectedCutCollection := &meta.Collection{
|
||||
OpenParenthesisComment,
|
||||
}
|
||||
|
||||
// action
|
||||
|
||||
actualCutCollection := 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(expectedCutCollection, actualCutCollection) {
|
||||
diff := pretty.Compare(expectedCutCollection, actualCutCollection)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\ndiff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectionCutByValue(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,
|
||||
OpenParenthesisComment,
|
||||
}
|
||||
expectedCutCollection := &meta.Collection{
|
||||
OpenParenthesisToken,
|
||||
CloseParenthesisToken,
|
||||
}
|
||||
|
||||
// action
|
||||
|
||||
actualCutCollection := actualCollection.Cut(meta.ValueFilter("(", ")"))
|
||||
|
||||
// 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(expectedCutCollection, actualCutCollection) {
|
||||
diff := pretty.Compare(expectedCutCollection, actualCutCollection)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\ndiff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectionCutUntilFirstToken(t *testing.T) {
|
||||
|
||||
// prepare
|
||||
|
||||
whiteSpace := &meta.Data{
|
||||
Type: meta.WhiteSpaceType,
|
||||
Value: "\n",
|
||||
TokenName: meta.NodeStart,
|
||||
}
|
||||
OpenParenthesisComment := &meta.Data{
|
||||
Type: meta.CommentType,
|
||||
Value: "// some comment",
|
||||
TokenName: meta.NodeStart,
|
||||
}
|
||||
OpenParenthesisToken := &meta.Data{
|
||||
Type: meta.TokenType,
|
||||
Value: "(",
|
||||
TokenName: meta.OpenParenthesisToken,
|
||||
}
|
||||
CloseParenthesisComment := &meta.Data{
|
||||
Type: meta.WhiteSpaceType,
|
||||
Value: "// some comment",
|
||||
TokenName: meta.OpenParenthesisToken,
|
||||
}
|
||||
CloseParenthesisToken := &meta.Data{
|
||||
Type: meta.TokenType,
|
||||
Value: ")",
|
||||
TokenName: meta.CloseParenthesisToken,
|
||||
}
|
||||
|
||||
actualCollection := meta.Collection{
|
||||
whiteSpace,
|
||||
OpenParenthesisComment,
|
||||
OpenParenthesisToken,
|
||||
CloseParenthesisComment,
|
||||
CloseParenthesisToken,
|
||||
}
|
||||
|
||||
expectedCutCollection := &meta.Collection{
|
||||
whiteSpace,
|
||||
OpenParenthesisComment,
|
||||
}
|
||||
expectedCollection := meta.Collection{
|
||||
OpenParenthesisToken,
|
||||
CloseParenthesisComment, // must not be cut
|
||||
CloseParenthesisToken,
|
||||
}
|
||||
|
||||
// action
|
||||
|
||||
actualCutCollection := actualCollection.Cut(
|
||||
meta.StopOnFailureFilter(
|
||||
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(expectedCutCollection, actualCutCollection) {
|
||||
diff := pretty.Compare(expectedCutCollection, actualCutCollection)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\ndiff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectionFindByType(t *testing.T) {
|
||||
|
||||
// prepare
|
||||
|
||||
whiteSpace := &meta.Data{
|
||||
Type: meta.WhiteSpaceType,
|
||||
Value: "\n",
|
||||
TokenName: meta.NodeStart,
|
||||
}
|
||||
OpenParenthesisComment := &meta.Data{
|
||||
Type: meta.CommentType,
|
||||
Value: "// some comment",
|
||||
TokenName: meta.NodeStart,
|
||||
}
|
||||
OpenParenthesisToken := &meta.Data{
|
||||
Type: meta.TokenType,
|
||||
Value: "(",
|
||||
TokenName: meta.OpenParenthesisToken,
|
||||
}
|
||||
CloseParenthesisComment := &meta.Data{
|
||||
Type: meta.WhiteSpaceType,
|
||||
Value: "// some comment",
|
||||
TokenName: meta.OpenParenthesisToken,
|
||||
}
|
||||
CloseParenthesisToken := &meta.Data{
|
||||
Type: meta.TokenType,
|
||||
Value: ")",
|
||||
TokenName: meta.CloseParenthesisToken,
|
||||
}
|
||||
|
||||
actualCollection := meta.Collection{
|
||||
whiteSpace,
|
||||
OpenParenthesisComment,
|
||||
OpenParenthesisToken,
|
||||
CloseParenthesisComment,
|
||||
CloseParenthesisToken,
|
||||
}
|
||||
|
||||
expectedCollection := meta.Collection{
|
||||
whiteSpace,
|
||||
OpenParenthesisComment,
|
||||
OpenParenthesisToken,
|
||||
CloseParenthesisComment,
|
||||
CloseParenthesisToken,
|
||||
}
|
||||
|
||||
expectedFoundCollection := meta.Collection{
|
||||
OpenParenthesisToken,
|
||||
CloseParenthesisToken,
|
||||
}
|
||||
|
||||
// action
|
||||
|
||||
actualFoundCollection := actualCollection.FindBy(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(expectedFoundCollection, actualFoundCollection) {
|
||||
diff := pretty.Compare(expectedFoundCollection, actualFoundCollection)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\ndiff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("\nexpected and actual Cut collections are not equal\n")
|
||||
}
|
||||
}
|
||||
}
|
17
meta/data.go
17
meta/data.go
@ -1,17 +0,0 @@
|
||||
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
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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")
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package meta
|
||||
|
||||
// TokenName is used to specify a comment position
|
||||
type TokenName int
|
||||
|
||||
//go:generate stringer -type=TokenName -output ./tokenName_string.go
|
||||
const (
|
||||
NodeStart TokenName = iota
|
||||
NodeEnd
|
||||
WhileToken
|
||||
EndwhileToken
|
||||
ForInitSemicolonToken
|
||||
ForCondSemicolonToken
|
||||
EndforToken
|
||||
EndforeachToken
|
||||
EnddeclareToken
|
||||
AsToken
|
||||
EndswitchToken
|
||||
FunctionToken
|
||||
ConstToken
|
||||
InsteadofToken
|
||||
ClassToken
|
||||
ExtendsToken
|
||||
ImplementsToken
|
||||
DoubleArrowToken
|
||||
PaamayimNekudotayimToken
|
||||
NsSeparatorToken
|
||||
EllipsisToken
|
||||
LogicalOrToken
|
||||
LogicalXorToken
|
||||
LogicalAndToken
|
||||
InstanceofToken
|
||||
EndifToken
|
||||
IncToken
|
||||
DecToken
|
||||
ObjectOperatorToken
|
||||
CoalesceToken
|
||||
SpaceshipToken
|
||||
PlusEqualToken
|
||||
MinusEqualToken
|
||||
MulEqualToken
|
||||
PowEqualToken
|
||||
DivEqualToken
|
||||
ConcatEqualToken
|
||||
ModEqualToken
|
||||
AndEqualToken
|
||||
OrEqualToken
|
||||
XorEqualToken
|
||||
SlEqualToken
|
||||
SrEqualToken
|
||||
BooleanOrToken
|
||||
BooleanAndToken
|
||||
PowToken
|
||||
SlToken
|
||||
SrToken
|
||||
IsIdenticalToken
|
||||
IsNotIdenticalToken
|
||||
IsEqualToken
|
||||
IsNotEqualToken
|
||||
IsSmallerOrEqualToken
|
||||
IsGreaterOrEqualToken
|
||||
CaseSeparatorToken // ';' or ':'
|
||||
OpenCurlyBracesToken // '{'
|
||||
CloseCurlyBracesToken // '}'
|
||||
SemiColonToken // ';'
|
||||
ColonToken // ':'
|
||||
OpenParenthesisToken // '('
|
||||
CloseParenthesisToken // ')'
|
||||
OpenSquareBracket // '['
|
||||
CloseSquareBracket // ']'
|
||||
QuestionMarkToken // '?'
|
||||
AmpersandToken // '&'
|
||||
MinusToken // '-'
|
||||
PlusToken // '+'
|
||||
CommaToken // ','
|
||||
VerticalBarToken // '|'
|
||||
EqualToken // '='
|
||||
CaretToken // '^'
|
||||
AsteriskToken // '*'
|
||||
SlashToken // '/'
|
||||
PercentToken // '%'
|
||||
LessToken // '<'
|
||||
GreaterToken // '>'
|
||||
DotToken // '.'
|
||||
)
|
@ -1,16 +0,0 @@
|
||||
// Code generated by "stringer -type=TokenName -output ./tokenName_string.go"; DO NOT EDIT.
|
||||
|
||||
package meta
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _TokenName_name = "NodeStartNodeEndWhileTokenEndwhileTokenForInitSemicolonTokenForCondSemicolonTokenEndforTokenEndforeachTokenEnddeclareTokenAsTokenEndswitchTokenFunctionTokenConstTokenInsteadofTokenClassTokenExtendsTokenImplementsTokenDoubleArrowTokenPaamayimNekudotayimTokenNsSeparatorTokenEllipsisTokenLogicalOrTokenLogicalXorTokenLogicalAndTokenInstanceofTokenEndifTokenIncTokenDecTokenObjectOperatorTokenCoalesceTokenSpaceshipTokenPlusEqualTokenMinusEqualTokenMulEqualTokenPowEqualTokenDivEqualTokenConcatEqualTokenModEqualTokenAndEqualTokenOrEqualTokenXorEqualTokenSlEqualTokenSrEqualTokenBooleanOrTokenBooleanAndTokenPowTokenSlTokenSrTokenIsIdenticalTokenIsNotIdenticalTokenIsEqualTokenIsNotEqualTokenIsSmallerOrEqualTokenIsGreaterOrEqualTokenCaseSeparatorTokenOpenCurlyBracesTokenCloseCurlyBracesTokenSemiColonTokenColonTokenOpenParenthesisTokenCloseParenthesisTokenOpenSquareBracketCloseSquareBracketQuestionMarkTokenAmpersandTokenMinusTokenPlusTokenCommaTokenVerticalBarTokenEqualTokenCaretTokenAsteriskTokenSlashTokenPercentTokenLessTokenGreaterTokenDotToken"
|
||||
|
||||
var _TokenName_index = [...]uint16{0, 9, 16, 26, 39, 60, 81, 92, 107, 122, 129, 143, 156, 166, 180, 190, 202, 217, 233, 257, 273, 286, 300, 315, 330, 345, 355, 363, 371, 390, 403, 417, 431, 446, 459, 472, 485, 501, 514, 527, 539, 552, 564, 576, 590, 605, 613, 620, 627, 643, 662, 674, 689, 710, 731, 749, 769, 790, 804, 814, 834, 855, 872, 890, 907, 921, 931, 940, 950, 966, 976, 986, 999, 1009, 1021, 1030, 1042, 1050}
|
||||
|
||||
func (i TokenName) String() string {
|
||||
if i < 0 || i >= TokenName(len(_TokenName_index)-1) {
|
||||
return "TokenName(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _TokenName_name[_TokenName_index[i]:_TokenName_index[i+1]]
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package meta_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
)
|
||||
|
||||
func TestTokenNameString(t *testing.T) {
|
||||
c := meta.NsSeparatorToken
|
||||
|
||||
expected := "NsSeparatorToken"
|
||||
actual := c.String()
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrongTokenNameString(t *testing.T) {
|
||||
c := meta.TokenName(-1)
|
||||
|
||||
expected := "TokenName(-1)"
|
||||
actual := c.String()
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
||||
}
|
||||
}
|
11
meta/type.go
11
meta/type.go
@ -1,11 +0,0 @@
|
||||
package meta
|
||||
|
||||
// Type TODO
|
||||
type Type int
|
||||
|
||||
//go:generate stringer -type=Type -output ./type_string.go
|
||||
const (
|
||||
CommentType Type = iota
|
||||
WhiteSpaceType
|
||||
TokenType
|
||||
)
|
@ -1,16 +0,0 @@
|
||||
// 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]]
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Assign node
|
||||
type Assign struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Assign struct {
|
||||
// NewAssign node constructor
|
||||
func NewAssign(Variable node.Node, Expression node.Node) *Assign {
|
||||
return &Assign{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Assign) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Assign) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Assign) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Reference node
|
||||
type Reference struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Reference struct {
|
||||
// NewReference node constructor
|
||||
func NewReference(Variable node.Node, Expression node.Node) *Reference {
|
||||
return &Reference{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Reference) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Reference) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Reference) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BitwiseAnd node
|
||||
type BitwiseAnd struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type BitwiseAnd struct {
|
||||
// NewBitwiseAnd node constructor
|
||||
func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd {
|
||||
return &BitwiseAnd{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BitwiseAnd) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BitwiseAnd) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BitwiseAnd) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BitwiseOr node
|
||||
type BitwiseOr struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type BitwiseOr struct {
|
||||
// NewBitwiseOr node constructor
|
||||
func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr {
|
||||
return &BitwiseOr{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BitwiseOr) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BitwiseOr) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BitwiseOr) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BitwiseXor node
|
||||
type BitwiseXor struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type BitwiseXor struct {
|
||||
// NewBitwiseXor node constructor
|
||||
func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor {
|
||||
return &BitwiseXor{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BitwiseXor) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BitwiseXor) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BitwiseXor) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Concat node
|
||||
type Concat struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Concat struct {
|
||||
// NewConcat node constructor
|
||||
func NewConcat(Variable node.Node, Expression node.Node) *Concat {
|
||||
return &Concat{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Concat) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Concat) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Concat) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Div node
|
||||
type Div struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Div struct {
|
||||
// NewDiv node constructor
|
||||
func NewDiv(Variable node.Node, Expression node.Node) *Div {
|
||||
return &Div{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Div) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Div) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Div) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Minus node
|
||||
type Minus struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Minus struct {
|
||||
// NewMinus node constructor
|
||||
func NewMinus(Variable node.Node, Expression node.Node) *Minus {
|
||||
return &Minus{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Minus) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Minus) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Minus) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Mod node
|
||||
type Mod struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Mod struct {
|
||||
// NewMod node constructor
|
||||
func NewMod(Variable node.Node, Expression node.Node) *Mod {
|
||||
return &Mod{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Mod) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Mod) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Mod) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Mul node
|
||||
type Mul struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Mul struct {
|
||||
// NewMul node constructor
|
||||
func NewMul(Variable node.Node, Expression node.Node) *Mul {
|
||||
return &Mul{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Mul) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Mul) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Mul) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Plus node
|
||||
type Plus struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Plus struct {
|
||||
// NewPlus node constructor
|
||||
func NewPlus(Variable node.Node, Expression node.Node) *Plus {
|
||||
return &Plus{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Plus) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Plus) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Plus) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Pow node
|
||||
type Pow struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type Pow struct {
|
||||
// NewPow node constructor
|
||||
func NewPow(Variable node.Node, Expression node.Node) *Pow {
|
||||
return &Pow{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Pow) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Pow) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Pow) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ShiftLeft node
|
||||
type ShiftLeft struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type ShiftLeft struct {
|
||||
// NewShiftLeft node constructor
|
||||
func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft {
|
||||
return &ShiftLeft{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *ShiftLeft) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ShiftLeft) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ShiftLeft) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package assign
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ShiftRight node
|
||||
type ShiftRight struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Expression node.Node
|
||||
@ -18,6 +18,7 @@ type ShiftRight struct {
|
||||
// NewShiftRight node constructor
|
||||
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
|
||||
return &ShiftRight{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Expression: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *ShiftRight) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ShiftRight) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ShiftRight) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -2,14 +2,13 @@ package assign_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/node/expr/assign"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
"github.com/z7zmey/php-parser/node/name"
|
||||
@ -18,18 +17,6 @@ import (
|
||||
"github.com/z7zmey/php-parser/php7"
|
||||
)
|
||||
|
||||
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
diff := pretty.Compare(expected, actual)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("diff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReference(t *testing.T) {
|
||||
src := `<? $a =& $b;`
|
||||
|
||||
@ -97,12 +84,12 @@ func TestReference(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestReferenceNew(t *testing.T) {
|
||||
@ -182,12 +169,12 @@ func TestReferenceNew(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestReferenceArgs(t *testing.T) {
|
||||
@ -304,12 +291,12 @@ func TestReferenceArgs(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestAssign(t *testing.T) {
|
||||
@ -379,12 +366,12 @@ func TestAssign(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBitwiseAnd(t *testing.T) {
|
||||
@ -454,12 +441,12 @@ func TestBitwiseAnd(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBitwiseOr(t *testing.T) {
|
||||
@ -529,12 +516,12 @@ func TestBitwiseOr(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBitwiseXor(t *testing.T) {
|
||||
@ -604,12 +591,12 @@ func TestBitwiseXor(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestConcat(t *testing.T) {
|
||||
@ -679,12 +666,12 @@ func TestConcat(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestDiv(t *testing.T) {
|
||||
@ -754,12 +741,12 @@ func TestDiv(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestMinus(t *testing.T) {
|
||||
@ -829,12 +816,12 @@ func TestMinus(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestMod(t *testing.T) {
|
||||
@ -904,12 +891,12 @@ func TestMod(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestMul(t *testing.T) {
|
||||
@ -979,12 +966,12 @@ func TestMul(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestPlus(t *testing.T) {
|
||||
@ -1054,12 +1041,12 @@ func TestPlus(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestPow(t *testing.T) {
|
||||
@ -1129,12 +1116,12 @@ func TestPow(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestShiftLeft(t *testing.T) {
|
||||
@ -1204,12 +1191,12 @@ func TestShiftLeft(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestShiftRight(t *testing.T) {
|
||||
@ -1279,10 +1266,10 @@ func TestShiftRight(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
81
node/expr/assign/t_freefloating_test.go
Normal file
81
node/expr/assign/t_freefloating_test.go
Normal file
@ -0,0 +1,81 @@
|
||||
package assign_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr/assign"
|
||||
)
|
||||
|
||||
var expected freefloating.Collection = freefloating.Collection{
|
||||
freefloating.Start: []freefloating.String{
|
||||
{
|
||||
StringType: freefloating.WhiteSpaceType,
|
||||
Value: " ",
|
||||
Position: nil,
|
||||
},
|
||||
{
|
||||
StringType: freefloating.CommentType,
|
||||
Value: "//comment\n",
|
||||
Position: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var nodes = []node.Node{
|
||||
&assign.Reference{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Assign{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.BitwiseAnd{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.BitwiseOr{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.BitwiseXor{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Concat{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Div{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Minus{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Mod{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Mul{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Plus{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.Pow{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.ShiftLeft{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.ShiftRight{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&assign.ShiftRight{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
}
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
for _, n := range nodes {
|
||||
actual := *n.GetFreeFloating()
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package assign_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/node/expr/assign"
|
||||
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
var nodes = []node.Node{
|
||||
&assign.Reference{},
|
||||
&assign.Assign{},
|
||||
&assign.BitwiseAnd{},
|
||||
&assign.BitwiseOr{},
|
||||
&assign.BitwiseXor{},
|
||||
&assign.Concat{},
|
||||
&assign.Div{},
|
||||
&assign.Minus{},
|
||||
&assign.Mod{},
|
||||
&assign.Mul{},
|
||||
&assign.Plus{},
|
||||
&assign.Pow{},
|
||||
&assign.ShiftLeft{},
|
||||
&assign.ShiftRight{},
|
||||
&assign.ShiftRight{},
|
||||
}
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
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.GetMeta().Push(*expected...)
|
||||
actual := n.GetMeta()
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package assign_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
)
|
||||
|
||||
@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
|
||||
for _, n := range nodes {
|
||||
n.SetPosition(expected)
|
||||
actual := n.GetPosition()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package assign_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/node/expr/assign"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
"github.com/z7zmey/php-parser/node/expr/assign"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
@ -24,7 +22,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Assign{
|
||||
@ -32,7 +30,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.BitwiseAnd{
|
||||
@ -40,7 +38,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.BitwiseOr{
|
||||
@ -48,7 +46,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.BitwiseXor{
|
||||
@ -56,7 +54,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Concat{
|
||||
@ -64,7 +62,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Div{
|
||||
@ -72,7 +70,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Minus{
|
||||
@ -80,7 +78,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Mod{
|
||||
@ -88,7 +86,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Mul{
|
||||
@ -96,7 +94,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Plus{
|
||||
@ -104,7 +102,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.Pow{
|
||||
@ -112,7 +110,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.ShiftLeft{
|
||||
@ -120,7 +118,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&assign.ShiftRight{
|
||||
@ -128,7 +126,7 @@ var nodesToTest = []struct {
|
||||
Expression: &expr.Variable{},
|
||||
},
|
||||
[]string{"Variable", "Expression"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
@ -150,31 +148,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
|
||||
|
||||
func TestVisitorDisableChildren(t *testing.T) {
|
||||
for _, tt := range nodesToTest {
|
||||
v := &visitorMock{false, nil}
|
||||
v := &visitorMock{false, []string{}}
|
||||
tt.node.Walk(v)
|
||||
|
||||
expected := []string{}
|
||||
actual := v.visitedKeys
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVisitor(t *testing.T) {
|
||||
for _, tt := range nodesToTest {
|
||||
v := &visitorMock{true, nil}
|
||||
v := &visitorMock{true, []string{}}
|
||||
tt.node.Walk(v)
|
||||
|
||||
expected := tt.expectedVisitedKeys
|
||||
actual := v.visitedKeys
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,9 +177,6 @@ func TestNameAttributes(t *testing.T) {
|
||||
expected := tt.expectedAttributes
|
||||
actual := tt.node.Attributes()
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BitwiseAnd node
|
||||
type BitwiseAnd struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type BitwiseAnd struct {
|
||||
// NewBitwiseAnd node constructor
|
||||
func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd {
|
||||
return &BitwiseAnd{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BitwiseAnd) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BitwiseAnd) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BitwiseAnd) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BitwiseOr node
|
||||
type BitwiseOr struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type BitwiseOr struct {
|
||||
// NewBitwiseOr node constructor
|
||||
func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr {
|
||||
return &BitwiseOr{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BitwiseOr) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BitwiseOr) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BitwiseOr) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BitwiseXor node
|
||||
type BitwiseXor struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type BitwiseXor struct {
|
||||
// NewBitwiseXor node constructor
|
||||
func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor {
|
||||
return &BitwiseXor{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BitwiseXor) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BitwiseXor) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BitwiseXor) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BooleanAnd node
|
||||
type BooleanAnd struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type BooleanAnd struct {
|
||||
// NewBooleanAnd node constructor
|
||||
func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd {
|
||||
return &BooleanAnd{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BooleanAnd) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BooleanAnd) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BooleanAnd) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BooleanOr node
|
||||
type BooleanOr struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type BooleanOr struct {
|
||||
// NewBooleanOr node constructor
|
||||
func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr {
|
||||
return &BooleanOr{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *BooleanOr) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BooleanOr) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BooleanOr) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Coalesce node
|
||||
type Coalesce struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Coalesce struct {
|
||||
// NewCoalesce node constructor
|
||||
func NewCoalesce(Variable node.Node, Expression node.Node) *Coalesce {
|
||||
return &Coalesce{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Coalesce) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Coalesce) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Coalesce) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Concat node
|
||||
type Concat struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Concat struct {
|
||||
// NewConcat node constructor
|
||||
func NewConcat(Variable node.Node, Expression node.Node) *Concat {
|
||||
return &Concat{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Concat) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Concat) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Concat) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Div node
|
||||
type Div struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Div struct {
|
||||
// NewDiv node constructor
|
||||
func NewDiv(Variable node.Node, Expression node.Node) *Div {
|
||||
return &Div{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Div) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Div) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Div) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Equal node
|
||||
type Equal struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Equal struct {
|
||||
// NewEqual node constructor
|
||||
func NewEqual(Variable node.Node, Expression node.Node) *Equal {
|
||||
return &Equal{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Equal) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Equal) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Equal) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Greater node
|
||||
type Greater struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Greater struct {
|
||||
// NewGreater node constructor
|
||||
func NewGreater(Variable node.Node, Expression node.Node) *Greater {
|
||||
return &Greater{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Greater) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Greater) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Greater) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// GreaterOrEqual node
|
||||
type GreaterOrEqual struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type GreaterOrEqual struct {
|
||||
// NewGreaterOrEqual node constructor
|
||||
func NewGreaterOrEqual(Variable node.Node, Expression node.Node) *GreaterOrEqual {
|
||||
return &GreaterOrEqual{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *GreaterOrEqual) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *GreaterOrEqual) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *GreaterOrEqual) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Identical node
|
||||
type Identical struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Identical struct {
|
||||
// NewIdentical node constructor
|
||||
func NewIdentical(Variable node.Node, Expression node.Node) *Identical {
|
||||
return &Identical{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Identical) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Identical) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Identical) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// LogicalAnd node
|
||||
type LogicalAnd struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type LogicalAnd struct {
|
||||
// NewLogicalAnd node constructor
|
||||
func NewLogicalAnd(Variable node.Node, Expression node.Node) *LogicalAnd {
|
||||
return &LogicalAnd{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *LogicalAnd) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *LogicalAnd) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *LogicalAnd) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// LogicalOr node
|
||||
type LogicalOr struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type LogicalOr struct {
|
||||
// NewLogicalOr node constructor
|
||||
func NewLogicalOr(Variable node.Node, Expression node.Node) *LogicalOr {
|
||||
return &LogicalOr{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *LogicalOr) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *LogicalOr) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *LogicalOr) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// LogicalXor node
|
||||
type LogicalXor struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type LogicalXor struct {
|
||||
// NewLogicalXor node constructor
|
||||
func NewLogicalXor(Variable node.Node, Expression node.Node) *LogicalXor {
|
||||
return &LogicalXor{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *LogicalXor) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *LogicalXor) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *LogicalXor) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Minus node
|
||||
type Minus struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Minus struct {
|
||||
// NewMinus node constructor
|
||||
func NewMinus(Variable node.Node, Expression node.Node) *Minus {
|
||||
return &Minus{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Minus) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Minus) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Minus) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Mod node
|
||||
type Mod struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Mod struct {
|
||||
// NewMod node constructor
|
||||
func NewMod(Variable node.Node, Expression node.Node) *Mod {
|
||||
return &Mod{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Mod) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Mod) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Mod) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Mul node
|
||||
type Mul struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Mul struct {
|
||||
// NewMul node constructor
|
||||
func NewMul(Variable node.Node, Expression node.Node) *Mul {
|
||||
return &Mul{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Mul) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Mul) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Mul) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// NotEqual node
|
||||
type NotEqual struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type NotEqual struct {
|
||||
// NewNotEqual node constructor
|
||||
func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual {
|
||||
return &NotEqual{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *NotEqual) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *NotEqual) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *NotEqual) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// NotIdentical node
|
||||
type NotIdentical struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type NotIdentical struct {
|
||||
// NewNotIdentical node constructor
|
||||
func NewNotIdentical(Variable node.Node, Expression node.Node) *NotIdentical {
|
||||
return &NotIdentical{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *NotIdentical) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *NotIdentical) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *NotIdentical) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Plus node
|
||||
type Plus struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Plus struct {
|
||||
// NewPlus node constructor
|
||||
func NewPlus(Variable node.Node, Expression node.Node) *Plus {
|
||||
return &Plus{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Plus) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Plus) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Plus) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Pow node
|
||||
type Pow struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Pow struct {
|
||||
// NewPow node constructor
|
||||
func NewPow(Variable node.Node, Expression node.Node) *Pow {
|
||||
return &Pow{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Pow) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Pow) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Pow) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ShiftLeft node
|
||||
type ShiftLeft struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type ShiftLeft struct {
|
||||
// NewShiftLeft node constructor
|
||||
func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft {
|
||||
return &ShiftLeft{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *ShiftLeft) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ShiftLeft) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ShiftLeft) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ShiftRight node
|
||||
type ShiftRight struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type ShiftRight struct {
|
||||
// NewShiftRight node constructor
|
||||
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
|
||||
return &ShiftRight{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *ShiftRight) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ShiftRight) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ShiftRight) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Smaller node
|
||||
type Smaller struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Smaller struct {
|
||||
// NewSmaller node constructor
|
||||
func NewSmaller(Variable node.Node, Expression node.Node) *Smaller {
|
||||
return &Smaller{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Smaller) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Smaller) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Smaller) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// SmallerOrEqual node
|
||||
type SmallerOrEqual struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type SmallerOrEqual struct {
|
||||
// NewSmallerOrEqual node constructor
|
||||
func NewSmallerOrEqual(Variable node.Node, Expression node.Node) *SmallerOrEqual {
|
||||
return &SmallerOrEqual{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *SmallerOrEqual) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *SmallerOrEqual) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *SmallerOrEqual) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Spaceship node
|
||||
type Spaceship struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Left node.Node
|
||||
Right node.Node
|
||||
@ -18,6 +18,7 @@ type Spaceship struct {
|
||||
// NewSpaceship node constructor
|
||||
func NewSpaceship(Variable node.Node, Expression node.Node) *Spaceship {
|
||||
return &Spaceship{
|
||||
FreeFloating: nil,
|
||||
Left: Variable,
|
||||
Right: Expression,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *Spaceship) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Spaceship) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Spaceship) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -2,10 +2,9 @@ package binary_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
@ -16,18 +15,6 @@ import (
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
)
|
||||
|
||||
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
diff := pretty.Compare(expected, actual)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("diff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBitwiseAnd(t *testing.T) {
|
||||
src := `<? $a & $b;`
|
||||
|
||||
@ -95,12 +82,12 @@ func TestBitwiseAnd(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBitwiseOr(t *testing.T) {
|
||||
@ -170,12 +157,12 @@ func TestBitwiseOr(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBitwiseXor(t *testing.T) {
|
||||
@ -245,12 +232,12 @@ func TestBitwiseXor(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBooleanAnd(t *testing.T) {
|
||||
@ -320,12 +307,12 @@ func TestBooleanAnd(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBooleanOr(t *testing.T) {
|
||||
@ -395,12 +382,12 @@ func TestBooleanOr(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCoalesce(t *testing.T) {
|
||||
@ -470,7 +457,7 @@ func TestCoalesce(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestConcat(t *testing.T) {
|
||||
@ -540,12 +527,12 @@ func TestConcat(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestDiv(t *testing.T) {
|
||||
@ -615,12 +602,12 @@ func TestDiv(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestEqual(t *testing.T) {
|
||||
@ -690,12 +677,12 @@ func TestEqual(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestGreaterOrEqual(t *testing.T) {
|
||||
@ -765,12 +752,12 @@ func TestGreaterOrEqual(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestGreater(t *testing.T) {
|
||||
@ -840,12 +827,12 @@ func TestGreater(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestIdentical(t *testing.T) {
|
||||
@ -915,12 +902,12 @@ func TestIdentical(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestLogicalAnd(t *testing.T) {
|
||||
@ -990,12 +977,12 @@ func TestLogicalAnd(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestLogicalOr(t *testing.T) {
|
||||
@ -1065,12 +1052,12 @@ func TestLogicalOr(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestLogicalXor(t *testing.T) {
|
||||
@ -1140,12 +1127,12 @@ func TestLogicalXor(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestMinus(t *testing.T) {
|
||||
@ -1215,12 +1202,12 @@ func TestMinus(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestMod(t *testing.T) {
|
||||
@ -1290,12 +1277,12 @@ func TestMod(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestMul(t *testing.T) {
|
||||
@ -1365,12 +1352,12 @@ func TestMul(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestNotEqual(t *testing.T) {
|
||||
@ -1440,12 +1427,12 @@ func TestNotEqual(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestNotIdentical(t *testing.T) {
|
||||
@ -1515,12 +1502,12 @@ func TestNotIdentical(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestPlus(t *testing.T) {
|
||||
@ -1590,12 +1577,12 @@ func TestPlus(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestPow(t *testing.T) {
|
||||
@ -1665,12 +1652,12 @@ func TestPow(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestShiftLeft(t *testing.T) {
|
||||
@ -1740,12 +1727,12 @@ func TestShiftLeft(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestShiftRight(t *testing.T) {
|
||||
@ -1815,12 +1802,12 @@ func TestShiftRight(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestSmallerOrEqual(t *testing.T) {
|
||||
@ -1890,12 +1877,12 @@ func TestSmallerOrEqual(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestSmaller(t *testing.T) {
|
||||
@ -1965,12 +1952,12 @@ func TestSmaller(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestSpaceship(t *testing.T) {
|
||||
@ -2040,5 +2027,5 @@ func TestSpaceship(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
117
node/expr/binary/t_freefloating_test.go
Normal file
117
node/expr/binary/t_freefloating_test.go
Normal file
@ -0,0 +1,117 @@
|
||||
package binary_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr/binary"
|
||||
)
|
||||
|
||||
var expected freefloating.Collection = freefloating.Collection{
|
||||
freefloating.Start: []freefloating.String{
|
||||
{
|
||||
StringType: freefloating.WhiteSpaceType,
|
||||
Value: " ",
|
||||
Position: nil,
|
||||
},
|
||||
{
|
||||
StringType: freefloating.CommentType,
|
||||
Value: "//comment\n",
|
||||
Position: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var nodes = []node.Node{
|
||||
&binary.BitwiseAnd{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.BitwiseOr{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.BitwiseXor{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.BooleanAnd{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.BooleanOr{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Coalesce{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Concat{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Div{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Equal{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.GreaterOrEqual{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Greater{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Identical{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.LogicalAnd{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.LogicalOr{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.LogicalXor{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Minus{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Mod{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Mul{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.NotEqual{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.NotIdentical{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Plus{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Pow{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.ShiftLeft{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.ShiftRight{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.SmallerOrEqual{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Smaller{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&binary.Spaceship{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
}
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
for _, n := range nodes {
|
||||
actual := *n.GetFreeFloating()
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package binary_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/node/expr/binary"
|
||||
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
var nodes = []node.Node{
|
||||
&binary.BitwiseAnd{},
|
||||
&binary.BitwiseOr{},
|
||||
&binary.BitwiseXor{},
|
||||
&binary.BooleanAnd{},
|
||||
&binary.BooleanOr{},
|
||||
&binary.Coalesce{},
|
||||
&binary.Concat{},
|
||||
&binary.Div{},
|
||||
&binary.Equal{},
|
||||
&binary.GreaterOrEqual{},
|
||||
&binary.Greater{},
|
||||
&binary.Identical{},
|
||||
&binary.LogicalAnd{},
|
||||
&binary.LogicalOr{},
|
||||
&binary.LogicalXor{},
|
||||
&binary.Minus{},
|
||||
&binary.Mod{},
|
||||
&binary.Mul{},
|
||||
&binary.NotEqual{},
|
||||
&binary.NotIdentical{},
|
||||
&binary.Plus{},
|
||||
&binary.Pow{},
|
||||
&binary.ShiftLeft{},
|
||||
&binary.ShiftRight{},
|
||||
&binary.SmallerOrEqual{},
|
||||
&binary.Smaller{},
|
||||
&binary.Spaceship{},
|
||||
}
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
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.GetMeta().Push(*expected...)
|
||||
actual := n.GetMeta()
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package binary_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
)
|
||||
|
||||
@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
|
||||
for _, n := range nodes {
|
||||
n.SetPosition(expected)
|
||||
actual := n.GetPosition()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package binary_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
"github.com/z7zmey/php-parser/node/expr/binary"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
var nodesToTest = []struct {
|
||||
@ -23,7 +21,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.BitwiseOr{
|
||||
@ -31,7 +29,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.BitwiseXor{
|
||||
@ -39,7 +37,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.BooleanAnd{
|
||||
@ -47,7 +45,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.BooleanOr{
|
||||
@ -55,7 +53,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Coalesce{
|
||||
@ -63,7 +61,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Concat{
|
||||
@ -71,7 +69,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Div{
|
||||
@ -79,7 +77,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Equal{
|
||||
@ -87,7 +85,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.GreaterOrEqual{
|
||||
@ -95,7 +93,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Greater{
|
||||
@ -103,7 +101,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Identical{
|
||||
@ -111,7 +109,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.LogicalAnd{
|
||||
@ -119,7 +117,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.LogicalOr{
|
||||
@ -127,7 +125,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.LogicalXor{
|
||||
@ -135,7 +133,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Minus{
|
||||
@ -143,7 +141,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Mod{
|
||||
@ -151,7 +149,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Mul{
|
||||
@ -159,7 +157,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.NotEqual{
|
||||
@ -167,7 +165,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.NotIdentical{
|
||||
@ -175,7 +173,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Plus{
|
||||
@ -183,7 +181,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Pow{
|
||||
@ -191,7 +189,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.ShiftLeft{
|
||||
@ -199,7 +197,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.ShiftRight{
|
||||
@ -207,7 +205,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.SmallerOrEqual{
|
||||
@ -215,7 +213,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Smaller{
|
||||
@ -223,7 +221,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&binary.Spaceship{
|
||||
@ -231,7 +229,7 @@ var nodesToTest = []struct {
|
||||
Right: &expr.Variable{},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
@ -253,31 +251,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
|
||||
|
||||
func TestVisitorDisableChildren(t *testing.T) {
|
||||
for _, tt := range nodesToTest {
|
||||
v := &visitorMock{false, nil}
|
||||
v := &visitorMock{false, []string{}}
|
||||
tt.node.Walk(v)
|
||||
|
||||
expected := []string{}
|
||||
actual := v.visitedKeys
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVisitor(t *testing.T) {
|
||||
for _, tt := range nodesToTest {
|
||||
v := &visitorMock{true, nil}
|
||||
v := &visitorMock{true, []string{}}
|
||||
tt.node.Walk(v)
|
||||
|
||||
expected := tt.expectedVisitedKeys
|
||||
actual := v.visitedKeys
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,9 +280,6 @@ func TestNameAttributes(t *testing.T) {
|
||||
expected := tt.expectedAttributes
|
||||
actual := tt.node.Attributes()
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Array node
|
||||
type Array struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Array struct {
|
||||
// NewArray node constructor
|
||||
func NewArray(Expr node.Node) *Array {
|
||||
return &Array{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Array) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Array) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Array) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Bool node
|
||||
type Bool struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Bool struct {
|
||||
// NewBool node constructor
|
||||
func NewBool(Expr node.Node) *Bool {
|
||||
return &Bool{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Bool) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Bool) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Bool) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Double node
|
||||
type Double struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Double struct {
|
||||
// NewDouble node constructor
|
||||
func NewDouble(Expr node.Node) *Double {
|
||||
return &Double{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Double) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Double) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Double) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Int node
|
||||
type Int struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Int struct {
|
||||
// NewInt node constructor
|
||||
func NewInt(Expr node.Node) *Int {
|
||||
return &Int{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Int) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Int) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Int) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Object node
|
||||
type Object struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Object struct {
|
||||
// NewObject node constructor
|
||||
func NewObject(Expr node.Node) *Object {
|
||||
return &Object{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Object) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Object) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Object) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// String node
|
||||
type String struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type String struct {
|
||||
// NewString node constructor
|
||||
func NewString(Expr node.Node) *String {
|
||||
return &String{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *String) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *String) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *String) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Unset node
|
||||
type Unset struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Unset struct {
|
||||
// NewUnset node constructor
|
||||
func NewUnset(Expr node.Node) *Unset {
|
||||
return &Unset{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Unset) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Unset) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Unset) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -2,10 +2,9 @@ package cast_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
@ -16,18 +15,6 @@ import (
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
)
|
||||
|
||||
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
diff := pretty.Compare(expected, actual)
|
||||
|
||||
if diff != "" {
|
||||
t.Errorf("diff: (-expected +actual)\n%s", diff)
|
||||
} else {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestArray(t *testing.T) {
|
||||
src := `<? (array)$a;`
|
||||
|
||||
@ -78,12 +65,12 @@ func TestArray(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBool(t *testing.T) {
|
||||
@ -136,12 +123,12 @@ func TestBool(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBoolShort(t *testing.T) {
|
||||
@ -194,12 +181,12 @@ func TestBoolShort(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestDouble(t *testing.T) {
|
||||
@ -252,12 +239,12 @@ func TestDouble(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastFloat(t *testing.T) {
|
||||
@ -310,12 +297,12 @@ func TestCastFloat(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestInt(t *testing.T) {
|
||||
@ -368,12 +355,12 @@ func TestInt(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestIntShort(t *testing.T) {
|
||||
@ -426,12 +413,12 @@ func TestIntShort(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestObject(t *testing.T) {
|
||||
@ -484,12 +471,12 @@ func TestObject(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
@ -542,12 +529,12 @@ func TestString(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestBinaryString(t *testing.T) {
|
||||
@ -600,12 +587,12 @@ func TestBinaryString(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestUnset(t *testing.T) {
|
||||
@ -658,10 +645,10 @@ func TestUnset(t *testing.T) {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
|
57
node/expr/cast/t_freefloating_test.go
Normal file
57
node/expr/cast/t_freefloating_test.go
Normal file
@ -0,0 +1,57 @@
|
||||
package cast_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr/cast"
|
||||
)
|
||||
|
||||
var expected freefloating.Collection = freefloating.Collection{
|
||||
freefloating.Start: []freefloating.String{
|
||||
{
|
||||
StringType: freefloating.WhiteSpaceType,
|
||||
Value: " ",
|
||||
Position: nil,
|
||||
},
|
||||
{
|
||||
StringType: freefloating.CommentType,
|
||||
Value: "//comment\n",
|
||||
Position: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var nodes = []node.Node{
|
||||
&cast.Array{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&cast.Bool{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&cast.Double{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&cast.Int{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&cast.Object{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&cast.String{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
&cast.Unset{
|
||||
FreeFloating: expected,
|
||||
},
|
||||
}
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
for _, n := range nodes {
|
||||
actual := *n.GetFreeFloating()
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package cast_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/node/expr/cast"
|
||||
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
var nodes = []node.Node{
|
||||
&cast.Array{},
|
||||
&cast.Bool{},
|
||||
&cast.Double{},
|
||||
&cast.Int{},
|
||||
&cast.Object{},
|
||||
&cast.String{},
|
||||
&cast.Unset{},
|
||||
}
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
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.GetMeta().Push(*expected...)
|
||||
actual := n.GetMeta()
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package cast_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
)
|
||||
|
||||
@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
|
||||
for _, n := range nodes {
|
||||
n.SetPosition(expected)
|
||||
actual := n.GetPosition()
|
||||
assertEqual(t, expected, actual)
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package cast_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
@ -22,49 +21,49 @@ var nodesToTest = []struct {
|
||||
Expr: &expr.Variable{},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&cast.Bool{
|
||||
Expr: &expr.Variable{},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&cast.Double{
|
||||
Expr: &expr.Variable{},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&cast.Int{
|
||||
Expr: &expr.Variable{},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&cast.Object{
|
||||
Expr: &expr.Variable{},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&cast.String{
|
||||
Expr: &expr.Variable{},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
&cast.Unset{
|
||||
Expr: &expr.Variable{},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
@ -86,31 +85,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
|
||||
|
||||
func TestVisitorDisableChildren(t *testing.T) {
|
||||
for _, tt := range nodesToTest {
|
||||
v := &visitorMock{false, nil}
|
||||
v := &visitorMock{false, []string{}}
|
||||
tt.node.Walk(v)
|
||||
|
||||
expected := []string{}
|
||||
actual := v.visitedKeys
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVisitor(t *testing.T) {
|
||||
for _, tt := range nodesToTest {
|
||||
v := &visitorMock{true, nil}
|
||||
v := &visitorMock{true, []string{}}
|
||||
tt.node.Walk(v)
|
||||
|
||||
expected := tt.expectedVisitedKeys
|
||||
actual := v.visitedKeys
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,9 +114,6 @@ func TestNameAttributes(t *testing.T) {
|
||||
expected := tt.expectedAttributes
|
||||
actual := tt.node.Attributes()
|
||||
|
||||
diff := pretty.Compare(expected, actual)
|
||||
if diff != "" {
|
||||
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
|
||||
}
|
||||
assert.DeepEqual(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Array node
|
||||
type Array struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Items []node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Array struct {
|
||||
// NewArray node constructor
|
||||
func NewArray(Items []node.Node) *Array {
|
||||
return &Array{
|
||||
FreeFloating: nil,
|
||||
Items: Items,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Array) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Array) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Array) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ArrayDimFetch node
|
||||
type ArrayDimFetch struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Dim node.Node
|
||||
@ -18,6 +18,7 @@ type ArrayDimFetch struct {
|
||||
// NewArrayDimFetch node constructor
|
||||
func NewArrayDimFetch(Variable node.Node, Dim node.Node) *ArrayDimFetch {
|
||||
return &ArrayDimFetch{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Dim: Dim,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *ArrayDimFetch) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ArrayDimFetch) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ArrayDimFetch) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ArrayItem node
|
||||
type ArrayItem struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Key node.Node
|
||||
Val node.Node
|
||||
@ -18,6 +18,7 @@ type ArrayItem struct {
|
||||
// NewArrayItem node constructor
|
||||
func NewArrayItem(Key node.Node, Val node.Node) *ArrayItem {
|
||||
return &ArrayItem{
|
||||
FreeFloating: nil,
|
||||
Key: Key,
|
||||
Val: Val,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *ArrayItem) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ArrayItem) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ArrayItem) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BitwiseNot node
|
||||
type BitwiseNot struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type BitwiseNot struct {
|
||||
// NewBitwiseNot node constructor
|
||||
func NewBitwiseNot(Expression node.Node) *BitwiseNot {
|
||||
return &BitwiseNot{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *BitwiseNot) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BitwiseNot) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BitwiseNot) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// BooleanNot node
|
||||
type BooleanNot struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type BooleanNot struct {
|
||||
// NewBooleanNot node constructor
|
||||
func NewBooleanNot(Expression node.Node) *BooleanNot {
|
||||
return &BooleanNot{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *BooleanNot) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *BooleanNot) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *BooleanNot) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ClassConstFetch node
|
||||
type ClassConstFetch struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Class node.Node
|
||||
ConstantName node.Node
|
||||
@ -18,6 +18,7 @@ type ClassConstFetch struct {
|
||||
// NewClassConstFetch node constructor
|
||||
func NewClassConstFetch(Class node.Node, ConstantName node.Node) *ClassConstFetch {
|
||||
return &ClassConstFetch{
|
||||
FreeFloating: nil,
|
||||
Class: Class,
|
||||
ConstantName: ConstantName,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *ClassConstFetch) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ClassConstFetch) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ClassConstFetch) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Clone node
|
||||
type Clone struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Clone struct {
|
||||
// NewClone node constructor
|
||||
func NewClone(Expression node.Node) *Clone {
|
||||
return &Clone{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Clone) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Clone) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Clone) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Closure node
|
||||
type Closure struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
ReturnsRef bool
|
||||
Static bool
|
||||
@ -23,6 +23,7 @@ type Closure struct {
|
||||
// NewClosure node constructor
|
||||
func NewClosure(Params []node.Node, ClosureUse *ClosureUse, ReturnType node.Node, Stmts []node.Node, Static bool, ReturnsRef bool, PhpDocComment string) *Closure {
|
||||
return &Closure{
|
||||
FreeFloating: nil,
|
||||
ReturnsRef: ReturnsRef,
|
||||
Static: Static,
|
||||
PhpDocComment: PhpDocComment,
|
||||
@ -43,8 +44,8 @@ func (n *Closure) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Closure) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Closure) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ClosureUse node
|
||||
type ClosureUse struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Uses []node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type ClosureUse struct {
|
||||
// NewClosureUse node constructor
|
||||
func NewClosureUse(Uses []node.Node) *ClosureUse {
|
||||
return &ClosureUse{
|
||||
FreeFloating: nil,
|
||||
Uses: Uses,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *ClosureUse) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ClosureUse) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ClosureUse) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ConstFetch node
|
||||
type ConstFetch struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Constant node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type ConstFetch struct {
|
||||
// NewConstFetch node constructor
|
||||
func NewConstFetch(Constant node.Node) *ConstFetch {
|
||||
return &ConstFetch{
|
||||
FreeFloating: nil,
|
||||
Constant: Constant,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *ConstFetch) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ConstFetch) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ConstFetch) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Empty node
|
||||
type Empty struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Empty struct {
|
||||
// NewEmpty node constructor
|
||||
func NewEmpty(Expression node.Node) *Empty {
|
||||
return &Empty{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Empty) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Empty) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Empty) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// ErrorSuppress node
|
||||
type ErrorSuppress struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type ErrorSuppress struct {
|
||||
// NewErrorSuppress node constructor
|
||||
func NewErrorSuppress(Expression node.Node) *ErrorSuppress {
|
||||
return &ErrorSuppress{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *ErrorSuppress) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ErrorSuppress) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *ErrorSuppress) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Eval node
|
||||
type Eval struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Eval struct {
|
||||
// NewEval node constructor
|
||||
func NewEval(Expression node.Node) *Eval {
|
||||
return &Eval{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Eval) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Eval) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Eval) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Exit node
|
||||
type Exit struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Die bool
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
@ -18,6 +18,7 @@ type Exit struct {
|
||||
// NewExit node constructor
|
||||
func NewExit(Expr node.Node) *Exit {
|
||||
return &Exit{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
}
|
||||
}
|
||||
@ -32,8 +33,8 @@ func (n *Exit) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Exit) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Exit) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// FunctionCall node
|
||||
type FunctionCall struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Function node.Node
|
||||
ArgumentList *node.ArgumentList
|
||||
@ -18,6 +18,7 @@ type FunctionCall struct {
|
||||
// NewFunctionCall node constructor
|
||||
func NewFunctionCall(Function node.Node, ArgumentList *node.ArgumentList) *FunctionCall {
|
||||
return &FunctionCall{
|
||||
FreeFloating: nil,
|
||||
Function: Function,
|
||||
ArgumentList: ArgumentList,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *FunctionCall) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *FunctionCall) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *FunctionCall) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Include node
|
||||
type Include struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Include struct {
|
||||
// NewInclude node constructor
|
||||
func NewInclude(Expression node.Node) *Include {
|
||||
return &Include{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Include) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Include) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Include) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// IncludeOnce node
|
||||
type IncludeOnce struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type IncludeOnce struct {
|
||||
// NewIncludeOnce node constructor
|
||||
func NewIncludeOnce(Expression node.Node) *IncludeOnce {
|
||||
return &IncludeOnce{
|
||||
FreeFloating: nil,
|
||||
Expr: Expression,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *IncludeOnce) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *IncludeOnce) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *IncludeOnce) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// InstanceOf node
|
||||
type InstanceOf struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Expr node.Node
|
||||
Class node.Node
|
||||
@ -18,6 +18,7 @@ type InstanceOf struct {
|
||||
// NewInstanceOf node constructor
|
||||
func NewInstanceOf(Expr node.Node, Class node.Node) *InstanceOf {
|
||||
return &InstanceOf{
|
||||
FreeFloating: nil,
|
||||
Expr: Expr,
|
||||
Class: Class,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *InstanceOf) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *InstanceOf) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *InstanceOf) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Isset node
|
||||
type Isset struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variables []node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type Isset struct {
|
||||
// NewIsset node constructor
|
||||
func NewIsset(Variables []node.Node) *Isset {
|
||||
return &Isset{
|
||||
FreeFloating: nil,
|
||||
Variables: Variables,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *Isset) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *Isset) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *Isset) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// List node
|
||||
type List struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Items []node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type List struct {
|
||||
// NewList node constructor
|
||||
func NewList(Items []node.Node) *List {
|
||||
return &List{
|
||||
FreeFloating: nil,
|
||||
Items: Items,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *List) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *List) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *List) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// MethodCall node
|
||||
type MethodCall struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
Method node.Node
|
||||
@ -19,6 +19,7 @@ type MethodCall struct {
|
||||
// NewMethodCall node constructor
|
||||
func NewMethodCall(Variable node.Node, Method node.Node, ArgumentList *node.ArgumentList) *MethodCall {
|
||||
return &MethodCall{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
Method: Method,
|
||||
ArgumentList: ArgumentList,
|
||||
@ -35,8 +36,8 @@ func (n *MethodCall) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *MethodCall) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *MethodCall) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// New node
|
||||
type New struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Class node.Node
|
||||
ArgumentList *node.ArgumentList
|
||||
@ -18,6 +18,7 @@ type New struct {
|
||||
// NewNew node constructor
|
||||
func NewNew(Class node.Node, ArgumentList *node.ArgumentList) *New {
|
||||
return &New{
|
||||
FreeFloating: nil,
|
||||
Class: Class,
|
||||
ArgumentList: ArgumentList,
|
||||
}
|
||||
@ -33,8 +34,8 @@ func (n *New) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *New) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *New) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// PostDec node
|
||||
type PostDec struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type PostDec struct {
|
||||
// NewPostDec node constructor
|
||||
func NewPostDec(Variable node.Node) *PostDec {
|
||||
return &PostDec{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *PostDec) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *PostDec) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *PostDec) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// PostInc node
|
||||
type PostInc struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type PostInc struct {
|
||||
// NewPostInc node constructor
|
||||
func NewPostInc(Variable node.Node) *PostInc {
|
||||
return &PostInc{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *PostInc) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *PostInc) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *PostInc) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
@ -1,7 +1,7 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
"github.com/z7zmey/php-parser/freefloating"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
// PreDec node
|
||||
type PreDec struct {
|
||||
Meta meta.Collection
|
||||
FreeFloating freefloating.Collection
|
||||
Position *position.Position
|
||||
Variable node.Node
|
||||
}
|
||||
@ -17,6 +17,7 @@ type PreDec struct {
|
||||
// NewPreDec node constructor
|
||||
func NewPreDec(Variable node.Node) *PreDec {
|
||||
return &PreDec{
|
||||
FreeFloating: nil,
|
||||
Variable: Variable,
|
||||
}
|
||||
}
|
||||
@ -31,8 +32,8 @@ func (n *PreDec) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *PreDec) GetMeta() *meta.Collection {
|
||||
return &n.Meta
|
||||
func (n *PreDec) GetFreeFloating() *freefloating.Collection {
|
||||
return &n.FreeFloating
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user