diff --git a/.travis.yml b/.travis.yml index 58f9465..25bc627 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ services: - docker before_script: - - go get -v gopkg.in/bblfsh/sdk.v1/... + - go get -v gopkg.in/bblfsh/sdk.v2/... - bblfsh-sdk prepare-build . - go get -v -t ./driver/... diff --git a/Dockerfile.build.tpl b/Dockerfile.build.tpl index d8afd75..4cebd1d 100644 --- a/Dockerfile.build.tpl +++ b/Dockerfile.build.tpl @@ -6,6 +6,6 @@ RUN mkdir -p /opt/driver/src && \ RUN apk add --no-cache make git ca-certificates libc-dev gcc \ ruby=${RUNTIME_NATIVE_VERSION} ruby-dev=${RUNTIME_NATIVE_VERSION} -RUN gem install -V --no-document rake bundler io-console parser +RUN gem install -V --no-document rake bundler io-console parser json WORKDIR /opt/driver/src diff --git a/Makefile b/Makefile index 24ea5b3..193055b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ RUBY_DEP_PACK_CMD=bundle RUBY_GEM_CMD=gem test-native-internal: - if [ -f native/.bundle/config ] ; then rm native/.bundle/config ; fi + rm native/.bundle/config || true cd native; \ export BUNDLE_IGNORE_CONFIG=1 && $(RUBY_DEP_PACK_CMD) install --path vendor/bundle --verbose; \ export GEM_PATH=./vendor/bundle/ruby/2.4.0 && $(RUBY_MAKE_CMD) test --trace; diff --git a/README.md b/README.md index f070812..40534c5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Development Environment Requirements: - `docker` -- [`bblfsh-sdk`](https://github.com/bblfsh/sdk) _(go get -u gopkg.in/bblfsh/sdk.v1/...)_ +- [`bblfsh-sdk`](https://github.com/bblfsh/sdk) _(go get -u gopkg.in/bblfsh/sdk.v2/...)_ - UAST converter dependencies _(go get -t -v ./...)_ To initialize the build system execute: `bblfsh-sdk prepare-build`, at the root of the project. This will install the SDK at `.sdk` for this driver. diff --git a/driver/fixtures/fixtures_test.go b/driver/fixtures/fixtures_test.go new file mode 100644 index 0000000..9f00f78 --- /dev/null +++ b/driver/fixtures/fixtures_test.go @@ -0,0 +1,34 @@ +package fixtures + +import ( + "path/filepath" + "testing" + + "github.com/bblfsh/ruby-driver/driver/normalizer" + "gopkg.in/bblfsh/sdk.v2/sdk/driver" + "gopkg.in/bblfsh/sdk.v2/sdk/driver/fixtures" +) + +const projectRoot = "../../" + +var Suite = &fixtures.Suite{ + Lang: "ruby", + Ext: ".rb", + Path: filepath.Join(projectRoot, fixtures.Dir), + NewDriver: func() driver.BaseDriver { + return driver.NewExecDriverAt(filepath.Join(projectRoot, "native/exe/native")) + }, + Transforms: driver.Transforms{ + Native: normalizer.Native, + Code: normalizer.Code, + }, + BenchName: "class_complete", +} + +func TestRubyDriver(t *testing.T) { + Suite.RunTests(t) +} + +func BenchmarkRubyDriver(b *testing.B) { + Suite.RunBenchmarks(b) +} diff --git a/driver/impl/impl.go b/driver/impl/impl.go new file mode 100644 index 0000000..552b5c8 --- /dev/null +++ b/driver/impl/impl.go @@ -0,0 +1,8 @@ +package impl + +import "gopkg.in/bblfsh/sdk.v2/sdk/driver" + +func init() { + // Can be overridden to link a native driver into a Go driver server. + driver.DefaultDriver = driver.NewExecDriver() +} diff --git a/driver/main.go b/driver/main.go index 8c4ee49..208aa4d 100644 --- a/driver/main.go +++ b/driver/main.go @@ -1,11 +1,15 @@ package main import ( + _ "github.com/bblfsh/ruby-driver/driver/impl" "github.com/bblfsh/ruby-driver/driver/normalizer" - "gopkg.in/bblfsh/sdk.v1/sdk/driver" + "gopkg.in/bblfsh/sdk.v2/sdk/driver" ) func main() { - driver.Run(normalizer.ToNode, normalizer.Transformers) + driver.Run(driver.Transforms{ + Native: normalizer.Native, + Code: normalizer.Code, + }) } diff --git a/driver/normalizer/annotation.go b/driver/normalizer/annotation.go index 61b0bfe..a273a21 100644 --- a/driver/normalizer/annotation.go +++ b/driver/normalizer/annotation.go @@ -1,262 +1,333 @@ package normalizer import ( - "github.com/bblfsh/ruby-driver/driver/normalizer/rubyast" - - "gopkg.in/bblfsh/sdk.v1/uast" - . "gopkg.in/bblfsh/sdk.v1/uast/ann" - "gopkg.in/bblfsh/sdk.v1/uast/transformer" - "gopkg.in/bblfsh/sdk.v1/uast/transformer/annotatter" - "gopkg.in/bblfsh/sdk.v1/uast/transformer/positioner" + "gopkg.in/bblfsh/sdk.v2/uast" + "gopkg.in/bblfsh/sdk.v2/uast/role" + . "gopkg.in/bblfsh/sdk.v2/uast/transformer" + "gopkg.in/bblfsh/sdk.v2/uast/transformer/positioner" ) -// Transformers is the of list `transformer.Transfomer` to apply to a UAST, to -// learn more about the Transformers and the available ones take a look to: -// https://godoc.org/gopkg.in/bblfsh/sdk.v1/uast/transformers -var Transformers = []transformer.Tranformer{ - annotatter.NewAnnotatter(AnnotationRules), +var Native = Transformers([][]Transformer{ + {Mappings(Annotations...)}, + {RolesDedup()}, +}...) + +var Code = []CodeTransformer{ positioner.NewFillOffsetFromLineCol(), } -var isSomeOperator = Or(HasToken("+"), HasToken("-"), HasToken("*"), HasToken("/"), - HasToken("%"), HasToken("**"), HasToken("=="), HasToken("!="), HasToken("!"), - HasToken("<=>"), HasToken("==="), HasToken("eql?"), HasToken("equal?"), - HasToken("<="), HasToken(">="), rubyast.And, rubyast.Or, -) +// FIXME: move to the SDK and remove from here and the python driver +func annotateTypeToken(typ, token string, roles ...role.Role) Mapping { + return AnnotateType(typ, + FieldRoles{ + uast.KeyToken: {Add: true, Op: String(token)}, + }, roles...) +} + +func annotateTypeTokenField(typ, tokenfield string, roles ...role.Role) Mapping { + return AnnotateType(typ, FieldRoles{ + tokenfield: {Rename: uast.KeyToken}, + }, roles...) +} + +// FIXME: move to the SDK and remove from here and the python driver +func mapInternalProperty(key string, roles ...role.Role) Mapping { + return Map(key, + Part("other", Obj{ + key: ObjectRoles(key), + }), + Part("other", Obj{ + key: ObjectRoles(key, roles...), + }), + ) +} // Nodes doc: // https://github.com/whitequark/parser/blob/master/doc/AST_FORMAT.md -// AnnotationRules describes how a UAST should be annotated with `uast.Role`. -// -// https://godoc.org/gopkg.in/bblfsh/sdk.v1/uast/ann -var AnnotationRules = On(Any).Roles(uast.Module, uast.File).Descendants( - On(Or(rubyast.Begin, rubyast.Block)).Roles(uast.Block).Children( - On(rubyast.Body).Roles(uast.Body), - ), - // *Asgn with two children = binary and value have the "Right" role but with a single children = multiple assignment target :-/ - On(rubyast.LVAsgn).Roles(uast.Expression, uast.Assignment, uast.Binary, - uast.Identifier, uast.Left).Children( - On(HasInternalRole("value")).Roles(uast.Right), - ), - // is also member - On(rubyast.IVAsgn).Roles(uast.Expression, uast.Assignment, uast.Binary, - uast.Identifier, uast.Left, uast.Incomplete).Children( - On(HasInternalRole("value")).Roles(uast.Right), - ), - On(rubyast.GVAsgn).Roles(uast.Expression, uast.Assignment, uast.Binary, - uast.Identifier, uast.Left, uast.Visibility, uast.World).Children( - On(HasInternalRole("value")).Roles(uast.Right), - ), - // constant - On(rubyast.CAsgn).Roles(uast.Expression, uast.Assignment, uast.Binary, - uast.Identifier, uast.Left).Children( - On(HasInternalRole("value")).Roles(uast.Right), - ), - // class - On(rubyast.CVAsgn).Roles(uast.Expression, uast.Assignment, uast.Binary, - uast.Identifier, uast.Left).Children( - On(HasInternalRole("value")).Roles(uast.Binary, uast.Right), - ), - // instance (member) - On(rubyast.IVAsgn).Roles(uast.Expression, uast.Assignment, uast.Binary, - uast.Identifier, uast.Left).Children(On(HasInternalRole("value")).Roles(uast.Binary, uast.Right)), - // Multiple assignment; second element (whatever it is) must have the "Right" role - On(rubyast.MAsgn).Roles(uast.Expression, uast.Assignment, uast.Incomplete).Children( - On(HasInternalRole("values")).Roles(uast.Binary, uast.Right), - ), - On(rubyast.MultipleLeftSide).Roles(uast.Left, uast.Incomplete), +var operatorRoles = StringToRolesMap(map[string][]role.Role{ + "+": {role.Arithmetic, role.Add}, + "-": {role.Arithmetic, role.Substract}, + "*": {role.Arithmetic, role.Multiply}, + "/": {role.Arithmetic, role.Divide}, + "%": {role.Arithmetic, role.Modulo}, + // pow + "**": {role.Arithmetic, role.Incomplete}, + "&": {role.Bitwise, role.And}, + "|": {role.Bitwise, role.Or}, + "^": {role.Bitwise, role.Xor}, + // Complement + "~": {role.Bitwise, role.Incomplete}, + "<<": {role.Bitwise, role.LeftShift}, + ">>": {role.Bitwise, role.RightShift}, + "==": {role.Equal, role.Relational}, + "<=": {role.LessThanOrEqual, role.Relational}, + ">=": {role.GreaterThanOrEqual, role.Relational}, + "!=": {role.Equal, role.Not, role.Relational}, + "!": {role.Not, role.Relational}, + // Incomplete: check type (1 !eql? 1.0) but not being the same object like equal? + "eql?": {role.Identical, role.Relational}, + "equal?": {role.Identical, role.Relational}, + // rocket ship operator + "===": {role.Identical, role.Relational}, + "<==>": {role.Identical, role.Incomplete}, +}) + +var Annotations = []Mapping{ + AnnotateType("file", nil, role.File), + AnnotateType("begin", nil, role.Block), + AnnotateType("body", nil, role.Body), + mapInternalProperty("body", role.Body), + mapInternalProperty("left", role.Left), + mapInternalProperty("right", role.Right), + mapInternalProperty("condition", role.Expression, role.Condition), + mapInternalProperty("target", role.Binary, role.Left), + mapInternalProperty("value", role.Binary, role.Right), + mapInternalProperty("_1", role.Tuple, role.Value), + mapInternalProperty("_2", role.Tuple, role.Value), // Types - On(rubyast.Module).Roles(uast.Statement, uast.Module, uast.Identifier), - On(rubyast.Int).Roles(uast.Expression, uast.Literal, uast.Number, uast.Primitive), - On(rubyast.Str).Roles(uast.Expression, uast.Literal, uast.String, uast.Primitive), - On(rubyast.Pair).Roles(uast.Expression, uast.Literal, uast.Tuple, uast.Primitive), - On(rubyast.Array).Roles(uast.Expression, uast.Literal, uast.List, uast.Primitive), - On(rubyast.Hash).Roles(uast.Expression, uast.Literal, uast.Map, uast.Primitive), - On(rubyast.KwSplat).Roles(uast.Expression, uast.Incomplete), - - // splat (*a) - On(rubyast.Splat).Roles(uast.Expression, uast.Identifier, uast.Incomplete), - - // local var ::var - On(rubyast.LVar).Roles(uast.Expression, uast.Identifier), - // instance var @var - On(rubyast.IVar).Roles(uast.Expression, uast.Identifier, uast.Visibility, uast.Instance), - // global var $var - On(rubyast.GVar).Roles(uast.Expression, uast.Identifier, uast.Visibility, uast.World), - // class var @@var - On(rubyast.CVar).Roles(uast.Expression, uast.Identifier, uast.Visibility, uast.Type), - - // Augmented assignment (op-asgn) - On(rubyast.OpAsgn).Roles(uast.Expression, uast.Operator, uast.Binary, uast.Assignment).Self( - On(HasProperty("operator", "+")).Roles(uast.Arithmetic, uast.Add), - On(HasProperty("operator", "-")).Roles(uast.Arithmetic, uast.Substract), - On(HasProperty("operator", "*")).Roles(uast.Arithmetic, uast.Multiply), - On(HasProperty("operator", "/")).Roles(uast.Arithmetic, uast.Divide), - On(HasProperty("operator", "%")).Roles(uast.Arithmetic, uast.Modulo), - // Pow - On(HasProperty("operator", "**")).Roles(uast.Arithmetic, uast.Incomplete), - On(HasProperty("operator", "&")).Roles(uast.Bitwise, uast.And), - On(HasProperty("operator", "|")).Roles(uast.Bitwise, uast.Or), - On(HasProperty("operator", "^")).Roles(uast.Bitwise, uast.Xor), - // Complement - On(HasProperty("operator", "~")).Roles(uast.Bitwise, uast.Incomplete), - On(HasProperty("operator", "<<")).Roles(uast.Bitwise, uast.LeftShift), - On(HasProperty("operator", ">>")).Roles(uast.Bitwise, uast.RightShift), - ).Children( - On(HasInternalRole("target")).Roles(uast.Binary, uast.Left), - On(HasInternalRole("value")).Roles(uast.Binary, uast.Right), - ), + AnnotateType("module", nil, role.Statement, role.Module), + AnnotateType("comment", nil, role.Noop, role.Comment), + AnnotateType("module", nil, role.Statement, role.Module, role.Identifier), + AnnotateType("block", nil, role.Block), + AnnotateType("int", nil, role.Expression, role.Literal, role.Number, role.Primitive), + AnnotateType("NilNode", nil, role.Null), + AnnotateType("return", nil, role.Statement, role.Return), + AnnotateType("float", nil, role.Expression, role.Literal, role.Number, role.Primitive), + AnnotateType("complex", nil, role.Expression, role.Literal, role.Number, role.Primitive, role.Incomplete), + AnnotateType("rational", nil, role.Expression, role.Literal, role.Number, role.Primitive, role.Incomplete), + AnnotateType("str", nil, role.Expression, role.Literal, role.String, role.Primitive), + AnnotateType("pair", nil, role.Expression, role.Literal, role.Tuple, role.Primitive), + AnnotateType("array", nil, role.Expression, role.Literal, role.List, role.Primitive), + AnnotateType("hash", nil, role.Expression, role.Literal, role.Map, role.Primitive), + AnnotateType("class", nil, role.Statement, role.Type, role.Declaration, role.Identifier), + + // splats (*a) + AnnotateType("kwsplat", nil, role.Expression, role.Incomplete), + AnnotateType("splat", nil, role.Expression, role.Identifier, role.Incomplete), + + // Vars + // local + AnnotateType("lvar", nil, role.Expression, role.Identifier), + // instance + AnnotateType("ivar", nil, role.Expression, role.Identifier, role.Visibility, role.Instance), + // global + AnnotateType("gvar", nil, role.Expression, role.Identifier, role.Visibility, role.World), + // class + AnnotateType("cvar", nil, role.Expression, role.Identifier, role.Visibility, role.Type), - // Or Assign (a ||= b), And Assign (a &&= b) - On(rubyast.AndAsgn).Roles(uast.Expression, uast.Operator, uast.And, uast.Bitwise).Children( - On(HasInternalRole("target")).Roles(uast.Binary, uast.Left), - On(HasInternalRole("value")).Roles(uast.Binary, uast.Right), - ), - On(rubyast.OrAsgn).Roles(uast.Expression, uast.Operator, uast.Or, uast.Bitwise).Children( - On(HasInternalRole("target")).Roles(uast.Binary, uast.Left), - On(HasInternalRole("value")).Roles(uast.Binary, uast.Right), - ), - - // a.b.c.d would generate the tree d=->c->b->a where "a", "b" and "c" will be - // Qualified+Identifier and "d" will be just Identifier. - - // send is used for qualified identifiers (foo.bar), method calls (puts "foo") - // and a lot of other things... - On(rubyast.Send).Self( - On(And(HasInternalRole("base"), - Not(isSomeOperator), Not(HasToken("continue")), - Not(HasInternalRole("condition")))).Roles(uast.Expression, uast.Qualified, uast.Identifier), - - On(HasChild(HasInternalRole("base"))).Roles(uast.Expression, uast.Identifier), - - On(And(Or(rubyast.BodyRole, HasInternalRole("module")), Not(HasToken("continue")), - Not(isSomeOperator))).Roles(uast.Expression, uast.Call, uast.Identifier).Children( - On(rubyast.Values).Roles(uast.Expression, uast.Argument, uast.Identifier), - ), - - On(HasInternalRole("blockdata")).Self( - On(HasToken("each")).Roles(uast.Statement, uast.For, uast.Iterator), - On(HasToken("lambda")).Roles(uast.Expression, uast.Declaration, uast.Function, uast.Anonymous), - ), - - On(isSomeOperator).Roles(uast.Expression, uast.Operator).Self( - On(HasToken("+")).Roles(uast.Arithmetic, uast.Add), - On(HasToken("-")).Roles(uast.Arithmetic, uast.Substract), - On(HasToken("*")).Roles(uast.Arithmetic, uast.Multiply), - On(HasToken("/")).Roles(uast.Arithmetic, uast.Divide), - On(HasToken("%")).Roles(uast.Arithmetic, uast.Modulo), - // Pow - On(HasToken("**")).Roles(uast.Arithmetic, uast.Incomplete), - On(HasToken("&")).Roles(uast.Bitwise, uast.And), - On(HasToken("|")).Roles(uast.Bitwise, uast.Or), - On(HasToken("^")).Roles(uast.Bitwise, uast.Xor), - // Complemen - On(HasToken("~")).Roles(uast.Bitwise, uast.Incomplete), - On(HasToken("<<")).Roles(uast.Bitwise, uast.LeftShift), - On(HasToken(">>")).Roles(uast.Bitwise, uast.RightShift), - On(HasToken("==")).Roles(uast.Relational, uast.Equal), - On(HasToken(">=")).Roles(uast.Relational, uast.GreaterThanOrEqual), - On(HasToken("<=")).Roles(uast.Relational, uast.LessThanOrEqual), - On(HasToken("!=")).Roles(uast.Relational, uast.Equal, uast.Not), - On(HasToken("!")).Roles(uast.Relational, uast.Not), - // Incomplete: check type (1 !eql? 1.0) but not being the same object like equal? - On(HasToken("eql?")).Roles(uast.Relational, uast.Identical, uast.Incomplete), - On(HasToken("equal?")).Roles(uast.Relational, uast.Identical, uast.Identical), - // Combined comparison operator - On(HasToken("<==>")).Roles(uast.Relational, uast.Incomplete), - ), - - On(HasToken("continue")).Roles(uast.Statement, uast.Continue), - ), - - // FIXME: needs Range role or similar - On(Or(rubyast.IFlipFlop, rubyast.EFlipFlop)).Roles(uast.Expression, uast.Incomplete, - uast.List).Children( - On(Any).Roles(uast.Identifier, uast.Incomplete), - ), - On(rubyast.ERange).Roles(uast.Expression, uast.Tuple, uast.Incomplete), - On(rubyast.IRange).Roles(uast.Expression, uast.Tuple, uast.Incomplete), - On(rubyast.RegExp).Roles(uast.Expression, uast.Expression, uast.Regexp), - On(rubyast.RegExpBackRef).Roles(uast.Expression, uast.Regexp, uast.Incomplete), - On(rubyast.RegExpRef).Roles(uast.Expression, uast.Regexp, uast.Incomplete), - On(rubyast.RegOpt).Roles(uast.Expression, uast.Regexp, uast.Incomplete), - On(rubyast.Options).Roles(uast.Expression, uast.Regexp, uast.Incomplete), - On(rubyast.Symbol).Roles(uast.Expression, uast.Identifier), - On(rubyast.Sym).Roles(uast.Expression, uast.Identifier), - On(rubyast.Const).Roles(uast.Expression, uast.Identifier, uast.Incomplete).Children( - On(rubyast.CBase).Roles(uast.Expression, uast.Identifier, uast.Qualified, uast.Incomplete), - ), - // Interpolated symbols on strings - On(rubyast.DSym).Roles(uast.Expression, uast.String, uast.Incomplete), - On(rubyast.Self).Roles(uast.Expression, uast.This, uast.Left), - - On(HasInternalRole("condition")).Roles(uast.Expression, uast.Condition), - On(rubyast.If).Roles(uast.Statement, uast.If).Children( - On(HasInternalRole("body")).Roles(uast.Expression, uast.If, uast.Then), - On(HasInternalRole("condition")).Roles(uast.Expression, uast.If), - On(HasInternalRole("else")).Roles(uast.Expression, uast.If, uast.Else), - ), - - On(rubyast.Class).Roles(uast.Statement, uast.Type, uast.Declaration, uast.Identifier).Children( - On(And(rubyast.Block, HasInternalRole("body"))).Roles(uast.Expression, uast.Body), - ), // Singleton class - On(rubyast.SClass).Roles(uast.Expression, uast.Type, uast.Declaration, uast.Incomplete), - - // Arguments grouping node, needs uast.Group or similar - On(rubyast.Args).Roles(uast.Expression, uast.Argument, uast.Incomplete).Children( - On(rubyast.Arg).Roles(uast.Expression, uast.Argument, uast.Name), - On(rubyast.KwArg).Roles(uast.Expression, uast.Argument, uast.Name, uast.Map), - On(rubyast.KwOptArg).Roles(uast.Expression, uast.Argument, uast.Name, uast.Incomplete), - On(rubyast.KwRestArg).Roles(uast.Expression, uast.Argument, uast.Incomplete).Self( - On(Not(HasToken(""))).Roles(uast.Expression, uast.Identifier), - ), - On(rubyast.OptArg).Roles(uast.Expression, uast.Argument, uast.Name).Children( - On(Any).Roles(uast.Expression, uast.Argument, uast.Default), - ), - ), - On(rubyast.Alias).Roles(uast.Statement, uast.Alias), - On(rubyast.Def).Roles(uast.Statement, uast.Function, uast.Declaration, uast.Identifier).Children(), + AnnotateType("sclass", nil, role.Expression, role.Type, role.Declaration, role.Incomplete), + + AnnotateType("alias", nil, role.Statement, role.Alias), + AnnotateType("def", nil, role.Statement, role.Function, role.Declaration, role.Identifier), // Singleton method - On(rubyast.Defs).Roles(uast.Statement, uast.Function, uast.Declaration, uast.Identifier, uast.Incomplete).Children(), - On(rubyast.NilClass).Roles(uast.Statement, uast.Type, uast.Null), - On(Or(rubyast.Until, rubyast.UntilPost)).Roles(uast.Statement, uast.Incomplete), // Complete annotations below - On(Or(rubyast.Until, rubyast.UntilPost, rubyast.While, rubyast.WhilePost)).Roles(uast.Statement, uast.While).Children( - On(HasInternalRole("body")).Roles(uast.Expression, uast.While, uast.Body), - On(HasInternalRole("condition")).Roles(uast.Expression, uast.While), - ), - - On(rubyast.For).Roles(uast.Statement, uast.For).Children( - On(HasInternalRole("body")).Roles(uast.Expression, uast.For, uast.Body), - On(HasInternalRole("iterated")).Roles(uast.Expression, uast.For, uast.Update), - On(HasInternalRole("iterators")).Roles(uast.Expression, uast.For, uast.Iterator), - ), - - On(rubyast.True).Roles(uast.Expression, uast.Boolean, uast.Literal), - On(rubyast.False).Roles(uast.Expression, uast.Boolean, uast.Literal), - On(rubyast.And).Roles(uast.Expression, uast.Binary, uast.Expression, uast.Operator, uast.Boolean, uast.And), - On(rubyast.Or).Roles(uast.Expression, uast.Binary, uast.Expression, uast.Operator, uast.Boolean, uast.Or), - On(HasInternalRole("left")).Roles(uast.Expression, uast.Left), - On(HasInternalRole("right")).Roles(uast.Expression, uast.Right), - On(HasToken("raise")).Roles(uast.Statement, uast.Throw), + AnnotateType("defs", nil, role.Statement, role.Function, role.Declaration, role.Identifier, role.Incomplete), + AnnotateType("NilClass", nil, role.Statement, role.Type, role.Null), + AnnotateType("break", nil, role.Statement, role.Break), + AnnotateType("undef", nil, role.Statement, role.Incomplete), + AnnotateType("case", nil, role.Statement, role.Switch), + AnnotateType("when", nil, role.Expression, role.Case), // Exceptions - On(rubyast.KwBegin).Roles(uast.Expression, uast.Block).Self( - On(Or(HasChild(rubyast.Rescue), HasChild(rubyast.Ensure))).Roles(uast.Try).Children( - On(rubyast.Rescue).Roles(uast.Expression, uast.Try, uast.Body).Children( - On(rubyast.ResBody).Roles(uast.Expression, uast.Catch).Children( - On(rubyast.Retry).Roles(uast.Expression, uast.Statement, uast.Call), - ), - ), - On(rubyast.Ensure).Roles(uast.Expression, uast.Finally, uast.Body), - ), - ), - - On(rubyast.Case).Roles(uast.Statement, uast.Switch).Children( - On(rubyast.When).Roles(uast.Expression, uast.Case), - ), - On(rubyast.Break).Roles(uast.Statement, uast.Break), - On(rubyast.Undef).Roles(uast.Statement, uast.Incomplete), -) + AnnotateType("kwbegin", nil, role.Expression, role.Block), + AnnotateType("rescue", nil, role.Expression, role.Try, role.Body), + AnnotateType("resbody", nil, role.Expression, role.Catch), + AnnotateType("retry", nil, role.Expression, role.Statement, role.Call, role.Incomplete), + AnnotateType("ensure", nil, role.Expression, role.Finally), + + // Arguments + // grouping node for function definition (not for calls which just use send.values), need grouping role + AnnotateType("args", nil, role.Expression, role.Argument, role.Incomplete), + AnnotateType("arg", nil, role.Expression, role.Argument, role.Name, role.Identifier), + AnnotateType("kwarg", nil, role.Expression, role.Argument, role.Name, role.Map), + AnnotateType("kwoptarg", nil, role.Expression, role.Argument, role.Name, role.Incomplete), + AnnotateType("restarg", nil, role.Expression, role.Argument, role.Identifier, role.List), + AnnotateType("kwrestarg", nil, role.Expression, role.Argument, role.Identifier, role.Incomplete), + + // Assigns + // constant assign + annotateTypeTokenField("casgn", "selector", role.Expression, role.Assignment, role.Binary, role.Identifier, role.Left), + // multiple + AnnotateType("masgn", nil, role.Expression, role.Assignment, role.Incomplete), + // *Asgn with two children = binary and value have the "Right" role but with a single children = multiple assignment target :-/ + annotateTypeTokenField("lvasgn", "target", role.Expression, role.Assignment, role.Binary, role.Identifier, role.Left), + // is also a member + annotateTypeTokenField("ivasgn", "target", role.Expression, role.Assignment, role.Binary, role.Identifier, role.Left), + annotateTypeTokenField("gvasgn", "target", role.Expression, role.Assignment, role.Binary, role.Identifier, role.Left), + // class assign + annotateTypeTokenField("cvasgn", "target", role.Expression, role.Assignment, role.Binary, role.Identifier, role.Left), + // instance member + annotateTypeTokenField("ivasgn", "target", role.Expression, role.Assignment, role.Binary, role.Identifier, role.Left), + // Or Assign (a ||= b), And Assign (a &&= b) + AnnotateType("and_asgn", nil, role.Expression, role.Operator, role.And, role.Bitwise), + AnnotateType("or_asgn", nil, role.Expression, role.Operator, role.Or, role.Bitwise), + + // Misc + // multiple left side + AnnotateType("mlhs", nil, role.Left, role.Incomplete), + AnnotateType("erange", nil, role.Expression, role.Tuple, role.Incomplete), + AnnotateType("irange", nil, role.Expression, role.Tuple, role.Incomplete), + AnnotateType("regexp", nil, role.Expression, role.Regexp), + // regexp back reference + AnnotateType("back_ref", nil, role.Expression, role.Regexp, role.Incomplete), + // regexp reference + AnnotateType("nth_ref", nil, role.Expression, role.Regexp, role.Incomplete), + // regexp option/s + AnnotateType("regopt", nil, role.Expression, role.Regexp, role.Incomplete), + AnnotateType("options", nil, role.Expression, role.Regexp, role.Incomplete), + + AnnotateType("Symbol", nil, role.Expression, role.Identifier), + AnnotateType("sym", nil, role.Expression, role.Identifier), + // Interpolated symbols on strings + AnnotateType("dsym", nil, role.Expression, role.String, role.Incomplete), + AnnotateType("self", nil, role.Expression, role.This, role.Left), + annotateTypeToken("true", "true", role.Expression, role.Boolean, role.Literal), + annotateTypeToken("false", "false", role.Expression, role.Boolean, role.Literal), + annotateTypeToken("and", "and", role.Expression, role.Binary, role.Operator, role.Boolean, role.And), + annotateTypeToken("or", "or", role.Expression, role.Binary, role.Operator, role.Boolean, role.Or), + annotateTypeToken("raise", "raise", role.Statement, role.Throw), + + AnnotateType("const", nil, role.Expression, role.Identifier, role.Incomplete), + AnnotateType("cbase", nil, role.Expression, role.Identifier, role.Qualified, role.Incomplete), + + AnnotateType("values", nil, role.Expression, role.Argument, role.Identifier), + + // For + AnnotateType("for", ObjRoles{ + "body": {role.Expression, role.For, role.Body}, + "iterated": {role.Expression, role.For, role.Update}, + "iterators": {role.Expression, role.For, role.Iterator}, + }, role.Statement, role.For), + + // While/Until + AnnotateType("while", nil, role.Statement, role.While), + AnnotateType("while_post", nil, role.Statement, role.While), + AnnotateType("until", nil, role.Statement, role.While), + AnnotateType("until_post", nil, role.Statement, role.While), + + // If + AnnotateType("if", ObjRoles{ + "body": {role.Expression, role.Then}, + "else": {role.Expression, role.Else}, + }, role.Statement, role.If), + + MapASTCustom("op_asgn", + Obj{ + "operator": Var("op"), + }, Fields{ + {Name: "operator", Op: Operator("op", operatorRoles, role.Binary)}, + }, + LookupArrOpVar("op", operatorRoles), + role.Expression, role.Binary, role.Assignment, role.Operator), + + AnnotateType("iflipflop", ObjRoles{ + "_1": {role.Identifier, role.Incomplete}, + "_2": {role.Identical, role.Incomplete}, + }, role.Expression, role.List, role.Incomplete), + + // The many faces of Ruby's "send" start here ===> + MapAST("send_statement", Obj{ + "selector": String("continue"), + }, Obj{ + uast.KeyToken: String("continue"), + }, role.Statement, role.Continue), + + MapAST("send_statement", Obj{ + "selector": String("lambda"), + }, Obj{ + uast.KeyToken: String("lambda"), + }, role.Expression, role.Declaration, role.Function, role.Anonymous), + + MapAST("send_statement", Obj{ + "selector": String("require"), + }, Obj{ + uast.KeyToken: String("require"), + }, role.Expression, role.Import), + + MapAST("send_statement", Obj{ + "selector": String("each"), + }, Obj{ + uast.KeyToken: String("each"), + }, role.Statement, role.For, role.Iterator), + + MapAST("send_statement", Obj{ + "selector": String("public"), + }, Obj{ + uast.KeyToken: String("public"), + }, role.Statement, role.Visibility, role.World), + + MapAST("send_statement", Obj{ + "selector": String("protected"), + }, Obj{ + uast.KeyToken: String("protected"), + }, role.Statement, role.Visibility, role.Subtype), + + MapAST("send_statement", Obj{ + "selector": String("private"), + }, Obj{ + uast.KeyType: String("private"), + }, role.Statement, role.Visibility, role.Instance), + + // Operator expression "send" + MapASTCustom("send_operator", Obj{ + "base": ObjectRoles("bs"), + "values": EachObjectRoles("values"), + "selector": Var("selector"), + }, Obj{ + "base": ObjectRoles("bs", role.Left), + "values": EachObjectRoles("values", role.Right), + uast.KeyToken: Var("selector"), + }, + LookupArrOpVar("selector", operatorRoles), + role.Expression, role.Binary, role.Operator), + + // Same without values (unary) + MapASTCustom("send_operator", Obj{ + "selector": Var("selector"), + }, Obj{ + uast.KeyToken: Var("selector"), + }, + LookupArrOpVar("selector", operatorRoles), + role.Expression, role.Unary, role.Operator), + + // Assignment "send" (self.foo = 1) + MapAST("send_assign", Obj{ + "base": Var("base"), + "values": EachObjectRoles("values"), + "selector": Var("sel"), + uast.KeyToken: Var("tk"), + }, Obj{ + "base": Var("base"), + "values": EachObjectRoles("values", role.Assignment, role.Right), + "selector": Var("sel"), + uast.KeyToken: Var("tk"), + }, role.Expression, role.Assignment, role.Left), + + // Qualified identifier "send" (other than the parent of the last one that will + // match the rule above) + AnnotateType("send_qualified", nil, role.Expression, role.Qualified, role.Identical), + + // Function call "send" with arguments + MapAST("send_call", Obj{ + "base": Var("base"), + "selector": Var("selector"), + "values": EachObjectRoles("values"), + }, Obj{ + "base": Var("base"), + "values": EachObjectRoles("values", role.Function, role.Call, role.Argument), + uast.KeyToken: Var("selector"), + }, role.Expression, role.Function, role.Call), + + // Function call "send" without arguments + MapAST("send_call", Obj{ + "base": Var("base"), + "selector": Var("selector"), + }, Obj{ + "base": Var("base"), + uast.KeyToken: Var("selector"), + }, role.Expression, role.Function, role.Call), + + AnnotateType("send_array", nil, role.Expression, role.List), +} diff --git a/driver/normalizer/rubyast/rubyast.go b/driver/normalizer/rubyast/rubyast.go deleted file mode 100644 index 484e289..0000000 --- a/driver/normalizer/rubyast/rubyast.go +++ /dev/null @@ -1,140 +0,0 @@ -// Package rubyast defines constants for Ruby AST. -package rubyast - -import "gopkg.in/bblfsh/sdk.v1/uast/ann" - -var ( - Alias = ann.HasInternalType("alias") - And = ann.HasInternalType("and") - AndAsgn = ann.HasInternalType("and_asgn") - Arg = ann.HasInternalType("arg") - ArgExpr = ann.HasInternalType("arg_expr") - Args = ann.HasInternalRole("args") - Array = ann.HasInternalType("array") - Base = ann.HasInternalType("base") - Begin = ann.HasInternalType("begin") - Block = ann.HasInternalType("block") - BlockArg = ann.HasInternalType("blockarg") - BlockData = ann.HasInternalType("blockdata") - BlockPass = ann.HasInternalType("block_pass") - Body = ann.HasInternalType("body") - BodyRole = ann.HasInternalRole("body") - Break = ann.HasInternalType("break") - CAsgn = ann.HasInternalType("casgn") - CBase = ann.HasInternalType("cbase") - CSend = ann.HasInternalType("csend") - CVAsgn = ann.HasInternalType("cvasgn") - CVar = ann.HasInternalType("cvar") - Case = ann.HasInternalType("case") - CaseVar = ann.HasInternalType("casevar") - Children = ann.HasInternalType("children") - Class = ann.HasInternalType("class") - Complex = ann.HasInternalType("complex") - Condition = ann.HasInternalType("condition") - Conditions = ann.HasInternalType("conditions") - Const = ann.HasInternalType("const") - Contents = ann.HasInternalType("contents") - DStr = ann.HasInternalType("dstr") - DSym = ann.HasInternalType("dsym") - Def = ann.HasInternalType("def") - Default = ann.HasInternalType("default") - Defined = ann.HasInternalType("defined?") - Defs = ann.HasInternalType("defs") - Documentation = ann.HasInternalType("documentation") - EFlipFlop = ann.HasInternalType("eflipflop") - ERange = ann.HasInternalType("erange") - Else = ann.HasInternalType("else") - Ensure = ann.HasInternalType("ensure") - Ensurebody = ann.HasInternalType("ensure_body") - Exceptions = ann.HasInternalType("exceptions") - Expression = ann.HasInternalType("expression") - False = ann.HasInternalType("false") - Float = ann.HasInternalType("float") - For = ann.HasInternalType("for") - GVAsgn = ann.HasInternalType("gvasgn") - GVar = ann.HasInternalType("gvar") - Handlers = ann.HasInternalType("handlers") - Hash = ann.HasInternalType("hash") - IFlipFlop = ann.HasInternalType("iflipflop") - IRange = ann.HasInternalType("irange") - IVAsgn = ann.HasInternalType("ivasgn") - IVar = ann.HasInternalType("ivar") - If = ann.HasInternalType("if") - Inline = ann.HasInternalType("inline") - InnerComplex = ann.HasInternalType("Complex") - InnerRational = ann.HasInternalType("Rational") - InnerSymbol = ann.HasInternalType("Symbol") - Int = ann.HasInternalType("int") - Iterated = ann.HasInternalType("iterated") - Iterators = ann.HasInternalType("iterators") - KwArg = ann.HasInternalType("kwarg") - KwBegin = ann.HasInternalType("kwbegin") - KwOptArg = ann.HasInternalType("kwoptarg") - KwRestArg = ann.HasInternalType("kwrestarg") - KwSplat = ann.HasInternalType("kwsplat") - LVAsgn = ann.HasInternalType("lvasgn") - LVar = ann.HasInternalType("lvar") - Lambda = ann.HasInternalType("lambda") - MAsgn = ann.HasInternalType("masgn") - MatchCurrentLine = ann.HasInternalType("match_current_line") - MatchWithLVAsgn = ann.HasInternalType("match_with_lvasgn") - MultipleLeftSide = ann.HasInternalType("mlhs") - Module = ann.HasInternalType("module") - Name = ann.HasInternalType("name") - Next = ann.HasInternalType("next") - Nil = ann.HasInternalType("nil") - NilClass = ann.HasInternalType("NilClass") - Not = ann.HasInternalType("not") - Object = ann.HasInternalType("object") - OpAsgn = ann.HasInternalType("op_asgn") - Operator = ann.HasInternalType("operator") - OptArg = ann.HasInternalType("optarg") - Options = ann.HasInternalRole("options") - Or = ann.HasInternalType("or") - OrAsgn = ann.HasInternalType("or_asgn") - Pair = ann.HasInternalType("pair") - PairFirst = ann.HasInternalRole("_1") - PairSecond = ann.HasInternalRole("_2") - Parent = ann.HasInternalType("parent") - PostExe = ann.HasInternalType("postexe") - PreExe = ann.HasInternalType("preexe") - ProcArg0 = ann.HasInternalType("procarg0") - Question = ann.HasInternalType("question") - Rational = ann.HasInternalType("rational") - Redo = ann.HasInternalType("redo") - RegExp = ann.HasInternalType("regexp") - RegExpBackRef = ann.HasInternalType("back_ref") - RegExpRef = ann.HasInternalType("nth_ref") - RegOpt = ann.HasInternalType("regopt") - ResBody = ann.HasInternalType("resbody") - Rescue = ann.HasInternalType("rescue") - RestArg = ann.HasInternalType("restarg") - Retry = ann.HasInternalType("retry") - Return = ann.HasInternalType("return") - SClass = ann.HasInternalType("sclass") - SName = ann.HasInternalType("s_name") - Selector = ann.HasInternalType("selector") - Self = ann.HasInternalType("self") - Send = ann.HasInternalType("send") - ShadowArg = ann.HasInternalType("shadow_arg") - Splat = ann.HasInternalType("splat") - Str = ann.HasInternalType("str") - Symbol = ann.HasInternalType("Symbol") - Super = ann.HasInternalType("super") - Sym = ann.HasInternalType("sym") - Target = ann.HasInternalType("target") - Text = ann.HasInternalType("text") - True = ann.HasInternalType("true") - Undef = ann.HasInternalType("undef") - Until = ann.HasInternalType("until") - UntilPost = ann.HasInternalType("until_post") - Value = ann.HasInternalType("value") - Values = ann.HasInternalRole("values") - When = ann.HasInternalType("when") - WhenClauses = ann.HasInternalType("when_clauses") - While = ann.HasInternalType("while") - WhilePost = ann.HasInternalType("while_post") - XStr = ann.HasInternalType("xstr") - Yield = ann.HasInternalType("yield") - ZSuper = ann.HasInternalType("zsuper") -) diff --git a/driver/normalizer/tonode.go b/driver/normalizer/tonode.go deleted file mode 100644 index 2464136..0000000 --- a/driver/normalizer/tonode.go +++ /dev/null @@ -1,60 +0,0 @@ -package normalizer - -import ( - "strings" - - "gopkg.in/bblfsh/sdk.v1/uast" -) - -// ToNode is an instance of `uast.ObjectToNode`, defining how to transform an -// into a UAST (`uast.Node`). -// -// https://godoc.org/gopkg.in/bblfsh/sdk.v1/uast#ObjectToNode -var ToNode = &uast.ObjectToNode{ - InternalTypeKey: "type", - LineKey: "start_line", - EndLineKey: "end_line", - ColumnKey: "start_col", - EndColumnKey: "end_col", - - TokenKeys: map[string]bool{ - "name": true, - "token": true, - "selector": true, - "target": true, - }, - - SyntheticTokens: map[string]string{ - "true": "true", - "false": "false", - "and": "and", - "or": "or", - "retry": "retry", - }, - - Modifier: func(n map[string]interface{}) error { - // Native parser uses a [) interval for columns, so add 1 to start_col - if col, ok := n["start_col"].(float64); ok { - n["start_col"] = col + 1 - - // Native parser wrongly set positions at individual lines in multiline - // strings at 0, remove the position on those to avoid confusion - if t, ok := n["type"].(string); ok { - if t == "str" { - if endCol, ok := n["end_col"].(float64); ok && endCol == 0 { - delete(n, "start_col") - delete(n, "end_col") - delete(n, "start_line") - delete(n, "end_line") - } - } else if t == "comment" { - if text, ok := n["text"].(string); ok && strings.HasPrefix(text, "#") { - n["text"] = text[1:] - } - } - } - } - - return nil - }, -} diff --git a/fixtures/aritmeticops.rb.native b/fixtures/aritmeticops.rb.native index 7d497e8..052b2a5 100644 --- a/fixtures/aritmeticops.rb.native +++ b/fixtures/aritmeticops.rb.native @@ -3,216 +3,359 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "base": { - "end_col": 1, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 }, - "end_col": 3, - "end_line": 1, - "selector": "+", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 3, - "end_line": 1, - "start_col": 2, - "start_line": 1, - "token": 2, - "type": "int" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": 1, + "@type": "int" }, - { - "base": { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "token": 1, - "type": "int" + "selector": "+", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 }, - "end_col": 3, - "end_line": 2, - "selector": "-", - "start_col": 0, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 3, - "end_line": 2, - "start_col": 2, - "start_line": 2, - "token": 2, - "type": "int" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@token": 1, + "@type": "int" }, - { - "base": { - "end_col": 1, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "token": 1, - "type": "int" + "selector": "-", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 3, + "line": 2 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 3 }, - "end_col": 3, - "end_line": 3, - "selector": "*", - "start_col": 0, - "start_line": 3, - "type": "send", - "values": [ - { - "end_col": 3, - "end_line": 3, - "start_col": 2, - "start_line": 3, - "token": 2, - "type": "int" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@token": 1, + "@type": "int" }, - { - "base": { - "end_col": 1, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "token": 1, - "type": "int" + "selector": "*", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 3, + "line": 3 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 4 }, - "end_col": 3, - "end_line": 4, - "selector": "/", - "start_col": 0, - "start_line": 4, - "type": "send", - "values": [ - { - "end_col": 3, - "end_line": 4, - "start_col": 2, - "start_line": 4, - "token": 2, - "type": "int" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@token": 1, + "@type": "int" }, - { - "base": { - "end_col": 1, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "token": 1, - "type": "int" + "selector": "/", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 3, + "line": 4 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 5 }, - "end_col": 3, - "end_line": 5, - "selector": "%", - "start_col": 0, - "start_line": 5, - "type": "send", - "values": [ - { - "end_col": 3, - "end_line": 5, - "start_col": 2, - "start_line": 5, - "token": 2, - "type": "int" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@token": 1, + "@type": "int" }, - { - "base": { - "end_col": 1, - "end_line": 6, - "start_col": 0, - "start_line": 6, - "token": 1, - "type": "int" + "selector": "%", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 6 }, - "end_col": 4, - "end_line": 6, - "selector": "**", - "start_col": 0, - "start_line": 6, - "type": "send", - "values": [ - { - "end_col": 4, - "end_line": 6, - "start_col": 3, - "start_line": 6, - "token": 2, - "type": "int" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@token": 1, + "@type": "int" + }, + "selector": "**", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 6 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 7 }, - { + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 7 + }, + "@type": "send_operator", "base": { - "base": { - "end_col": 1, - "end_line": 7, - "start_col": 0, - "start_line": 7, - "token": 4, - "type": "int" - }, - "end_col": 3, - "end_line": 7, - "selector": "+", - "start_col": 0, - "start_line": 7, - "type": "send", - "values": [ - { - "end_col": 3, - "end_line": 7, - "start_col": 2, - "start_line": 7, - "token": 5, - "type": "int" - } - ] + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 7 + }, + "@token": 4, + "@type": "int" }, - "end_col": 5, - "end_line": 7, - "selector": "-", - "start_col": 0, - "start_line": 7, - "type": "send", + "selector": "+", "values": [ { - "end_col": 5, - "end_line": 7, - "start_col": 4, - "start_line": 7, - "token": 6, - "type": "int" + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 3, + "line": 7 + }, + "@token": 5, + "@type": "int" } ] - } - ], - "end_col": 5, - "end_line": 7, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + }, + "selector": "-", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@token": 6, + "@type": "int" + } + ] + } + ] } } } diff --git a/fixtures/aritmeticops.rb.uast b/fixtures/aritmeticops.rb.uast index 22151c7..02a71e4 100644 --- a/fixtures/aritmeticops.rb.uast +++ b/fixtures/aritmeticops.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Add +. . . . 0: send_operator { +. . . . . Roles: Add,Arithmetic,Binary,Expression,Operator . . . . . TOKEN "+" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 0 @@ -56,7 +56,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 2 @@ -74,8 +74,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Substract +. . . . 1: send_operator { +. . . . . Roles: Arithmetic,Binary,Expression,Operator,Substract . . . . . TOKEN "-" . . . . . StartPosition: { . . . . . . Offset: 4 @@ -92,7 +92,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 4 @@ -109,7 +109,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -127,8 +127,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 2: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Multiply +. . . . 2: send_operator { +. . . . . Roles: Arithmetic,Binary,Expression,Multiply,Operator . . . . . TOKEN "*" . . . . . StartPosition: { . . . . . . Offset: 8 @@ -145,7 +145,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 8 @@ -162,7 +162,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 @@ -180,8 +180,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 3: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Divide +. . . . 3: send_operator { +. . . . . Roles: Arithmetic,Binary,Divide,Expression,Operator . . . . . TOKEN "/" . . . . . StartPosition: { . . . . . . Offset: 12 @@ -198,7 +198,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 12 @@ -215,7 +215,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 14 @@ -233,8 +233,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 4: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Modulo +. . . . 4: send_operator { +. . . . . Roles: Arithmetic,Binary,Expression,Modulo,Operator . . . . . TOKEN "%" . . . . . StartPosition: { . . . . . . Offset: 16 @@ -251,7 +251,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 16 @@ -268,7 +268,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 18 @@ -286,8 +286,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 5: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Incomplete +. . . . 5: send_operator { +. . . . . Roles: Arithmetic,Binary,Expression,Incomplete,Operator . . . . . TOKEN "**" . . . . . StartPosition: { . . . . . . Offset: 20 @@ -304,7 +304,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 20 @@ -321,7 +321,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 23 @@ -339,8 +339,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 6: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Substract +. . . . 6: send_operator { +. . . . . Roles: Arithmetic,Binary,Expression,Operator,Substract . . . . . TOKEN "-" . . . . . StartPosition: { . . . . . . Offset: 25 @@ -356,8 +356,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Identifier,Operator,Arithmetic,Add +. . . . . . 0: send_operator { +. . . . . . . Roles: Add,Arithmetic,Binary,Expression,Left,Operator . . . . . . . TOKEN "+" . . . . . . . StartPosition: { . . . . . . . . Offset: 25 @@ -374,7 +374,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . . . TOKEN "4" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 25 @@ -391,7 +391,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "5" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 27 @@ -410,7 +410,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "6" . . . . . . . StartPosition: { . . . . . . . . Offset: 29 diff --git a/fixtures/array_access.rb.native b/fixtures/array_access.rb.native index c8c2bb6..3cd19f6 100644 --- a/fixtures/array_access.rb.native +++ b/fixtures/array_access.rb.native @@ -3,83 +3,136 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 10, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 }, - { - "end_col": 9, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": 2, - "type": "int" - } - ], - "end_col": 10, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "array" - } + "@token": 2, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 }, - { - "end_col": 8, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": { - "base": { - "end_col": 5, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "token": "a", - "type": "lvar" + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "send_array", + "base": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "end_col": 8, - "end_line": 2, - "selector": "[]", - "start_col": 4, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 7, - "end_line": 2, - "start_col": 6, - "start_line": 2, - "token": 0, - "type": "int" - } - ] - } + "@token": "a", + "@type": "lvar" + }, + "selector": "[]", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@token": 0, + "@type": "int" + } + ] } - ], - "end_col": 8, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/array_access.rb.uast b/fixtures/array_access.rb.uast index 33fa754..95af3a6 100644 --- a/fixtures/array_access.rb.uast +++ b/fixtures/array_access.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 8 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -93,7 +93,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 11 @@ -109,9 +109,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Right,Expression,Identifier -. . . . . . . TOKEN "[]" +. . . . . . 0: send_array { +. . . . . . . Roles: Binary,Expression,List,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 15 . . . . . . . . Line: 2 @@ -124,6 +123,7 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: value +. . . . . . . . selector: [] . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvar { diff --git a/fixtures/array_interpolated.rb.native b/fixtures/array_interpolated.rb.native index 22acfbc..2f29e7b 100644 --- a/fixtures/array_interpolated.rb.native +++ b/fixtures/array_interpolated.rb.native @@ -3,97 +3,162 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 10, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 }, - { - "end_col": 9, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": 2, - "type": "int" - } - ], - "end_col": 10, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "array" - } + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@token": 2, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 }, - { - "end_col": 14, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": 3, - "type": "int" + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 }, - { - "end_col": 10, - "end_line": 2, - "name": { - "end_col": 10, - "end_line": 2, - "start_col": 9, - "start_line": 2, - "token": "a", - "type": "lvar" + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@token": 3, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 2 }, - "start_col": 8, - "start_line": 2, - "type": "splat" + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 2 + }, + "@token": "a", + "@type": "lvar" + }, + "@type": "splat" + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 2 }, - { - "end_col": 13, - "end_line": 2, - "start_col": 12, - "start_line": 2, - "token": 4, - "type": "int" - } - ], - "end_col": 14, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "type": "array" - } + "@token": 4, + "@type": "int" + } + ] } - ], - "end_col": 14, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/array_interpolated.rb.uast b/fixtures/array_interpolated.rb.uast index b5d2e61..3932b96 100644 --- a/fixtures/array_interpolated.rb.uast +++ b/fixtures/array_interpolated.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 14 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -93,7 +93,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 11 @@ -110,7 +110,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 15 . . . . . . . . Line: 2 @@ -157,25 +157,6 @@ UAST: . . . . . . . . . Properties: { . . . . . . . . . . internalRole: contents . . . . . . . . . } -. . . . . . . . . Children: { -. . . . . . . . . . 0: lvar { -. . . . . . . . . . . Roles: Expression,Identifier -. . . . . . . . . . . TOKEN "a" -. . . . . . . . . . . StartPosition: { -. . . . . . . . . . . . Offset: 20 -. . . . . . . . . . . . Line: 2 -. . . . . . . . . . . . Col: 10 -. . . . . . . . . . . } -. . . . . . . . . . . EndPosition: { -. . . . . . . . . . . . Offset: 20 -. . . . . . . . . . . . Line: 2 -. . . . . . . . . . . . Col: 10 -. . . . . . . . . . . } -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: name -. . . . . . . . . . . } -. . . . . . . . . . } -. . . . . . . . . } . . . . . . . . } . . . . . . . . 2: int { . . . . . . . . . Roles: Expression,Literal,Number,Primitive diff --git a/fixtures/array_plain.rb.native b/fixtures/array_plain.rb.native index 2d4292d..832af9a 100644 --- a/fixtures/array_plain.rb.native +++ b/fixtures/array_plain.rb.native @@ -3,39 +3,62 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 10, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - { - "end_col": 9, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": 2, - "type": "int" - } - ], - "end_col": 10, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "array" - } + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@token": 2, + "@type": "int" + } + ] } } } diff --git a/fixtures/array_plain.rb.uast b/fixtures/array_plain.rb.uast index 3dc7af2..3e6764d 100644 --- a/fixtures/array_plain.rb.uast +++ b/fixtures/array_plain.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 10 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: array { -. . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . StartPosition: { . . . . . . Offset: 4 . . . . . . Line: 1 diff --git a/fixtures/array_range.rb.native b/fixtures/array_range.rb.native index da5f03a..f52fa0a 100644 --- a/fixtures/array_range.rb.native +++ b/fixtures/array_range.rb.native @@ -3,204 +3,347 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 13, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - { - "end_col": 9, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - { - "end_col": 12, - "end_line": 1, - "start_col": 11, - "start_line": 1, - "token": 3, - "type": "int" - } - ], - "end_col": 13, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "array" - } + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@token": 2, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@token": 3, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 }, - { - "end_col": 18, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "inc_end", - "type": "lvasgn", - "value": { - "base": { - "end_col": 11, - "end_line": 2, - "start_col": 10, - "start_line": 2, - "token": "a", - "type": "lvar" + "@type": "lvasgn", + "target": "inc_end", + "value": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@type": "send_array", + "base": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 }, - "end_col": 18, - "end_line": 2, - "selector": "[]", - "start_col": 10, - "start_line": 2, - "type": "send", - "values": [ - { - "_1": { - "end_col": 13, - "end_line": 2, - "start_col": 12, - "start_line": 2, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "[]", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@type": "irange", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@token": 1, + "@type": "int" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 }, - "_2": { - "end_col": 17, - "end_line": 2, - "start_col": 15, - "start_line": 2, - "token": -1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 2 }, - "end_col": 17, - "end_line": 2, - "start_col": 12, - "start_line": 2, - "type": "irange" + "@token": -1, + "@type": "int" } - ] - } + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 }, - { - "end_col": 19, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": "inc_slice", - "type": "lvasgn", - "value": { - "base": { - "end_col": 13, - "end_line": 3, - "start_col": 12, - "start_line": 3, - "token": "a", - "type": "lvar" + "@type": "lvasgn", + "target": "inc_slice", + "value": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 3 + }, + "@type": "send_array", + "base": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 3 }, - "end_col": 19, - "end_line": 3, - "selector": "[]", - "start_col": 12, - "start_line": 3, - "type": "send", - "values": [ - { - "_1": { - "end_col": 15, - "end_line": 3, - "start_col": 14, - "start_line": 3, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 3 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "[]", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 3 + }, + "@type": "irange", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 3 + }, + "@token": 1, + "@type": "int" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 }, - "_2": { - "end_col": 18, - "end_line": 3, - "start_col": 17, - "start_line": 3, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 3 }, - "end_col": 18, - "end_line": 3, - "start_col": 14, - "start_line": 3, - "type": "irange" + "@token": 2, + "@type": "int" } - ] - } + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 }, - { - "end_col": 19, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "target": "exc_end", - "type": "lvasgn", - "value": { - "base": { - "end_col": 11, - "end_line": 4, - "start_col": 10, - "start_line": 4, - "token": "a", - "type": "lvar" + "@type": "lvasgn", + "target": "exc_end", + "value": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 4 + }, + "@type": "send_array", + "base": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 4 }, - "end_col": 19, - "end_line": 4, - "selector": "[]", - "start_col": 10, - "start_line": 4, - "type": "send", - "values": [ - { - "_1": { - "end_col": 13, - "end_line": 4, - "start_col": 12, - "start_line": 4, - "token": 0, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 4 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "[]", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 4 + }, + "@type": "erange", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 4 + }, + "@token": 0, + "@type": "int" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 4 }, - "_2": { - "end_col": 18, - "end_line": 4, - "start_col": 16, - "start_line": 4, - "token": -1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 4 }, - "end_col": 18, - "end_line": 4, - "start_col": 12, - "start_line": 4, - "type": "erange" + "@token": -1, + "@type": "int" } - ] - } + } + ] } - ], - "end_col": 19, - "end_line": 4, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/array_range.rb.uast b/fixtures/array_range.rb.uast index c9bfc07..c1e196a 100644 --- a/fixtures/array_range.rb.uast +++ b/fixtures/array_range.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 19 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -110,7 +110,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "inc_end" . . . . . StartPosition: { . . . . . . Offset: 14 @@ -126,9 +126,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Right,Expression,Identifier -. . . . . . . TOKEN "[]" +. . . . . . 0: send_array { +. . . . . . . Roles: Binary,Expression,List,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 24 . . . . . . . . Line: 2 @@ -141,6 +140,7 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: value +. . . . . . . . selector: [] . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvar { @@ -161,7 +161,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: irange { -. . . . . . . . . Roles: Expression,Tuple,Incomplete +. . . . . . . . . Roles: Expression,Incomplete,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 26 . . . . . . . . . . Line: 2 @@ -177,7 +177,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 26 @@ -194,7 +194,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "-1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 29 @@ -217,7 +217,7 @@ UAST: . . . . . } . . . . } . . . . 2: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "inc_slice" . . . . . StartPosition: { . . . . . . Offset: 33 @@ -233,9 +233,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Right,Expression,Identifier -. . . . . . . TOKEN "[]" +. . . . . . 0: send_array { +. . . . . . . Roles: Binary,Expression,List,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 45 . . . . . . . . Line: 3 @@ -248,6 +247,7 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: value +. . . . . . . . selector: [] . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvar { @@ -268,7 +268,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: irange { -. . . . . . . . . Roles: Expression,Tuple,Incomplete +. . . . . . . . . Roles: Expression,Incomplete,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 47 . . . . . . . . . . Line: 3 @@ -284,7 +284,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 47 @@ -301,7 +301,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "2" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 50 @@ -324,7 +324,7 @@ UAST: . . . . . } . . . . } . . . . 3: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "exc_end" . . . . . StartPosition: { . . . . . . Offset: 53 @@ -340,9 +340,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Right,Expression,Identifier -. . . . . . . TOKEN "[]" +. . . . . . 0: send_array { +. . . . . . . Roles: Binary,Expression,List,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 63 . . . . . . . . Line: 4 @@ -355,6 +354,7 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: value +. . . . . . . . selector: [] . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvar { @@ -375,7 +375,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: erange { -. . . . . . . . . Roles: Expression,Tuple,Incomplete +. . . . . . . . . Roles: Expression,Incomplete,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 65 . . . . . . . . . . Line: 4 @@ -391,7 +391,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "0" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 65 @@ -408,7 +408,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "-1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 69 diff --git a/fixtures/array_splat.rb.native b/fixtures/array_splat.rb.native index 506ba8d..0e694a3 100644 --- a/fixtures/array_splat.rb.native +++ b/fixtures/array_splat.rb.native @@ -3,81 +3,134 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 10, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - { - "end_col": 9, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": 2, - "type": "int" - } - ], - "end_col": 10, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "array" - } + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@token": 2, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 }, - { - "end_col": 6, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 2, - "name": { - "end_col": 6, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": "a", - "type": "lvar" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 }, - "start_col": 4, - "start_line": 2, - "type": "splat" - } - ], - "end_col": 6, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "type": "array" - } + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@token": "a", + "@type": "lvar" + }, + "@type": "splat" + } + ] } - ], - "end_col": 6, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/array_splat.rb.uast b/fixtures/array_splat.rb.uast index e609570..e0ece07 100644 --- a/fixtures/array_splat.rb.uast +++ b/fixtures/array_splat.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -93,7 +93,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 11 @@ -110,7 +110,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 15 . . . . . . . . Line: 2 @@ -140,25 +140,6 @@ UAST: . . . . . . . . . Properties: { . . . . . . . . . . internalRole: contents . . . . . . . . . } -. . . . . . . . . Children: { -. . . . . . . . . . 0: lvar { -. . . . . . . . . . . Roles: Expression,Identifier -. . . . . . . . . . . TOKEN "a" -. . . . . . . . . . . StartPosition: { -. . . . . . . . . . . . Offset: 16 -. . . . . . . . . . . . Line: 2 -. . . . . . . . . . . . Col: 6 -. . . . . . . . . . . } -. . . . . . . . . . . EndPosition: { -. . . . . . . . . . . . Offset: 16 -. . . . . . . . . . . . Line: 2 -. . . . . . . . . . . . Col: 6 -. . . . . . . . . . . } -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: name -. . . . . . . . . . . } -. . . . . . . . . . } -. . . . . . . . . } . . . . . . . . } . . . . . . . } . . . . . . } diff --git a/fixtures/assign.rb.native b/fixtures/assign.rb.native index 9b6f927..e660ee2 100644 --- a/fixtures/assign.rb.native +++ b/fixtures/assign.rb.native @@ -3,22 +3,33 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 5, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": 1, + "@type": "int" } } } diff --git a/fixtures/assign.rb.uast b/fixtures/assign.rb.uast index 8de82b0..45bc039 100644 --- a/fixtures/assign.rb.uast +++ b/fixtures/assign.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: int { -. . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . TOKEN "1" . . . . . StartPosition: { . . . . . . Offset: 4 diff --git a/fixtures/assign_binop.rb.native b/fixtures/assign_binop.rb.native index 83c36cf..eacfb22 100644 --- a/fixtures/assign_binop.rb.native +++ b/fixtures/assign_binop.rb.native @@ -3,189 +3,320 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "op_asgn", + "operator": "+", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", "target": "a", - "type": "lvasgn", - "value": { - "end_col": 5, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": 1, - "type": "int" - } - }, - { - "end_col": 6, - "end_line": 2, - "operator": "+", - "start_col": 0, - "start_line": 2, - "target": { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 6, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": 1, - "type": "int" - } - }, - { - "end_col": 6, - "end_line": 3, - "operator": "-", - "start_col": 0, - "start_line": 3, - "target": { - "end_col": 1, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": "a", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 6, - "end_line": 3, - "start_col": 5, - "start_line": 3, - "token": 1, - "type": "int" - } - }, - { - "end_col": 7, - "end_line": 5, - "operator": "+", - "start_col": 0, - "start_line": 5, - "target": { - "end_col": 2, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "target": "@b", - "type": "ivasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 7, - "end_line": 5, - "start_col": 6, - "start_line": 5, - "token": 2, - "type": "int" - } - }, - { - "end_col": 9, - "end_line": 6, - "operator": "+", - "start_col": 0, - "start_line": 6, - "target": { - "base": { - "end_col": 2, - "end_line": 6, - "start_col": 0, - "start_line": 6, - "token": "@c", - "type": "ivar" + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "op_asgn", + "operator": "-", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "lvasgn", + "target": "a", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "op_asgn", + "operator": "+", + "target": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "ivasgn", + "target": "@b", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@token": 2, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "op_asgn", + "operator": "+", + "target": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@token": "@c", + "@type": "ivar" + }, + "selector": "x" + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@token": 3, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@type": "op_asgn", + "operator": "+", + "target": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@type": "send_array", + "base": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 8 }, - "end_col": 4, - "end_line": 6, - "selector": "x", - "start_col": 0, - "start_line": 6, - "type": "send" - }, - "type": "op_asgn", - "value": { - "end_col": 9, - "end_line": 6, - "start_col": 8, - "start_line": 6, - "token": 3, - "type": "int" - } - }, - { - "end_col": 13, - "end_line": 8, - "operator": "+", - "start_col": 0, - "start_line": 8, - "target": { - "base": { - "end_col": 2, - "end_line": 8, - "start_col": 0, - "start_line": 8, - "token": "@j", - "type": "ivar" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 }, - "end_col": 8, - "end_line": 8, - "selector": "[]", - "start_col": 0, - "start_line": 8, - "type": "send", - "values": [ - { - "end_col": 4, - "end_line": 8, - "start_col": 3, - "start_line": 8, - "token": 0, - "type": "int" + "@token": "@j", + "@type": "ivar" + }, + "selector": "[]", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 8 }, - { - "end_col": 7, - "end_line": 8, - "start_col": 6, - "start_line": 8, - "token": 1, - "type": "int" - } - ] - }, - "type": "op_asgn", - "value": { - "end_col": 13, - "end_line": 8, - "start_col": 12, - "start_line": 8, - "token": 4, - "type": "int" - } + "@token": 0, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 8 + }, + "@token": 1, + "@type": "int" + } + ] + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 8 + }, + "@token": 4, + "@type": "int" } - ], - "end_col": 13, - "end_line": 8, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/assign_binop.rb.uast b/fixtures/assign_binop.rb.uast index 8e6e460..98f5c63 100644 --- a/fixtures/assign_binop.rb.uast +++ b/fixtures/assign_binop.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 13 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 4 @@ -58,7 +58,7 @@ UAST: . . . . . } . . . . } . . . . 1: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Add +. . . . . Roles: Add,Arithmetic,Assignment,Binary,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 6 . . . . . . Line: 2 @@ -71,11 +71,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: + . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Add,Arithmetic,Binary,Expression,Operator +. . . . . . . TOKEN "+" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -91,8 +97,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 11 @@ -111,7 +117,7 @@ UAST: . . . . . } . . . . } . . . . 2: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Substract +. . . . . Roles: Arithmetic,Assignment,Binary,Expression,Operator,Substract . . . . . StartPosition: { . . . . . . Offset: 13 . . . . . . Line: 3 @@ -124,11 +130,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: - . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Arithmetic,Binary,Expression,Operator,Substract +. . . . . . . TOKEN "-" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 13 @@ -144,8 +156,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 18 @@ -164,7 +176,7 @@ UAST: . . . . . } . . . . } . . . . 3: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Add +. . . . . Roles: Add,Arithmetic,Assignment,Binary,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 21 . . . . . . Line: 5 @@ -177,11 +189,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: + . . . . . } . . . . . Children: { -. . . . . . 0: ivasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Add,Arithmetic,Binary,Expression,Operator +. . . . . . . TOKEN "+" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: ivasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "@b" . . . . . . . StartPosition: { . . . . . . . . Offset: 21 @@ -197,8 +215,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 27 @@ -217,7 +235,7 @@ UAST: . . . . . } . . . . } . . . . 4: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Add +. . . . . Roles: Add,Arithmetic,Assignment,Binary,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 29 . . . . . . Line: 6 @@ -230,11 +248,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: + . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Binary,Left,Expression,Identifier +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Add,Arithmetic,Binary,Expression,Operator +. . . . . . . TOKEN "+" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: send_call { +. . . . . . . Roles: Binary,Call,Expression,Function,Left . . . . . . . TOKEN "x" . . . . . . . StartPosition: { . . . . . . . . Offset: 29 @@ -251,7 +275,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: ivar { -. . . . . . . . . Roles: Expression,Identifier,Visibility,Instance +. . . . . . . . . Roles: Expression,Identifier,Instance,Visibility . . . . . . . . . TOKEN "@c" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 29 @@ -269,8 +293,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "3" . . . . . . . StartPosition: { . . . . . . . . Offset: 37 @@ -289,7 +313,7 @@ UAST: . . . . . } . . . . } . . . . 5: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Add +. . . . . Roles: Add,Arithmetic,Assignment,Binary,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 40 . . . . . . Line: 8 @@ -302,12 +326,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: + . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Binary,Left,Expression,Identifier -. . . . . . . TOKEN "[]" +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Add,Arithmetic,Binary,Expression,Operator +. . . . . . . TOKEN "+" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: send_array { +. . . . . . . Roles: Binary,Expression,Left,List . . . . . . . StartPosition: { . . . . . . . . Offset: 40 . . . . . . . . Line: 8 @@ -320,10 +349,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: target +. . . . . . . . selector: [] . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: ivar { -. . . . . . . . . Roles: Expression,Identifier,Visibility,Instance +. . . . . . . . . Roles: Expression,Identifier,Instance,Visibility . . . . . . . . . TOKEN "@j" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 40 @@ -375,8 +405,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "4" . . . . . . . StartPosition: { . . . . . . . . Offset: 52 diff --git a/fixtures/assign_logical.rb.native b/fixtures/assign_logical.rb.native index ebd5893..f9ac231 100644 --- a/fixtures/assign_logical.rb.native +++ b/fixtures/assign_logical.rb.native @@ -3,192 +3,329 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": 0, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "or_asgn", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@token": 2, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "and_asgn", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "lvasgn", "target": "a", - "type": "lvasgn", - "value": { - "end_col": 5, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": 0, - "type": "int" - } - }, - { - "end_col": 7, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": null - }, - "type": "or_asgn", - "value": { - "end_col": 7, - "end_line": 2, - "start_col": 6, - "start_line": 2, - "token": 2, - "type": "int" - } - }, - { - "end_col": 7, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": { - "end_col": 1, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": "a", - "type": "lvasgn", - "value": null - }, - "type": "and_asgn", - "value": { - "end_col": 7, - "end_line": 3, - "start_col": 6, - "start_line": 3, - "token": 3, - "type": "int" - } - }, - { - "end_col": 14, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "target": { - "base": { - "end_col": 4, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "token": "@foo", - "type": "ivar" + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@token": 3, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "or_asgn", + "target": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 5 }, - "end_col": 8, - "end_line": 5, - "selector": "bar", - "start_col": 0, - "start_line": 5, - "type": "send" - }, - "type": "or_asgn", - "value": { - "end_col": 14, - "end_line": 5, - "start_col": 13, - "start_line": 5, - "token": 4, - "type": "int" - } - }, - { - "end_col": 13, - "end_line": 6, - "start_col": 0, - "start_line": 6, - "target": { - "base": { - "base": null, - "end_col": 3, - "end_line": 6, - "selector": "pok", - "start_col": 0, - "start_line": 6, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 }, - "end_col": 7, - "end_line": 6, - "selector": "pol", - "start_col": 0, - "start_line": 6, - "type": "send" - }, - "type": "and_asgn", - "value": { - "end_col": 13, - "end_line": 6, - "start_col": 12, - "start_line": 6, - "token": 5, - "type": "int" - } - }, - { - "end_col": 16, - "end_line": 8, - "start_col": 0, - "start_line": 8, - "target": { - "base": { - "end_col": 4, - "end_line": 8, - "start_col": 0, - "start_line": 8, - "token": "@baz", - "type": "ivar" + "@token": "@foo", + "@type": "ivar" + }, + "selector": "bar" + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 5 + }, + "@token": 4, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "and_asgn", + "target": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 6 }, - "end_col": 10, - "end_line": 8, - "selector": "[]", - "start_col": 0, - "start_line": 8, - "type": "send", - "values": [ - { - "end_col": 6, - "end_line": 8, - "start_col": 5, - "start_line": 8, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "send_qualified", + "base": null, + "selector": "pok" + }, + "selector": "pol" + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 6 + }, + "@token": 5, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@type": "or_asgn", + "target": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@type": "send_array", + "base": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@token": "@baz", + "@type": "ivar" + }, + "selector": "[]", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 8 }, - { - "end_col": 9, - "end_line": 8, - "start_col": 8, - "start_line": 8, - "token": 2, - "type": "int" - } - ] - }, - "type": "or_asgn", - "value": { - "end_col": 16, - "end_line": 8, - "start_col": 15, - "start_line": 8, - "token": 6, - "type": "int" - } + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@token": 2, + "@type": "int" + } + ] + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 8 + }, + "@token": 6, + "@type": "int" } - ], - "end_col": 16, - "end_line": 8, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/assign_logical.rb.uast b/fixtures/assign_logical.rb.uast index f56d5a0..daa4898 100644 --- a/fixtures/assign_logical.rb.uast +++ b/fixtures/assign_logical.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 16 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "0" . . . . . . . StartPosition: { . . . . . . . . Offset: 4 @@ -58,7 +58,7 @@ UAST: . . . . . } . . . . } . . . . 1: or_asgn { -. . . . . Roles: Expression,Operator,Or,Bitwise +. . . . . Roles: Bitwise,Expression,Operator,Or . . . . . StartPosition: { . . . . . . Offset: 6 . . . . . . Line: 2 @@ -74,7 +74,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -91,7 +91,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 12 @@ -110,7 +110,7 @@ UAST: . . . . . } . . . . } . . . . 2: and_asgn { -. . . . . Roles: Expression,Operator,And,Bitwise +. . . . . Roles: And,Bitwise,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 14 . . . . . . Line: 3 @@ -126,7 +126,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 14 @@ -143,7 +143,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "3" . . . . . . . StartPosition: { . . . . . . . . Offset: 20 @@ -162,7 +162,7 @@ UAST: . . . . . } . . . . } . . . . 3: or_asgn { -. . . . . Roles: Expression,Operator,Or,Bitwise +. . . . . Roles: Bitwise,Expression,Operator,Or . . . . . StartPosition: { . . . . . . Offset: 23 . . . . . . Line: 5 @@ -177,8 +177,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Binary,Left,Expression,Identifier +. . . . . . 0: send_call { +. . . . . . . Roles: Binary,Call,Expression,Function,Left . . . . . . . TOKEN "bar" . . . . . . . StartPosition: { . . . . . . . . Offset: 23 @@ -195,7 +195,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: ivar { -. . . . . . . . . Roles: Expression,Identifier,Visibility,Instance +. . . . . . . . . Roles: Expression,Identifier,Instance,Visibility . . . . . . . . . TOKEN "@foo" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 23 @@ -214,7 +214,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "4" . . . . . . . StartPosition: { . . . . . . . . Offset: 36 @@ -233,7 +233,7 @@ UAST: . . . . . } . . . . } . . . . 4: and_asgn { -. . . . . Roles: Expression,Operator,And,Bitwise +. . . . . Roles: And,Bitwise,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 38 . . . . . . Line: 6 @@ -248,8 +248,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Binary,Left,Expression,Identifier +. . . . . . 0: send_call { +. . . . . . . Roles: Binary,Call,Expression,Function,Left . . . . . . . TOKEN "pol" . . . . . . . StartPosition: { . . . . . . . . Offset: 38 @@ -265,9 +265,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: send { -. . . . . . . . . Roles: Expression,Qualified,Identifier -. . . . . . . . . TOKEN "pok" +. . . . . . . . 0: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 38 . . . . . . . . . . Line: 6 @@ -280,12 +279,13 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: base +. . . . . . . . . . selector: pok . . . . . . . . . } . . . . . . . . } . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "5" . . . . . . . StartPosition: { . . . . . . . . Offset: 50 @@ -304,7 +304,7 @@ UAST: . . . . . } . . . . } . . . . 5: or_asgn { -. . . . . Roles: Expression,Operator,Or,Bitwise +. . . . . Roles: Bitwise,Expression,Operator,Or . . . . . StartPosition: { . . . . . . Offset: 53 . . . . . . Line: 8 @@ -319,9 +319,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Binary,Left,Expression,Identifier -. . . . . . . TOKEN "[]" +. . . . . . 0: send_array { +. . . . . . . Roles: Binary,Expression,Left,List . . . . . . . StartPosition: { . . . . . . . . Offset: 53 . . . . . . . . Line: 8 @@ -334,10 +333,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: target +. . . . . . . . selector: [] . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: ivar { -. . . . . . . . . Roles: Expression,Identifier,Visibility,Instance +. . . . . . . . . Roles: Expression,Identifier,Instance,Visibility . . . . . . . . . TOKEN "@baz" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 53 @@ -390,7 +390,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "6" . . . . . . . StartPosition: { . . . . . . . . Offset: 68 diff --git a/fixtures/assign_multiple.rb.native b/fixtures/assign_multiple.rb.native index daa1214..5969487 100644 --- a/fixtures/assign_multiple.rb.native +++ b/fixtures/assign_multiple.rb.native @@ -3,227 +3,382 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 11, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "targets": { - "children": [ - { - "end_col": 1, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": null - }, - { - "end_col": 4, - "end_line": 1, - "start_col": 3, - "start_line": 1, - "target": "b", - "type": "lvasgn", - "value": null - } - ], - "end_col": 4, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "mlhs" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "masgn", + "targets": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 1 }, - "type": "masgn", - "values": { - "contents": [ - { - "end_col": 8, - "end_line": 1, - "start_col": 7, - "start_line": 1, - "token": 1, - "type": "int" - }, - { - "end_col": 11, - "end_line": 1, - "start_col": 10, - "start_line": 1, - "token": 2, - "type": "int" - } - ], - "end_col": 11, - "end_line": 1, - "start_col": 7, - "start_line": 1, - "type": "array" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "mlhs", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@type": "lvasgn", + "target": "b", + "value": null + } + ] }, - { - "end_col": 13, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "targets": { - "children": [ - { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": null - }, - { - "children": [ - { - "end_col": 5, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": null + "values": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@token": 2, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "masgn", + "targets": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "mlhs", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 2 + }, + "@type": "mlhs", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "b", + "value": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 2 }, - { - "end_col": 8, - "end_line": 2, - "start_col": 7, - "start_line": 2, - "target": "c", - "type": "lvasgn", - "value": null - } - ], - "end_col": 9, - "end_line": 2, - "start_col": 3, - "start_line": 2, - "type": "mlhs" - } - ], - "end_col": 9, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "type": "mlhs" + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 2 + }, + "@type": "lvasgn", + "target": "c", + "value": null + } + ] + } + ] + }, + "values": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "d" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "lvasgn", + "target": "c", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 3 }, - "type": "masgn", - "values": { - "base": null, - "end_col": 13, - "end_line": 2, - "selector": "d", - "start_col": 12, - "start_line": 2, - "type": "send" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@token": 3, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 3 + }, + "@token": 4, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 }, - { - "end_col": 10, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": "c", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 3, - "start_col": 5, - "start_line": 3, - "token": 3, - "type": "int" - }, - { - "end_col": 9, - "end_line": 3, - "start_col": 8, - "start_line": 3, - "token": 4, - "type": "int" - } - ], - "end_col": 10, - "end_line": 3, - "start_col": 4, - "start_line": 3, - "type": "array" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 }, - { - "end_col": 12, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "targets": { - "children": [ - { - "end_col": 2, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "target": "@a", - "type": "ivasgn", - "value": null - }, - { - "end_col": 7, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "target": "@@b", - "type": "cvasgn", - "value": null - } - ], - "end_col": 7, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "type": "mlhs" + "@type": "masgn", + "targets": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 4 }, - "type": "masgn", - "values": { - "contents": [ - { - "end_col": 12, - "end_line": 4, - "name": { - "end_col": 12, - "end_line": 4, - "start_col": 11, - "start_line": 4, - "token": "c", - "type": "lvar" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "mlhs", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "ivasgn", + "target": "@a", + "value": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "cvasgn", + "target": "@@b", + "value": null + } + ] + }, + "values": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 4 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 4 + }, + "@token": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 4 }, - "start_col": 10, - "start_line": 4, - "type": "splat" - } - ], - "end_col": 12, - "end_line": 4, - "start_col": 10, - "start_line": 4, - "type": "array" - } + "@token": "c", + "@type": "lvar" + }, + "@type": "splat" + } + ] } - ], - "end_col": 12, - "end_line": 4, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/assign_multiple.rb.uast b/fixtures/assign_multiple.rb.uast index d172e34..512f807 100644 --- a/fixtures/assign_multiple.rb.uast +++ b/fixtures/assign_multiple.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 12 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: masgn { -. . . . . Roles: Expression,Assignment,Incomplete +. . . . . Roles: Assignment,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -38,7 +38,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: mlhs { -. . . . . . . Roles: Left,Incomplete +. . . . . . . Roles: Incomplete,Left . . . . . . . StartPosition: { . . . . . . . . Offset: 0 . . . . . . . . Line: 1 @@ -54,7 +54,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 0 @@ -71,7 +71,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "b" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 3 @@ -90,7 +90,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: array { -. . . . . . . Roles: Binary,Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Expression,List,Literal,Primitive . . . . . . . StartPosition: { . . . . . . . . Offset: 7 . . . . . . . . Line: 1 @@ -144,7 +144,7 @@ UAST: . . . . . } . . . . } . . . . 1: masgn { -. . . . . Roles: Expression,Assignment,Incomplete +. . . . . Roles: Assignment,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 2 @@ -160,7 +160,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: mlhs { -. . . . . . . Roles: Left,Incomplete +. . . . . . . Roles: Incomplete,Left . . . . . . . StartPosition: { . . . . . . . . Offset: 12 . . . . . . . . Line: 2 @@ -176,7 +176,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 12 @@ -193,7 +193,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: mlhs { -. . . . . . . . . Roles: Left,Incomplete +. . . . . . . . . Roles: Incomplete,Left . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 15 . . . . . . . . . . Line: 2 @@ -209,7 +209,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: lvasgn { -. . . . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . . . TOKEN "b" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 16 @@ -226,7 +226,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: lvasgn { -. . . . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . . . TOKEN "c" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 19 @@ -246,9 +246,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Binary,Right -. . . . . . . TOKEN "d" +. . . . . . 1: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 24 . . . . . . . . Line: 2 @@ -261,12 +260,13 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: values +. . . . . . . . selector: d . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 2: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "c" . . . . . StartPosition: { . . . . . . Offset: 26 @@ -283,7 +283,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 30 . . . . . . . . Line: 3 @@ -337,7 +337,7 @@ UAST: . . . . . } . . . . } . . . . 3: masgn { -. . . . . Roles: Expression,Assignment,Incomplete +. . . . . Roles: Assignment,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 37 . . . . . . Line: 4 @@ -353,7 +353,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: mlhs { -. . . . . . . Roles: Left,Incomplete +. . . . . . . Roles: Incomplete,Left . . . . . . . StartPosition: { . . . . . . . . Offset: 37 . . . . . . . . Line: 4 @@ -369,7 +369,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: ivasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "@a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 37 @@ -386,7 +386,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: cvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "@@b" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 41 @@ -405,7 +405,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: array { -. . . . . . . Roles: Binary,Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Expression,List,Literal,Primitive . . . . . . . StartPosition: { . . . . . . . . Offset: 47 . . . . . . . . Line: 4 @@ -435,25 +435,6 @@ UAST: . . . . . . . . . Properties: { . . . . . . . . . . internalRole: contents . . . . . . . . . } -. . . . . . . . . Children: { -. . . . . . . . . . 0: lvar { -. . . . . . . . . . . Roles: Expression,Identifier -. . . . . . . . . . . TOKEN "c" -. . . . . . . . . . . StartPosition: { -. . . . . . . . . . . . Offset: 48 -. . . . . . . . . . . . Line: 4 -. . . . . . . . . . . . Col: 12 -. . . . . . . . . . . } -. . . . . . . . . . . EndPosition: { -. . . . . . . . . . . . Offset: 48 -. . . . . . . . . . . . Line: 4 -. . . . . . . . . . . . Col: 12 -. . . . . . . . . . . } -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: name -. . . . . . . . . . . } -. . . . . . . . . . } -. . . . . . . . . } . . . . . . . . } . . . . . . . } . . . . . . } diff --git a/fixtures/attribute.rb.native b/fixtures/attribute.rb.native index 1bf15a2..bf51a38 100644 --- a/fixtures/attribute.rb.native +++ b/fixtures/attribute.rb.native @@ -3,32 +3,50 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": { - "end_col": 4, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "self" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "foo", + "@type": "send_assign", + "base": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 1 }, - "end_col": 12, - "end_line": 1, - "selector": "foo=", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 12, - "end_line": 1, - "start_col": 11, - "start_line": 1, - "token": 1, - "type": "int" - } - ] - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "self" + }, + "selector": "foo=", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + ] } } } diff --git a/fixtures/attribute.rb.uast b/fixtures/attribute.rb.uast index 8f3e50d..a8e0b3e 100644 --- a/fixtures/attribute.rb.uast +++ b/fixtures/attribute.rb.uast @@ -2,12 +2,12 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { -. . 0: send { -. . . Roles: Expression,Identifier,Call -. . . TOKEN "foo=" +. . 0: send_assign { +. . . Roles: Assignment,Expression,Left +. . . TOKEN "foo" . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -19,11 +19,12 @@ UAST: . . . . Col: 12 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file +. . . . selector: foo= . . . } . . . Children: { . . . . 0: self { -. . . . . Roles: Expression,This,Left +. . . . . Roles: Expression,Left,This . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -39,7 +40,7 @@ UAST: . . . . . } . . . . } . . . . 1: int { -. . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . Roles: Assignment,Expression,Literal,Number,Primitive,Right . . . . . TOKEN "1" . . . . . StartPosition: { . . . . . . Offset: 11 diff --git a/fixtures/attribute_safe.rb.native b/fixtures/attribute_safe.rb.native index efc518c..45e4630 100644 --- a/fixtures/attribute_safe.rb.native +++ b/fixtures/attribute_safe.rb.native @@ -3,29 +3,46 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 13, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "base": { - "end_col": 8, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "self" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 }, - "end_col": 13, - "end_line": 1, - "selector": "foo", - "start_col": 4, - "start_line": 1, - "type": "csend" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "self" + }, + "selector": "foo" } } } diff --git a/fixtures/attribute_safe.rb.uast b/fixtures/attribute_safe.rb.uast index 067660f..443153e 100644 --- a/fixtures/attribute_safe.rb.uast +++ b/fixtures/attribute_safe.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 13 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: csend { -. . . . . Roles: Right +. . . . 0: send_call { +. . . . . Roles: Binary,Call,Expression,Function,Right . . . . . TOKEN "foo" . . . . . StartPosition: { . . . . . . Offset: 4 @@ -40,7 +40,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: self { -. . . . . . . Roles: Expression,This,Left +. . . . . . . Roles: Expression,Left,This . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 diff --git a/fixtures/attribute_safe_old.rb.native b/fixtures/attribute_safe_old.rb.native index ab12b23..69171d3 100644 --- a/fixtures/attribute_safe_old.rb.native +++ b/fixtures/attribute_safe_old.rb.native @@ -3,39 +3,62 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 18, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "base": { - "end_col": 8, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "self" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 }, - "end_col": 18, - "end_line": 1, - "selector": "try", - "start_col": 4, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 17, - "end_line": 1, - "start_col": 13, - "start_line": 1, - "token": "foo", - "type": "sym" - } - ] - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "self" + }, + "selector": "try", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@token": "foo", + "@type": "sym" + } + ] } } } diff --git a/fixtures/attribute_safe_old.rb.uast b/fixtures/attribute_safe_old.rb.uast index 67e4053..4b43270 100644 --- a/fixtures/attribute_safe_old.rb.uast +++ b/fixtures/attribute_safe_old.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 18 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Right,Expression,Identifier +. . . . 0: send_call { +. . . . . Roles: Binary,Call,Expression,Function,Right . . . . . TOKEN "try" . . . . . StartPosition: { . . . . . . Offset: 4 @@ -40,7 +40,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: self { -. . . . . . . Roles: Expression,This,Left +. . . . . . . Roles: Expression,Left,This . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -56,7 +56,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: sym { -. . . . . . . Roles: Expression,Identifier +. . . . . . . Roles: Argument,Call,Expression,Function,Identifier . . . . . . . TOKEN "foo" . . . . . . . StartPosition: { . . . . . . . . Offset: 13 diff --git a/fixtures/augassign.rb.native b/fixtures/augassign.rb.native index 275b4ad..da84705 100644 --- a/fixtures/augassign.rb.native +++ b/fixtures/augassign.rb.native @@ -3,166 +3,279 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 6, - "end_line": 1, - "operator": "+", - "start_col": 0, - "start_line": 1, - "target": { - "end_col": 1, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 1, - "type": "int" - } - }, - { - "end_col": 6, - "end_line": 2, - "operator": "-", - "start_col": 0, - "start_line": 2, - "target": { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 6, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": 1, - "type": "int" - } - }, - { - "end_col": 6, - "end_line": 3, - "operator": "*", - "start_col": 0, - "start_line": 3, - "target": { - "end_col": 1, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": "c", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 6, - "end_line": 3, - "start_col": 5, - "start_line": 3, - "token": 1, - "type": "int" - } - }, - { - "end_col": 6, - "end_line": 4, - "operator": "/", - "start_col": 0, - "start_line": 4, - "target": { - "end_col": 1, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "target": "d", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 6, - "end_line": 4, - "start_col": 5, - "start_line": 4, - "token": 1, - "type": "int" - } - }, - { - "end_col": 6, - "end_line": 5, - "operator": "%", - "start_col": 0, - "start_line": 5, - "target": { - "end_col": 1, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "target": "e", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 6, - "end_line": 5, - "start_col": 5, - "start_line": 5, - "token": 1, - "type": "int" - } - }, - { - "end_col": 7, - "end_line": 6, - "operator": "**", - "start_col": 0, - "start_line": 6, - "target": { - "end_col": 1, - "end_line": 6, - "start_col": 0, - "start_line": 6, - "target": "f", - "type": "lvasgn", - "value": null - }, - "type": "op_asgn", - "value": { - "end_col": 7, - "end_line": 6, - "start_col": 6, - "start_line": 6, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "op_asgn", + "operator": "+", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "op_asgn", + "operator": "-", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "target": "b", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "op_asgn", + "operator": "*", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "lvasgn", + "target": "c", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "op_asgn", + "operator": "/", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "lvasgn", + "target": "d", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "op_asgn", + "operator": "%", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "lvasgn", + "target": "e", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "op_asgn", + "operator": "**", + "target": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "lvasgn", + "target": "f", + "value": null + }, + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@token": 1, + "@type": "int" } - ], - "end_col": 7, - "end_line": 6, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/augassign.rb.uast b/fixtures/augassign.rb.uast index 7da425a..06951c0 100644 --- a/fixtures/augassign.rb.uast +++ b/fixtures/augassign.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 7 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Add +. . . . . Roles: Add,Arithmetic,Assignment,Binary,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -35,11 +35,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: + . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Add,Arithmetic,Binary,Expression,Operator +. . . . . . . TOKEN "+" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 0 @@ -55,8 +61,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 5 @@ -75,7 +81,7 @@ UAST: . . . . . } . . . . } . . . . 1: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Substract +. . . . . Roles: Arithmetic,Assignment,Binary,Expression,Operator,Substract . . . . . StartPosition: { . . . . . . Offset: 7 . . . . . . Line: 2 @@ -88,11 +94,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: - . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Arithmetic,Binary,Expression,Operator,Substract +. . . . . . . TOKEN "-" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "b" . . . . . . . StartPosition: { . . . . . . . . Offset: 7 @@ -108,8 +120,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 12 @@ -128,7 +140,7 @@ UAST: . . . . . } . . . . } . . . . 2: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Multiply +. . . . . Roles: Arithmetic,Assignment,Binary,Expression,Multiply,Operator . . . . . StartPosition: { . . . . . . Offset: 14 . . . . . . Line: 3 @@ -141,11 +153,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: * . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Arithmetic,Binary,Expression,Multiply,Operator +. . . . . . . TOKEN "*" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "c" . . . . . . . StartPosition: { . . . . . . . . Offset: 14 @@ -161,8 +179,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -181,7 +199,7 @@ UAST: . . . . . } . . . . } . . . . 3: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Divide +. . . . . Roles: Arithmetic,Assignment,Binary,Divide,Expression,Operator . . . . . StartPosition: { . . . . . . Offset: 21 . . . . . . Line: 4 @@ -194,11 +212,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: / . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Arithmetic,Binary,Divide,Expression,Operator +. . . . . . . TOKEN "/" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "d" . . . . . . . StartPosition: { . . . . . . . . Offset: 21 @@ -214,8 +238,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 26 @@ -234,7 +258,7 @@ UAST: . . . . . } . . . . } . . . . 4: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Modulo +. . . . . Roles: Arithmetic,Assignment,Binary,Expression,Modulo,Operator . . . . . StartPosition: { . . . . . . Offset: 28 . . . . . . Line: 5 @@ -247,11 +271,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: % . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Arithmetic,Binary,Expression,Modulo,Operator +. . . . . . . TOKEN "%" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "e" . . . . . . . StartPosition: { . . . . . . . . Offset: 28 @@ -267,8 +297,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 33 @@ -287,7 +317,7 @@ UAST: . . . . . } . . . . } . . . . 5: op_asgn { -. . . . . Roles: Expression,Operator,Binary,Assignment,Arithmetic,Incomplete +. . . . . Roles: Arithmetic,Assignment,Binary,Expression,Incomplete,Operator . . . . . StartPosition: { . . . . . . Offset: 35 . . . . . . Line: 6 @@ -300,11 +330,17 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body -. . . . . . operator: ** . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: ast:Operator { +. . . . . . . Roles: Arithmetic,Binary,Expression,Incomplete,Operator +. . . . . . . TOKEN "**" +. . . . . . . Properties: { +. . . . . . . . internalRole: operator +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "f" . . . . . . . StartPosition: { . . . . . . . . Offset: 35 @@ -320,8 +356,8 @@ UAST: . . . . . . . . internalRole: target . . . . . . . } . . . . . . } -. . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Binary,Right +. . . . . . 2: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 41 diff --git a/fixtures/bitwise.rb.native b/fixtures/bitwise.rb.native index 19f1e62..10966fc 100644 --- a/fixtures/bitwise.rb.native +++ b/fixtures/bitwise.rb.native @@ -3,162 +3,269 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "base": { - "end_col": 1, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": 1, + "@type": "int" + }, + "selector": "&", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@token": 1, + "@type": "int" + }, + "selector": "|", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 3 }, - "end_col": 5, - "end_line": 1, - "selector": "&", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 5, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": 2, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 }, - "end_col": 5, - "end_line": 2, - "selector": "|", - "start_col": 0, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 5, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "token": 2, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 1, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "token": 1, - "type": "int" + "@token": 1, + "@type": "int" + }, + "selector": "^", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 2, + "line": 4 + }, + "@token": 2, + "@type": "int" + }, + "selector": "~" + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 5 }, - "end_col": 5, - "end_line": 3, - "selector": "^", - "start_col": 0, - "start_line": 3, - "type": "send", - "values": [ - { - "end_col": 5, - "end_line": 3, - "start_col": 4, - "start_line": 3, - "token": 2, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 2, - "end_line": 4, - "start_col": 1, - "start_line": 4, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 }, - "end_col": 2, - "end_line": 4, - "selector": "~", - "start_col": 0, - "start_line": 4, - "type": "send" - }, - { - "base": { - "end_col": 1, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "token": 1, - "type": "int" + "@token": 1, + "@type": "int" + }, + "selector": "<<", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 6 }, - "end_col": 6, - "end_line": 5, - "selector": "<<", - "start_col": 0, - "start_line": 5, - "type": "send", - "values": [ - { - "end_col": 6, - "end_line": 5, - "start_col": 5, - "start_line": 5, - "token": 2, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 1, - "end_line": 6, - "start_col": 0, - "start_line": 6, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 }, - "end_col": 6, - "end_line": 6, - "selector": ">>", - "start_col": 0, - "start_line": 6, - "type": "send", - "values": [ - { - "end_col": 6, - "end_line": 6, - "start_col": 5, - "start_line": 6, - "token": 2, - "type": "int" - } - ] - } - ], - "end_col": 6, - "end_line": 6, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "@token": 1, + "@type": "int" + }, + "selector": ">>", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@token": 2, + "@type": "int" + } + ] + } + ] } } } diff --git a/fixtures/bitwise.rb.uast b/fixtures/bitwise.rb.uast index c1779ea..3fa8536 100644 --- a/fixtures/bitwise.rb.uast +++ b/fixtures/bitwise.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Identifier,Call +. . . . 0: send_operator { +. . . . . Roles: And,Binary,Bitwise,Expression,Operator . . . . . TOKEN "&" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 0 @@ -56,7 +56,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 4 @@ -74,8 +74,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: send { -. . . . . Roles: Expression,Identifier,Call +. . . . 1: send_operator { +. . . . . Roles: Binary,Bitwise,Expression,Operator,Or . . . . . TOKEN "|" . . . . . StartPosition: { . . . . . . Offset: 6 @@ -92,7 +92,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -109,7 +109,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 @@ -127,8 +127,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 2: send { -. . . . . Roles: Expression,Identifier,Call +. . . . 2: send_operator { +. . . . . Roles: Binary,Bitwise,Expression,Operator,Xor . . . . . TOKEN "^" . . . . . StartPosition: { . . . . . . Offset: 12 @@ -145,7 +145,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 12 @@ -162,7 +162,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 16 @@ -180,8 +180,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 3: send { -. . . . . Roles: Expression,Identifier,Call +. . . . 3: send_operator { +. . . . . Roles: Bitwise,Expression,Incomplete,Operator,Unary . . . . . TOKEN "~" . . . . . StartPosition: { . . . . . . Offset: 18 @@ -216,8 +216,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 4: send { -. . . . . Roles: Expression,Identifier,Call +. . . . 4: send_operator { +. . . . . Roles: Binary,Bitwise,Expression,LeftShift,Operator . . . . . TOKEN "<<" . . . . . StartPosition: { . . . . . . Offset: 21 @@ -234,7 +234,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 21 @@ -251,7 +251,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 26 @@ -269,8 +269,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 5: send { -. . . . . Roles: Expression,Identifier,Call +. . . . 5: send_operator { +. . . . . Roles: Binary,Bitwise,Expression,Operator,RightShift . . . . . TOKEN ">>" . . . . . StartPosition: { . . . . . . Offset: 28 @@ -287,7 +287,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 28 @@ -304,7 +304,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 33 diff --git a/fixtures/blockargs.rb.native b/fixtures/blockargs.rb.native index 1aa47fb..a102ec7 100644 --- a/fixtures/blockargs.rb.native +++ b/fixtures/blockargs.rb.native @@ -3,268 +3,453 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 13, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - { - "end_col": 9, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - { - "end_col": 12, - "end_line": 1, - "start_col": 11, - "start_line": 1, - "token": 3, - "type": "int" - } - ], - "end_col": 13, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "array" + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@token": 2, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@token": 3, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "block", + "args": [ + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 2 + }, + "@token": "x", + "@type": "arg" } + ], + "blockdata": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_statement", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "each" }, - { - "args": [ + "body": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@type": "begin", + "body": [ { - "end_col": 12, - "end_line": 2, - "start_col": 11, - "start_line": 2, - "token": "x", - "type": "arg" - } - ], - "blockdata": { - "base": { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "token": "a", - "type": "lvar" + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 3 + }, + "@token": "x", + "@type": "lvar" + } + ] }, - "end_col": 6, - "end_line": 2, - "selector": "each", - "start_col": 0, - "start_line": 2, - "type": "send" + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 4 + }, + "@token": 1, + "@type": "int" + } + ] + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 7 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 }, - "body": { - "body": [ - { - "base": null, - "end_col": 10, - "end_line": 3, - "selector": "puts", - "start_col": 4, - "start_line": 3, - "type": "send", - "values": [ - { - "end_col": 10, - "end_line": 3, - "start_col": 9, - "start_line": 3, - "token": "x", - "type": "lvar" - } - ] + "@type": "hash", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 7 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 7 + }, + "@token": 1, + "@type": "int" }, - { - "base": null, - "end_col": 10, - "end_line": 4, - "selector": "puts", - "start_col": 4, - "start_line": 4, - "type": "send", - "values": [ - { - "end_col": 10, - "end_line": 4, - "start_col": 9, - "start_line": 4, - "token": 1, - "type": "int" - } - ] + "_2": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 7 + }, + "@token": 1, + "@type": "int" } - ], - "end_col": 10, - "end_line": 4, - "start_col": 4, - "start_line": 3, - "type": "begin" - }, - "end_col": 3, - "end_line": 5, - "start_col": 0, - "start_line": 2, - "type": "block" - }, - { - "end_col": 20, - "end_line": 7, - "start_col": 0, - "start_line": 7, - "target": "b", - "type": "lvasgn", - "value": { - "contents": [ - { - "_1": { - "end_col": 6, - "end_line": 7, - "start_col": 5, - "start_line": 7, - "token": 1, - "type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 7 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 7 }, - "_2": { - "end_col": 11, - "end_line": 7, - "start_col": 10, - "start_line": 7, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 7 }, - "end_col": 11, - "end_line": 7, - "start_col": 5, - "start_line": 7, - "type": "pair" + "@token": 2, + "@type": "int" }, - { - "_1": { - "end_col": 14, - "end_line": 7, - "start_col": 13, - "start_line": 7, - "token": 2, - "type": "int" + "_2": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 7 }, - "_2": { - "end_col": 19, - "end_line": 7, - "start_col": 18, - "start_line": 7, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 19, + "line": 7 }, - "end_col": 19, - "end_line": 7, - "start_col": 13, - "start_line": 7, - "type": "pair" + "@token": 2, + "@type": "int" } - ], - "end_col": 20, - "end_line": 7, - "start_col": 4, - "start_line": 7, - "type": "hash" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@type": "block", + "args": [ + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 8 + }, + "@token": "k", + "@type": "arg" + }, + { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 8 + }, + "@token": "v", + "@type": "arg" } + ], + "blockdata": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@type": "send_statement", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@token": "b", + "@type": "lvar" + }, + "selector": "each" }, - { - "args": [ + "body": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 9 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ { - "end_col": 12, - "end_line": 8, - "start_col": 11, - "start_line": 8, - "token": "k", - "type": "arg" + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@token": "k", + "@type": "lvar" }, { - "end_col": 15, - "end_line": 8, - "start_col": 14, - "start_line": 8, - "token": "v", - "type": "arg" - } - ], - "blockdata": { - "base": { - "end_col": 1, - "end_line": 8, - "start_col": 0, - "start_line": 8, - "token": "b", - "type": "lvar" - }, - "end_col": 6, - "end_line": 8, - "selector": "each", - "start_col": 0, - "start_line": 8, - "type": "send" - }, - "body": { - "base": null, - "end_col": 13, - "end_line": 9, - "selector": "puts", - "start_col": 4, - "start_line": 9, - "type": "send", - "values": [ - { - "end_col": 10, - "end_line": 9, - "start_col": 9, - "start_line": 9, - "token": "k", - "type": "lvar" + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 9 }, - { - "end_col": 13, - "end_line": 9, - "start_col": 12, - "start_line": 9, - "token": "v", - "type": "lvar" - } - ] - }, - "end_col": 3, - "end_line": 10, - "start_col": 0, - "start_line": 8, - "type": "block" + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 9 + }, + "@token": "v", + "@type": "lvar" + } + ] } - ], - "end_col": 3, - "end_line": 10, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/blockargs.rb.uast b/fixtures/blockargs.rb.uast index 122493c..424543e 100644 --- a/fixtures/blockargs.rb.uast +++ b/fixtures/blockargs.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -125,25 +125,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: arg { -. . . . . . . Roles: Expression,Argument,Incomplete -. . . . . . . TOKEN "x" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 25 -. . . . . . . . Line: 2 -. . . . . . . . Col: 12 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 25 -. . . . . . . . Line: 2 -. . . . . . . . Col: 12 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: args -. . . . . . . } -. . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Identifier,Statement,For,Iterator +. . . . . . 0: send_statement { +. . . . . . . Roles: For,Iterator,Statement . . . . . . . TOKEN "each" . . . . . . . StartPosition: { . . . . . . . . Offset: 14 @@ -178,8 +161,25 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } +. . . . . . 1: arg { +. . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . TOKEN "x" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 25 +. . . . . . . . Line: 2 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 25 +. . . . . . . . Line: 2 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: args +. . . . . . . } +. . . . . . } . . . . . . 2: begin { -. . . . . . . Roles: Block +. . . . . . . Roles: Block,Body . . . . . . . StartPosition: { . . . . . . . . Offset: 32 . . . . . . . . Line: 3 @@ -194,9 +194,8 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: send { -. . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . TOKEN "puts" +. . . . . . . . 0: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 32 . . . . . . . . . . Line: 3 @@ -209,10 +208,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: body +. . . . . . . . . . selector: puts . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: lvar { -. . . . . . . . . . . Roles: Expression,Identifier,Argument +. . . . . . . . . . . Roles: Expression,Identifier . . . . . . . . . . . TOKEN "x" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 37 @@ -230,9 +230,8 @@ UAST: . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: send { -. . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . TOKEN "puts" +. . . . . . . . 1: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 43 . . . . . . . . . . Line: 4 @@ -245,10 +244,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: body +. . . . . . . . . . selector: puts . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 48 @@ -271,7 +271,7 @@ UAST: . . . . . } . . . . } . . . . 2: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 55 @@ -288,7 +288,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: hash { -. . . . . . . Roles: Right,Expression,Literal,Map,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Map,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 59 . . . . . . . . Line: 7 @@ -304,7 +304,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: pair { -. . . . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 60 . . . . . . . . . . Line: 7 @@ -320,7 +320,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 60 @@ -337,7 +337,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 65 @@ -356,7 +356,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: pair { -. . . . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 68 . . . . . . . . . . Line: 7 @@ -372,7 +372,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "2" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 68 @@ -389,7 +389,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "2" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 73 @@ -427,42 +427,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: arg { -. . . . . . . Roles: Expression,Argument,Incomplete -. . . . . . . TOKEN "k" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 87 -. . . . . . . . Line: 8 -. . . . . . . . Col: 12 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 87 -. . . . . . . . Line: 8 -. . . . . . . . Col: 12 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: args -. . . . . . . } -. . . . . . } -. . . . . . 1: arg { -. . . . . . . Roles: Expression,Argument,Incomplete -. . . . . . . TOKEN "v" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 90 -. . . . . . . . Line: 8 -. . . . . . . . Col: 15 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 90 -. . . . . . . . Line: 8 -. . . . . . . . Col: 15 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: args -. . . . . . . } -. . . . . . } -. . . . . . 2: send { -. . . . . . . Roles: Expression,Identifier,Statement,For,Iterator +. . . . . . 0: send_statement { +. . . . . . . Roles: For,Iterator,Statement . . . . . . . TOKEN "each" . . . . . . . StartPosition: { . . . . . . . . Offset: 76 @@ -497,9 +463,42 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 3: send { -. . . . . . . Roles: Expression,Call,Identifier -. . . . . . . TOKEN "puts" +. . . . . . 1: arg { +. . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . TOKEN "k" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 87 +. . . . . . . . Line: 8 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 87 +. . . . . . . . Line: 8 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: args +. . . . . . . } +. . . . . . } +. . . . . . 2: arg { +. . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . TOKEN "v" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 90 +. . . . . . . . Line: 8 +. . . . . . . . Col: 15 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 90 +. . . . . . . . Line: 8 +. . . . . . . . Col: 15 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: args +. . . . . . . } +. . . . . . } +. . . . . . 3: send_qualified { +. . . . . . . Roles: Body,Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 97 . . . . . . . . Line: 9 @@ -512,10 +511,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: body +. . . . . . . . selector: puts . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvar { -. . . . . . . . . Roles: Expression,Identifier,Argument +. . . . . . . . . Roles: Expression,Identifier . . . . . . . . . TOKEN "k" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 102 @@ -532,7 +532,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: lvar { -. . . . . . . . . Roles: Expression,Identifier,Argument +. . . . . . . . . Roles: Expression,Identifier . . . . . . . . . TOKEN "v" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 105 diff --git a/fixtures/break.rb.native b/fixtures/break.rb.native index 8c95479..70f2aa4 100644 --- a/fixtures/break.rb.native +++ b/fixtures/break.rb.native @@ -3,107 +3,178 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": null, - "type": "break" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "while", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "condition": { - "end_col": 10, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "type": "true" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "while" + "@type": "break", + "target": null }, - { - "body": { - "body": [ - { - "base": null, - "end_col": 10, - "end_line": 6, - "selector": "puts", - "start_col": 4, - "start_line": 6, - "type": "send", - "values": [ - { - "end_col": 10, - "end_line": 6, - "start_col": 9, - "start_line": 6, - "token": 1, - "type": "int" - } - ] + "condition": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "true" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "while", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 6 }, - { - "end_col": 9, - "end_line": 7, - "start_col": 4, - "start_line": 7, - "target": null, - "type": "break" - } - ], - "end_col": 9, - "end_line": 7, - "start_col": 4, - "start_line": 6, - "type": "begin" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 6 + }, + "@token": 1, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@type": "break", + "target": null + } + ] + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 5 }, - "condition": { - "base": { - "end_col": 7, - "end_line": 5, - "start_col": 6, - "start_line": 5, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 5 }, - "end_col": 12, - "end_line": 5, - "selector": "!=", - "start_col": 6, - "start_line": 5, - "type": "send", - "values": [ - { - "end_col": 12, - "end_line": 5, - "start_col": 11, - "start_line": 5, - "token": 2, - "type": "int" - } - ] + "@token": 1, + "@type": "int" }, - "end_col": 5, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "type": "while" + "selector": "!=", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 5 + }, + "@token": 2, + "@type": "int" + } + ] } - ], - "end_col": 3, - "end_line": 8, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/break.rb.uast b/fixtures/break.rb.uast index 9ab53df..10eafa0 100644 --- a/fixtures/break.rb.uast +++ b/fixtures/break.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,7 +18,7 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: while { @@ -37,24 +37,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: break { -. . . . . . . Roles: Expression,While,Body,Statement,Break -. . . . . . . StartPosition: { -. . . . . . . . Offset: 15 -. . . . . . . . Line: 2 -. . . . . . . . Col: 5 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 19 -. . . . . . . . Line: 2 -. . . . . . . . Col: 9 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: body -. . . . . . . } -. . . . . . } -. . . . . . 1: true { -. . . . . . . Roles: Expression,Condition,While,Boolean,Literal +. . . . . . 0: true { +. . . . . . . Roles: Boolean,Condition,Expression,Literal . . . . . . . TOKEN "true" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -70,6 +54,22 @@ UAST: . . . . . . . . internalRole: condition . . . . . . . } . . . . . . } +. . . . . . 1: break { +. . . . . . . Roles: Body,Break,Statement +. . . . . . . StartPosition: { +. . . . . . . . Offset: 15 +. . . . . . . . Line: 2 +. . . . . . . . Col: 5 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 19 +. . . . . . . . Line: 2 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . } . . . . . } . . . . } . . . . 1: while { @@ -88,8 +88,61 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: begin { -. . . . . . . Roles: Block,Expression,While,Body +. . . . . . 0: send_operator { +. . . . . . . Roles: Binary,Condition,Equal,Expression,Not,Operator,Relational +. . . . . . . TOKEN "!=" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 32 +. . . . . . . . Line: 5 +. . . . . . . . Col: 7 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 37 +. . . . . . . . Line: 5 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: condition +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: int { +. . . . . . . . . Roles: Expression,Left,Literal,Number,Primitive +. . . . . . . . . TOKEN "1" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 32 +. . . . . . . . . . Line: 5 +. . . . . . . . . . Col: 7 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 32 +. . . . . . . . . . Line: 5 +. . . . . . . . . . Col: 7 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: base +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: int { +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Right +. . . . . . . . . TOKEN "2" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 37 +. . . . . . . . . . Line: 5 +. . . . . . . . . . Col: 12 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 37 +. . . . . . . . . . Line: 5 +. . . . . . . . . . Col: 12 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: values +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . . 1: begin { +. . . . . . . Roles: Block,Body . . . . . . . StartPosition: { . . . . . . . . Offset: 43 . . . . . . . . Line: 6 @@ -104,9 +157,8 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: send { -. . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . TOKEN "puts" +. . . . . . . . 0: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 43 . . . . . . . . . . Line: 6 @@ -119,10 +171,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: body +. . . . . . . . . . selector: puts . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 48 @@ -141,7 +194,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: break { -. . . . . . . . . Roles: Statement,Break +. . . . . . . . . Roles: Break,Statement . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 54 . . . . . . . . . . Line: 7 @@ -158,59 +211,6 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Identifier,Operator,Relational,Equal,Not,Condition,While -. . . . . . . TOKEN "!=" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 32 -. . . . . . . . Line: 5 -. . . . . . . . Col: 7 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 37 -. . . . . . . . Line: 5 -. . . . . . . . Col: 12 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: condition -. . . . . . . } -. . . . . . . Children: { -. . . . . . . . 0: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive -. . . . . . . . . TOKEN "1" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 32 -. . . . . . . . . . Line: 5 -. . . . . . . . . . Col: 7 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 32 -. . . . . . . . . . Line: 5 -. . . . . . . . . . Col: 7 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: base -. . . . . . . . . } -. . . . . . . . } -. . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive -. . . . . . . . . TOKEN "2" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 37 -. . . . . . . . . . Line: 5 -. . . . . . . . . . Col: 12 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 37 -. . . . . . . . . . Line: 5 -. . . . . . . . . . Col: 12 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: values -. . . . . . . . . } -. . . . . . . . } -. . . . . . . } -. . . . . . } . . . . . } . . . . } . . . } diff --git a/fixtures/case.rb.native b/fixtures/case.rb.native index 0db3bc5..a7bd212 100644 --- a/fixtures/case.rb.native +++ b/fixtures/case.rb.native @@ -3,139 +3,228 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 7, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "foo", - "type": "lvasgn", + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "foo", + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "case", + "casevar": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@token": "foo", + "@type": "lvar" + }, + "else": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 9 + }, + "@type": "lvasgn", + "target": "a", "value": { - "end_col": 7, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "token": 1, - "type": "int" + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 9 + }, + "@token": 100, + "@type": "int" } }, - { - "casevar": { - "end_col": 8, - "end_line": 3, - "start_col": 5, - "start_line": 3, - "token": "foo", - "type": "lvar" - }, - "else": { - "end_col": 11, - "end_line": 9, - "start_col": 4, - "start_line": 9, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 11, - "end_line": 9, - "start_col": 8, - "start_line": 9, - "token": 100, - "type": "int" - } + "when_clauses": [ + { + "@type": "when", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 5 + }, + "@token": 1, + "@type": "int" + } + }, + "conditions": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@token": 1, + "@type": "int" + } + ] }, - "end_col": 4, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "type": "case", - "when_clauses": [ - { - "body": { - "end_col": 9, - "end_line": 5, - "start_col": 4, - "start_line": 5, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 5, - "start_col": 8, - "start_line": 5, - "token": 1, - "type": "int" - } + { + "@type": "when", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 7 }, - "conditions": [ - { - "end_col": 6, - "end_line": 4, - "start_col": 5, - "start_line": 4, - "token": 1, - "type": "int" - } - ], - "type": "when" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@token": 3, + "@type": "int" + } }, - { - "body": { - "end_col": 9, - "end_line": 7, - "start_col": 4, - "start_line": 7, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 7, - "start_col": 8, - "start_line": 7, - "token": 3, - "type": "int" - } + "conditions": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@token": 2, + "@type": "int" }, - "conditions": [ - { - "end_col": 6, - "end_line": 6, - "start_col": 5, - "start_line": 6, - "token": 2, - "type": "int" + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 }, - { - "end_col": 9, - "end_line": 6, - "start_col": 8, - "start_line": 6, - "token": 3, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 }, - { - "end_col": 12, - "end_line": 6, - "start_col": 11, - "start_line": 6, - "token": 4, - "type": "int" - } - ], - "type": "when" - } - ] - } - ], - "end_col": 3, - "end_line": 10, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "@token": 3, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 6 + }, + "@token": 4, + "@type": "int" + } + ] + } + ] + } + ] } } } diff --git a/fixtures/case.rb.uast b/fixtures/case.rb.uast index d7ba645..ea515e3 100644 --- a/fixtures/case.rb.uast +++ b/fixtures/case.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "foo" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -90,50 +90,31 @@ UAST: . . . . . . . . internalRole: casevar . . . . . . . } . . . . . . } -. . . . . . 1: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left -. . . . . . . TOKEN "a" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 67 -. . . . . . . . Line: 9 -. . . . . . . . Col: 5 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 73 -. . . . . . . . Line: 9 -. . . . . . . . Col: 11 -. . . . . . . } +. . . . . . 1: when { +. . . . . . . Roles: Case,Expression . . . . . . . Properties: { -. . . . . . . . internalRole: else +. . . . . . . . internalRole: when_clauses . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive -. . . . . . . . . TOKEN "100" +. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 71 -. . . . . . . . . . Line: 9 -. . . . . . . . . . Col: 9 +. . . . . . . . . . Offset: 23 +. . . . . . . . . . Line: 4 +. . . . . . . . . . Col: 6 . . . . . . . . . } . . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 73 -. . . . . . . . . . Line: 9 -. . . . . . . . . . Col: 11 +. . . . . . . . . . Offset: 23 +. . . . . . . . . . Line: 4 +. . . . . . . . . . Col: 6 . . . . . . . . . } . . . . . . . . . Properties: { -. . . . . . . . . . internalRole: value +. . . . . . . . . . internalRole: conditions . . . . . . . . . } . . . . . . . . } -. . . . . . . } -. . . . . . } -. . . . . . 2: when { -. . . . . . . Roles: Expression,Case -. . . . . . . Properties: { -. . . . . . . . internalRole: when_clauses -. . . . . . . } -. . . . . . . Children: { -. . . . . . . . 0: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . 1: lvasgn { +. . . . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 29 @@ -150,7 +131,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 33 @@ -168,68 +149,15 @@ UAST: . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive -. . . . . . . . . TOKEN "1" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 23 -. . . . . . . . . . Line: 4 -. . . . . . . . . . Col: 6 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 23 -. . . . . . . . . . Line: 4 -. . . . . . . . . . Col: 6 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: conditions -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 3: when { -. . . . . . . Roles: Expression,Case +. . . . . . 2: when { +. . . . . . . Roles: Case,Expression . . . . . . . Properties: { . . . . . . . . internalRole: when_clauses . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left -. . . . . . . . . TOKEN "a" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 52 -. . . . . . . . . . Line: 7 -. . . . . . . . . . Col: 5 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 56 -. . . . . . . . . . Line: 7 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . . Children: { -. . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive -. . . . . . . . . . . TOKEN "3" -. . . . . . . . . . . StartPosition: { -. . . . . . . . . . . . Offset: 56 -. . . . . . . . . . . . Line: 7 -. . . . . . . . . . . . Col: 9 -. . . . . . . . . . . } -. . . . . . . . . . . EndPosition: { -. . . . . . . . . . . . Offset: 56 -. . . . . . . . . . . . Line: 7 -. . . . . . . . . . . . Col: 9 -. . . . . . . . . . . } -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: value -. . . . . . . . . . . } -. . . . . . . . . . } -. . . . . . . . . } -. . . . . . . . } -. . . . . . . . 1: int { +. . . . . . . . 0: int { . . . . . . . . . Roles: Expression,Literal,Number,Primitive . . . . . . . . . TOKEN "2" . . . . . . . . . StartPosition: { @@ -246,7 +174,7 @@ UAST: . . . . . . . . . . internalRole: conditions . . . . . . . . . } . . . . . . . . } -. . . . . . . . 2: int { +. . . . . . . . 1: int { . . . . . . . . . Roles: Expression,Literal,Number,Primitive . . . . . . . . . TOKEN "3" . . . . . . . . . StartPosition: { @@ -263,7 +191,7 @@ UAST: . . . . . . . . . . internalRole: conditions . . . . . . . . . } . . . . . . . . } -. . . . . . . . 3: int { +. . . . . . . . 2: int { . . . . . . . . . Roles: Expression,Literal,Number,Primitive . . . . . . . . . TOKEN "4" . . . . . . . . . StartPosition: { @@ -280,6 +208,78 @@ UAST: . . . . . . . . . . internalRole: conditions . . . . . . . . . } . . . . . . . . } +. . . . . . . . 3: lvasgn { +. . . . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left +. . . . . . . . . TOKEN "a" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 52 +. . . . . . . . . . Line: 7 +. . . . . . . . . . Col: 5 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 56 +. . . . . . . . . . Line: 7 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . . Children: { +. . . . . . . . . . 0: int { +. . . . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right +. . . . . . . . . . . TOKEN "3" +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 56 +. . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . Col: 9 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 56 +. . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . Col: 9 +. . . . . . . . . . . } +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: value +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . . 3: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left +. . . . . . . TOKEN "a" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 67 +. . . . . . . . Line: 9 +. . . . . . . . Col: 5 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 73 +. . . . . . . . Line: 9 +. . . . . . . . Col: 11 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: else +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: int { +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right +. . . . . . . . . TOKEN "100" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 71 +. . . . . . . . . . Line: 9 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 73 +. . . . . . . . . . Line: 9 +. . . . . . . . . . Col: 11 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: value +. . . . . . . . . } +. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } diff --git a/fixtures/class_bare.rb.native b/fixtures/class_bare.rb.native index ddabf5c..ada77f2 100644 --- a/fixtures/class_bare.rb.native +++ b/fixtures/class_bare.rb.native @@ -3,21 +3,26 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Foo", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Foo", + "@type": "class", + "body": [ + { + "@type": "NilNode" + } + ], + "parent": null } } } diff --git a/fixtures/class_bare.rb.uast b/fixtures/class_bare.rb.uast index ef06302..2d06175 100644 --- a/fixtures/class_bare.rb.uast +++ b/fixtures/class_bare.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Foo" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: NilClass { -. . . . . Roles: Statement,Type,Null +. . . . 0: NilNode { +. . . . . Roles: Null . . . . . Properties: { . . . . . . internalRole: body . . . . . } diff --git a/fixtures/class_complete.rb.native b/fixtures/class_complete.rb.native index 42ab4d3..82b8ed1 100644 --- a/fixtures/class_complete.rb.native +++ b/fixtures/class_complete.rb.native @@ -3,287 +3,472 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "begin": [ - { - "body": [ - { - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 5, - "end_line": 3, - "name": "Foo", - "parent": null, - "start_col": 0, - "start_line": 3, - "type": "class" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "FooMod", + "@type": "module", + "begin": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 25 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 3 }, - { - "body": [ - { - "body": [ - { - "end_col": 19, - "end_line": 7, - "start_col": 4, - "start_line": 7, - "target": "@@classvar", - "type": "cvasgn", - "value": { - "end_col": 19, - "end_line": 7, - "start_col": 17, - "start_line": 7, - "token": 10, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@token": "Foo", + "@type": "class", + "body": [ + { + "@type": "NilNode" + } + ], + "parent": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@token": "Bar", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 24 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 7 }, - { - "args": { - "children": [ - { - "end_col": 20, - "end_line": 8, - "start_col": 19, - "start_line": 8, - "token": "a", - "type": "arg" - } - ], - "end_col": 21, - "end_line": 8, - "start_col": 18, - "start_line": 8, - "type": "args" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@type": "cvasgn", + "target": "@@classvar", + "value": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 7 }, - "body": [ - { - "end_col": 25, - "end_line": 9, - "start_col": 8, - "start_line": 9, - "target": "@instance_var", - "type": "ivasgn", - "value": { - "end_col": 25, - "end_line": 9, - "start_col": 24, - "start_line": 9, - "token": "a", - "type": "lvar" - } - } - ], - "end_col": 7, - "end_line": 8, - "name": "initialize", - "start_col": 4, - "start_line": 8, - "type": "def" + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 7 + }, + "@token": 10, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 8 }, - { - "args": { - "end_col": 13, - "end_line": 12, - "start_col": 11, - "start_line": 12, - "type": "args" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 8 + }, + "@token": "initialize", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 19, + "line": 8 }, - "body": [ + "@type": "args", + "children": [ { - "type": "NilClass" + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 20, + "line": 8 + }, + "@token": "a", + "@type": "arg" } - ], - "end_col": 7, - "end_line": 12, - "name": "foo", - "start_col": 4, - "start_line": 12, - "type": "def" + ] + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 25, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 9 + }, + "@type": "ivasgn", + "target": "@instance_var", + "value": { + "@end": { + "@type": "ast:Position", + "col": 25, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 25, + "line": 9 + }, + "@token": "a", + "@type": "lvar" + } + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 12 }, - { - "args": { - "end_col": 13, - "end_line": 15, - "start_col": 11, - "start_line": 15, - "type": "args" + "@token": "foo", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 12 }, - "body": [ - { - "body": [ - { - "base": null, - "end_col": 23, - "end_line": 16, - "selector": "puts", - "start_col": 8, - "start_line": 16, - "type": "send", - "values": [ - { - "end_col": 23, - "end_line": 16, - "start_col": 13, - "start_line": 16, - "token": "@@classvar", - "type": "cvar" - } - ] + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 12 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 15 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 15 + }, + "@token": "use", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 15 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 15 + }, + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 19 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 16 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 23, + "line": 16 }, - { - "base": null, - "end_col": 26, - "end_line": 17, - "selector": "puts", - "start_col": 8, - "start_line": 17, - "type": "send", - "values": [ - { - "end_col": 26, - "end_line": 17, - "start_col": 13, - "start_line": 17, - "token": "@instance_var", - "type": "ivar" - } - ] + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 16 }, - { - "base": null, - "end_col": 13, - "end_line": 18, - "selector": "foo", - "start_col": 8, - "start_line": 18, - "type": "send" + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 23, + "line": 16 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 16 + }, + "@token": "@@classvar", + "@type": "cvar" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 26, + "line": 17 }, - { - "base": { - "end_col": 12, - "end_line": 19, - "start_col": 8, - "start_line": 19, - "type": "self" - }, - "end_col": 18, - "end_line": 19, - "selector": "foo", - "start_col": 8, - "start_line": 19, - "type": "send" - } - ], - "end_col": 18, - "end_line": 19, - "start_col": 8, - "start_line": 16, - "type": "begin" - } - ], - "end_col": 7, - "end_line": 15, - "name": "use", - "start_col": 4, - "start_line": 15, - "type": "def" - }, - { - "args": { - "end_col": 22, - "end_line": 22, - "start_col": 20, - "start_line": 22, - "type": "args" - }, - "body": [ - { - "end_col": 22, - "end_line": 23, - "start_col": 8, - "start_line": 23, - "target": "b", - "type": "lvasgn", - "value": { - "base": { - "base": null, - "end_col": 15, - "end_line": 23, - "start_col": 12, - "start_line": 23, - "token": "Bar", - "type": "const" + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 17 }, - "end_col": 22, - "end_line": 23, - "selector": "new", - "start_col": 12, - "start_line": 23, - "type": "send", + "@type": "send_qualified", + "base": null, + "selector": "puts", "values": [ { - "end_col": 21, - "end_line": 23, - "start_col": 20, - "start_line": 23, - "token": 1, - "type": "int" + "@end": { + "@type": "ast:Position", + "col": 26, + "line": 17 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 17 + }, + "@token": "@instance_var", + "@type": "ivar" } ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 18 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 18 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 19 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 19 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 19 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 19 + }, + "@type": "self" + }, + "selector": "foo" } + ] + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 22 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 22 + }, + "@token": "selfinstance", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 22, + "line": 22 + }, + "@start": { + "@type": "ast:Position", + "col": 21, + "line": 22 + }, + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 22, + "line": 23 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 23 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 22, + "line": 23 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 23 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 23 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 23 + }, + "@token": "Bar", + "@type": "const", + "base": null + }, + "selector": "new", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 23 + }, + "@start": { + "@type": "ast:Position", + "col": 21, + "line": 23 + }, + "@token": 1, + "@type": "int" + } + ] } - ], - "end_col": 7, - "end_line": 22, - "name": "selfinstance", - "start_col": 4, - "start_line": 22, - "type": "def" - } - ], - "end_col": 7, - "end_line": 24, - "start_col": 4, - "start_line": 7, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 6, - "name": "Bar", - "parent": { - "base": null, - "end_col": 15, - "end_line": 6, - "start_col": 12, - "start_line": 6, - "token": "Foo", - "type": "const" + } + ] + } + ] + } + ], + "parent": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 6 }, - "start_col": 0, - "start_line": 6, - "type": "class" + "@token": "Foo", + "@type": "const", + "base": null } - ], - "end_col": 3, - "end_line": 25, - "start_col": 0, - "start_line": 3, - "type": "begin" - } - ], - "end_col": 6, - "end_line": 1, - "name": "FooMod", - "start_col": 0, - "start_line": 1, - "type": "module" - } + } + ] + } + ] } } } diff --git a/fixtures/class_complete.rb.uast b/fixtures/class_complete.rb.uast index 940343b..f13a4fa 100644 --- a/fixtures/class_complete.rb.uast +++ b/fixtures/class_complete.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: module { -. . . Roles: Statement,Module,Identifier +. . . Roles: Identifier,Module,Statement . . . TOKEN "FooMod" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: begin { @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: class { -. . . . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . . . Roles: Declaration,Identifier,Statement,Type . . . . . . . TOKEN "Foo" . . . . . . . StartPosition: { . . . . . . . . Offset: 15 @@ -55,8 +55,8 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: NilClass { -. . . . . . . . . Roles: Statement,Type,Null +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null . . . . . . . . . Properties: { . . . . . . . . . . internalRole: body . . . . . . . . . } @@ -64,7 +64,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: class { -. . . . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . . . Roles: Declaration,Identifier,Statement,Type . . . . . . . TOKEN "Bar" . . . . . . . StartPosition: { . . . . . . . . Offset: 30 @@ -80,7 +80,24 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: begin { +. . . . . . . . 0: const { +. . . . . . . . . Roles: Expression,Identifier,Incomplete +. . . . . . . . . TOKEN "Foo" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 42 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 13 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 44 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 15 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: parent +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: begin { . . . . . . . . . Roles: Block . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 50 @@ -97,7 +114,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: cvasgn { -. . . . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . . . TOKEN "@@classvar" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 50 @@ -114,7 +131,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: int { -. . . . . . . . . . . . . Roles: Binary,Right,Expression,Literal,Number,Primitive +. . . . . . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . . . . . TOKEN "10" . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 63 @@ -133,7 +150,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: def { -. . . . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . . . TOKEN "initialize" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 70 @@ -150,7 +167,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: args { -. . . . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 84 . . . . . . . . . . . . . . Line: 8 @@ -166,7 +183,7 @@ UAST: . . . . . . . . . . . . . } . . . . . . . . . . . . . Children: { . . . . . . . . . . . . . . 0: arg { -. . . . . . . . . . . . . . . Roles: Expression,Argument,Name +. . . . . . . . . . . . . . . Roles: Argument,Expression,Identifier,Name . . . . . . . . . . . . . . . TOKEN "a" . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 85 @@ -185,7 +202,7 @@ UAST: . . . . . . . . . . . . . } . . . . . . . . . . . . } . . . . . . . . . . . . 1: ivasgn { -. . . . . . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . . . . . TOKEN "@instance_var" . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 96 @@ -202,7 +219,7 @@ UAST: . . . . . . . . . . . . . } . . . . . . . . . . . . . Children: { . . . . . . . . . . . . . . 0: lvar { -. . . . . . . . . . . . . . . Roles: Right,Binary,Expression,Identifier +. . . . . . . . . . . . . . . Roles: Binary,Expression,Identifier,Right . . . . . . . . . . . . . . . TOKEN "a" . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 112 @@ -223,7 +240,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 2: def { -. . . . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . . . TOKEN "foo" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 127 @@ -239,8 +256,14 @@ UAST: . . . . . . . . . . . . internalRole: body . . . . . . . . . . . } . . . . . . . . . . . Children: { -. . . . . . . . . . . . 0: args { -. . . . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . . . 0: NilNode { +. . . . . . . . . . . . . Roles: Null +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: body +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . . 1: args { +. . . . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 134 . . . . . . . . . . . . . . Line: 12 @@ -255,16 +278,10 @@ UAST: . . . . . . . . . . . . . . internalRole: args . . . . . . . . . . . . . } . . . . . . . . . . . . } -. . . . . . . . . . . . 1: NilClass { -. . . . . . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . . . . . Properties: { -. . . . . . . . . . . . . . internalRole: body -. . . . . . . . . . . . . } -. . . . . . . . . . . . } . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 3: def { -. . . . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . . . TOKEN "use" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 150 @@ -281,7 +298,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: args { -. . . . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 157 . . . . . . . . . . . . . . Line: 15 @@ -312,9 +329,8 @@ UAST: . . . . . . . . . . . . . . internalRole: body . . . . . . . . . . . . . } . . . . . . . . . . . . . Children: { -. . . . . . . . . . . . . . 0: send { -. . . . . . . . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . . . . . . . TOKEN "puts" +. . . . . . . . . . . . . . 0: send_qualified { +. . . . . . . . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 168 . . . . . . . . . . . . . . . . Line: 16 @@ -327,10 +343,11 @@ UAST: . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . Properties: { . . . . . . . . . . . . . . . . internalRole: body +. . . . . . . . . . . . . . . . selector: puts . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . Children: { . . . . . . . . . . . . . . . . 0: cvar { -. . . . . . . . . . . . . . . . . Roles: Expression,Identifier,Visibility,Type,Argument +. . . . . . . . . . . . . . . . . Roles: Expression,Identifier,Type,Visibility . . . . . . . . . . . . . . . . . TOKEN "@@classvar" . . . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . . . Offset: 173 @@ -348,9 +365,8 @@ UAST: . . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . } -. . . . . . . . . . . . . . 1: send { -. . . . . . . . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . . . . . . . TOKEN "puts" +. . . . . . . . . . . . . . 1: send_qualified { +. . . . . . . . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 192 . . . . . . . . . . . . . . . . Line: 17 @@ -363,10 +379,11 @@ UAST: . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . Properties: { . . . . . . . . . . . . . . . . internalRole: body +. . . . . . . . . . . . . . . . selector: puts . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . Children: { . . . . . . . . . . . . . . . . 0: ivar { -. . . . . . . . . . . . . . . . . Roles: Expression,Identifier,Visibility,Instance,Argument +. . . . . . . . . . . . . . . . . Roles: Expression,Identifier,Instance,Visibility . . . . . . . . . . . . . . . . . TOKEN "@instance_var" . . . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . . . Offset: 197 @@ -384,9 +401,8 @@ UAST: . . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . } -. . . . . . . . . . . . . . 2: send { -. . . . . . . . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . . . . . . . TOKEN "foo" +. . . . . . . . . . . . . . 2: send_qualified { +. . . . . . . . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 219 . . . . . . . . . . . . . . . . Line: 18 @@ -399,10 +415,11 @@ UAST: . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . Properties: { . . . . . . . . . . . . . . . . internalRole: body +. . . . . . . . . . . . . . . . selector: foo . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . } -. . . . . . . . . . . . . . 3: send { -. . . . . . . . . . . . . . . Roles: Expression,Identifier,Call +. . . . . . . . . . . . . . 3: send_call { +. . . . . . . . . . . . . . . Roles: Call,Expression,Function . . . . . . . . . . . . . . . TOKEN "foo" . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 233 @@ -419,7 +436,7 @@ UAST: . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . Children: { . . . . . . . . . . . . . . . . 0: self { -. . . . . . . . . . . . . . . . . Roles: Expression,This,Left +. . . . . . . . . . . . . . . . . Roles: Expression,Left,This . . . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . . . Offset: 233 . . . . . . . . . . . . . . . . . . Line: 19 @@ -441,7 +458,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 4: def { -. . . . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . . . TOKEN "selfinstance" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 257 @@ -458,7 +475,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: args { -. . . . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 273 . . . . . . . . . . . . . . Line: 22 @@ -474,7 +491,7 @@ UAST: . . . . . . . . . . . . . } . . . . . . . . . . . . } . . . . . . . . . . . . 1: lvasgn { -. . . . . . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . . . . . TOKEN "b" . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 284 @@ -490,8 +507,8 @@ UAST: . . . . . . . . . . . . . . internalRole: body . . . . . . . . . . . . . } . . . . . . . . . . . . . Children: { -. . . . . . . . . . . . . . 0: send { -. . . . . . . . . . . . . . . Roles: Right,Expression,Identifier +. . . . . . . . . . . . . . 0: send_call { +. . . . . . . . . . . . . . . Roles: Binary,Call,Expression,Function,Right . . . . . . . . . . . . . . . TOKEN "new" . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 288 @@ -525,7 +542,7 @@ UAST: . . . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . . } . . . . . . . . . . . . . . . . 1: int { -. . . . . . . . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . . . . . . . Roles: Argument,Call,Expression,Function,Literal,Number,Primitive . . . . . . . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . . . Offset: 296 @@ -549,23 +566,6 @@ UAST: . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: const { -. . . . . . . . . Roles: Expression,Identifier,Incomplete -. . . . . . . . . TOKEN "Foo" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 42 -. . . . . . . . . . Line: 6 -. . . . . . . . . . Col: 13 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 44 -. . . . . . . . . . Line: 6 -. . . . . . . . . . Col: 15 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: parent -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } diff --git a/fixtures/class_singleton.rb.native b/fixtures/class_singleton.rb.native index 8c0aa0d..d05a6f8 100644 --- a/fixtures/class_singleton.rb.native +++ b/fixtures/class_singleton.rb.native @@ -3,68 +3,109 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 8, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "foo", - "type": "lvasgn", - "value": { - "end_col": 8, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "type": "array" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "foo", + "value": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "array" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 }, - { - "body": [ - { - "args": { - "end_col": 15, - "end_line": 4, - "start_col": 13, - "start_line": 4, - "type": "args" + "@type": "sclass", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@token": "added", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 4 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 4, - "name": "added", - "start_col": 4, - "start_line": 4, - "type": "def" - } - ], - "end_col": 5, - "end_line": 3, - "object": { - "end_col": 12, - "end_line": 3, - "start_col": 9, - "start_line": 3, - "token": "foo", - "type": "lvar" + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ], + "object": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 3 }, - "start_col": 0, - "start_line": 3, - "type": "sclass" + "@token": "foo", + "@type": "lvar" } - ], - "end_col": 3, - "end_line": 6, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/class_singleton.rb.uast b/fixtures/class_singleton.rb.uast index f36139b..23f8c01 100644 --- a/fixtures/class_singleton.rb.uast +++ b/fixtures/class_singleton.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "foo" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 6 . . . . . . . . Line: 1 @@ -57,7 +57,7 @@ UAST: . . . . . } . . . . } . . . . 1: sclass { -. . . . . Roles: Expression,Type,Declaration,Incomplete +. . . . . Roles: Declaration,Expression,Incomplete,Type . . . . . StartPosition: { . . . . . . Offset: 10 . . . . . . Line: 3 @@ -72,8 +72,25 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . 0: lvar { +. . . . . . . Roles: Expression,Identifier +. . . . . . . TOKEN "foo" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 19 +. . . . . . . . Line: 3 +. . . . . . . . Col: 10 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 21 +. . . . . . . . Line: 3 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: object +. . . . . . . } +. . . . . . } +. . . . . . 1: def { +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "added" . . . . . . . StartPosition: { . . . . . . . . Offset: 27 @@ -89,8 +106,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 36 . . . . . . . . . . Line: 4 @@ -105,29 +128,6 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } -. . . . . . . } -. . . . . . } -. . . . . . 1: lvar { -. . . . . . . Roles: Expression,Identifier -. . . . . . . TOKEN "foo" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 19 -. . . . . . . . Line: 3 -. . . . . . . . Col: 10 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 21 -. . . . . . . . Line: 3 -. . . . . . . . Col: 12 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: object . . . . . . . } . . . . . . } . . . . . } diff --git a/fixtures/comments.rb.native b/fixtures/comments.rb.native index 29bf396..098a163 100644 --- a/fixtures/comments.rb.native +++ b/fixtures/comments.rb.native @@ -3,54 +3,83 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "comments": [ - { - "documentation": false, - "end_col": 10, - "end_line": 1, - "inline": true, - "start_col": 0, - "start_line": 1, - "text": "# previous", - "type": "comment" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "comments": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 }, - { - "documentation": false, - "end_col": 14, - "end_line": 2, - "inline": true, - "start_col": 6, - "start_line": 2, - "text": "# inline", - "type": "comment" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 }, - { - "documentation": false, - "end_col": 7, - "end_line": 3, - "inline": true, - "start_col": 0, - "start_line": 3, - "text": "# after", - "type": "comment" - } - ], - "end_col": 5, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 5, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "token": 1, - "type": "int" + "@token": " previous", + "@type": "comment", + "documentation": false, + "inline": true + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@token": " inline", + "@type": "comment", + "documentation": false, + "inline": true + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@token": " after", + "@type": "comment", + "documentation": false, + "inline": true } + ], + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": 1, + "@type": "int" } } } diff --git a/fixtures/comments.rb.uast b/fixtures/comments.rb.uast index 1b04a91..b4f6374 100644 --- a/fixtures/comments.rb.uast +++ b/fixtures/comments.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 11 @@ -19,11 +19,12 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: comment { -. . . . . Roles: Unannotated +. . . . . Roles: Comment,Noop +. . . . . TOKEN " previous" . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -38,11 +39,28 @@ UAST: . . . . . . documentation: false . . . . . . inline: true . . . . . . internalRole: comments -. . . . . . text: previous . . . . . } . . . . } -. . . . 1: comment { -. . . . . Roles: Unannotated +. . . . 1: int { +. . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right +. . . . . TOKEN "1" +. . . . . StartPosition: { +. . . . . . Offset: 15 +. . . . . . Line: 2 +. . . . . . Col: 5 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 15 +. . . . . . Line: 2 +. . . . . . Col: 5 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: value +. . . . . } +. . . . } +. . . . 2: comment { +. . . . . Roles: Comment,Noop +. . . . . TOKEN " inline" . . . . . StartPosition: { . . . . . . Offset: 17 . . . . . . Line: 2 @@ -57,11 +75,11 @@ UAST: . . . . . . documentation: false . . . . . . inline: true . . . . . . internalRole: comments -. . . . . . text: inline . . . . . } . . . . } -. . . . 2: comment { -. . . . . Roles: Unannotated +. . . . 3: comment { +. . . . . Roles: Comment,Noop +. . . . . TOKEN " after" . . . . . StartPosition: { . . . . . . Offset: 26 . . . . . . Line: 3 @@ -76,24 +94,6 @@ UAST: . . . . . . documentation: false . . . . . . inline: true . . . . . . internalRole: comments -. . . . . . text: after -. . . . . } -. . . . } -. . . . 3: int { -. . . . . Roles: Right,Expression,Literal,Number,Primitive -. . . . . TOKEN "1" -. . . . . StartPosition: { -. . . . . . Offset: 15 -. . . . . . Line: 2 -. . . . . . Col: 5 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 15 -. . . . . . Line: 2 -. . . . . . Col: 5 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: value . . . . . } . . . . } . . . } diff --git a/fixtures/comparisonops.rb.native b/fixtures/comparisonops.rb.native index 3c7efad..40bdfeb 100644 --- a/fixtures/comparisonops.rb.native +++ b/fixtures/comparisonops.rb.native @@ -3,188 +3,313 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "base": { - "end_col": 1, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": 1, + "@type": "int" + }, + "selector": "==", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@token": 3, + "@type": "int" + }, + "selector": "!=", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@token": 4, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@token": 5, + "@type": "int" + }, + "selector": "!" + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 }, - "end_col": 6, - "end_line": 1, - "selector": "==", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 6, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": 2, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 1, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "token": 3, - "type": "int" + "@token": 6, + "@type": "int" + }, + "selector": "<=>", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 4 + }, + "@token": 7, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 5 }, - "end_col": 6, - "end_line": 2, - "selector": "!=", - "start_col": 0, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 6, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": 4, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 5, - "end_line": 3, - "start_col": 4, - "start_line": 3, - "token": 5, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 }, - "end_col": 5, - "end_line": 3, - "selector": "!", - "start_col": 0, - "start_line": 3, - "type": "send" - }, - { - "base": { - "end_col": 1, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "token": 6, - "type": "int" + "@token": 8, + "@type": "int" + }, + "selector": "===", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@token": 9, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 6 }, - "end_col": 7, - "end_line": 4, - "selector": "<=>", - "start_col": 0, - "start_line": 4, - "type": "send", - "values": [ - { - "end_col": 7, - "end_line": 4, - "start_col": 6, - "start_line": 4, - "token": 7, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 1, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "token": 8, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 }, - "end_col": 7, - "end_line": 5, - "selector": "===", - "start_col": 0, - "start_line": 5, - "type": "send", - "values": [ - { - "end_col": 7, - "end_line": 5, - "start_col": 6, - "start_line": 5, - "token": 9, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 1, - "end_line": 6, - "start_col": 0, - "start_line": 6, - "token": 1, - "type": "int" + "@token": 1, + "@type": "int" + }, + "selector": "eql?", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 6 + }, + "@token": 2, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 7 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 7 }, - "end_col": 8, - "end_line": 6, - "selector": "eql?", - "start_col": 0, - "start_line": 6, - "type": "send", - "values": [ - { - "end_col": 8, - "end_line": 6, - "start_col": 7, - "start_line": 6, - "token": 2, - "type": "int" - } - ] - }, - { - "base": { - "end_col": 1, - "end_line": 7, - "start_col": 0, - "start_line": 7, - "token": 3, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 7 }, - "end_col": 10, - "end_line": 7, - "selector": "equal?", - "start_col": 0, - "start_line": 7, - "type": "send", - "values": [ - { - "end_col": 10, - "end_line": 7, - "start_col": 9, - "start_line": 7, - "token": 4, - "type": "int" - } - ] - } - ], - "end_col": 10, - "end_line": 7, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "@token": 3, + "@type": "int" + }, + "selector": "equal?", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 7 + }, + "@token": 4, + "@type": "int" + } + ] + } + ] } } } diff --git a/fixtures/comparisonops.rb.uast b/fixtures/comparisonops.rb.uast index 3aa9415..0aa35df 100644 --- a/fixtures/comparisonops.rb.uast +++ b/fixtures/comparisonops.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 10 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Identifier,Operator,Relational,Equal +. . . . 0: send_operator { +. . . . . Roles: Binary,Equal,Expression,Operator,Relational . . . . . TOKEN "==" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 0 @@ -56,7 +56,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 5 @@ -74,8 +74,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: send { -. . . . . Roles: Expression,Identifier,Operator,Relational,Equal,Not +. . . . 1: send_operator { +. . . . . Roles: Binary,Equal,Expression,Not,Operator,Relational . . . . . TOKEN "!=" . . . . . StartPosition: { . . . . . . Offset: 7 @@ -92,7 +92,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "3" . . . . . . . StartPosition: { . . . . . . . . Offset: 7 @@ -109,7 +109,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "4" . . . . . . . StartPosition: { . . . . . . . . Offset: 12 @@ -127,8 +127,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 2: send { -. . . . . Roles: Expression,Identifier,Operator,Relational,Not +. . . . 2: send_operator { +. . . . . Roles: Expression,Not,Operator,Relational,Unary . . . . . TOKEN "!" . . . . . StartPosition: { . . . . . . Offset: 14 @@ -163,8 +163,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 3: send { -. . . . . Roles: Expression,Identifier,Operator +. . . . 3: send_call { +. . . . . Roles: Call,Expression,Function . . . . . TOKEN "<=>" . . . . . StartPosition: { . . . . . . Offset: 20 @@ -198,7 +198,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Argument,Call,Expression,Function,Literal,Number,Primitive . . . . . . . TOKEN "7" . . . . . . . StartPosition: { . . . . . . . . Offset: 26 @@ -216,8 +216,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 4: send { -. . . . . Roles: Expression,Identifier,Operator +. . . . 4: send_operator { +. . . . . Roles: Binary,Expression,Identical,Operator,Relational . . . . . TOKEN "===" . . . . . StartPosition: { . . . . . . Offset: 28 @@ -234,7 +234,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "8" . . . . . . . StartPosition: { . . . . . . . . Offset: 28 @@ -251,7 +251,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "9" . . . . . . . StartPosition: { . . . . . . . . Offset: 34 @@ -269,8 +269,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 5: send { -. . . . . Roles: Expression,Identifier,Operator,Relational,Identical,Incomplete +. . . . 5: send_operator { +. . . . . Roles: Binary,Expression,Identical,Operator,Relational . . . . . TOKEN "eql?" . . . . . StartPosition: { . . . . . . Offset: 36 @@ -287,7 +287,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 36 @@ -304,7 +304,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 43 @@ -322,8 +322,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 6: send { -. . . . . Roles: Expression,Identifier,Operator,Relational,Identical +. . . . 6: send_operator { +. . . . . Roles: Binary,Expression,Identical,Operator,Relational . . . . . TOKEN "equal?" . . . . . StartPosition: { . . . . . . Offset: 45 @@ -340,7 +340,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "3" . . . . . . . StartPosition: { . . . . . . . . Offset: 45 @@ -357,7 +357,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "4" . . . . . . . StartPosition: { . . . . . . . . Offset: 54 diff --git a/fixtures/complex_literal.rb.native b/fixtures/complex_literal.rb.native index 7dae9bf..c55941e 100644 --- a/fixtures/complex_literal.rb.native +++ b/fixtures/complex_literal.rb.native @@ -3,22 +3,33 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 6, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 6, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": "0+1i", - "type": "complex" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": "0+1i", + "@type": "complex" } } } diff --git a/fixtures/complex_literal.rb.uast b/fixtures/complex_literal.rb.uast index 603f4c4..a53df66 100644 --- a/fixtures/complex_literal.rb.uast +++ b/fixtures/complex_literal.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: complex { -. . . . . Roles: Right +. . . . . Roles: Binary,Expression,Incomplete,Literal,Number,Primitive,Right . . . . . TOKEN "0+1i" . . . . . StartPosition: { . . . . . . Offset: 4 diff --git a/fixtures/conditional_exec.rb.native b/fixtures/conditional_exec.rb.native index 6f74aff..e05c77a 100644 --- a/fixtures/conditional_exec.rb.native +++ b/fixtures/conditional_exec.rb.native @@ -3,88 +3,141 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "base": null, - "end_col": 10, - "end_line": 1, - "selector": "puts", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 10, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": "foo", - "type": "str" - } - ] + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": "foo", + "@type": "str" + } + ] + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 2 + }, + "@type": "if", + "body": null, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 2 }, - "condition": { - "base": null, - "end_col": 17, - "end_line": 1, - "selector": "foo", - "start_col": 14, - "start_line": 1, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 19, + "line": 2 }, - "else": null, - "end_col": 13, - "end_line": 1, - "start_col": 11, - "start_line": 1, - "type": "if" + "@type": "send_qualified", + "base": null, + "selector": "foo" }, - { - "body": null, - "condition": { - "base": null, - "end_col": 21, - "end_line": 2, - "selector": "foo", - "start_col": 18, - "start_line": 2, - "type": "send" + "else": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 2 }, - "else": { - "base": null, - "end_col": 10, - "end_line": 2, - "selector": "puts", - "start_col": 0, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 10, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": "bar", - "type": "str" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 }, - "end_col": 17, - "end_line": 2, - "start_col": 11, - "start_line": 2, - "type": "if" + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@token": "bar", + "@type": "str" + } + ] } - ], - "end_col": 21, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/conditional_exec.rb.uast b/fixtures/conditional_exec.rb.uast index fe46493..267f730 100644 --- a/fixtures/conditional_exec.rb.uast +++ b/fixtures/conditional_exec.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 21 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: if { -. . . . . Roles: Statement,If +. . . . . Roles: If,Statement . . . . . StartPosition: { . . . . . . Offset: 11 . . . . . . Line: 1 @@ -37,9 +37,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Call,Identifier,If,Then -. . . . . . . TOKEN "puts" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Body,Expression,Identical,Qualified,Then . . . . . . . StartPosition: { . . . . . . . . Offset: 0 . . . . . . . . Line: 1 @@ -52,10 +51,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: body +. . . . . . . . selector: puts . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive,Argument,Identifier +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "foo" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 5 @@ -73,9 +73,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "foo" +. . . . . . 1: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 14 . . . . . . . . Line: 1 @@ -88,12 +87,13 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: condition +. . . . . . . . selector: foo . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 1: if { -. . . . . Roles: Statement,If +. . . . . Roles: If,Statement . . . . . StartPosition: { . . . . . . Offset: 29 . . . . . . Line: 2 @@ -108,26 +108,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "foo" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 36 -. . . . . . . . Line: 2 -. . . . . . . . Col: 19 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 38 -. . . . . . . . Line: 2 -. . . . . . . . Col: 21 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: condition -. . . . . . . } -. . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,If,Else -. . . . . . . TOKEN "puts" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Else,Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 18 . . . . . . . . Line: 2 @@ -140,10 +122,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: else +. . . . . . . . selector: puts . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "bar" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 23 @@ -161,6 +144,23 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } +. . . . . . 1: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified +. . . . . . . StartPosition: { +. . . . . . . . Offset: 36 +. . . . . . . . Line: 2 +. . . . . . . . Col: 19 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 38 +. . . . . . . . Line: 2 +. . . . . . . . Col: 21 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: condition +. . . . . . . . selector: foo +. . . . . . . } +. . . . . . } . . . . . } . . . . } . . . } diff --git a/fixtures/constant_scoped.rb.native b/fixtures/constant_scoped.rb.native index 636e79a..8ac87ab 100644 --- a/fixtures/constant_scoped.rb.native +++ b/fixtures/constant_scoped.rb.native @@ -3,23 +3,34 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": { - "base": null, - "end_col": 1, - "end_line": 1, - "selector": "a", - "start_col": 0, - "start_line": 1, - "type": "send" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Foo", + "@type": "const", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 }, - "end_col": 6, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": "Foo", - "type": "const" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" } } } diff --git a/fixtures/constant_scoped.rb.uast b/fixtures/constant_scoped.rb.uast index f9592a9..39ce25e 100644 --- a/fixtures/constant_scoped.rb.uast +++ b/fixtures/constant_scoped.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: const { . . . Roles: Expression,Identifier,Incomplete @@ -19,12 +19,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Qualified,Identifier -. . . . . TOKEN "a" +. . . . 0: send_qualified { +. . . . . Roles: Expression,Identical,Qualified . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -37,6 +36,7 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: base +. . . . . . selector: a . . . . . } . . . . } . . . } diff --git a/fixtures/constant_toplevel.rb.native b/fixtures/constant_toplevel.rb.native index be9ece4..cba3916 100644 --- a/fixtures/constant_toplevel.rb.native +++ b/fixtures/constant_toplevel.rb.native @@ -3,21 +3,32 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": { - "end_col": 2, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "cbase" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Foo", + "@type": "const", + "base": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 1 }, - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": "Foo", - "type": "const" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "cbase" } } } diff --git a/fixtures/constant_toplevel.rb.uast b/fixtures/constant_toplevel.rb.uast index 6bae1f5..c9c9ff3 100644 --- a/fixtures/constant_toplevel.rb.uast +++ b/fixtures/constant_toplevel.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: const { . . . Roles: Expression,Identifier,Incomplete @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: cbase { -. . . . . Roles: Expression,Identifier,Qualified,Incomplete +. . . . . Roles: Expression,Identifier,Incomplete,Qualified . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 diff --git a/fixtures/constant_unscoped.rb.native b/fixtures/constant_unscoped.rb.native index cbbdd57..d78b68f 100644 --- a/fixtures/constant_unscoped.rb.native +++ b/fixtures/constant_unscoped.rb.native @@ -3,23 +3,34 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": null, - "end_col": 7, - "end_line": 1, - "selector": "Foo", - "start_col": 0, - "start_line": 1, - "type": "casgn", - "value": { - "end_col": 7, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "casgn", + "base": null, + "selector": "Foo", + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@token": 1, + "@type": "int" } } } diff --git a/fixtures/constant_unscoped.rb.uast b/fixtures/constant_unscoped.rb.uast index e3f1f56..3b6e3b5 100644 --- a/fixtures/constant_unscoped.rb.uast +++ b/fixtures/constant_unscoped.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: casgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "Foo" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 7 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: int { -. . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . TOKEN "1" . . . . . StartPosition: { . . . . . . Offset: 6 diff --git a/fixtures/continue.rb.native b/fixtures/continue.rb.native index 4a1b3c8..602d232 100644 --- a/fixtures/continue.rb.native +++ b/fixtures/continue.rb.native @@ -3,29 +3,46 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "base": null, - "end_col": 12, - "end_line": 2, - "selector": "continue", - "start_col": 4, - "start_line": 2, - "type": "send" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "while", + "body": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 2 }, - "condition": { - "end_col": 10, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "type": "true" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "while" + "@type": "send_statement", + "base": null, + "selector": "continue" + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "true" } } } diff --git a/fixtures/continue.rb.uast b/fixtures/continue.rb.uast index 589121c..9b6bfce 100644 --- a/fixtures/continue.rb.uast +++ b/fixtures/continue.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: while { . . . Roles: Statement,While @@ -18,28 +18,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Statement,Continue,Expression,While,Body -. . . . . TOKEN "continue" -. . . . . StartPosition: { -. . . . . . Offset: 15 -. . . . . . Line: 2 -. . . . . . Col: 5 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 22 -. . . . . . Line: 2 -. . . . . . Col: 12 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . } -. . . . 1: true { -. . . . . Roles: Expression,Condition,While,Boolean,Literal +. . . . 0: true { +. . . . . Roles: Boolean,Condition,Expression,Literal . . . . . TOKEN "true" . . . . . StartPosition: { . . . . . . Offset: 6 @@ -55,6 +38,23 @@ UAST: . . . . . . internalRole: condition . . . . . } . . . . } +. . . . 1: send_statement { +. . . . . Roles: Body,Continue,Statement +. . . . . TOKEN "continue" +. . . . . StartPosition: { +. . . . . . Offset: 15 +. . . . . . Line: 2 +. . . . . . Col: 5 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 22 +. . . . . . Line: 2 +. . . . . . Col: 12 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . } . . . } . . } . } diff --git a/fixtures/float_literal.rb.native b/fixtures/float_literal.rb.native index 01ab0cd..113a60e 100644 --- a/fixtures/float_literal.rb.native +++ b/fixtures/float_literal.rb.native @@ -3,22 +3,33 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 8, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 8, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": 1.23, - "type": "float" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": 1.23, + "@type": "float" } } } diff --git a/fixtures/float_literal.rb.uast b/fixtures/float_literal.rb.uast index cfb58bd..f47404a 100644 --- a/fixtures/float_literal.rb.uast +++ b/fixtures/float_literal.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 8 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: float { -. . . . . Roles: Right +. . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . TOKEN "1.23" . . . . . StartPosition: { . . . . . . Offset: 4 diff --git a/fixtures/for.rb.native b/fixtures/for.rb.native index 25ced2e..e6ed317 100644 --- a/fixtures/for.rb.native +++ b/fixtures/for.rb.native @@ -3,152 +3,259 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": "i", - "type": "lvar" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "for", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": "i", + "@type": "lvar" + } + }, + "iterated": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 }, - "end_col": 3, - "end_line": 1, - "iterated": { - "_1": { - "end_col": 10, - "end_line": 1, - "start_col": 9, - "start_line": 1, - "token": 0, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@type": "irange", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 1 }, - "_2": { - "end_col": 13, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "token": 5, - "type": "int" + "@token": 0, + "@type": "int" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 }, - "end_col": 13, - "end_line": 1, - "start_col": 9, - "start_line": 1, - "type": "irange" + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@token": 5, + "@type": "int" + } + }, + "iterators": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 }, - "iterators": { - "end_col": 5, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "target": "i", - "type": "lvasgn", - "value": null + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 }, - "start_col": 0, - "start_line": 1, - "type": "for" + "@type": "lvasgn", + "target": "i", + "value": null + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 5 }, - { - "end_col": 13, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "target": "b", - "type": "lvasgn", - "value": { - "contents": [ - { - "end_col": 6, - "end_line": 5, - "start_col": 5, - "start_line": 5, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 5 + }, + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 5 }, - { - "end_col": 9, - "end_line": 5, - "start_col": 8, - "start_line": 5, - "token": 2, - "type": "int" + "@token": 2, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 5 }, - { - "end_col": 12, - "end_line": 5, - "start_col": 11, - "start_line": 5, - "token": 3, - "type": "int" - } - ], - "end_col": 13, - "end_line": 5, - "start_col": 4, - "start_line": 5, - "type": "array" + "@token": 3, + "@type": "int" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 7 + }, + "@type": "for", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 8 + }, + "@type": "lvasgn", + "target": "x", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@token": "i", + "@type": "lvar" } }, - { - "body": { - "end_col": 9, - "end_line": 8, - "start_col": 4, - "start_line": 8, - "target": "x", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 8, - "start_col": 8, - "start_line": 8, - "token": "i", - "type": "lvar" - } + "iterated": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 7 }, - "end_col": 3, - "end_line": 7, - "iterated": { - "end_col": 10, - "end_line": 7, - "start_col": 9, - "start_line": 7, - "token": "b", - "type": "lvar" + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 7 + }, + "@token": "b", + "@type": "lvar" + }, + "iterators": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 7 }, - "iterators": { - "end_col": 5, - "end_line": 7, - "start_col": 4, - "start_line": 7, - "target": "i", - "type": "lvasgn", - "value": null + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 }, - "start_col": 0, - "start_line": 7, - "type": "for" + "@type": "lvasgn", + "target": "i", + "value": null } - ], - "end_col": 3, - "end_line": 9, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/for.rb.uast b/fixtures/for.rb.uast index 2758be2..cd68e5c 100644 --- a/fixtures/for.rb.uast +++ b/fixtures/for.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: for { -. . . . . Roles: Statement,For +. . . . . Roles: For,Statement . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -38,43 +38,24 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,For,Body -. . . . . . . TOKEN "a" +. . . . . . . Roles: Assignment,Binary,Expression,For,Identifier,Iterator,Left +. . . . . . . TOKEN "i" . . . . . . . StartPosition: { -. . . . . . . . Offset: 18 -. . . . . . . . Line: 2 +. . . . . . . . Offset: 4 +. . . . . . . . Line: 1 . . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 22 -. . . . . . . . Line: 2 -. . . . . . . . Col: 9 +. . . . . . . . Offset: 4 +. . . . . . . . Line: 1 +. . . . . . . . Col: 5 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: body -. . . . . . . } -. . . . . . . Children: { -. . . . . . . . 0: lvar { -. . . . . . . . . Roles: Right,Expression,Identifier -. . . . . . . . . TOKEN "i" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 22 -. . . . . . . . . . Line: 2 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 22 -. . . . . . . . . . Line: 2 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: value -. . . . . . . . . } -. . . . . . . . } +. . . . . . . . internalRole: iterators . . . . . . . } . . . . . . } . . . . . . 1: irange { -. . . . . . . Roles: Expression,Tuple,Incomplete,For,Update +. . . . . . . Roles: Expression,For,Incomplete,Tuple,Update . . . . . . . StartPosition: { . . . . . . . . Offset: 9 . . . . . . . . Line: 1 @@ -90,7 +71,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . TOKEN "0" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 9 @@ -107,7 +88,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . TOKEN "5" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 12 @@ -126,26 +107,45 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 2: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,For,Iterator -. . . . . . . TOKEN "i" +. . . . . . . Roles: Assignment,Binary,Body,Expression,For,Identifier,Left +. . . . . . . TOKEN "a" . . . . . . . StartPosition: { -. . . . . . . . Offset: 4 -. . . . . . . . Line: 1 +. . . . . . . . Offset: 18 +. . . . . . . . Line: 2 . . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 4 -. . . . . . . . Line: 1 -. . . . . . . . Col: 5 +. . . . . . . . Offset: 22 +. . . . . . . . Line: 2 +. . . . . . . . Col: 9 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: iterators +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: lvar { +. . . . . . . . . Roles: Binary,Expression,Identifier,Right +. . . . . . . . . TOKEN "i" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 22 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 22 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: value +. . . . . . . . . } +. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 29 @@ -162,7 +162,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: array { -. . . . . . . Roles: Right,Expression,Literal,List,Primitive +. . . . . . . Roles: Binary,Expression,List,Literal,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 33 . . . . . . . . Line: 5 @@ -233,7 +233,7 @@ UAST: . . . . . } . . . . } . . . . 2: for { -. . . . . Roles: Statement,For +. . . . . Roles: For,Statement . . . . . StartPosition: { . . . . . . Offset: 44 . . . . . . Line: 7 @@ -249,43 +249,24 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,For,Body -. . . . . . . TOKEN "x" +. . . . . . . Roles: Assignment,Binary,Expression,For,Identifier,Iterator,Left +. . . . . . . TOKEN "i" . . . . . . . StartPosition: { -. . . . . . . . Offset: 59 -. . . . . . . . Line: 8 +. . . . . . . . Offset: 48 +. . . . . . . . Line: 7 . . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 63 -. . . . . . . . Line: 8 -. . . . . . . . Col: 9 +. . . . . . . . Offset: 48 +. . . . . . . . Line: 7 +. . . . . . . . Col: 5 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: body -. . . . . . . } -. . . . . . . Children: { -. . . . . . . . 0: lvar { -. . . . . . . . . Roles: Right,Expression,Identifier -. . . . . . . . . TOKEN "i" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 63 -. . . . . . . . . . Line: 8 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 63 -. . . . . . . . . . Line: 8 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: value -. . . . . . . . . } -. . . . . . . . } +. . . . . . . . internalRole: iterators . . . . . . . } . . . . . . } . . . . . . 1: lvar { -. . . . . . . Roles: Expression,Identifier,For,Update +. . . . . . . Roles: Expression,For,Identifier,Update . . . . . . . TOKEN "b" . . . . . . . StartPosition: { . . . . . . . . Offset: 53 @@ -302,20 +283,39 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 2: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,For,Iterator -. . . . . . . TOKEN "i" +. . . . . . . Roles: Assignment,Binary,Body,Expression,For,Identifier,Left +. . . . . . . TOKEN "x" . . . . . . . StartPosition: { -. . . . . . . . Offset: 48 -. . . . . . . . Line: 7 +. . . . . . . . Offset: 59 +. . . . . . . . Line: 8 . . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 48 -. . . . . . . . Line: 7 -. . . . . . . . Col: 5 +. . . . . . . . Offset: 63 +. . . . . . . . Line: 8 +. . . . . . . . Col: 9 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: iterators +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: lvar { +. . . . . . . . . Roles: Binary,Expression,Identifier,Right +. . . . . . . . . TOKEN "i" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 63 +. . . . . . . . . . Line: 8 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 63 +. . . . . . . . . . Line: 8 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: value +. . . . . . . . . } +. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } diff --git a/fixtures/hash_label.rb.native b/fixtures/hash_label.rb.native index 9e9d28b..03c1a45 100644 --- a/fixtures/hash_label.rb.native +++ b/fixtures/hash_label.rb.native @@ -3,69 +3,116 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 20, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "_1": { - "end_col": 8, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": "a", - "type": "sym" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "hash", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": "a", + "@type": "sym" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 1 }, - "_2": { - "end_col": 11, - "end_line": 1, - "start_col": 10, - "start_line": 1, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 1 }, - "end_col": 11, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "type": "pair" + "@token": "b", + "@type": "sym" }, - { - "_1": { - "end_col": 16, - "end_line": 1, - "start_col": 13, - "start_line": 1, - "token": "b", - "type": "sym" + "_2": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 1 }, - "_2": { - "end_col": 19, - "end_line": 1, - "start_col": 18, - "start_line": 1, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 19, + "line": 1 }, - "end_col": 19, - "end_line": 1, - "start_col": 13, - "start_line": 1, - "type": "pair" + "@token": 2, + "@type": "int" } - ], - "end_col": 20, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "hash" - } + } + ] } } } diff --git a/fixtures/hash_label.rb.uast b/fixtures/hash_label.rb.uast index 7325497..04726bb 100644 --- a/fixtures/hash_label.rb.uast +++ b/fixtures/hash_label.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 20 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: hash { -. . . . . Roles: Right,Expression,Literal,Map,Primitive +. . . . . Roles: Binary,Expression,Literal,Map,Primitive,Right . . . . . StartPosition: { . . . . . . Offset: 4 . . . . . . Line: 1 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: pair { -. . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . StartPosition: { . . . . . . . . Offset: 5 . . . . . . . . Line: 1 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: sym { -. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . Roles: Expression,Identifier,Tuple,Value . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 5 @@ -72,7 +72,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 10 @@ -91,7 +91,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: pair { -. . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . StartPosition: { . . . . . . . . Offset: 13 . . . . . . . . Line: 1 @@ -107,7 +107,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: sym { -. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . Roles: Expression,Identifier,Tuple,Value . . . . . . . . . TOKEN "b" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 13 @@ -124,7 +124,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . TOKEN "2" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 18 diff --git a/fixtures/hash_rocket.rb.native b/fixtures/hash_rocket.rb.native index d04e810..3436e6c 100644 --- a/fixtures/hash_rocket.rb.native +++ b/fixtures/hash_rocket.rb.native @@ -3,69 +3,116 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 24, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "_1": { - "end_col": 8, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": "a", - "type": "str" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 24, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 24, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "hash", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": "a", + "@type": "str" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 23, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 }, - "_2": { - "end_col": 13, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 1 }, - "end_col": 13, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "type": "pair" + "@token": "b", + "@type": "str" }, - { - "_1": { - "end_col": 18, - "end_line": 1, - "start_col": 15, - "start_line": 1, - "token": "b", - "type": "str" + "_2": { + "@end": { + "@type": "ast:Position", + "col": 23, + "line": 1 }, - "_2": { - "end_col": 23, - "end_line": 1, - "start_col": 22, - "start_line": 1, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 23, + "line": 1 }, - "end_col": 23, - "end_line": 1, - "start_col": 15, - "start_line": 1, - "type": "pair" + "@token": 2, + "@type": "int" } - ], - "end_col": 24, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "hash" - } + } + ] } } } diff --git a/fixtures/hash_rocket.rb.uast b/fixtures/hash_rocket.rb.uast index 426df3b..abc04cb 100644 --- a/fixtures/hash_rocket.rb.uast +++ b/fixtures/hash_rocket.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 24 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: hash { -. . . . . Roles: Right,Expression,Literal,Map,Primitive +. . . . . Roles: Binary,Expression,Literal,Map,Primitive,Right . . . . . StartPosition: { . . . . . . Offset: 4 . . . . . . Line: 1 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: pair { -. . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . StartPosition: { . . . . . . . . Offset: 5 . . . . . . . . Line: 1 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String,Tuple,Value . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 5 @@ -72,7 +72,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 12 @@ -91,7 +91,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: pair { -. . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . StartPosition: { . . . . . . . . Offset: 15 . . . . . . . . Line: 1 @@ -107,7 +107,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String,Tuple,Value . . . . . . . . . TOKEN "b" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 15 @@ -124,7 +124,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . TOKEN "2" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 22 diff --git a/fixtures/hash_splat.rb.native b/fixtures/hash_splat.rb.native index ec00607..aa335de 100644 --- a/fixtures/hash_splat.rb.native +++ b/fixtures/hash_splat.rb.native @@ -3,134 +3,229 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 24, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "contents": [ - { - "_1": { - "end_col": 8, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": "a", - "type": "str" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 24, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 24, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "hash", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": "a", + "@type": "str" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 23, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 }, - "_2": { - "end_col": 13, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 1 }, - "end_col": 13, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "type": "pair" + "@token": "b", + "@type": "str" }, - { - "_1": { - "end_col": 18, - "end_line": 1, - "start_col": 15, - "start_line": 1, - "token": "b", - "type": "str" + "_2": { + "@end": { + "@type": "ast:Position", + "col": 23, + "line": 1 }, - "_2": { - "end_col": 23, - "end_line": 1, - "start_col": 22, - "start_line": 1, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 23, + "line": 1 }, - "end_col": 23, - "end_line": 1, - "start_col": 15, - "start_line": 1, - "type": "pair" + "@token": 2, + "@type": "int" } - ], - "end_col": 24, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "hash" - } + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 }, - { - "end_col": 19, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": { - "contents": [ - { - "_1": { - "end_col": 8, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": "c", - "type": "str" + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "hash", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@type": "pair", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 2 }, - "_2": { - "end_col": 13, - "end_line": 2, - "start_col": 12, - "start_line": 2, - "token": 3, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 }, - "end_col": 13, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "type": "pair" + "@token": "c", + "@type": "str" }, - { - "end_col": 18, - "end_line": 2, - "name": { - "end_col": 18, - "end_line": 2, - "start_col": 17, - "start_line": 2, - "token": "a", - "type": "lvar" + "_2": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 2 }, - "start_col": 15, - "start_line": 2, - "type": "kwsplat" + "@token": 3, + "@type": "int" } - ], - "end_col": 19, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "type": "hash" - } + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 2 + }, + "@token": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@token": "a", + "@type": "lvar" + }, + "@type": "kwsplat" + } + ] } - ], - "end_col": 19, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/hash_splat.rb.uast b/fixtures/hash_splat.rb.uast index bf2a239..37b02e0 100644 --- a/fixtures/hash_splat.rb.uast +++ b/fixtures/hash_splat.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 19 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: hash { -. . . . . . . Roles: Right,Expression,Literal,Map,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Map,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: pair { -. . . . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 5 . . . . . . . . . . Line: 1 @@ -71,7 +71,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: str { -. . . . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Primitive,String,Tuple,Value . . . . . . . . . . . TOKEN "a" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 5 @@ -88,7 +88,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 12 @@ -107,7 +107,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: pair { -. . . . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 15 . . . . . . . . . . Line: 1 @@ -123,7 +123,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: str { -. . . . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Primitive,String,Tuple,Value . . . . . . . . . . . TOKEN "b" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 15 @@ -140,7 +140,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "2" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 22 @@ -163,7 +163,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 25 @@ -180,7 +180,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: hash { -. . . . . . . Roles: Right,Expression,Literal,Map,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Map,Primitive,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 29 . . . . . . . . Line: 2 @@ -196,7 +196,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: pair { -. . . . . . . . . Roles: Expression,Literal,Tuple,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,Tuple . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 30 . . . . . . . . . . Line: 2 @@ -212,7 +212,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: str { -. . . . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Primitive,String,Tuple,Value . . . . . . . . . . . TOKEN "c" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 30 @@ -229,7 +229,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive,Tuple,Value . . . . . . . . . . . TOKEN "3" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 37 @@ -262,25 +262,6 @@ UAST: . . . . . . . . . Properties: { . . . . . . . . . . internalRole: contents . . . . . . . . . } -. . . . . . . . . Children: { -. . . . . . . . . . 0: lvar { -. . . . . . . . . . . Roles: Expression,Identifier -. . . . . . . . . . . TOKEN "a" -. . . . . . . . . . . StartPosition: { -. . . . . . . . . . . . Offset: 42 -. . . . . . . . . . . . Line: 2 -. . . . . . . . . . . . Col: 18 -. . . . . . . . . . . } -. . . . . . . . . . . EndPosition: { -. . . . . . . . . . . . Offset: 42 -. . . . . . . . . . . . Line: 2 -. . . . . . . . . . . . Col: 18 -. . . . . . . . . . . } -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: name -. . . . . . . . . . . } -. . . . . . . . . . } -. . . . . . . . . } . . . . . . . . } . . . . . . . } . . . . . . } diff --git a/fixtures/hello.rb.native b/fixtures/hello.rb.native index 13204a5..bc850e3 100644 --- a/fixtures/hello.rb.native +++ b/fixtures/hello.rb.native @@ -3,26 +3,37 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": null, - "end_col": 18, - "end_line": 1, - "selector": "puts", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 18, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": "hello world", - "type": "str" - } - ] - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@token": "hello world", + "@type": "str" + } + ] } } } diff --git a/fixtures/hello.rb.uast b/fixtures/hello.rb.uast index 7ee55a4..9661af5 100644 --- a/fixtures/hello.rb.uast +++ b/fixtures/hello.rb.uast @@ -2,12 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { -. . 0: send { -. . . Roles: Expression,Call,Identifier -. . . TOKEN "puts" +. . 0: send_qualified { +. . . Roles: Expression,Identical,Qualified . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -19,11 +18,12 @@ UAST: . . . . Col: 18 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file +. . . . selector: puts . . . } . . . Children: { . . . . 0: str { -. . . . . Roles: Expression,Literal,String,Primitive,Argument,Identifier +. . . . . Roles: Expression,Literal,Primitive,String . . . . . TOKEN "hello world" . . . . . StartPosition: { . . . . . . Offset: 5 diff --git a/fixtures/if.rb.native b/fixtures/if.rb.native index 2dd39e8..bb392ad 100644 --- a/fixtures/if.rb.native +++ b/fixtures/if.rb.native @@ -3,173 +3,292 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 }, - "condition": { - "base": null, - "end_col": 6, - "end_line": 1, - "selector": "foo", - "start_col": 3, - "start_line": 1, - "type": "send" - }, - "else": null, - "end_col": 2, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "if" - }, - { - "body": { - "body": [ - { - "end_col": 9, - "end_line": 6, - "start_col": 4, - "start_line": 6, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 6, - "start_col": 8, - "start_line": 6, - "token": 1, - "type": "int" - } + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 }, - { - "end_col": 9, - "end_line": 7, - "start_col": 4, - "start_line": 7, - "target": "b", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 7, - "start_col": 8, - "start_line": 7, - "token": 2, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 7 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@token": 2, + "@type": "int" } - ], - "end_col": 9, - "end_line": 7, - "start_col": 4, - "start_line": 6, - "type": "begin" - }, - "condition": { - "base": null, - "end_col": 6, - "end_line": 5, - "selector": "foo", - "start_col": 3, - "start_line": 5, - "type": "send" - }, - "else": null, - "end_col": 2, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "type": "if" - }, - { - "body": { - "end_col": 13, - "end_line": 10, - "start_col": 8, - "start_line": 10, - "target": "x", - "type": "lvasgn", - "value": { - "end_col": 13, - "end_line": 10, - "start_col": 12, - "start_line": 10, - "token": 2, - "type": "int" } + ] + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 5 }, - "condition": { - "base": null, - "end_col": 6, - "end_line": 10, - "selector": "foo", - "start_col": 3, - "start_line": 10, - "type": "send" - }, - "else": null, - "end_col": 2, - "end_line": 10, - "start_col": 0, - "start_line": 10, - "type": "if" - }, - { - "body": { - "end_col": 5, - "end_line": 12, - "start_col": 0, - "start_line": 12, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 5, - "end_line": 12, - "start_col": 4, - "start_line": 12, - "token": 1, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 5 }, - "condition": { - "base": null, - "end_col": 12, - "end_line": 12, - "selector": "foo", - "start_col": 9, - "start_line": 12, - "type": "send" - }, - "else": null, - "end_col": 8, - "end_line": 12, - "start_col": 6, - "start_line": 12, - "type": "if" - } - ], - "end_col": 12, - "end_line": 12, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 10 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 10 + }, + "@type": "lvasgn", + "target": "x", + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 10 + }, + "@token": 2, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 10 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 12 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 12 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 12 + }, + "@token": 1, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 12 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": null + } + ] } } } diff --git a/fixtures/if.rb.uast b/fixtures/if.rb.uast index 973c7dd..098997d 100644 --- a/fixtures/if.rb.uast +++ b/fixtures/if.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 12 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: if { -. . . . . Roles: Statement,If +. . . . . Roles: If,Statement . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -37,8 +37,25 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then +. . . . . . 0: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified +. . . . . . . StartPosition: { +. . . . . . . . Offset: 3 +. . . . . . . . Line: 1 +. . . . . . . . Col: 4 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 5 +. . . . . . . . Line: 1 +. . . . . . . . Col: 6 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: condition +. . . . . . . . selector: foo +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 11 @@ -55,7 +72,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 15 @@ -73,27 +90,10 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "foo" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 3 -. . . . . . . . Line: 1 -. . . . . . . . Col: 4 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 5 -. . . . . . . . Line: 1 -. . . . . . . . Col: 6 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: condition -. . . . . . . } -. . . . . . } . . . . . } . . . . } . . . . 1: if { -. . . . . Roles: Statement,If +. . . . . Roles: If,Statement . . . . . StartPosition: { . . . . . . Offset: 22 . . . . . . Line: 5 @@ -108,8 +108,25 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: begin { -. . . . . . . Roles: Block,Expression,If,Then +. . . . . . 0: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified +. . . . . . . StartPosition: { +. . . . . . . . Offset: 25 +. . . . . . . . Line: 5 +. . . . . . . . Col: 4 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 27 +. . . . . . . . Line: 5 +. . . . . . . . Col: 6 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: condition +. . . . . . . . selector: foo +. . . . . . . } +. . . . . . } +. . . . . . 1: begin { +. . . . . . . Roles: Block,Body,Expression,Then . . . . . . . StartPosition: { . . . . . . . . Offset: 33 . . . . . . . . Line: 6 @@ -125,7 +142,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 33 @@ -142,7 +159,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 37 @@ -161,7 +178,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "b" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 43 @@ -178,7 +195,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . . . TOKEN "2" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 47 @@ -198,27 +215,10 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "foo" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 25 -. . . . . . . . Line: 5 -. . . . . . . . Col: 4 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 27 -. . . . . . . . Line: 5 -. . . . . . . . Col: 6 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: condition -. . . . . . . } -. . . . . . } . . . . . } . . . . } . . . . 2: if { -. . . . . Roles: Statement,If +. . . . . Roles: If,Statement . . . . . StartPosition: { . . . . . . Offset: 54 . . . . . . Line: 10 @@ -233,8 +233,25 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then +. . . . . . 0: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified +. . . . . . . StartPosition: { +. . . . . . . . Offset: 57 +. . . . . . . . Line: 10 +. . . . . . . . Col: 4 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 59 +. . . . . . . . Line: 10 +. . . . . . . . Col: 6 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: condition +. . . . . . . . selector: foo +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then . . . . . . . TOKEN "x" . . . . . . . StartPosition: { . . . . . . . . Offset: 62 @@ -251,7 +268,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "2" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 66 @@ -269,27 +286,10 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "foo" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 57 -. . . . . . . . Line: 10 -. . . . . . . . Col: 4 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 59 -. . . . . . . . Line: 10 -. . . . . . . . Col: 6 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: condition -. . . . . . . } -. . . . . . } . . . . . } . . . . } . . . . 3: if { -. . . . . Roles: Statement,If +. . . . . Roles: If,Statement . . . . . StartPosition: { . . . . . . Offset: 80 . . . . . . Line: 12 @@ -305,7 +305,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 74 @@ -322,7 +322,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 78 @@ -340,9 +340,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "foo" +. . . . . . 1: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 83 . . . . . . . . Line: 12 @@ -355,6 +354,7 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: condition +. . . . . . . . selector: foo . . . . . . . } . . . . . . } . . . . . } diff --git a/fixtures/if_else.rb.native b/fixtures/if_else.rb.native index d337cdd..cc37cfe 100644 --- a/fixtures/if_else.rb.native +++ b/fixtures/if_else.rb.native @@ -3,54 +3,89 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "condition": { - "base": null, - "end_col": 6, - "end_line": 1, - "selector": "foo", - "start_col": 3, - "start_line": 1, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "else": { - "end_col": 9, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "target": "b", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 4, - "start_col": 8, - "start_line": 4, - "token": 2, - "type": "int" - } + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - "end_col": 2, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "if" + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@token": 2, + "@type": "int" + } } } } diff --git a/fixtures/if_else.rb.uast b/fixtures/if_else.rb.uast index 7e84141..ff8726f 100644 --- a/fixtures/if_else.rb.uast +++ b/fixtures/if_else.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: if { -. . . Roles: Statement,If +. . . Roles: If,Statement . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,11 +18,28 @@ UAST: . . . . Col: 2 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then +. . . . 0: send_qualified { +. . . . . Roles: Condition,Expression,Identical,Qualified +. . . . . StartPosition: { +. . . . . . Offset: 3 +. . . . . . Line: 1 +. . . . . . Col: 4 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 5 +. . . . . . Line: 1 +. . . . . . Col: 6 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: condition +. . . . . . selector: foo +. . . . . } +. . . . } +. . . . 1: lvasgn { +. . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 11 @@ -39,7 +56,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 15 @@ -57,25 +74,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: send { -. . . . . Roles: Expression,Condition,If -. . . . . TOKEN "foo" -. . . . . StartPosition: { -. . . . . . Offset: 3 -. . . . . . Line: 1 -. . . . . . Col: 4 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 5 -. . . . . . Line: 1 -. . . . . . Col: 6 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: condition -. . . . . } -. . . . } . . . . 2: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Else +. . . . . Roles: Assignment,Binary,Else,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 26 @@ -92,7 +92,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 30 diff --git a/fixtures/if_elsif.rb.native b/fixtures/if_elsif.rb.native index dc2f234..d3151b9 100644 --- a/fixtures/if_elsif.rb.native +++ b/fixtures/if_elsif.rb.native @@ -3,86 +3,145 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "if", "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "lvasgn", + "target": "b", "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@token": 2, + "@type": "int" } }, "condition": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@type": "send_qualified", "base": null, - "end_col": 6, - "end_line": 1, - "selector": "foo", - "start_col": 3, - "start_line": 1, - "type": "send" + "selector": "bar" }, "else": { - "body": { - "end_col": 9, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "target": "b", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 4, - "start_col": 8, - "start_line": 4, - "token": 2, - "type": "int" - } + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 }, - "condition": { - "base": null, - "end_col": 9, - "end_line": 3, - "selector": "bar", - "start_col": 6, - "start_line": 3, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 }, - "else": { - "end_col": 9, - "end_line": 6, - "start_col": 4, - "start_line": 6, - "target": "c", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 6, - "start_col": 8, - "start_line": 6, - "token": 3, - "type": "int" - } - }, - "end_col": 5, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "type": "if" - }, - "end_col": 2, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "if" + "@type": "lvasgn", + "target": "c", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@token": 3, + "@type": "int" + } + } } } } diff --git a/fixtures/if_elsif.rb.uast b/fixtures/if_elsif.rb.uast index 43d53e4..ac9e30e 100644 --- a/fixtures/if_elsif.rb.uast +++ b/fixtures/if_elsif.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: if { -. . . Roles: Statement,If +. . . Roles: If,Statement . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,11 +18,28 @@ UAST: . . . . Col: 2 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then +. . . . 0: send_qualified { +. . . . . Roles: Condition,Expression,Identical,Qualified +. . . . . StartPosition: { +. . . . . . Offset: 3 +. . . . . . Line: 1 +. . . . . . Col: 4 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 5 +. . . . . . Line: 1 +. . . . . . Col: 6 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: condition +. . . . . . selector: foo +. . . . . } +. . . . } +. . . . 1: lvasgn { +. . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 11 @@ -39,7 +56,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 15 @@ -57,25 +74,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: send { -. . . . . Roles: Expression,Condition,If -. . . . . TOKEN "foo" -. . . . . StartPosition: { -. . . . . . Offset: 3 -. . . . . . Line: 1 -. . . . . . Col: 4 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 5 -. . . . . . Line: 1 -. . . . . . Col: 6 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: condition -. . . . . } -. . . . } . . . . 2: if { -. . . . . Roles: Expression,If,Else,Statement +. . . . . Roles: Else,Expression,If,Statement . . . . . StartPosition: { . . . . . . Offset: 17 . . . . . . Line: 3 @@ -90,8 +90,25 @@ UAST: . . . . . . internalRole: else . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then +. . . . . . 0: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified +. . . . . . . StartPosition: { +. . . . . . . . Offset: 23 +. . . . . . . . Line: 3 +. . . . . . . . Col: 7 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 25 +. . . . . . . . Line: 3 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: condition +. . . . . . . . selector: bar +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then . . . . . . . TOKEN "b" . . . . . . . StartPosition: { . . . . . . . . Offset: 31 @@ -108,7 +125,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "2" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 35 @@ -126,25 +143,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "bar" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 23 -. . . . . . . . Line: 3 -. . . . . . . . Col: 7 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 25 -. . . . . . . . Line: 3 -. . . . . . . . Col: 9 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: condition -. . . . . . . } -. . . . . . } . . . . . . 2: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Else +. . . . . . . Roles: Assignment,Binary,Else,Expression,Identifier,Left . . . . . . . TOKEN "c" . . . . . . . StartPosition: { . . . . . . . . Offset: 46 @@ -161,7 +161,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "3" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 50 diff --git a/fixtures/if_flipflop.rb.native b/fixtures/if_flipflop.rb.native index 9af7b03..913fe32 100644 --- a/fixtures/if_flipflop.rb.native +++ b/fixtures/if_flipflop.rb.native @@ -3,114 +3,191 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "condition": { - "_1": { - "base": null, - "end_col": 4, - "end_line": 1, - "selector": "a", - "start_col": 3, - "start_line": 1, - "type": "send" + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "_2": { - "base": null, - "end_col": 7, - "end_line": 1, - "selector": "b", - "start_col": 6, - "start_line": 1, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "end_col": 7, - "end_line": 1, - "start_col": 3, - "start_line": 1, - "type": "iflipflop" + "@token": 1, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 1 }, - "else": null, - "end_col": 2, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "if" + "@type": "iflipflop", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" + }, + "_2": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "b" + } + }, + "else": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 5 }, - { - "body": { - "end_col": 9, - "end_line": 6, - "start_col": 4, - "start_line": 6, - "target": "b", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 6, - "start_col": 8, - "start_line": 6, - "token": 2, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@token": 2, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 5 }, - "condition": { - "_1": { - "base": null, - "end_col": 4, - "end_line": 5, - "selector": "d", - "start_col": 3, - "start_line": 5, - "type": "send" + "@type": "eflipflop", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 5 }, - "_2": { - "base": null, - "end_col": 8, - "end_line": 5, - "selector": "j", - "start_col": 7, - "start_line": 5, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 4, + "line": 5 }, - "end_col": 8, - "end_line": 5, - "start_col": 3, - "start_line": 5, - "type": "eflipflop" + "@type": "send_qualified", + "base": null, + "selector": "d" }, - "else": null, - "end_col": 2, - "end_line": 5, - "start_col": 0, - "start_line": 5, - "type": "if" - } - ], - "end_col": 3, - "end_line": 7, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "_2": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 5 + }, + "@type": "send_qualified", + "base": null, + "selector": "j" + } + }, + "else": null + } + ] } } } diff --git a/fixtures/if_flipflop.rb.uast b/fixtures/if_flipflop.rb.uast index 0b03c10..c275426 100644 --- a/fixtures/if_flipflop.rb.uast +++ b/fixtures/if_flipflop.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: if { -. . . . . Roles: Statement,If +. . . . . Roles: If,Statement . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -37,44 +37,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then -. . . . . . . TOKEN "a" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 12 -. . . . . . . . Line: 2 -. . . . . . . . Col: 5 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 16 -. . . . . . . . Line: 2 -. . . . . . . . Col: 9 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: body -. . . . . . . } -. . . . . . . Children: { -. . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive -. . . . . . . . . TOKEN "1" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 16 -. . . . . . . . . . Line: 2 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 16 -. . . . . . . . . . Line: 2 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: value -. . . . . . . . . } -. . . . . . . . } -. . . . . . . } -. . . . . . } -. . . . . . 1: iflipflop { -. . . . . . . Roles: Expression,Incomplete,List,Condition,If +. . . . . . 0: iflipflop { +. . . . . . . Roles: Condition,Expression,Incomplete,List . . . . . . . StartPosition: { . . . . . . . . Offset: 3 . . . . . . . . Line: 1 @@ -89,9 +53,8 @@ UAST: . . . . . . . . internalRole: condition . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: send { -. . . . . . . . . Roles: Identifier,Incomplete -. . . . . . . . . TOKEN "a" +. . . . . . . . 0: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Identifier,Incomplete,Qualified,Tuple,Value . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 3 . . . . . . . . . . Line: 1 @@ -104,11 +67,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: _1 +. . . . . . . . . . selector: a . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: send { -. . . . . . . . . Roles: Identifier,Incomplete -. . . . . . . . . TOKEN "b" +. . . . . . . . 1: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Incomplete,Qualified,Tuple,Value . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 6 . . . . . . . . . . Line: 1 @@ -121,39 +84,22 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: _2 +. . . . . . . . . . selector: b . . . . . . . . . } . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . } -. . . . } -. . . . 1: if { -. . . . . Roles: Statement,If -. . . . . StartPosition: { -. . . . . . Offset: 23 -. . . . . . Line: 5 -. . . . . . Col: 1 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 24 -. . . . . . Line: 5 -. . . . . . Col: 2 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then -. . . . . . . TOKEN "b" +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then +. . . . . . . TOKEN "a" . . . . . . . StartPosition: { -. . . . . . . . Offset: 36 -. . . . . . . . Line: 6 +. . . . . . . . Offset: 12 +. . . . . . . . Line: 2 . . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 40 -. . . . . . . . Line: 6 +. . . . . . . . Offset: 16 +. . . . . . . . Line: 2 . . . . . . . . Col: 9 . . . . . . . } . . . . . . . Properties: { @@ -161,16 +107,16 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive -. . . . . . . . . TOKEN "2" +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right +. . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 40 -. . . . . . . . . . Line: 6 +. . . . . . . . . . Offset: 16 +. . . . . . . . . . Line: 2 . . . . . . . . . . Col: 9 . . . . . . . . . } . . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 40 -. . . . . . . . . . Line: 6 +. . . . . . . . . . Offset: 16 +. . . . . . . . . . Line: 2 . . . . . . . . . . Col: 9 . . . . . . . . . } . . . . . . . . . Properties: { @@ -179,8 +125,26 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: eflipflop { -. . . . . . . Roles: Expression,Incomplete,List,Condition,If +. . . . . } +. . . . } +. . . . 1: if { +. . . . . Roles: If,Statement +. . . . . StartPosition: { +. . . . . . Offset: 23 +. . . . . . Line: 5 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 24 +. . . . . . Line: 5 +. . . . . . Col: 2 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: eflipflop { +. . . . . . . Roles: Condition,Expression . . . . . . . StartPosition: { . . . . . . . . Offset: 26 . . . . . . . . Line: 5 @@ -195,9 +159,8 @@ UAST: . . . . . . . . internalRole: condition . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: send { -. . . . . . . . . Roles: Identifier,Incomplete -. . . . . . . . . TOKEN "d" +. . . . . . . . 0: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified,Tuple,Value . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 26 . . . . . . . . . . Line: 5 @@ -210,11 +173,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: _1 +. . . . . . . . . . selector: d . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: send { -. . . . . . . . . Roles: Identifier,Incomplete -. . . . . . . . . TOKEN "j" +. . . . . . . . 1: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified,Tuple,Value . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 30 . . . . . . . . . . Line: 5 @@ -227,6 +190,43 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: _2 +. . . . . . . . . . selector: j +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then +. . . . . . . TOKEN "b" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 36 +. . . . . . . . Line: 6 +. . . . . . . . Col: 5 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 40 +. . . . . . . . Line: 6 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: int { +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right +. . . . . . . . . TOKEN "2" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 40 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 40 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: value . . . . . . . . . } . . . . . . . . } . . . . . . . } diff --git a/fixtures/int_literal.rb.native b/fixtures/int_literal.rb.native index 64baccd..c9f2216 100644 --- a/fixtures/int_literal.rb.native +++ b/fixtures/int_literal.rb.native @@ -3,22 +3,33 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 7, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 7, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": 123, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": 123, + "@type": "int" } } } diff --git a/fixtures/int_literal.rb.uast b/fixtures/int_literal.rb.uast index 9532ba7..690022b 100644 --- a/fixtures/int_literal.rb.uast +++ b/fixtures/int_literal.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 7 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: int { -. . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . TOKEN "123" . . . . . StartPosition: { . . . . . . Offset: 4 diff --git a/fixtures/internal_call.rb b/fixtures/internal_call.rb new file mode 100644 index 0000000..af0273f --- /dev/null +++ b/fixtures/internal_call.rb @@ -0,0 +1,11 @@ +def fnc1(a, b, c) + puts a, b, c +end + +class Foo + def initialize(a) + fnc1(1, 2, 3) + a.b.c + h.i.j = 10 + end +end diff --git a/fixtures/internal_call.rb.native b/fixtures/internal_call.rb.native new file mode 100644 index 0000000..d43ebf8 --- /dev/null +++ b/fixtures/internal_call.rb.native @@ -0,0 +1,393 @@ +{ + "status": "ok", + "language": "ruby", + "errors": [], + "ast": { + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 11 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "fnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@type": "args", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@token": "a", + "@type": "arg" + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@token": "b", + "@type": "arg" + }, + { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@token": "c", + "@type": "arg" + } + ] + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@token": "a", + "@type": "lvar" + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@token": "b", + "@type": "lvar" + }, + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@token": "c", + "@type": "lvar" + } + ] + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@token": "Foo", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@token": "initialize", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 19, + "line": 6 + }, + "@type": "args", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 20, + "line": 6 + }, + "@token": "a", + "@type": "arg" + } + ] + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@type": "send_qualified", + "base": null, + "selector": "fnc1", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 7 + }, + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 7 + }, + "@token": 2, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 20, + "line": 7 + }, + "@token": 3, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "b" + }, + "selector": "c" + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 9 + }, + "@token": "j", + "@type": "send_assign", + "base": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 9 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 9 + }, + "@type": "send_qualified", + "base": null, + "selector": "h" + }, + "selector": "i" + }, + "selector": "j=", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 9 + }, + "@token": 10, + "@type": "int" + } + ] + } + ] + } + ] + } + ], + "parent": null + } + ] + } + } +} diff --git a/fixtures/internal_call.rb.uast b/fixtures/internal_call.rb.uast new file mode 100644 index 0000000..93a168a --- /dev/null +++ b/fixtures/internal_call.rb.uast @@ -0,0 +1,475 @@ +Status: ok +Language: ruby +Errors: +UAST: +module { +. Roles: Identifier,Module,Statement +. Children: { +. . 0: begin { +. . . Roles: Block +. . . StartPosition: { +. . . . Offset: 0 +. . . . Line: 1 +. . . . Col: 1 +. . . } +. . . EndPosition: { +. . . . Offset: 138 +. . . . Line: 11 +. . . . Col: 3 +. . . } +. . . Properties: { +. . . . internalRole: file +. . . } +. . . Children: { +. . . . 0: def { +. . . . . Roles: Declaration,Function,Identifier,Statement +. . . . . TOKEN "fnc1" +. . . . . StartPosition: { +. . . . . . Offset: 0 +. . . . . . Line: 1 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 2 +. . . . . . Line: 1 +. . . . . . Col: 3 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: args { +. . . . . . . Roles: Argument,Expression,Incomplete +. . . . . . . StartPosition: { +. . . . . . . . Offset: 8 +. . . . . . . . Line: 1 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 16 +. . . . . . . . Line: 1 +. . . . . . . . Col: 17 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: args +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: arg { +. . . . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . . . TOKEN "a" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 9 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 10 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 9 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 10 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: children +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: arg { +. . . . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . . . TOKEN "b" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 12 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 13 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 12 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 13 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: children +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 2: arg { +. . . . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . . . TOKEN "c" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 15 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 16 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 15 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 16 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: children +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . . 1: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . StartPosition: { +. . . . . . . . Offset: 23 +. . . . . . . . Line: 2 +. . . . . . . . Col: 6 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 34 +. . . . . . . . Line: 2 +. . . . . . . . Col: 17 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . . selector: puts +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: lvar { +. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . TOKEN "a" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 28 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 11 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 28 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 11 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: values +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: lvar { +. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . TOKEN "b" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 31 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 14 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 31 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 14 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: values +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 2: lvar { +. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . TOKEN "c" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 34 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 17 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 34 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 17 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: values +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . } +. . . . } +. . . . 1: class { +. . . . . Roles: Declaration,Identifier,Statement,Type +. . . . . TOKEN "Foo" +. . . . . StartPosition: { +. . . . . . Offset: 41 +. . . . . . Line: 5 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 45 +. . . . . . Line: 5 +. . . . . . Col: 5 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: def { +. . . . . . . Roles: Declaration,Function,Identifier,Statement +. . . . . . . TOKEN "initialize" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 55 +. . . . . . . . Line: 6 +. . . . . . . . Col: 5 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 57 +. . . . . . . . Line: 6 +. . . . . . . . Col: 7 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 69 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 19 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 71 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 21 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: args +. . . . . . . . . } +. . . . . . . . . Children: { +. . . . . . . . . . 0: arg { +. . . . . . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . . . . . TOKEN "a" +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 70 +. . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . Col: 20 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 70 +. . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . Col: 20 +. . . . . . . . . . . } +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: children +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: begin { +. . . . . . . . . Roles: Block +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 81 +. . . . . . . . . . Line: 7 +. . . . . . . . . . Col: 9 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 126 +. . . . . . . . . . Line: 9 +. . . . . . . . . . Col: 18 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . . Children: { +. . . . . . . . . . 0: send_qualified { +. . . . . . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 81 +. . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . Col: 9 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 93 +. . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . Col: 21 +. . . . . . . . . . . } +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: body +. . . . . . . . . . . . selector: fnc1 +. . . . . . . . . . . } +. . . . . . . . . . . Children: { +. . . . . . . . . . . . 0: int { +. . . . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . . . TOKEN "1" +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 86 +. . . . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . . . Col: 14 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 86 +. . . . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . . . Col: 14 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: values +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . . 1: int { +. . . . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . . . TOKEN "2" +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 89 +. . . . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . . . Col: 17 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 89 +. . . . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . . . Col: 17 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: values +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . . 2: int { +. . . . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . . . TOKEN "3" +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 92 +. . . . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . . . Col: 20 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 92 +. . . . . . . . . . . . . . Line: 7 +. . . . . . . . . . . . . . Col: 20 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: values +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . . 1: send_call { +. . . . . . . . . . . Roles: Call,Expression,Function +. . . . . . . . . . . TOKEN "c" +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 103 +. . . . . . . . . . . . Line: 8 +. . . . . . . . . . . . Col: 9 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 107 +. . . . . . . . . . . . Line: 8 +. . . . . . . . . . . . Col: 13 +. . . . . . . . . . . } +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: body +. . . . . . . . . . . } +. . . . . . . . . . . Children: { +. . . . . . . . . . . . 0: send_call { +. . . . . . . . . . . . . Roles: Call,Expression,Function +. . . . . . . . . . . . . TOKEN "b" +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 103 +. . . . . . . . . . . . . . Line: 8 +. . . . . . . . . . . . . . Col: 9 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 105 +. . . . . . . . . . . . . . Line: 8 +. . . . . . . . . . . . . . Col: 11 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: base +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Children: { +. . . . . . . . . . . . . . 0: lvar { +. . . . . . . . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . . . . . . . TOKEN "a" +. . . . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . . . Offset: 103 +. . . . . . . . . . . . . . . . Line: 8 +. . . . . . . . . . . . . . . . Col: 9 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . . . Offset: 103 +. . . . . . . . . . . . . . . . Line: 8 +. . . . . . . . . . . . . . . . Col: 9 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . . . internalRole: base +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . } +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . . 2: send_assign { +. . . . . . . . . . . Roles: Assignment,Expression,Left +. . . . . . . . . . . TOKEN "j" +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 117 +. . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . Col: 9 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 126 +. . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . Col: 18 +. . . . . . . . . . . } +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: body +. . . . . . . . . . . . selector: j= +. . . . . . . . . . . } +. . . . . . . . . . . Children: { +. . . . . . . . . . . . 0: send_call { +. . . . . . . . . . . . . Roles: Call,Expression,Function +. . . . . . . . . . . . . TOKEN "i" +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 117 +. . . . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . . . Col: 9 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 119 +. . . . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . . . Col: 11 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: base +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Children: { +. . . . . . . . . . . . . . 0: send_qualified { +. . . . . . . . . . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . . . Offset: 117 +. . . . . . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . . . . . Col: 9 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . . . Offset: 117 +. . . . . . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . . . . . Col: 9 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . . . internalRole: base +. . . . . . . . . . . . . . . . selector: h +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . } +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . . 1: int { +. . . . . . . . . . . . . Roles: Assignment,Expression,Literal,Number,Primitive,Right +. . . . . . . . . . . . . TOKEN "10" +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 125 +. . . . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . . . Col: 17 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 126 +. . . . . . . . . . . . . . Line: 9 +. . . . . . . . . . . . . . Col: 18 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: values +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . } +. . . . } +. . . } +. . } +. } +} + diff --git a/fixtures/logical_ops.rb.native b/fixtures/logical_ops.rb.native index e6d4320..d7d7980 100644 --- a/fixtures/logical_ops.rb.native +++ b/fixtures/logical_ops.rb.native @@ -3,175 +3,294 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 7, - "end_line": 1, - "left": { - "base": null, - "end_col": 1, - "end_line": 1, - "selector": "a", - "start_col": 0, - "start_line": 1, - "type": "send" - }, - "right": { - "base": null, - "end_col": 7, - "end_line": 1, - "selector": "b", - "start_col": 6, - "start_line": 1, - "type": "send" - }, - "start_col": 0, - "start_line": 1, - "type": "and" - }, - { - "end_col": 6, - "end_line": 2, - "left": { - "base": null, - "end_col": 1, - "end_line": 2, - "selector": "a", - "start_col": 0, - "start_line": 2, - "type": "send" - }, - "right": { - "base": null, - "end_col": 6, - "end_line": 2, - "selector": "b", - "start_col": 5, - "start_line": 2, - "type": "send" - }, - "start_col": 0, - "start_line": 2, - "type": "or" - }, - { - "end_col": 6, - "end_line": 3, - "left": { - "base": null, - "end_col": 1, - "end_line": 3, - "selector": "a", - "start_col": 0, - "start_line": 3, - "type": "send" - }, - "right": { - "base": null, - "end_col": 6, - "end_line": 3, - "selector": "b", - "start_col": 5, - "start_line": 3, - "type": "send" - }, - "start_col": 0, - "start_line": 3, - "type": "and" - }, - { - "end_col": 6, - "end_line": 4, - "left": { - "base": null, - "end_col": 1, - "end_line": 4, - "selector": "a", - "start_col": 0, - "start_line": 4, - "type": "send" - }, - "right": { - "base": null, - "end_col": 6, - "end_line": 4, - "selector": "b", - "start_col": 5, - "start_line": 4, - "type": "send" - }, - "start_col": 0, - "start_line": 4, - "type": "or" - }, - { - "base": { - "base": null, - "end_col": 2, - "end_line": 5, - "selector": "b", - "start_col": 1, - "start_line": 5, - "type": "send" - }, - "end_col": 2, - "end_line": 5, - "selector": "!", - "start_col": 0, - "start_line": 5, - "type": "send" - }, - { - "base": { - "body": [ - { - "end_col": 12, - "end_line": 6, - "left": { - "base": null, - "end_col": 6, - "end_line": 6, - "selector": "a", - "start_col": 5, - "start_line": 6, - "type": "send" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "and", + "left": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" + }, + "right": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "b" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "or", + "left": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" + }, + "right": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "b" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "and", + "left": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" + }, + "right": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@type": "send_qualified", + "base": null, + "selector": "b" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "or", + "left": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" + }, + "right": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 4 + }, + "@type": "send_qualified", + "base": null, + "selector": "b" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 2, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 2, + "line": 5 + }, + "@type": "send_qualified", + "base": null, + "selector": "b" + }, + "selector": "!" + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@type": "and", + "left": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 6 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" + }, + "right": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 6 }, - "right": { - "base": null, - "end_col": 12, - "end_line": 6, - "selector": "b", - "start_col": 11, - "start_line": 6, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 6 }, - "start_col": 5, - "start_line": 6, - "type": "and" + "@type": "send_qualified", + "base": null, + "selector": "b" } - ], - "end_col": 13, - "end_line": 6, - "start_col": 4, - "start_line": 6, - "type": "begin" - }, - "end_col": 13, - "end_line": 6, - "selector": "!", - "start_col": 0, - "start_line": 6, - "type": "send" - } - ], - "end_col": 13, - "end_line": 6, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] + }, + "selector": "!" + } + ] } } } diff --git a/fixtures/logical_ops.rb.uast b/fixtures/logical_ops.rb.uast index 3eecb85..cf49145 100644 --- a/fixtures/logical_ops.rb.uast +++ b/fixtures/logical_ops.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 13 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: and { -. . . . . Roles: Expression,Binary,Operator,Boolean,And +. . . . . Roles: And,Binary,Boolean,Expression,Operator . . . . . TOKEN "and" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -38,9 +38,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Left -. . . . . . . TOKEN "a" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Expression,Identical,Left,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 0 . . . . . . . . Line: 1 @@ -53,11 +52,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: left +. . . . . . . . selector: a . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Right -. . . . . . . TOKEN "b" +. . . . . . 1: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 6 . . . . . . . . Line: 1 @@ -70,12 +69,13 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: right +. . . . . . . . selector: b . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 1: or { -. . . . . Roles: Expression,Binary,Operator,Boolean,Or +. . . . . Roles: Binary,Boolean,Expression,Operator,Or . . . . . TOKEN "or" . . . . . StartPosition: { . . . . . . Offset: 8 @@ -91,9 +91,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Left -. . . . . . . TOKEN "a" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Expression,Identical,Left,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 8 . . . . . . . . Line: 2 @@ -106,11 +105,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: left +. . . . . . . . selector: a . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Right -. . . . . . . TOKEN "b" +. . . . . . 1: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 13 . . . . . . . . Line: 2 @@ -123,12 +122,13 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: right +. . . . . . . . selector: b . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 2: and { -. . . . . Roles: Expression,Binary,Operator,Boolean,And +. . . . . Roles: And,Binary,Boolean,Expression,Operator . . . . . TOKEN "and" . . . . . StartPosition: { . . . . . . Offset: 15 @@ -144,9 +144,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Left -. . . . . . . TOKEN "a" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Expression,Identical,Left,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 15 . . . . . . . . Line: 3 @@ -159,11 +158,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: left +. . . . . . . . selector: a . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Right -. . . . . . . TOKEN "b" +. . . . . . 1: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 20 . . . . . . . . Line: 3 @@ -176,12 +175,13 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: right +. . . . . . . . selector: b . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 3: or { -. . . . . Roles: Expression,Binary,Operator,Boolean,Or +. . . . . Roles: Binary,Boolean,Expression,Operator,Or . . . . . TOKEN "or" . . . . . StartPosition: { . . . . . . Offset: 22 @@ -197,9 +197,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Left -. . . . . . . TOKEN "a" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Expression,Identical,Left,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 22 . . . . . . . . Line: 4 @@ -212,11 +211,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: left +. . . . . . . . selector: a . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Right -. . . . . . . TOKEN "b" +. . . . . . 1: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 27 . . . . . . . . Line: 4 @@ -229,12 +228,13 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: right +. . . . . . . . selector: b . . . . . . . } . . . . . . } . . . . . } . . . . } -. . . . 4: send { -. . . . . Roles: Expression,Identifier,Operator,Relational,Not +. . . . 4: send_operator { +. . . . . Roles: Expression,Not,Operator,Relational,Unary . . . . . TOKEN "!" . . . . . StartPosition: { . . . . . . Offset: 29 @@ -250,9 +250,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Qualified,Identifier -. . . . . . . TOKEN "b" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 30 . . . . . . . . Line: 5 @@ -265,12 +264,13 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: base +. . . . . . . . selector: b . . . . . . . } . . . . . . } . . . . . } . . . . } -. . . . 5: send { -. . . . . Roles: Expression,Identifier,Operator,Relational,Not +. . . . 5: send_operator { +. . . . . Roles: Expression,Not,Operator,Relational,Unary . . . . . TOKEN "!" . . . . . StartPosition: { . . . . . . Offset: 32 @@ -303,7 +303,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: and { -. . . . . . . . . Roles: Expression,Binary,Operator,Boolean,And +. . . . . . . . . Roles: And,Binary,Boolean,Expression,Operator . . . . . . . . . TOKEN "and" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 37 @@ -319,9 +319,8 @@ UAST: . . . . . . . . . . internalRole: body . . . . . . . . . } . . . . . . . . . Children: { -. . . . . . . . . . 0: send { -. . . . . . . . . . . Roles: Expression,Left -. . . . . . . . . . . TOKEN "a" +. . . . . . . . . . 0: send_qualified { +. . . . . . . . . . . Roles: Expression,Identical,Left,Qualified . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 37 . . . . . . . . . . . . Line: 6 @@ -334,11 +333,11 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Properties: { . . . . . . . . . . . . internalRole: left +. . . . . . . . . . . . selector: a . . . . . . . . . . . } . . . . . . . . . . } -. . . . . . . . . . 1: send { -. . . . . . . . . . . Roles: Expression,Right -. . . . . . . . . . . TOKEN "b" +. . . . . . . . . . 1: send_qualified { +. . . . . . . . . . . Roles: Expression,Identical,Qualified,Right . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 43 . . . . . . . . . . . . Line: 6 @@ -351,6 +350,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Properties: { . . . . . . . . . . . . internalRole: right +. . . . . . . . . . . . selector: b . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . } diff --git a/fixtures/method_alias.rb.native b/fixtures/method_alias.rb.native index 7f18a43..60f9a00 100644 --- a/fixtures/method_alias.rb.native +++ b/fixtures/method_alias.rb.native @@ -3,70 +3,111 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "args": { - "end_col": 13, - "end_line": 2, - "start_col": 11, - "start_line": 2, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Foo", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "bar", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 2 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@type": "alias", + "_1": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 5 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 2, - "name": "bar", - "start_col": 4, - "start_line": 2, - "type": "def" + "@token": "baz", + "@type": "sym" }, - { - "_1": { - "end_col": 13, - "end_line": 5, - "start_col": 10, - "start_line": 5, - "token": "baz", - "type": "sym" + "_2": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 5 }, - "_2": { - "end_col": 17, - "end_line": 5, - "start_col": 14, - "start_line": 5, - "token": "bar", - "type": "sym" + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 5 }, - "end_col": 9, - "end_line": 5, - "start_col": 4, - "start_line": 5, - "type": "alias" + "@token": "bar", + "@type": "sym" } - ], - "end_col": 17, - "end_line": 5, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Foo", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/method_alias.rb.uast b/fixtures/method_alias.rb.uast index 6d5cb37..0b4ccf2 100644 --- a/fixtures/method_alias.rb.uast +++ b/fixtures/method_alias.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Foo" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: begin { @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "bar" . . . . . . . StartPosition: { . . . . . . . . Offset: 14 @@ -55,8 +55,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 21 . . . . . . . . . . Line: 2 @@ -71,16 +77,10 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } . . . . . . 1: alias { -. . . . . . . Roles: Statement,Alias +. . . . . . . Roles: Alias,Statement . . . . . . . StartPosition: { . . . . . . . . Offset: 37 . . . . . . . . Line: 5 @@ -96,7 +96,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: sym { -. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . Roles: Expression,Identifier,Tuple,Value . . . . . . . . . TOKEN "baz" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 43 @@ -113,7 +113,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: sym { -. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . Roles: Expression,Identifier,Tuple,Value . . . . . . . . . TOKEN "bar" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 47 diff --git a/fixtures/module.rb.native b/fixtures/module.rb.native index 42905b3..a31279a 100644 --- a/fixtures/module.rb.native +++ b/fixtures/module.rb.native @@ -3,20 +3,25 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "begin": [ - { - "type": "NilClass" - } - ], - "end_col": 6, - "end_line": 1, - "name": "Foo", - "start_col": 0, - "start_line": 1, - "type": "module" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Foo", + "@type": "module", + "begin": [ + { + "@type": "NilNode" + } + ] } } } diff --git a/fixtures/module.rb.uast b/fixtures/module.rb.uast index b9957a0..bc51c48 100644 --- a/fixtures/module.rb.uast +++ b/fixtures/module.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: module { -. . . Roles: Statement,Module,Identifier +. . . Roles: Identifier,Module,Statement . . . TOKEN "Foo" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: NilClass { -. . . . . Roles: Statement,Type,Null +. . . . 0: NilNode { +. . . . . Roles: Null . . . . . Properties: { . . . . . . internalRole: begin . . . . . } diff --git a/fixtures/next.rb.native b/fixtures/next.rb.native index 6af6860..5ee24ca 100644 --- a/fixtures/next.rb.native +++ b/fixtures/next.rb.native @@ -3,43 +3,72 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "while", + "body": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "if", "body": { - "body": { - "end_col": 12, - "end_line": 3, - "start_col": 8, - "start_line": 3, - "target": null, - "type": "next" + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 3 }, - "condition": { - "end_col": 12, - "end_line": 2, - "start_col": 7, - "start_line": 2, - "type": "false" + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 3 }, - "else": null, - "end_col": 6, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "type": "if" + "@type": "next", + "target": null }, "condition": { - "end_col": 10, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "type": "true" + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 2 + }, + "@type": "false" + }, + "else": null + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 }, - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "while" + "@type": "true" } } } diff --git a/fixtures/next.rb.uast b/fixtures/next.rb.uast index 46bf62a..394e387 100644 --- a/fixtures/next.rb.uast +++ b/fixtures/next.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: while { . . . Roles: Statement,While @@ -18,11 +18,28 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: if { -. . . . . Roles: Statement,If,Expression,While,Body +. . . . 0: true { +. . . . . Roles: Boolean,Condition,Expression,Literal +. . . . . TOKEN "true" +. . . . . StartPosition: { +. . . . . . Offset: 6 +. . . . . . Line: 1 +. . . . . . Col: 7 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 9 +. . . . . . Line: 1 +. . . . . . Col: 10 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: condition +. . . . . } +. . . . } +. . . . 1: if { +. . . . . Roles: Body,If,Statement . . . . . StartPosition: { . . . . . . Offset: 15 . . . . . . Line: 2 @@ -37,58 +54,41 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: next { -. . . . . . . Roles: Expression,If,Then +. . . . . . 0: false { +. . . . . . . Roles: Boolean,Condition,Expression,Literal +. . . . . . . TOKEN "false" . . . . . . . StartPosition: { -. . . . . . . . Offset: 32 -. . . . . . . . Line: 3 -. . . . . . . . Col: 9 +. . . . . . . . Offset: 18 +. . . . . . . . Line: 2 +. . . . . . . . Col: 8 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 35 -. . . . . . . . Line: 3 +. . . . . . . . Offset: 22 +. . . . . . . . Line: 2 . . . . . . . . Col: 12 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: body +. . . . . . . . internalRole: condition . . . . . . . } . . . . . . } -. . . . . . 1: false { -. . . . . . . Roles: Expression,Condition,If,Boolean,Literal -. . . . . . . TOKEN "false" +. . . . . . 1: next { +. . . . . . . Roles: Body,Expression,Then . . . . . . . StartPosition: { -. . . . . . . . Offset: 18 -. . . . . . . . Line: 2 -. . . . . . . . Col: 8 +. . . . . . . . Offset: 32 +. . . . . . . . Line: 3 +. . . . . . . . Col: 9 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 22 -. . . . . . . . Line: 2 +. . . . . . . . Offset: 35 +. . . . . . . . Line: 3 . . . . . . . . Col: 12 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: condition +. . . . . . . . internalRole: body . . . . . . . } . . . . . . } . . . . . } . . . . } -. . . . 1: true { -. . . . . Roles: Expression,Condition,While,Boolean,Literal -. . . . . TOKEN "true" -. . . . . StartPosition: { -. . . . . . Offset: 6 -. . . . . . Line: 1 -. . . . . . Col: 7 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 9 -. . . . . . Line: 1 -. . . . . . Col: 10 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: condition -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/qualified.rb b/fixtures/qualified.rb index c317e03..b42e476 100644 --- a/fixtures/qualified.rb +++ b/fixtures/qualified.rb @@ -1 +1,2 @@ a.b.c.d = 1 +h.i.j diff --git a/fixtures/qualified.rb.native b/fixtures/qualified.rb.native index d3a3eea..0298e32 100644 --- a/fixtures/qualified.rb.native +++ b/fixtures/qualified.rb.native @@ -3,50 +3,138 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": { + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "d", + "@type": "send_assign", "base": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_call", "base": { - "base": null, - "end_col": 1, - "end_line": 1, - "selector": "a", - "start_col": 0, - "start_line": 1, - "type": "send" + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "a" + }, + "selector": "b" }, - "end_col": 3, - "end_line": 1, - "selector": "b", - "start_col": 0, - "start_line": 1, - "type": "send" + "selector": "c" }, - "end_col": 5, - "end_line": 1, - "selector": "c", - "start_col": 0, - "start_line": 1, - "type": "send" + "selector": "d=", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + ] }, - "end_col": 11, - "end_line": 1, - "selector": "d=", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 11, - "end_line": 1, - "start_col": 10, - "start_line": 1, - "token": 1, - "type": "int" - } - ] - } + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "h" + }, + "selector": "i" + }, + "selector": "j" + } + ] } } } diff --git a/fixtures/qualified.rb.uast b/fixtures/qualified.rb.uast index c717b55..22212d2 100644 --- a/fixtures/qualified.rb.uast +++ b/fixtures/qualified.rb.uast @@ -2,96 +2,170 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { -. . 0: send { -. . . Roles: Expression,Identifier,Call -. . . TOKEN "d=" +. . 0: begin { +. . . Roles: Block . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 . . . . Col: 1 . . . } . . . EndPosition: { -. . . . Offset: 10 -. . . . Line: 1 -. . . . Col: 11 +. . . . Offset: 16 +. . . . Line: 2 +. . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Qualified,Identifier -. . . . . TOKEN "c" +. . . . 0: send_assign { +. . . . . Roles: Assignment,Expression,Left +. . . . . TOKEN "d" . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 . . . . . . Col: 1 . . . . . } . . . . . EndPosition: { -. . . . . . Offset: 4 +. . . . . . Offset: 10 . . . . . . Line: 1 -. . . . . . Col: 5 +. . . . . . Col: 11 . . . . . } . . . . . Properties: { -. . . . . . internalRole: base +. . . . . . internalRole: body +. . . . . . selector: d= . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Qualified,Identifier -. . . . . . . TOKEN "b" +. . . . . . 0: send_call { +. . . . . . . Roles: Call,Expression,Function +. . . . . . . TOKEN "c" . . . . . . . StartPosition: { . . . . . . . . Offset: 0 . . . . . . . . Line: 1 . . . . . . . . Col: 1 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 2 +. . . . . . . . Offset: 4 . . . . . . . . Line: 1 -. . . . . . . . Col: 3 +. . . . . . . . Col: 5 . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: base . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: send { -. . . . . . . . . Roles: Expression,Qualified,Identifier -. . . . . . . . . TOKEN "a" +. . . . . . . . 0: send_call { +. . . . . . . . . Roles: Call,Expression,Function +. . . . . . . . . TOKEN "b" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 0 . . . . . . . . . . Line: 1 . . . . . . . . . . Col: 1 . . . . . . . . . } . . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 0 +. . . . . . . . . . Offset: 2 . . . . . . . . . . Line: 1 -. . . . . . . . . . Col: 1 +. . . . . . . . . . Col: 3 . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: base . . . . . . . . . } +. . . . . . . . . Children: { +. . . . . . . . . . 0: send_qualified { +. . . . . . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 0 +. . . . . . . . . . . . Line: 1 +. . . . . . . . . . . . Col: 1 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 0 +. . . . . . . . . . . . Line: 1 +. . . . . . . . . . . . Col: 1 +. . . . . . . . . . . } +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: base +. . . . . . . . . . . . selector: a +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . } . . . . . . . . } . . . . . . . } . . . . . . } +. . . . . . 1: int { +. . . . . . . Roles: Assignment,Expression,Literal,Number,Primitive,Right +. . . . . . . TOKEN "1" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 10 +. . . . . . . . Line: 1 +. . . . . . . . Col: 11 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 10 +. . . . . . . . Line: 1 +. . . . . . . . Col: 11 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: values +. . . . . . . } +. . . . . . } . . . . . } . . . . } -. . . . 1: int { -. . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier -. . . . . TOKEN "1" +. . . . 1: send_call { +. . . . . Roles: Call,Expression,Function +. . . . . TOKEN "j" . . . . . StartPosition: { -. . . . . . Offset: 10 -. . . . . . Line: 1 -. . . . . . Col: 11 +. . . . . . Offset: 12 +. . . . . . Line: 2 +. . . . . . Col: 1 . . . . . } . . . . . EndPosition: { -. . . . . . Offset: 10 -. . . . . . Line: 1 -. . . . . . Col: 11 +. . . . . . Offset: 16 +. . . . . . Line: 2 +. . . . . . Col: 5 . . . . . } . . . . . Properties: { -. . . . . . internalRole: values +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: send_call { +. . . . . . . Roles: Call,Expression,Function +. . . . . . . TOKEN "i" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 12 +. . . . . . . . Line: 2 +. . . . . . . . Col: 1 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 14 +. . . . . . . . Line: 2 +. . . . . . . . Col: 3 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: base +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 12 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 1 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 12 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 1 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: base +. . . . . . . . . . selector: h +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } . . . . . } . . . . } . . . } diff --git a/fixtures/rational_literal.rb.native b/fixtures/rational_literal.rb.native index 500ad49..d0d09a9 100644 --- a/fixtures/rational_literal.rb.native +++ b/fixtures/rational_literal.rb.native @@ -3,22 +3,33 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 8, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 8, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": "2/1", - "type": "rational" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": "2/1", + "@type": "rational" } } } diff --git a/fixtures/rational_literal.rb.uast b/fixtures/rational_literal.rb.uast index 031d924..e210062 100644 --- a/fixtures/rational_literal.rb.uast +++ b/fixtures/rational_literal.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 8 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: rational { -. . . . . Roles: Right +. . . . . Roles: Binary,Expression,Incomplete,Literal,Number,Primitive,Right . . . . . TOKEN "2/1" . . . . . StartPosition: { . . . . . . Offset: 4 diff --git a/fixtures/redo.rb.native b/fixtures/redo.rb.native index a43bf78..48f56d9 100644 --- a/fixtures/redo.rb.native +++ b/fixtures/redo.rb.native @@ -3,27 +3,44 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "end_col": 8, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "type": "redo" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "while", + "body": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 2 }, - "condition": { - "end_col": 10, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "type": "true" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "while" + "@type": "redo" + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "true" } } } diff --git a/fixtures/redo.rb.uast b/fixtures/redo.rb.uast index c8eafc8..4de6664 100644 --- a/fixtures/redo.rb.uast +++ b/fixtures/redo.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: while { . . . Roles: Statement,While @@ -18,27 +18,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: redo { -. . . . . Roles: Expression,While,Body -. . . . . StartPosition: { -. . . . . . Offset: 15 -. . . . . . Line: 2 -. . . . . . Col: 5 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 18 -. . . . . . Line: 2 -. . . . . . Col: 8 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . } -. . . . 1: true { -. . . . . Roles: Expression,Condition,While,Boolean,Literal +. . . . 0: true { +. . . . . Roles: Boolean,Condition,Expression,Literal . . . . . TOKEN "true" . . . . . StartPosition: { . . . . . . Offset: 6 @@ -54,6 +38,22 @@ UAST: . . . . . . internalRole: condition . . . . . } . . . . } +. . . . 1: redo { +. . . . . Roles: Body +. . . . . StartPosition: { +. . . . . . Offset: 15 +. . . . . . Line: 2 +. . . . . . Col: 5 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 18 +. . . . . . Line: 2 +. . . . . . Col: 8 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . } . . . } . . } . } diff --git a/fixtures/regexp.rb.native b/fixtures/regexp.rb.native index d919ad6..750ff9c 100644 --- a/fixtures/regexp.rb.native +++ b/fixtures/regexp.rb.native @@ -3,38 +3,55 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 12, - "end_line": 1, - "options": { - "end_col": 12, - "end_line": 1, - "options": [ - { - "token": "i", - "type": "Symbol" - }, - { - "token": "m", - "type": "Symbol" - } - ], - "start_col": 10, - "start_line": 1, - "type": "regopt" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "regexp", + "options": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 1 }, - "start_col": 0, - "start_line": 1, - "text": { - "end_col": 9, - "end_line": 1, - "start_col": 1, - "start_line": 1, - "token": "text(.*)", - "type": "str" + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 1 }, - "type": "regexp" + "@type": "regopt", + "options": [ + { + "@token": "i", + "@type": "Symbol" + }, + { + "@token": "m", + "@type": "Symbol" + } + ] + }, + "text": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 2, + "line": 1 + }, + "@token": "text(.*)", + "@type": "str" } } } diff --git a/fixtures/regexp.rb.uast b/fixtures/regexp.rb.uast index 9ee5eea..eea2cfc 100644 --- a/fixtures/regexp.rb.uast +++ b/fixtures/regexp.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: regexp { . . . Roles: Expression,Regexp @@ -18,11 +18,28 @@ UAST: . . . . Col: 12 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: regopt { -. . . . . Roles: Expression,Regexp,Incomplete +. . . . 0: str { +. . . . . Roles: Expression,Literal,Primitive,String +. . . . . TOKEN "text(.*)" +. . . . . StartPosition: { +. . . . . . Offset: 1 +. . . . . . Line: 1 +. . . . . . Col: 2 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 8 +. . . . . . Line: 1 +. . . . . . Col: 9 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: text +. . . . . } +. . . . } +. . . . 1: regopt { +. . . . . Roles: Expression,Incomplete,Regexp . . . . . StartPosition: { . . . . . . Offset: 10 . . . . . . Line: 1 @@ -38,14 +55,14 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: Symbol { -. . . . . . . Roles: Expression,Regexp,Incomplete,Identifier +. . . . . . . Roles: Expression,Identifier . . . . . . . TOKEN "i" . . . . . . . Properties: { . . . . . . . . internalRole: options . . . . . . . } . . . . . . } . . . . . . 1: Symbol { -. . . . . . . Roles: Expression,Regexp,Incomplete,Identifier +. . . . . . . Roles: Expression,Identifier . . . . . . . TOKEN "m" . . . . . . . Properties: { . . . . . . . . internalRole: options @@ -53,23 +70,6 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: str { -. . . . . Roles: Expression,Literal,String,Primitive -. . . . . TOKEN "text(.*)" -. . . . . StartPosition: { -. . . . . . Offset: 1 -. . . . . . Line: 1 -. . . . . . Col: 2 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 8 -. . . . . . Line: 1 -. . . . . . Col: 9 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: text -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/rescue.rb.native b/fixtures/rescue.rb.native index e667594..1c7bd0e 100644 --- a/fixtures/rescue.rb.native +++ b/fixtures/rescue.rb.native @@ -3,68 +3,103 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "base": null, - "end_col": 15, - "end_line": 2, - "selector": "raise", - "start_col": 4, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 15, - "end_line": 2, - "start_col": 10, - "start_line": 2, - "token": "foo", - "type": "str" - } - ] + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "kwbegin", + "body": [ + { + "@type": "rescue", + "body": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 }, - "else": { - "type": "NilClass" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "handlers": [ + "@type": "send_qualified", + "base": null, + "selector": "raise", + "values": [ { - "alias": null, - "body": { - "end_col": 9, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 4, - "start_col": 8, - "start_line": 4, - "token": 1, - "type": "int" - } + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 2 }, - "end_col": 9, - "end_line": 4, - "exceptions": null, - "start_col": 0, - "start_line": 3, - "type": "resbody" + "@token": "foo", + "@type": "str" } - ], - "type": "rescue" - } - ], - "end_col": 3, - "end_line": 5, - "start_col": 0, - "start_line": 1, - "type": "kwbegin" - } + ] + }, + "else": { + "@type": "NilNode" + }, + "handlers": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "resbody", + "alias": null, + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@token": 1, + "@type": "int" + } + }, + "exceptions": null + } + ] + } + ] } } } diff --git a/fixtures/rescue.rb.uast b/fixtures/rescue.rb.uast index f4ec93d..af4f34e 100644 --- a/fixtures/rescue.rb.uast +++ b/fixtures/rescue.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: kwbegin { -. . . Roles: Expression,Block,Try +. . . Roles: Block,Expression . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,18 +18,23 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: rescue { -. . . . . Roles: Expression,Try,Body +. . . . . Roles: Body,Expression,Try . . . . . Properties: { . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Call,Identifier,Statement,Throw -. . . . . . . TOKEN "raise" +. . . . . . 0: NilNode { +. . . . . . . Roles: Null +. . . . . . . Properties: { +. . . . . . . . internalRole: else +. . . . . . . } +. . . . . . } +. . . . . . 1: send_qualified { +. . . . . . . Roles: Body,Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 10 . . . . . . . . Line: 2 @@ -42,10 +47,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: body +. . . . . . . . selector: raise . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive,Argument,Identifier +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "foo" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 16 @@ -63,14 +69,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: NilClass { -. . . . . . . Roles: Statement,Type,Null -. . . . . . . Properties: { -. . . . . . . . internalRole: else -. . . . . . . } -. . . . . . } . . . . . . 2: resbody { -. . . . . . . Roles: Expression,Catch +. . . . . . . Roles: Catch,Expression . . . . . . . StartPosition: { . . . . . . . . Offset: 22 . . . . . . . . Line: 3 @@ -86,7 +86,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 33 @@ -103,7 +103,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 37 diff --git a/fixtures/rescue_ensure.rb.native b/fixtures/rescue_ensure.rb.native index 02ee704..fc3fb2b 100644 --- a/fixtures/rescue_ensure.rb.native +++ b/fixtures/rescue_ensure.rb.native @@ -3,55 +3,90 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "kwbegin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "ensure", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "end_col": 6, - "end_line": 3, - "ensure_body": { - "end_col": 14, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "target": "always", - "type": "lvasgn", - "value": { - "end_col": 14, - "end_line": 4, - "start_col": 13, - "start_line": 4, - "token": 0, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "start_col": 0, - "start_line": 3, - "type": "ensure" + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + "ensure_body": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "lvasgn", + "target": "always", + "value": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 4 + }, + "@token": 0, + "@type": "int" + } } - ], - "end_col": 3, - "end_line": 5, - "start_col": 0, - "start_line": 1, - "type": "kwbegin" - } + } + ] } } } diff --git a/fixtures/rescue_ensure.rb.uast b/fixtures/rescue_ensure.rb.uast index e9b5363..1ff4d8c 100644 --- a/fixtures/rescue_ensure.rb.uast +++ b/fixtures/rescue_ensure.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: kwbegin { -. . . Roles: Expression,Block,Try +. . . Roles: Block,Expression . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: ensure { -. . . . . Roles: Expression,Finally,Body +. . . . . Roles: Expression,Finally . . . . . StartPosition: { . . . . . . Offset: 16 . . . . . . Line: 3 @@ -38,7 +38,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 14 @@ -74,7 +74,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "always" . . . . . . . StartPosition: { . . . . . . . . Offset: 27 @@ -91,7 +91,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "0" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 36 diff --git a/fixtures/rescue_named.rb.native b/fixtures/rescue_named.rb.native index 7ac97aa..b1411a3 100644 --- a/fixtures/rescue_named.rb.native +++ b/fixtures/rescue_named.rb.native @@ -3,114 +3,185 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "base": null, - "end_col": 15, - "end_line": 2, - "selector": "raise", - "start_col": 4, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 15, - "end_line": 2, - "start_col": 10, - "start_line": 2, - "token": "foo", - "type": "str" - } - ] + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "kwbegin", + "body": [ + { + "@type": "rescue", + "body": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 }, - "else": { - "end_col": 9, - "end_line": 6, - "start_col": 4, - "start_line": 6, - "target": "b", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 6, - "start_col": 8, - "start_line": 6, - "token": 0, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "handlers": [ + "@type": "send_qualified", + "base": null, + "selector": "raise", + "values": [ { - "alias": { - "end_col": 21, - "end_line": 3, - "start_col": 20, - "start_line": 3, - "target": "e", - "type": "lvasgn", - "value": null + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@token": "foo", + "@type": "str" + } + ] + }, + "else": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@token": 0, + "@type": "int" + } + }, + "handlers": [ + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "resbody", + "alias": { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 21, + "line": 3 }, - "body": { - "end_col": 17, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "target": "a", - "type": "lvasgn", - "value": { - "base": { - "end_col": 9, - "end_line": 4, - "start_col": 8, - "start_line": 4, - "token": "e", - "type": "lvar" + "@type": "lvasgn", + "target": "e", + "value": null + }, + "body": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 }, - "end_col": 17, - "end_line": 4, - "selector": "message", - "start_col": 8, - "start_line": 4, - "type": "send" - } + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@token": "e", + "@type": "lvar" + }, + "selector": "message" + } + }, + "exceptions": { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 3 }, - "end_col": 17, - "end_line": 4, - "exceptions": { - "contents": [ - { - "base": null, - "end_col": 16, - "end_line": 3, - "start_col": 7, - "start_line": 3, - "token": "Exception", - "type": "const" - } - ], - "end_col": 16, - "end_line": 3, - "start_col": 7, - "start_line": 3, - "type": "array" + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 3 }, - "start_col": 0, - "start_line": 3, - "type": "resbody" + "@type": "array", + "contents": [ + { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 3 + }, + "@token": "Exception", + "@type": "const", + "base": null + } + ] } - ], - "type": "rescue" - } - ], - "end_col": 3, - "end_line": 7, - "start_col": 0, - "start_line": 1, - "type": "kwbegin" - } + } + ] + } + ] } } } diff --git a/fixtures/rescue_named.rb.uast b/fixtures/rescue_named.rb.uast index bb2014d..21b80ab 100644 --- a/fixtures/rescue_named.rb.uast +++ b/fixtures/rescue_named.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: kwbegin { -. . . Roles: Expression,Block,Try +. . . Roles: Block,Expression . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,18 +18,17 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: rescue { -. . . . . Roles: Expression,Try,Body +. . . . . Roles: Body,Expression,Try . . . . . Properties: { . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Call,Identifier,Statement,Throw -. . . . . . . TOKEN "raise" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Body,Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 10 . . . . . . . . Line: 2 @@ -42,10 +41,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: body +. . . . . . . . selector: raise . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive,Argument,Identifier +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "foo" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 16 @@ -63,44 +63,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left -. . . . . . . TOKEN "b" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 71 -. . . . . . . . Line: 6 -. . . . . . . . Col: 5 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 75 -. . . . . . . . Line: 6 -. . . . . . . . Col: 9 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: else -. . . . . . . } -. . . . . . . Children: { -. . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive -. . . . . . . . . TOKEN "0" -. . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 75 -. . . . . . . . . . Line: 6 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 75 -. . . . . . . . . . Line: 6 -. . . . . . . . . . Col: 9 -. . . . . . . . . } -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: value -. . . . . . . . . } -. . . . . . . . } -. . . . . . . } -. . . . . . } -. . . . . . 2: resbody { -. . . . . . . Roles: Expression,Catch +. . . . . . 1: resbody { +. . . . . . . Roles: Catch,Expression . . . . . . . StartPosition: { . . . . . . . . Offset: 22 . . . . . . . . Line: 3 @@ -115,8 +79,43 @@ UAST: . . . . . . . . internalRole: handlers . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . 0: array { +. . . . . . . . . Roles: Expression,List,Literal,Primitive +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 29 +. . . . . . . . . . Line: 3 +. . . . . . . . . . Col: 8 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 37 +. . . . . . . . . . Line: 3 +. . . . . . . . . . Col: 16 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: exceptions +. . . . . . . . . } +. . . . . . . . . Children: { +. . . . . . . . . . 0: const { +. . . . . . . . . . . Roles: Expression,Identifier,Incomplete +. . . . . . . . . . . TOKEN "Exception" +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 29 +. . . . . . . . . . . . Line: 3 +. . . . . . . . . . . . Col: 8 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 37 +. . . . . . . . . . . . Line: 3 +. . . . . . . . . . . . Col: 16 +. . . . . . . . . . . } +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: contents +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: lvasgn { +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "e" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 42 @@ -132,8 +131,8 @@ UAST: . . . . . . . . . . internalRole: alias . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: lvasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . . 2: lvasgn { +. . . . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 48 @@ -149,8 +148,8 @@ UAST: . . . . . . . . . . internalRole: body . . . . . . . . . } . . . . . . . . . Children: { -. . . . . . . . . . 0: send { -. . . . . . . . . . . Roles: Right,Expression,Identifier +. . . . . . . . . . 0: send_call { +. . . . . . . . . . . Roles: Binary,Call,Expression,Function,Right . . . . . . . . . . . TOKEN "message" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 52 @@ -187,39 +186,40 @@ UAST: . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } -. . . . . . . . 2: array { -. . . . . . . . . Roles: Expression,Literal,List,Primitive +. . . . . . . } +. . . . . . } +. . . . . . 2: lvasgn { +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left +. . . . . . . TOKEN "b" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 71 +. . . . . . . . Line: 6 +. . . . . . . . Col: 5 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 75 +. . . . . . . . Line: 6 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: else +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: int { +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right +. . . . . . . . . TOKEN "0" . . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 29 -. . . . . . . . . . Line: 3 -. . . . . . . . . . Col: 8 +. . . . . . . . . . Offset: 75 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 9 . . . . . . . . . } . . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 37 -. . . . . . . . . . Line: 3 -. . . . . . . . . . Col: 16 +. . . . . . . . . . Offset: 75 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 9 . . . . . . . . . } . . . . . . . . . Properties: { -. . . . . . . . . . internalRole: exceptions -. . . . . . . . . } -. . . . . . . . . Children: { -. . . . . . . . . . 0: const { -. . . . . . . . . . . Roles: Expression,Identifier,Incomplete -. . . . . . . . . . . TOKEN "Exception" -. . . . . . . . . . . StartPosition: { -. . . . . . . . . . . . Offset: 29 -. . . . . . . . . . . . Line: 3 -. . . . . . . . . . . . Col: 8 -. . . . . . . . . . . } -. . . . . . . . . . . EndPosition: { -. . . . . . . . . . . . Offset: 37 -. . . . . . . . . . . . Line: 3 -. . . . . . . . . . . . Col: 16 -. . . . . . . . . . . } -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: contents -. . . . . . . . . . . } -. . . . . . . . . . } +. . . . . . . . . . internalRole: value . . . . . . . . . } . . . . . . . . } . . . . . . . } diff --git a/fixtures/retry.rb.native b/fixtures/retry.rb.native index 1a6950f..d01b900 100644 --- a/fixtures/retry.rb.native +++ b/fixtures/retry.rb.native @@ -3,56 +3,85 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "kwbegin", + "body": [ + { + "@type": "rescue", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "else": { - "type": "NilClass" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "handlers": [ - { - "alias": null, - "body": { - "end_col": 9, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "type": "retry" + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + "else": { + "@type": "NilNode" + }, + "handlers": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "resbody", + "alias": null, + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 }, - "end_col": 9, - "end_line": 4, - "exceptions": null, - "start_col": 0, - "start_line": 3, - "type": "resbody" - } - ], - "type": "rescue" - } - ], - "end_col": 3, - "end_line": 5, - "start_col": 0, - "start_line": 1, - "type": "kwbegin" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "retry" + }, + "exceptions": null + } + ] + } + ] } } } diff --git a/fixtures/retry.rb.uast b/fixtures/retry.rb.uast index 80eeb88..d5e1460 100644 --- a/fixtures/retry.rb.uast +++ b/fixtures/retry.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: kwbegin { -. . . Roles: Expression,Block,Try +. . . Roles: Block,Expression . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,17 +18,23 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: rescue { -. . . . . Roles: Expression,Try,Body +. . . . . Roles: Body,Expression,Try . . . . . Properties: { . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . 0: NilNode { +. . . . . . . Roles: Null +. . . . . . . Properties: { +. . . . . . . . internalRole: else +. . . . . . . } +. . . . . . } +. . . . . . 1: lvasgn { +. . . . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 @@ -45,7 +51,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 14 @@ -63,14 +69,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: NilClass { -. . . . . . . Roles: Statement,Type,Null -. . . . . . . Properties: { -. . . . . . . . internalRole: else -. . . . . . . } -. . . . . . } . . . . . . 2: resbody { -. . . . . . . Roles: Expression,Catch +. . . . . . . Roles: Catch,Expression . . . . . . . StartPosition: { . . . . . . . . Offset: 16 . . . . . . . . Line: 3 @@ -86,8 +86,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: retry { -. . . . . . . . . Roles: Expression,Statement,Call -. . . . . . . . . TOKEN "retry" +. . . . . . . . . Roles: Body,Call,Expression,Incomplete,Statement . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 27 . . . . . . . . . . Line: 4 diff --git a/fixtures/send_method.rb b/fixtures/send_method.rb index 82742bf..dab1d5e 100644 --- a/fixtures/send_method.rb +++ b/fixtures/send_method.rb @@ -3,10 +3,12 @@ def foo(a) end def bar() + this.foo(this.bar(5)) end end a = Foo.new() a.foo(1) +a.bar() a.bar + 1 a.foo = 3 diff --git a/fixtures/send_method.rb.native b/fixtures/send_method.rb.native index c8cc385..edb7895 100644 --- a/fixtures/send_method.rb.native +++ b/fixtures/send_method.rb.native @@ -3,197 +3,424 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "body": [ - { - "args": { - "children": [ - { - "end_col": 13, - "end_line": 2, - "start_col": 12, - "start_line": 2, - "token": "a", - "type": "arg" - } - ], - "end_col": 14, - "end_line": 2, - "start_col": 11, - "start_line": 2, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 14 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Foo", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "foo", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 2 }, - "body": [ + "@type": "args", + "children": [ { - "type": "NilClass" + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@token": "a", + "@type": "arg" } - ], - "end_col": 7, - "end_line": 2, - "name": "foo", - "start_col": 4, - "start_line": 2, - "type": "def" + ] + }, + "body": [ + { + "@type": "NilNode" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 }, - { - "args": { - "end_col": 13, - "end_line": 5, - "start_col": 11, - "start_line": 5, - "type": "args" + "@token": "bar", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 5 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 5, - "name": "bar", - "start_col": 4, - "start_line": 5, - "type": "def" - } - ], - "end_col": 7, - "end_line": 6, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Foo", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - }, - { - "end_col": 13, - "end_line": 9, - "start_col": 0, - "start_line": 9, - "target": "a", - "type": "lvasgn", - "value": { - "base": { - "base": null, - "end_col": 7, - "end_line": 9, - "start_col": 4, - "start_line": 9, - "token": "Foo", - "type": "const" - }, - "end_col": 13, - "end_line": 9, - "selector": "new", - "start_col": 4, - "start_line": 9, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 5 + }, + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 29, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@type": "send_qualified", + "base": null, + "selector": "this" + }, + "selector": "foo", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 28, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 6 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 21, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 6 + }, + "@type": "send_qualified", + "base": null, + "selector": "this" + }, + "selector": "bar", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 27, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 27, + "line": 6 + }, + "@token": 5, + "@type": "int" + } + ] + } + ] + } + ] + } + ] } + ], + "parent": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 10 }, - { - "base": { - "end_col": 1, - "end_line": 10, - "start_col": 0, - "start_line": 10, - "token": "a", - "type": "lvar" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 10 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 10 }, - "end_col": 8, - "end_line": 10, - "selector": "foo", - "start_col": 0, - "start_line": 10, - "type": "send", - "values": [ - { - "end_col": 7, - "end_line": 10, - "start_col": 6, - "start_line": 10, - "token": 1, - "type": "int" - } - ] - }, - { + "@type": "send_call", "base": { - "base": { - "end_col": 1, - "end_line": 11, - "start_col": 0, - "start_line": 11, - "token": "a", - "type": "lvar" + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 10 }, - "end_col": 5, - "end_line": 11, - "selector": "bar", - "start_col": 0, - "start_line": 11, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 10 + }, + "@token": "Foo", + "@type": "const", + "base": null }, - "end_col": 9, - "end_line": 11, - "selector": "+", - "start_col": 0, - "start_line": 11, - "type": "send", - "values": [ - { - "end_col": 9, - "end_line": 11, - "start_col": 8, - "start_line": 11, - "token": 1, - "type": "int" - } - ] - }, - { + "selector": "new" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 11 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 11 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 11 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 11 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "foo", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 11 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 11 + }, + "@token": 1, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 12 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 12 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "bar" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 13 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 13 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 13 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 13 + }, + "@type": "send_call", "base": { - "end_col": 1, - "end_line": 12, - "start_col": 0, - "start_line": 12, - "token": "a", - "type": "lvar" + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 13 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 13 + }, + "@token": "a", + "@type": "lvar" }, - "end_col": 9, - "end_line": 12, - "selector": "foo=", - "start_col": 0, - "start_line": 12, - "type": "send", - "values": [ - { - "end_col": 9, - "end_line": 12, - "start_col": 8, - "start_line": 12, - "token": 3, - "type": "int" - } - ] - } - ], - "end_col": 9, - "end_line": 12, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "selector": "bar" + }, + "selector": "+", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 13 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 13 + }, + "@token": 1, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 14 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 14 + }, + "@token": "foo", + "@type": "send_assign", + "base": { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 14 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 14 + }, + "@token": "a", + "@type": "lvar" + }, + "selector": "foo=", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 14 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 14 + }, + "@token": 3, + "@type": "int" + } + ] + } + ] } } } diff --git a/fixtures/send_method.rb.uast b/fixtures/send_method.rb.uast index 28dacd5..070c444 100644 --- a/fixtures/send_method.rb.uast +++ b/fixtures/send_method.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -13,16 +13,16 @@ UAST: . . . . Col: 1 . . . } . . . EndPosition: { -. . . . Offset: 102 -. . . . Line: 12 +. . . . Offset: 140 +. . . . Line: 14 . . . . Col: 9 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Foo" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -46,8 +46,8 @@ UAST: . . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 54 -. . . . . . . . Line: 6 +. . . . . . . . Offset: 84 +. . . . . . . . Line: 7 . . . . . . . . Col: 7 . . . . . . . } . . . . . . . Properties: { @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: def { -. . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . TOKEN "foo" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 14 @@ -71,8 +71,14 @@ UAST: . . . . . . . . . . internalRole: body . . . . . . . . . } . . . . . . . . . Children: { -. . . . . . . . . . 0: args { -. . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . 0: NilNode { +. . . . . . . . . . . Roles: Null +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: body +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . . 1: args { +. . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 21 . . . . . . . . . . . . Line: 2 @@ -88,7 +94,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: arg { -. . . . . . . . . . . . . Roles: Expression,Argument,Name +. . . . . . . . . . . . . Roles: Argument,Expression,Identifier,Name . . . . . . . . . . . . . TOKEN "a" . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 22 @@ -106,16 +112,10 @@ UAST: . . . . . . . . . . . . } . . . . . . . . . . . } . . . . . . . . . . } -. . . . . . . . . . 1: NilClass { -. . . . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: body -. . . . . . . . . . . } -. . . . . . . . . . } . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: def { -. . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . TOKEN "bar" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 38 @@ -132,7 +132,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: args { -. . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 45 . . . . . . . . . . . . Line: 5 @@ -147,11 +147,94 @@ UAST: . . . . . . . . . . . . internalRole: args . . . . . . . . . . . } . . . . . . . . . . } -. . . . . . . . . . 1: NilClass { -. . . . . . . . . . . Roles: Statement,Type,Null +. . . . . . . . . . 1: send_call { +. . . . . . . . . . . Roles: Call,Expression,Function +. . . . . . . . . . . TOKEN "foo" +. . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . Offset: 56 +. . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . Col: 9 +. . . . . . . . . . . } +. . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . Offset: 76 +. . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . Col: 29 +. . . . . . . . . . . } . . . . . . . . . . . Properties: { . . . . . . . . . . . . internalRole: body . . . . . . . . . . . } +. . . . . . . . . . . Children: { +. . . . . . . . . . . . 0: send_qualified { +. . . . . . . . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 56 +. . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . Col: 9 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 59 +. . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . Col: 12 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: base +. . . . . . . . . . . . . . selector: this +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . . 1: send_call { +. . . . . . . . . . . . . Roles: Argument,Call,Expression,Function +. . . . . . . . . . . . . TOKEN "bar" +. . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . Offset: 65 +. . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . Col: 18 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . Offset: 75 +. . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . Col: 28 +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . internalRole: values +. . . . . . . . . . . . . } +. . . . . . . . . . . . . Children: { +. . . . . . . . . . . . . . 0: send_qualified { +. . . . . . . . . . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . . . Offset: 65 +. . . . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . . . Col: 18 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . . . Offset: 68 +. . . . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . . . Col: 21 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . . . internalRole: base +. . . . . . . . . . . . . . . . selector: this +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . } +. . . . . . . . . . . . . . 1: int { +. . . . . . . . . . . . . . . Roles: Argument,Call,Expression,Function,Literal,Number,Primitive +. . . . . . . . . . . . . . . TOKEN "5" +. . . . . . . . . . . . . . . StartPosition: { +. . . . . . . . . . . . . . . . Offset: 74 +. . . . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . . . Col: 27 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . EndPosition: { +. . . . . . . . . . . . . . . . Offset: 74 +. . . . . . . . . . . . . . . . Line: 6 +. . . . . . . . . . . . . . . . Col: 27 +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . . Properties: { +. . . . . . . . . . . . . . . . internalRole: values +. . . . . . . . . . . . . . . } +. . . . . . . . . . . . . . } +. . . . . . . . . . . . . } +. . . . . . . . . . . . } +. . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } @@ -160,33 +243,33 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { -. . . . . . Offset: 61 -. . . . . . Line: 9 +. . . . . . Offset: 91 +. . . . . . Line: 10 . . . . . . Col: 1 . . . . . } . . . . . EndPosition: { -. . . . . . Offset: 73 -. . . . . . Line: 9 +. . . . . . Offset: 103 +. . . . . . Line: 10 . . . . . . Col: 13 . . . . . } . . . . . Properties: { . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Right,Expression,Identifier +. . . . . . 0: send_call { +. . . . . . . Roles: Binary,Call,Expression,Function,Right . . . . . . . TOKEN "new" . . . . . . . StartPosition: { -. . . . . . . . Offset: 65 -. . . . . . . . Line: 9 +. . . . . . . . Offset: 95 +. . . . . . . . Line: 10 . . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 73 -. . . . . . . . Line: 9 +. . . . . . . . Offset: 103 +. . . . . . . . Line: 10 . . . . . . . . Col: 13 . . . . . . . } . . . . . . . Properties: { @@ -197,13 +280,13 @@ UAST: . . . . . . . . . Roles: Expression,Identifier,Incomplete . . . . . . . . . TOKEN "Foo" . . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 65 -. . . . . . . . . . Line: 9 +. . . . . . . . . . Offset: 95 +. . . . . . . . . . Line: 10 . . . . . . . . . . Col: 5 . . . . . . . . . } . . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 67 -. . . . . . . . . . Line: 9 +. . . . . . . . . . Offset: 97 +. . . . . . . . . . Line: 10 . . . . . . . . . . Col: 7 . . . . . . . . . } . . . . . . . . . Properties: { @@ -214,17 +297,17 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 2: send { -. . . . . Roles: Expression,Identifier,Call +. . . . 2: send_call { +. . . . . Roles: Call,Expression,Function . . . . . TOKEN "foo" . . . . . StartPosition: { -. . . . . . Offset: 75 -. . . . . . Line: 10 +. . . . . . Offset: 105 +. . . . . . Line: 11 . . . . . . Col: 1 . . . . . } . . . . . EndPosition: { -. . . . . . Offset: 82 -. . . . . . Line: 10 +. . . . . . Offset: 112 +. . . . . . Line: 11 . . . . . . Col: 8 . . . . . } . . . . . Properties: { @@ -235,13 +318,13 @@ UAST: . . . . . . . Roles: Expression,Identifier . . . . . . . TOKEN "a" . . . . . . . StartPosition: { -. . . . . . . . Offset: 75 -. . . . . . . . Line: 10 +. . . . . . . . Offset: 105 +. . . . . . . . Line: 11 . . . . . . . . Col: 1 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 75 -. . . . . . . . Line: 10 +. . . . . . . . Offset: 105 +. . . . . . . . Line: 11 . . . . . . . . Col: 1 . . . . . . . } . . . . . . . Properties: { @@ -249,16 +332,16 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . Roles: Argument,Call,Expression,Function,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { -. . . . . . . . Offset: 81 -. . . . . . . . Line: 10 +. . . . . . . . Offset: 111 +. . . . . . . . Line: 11 . . . . . . . . Col: 7 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 81 -. . . . . . . . Line: 10 +. . . . . . . . Offset: 111 +. . . . . . . . Line: 11 . . . . . . . . Col: 7 . . . . . . . } . . . . . . . Properties: { @@ -267,34 +350,70 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 3: send { -. . . . . Roles: Expression,Identifier,Operator,Arithmetic,Add +. . . . 3: send_call { +. . . . . Roles: Call,Expression,Function +. . . . . TOKEN "bar" +. . . . . StartPosition: { +. . . . . . Offset: 114 +. . . . . . Line: 12 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 120 +. . . . . . Line: 12 +. . . . . . Col: 7 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: lvar { +. . . . . . . Roles: Expression,Identifier +. . . . . . . TOKEN "a" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 114 +. . . . . . . . Line: 12 +. . . . . . . . Col: 1 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 114 +. . . . . . . . Line: 12 +. . . . . . . . Col: 1 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: base +. . . . . . . } +. . . . . . } +. . . . . } +. . . . } +. . . . 4: send_operator { +. . . . . Roles: Add,Arithmetic,Binary,Expression,Operator . . . . . TOKEN "+" . . . . . StartPosition: { -. . . . . . Offset: 84 -. . . . . . Line: 11 +. . . . . . Offset: 122 +. . . . . . Line: 13 . . . . . . Col: 1 . . . . . } . . . . . EndPosition: { -. . . . . . Offset: 92 -. . . . . . Line: 11 +. . . . . . Offset: 130 +. . . . . . Line: 13 . . . . . . Col: 9 . . . . . } . . . . . Properties: { . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Qualified,Identifier +. . . . . . 0: send_call { +. . . . . . . Roles: Call,Expression,Function,Left . . . . . . . TOKEN "bar" . . . . . . . StartPosition: { -. . . . . . . . Offset: 84 -. . . . . . . . Line: 11 +. . . . . . . . Offset: 122 +. . . . . . . . Line: 13 . . . . . . . . Col: 1 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 88 -. . . . . . . . Line: 11 +. . . . . . . . Offset: 126 +. . . . . . . . Line: 13 . . . . . . . . Col: 5 . . . . . . . } . . . . . . . Properties: { @@ -305,13 +424,13 @@ UAST: . . . . . . . . . Roles: Expression,Identifier . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { -. . . . . . . . . . Offset: 84 -. . . . . . . . . . Line: 11 +. . . . . . . . . . Offset: 122 +. . . . . . . . . . Line: 13 . . . . . . . . . . Col: 1 . . . . . . . . . } . . . . . . . . . EndPosition: { -. . . . . . . . . . Offset: 84 -. . . . . . . . . . Line: 11 +. . . . . . . . . . Offset: 122 +. . . . . . . . . . Line: 13 . . . . . . . . . . Col: 1 . . . . . . . . . } . . . . . . . . . Properties: { @@ -321,16 +440,16 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { -. . . . . . . . Offset: 92 -. . . . . . . . Line: 11 +. . . . . . . . Offset: 130 +. . . . . . . . Line: 13 . . . . . . . . Col: 9 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 92 -. . . . . . . . Line: 11 +. . . . . . . . Offset: 130 +. . . . . . . . Line: 13 . . . . . . . . Col: 9 . . . . . . . } . . . . . . . Properties: { @@ -339,34 +458,35 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 4: send { -. . . . . Roles: Expression,Identifier,Call -. . . . . TOKEN "foo=" +. . . . 5: send_assign { +. . . . . Roles: Assignment,Expression,Left +. . . . . TOKEN "foo" . . . . . StartPosition: { -. . . . . . Offset: 94 -. . . . . . Line: 12 +. . . . . . Offset: 132 +. . . . . . Line: 14 . . . . . . Col: 1 . . . . . } . . . . . EndPosition: { -. . . . . . Offset: 102 -. . . . . . Line: 12 +. . . . . . Offset: 140 +. . . . . . Line: 14 . . . . . . Col: 9 . . . . . } . . . . . Properties: { . . . . . . internalRole: body +. . . . . . selector: foo= . . . . . } . . . . . Children: { . . . . . . 0: lvar { . . . . . . . Roles: Expression,Identifier . . . . . . . TOKEN "a" . . . . . . . StartPosition: { -. . . . . . . . Offset: 94 -. . . . . . . . Line: 12 +. . . . . . . . Offset: 132 +. . . . . . . . Line: 14 . . . . . . . . Col: 1 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 94 -. . . . . . . . Line: 12 +. . . . . . . . Offset: 132 +. . . . . . . . Line: 14 . . . . . . . . Col: 1 . . . . . . . } . . . . . . . Properties: { @@ -374,16 +494,16 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . Roles: Assignment,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "3" . . . . . . . StartPosition: { -. . . . . . . . Offset: 102 -. . . . . . . . Line: 12 +. . . . . . . . Offset: 140 +. . . . . . . . Line: 14 . . . . . . . . Col: 9 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 102 -. . . . . . . . Line: 12 +. . . . . . . . Offset: 140 +. . . . . . . . Line: 14 . . . . . . . . Col: 9 . . . . . . . } . . . . . . . Properties: { diff --git a/fixtures/send_operator.rb.native b/fixtures/send_operator.rb.native index 5480946..b97cc81 100644 --- a/fixtures/send_operator.rb.native +++ b/fixtures/send_operator.rb.native @@ -3,34 +3,51 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": { - "base": null, - "end_col": 3, - "end_line": 1, - "selector": "foo", - "start_col": 0, - "start_line": 1, - "type": "send" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_operator", + "base": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 }, - "end_col": 7, - "end_line": 1, - "selector": "+", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 7, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "token": 1, - "type": "int" - } - ] - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "selector": "+", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + ] } } } diff --git a/fixtures/send_operator.rb.uast b/fixtures/send_operator.rb.uast index 67113d8..4902baa 100644 --- a/fixtures/send_operator.rb.uast +++ b/fixtures/send_operator.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { -. . 0: send { -. . . Roles: Expression,Identifier,Operator,Arithmetic,Add +. . 0: send_operator { +. . . Roles: Add,Arithmetic,Binary,Expression,Operator . . . TOKEN "+" . . . StartPosition: { . . . . Offset: 0 @@ -19,12 +19,11 @@ UAST: . . . . Col: 7 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Qualified,Identifier -. . . . . TOKEN "foo" +. . . . 0: send_qualified { +. . . . . Roles: Expression,Identical,Left,Qualified . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -37,10 +36,11 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: base +. . . . . . selector: foo . . . . . } . . . . } . . . . 1: int { -. . . . . Roles: Expression,Literal,Number,Primitive +. . . . . Roles: Expression,Literal,Number,Primitive,Right . . . . . TOKEN "1" . . . . . StartPosition: { . . . . . . Offset: 6 diff --git a/fixtures/simple_call.rb b/fixtures/simple_call.rb new file mode 100644 index 0000000..eed0d96 --- /dev/null +++ b/fixtures/simple_call.rb @@ -0,0 +1,10 @@ +def fnc1(a, b, c) + puts a, b, c +end + +def fnc2() +end + +fnc1(1, 2, 3) +fnc2() + diff --git a/fixtures/simple_call.rb.native b/fixtures/simple_call.rb.native new file mode 100644 index 0000000..31604df --- /dev/null +++ b/fixtures/simple_call.rb.native @@ -0,0 +1,261 @@ +{ + "status": "ok", + "language": "ruby", + "errors": [], + "ast": { + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "fnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@type": "args", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@token": "a", + "@type": "arg" + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@token": "b", + "@type": "arg" + }, + { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@token": "c", + "@type": "arg" + } + ] + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "puts", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@token": "a", + "@type": "lvar" + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@token": "b", + "@type": "lvar" + }, + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@token": "c", + "@type": "lvar" + } + ] + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@token": "fnc2", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 5 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@type": "send_qualified", + "base": null, + "selector": "fnc1", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 8 + }, + "@token": 1, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 8 + }, + "@token": 2, + "@type": "int" + }, + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 8 + }, + "@token": 3, + "@type": "int" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 9 + }, + "@type": "send_qualified", + "base": null, + "selector": "fnc2" + } + ] + } + } +} diff --git a/fixtures/simple_call.rb.uast b/fixtures/simple_call.rb.uast new file mode 100644 index 0000000..3150823 --- /dev/null +++ b/fixtures/simple_call.rb.uast @@ -0,0 +1,314 @@ +Status: ok +Language: ruby +Errors: +UAST: +module { +. Roles: Identifier,Module,Statement +. Children: { +. . 0: begin { +. . . Roles: Block +. . . StartPosition: { +. . . . Offset: 0 +. . . . Line: 1 +. . . . Col: 1 +. . . } +. . . EndPosition: { +. . . . Offset: 76 +. . . . Line: 9 +. . . . Col: 6 +. . . } +. . . Properties: { +. . . . internalRole: file +. . . } +. . . Children: { +. . . . 0: def { +. . . . . Roles: Declaration,Function,Identifier,Statement +. . . . . TOKEN "fnc1" +. . . . . StartPosition: { +. . . . . . Offset: 0 +. . . . . . Line: 1 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 2 +. . . . . . Line: 1 +. . . . . . Col: 3 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: args { +. . . . . . . Roles: Argument,Expression,Incomplete +. . . . . . . StartPosition: { +. . . . . . . . Offset: 8 +. . . . . . . . Line: 1 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 16 +. . . . . . . . Line: 1 +. . . . . . . . Col: 17 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: args +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: arg { +. . . . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . . . TOKEN "a" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 9 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 10 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 9 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 10 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: children +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: arg { +. . . . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . . . TOKEN "b" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 12 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 13 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 12 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 13 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: children +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 2: arg { +. . . . . . . . . Roles: Argument,Expression,Identifier,Name +. . . . . . . . . TOKEN "c" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 15 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 16 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 15 +. . . . . . . . . . Line: 1 +. . . . . . . . . . Col: 16 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: children +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . . 1: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified +. . . . . . . StartPosition: { +. . . . . . . . Offset: 23 +. . . . . . . . Line: 2 +. . . . . . . . Col: 6 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 34 +. . . . . . . . Line: 2 +. . . . . . . . Col: 17 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . . selector: puts +. . . . . . . } +. . . . . . . Children: { +. . . . . . . . 0: lvar { +. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . TOKEN "a" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 28 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 11 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 28 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 11 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: values +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: lvar { +. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . TOKEN "b" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 31 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 14 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 31 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 14 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: values +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 2: lvar { +. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . TOKEN "c" +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 34 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 17 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 34 +. . . . . . . . . . Line: 2 +. . . . . . . . . . Col: 17 +. . . . . . . . . } +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: values +. . . . . . . . . } +. . . . . . . . } +. . . . . . . } +. . . . . . } +. . . . . } +. . . . } +. . . . 1: def { +. . . . . Roles: Declaration,Function,Identifier,Statement +. . . . . TOKEN "fnc2" +. . . . . StartPosition: { +. . . . . . Offset: 41 +. . . . . . Line: 5 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 43 +. . . . . . Line: 5 +. . . . . . Col: 3 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: NilNode { +. . . . . . . Roles: Null +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . } +. . . . . . 1: args { +. . . . . . . Roles: Argument,Expression,Incomplete +. . . . . . . StartPosition: { +. . . . . . . . Offset: 49 +. . . . . . . . Line: 5 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 50 +. . . . . . . . Line: 5 +. . . . . . . . Col: 10 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: args +. . . . . . . } +. . . . . . } +. . . . . } +. . . . } +. . . . 2: send_qualified { +. . . . . Roles: Expression,Identical,Qualified +. . . . . StartPosition: { +. . . . . . Offset: 57 +. . . . . . Line: 8 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 69 +. . . . . . Line: 8 +. . . . . . Col: 13 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . . selector: fnc1 +. . . . . } +. . . . . Children: { +. . . . . . 0: int { +. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . TOKEN "1" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 62 +. . . . . . . . Line: 8 +. . . . . . . . Col: 6 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 62 +. . . . . . . . Line: 8 +. . . . . . . . Col: 6 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: values +. . . . . . . } +. . . . . . } +. . . . . . 1: int { +. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . TOKEN "2" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 65 +. . . . . . . . Line: 8 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 65 +. . . . . . . . Line: 8 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: values +. . . . . . . } +. . . . . . } +. . . . . . 2: int { +. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . TOKEN "3" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 68 +. . . . . . . . Line: 8 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 68 +. . . . . . . . Line: 8 +. . . . . . . . Col: 12 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: values +. . . . . . . } +. . . . . . } +. . . . . } +. . . . } +. . . . 3: send_qualified { +. . . . . Roles: Expression,Identical,Qualified +. . . . . StartPosition: { +. . . . . . Offset: 71 +. . . . . . Line: 9 +. . . . . . Col: 1 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 76 +. . . . . . Line: 9 +. . . . . . Col: 6 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . . selector: fnc2 +. . . . . } +. . . . } +. . . } +. . } +. } +} + diff --git a/fixtures/singleton_literals.rb.native b/fixtures/singleton_literals.rb.native index c6d029c..166610e 100644 --- a/fixtures/singleton_literals.rb.native +++ b/fixtures/singleton_literals.rb.native @@ -3,61 +3,102 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 8, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 8, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "true" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 }, - { - "end_col": 9, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "type": "false" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 }, - { - "end_col": 7, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": "c", - "type": "lvasgn", - "value": { - "end_col": 7, - "end_line": 3, - "start_col": 4, - "start_line": 3, - "type": "nil" - } + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "true" } - ], - "end_col": 7, - "end_line": 3, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + }, + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "false" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@type": "lvasgn", + "target": "c", + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@type": "nil" + } + } + ] } } } diff --git a/fixtures/singleton_literals.rb.uast b/fixtures/singleton_literals.rb.uast index 1c20c29..092f9a7 100644 --- a/fixtures/singleton_literals.rb.uast +++ b/fixtures/singleton_literals.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 7 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: true { -. . . . . . . Roles: Right,Expression,Boolean,Literal +. . . . . . . Roles: Binary,Boolean,Expression,Literal,Right . . . . . . . TOKEN "true" . . . . . . . StartPosition: { . . . . . . . . Offset: 4 @@ -58,7 +58,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 9 @@ -75,7 +75,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: false { -. . . . . . . Roles: Right,Expression,Boolean,Literal +. . . . . . . Roles: Binary,Boolean,Expression,Literal,Right . . . . . . . TOKEN "false" . . . . . . . StartPosition: { . . . . . . . . Offset: 13 @@ -94,7 +94,7 @@ UAST: . . . . . } . . . . } . . . . 2: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "c" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -111,7 +111,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: nil { -. . . . . . . Roles: Right +. . . . . . . Roles: Binary,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 23 . . . . . . . . Line: 3 diff --git a/fixtures/str_exec.rb.native b/fixtures/str_exec.rb.native index cdb3885..cbc4e8e 100644 --- a/fixtures/str_exec.rb.native +++ b/fixtures/str_exec.rb.native @@ -3,140 +3,235 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 8, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "children": [ - { - "end_col": 7, - "end_line": 1, - "start_col": 5, - "start_line": 1, - "token": "ls", - "type": "str" - } - ], - "end_col": 8, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "xstr" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 }, - { - "end_col": 7, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "bar", - "type": "lvasgn", - "value": { - "end_col": 7, - "end_line": 2, - "start_col": 6, - "start_line": 2, - "token": 1, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 }, - { - "end_col": 18, - "end_line": 3, - "start_col": 0, - "start_line": 3, - "target": "b", - "type": "lvasgn", - "value": { - "children": [ - { - "end_col": 8, - "end_line": 3, - "start_col": 5, - "start_line": 3, - "token": "foo", - "type": "str" + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "xstr", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 }, - { - "body": [ - { - "end_col": 13, - "end_line": 3, - "start_col": 10, - "start_line": 3, - "token": "bar", - "type": "lvar" - } - ], - "end_col": 14, - "end_line": 3, - "start_col": 8, - "start_line": 3, - "type": "begin" + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - { - "end_col": 17, - "end_line": 3, - "start_col": 14, - "start_line": 3, - "token": "baz", - "type": "str" - } - ], - "end_col": 18, - "end_line": 3, - "start_col": 4, - "start_line": 3, - "type": "xstr" - } + "@token": "ls", + "@type": "str" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "target": "bar", + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 }, - { - "end_col": 12, - "end_line": 4, - "start_col": 0, - "start_line": 4, - "target": "c", - "type": "lvasgn", - "value": { - "children": [ - { - "end_col": 0, - "end_line": 6, - "start_col": 0, - "start_line": 5, - "token": " foobar\n", - "type": "str" + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@type": "xstr", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 3 + }, + "@token": "foo", + "@type": "str" + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 3 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 3 + }, + "@token": "bar", + "@type": "lvar" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 3 + }, + "@token": "baz", + "@type": "str" + } + ] + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@type": "lvasgn", + "target": "c", + "value": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@type": "xstr", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@token": " foobar\n", + "@type": "str" + }, + { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 6 }, - { - "end_col": 0, - "end_line": 7, - "start_col": 0, - "start_line": 6, - "token": " multiline\n", - "type": "str" - } - ], - "end_col": 12, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "type": "xstr" - } + "@token": " multiline\n", + "@type": "str" + } + ] } - ], - "end_col": 12, - "end_line": 4, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/str_exec.rb.uast b/fixtures/str_exec.rb.uast index 9cd6b28..68bfde2 100644 --- a/fixtures/str_exec.rb.uast +++ b/fixtures/str_exec.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 12 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: xstr { -. . . . . . . Roles: Right +. . . . . . . Roles: Binary,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 4 . . . . . . . . Line: 1 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "ls" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 5 @@ -76,7 +76,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "bar" . . . . . StartPosition: { . . . . . . Offset: 9 @@ -93,7 +93,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 15 @@ -112,7 +112,7 @@ UAST: . . . . . } . . . . } . . . . 2: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 17 @@ -129,7 +129,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: xstr { -. . . . . . . Roles: Right +. . . . . . . Roles: Binary,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 21 . . . . . . . . Line: 3 @@ -145,7 +145,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "foo" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 22 @@ -197,7 +197,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 2: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "baz" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 31 @@ -218,7 +218,7 @@ UAST: . . . . . } . . . . } . . . . 3: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "c" . . . . . StartPosition: { . . . . . . Offset: 36 @@ -235,7 +235,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: xstr { -. . . . . . . Roles: Right +. . . . . . . Roles: Binary,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 40 . . . . . . . . Line: 4 @@ -251,17 +251,37 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN " foobar " +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 49 +. . . . . . . . . . Line: 5 +. . . . . . . . . . Col: 1 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 60 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 1 +. . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: children . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN " multiline " +. . . . . . . . . StartPosition: { +. . . . . . . . . . Offset: 60 +. . . . . . . . . . Line: 6 +. . . . . . . . . . Col: 1 +. . . . . . . . . } +. . . . . . . . . EndPosition: { +. . . . . . . . . . Offset: 74 +. . . . . . . . . . Line: 7 +. . . . . . . . . . Col: 1 +. . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: children . . . . . . . . . } diff --git a/fixtures/str_heredoc.rb.native b/fixtures/str_heredoc.rb.native index 3977583..1de1548 100644 --- a/fixtures/str_heredoc.rb.native +++ b/fixtures/str_heredoc.rb.native @@ -3,39 +3,62 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 10, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "children": [ - { - "end_col": 0, - "end_line": 3, - "start_col": 0, - "start_line": 2, - "token": " Some text\n", - "type": "str" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "dstr", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 3 }, - { - "end_col": 0, - "end_line": 4, - "start_col": 0, - "start_line": 3, - "token": " multiline\n", - "type": "str" - } - ], - "end_col": 10, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "dstr" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@token": " Some text\n", + "@type": "str" + }, + { + "@end": { + "@type": "ast:Position", + "col": 1, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 3 + }, + "@token": " multiline\n", + "@type": "str" + } + ] } } } diff --git a/fixtures/str_heredoc.rb.uast b/fixtures/str_heredoc.rb.uast index 3369218..7da2efc 100644 --- a/fixtures/str_heredoc.rb.uast +++ b/fixtures/str_heredoc.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 10 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: dstr { -. . . . . Roles: Right +. . . . . Roles: Binary,Right . . . . . StartPosition: { . . . . . . Offset: 4 . . . . . . Line: 1 @@ -39,17 +39,37 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: str { -. . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . TOKEN " Some text " +. . . . . . . StartPosition: { +. . . . . . . . Offset: 11 +. . . . . . . . Line: 2 +. . . . . . . . Col: 1 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 25 +. . . . . . . . Line: 3 +. . . . . . . . Col: 1 +. . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: children . . . . . . . } . . . . . . } . . . . . . 1: str { -. . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . TOKEN " multiline " +. . . . . . . StartPosition: { +. . . . . . . . Offset: 25 +. . . . . . . . Line: 3 +. . . . . . . . Col: 1 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 39 +. . . . . . . . Line: 4 +. . . . . . . . Col: 1 +. . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: children . . . . . . . } diff --git a/fixtures/str_interpolated.rb.native b/fixtures/str_interpolated.rb.native index 32a332d..ad4e1ec 100644 --- a/fixtures/str_interpolated.rb.native +++ b/fixtures/str_interpolated.rb.native @@ -3,82 +3,135 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 7, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "bar", - "type": "lvasgn", - "value": { - "end_col": 7, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 }, - { - "end_col": 18, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "target": "b", - "type": "lvasgn", - "value": { - "children": [ - { - "end_col": 8, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "token": "foo", - "type": "str" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "bar", + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "dstr", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@token": "foo", + "@type": "str" + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@token": "bar", + "@type": "lvar" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 }, - { - "body": [ - { - "end_col": 13, - "end_line": 2, - "start_col": 10, - "start_line": 2, - "token": "bar", - "type": "lvar" - } - ], - "end_col": 14, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "type": "begin" + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 2 }, - { - "end_col": 17, - "end_line": 2, - "start_col": 14, - "start_line": 2, - "token": "baz", - "type": "str" - } - ], - "end_col": 18, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "type": "dstr" - } + "@token": "baz", + "@type": "str" + } + ] } - ], - "end_col": 18, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/str_interpolated.rb.uast b/fixtures/str_interpolated.rb.uast index bbb8724..397e4b6 100644 --- a/fixtures/str_interpolated.rb.uast +++ b/fixtures/str_interpolated.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 18 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "bar" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -58,7 +58,7 @@ UAST: . . . . . } . . . . } . . . . 1: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "b" . . . . . StartPosition: { . . . . . . Offset: 8 @@ -75,7 +75,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: dstr { -. . . . . . . Roles: Right +. . . . . . . Roles: Binary,Right . . . . . . . StartPosition: { . . . . . . . . Offset: 12 . . . . . . . . Line: 2 @@ -91,7 +91,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "foo" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 13 @@ -143,7 +143,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 2: str { -. . . . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . . . TOKEN "baz" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 22 diff --git a/fixtures/str_plain.rb.native b/fixtures/str_plain.rb.native index 5116a84..1e8b104 100644 --- a/fixtures/str_plain.rb.native +++ b/fixtures/str_plain.rb.native @@ -3,22 +3,33 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 17, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 17, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "token": "some string", - "type": "str" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@token": "some string", + "@type": "str" } } } diff --git a/fixtures/str_plain.rb.uast b/fixtures/str_plain.rb.uast index ba41a7a..2ce1f94 100644 --- a/fixtures/str_plain.rb.uast +++ b/fixtures/str_plain.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 17 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: str { -. . . . . Roles: Right,Expression,Literal,String,Primitive +. . . . . Roles: Binary,Expression,Literal,Primitive,Right,String . . . . . TOKEN "some string" . . . . . StartPosition: { . . . . . . Offset: 4 diff --git a/fixtures/symbol.rb.native b/fixtures/symbol.rb.native index 1244026..e24e1ba 100644 --- a/fixtures/symbol.rb.native +++ b/fixtures/symbol.rb.native @@ -3,15 +3,20 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 4, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": "foo", - "type": "sym" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "foo", + "@type": "sym" } } } diff --git a/fixtures/symbol.rb.uast b/fixtures/symbol.rb.uast index 2eb8f99..5b137d6 100644 --- a/fixtures/symbol.rb.uast +++ b/fixtures/symbol.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: sym { . . . Roles: Expression,Identifier @@ -19,7 +19,7 @@ UAST: . . . . Col: 4 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . } . } diff --git a/fixtures/symbol_interpolated.rb.native b/fixtures/symbol_interpolated.rb.native index e9c10dd..ca96ce3 100644 --- a/fixtures/symbol_interpolated.rb.native +++ b/fixtures/symbol_interpolated.rb.native @@ -3,74 +3,121 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 7, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "bar", - "type": "lvasgn", - "value": { - "end_col": 7, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "bar", + "value": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 }, - { - "children": [ - { - "end_col": 5, - "end_line": 2, - "start_col": 2, - "start_line": 2, - "token": "foo", - "type": "str" + "@type": "dsym", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - { - "body": [ - { - "end_col": 10, - "end_line": 2, - "start_col": 7, - "start_line": 2, - "token": "bar", - "type": "lvar" - } - ], - "end_col": 11, - "end_line": 2, - "start_col": 5, - "start_line": 2, - "type": "begin" + "@start": { + "@type": "ast:Position", + "col": 3, + "line": 2 }, - { - "end_col": 14, - "end_line": 2, - "start_col": 11, - "start_line": 2, - "token": "baz", - "type": "str" - } - ], - "end_col": 15, - "end_line": 2, - "start_col": 0, - "start_line": 2, - "type": "dsym" - } - ], - "end_col": 15, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "@token": "foo", + "@type": "str" + }, + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 6, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 2 + }, + "@token": "bar", + "@type": "lvar" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 2 + }, + "@token": "baz", + "@type": "str" + } + ] + } + ] } } } diff --git a/fixtures/symbol_interpolated.rb.uast b/fixtures/symbol_interpolated.rb.uast index 0f01adf..8a7f170 100644 --- a/fixtures/symbol_interpolated.rb.uast +++ b/fixtures/symbol_interpolated.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 15 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "bar" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 6 @@ -58,7 +58,7 @@ UAST: . . . . . } . . . . } . . . . 1: dsym { -. . . . . Roles: Expression,String,Incomplete +. . . . . Roles: Expression,Incomplete,String . . . . . StartPosition: { . . . . . . Offset: 8 . . . . . . Line: 2 @@ -74,7 +74,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: str { -. . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . TOKEN "foo" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 @@ -126,7 +126,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 2: str { -. . . . . . . Roles: Expression,Literal,String,Primitive +. . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . TOKEN "baz" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 diff --git a/fixtures/ternary_if.rb.native b/fixtures/ternary_if.rb.native index a200867..fd2843e 100644 --- a/fixtures/ternary_if.rb.native +++ b/fixtures/ternary_if.rb.native @@ -3,45 +3,74 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 15, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "target": "a", - "type": "lvasgn", - "value": { - "body": { - "end_col": 11, - "end_line": 1, - "start_col": 10, - "start_line": 1, - "token": 1, - "type": "int" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 1 }, - "condition": { - "base": null, - "end_col": 7, - "end_line": 1, - "selector": "foo", - "start_col": 4, - "start_line": 1, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 1 }, - "else": { - "end_col": 15, - "end_line": 1, - "start_col": 14, - "start_line": 1, - "token": 2, - "type": "int" + "@token": 1, + "@type": "int" + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 1 }, - "end_col": 9, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "type": "if" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@token": 2, + "@type": "int" } } } diff --git a/fixtures/ternary_if.rb.uast b/fixtures/ternary_if.rb.uast index aac65d5..0586749 100644 --- a/fixtures/ternary_if.rb.uast +++ b/fixtures/ternary_if.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: lvasgn { -. . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . Roles: Assignment,Binary,Expression,Identifier,Left . . . TOKEN "a" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 15 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: if { -. . . . . Roles: Right,Statement,If +. . . . . Roles: Binary,If,Right,Statement . . . . . StartPosition: { . . . . . . Offset: 8 . . . . . . Line: 1 @@ -38,42 +38,42 @@ UAST: . . . . . . internalRole: value . . . . . } . . . . . Children: { -. . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,If,Then -. . . . . . . TOKEN "1" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Condition,Expression,Identical,Qualified . . . . . . . StartPosition: { -. . . . . . . . Offset: 10 +. . . . . . . . Offset: 4 . . . . . . . . Line: 1 -. . . . . . . . Col: 11 +. . . . . . . . Col: 5 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 10 +. . . . . . . . Offset: 6 . . . . . . . . Line: 1 -. . . . . . . . Col: 11 +. . . . . . . . Col: 7 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: body +. . . . . . . . internalRole: condition +. . . . . . . . selector: foo . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Condition,If -. . . . . . . TOKEN "foo" +. . . . . . 1: int { +. . . . . . . Roles: Body,Expression,Literal,Number,Primitive,Then +. . . . . . . TOKEN "1" . . . . . . . StartPosition: { -. . . . . . . . Offset: 4 +. . . . . . . . Offset: 10 . . . . . . . . Line: 1 -. . . . . . . . Col: 5 +. . . . . . . . Col: 11 . . . . . . . } . . . . . . . EndPosition: { -. . . . . . . . Offset: 6 +. . . . . . . . Offset: 10 . . . . . . . . Line: 1 -. . . . . . . . Col: 7 +. . . . . . . . Col: 11 . . . . . . . } . . . . . . . Properties: { -. . . . . . . . internalRole: condition +. . . . . . . . internalRole: body . . . . . . . } . . . . . . } . . . . . . 2: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive,If,Else +. . . . . . . Roles: Else,Expression,Literal,Number,Primitive . . . . . . . TOKEN "2" . . . . . . . StartPosition: { . . . . . . . . Offset: 14 diff --git a/fixtures/u2_class_accessors.rb.native b/fixtures/u2_class_accessors.rb.native index 17f3baf..3cac11c 100644 --- a/fixtures/u2_class_accessors.rb.native +++ b/fixtures/u2_class_accessors.rb.native @@ -3,202 +3,327 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "base": null, - "end_col": 20, - "end_line": 2, - "selector": "attr_accessor", - "start_col": 4, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 20, - "end_line": 2, - "start_col": 18, - "start_line": 2, - "token": "a", - "type": "sym" - } - ] - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 14 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 }, - { - "body": [ - { - "body": [ - { - "base": null, - "end_col": 18, - "end_line": 5, - "selector": "attr_reader", - "start_col": 4, - "start_line": 5, - "type": "send", - "values": [ - { - "end_col": 18, - "end_line": 5, - "start_col": 16, - "start_line": 5, - "token": "b", - "type": "sym" - } - ] + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "attr_accessor", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 2 }, - { - "base": null, - "end_col": 18, - "end_line": 6, - "selector": "attr_writer", - "start_col": 4, - "start_line": 6, - "type": "send", - "values": [ - { - "end_col": 18, - "end_line": 6, - "start_col": 16, - "start_line": 6, - "token": "b", - "type": "sym" - } - ] - } - ], - "end_col": 18, - "end_line": 6, - "start_col": 4, - "start_line": 5, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 4, - "name": "Testcls2", - "parent": null, - "start_col": 0, - "start_line": 4, - "type": "class" + "@start": { + "@type": "ast:Position", + "col": 19, + "line": 2 + }, + "@token": "a", + "@type": "sym" + } + ] + } + ], + "parent": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 4 }, - { - "body": [ - { - "body": [ - { - "end_col": 10, - "end_line": 9, - "start_col": 4, - "start_line": 9, - "target": "@c", - "type": "ivasgn", - "value": { - "end_col": 10, - "end_line": 9, - "start_col": 9, - "start_line": 9, - "token": 1, - "type": "int" + "@token": "Testcls2", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@type": "send_qualified", + "base": null, + "selector": "attr_reader", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 5 + }, + "@token": "b", + "@type": "sym" } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 6 }, - { - "base": null, - "end_col": 18, - "end_line": 10, - "selector": "attr_reader", - "start_col": 4, - "start_line": 10, - "type": "send", - "values": [ + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "send_qualified", + "base": null, + "selector": "attr_writer", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 6 + }, + "@token": "b", + "@type": "sym" + } + ] + } + ] + } + ], + "parent": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 8 + }, + "@token": "Testcls3", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 13 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 9 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 9 + }, + "@type": "ivasgn", + "target": "@c", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 10 + }, + "@type": "send_qualified", + "base": null, + "selector": "attr_reader", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 10 + }, + "@token": "c", + "@type": "sym" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 11 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 11 + }, + "@token": "c=", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 11 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 11 + }, + "@type": "args", + "children": [ { - "end_col": 18, - "end_line": 10, - "start_col": 16, - "start_line": 10, - "token": "c", - "type": "sym" + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 11 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 11 + }, + "@token": "new_c", + "@type": "arg" } ] }, - { - "args": { - "children": [ - { - "end_col": 16, - "end_line": 11, - "start_col": 11, - "start_line": 11, - "token": "new_c", - "type": "arg" - } - ], - "end_col": 17, - "end_line": 11, - "start_col": 10, - "start_line": 11, - "type": "args" - }, - "body": [ - { - "end_col": 18, - "end_line": 12, - "start_col": 8, - "start_line": 12, - "target": "@c", - "type": "ivasgn", - "value": { - "end_col": 18, - "end_line": 12, - "start_col": 13, - "start_line": 12, - "token": "new_c", - "type": "lvar" - } + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 12 + }, + "@type": "ivasgn", + "target": "@c", + "value": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 12 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 12 + }, + "@token": "new_c", + "@type": "lvar" } - ], - "end_col": 7, - "end_line": 11, - "name": "c=", - "start_col": 4, - "start_line": 11, - "type": "def" - } - ], - "end_col": 7, - "end_line": 13, - "start_col": 4, - "start_line": 9, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 8, - "name": "Testcls3", - "parent": null, - "start_col": 0, - "start_line": 8, - "type": "class" - } - ], - "end_col": 3, - "end_line": 14, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] + } + ] + } + ], + "parent": null + } + ] } } } diff --git a/fixtures/u2_class_accessors.rb.uast b/fixtures/u2_class_accessors.rb.uast index 52ae4d6..edc0e24 100644 --- a/fixtures/u2_class_accessors.rb.uast +++ b/fixtures/u2_class_accessors.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls1" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -38,9 +38,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Call,Identifier -. . . . . . . TOKEN "attr_accessor" +. . . . . . 0: send_qualified { +. . . . . . . Roles: Expression,Identical,Qualified . . . . . . . StartPosition: { . . . . . . . . Offset: 19 . . . . . . . . Line: 2 @@ -53,10 +52,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: body +. . . . . . . . selector: attr_accessor . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: sym { -. . . . . . . . . Roles: Expression,Argument,Identifier +. . . . . . . . . Roles: Expression,Identifier . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 33 @@ -77,7 +77,7 @@ UAST: . . . . . } . . . . } . . . . 1: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls2" . . . . . StartPosition: { . . . . . . Offset: 40 @@ -109,9 +109,8 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: send { -. . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . TOKEN "attr_reader" +. . . . . . . . 0: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 59 . . . . . . . . . . Line: 5 @@ -124,10 +123,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: body +. . . . . . . . . . selector: attr_reader . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: sym { -. . . . . . . . . . . Roles: Expression,Argument,Identifier +. . . . . . . . . . . Roles: Expression,Identifier . . . . . . . . . . . TOKEN "b" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 71 @@ -145,9 +145,8 @@ UAST: . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: send { -. . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . TOKEN "attr_writer" +. . . . . . . . 1: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 78 . . . . . . . . . . Line: 6 @@ -160,10 +159,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: body +. . . . . . . . . . selector: attr_writer . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: sym { -. . . . . . . . . . . Roles: Expression,Argument,Identifier +. . . . . . . . . . . Roles: Expression,Identifier . . . . . . . . . . . TOKEN "b" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 90 @@ -186,7 +186,7 @@ UAST: . . . . . } . . . . } . . . . 2: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls3" . . . . . StartPosition: { . . . . . . Offset: 97 @@ -219,7 +219,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: ivasgn { -. . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "@c" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 116 @@ -236,7 +236,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Right,Binary,Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 121 @@ -254,9 +254,8 @@ UAST: . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: send { -. . . . . . . . . Roles: Expression,Call,Identifier -. . . . . . . . . TOKEN "attr_reader" +. . . . . . . . 1: send_qualified { +. . . . . . . . . Roles: Expression,Identical,Qualified . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 127 . . . . . . . . . . Line: 10 @@ -269,10 +268,11 @@ UAST: . . . . . . . . . } . . . . . . . . . Properties: { . . . . . . . . . . internalRole: body +. . . . . . . . . . selector: attr_reader . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: sym { -. . . . . . . . . . . Roles: Expression,Argument,Identifier +. . . . . . . . . . . Roles: Expression,Identifier . . . . . . . . . . . TOKEN "c" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 139 @@ -291,7 +291,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 2: def { -. . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . TOKEN "c=" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 146 @@ -308,7 +308,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: args { -. . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 152 . . . . . . . . . . . . Line: 11 @@ -324,7 +324,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: arg { -. . . . . . . . . . . . . Roles: Expression,Argument,Name +. . . . . . . . . . . . . Roles: Argument,Expression,Identifier,Name . . . . . . . . . . . . . TOKEN "new_c" . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 153 @@ -343,7 +343,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: ivasgn { -. . . . . . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . . . . . TOKEN "@c" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 168 @@ -360,7 +360,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . . Children: { . . . . . . . . . . . . 0: lvar { -. . . . . . . . . . . . . Roles: Right,Binary,Expression,Identifier +. . . . . . . . . . . . . Roles: Binary,Expression,Identifier,Right . . . . . . . . . . . . . TOKEN "new_c" . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 173 diff --git a/fixtures/u2_class_anonymous.rb.native b/fixtures/u2_class_anonymous.rb.native index 2677d2e..7dd1925 100644 --- a/fixtures/u2_class_anonymous.rb.native +++ b/fixtures/u2_class_anonymous.rb.native @@ -3,33 +3,50 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": null, - "blockdata": { - "base": { - "base": null, - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": "Class", - "type": "const" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "block", + "args": null, + "blockdata": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 }, - "end_col": 9, - "end_line": 1, - "selector": "new", - "start_col": 0, - "start_line": 1, - "type": "send" + "@token": "Class", + "@type": "const", + "base": null }, - "body": null, - "end_col": 3, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "block" - } + "selector": "new" + }, + "body": null } } } diff --git a/fixtures/u2_class_anonymous.rb.uast b/fixtures/u2_class_anonymous.rb.uast index 39b31df..c695f50 100644 --- a/fixtures/u2_class_anonymous.rb.uast +++ b/fixtures/u2_class_anonymous.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: block { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Identifier +. . . . 0: send_call { +. . . . . Roles: Call,Expression,Function . . . . . TOKEN "new" . . . . . StartPosition: { . . . . . . Offset: 0 diff --git a/fixtures/u2_class_constructor.rb.native b/fixtures/u2_class_constructor.rb.native index a08befa..8459a32 100644 --- a/fixtures/u2_class_constructor.rb.native +++ b/fixtures/u2_class_constructor.rb.native @@ -3,77 +3,118 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "args": { - "end_col": 20, - "end_line": 2, - "start_col": 18, - "start_line": 2, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 22, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "initialize", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 2 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 2, - "name": "initialize", - "start_col": 4, - "start_line": 2, - "type": "def" + "@start": { + "@type": "ast:Position", + "col": 19, + "line": 2 + }, + "@type": "args" }, - { - "args": { - "children": [ - { - "end_col": 17, - "end_line": 3, - "start_col": 13, - "start_line": 3, - "token": "args", - "type": "restarg" - } - ], - "end_col": 18, - "end_line": 3, - "start_col": 11, - "start_line": 3, - "type": "args" + "body": [ + { + "@type": "NilNode" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@token": "new", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 }, - "body": [ + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 3 + }, + "@type": "args", + "children": [ { - "type": "NilClass" + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 3 + }, + "@token": "args", + "@type": "restarg" } - ], - "end_col": 7, - "end_line": 3, - "name": "new", - "start_col": 4, - "start_line": 3, - "type": "def" - } - ], - "end_col": 22, - "end_line": 3, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + ] + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_constructor.rb.uast b/fixtures/u2_class_constructor.rb.uast index ac322cd..fc80c47 100644 --- a/fixtures/u2_class_constructor.rb.uast +++ b/fixtures/u2_class_constructor.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: begin { @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "initialize" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -55,8 +55,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 33 . . . . . . . . . . Line: 2 @@ -71,16 +77,10 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } . . . . . . 1: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "new" . . . . . . . StartPosition: { . . . . . . . . Offset: 44 @@ -96,8 +96,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 51 . . . . . . . . . . Line: 3 @@ -113,7 +119,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: restarg { -. . . . . . . . . . . Roles: Unannotated +. . . . . . . . . . . Roles: Argument,Expression,Identifier,List . . . . . . . . . . . TOKEN "args" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 53 @@ -131,12 +137,6 @@ UAST: . . . . . . . . . . } . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } diff --git a/fixtures/u2_class_destructor.rb.native b/fixtures/u2_class_destructor.rb.native index 5bb9d9a..a10e45c 100644 --- a/fixtures/u2_class_destructor.rb.native +++ b/fixtures/u2_class_destructor.rb.native @@ -3,106 +3,171 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "args": null, - "base": { - "end_col": 12, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "type": "self" - }, - "class": null, - "end_col": 7, - "end_line": 2, - "name": "testfnc1", - "start_col": 4, - "start_line": 2, - "type": "defs" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - { - "args": { - "type": "args" + "@token": "testfnc1", + "@type": "defs", + "args": null, + "base": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 2 }, - "body": [ - { - "base": { - "base": null, - "end_col": 19, - "end_line": 5, - "start_col": 8, - "start_line": 5, - "token": "ObjectSpace", - "type": "const" + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@type": "self" + }, + "class": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 + }, + "@token": "initialize", + "@type": "def", + "args": { + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 63, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 5 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 19, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 5 }, - "end_col": 63, - "end_line": 5, - "selector": "define_finalizer", - "start_col": 8, - "start_line": 5, - "type": "send", - "values": [ - { - "end_col": 41, - "end_line": 5, - "start_col": 37, - "start_line": 5, - "type": "self" + "@token": "ObjectSpace", + "@type": "const", + "base": null + }, + "selector": "define_finalizer", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 41, + "line": 5 }, - { + "@start": { + "@type": "ast:Position", + "col": 38, + "line": 5 + }, + "@type": "self" + }, + { + "@end": { + "@type": "ast:Position", + "col": 62, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 44, + "line": 5 + }, + "@type": "send_call", + "base": { + "@end": { + "@type": "ast:Position", + "col": 53, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 44, + "line": 5 + }, + "@type": "send_call", "base": { - "base": { - "end_col": 47, - "end_line": 5, - "start_col": 43, - "start_line": 5, - "type": "self" + "@end": { + "@type": "ast:Position", + "col": 47, + "line": 5 }, - "end_col": 53, - "end_line": 5, - "selector": "class", - "start_col": 43, - "start_line": 5, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 44, + "line": 5 + }, + "@type": "self" }, - "end_col": 62, - "end_line": 5, - "selector": "testfnc1", - "start_col": 43, - "start_line": 5, - "type": "send" - } - ] - } - ], - "end_col": 7, - "end_line": 4, - "name": "initialize", - "start_col": 4, - "start_line": 4, - "type": "def" - } - ], - "end_col": 7, - "end_line": 6, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "selector": "class" + }, + "selector": "testfnc1" + } + ] + } + ] + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_destructor.rb.uast b/fixtures/u2_class_destructor.rb.uast index 8570cbf..dab5b33 100644 --- a/fixtures/u2_class_destructor.rb.uast +++ b/fixtures/u2_class_destructor.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: begin { @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: defs { -. . . . . . . Roles: Statement,Function,Declaration,Identifier,Incomplete +. . . . . . . Roles: Declaration,Function,Identifier,Incomplete,Statement . . . . . . . TOKEN "testfnc1" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -56,7 +56,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: self { -. . . . . . . . . Roles: Expression,This,Left +. . . . . . . . . Roles: Expression,Left,This . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 23 . . . . . . . . . . Line: 2 @@ -74,7 +74,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "initialize" . . . . . . . StartPosition: { . . . . . . . . Offset: 49 @@ -91,13 +91,13 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . Properties: { . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: send { -. . . . . . . . . Roles: Expression,Identifier,Call +. . . . . . . . 1: send_call { +. . . . . . . . . Roles: Call,Expression,Function . . . . . . . . . TOKEN "define_finalizer" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 72 @@ -131,7 +131,7 @@ UAST: . . . . . . . . . . . } . . . . . . . . . . } . . . . . . . . . . 1: self { -. . . . . . . . . . . Roles: Expression,Argument,Identifier,This,Left +. . . . . . . . . . . Roles: Argument,Call,Expression,Function,Left,This . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 101 . . . . . . . . . . . . Line: 5 @@ -146,8 +146,8 @@ UAST: . . . . . . . . . . . . internalRole: values . . . . . . . . . . . } . . . . . . . . . . } -. . . . . . . . . . 2: send { -. . . . . . . . . . . Roles: Expression,Argument,Identifier +. . . . . . . . . . 2: send_call { +. . . . . . . . . . . Roles: Argument,Call,Expression,Function . . . . . . . . . . . TOKEN "testfnc1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 107 @@ -163,8 +163,8 @@ UAST: . . . . . . . . . . . . internalRole: values . . . . . . . . . . . } . . . . . . . . . . . Children: { -. . . . . . . . . . . . 0: send { -. . . . . . . . . . . . . Roles: Expression,Qualified,Identifier +. . . . . . . . . . . . 0: send_call { +. . . . . . . . . . . . . Roles: Call,Expression,Function . . . . . . . . . . . . . TOKEN "class" . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . Offset: 107 @@ -181,7 +181,7 @@ UAST: . . . . . . . . . . . . . } . . . . . . . . . . . . . Children: { . . . . . . . . . . . . . . 0: self { -. . . . . . . . . . . . . . . Roles: Expression,This,Left +. . . . . . . . . . . . . . . Roles: Expression,Left,This . . . . . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . . . . . Offset: 107 . . . . . . . . . . . . . . . . Line: 5 diff --git a/fixtures/u2_class_empty.rb.native b/fixtures/u2_class_empty.rb.native index 7815b40..a91256d 100644 --- a/fixtures/u2_class_empty.rb.native +++ b/fixtures/u2_class_empty.rb.native @@ -3,21 +3,26 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@type": "NilNode" + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_empty.rb.uast b/fixtures/u2_class_empty.rb.uast index e07b299..c281567 100644 --- a/fixtures/u2_class_empty.rb.uast +++ b/fixtures/u2_class_empty.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: NilClass { -. . . . . Roles: Statement,Type,Null +. . . . 0: NilNode { +. . . . . Roles: Null . . . . . Properties: { . . . . . . internalRole: body . . . . . } diff --git a/fixtures/u2_class_field.rb.native b/fixtures/u2_class_field.rb.native index d382ed9..5f2a739 100644 --- a/fixtures/u2_class_field.rb.native +++ b/fixtures/u2_class_field.rb.native @@ -3,34 +3,51 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 15, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "@member", - "type": "ivasgn", - "value": { - "end_col": 15, - "end_line": 2, - "start_col": 14, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "ivasgn", + "target": "@member", + "value": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 2 + }, + "@token": 1, + "@type": "int" } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_field.rb.uast b/fixtures/u2_class_field.rb.uast index 358635f..2e4eda2 100644 --- a/fixtures/u2_class_field.rb.uast +++ b/fixtures/u2_class_field.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: ivasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "@member" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -40,7 +40,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Binary,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 29 diff --git a/fixtures/u2_class_field_binding.rb.native b/fixtures/u2_class_field_binding.rb.native index 6aedfbe..389df10 100644 --- a/fixtures/u2_class_field_binding.rb.native +++ b/fixtures/u2_class_field_binding.rb.native @@ -3,34 +3,51 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "end_col": 18, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "@@classvar", - "type": "cvasgn", - "value": { - "end_col": 18, - "end_line": 2, - "start_col": 17, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "cvasgn", + "target": "@@classvar", + "value": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@token": 1, + "@type": "int" } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_field_binding.rb.uast b/fixtures/u2_class_field_binding.rb.uast index 633dc18..44ca72b 100644 --- a/fixtures/u2_class_field_binding.rb.uast +++ b/fixtures/u2_class_field_binding.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: cvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . TOKEN "@@classvar" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -40,7 +40,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Binary,Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 32 diff --git a/fixtures/u2_class_field_qualifiers.rb.native b/fixtures/u2_class_field_qualifiers.rb.native index b0f5cbf..c0495c9 100644 --- a/fixtures/u2_class_field_qualifiers.rb.native +++ b/fixtures/u2_class_field_qualifiers.rb.native @@ -3,102 +3,167 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "base": null, - "end_col": 11, - "end_line": 2, - "selector": "private", - "start_col": 4, - "start_line": 2, - "type": "send" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 }, - { - "end_col": 10, - "end_line": 3, - "start_col": 4, - "start_line": 3, - "target": "@a", - "type": "ivasgn", - "value": { - "end_col": 10, - "end_line": 3, - "start_col": 9, - "start_line": 3, - "token": 1, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - { - "base": null, - "end_col": 13, - "end_line": 5, - "selector": "protected", - "start_col": 4, - "start_line": 5, - "type": "send" + "@type": "send_statement", + "base": null, + "selector": "private" + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 3 }, - { - "end_col": 10, - "end_line": 6, - "start_col": 4, - "start_line": 6, - "target": "@b", - "type": "ivasgn", - "value": { - "end_col": 10, - "end_line": 6, - "start_col": 9, - "start_line": 6, - "token": 2, - "type": "int" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 }, - { - "base": null, - "end_col": 10, - "end_line": 8, - "selector": "public", - "start_col": 4, - "start_line": 8, - "type": "send" + "@type": "ivasgn", + "target": "@a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 3 + }, + "@token": 1, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@type": "send_statement", + "base": null, + "selector": "protected" + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "ivasgn", + "target": "@b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 6 + }, + "@token": 2, + "@type": "int" + } + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 8 + }, + "@type": "send_statement", + "base": null, + "selector": "public" + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 9 }, - { - "end_col": 10, - "end_line": 9, - "start_col": 4, - "start_line": 9, - "target": "@c", - "type": "ivasgn", - "value": { - "end_col": 10, - "end_line": 9, - "start_col": 9, - "start_line": 9, - "token": 3, - "type": "int" - } + "@type": "ivasgn", + "target": "@c", + "value": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 9 + }, + "@token": 3, + "@type": "int" } - ], - "end_col": 10, - "end_line": 9, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_field_qualifiers.rb.uast b/fixtures/u2_class_field_qualifiers.rb.uast index c785326..163cf64 100644 --- a/fixtures/u2_class_field_qualifiers.rb.uast +++ b/fixtures/u2_class_field_qualifiers.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: begin { @@ -38,9 +38,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Call,Identifier -. . . . . . . TOKEN "private" +. . . . . . 0: send_statement { +. . . . . . . Roles: Instance,Statement,Visibility . . . . . . . StartPosition: { . . . . . . . . Offset: 19 . . . . . . . . Line: 2 @@ -56,7 +55,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: ivasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "@a" . . . . . . . StartPosition: { . . . . . . . . Offset: 31 @@ -73,7 +72,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Binary,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 36 @@ -91,8 +90,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 2: send { -. . . . . . . Roles: Expression,Call,Identifier +. . . . . . 2: send_statement { +. . . . . . . Roles: Statement,Subtype,Visibility . . . . . . . TOKEN "protected" . . . . . . . StartPosition: { . . . . . . . . Offset: 43 @@ -109,7 +108,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 3: ivasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "@b" . . . . . . . StartPosition: { . . . . . . . . Offset: 57 @@ -126,7 +125,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Binary,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "2" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 62 @@ -144,8 +143,8 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 4: send { -. . . . . . . Roles: Expression,Call,Identifier +. . . . . . 4: send_statement { +. . . . . . . Roles: Statement,Visibility,World . . . . . . . TOKEN "public" . . . . . . . StartPosition: { . . . . . . . . Offset: 69 @@ -162,7 +161,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 5: ivasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left,Incomplete +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "@c" . . . . . . . StartPosition: { . . . . . . . . Offset: 80 @@ -179,7 +178,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Binary,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "3" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 85 diff --git a/fixtures/u2_class_inherit.rb.native b/fixtures/u2_class_inherit.rb.native index b0b7332..583b612 100644 --- a/fixtures/u2_class_inherit.rb.native +++ b/fixtures/u2_class_inherit.rb.native @@ -3,52 +3,75 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 }, - { - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 5, - "end_line": 2, - "name": "Testcls2", - "parent": { - "base": null, - "end_col": 25, - "end_line": 2, - "start_col": 17, - "start_line": 2, - "token": "Testcls1", - "type": "const" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@type": "NilNode" + } + ], + "parent": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@token": "Testcls2", + "@type": "class", + "body": [ + { + "@type": "NilNode" + } + ], + "parent": { + "@end": { + "@type": "ast:Position", + "col": 25, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 2 }, - "start_col": 0, - "start_line": 2, - "type": "class" + "@token": "Testcls1", + "@type": "const", + "base": null } - ], - "end_col": 3, - "end_line": 3, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/u2_class_inherit.rb.uast b/fixtures/u2_class_inherit.rb.uast index 2b95ea2..ce8dfbf 100644 --- a/fixtures/u2_class_inherit.rb.uast +++ b/fixtures/u2_class_inherit.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls1" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -38,8 +38,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: NilClass { -. . . . . . . Roles: Statement,Type,Null +. . . . . . 0: NilNode { +. . . . . . . Roles: Null . . . . . . . Properties: { . . . . . . . . internalRole: body . . . . . . . } @@ -47,7 +47,7 @@ UAST: . . . . . } . . . . } . . . . 1: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls2" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -63,8 +63,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: NilClass { -. . . . . . . Roles: Statement,Type,Null +. . . . . . 0: NilNode { +. . . . . . . Roles: Null . . . . . . . Properties: { . . . . . . . . internalRole: body . . . . . . . } diff --git a/fixtures/u2_class_inner.rb.native b/fixtures/u2_class_inner.rb.native index 54721bc..29b867b 100644 --- a/fixtures/u2_class_inner.rb.native +++ b/fixtures/u2_class_inner.rb.native @@ -3,32 +3,43 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 9, - "end_line": 2, - "name": "Testcls2", - "parent": null, - "start_col": 4, - "start_line": 2, - "type": "class" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "Testcls2", + "@type": "class", + "body": [ + { + "@type": "NilNode" + } + ], + "parent": null + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_inner.rb.uast b/fixtures/u2_class_inner.rb.uast index f48cb3b..28c1235 100644 --- a/fixtures/u2_class_inner.rb.uast +++ b/fixtures/u2_class_inner.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls2" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -39,8 +39,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: NilClass { -. . . . . . . Roles: Statement,Type,Null +. . . . . . 0: NilNode { +. . . . . . . Roles: Null . . . . . . . Properties: { . . . . . . . . internalRole: body . . . . . . . } diff --git a/fixtures/u2_class_method.rb.native b/fixtures/u2_class_method.rb.native index ef34354..0d11802 100644 --- a/fixtures/u2_class_method.rb.native +++ b/fixtures/u2_class_method.rb.native @@ -3,38 +3,55 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "args": { - "end_col": 18, - "end_line": 2, - "start_col": 16, - "start_line": 2, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 2, - "name": "testfnc1", - "start_col": 4, - "start_line": 2, - "type": "def" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_method.rb.uast b/fixtures/u2_class_method.rb.uast index 58bbe14..a81e580 100644 --- a/fixtures/u2_class_method.rb.uast +++ b/fixtures/u2_class_method.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: def { -. . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . Roles: Declaration,Function,Identifier,Statement . . . . . TOKEN "testfnc1" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -39,8 +39,14 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: args { -. . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . 0: NilNode { +. . . . . . . Roles: Null +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . } +. . . . . . 1: args { +. . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . StartPosition: { . . . . . . . . Offset: 31 . . . . . . . . Line: 2 @@ -55,12 +61,6 @@ UAST: . . . . . . . . internalRole: args . . . . . . . } . . . . . . } -. . . . . . 1: NilClass { -. . . . . . . Roles: Statement,Type,Null -. . . . . . . Properties: { -. . . . . . . . internalRole: body -. . . . . . . } -. . . . . . } . . . . . } . . . . } . . . } diff --git a/fixtures/u2_class_method_binding.rb.native b/fixtures/u2_class_method_binding.rb.native index e3d4ebd..1c8f7aa 100644 --- a/fixtures/u2_class_method_binding.rb.native +++ b/fixtures/u2_class_method_binding.rb.native @@ -3,35 +3,52 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "args": null, - "base": { - "end_col": 12, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "type": "self" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "testfnc1", + "@type": "defs", + "args": null, + "base": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 2 }, - "class": null, - "end_col": 7, - "end_line": 2, - "name": "testfnc1", - "start_col": 4, - "start_line": 2, - "type": "defs" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@type": "self" + }, + "class": null + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_method_binding.rb.uast b/fixtures/u2_class_method_binding.rb.uast index 0c3ea0f..d38cbbb 100644 --- a/fixtures/u2_class_method_binding.rb.uast +++ b/fixtures/u2_class_method_binding.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: defs { -. . . . . Roles: Statement,Function,Declaration,Identifier,Incomplete +. . . . . Roles: Declaration,Function,Identifier,Incomplete,Statement . . . . . TOKEN "testfnc1" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -40,7 +40,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: self { -. . . . . . . Roles: Expression,This,Left +. . . . . . . Roles: Expression,Left,This . . . . . . . StartPosition: { . . . . . . . . Offset: 23 . . . . . . . . Line: 2 diff --git a/fixtures/u2_class_method_qualifiers.rb.native b/fixtures/u2_class_method_qualifiers.rb.native index e2f5586..66b855c 100644 --- a/fixtures/u2_class_method_qualifiers.rb.native +++ b/fixtures/u2_class_method_qualifiers.rb.native @@ -3,114 +3,179 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "base": null, - "end_col": 11, - "end_line": 2, - "selector": "private", - "start_col": 4, - "start_line": 2, - "type": "send" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 22, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 }, - { - "args": { - "end_col": 18, - "end_line": 3, - "start_col": 16, - "start_line": 3, - "type": "args" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "send_statement", + "base": null, + "selector": "private" + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 3 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 3, - "name": "testfnc1", - "start_col": 4, - "start_line": 3, - "type": "def" + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 13, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@type": "send_statement", + "base": null, + "selector": "protected" + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 }, - { - "base": null, - "end_col": 13, - "end_line": 5, - "selector": "protected", - "start_col": 4, - "start_line": 5, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 }, - { - "args": { - "end_col": 18, - "end_line": 6, - "start_col": 16, - "start_line": 6, - "type": "args" + "@token": "testfnc2", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 6 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 6, - "name": "testfnc2", - "start_col": 4, - "start_line": 6, - "type": "def" + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 6 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 8 }, - { - "base": null, - "end_col": 10, - "end_line": 8, - "selector": "public", - "start_col": 4, - "start_line": 8, - "type": "send" + "@type": "send_statement", + "base": null, + "selector": "public" + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 9 }, - { - "args": { - "end_col": 18, - "end_line": 9, - "start_col": 16, - "start_line": 9, - "type": "args" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 9 + }, + "@token": "testfnc3", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 9 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 9, - "name": "testfnc3", - "start_col": 4, - "start_line": 9, - "type": "def" - } - ], - "end_col": 22, - "end_line": 9, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_method_qualifiers.rb.uast b/fixtures/u2_class_method_qualifiers.rb.uast index 9fae301..a48cbb2 100644 --- a/fixtures/u2_class_method_qualifiers.rb.uast +++ b/fixtures/u2_class_method_qualifiers.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: begin { @@ -38,9 +38,8 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: send { -. . . . . . . Roles: Expression,Call,Identifier -. . . . . . . TOKEN "private" +. . . . . . 0: send_statement { +. . . . . . . Roles: Instance,Statement,Visibility . . . . . . . StartPosition: { . . . . . . . . Offset: 19 . . . . . . . . Line: 2 @@ -56,7 +55,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "testfnc1" . . . . . . . StartPosition: { . . . . . . . . Offset: 31 @@ -72,8 +71,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 43 . . . . . . . . . . Line: 3 @@ -88,16 +93,10 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 2: send { -. . . . . . . Roles: Expression,Call,Identifier +. . . . . . 2: send_statement { +. . . . . . . Roles: Statement,Subtype,Visibility . . . . . . . TOKEN "protected" . . . . . . . StartPosition: { . . . . . . . . Offset: 55 @@ -114,7 +113,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 3: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "testfnc2" . . . . . . . StartPosition: { . . . . . . . . Offset: 69 @@ -130,8 +129,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 81 . . . . . . . . . . Line: 6 @@ -146,16 +151,10 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 4: send { -. . . . . . . Roles: Expression,Call,Identifier +. . . . . . 4: send_statement { +. . . . . . . Roles: Statement,Visibility,World . . . . . . . TOKEN "public" . . . . . . . StartPosition: { . . . . . . . . Offset: 94 @@ -172,7 +171,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 5: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "testfnc3" . . . . . . . StartPosition: { . . . . . . . . Offset: 105 @@ -188,8 +187,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 117 . . . . . . . . . . Line: 9 @@ -204,12 +209,6 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } diff --git a/fixtures/u2_class_method_return.rb.native b/fixtures/u2_class_method_return.rb.native index dfbf1bb..dc62e75 100644 --- a/fixtures/u2_class_method_return.rb.native +++ b/fixtures/u2_class_method_return.rb.native @@ -3,116 +3,193 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "args": { - "end_col": 17, - "end_line": 2, - "start_col": 15, - "start_line": 2, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "A", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "method1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 2 }, - "body": [ - { - "end_col": 14, - "end_line": 3, - "start_col": 8, - "start_line": 3, - "target": null, - "type": "return" - } - ], - "end_col": 7, - "end_line": 2, - "name": "method1", - "start_col": 4, - "start_line": 2, - "type": "def" + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 2 + }, + "@type": "args" }, - { - "args": { - "end_col": 17, - "end_line": 5, - "start_col": 15, - "start_line": 5, - "type": "args" + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 3 + }, + "@type": "return", + "target": null + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 5 + }, + "@token": "method2", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 5 }, - "body": [ - { - "end_col": 14, - "end_line": 6, - "start_col": 8, - "start_line": 6, - "target": { - "end_col": 16, - "end_line": 6, - "start_col": 15, - "start_line": 6, - "token": 1, - "type": "int" + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@type": "return", + "target": { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 6 }, - "type": "return" + "@token": 1, + "@type": "int" } - ], - "end_col": 7, - "end_line": 5, - "name": "method2", - "start_col": 4, - "start_line": 5, - "type": "def" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 8 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 8 }, - { - "args": { - "end_col": 17, - "end_line": 8, - "start_col": 15, - "start_line": 8, - "type": "args" + "@token": "method3", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 8 }, - "body": [ - { - "end_col": 14, - "end_line": 9, - "start_col": 8, - "start_line": 9, - "target": { - "end_col": 16, - "end_line": 9, - "start_col": 15, - "start_line": 9, - "token": 2, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 8 + }, + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 9 + }, + "@type": "return", + "target": { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 9 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 9 }, - "type": "return" + "@token": 2, + "@type": "int" } - ], - "end_col": 7, - "end_line": 8, - "name": "method3", - "start_col": 4, - "start_line": 8, - "type": "def" - } - ], - "end_col": 7, - "end_line": 10, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 5, - "end_line": 1, - "name": "A", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + } + ] + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_method_return.rb.uast b/fixtures/u2_class_method_return.rb.uast index c04d50d..603f954 100644 --- a/fixtures/u2_class_method_return.rb.uast +++ b/fixtures/u2_class_method_return.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "A" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: begin { @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "method1" . . . . . . . StartPosition: { . . . . . . . . Offset: 12 @@ -56,7 +56,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 23 . . . . . . . . . . Line: 2 @@ -72,7 +72,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: return { -. . . . . . . . . Roles: Unannotated +. . . . . . . . . Roles: Return,Statement . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 34 . . . . . . . . . . Line: 3 @@ -90,7 +90,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "method2" . . . . . . . StartPosition: { . . . . . . . . Offset: 53 @@ -107,7 +107,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 64 . . . . . . . . . . Line: 5 @@ -123,7 +123,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: return { -. . . . . . . . . Roles: Unannotated +. . . . . . . . . Roles: Return,Statement . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 75 . . . . . . . . . . Line: 6 @@ -139,7 +139,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Binary,Expression,Left,Literal,Number,Primitive . . . . . . . . . . . TOKEN "1" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 82 @@ -160,7 +160,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 2: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "method3" . . . . . . . StartPosition: { . . . . . . . . Offset: 96 @@ -177,7 +177,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 107 . . . . . . . . . . Line: 8 @@ -193,7 +193,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: return { -. . . . . . . . . Roles: Unannotated +. . . . . . . . . Roles: Return,Statement . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 118 . . . . . . . . . . Line: 9 @@ -209,7 +209,7 @@ UAST: . . . . . . . . . } . . . . . . . . . Children: { . . . . . . . . . . 0: int { -. . . . . . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . . . . . Roles: Binary,Expression,Left,Literal,Number,Primitive . . . . . . . . . . . TOKEN "2" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 125 diff --git a/fixtures/u2_class_specific_method_singleton.rb.native b/fixtures/u2_class_specific_method_singleton.rb.native index d47f65a..abd0290 100644 --- a/fixtures/u2_class_specific_method_singleton.rb.native +++ b/fixtures/u2_class_specific_method_singleton.rb.native @@ -3,24 +3,35 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": null, - "base": { - "end_col": 8, - "end_line": 1, - "start_col": 4, - "start_line": 1, - "type": "self" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "defs", + "args": null, + "base": { + "@end": { + "@type": "ast:Position", + "col": 8, + "line": 1 }, - "class": null, - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "defs" - } + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@type": "self" + }, + "class": null } } } diff --git a/fixtures/u2_class_specific_method_singleton.rb.uast b/fixtures/u2_class_specific_method_singleton.rb.uast index 4bdd7e6..b1691f7 100644 --- a/fixtures/u2_class_specific_method_singleton.rb.uast +++ b/fixtures/u2_class_specific_method_singleton.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: defs { -. . . Roles: Statement,Function,Declaration,Identifier,Incomplete +. . . Roles: Declaration,Function,Identifier,Incomplete,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: self { -. . . . . Roles: Expression,This,Left +. . . . . Roles: Expression,Left,This . . . . . StartPosition: { . . . . . . Offset: 4 . . . . . . Line: 1 diff --git a/fixtures/u2_class_specific_method_undefine.rb.native b/fixtures/u2_class_specific_method_undefine.rb.native index 4c6852a..0f1a7e9 100644 --- a/fixtures/u2_class_specific_method_undefine.rb.native +++ b/fixtures/u2_class_specific_method_undefine.rb.native @@ -3,81 +3,128 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "body": [ - { - "args": { - "end_col": 18, - "end_line": 2, - "start_col": 16, - "start_line": 2, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 2, - "name": "testfnc1", - "start_col": 4, - "start_line": 2, - "type": "def" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ], + "parent": null + }, + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 5 }, - { - "body": [ - { - "end_col": 9, - "end_line": 6, - "start_col": 4, - "start_line": 6, - "target": { - "end_col": 18, - "end_line": 6, - "start_col": 10, - "start_line": 6, - "token": "testfnc1", - "type": "sym" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@token": "Testcls2", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@type": "undef", + "target": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 6 }, - "type": "undef" + "@token": "testfnc1", + "@type": "sym" } - ], - "end_col": 5, - "end_line": 5, - "name": "Testcls2", - "parent": { - "base": null, - "end_col": 25, - "end_line": 5, - "start_col": 17, - "start_line": 5, - "token": "Testcls1", - "type": "const" + } + ], + "parent": { + "@end": { + "@type": "ast:Position", + "col": 25, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 5 }, - "start_col": 0, - "start_line": 5, - "type": "class" + "@token": "Testcls1", + "@type": "const", + "base": null } - ], - "end_col": 3, - "end_line": 7, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + } + ] } } } diff --git a/fixtures/u2_class_specific_method_undefine.rb.uast b/fixtures/u2_class_specific_method_undefine.rb.uast index e214ddb..c53b508 100644 --- a/fixtures/u2_class_specific_method_undefine.rb.uast +++ b/fixtures/u2_class_specific_method_undefine.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls1" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "testfnc1" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -55,8 +55,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 31 . . . . . . . . . . Line: 2 @@ -71,18 +77,12 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 1: class { -. . . . . Roles: Statement,Type,Declaration,Identifier +. . . . . Roles: Declaration,Identifier,Statement,Type . . . . . TOKEN "Testcls2" . . . . . StartPosition: { . . . . . . Offset: 46 @@ -98,8 +98,25 @@ UAST: . . . . . . internalRole: body . . . . . } . . . . . Children: { -. . . . . . 0: undef { -. . . . . . . Roles: Statement,Incomplete +. . . . . . 0: const { +. . . . . . . Roles: Expression,Identifier,Incomplete +. . . . . . . TOKEN "Testcls1" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 63 +. . . . . . . . Line: 5 +. . . . . . . . Col: 18 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 70 +. . . . . . . . Line: 5 +. . . . . . . . Col: 25 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: parent +. . . . . . . } +. . . . . . } +. . . . . . 1: undef { +. . . . . . . Roles: Incomplete,Statement . . . . . . . StartPosition: { . . . . . . . . Offset: 76 . . . . . . . . Line: 6 @@ -115,7 +132,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: sym { -. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . Roles: Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "testfnc1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 82 @@ -133,23 +150,6 @@ UAST: . . . . . . . . } . . . . . . . } . . . . . . } -. . . . . . 1: const { -. . . . . . . Roles: Expression,Identifier,Incomplete -. . . . . . . TOKEN "Testcls1" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 63 -. . . . . . . . Line: 5 -. . . . . . . . Col: 18 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 70 -. . . . . . . . Line: 5 -. . . . . . . . Col: 25 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: parent -. . . . . . . } -. . . . . . } . . . . . } . . . . } . . . } diff --git a/fixtures/u2_class_this.rb.native b/fixtures/u2_class_this.rb.native index 428e33a..ddf2302 100644 --- a/fixtures/u2_class_this.rb.native +++ b/fixtures/u2_class_this.rb.native @@ -3,56 +3,86 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "args": { - "type": "args" - }, - "body": [ - { - "base": { - "end_col": 12, - "end_line": 3, - "start_col": 8, - "start_line": 3, - "type": "self" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testcls1", + "@type": "class", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 3 + }, + "@token": "a", + "@type": "send_assign", + "base": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 3 }, - "end_col": 18, - "end_line": 3, - "selector": "a=", - "start_col": 8, - "start_line": 3, - "type": "send", - "values": [ - { - "end_col": 18, - "end_line": 3, - "start_col": 17, - "start_line": 3, - "token": 1, - "type": "int" - } - ] - } - ], - "end_col": 7, - "end_line": 2, - "name": "testfnc1", - "start_col": 4, - "start_line": 2, - "type": "def" - } - ], - "end_col": 5, - "end_line": 1, - "name": "Testcls1", - "parent": null, - "start_col": 0, - "start_line": 1, - "type": "class" - } + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 3 + }, + "@type": "self" + }, + "selector": "a=", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 3 + }, + "@token": 1, + "@type": "int" + } + ] + } + ] + } + ], + "parent": null } } } diff --git a/fixtures/u2_class_this.rb.uast b/fixtures/u2_class_this.rb.uast index c94aba7..79661f9 100644 --- a/fixtures/u2_class_this.rb.uast +++ b/fixtures/u2_class_this.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: class { -. . . Roles: Statement,Type,Declaration,Identifier +. . . Roles: Declaration,Identifier,Statement,Type . . . TOKEN "Testcls1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: def { -. . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . Roles: Declaration,Function,Identifier,Statement . . . . . TOKEN "testfnc1" . . . . . StartPosition: { . . . . . . Offset: 19 @@ -40,14 +40,14 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: args { -. . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . Properties: { . . . . . . . . internalRole: args . . . . . . . } . . . . . . } -. . . . . . 1: send { -. . . . . . . Roles: Expression,Identifier,Call -. . . . . . . TOKEN "a=" +. . . . . . 1: send_assign { +. . . . . . . Roles: Assignment,Expression,Left +. . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 40 . . . . . . . . Line: 3 @@ -60,10 +60,11 @@ UAST: . . . . . . . } . . . . . . . Properties: { . . . . . . . . internalRole: body +. . . . . . . . selector: a= . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: self { -. . . . . . . . . Roles: Expression,This,Left +. . . . . . . . . Roles: Expression,Left,This . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 40 . . . . . . . . . . Line: 3 @@ -79,7 +80,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: int { -. . . . . . . . . Roles: Expression,Literal,Number,Primitive,Argument,Identifier +. . . . . . . . . Roles: Assignment,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 49 diff --git a/fixtures/u2_func_anonymous.rb.native b/fixtures/u2_func_anonymous.rb.native index 6c16b8f..816555c 100644 --- a/fixtures/u2_func_anonymous.rb.native +++ b/fixtures/u2_func_anonymous.rb.native @@ -3,25 +3,36 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": null, - "blockdata": { - "base": null, - "end_col": 6, - "end_line": 1, - "selector": "lambda", - "start_col": 0, - "start_line": 1, - "type": "send" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "block", + "args": null, + "blockdata": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 }, - "body": null, - "end_col": 9, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "block" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_statement", + "base": null, + "selector": "lambda" + }, + "body": null } } } diff --git a/fixtures/u2_func_anonymous.rb.uast b/fixtures/u2_func_anonymous.rb.uast index badb59c..f6220d3 100644 --- a/fixtures/u2_func_anonymous.rb.uast +++ b/fixtures/u2_func_anonymous.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: block { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 9 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Declaration,Function,Anonymous +. . . . 0: send_statement { +. . . . . Roles: Anonymous,Declaration,Expression,Function . . . . . TOKEN "lambda" . . . . . StartPosition: { . . . . . . Offset: 0 diff --git a/fixtures/u2_func_empty.rb.native b/fixtures/u2_func_empty.rb.native index 6ecb19f..09e2e5d 100644 --- a/fixtures/u2_func_empty.rb.native +++ b/fixtures/u2_func_empty.rb.native @@ -3,27 +3,38 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "end_col": 14, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 1 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] } } } diff --git a/fixtures/u2_func_empty.rb.uast b/fixtures/u2_func_empty.rb.uast index 97f6e0e..ef3ba70 100644 --- a/fixtures/u2_func_empty.rb.uast +++ b/fixtures/u2_func_empty.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,17 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . 0: NilNode { +. . . . . Roles: Null +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . } +. . . . 1: args { +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 @@ -38,12 +44,6 @@ UAST: . . . . . . internalRole: args . . . . . } . . . . } -. . . . 1: NilClass { -. . . . . Roles: Statement,Type,Null -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/u2_func_inner.rb.native b/fixtures/u2_func_inner.rb.native index 3fd0930..f432427 100644 --- a/fixtures/u2_func_inner.rb.native +++ b/fixtures/u2_func_inner.rb.native @@ -3,107 +3,172 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "args": { - "end_col": 14, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 10 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 }, - "body": [ - { - "args": { - "end_col": 18, - "end_line": 2, - "start_col": 16, - "start_line": 2, - "type": "args" + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "testfnc2", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 2 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 2, - "name": "testfnc2", - "start_col": 4, - "start_line": 2, - "type": "def" - } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 5 }, - { - "args": { - "end_col": 14, - "end_line": 5, - "start_col": 12, - "start_line": 5, - "type": "args" + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 5 + }, + "@token": "testfnc3", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 5 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 5 }, - "body": [ - { - "args": { - "end_col": 18, - "end_line": 6, - "start_col": 16, - "start_line": 6, - "type": "args" + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 6 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 6 + }, + "@token": "testfnc4", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 6 }, - "body": [ - { - "args": { - "end_col": 22, - "end_line": 7, - "start_col": 20, - "start_line": 7, - "type": "args" + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 6 + }, + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 7 + }, + "@token": "testfnc5", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 22, + "line": 7 + }, + "@start": { + "@type": "ast:Position", + "col": 21, + "line": 7 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 11, - "end_line": 7, - "name": "testfnc5", - "start_col": 8, - "start_line": 7, - "type": "def" - } - ], - "end_col": 7, - "end_line": 6, - "name": "testfnc4", - "start_col": 4, - "start_line": 6, - "type": "def" - } - ], - "end_col": 3, - "end_line": 5, - "name": "testfnc3", - "start_col": 0, - "start_line": 5, - "type": "def" - } - ], - "end_col": 3, - "end_line": 10, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ] + } + ] + } + ] } } } diff --git a/fixtures/u2_func_inner.rb.uast b/fixtures/u2_func_inner.rb.uast index fab7834..7514268 100644 --- a/fixtures/u2_func_inner.rb.uast +++ b/fixtures/u2_func_inner.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: def { -. . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . Roles: Declaration,Function,Identifier,Statement . . . . . TOKEN "testfnc1" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: args { -. . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . StartPosition: { . . . . . . . . Offset: 12 . . . . . . . . Line: 1 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "testfnc2" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -71,8 +71,14 @@ UAST: . . . . . . . . internalRole: body . . . . . . . } . . . . . . . Children: { -. . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . 0: NilNode { +. . . . . . . . . Roles: Null +. . . . . . . . . Properties: { +. . . . . . . . . . internalRole: body +. . . . . . . . . } +. . . . . . . . } +. . . . . . . . 1: args { +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 31 . . . . . . . . . . Line: 2 @@ -87,18 +93,12 @@ UAST: . . . . . . . . . . internalRole: args . . . . . . . . . } . . . . . . . . } -. . . . . . . . 1: NilClass { -. . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . Properties: { -. . . . . . . . . . internalRole: body -. . . . . . . . . } -. . . . . . . . } . . . . . . . } . . . . . . } . . . . . } . . . . } . . . . 1: def { -. . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . Roles: Declaration,Function,Identifier,Statement . . . . . TOKEN "testfnc3" . . . . . StartPosition: { . . . . . . Offset: 46 @@ -115,7 +115,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: args { -. . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . StartPosition: { . . . . . . . . Offset: 58 . . . . . . . . Line: 5 @@ -131,7 +131,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: def { -. . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . TOKEN "testfnc4" . . . . . . . StartPosition: { . . . . . . . . Offset: 65 @@ -148,7 +148,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: args { -. . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 77 . . . . . . . . . . Line: 6 @@ -164,7 +164,7 @@ UAST: . . . . . . . . . } . . . . . . . . } . . . . . . . . 1: def { -. . . . . . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . . . . . Roles: Declaration,Function,Identifier,Statement . . . . . . . . . TOKEN "testfnc5" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 88 @@ -180,8 +180,14 @@ UAST: . . . . . . . . . . internalRole: body . . . . . . . . . } . . . . . . . . . Children: { -. . . . . . . . . . 0: args { -. . . . . . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . . . . . 0: NilNode { +. . . . . . . . . . . Roles: Null +. . . . . . . . . . . Properties: { +. . . . . . . . . . . . internalRole: body +. . . . . . . . . . . } +. . . . . . . . . . } +. . . . . . . . . . 1: args { +. . . . . . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 100 . . . . . . . . . . . . Line: 7 @@ -196,12 +202,6 @@ UAST: . . . . . . . . . . . . internalRole: args . . . . . . . . . . . } . . . . . . . . . . } -. . . . . . . . . . 1: NilClass { -. . . . . . . . . . . Roles: Statement,Type,Null -. . . . . . . . . . . Properties: { -. . . . . . . . . . . . internalRole: body -. . . . . . . . . . . } -. . . . . . . . . . } . . . . . . . . . } . . . . . . . . } . . . . . . . } diff --git a/fixtures/u2_func_params_variadic_list.rb.native b/fixtures/u2_func_params_variadic_list.rb.native index d26942b..f037e1a 100644 --- a/fixtures/u2_func_params_variadic_list.rb.native +++ b/fixtures/u2_func_params_variadic_list.rb.native @@ -3,37 +3,54 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "children": [ - { - "end_col": 15, - "end_line": 1, - "start_col": 14, - "start_line": 1, - "token": "a", - "type": "restarg" - } - ], - "end_col": 16, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 1 }, - "body": [ + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@type": "args", + "children": [ { - "type": "NilClass" + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@token": "a", + "@type": "restarg" } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + ] + }, + "body": [ + { + "@type": "NilNode" + } + ] } } } diff --git a/fixtures/u2_func_params_variadic_list.rb.uast b/fixtures/u2_func_params_variadic_list.rb.uast index 201840a..e1afe0d 100644 --- a/fixtures/u2_func_params_variadic_list.rb.uast +++ b/fixtures/u2_func_params_variadic_list.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,17 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . 0: NilNode { +. . . . . Roles: Null +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . } +. . . . 1: args { +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 @@ -39,7 +45,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: restarg { -. . . . . . . Roles: Unannotated +. . . . . . . Roles: Argument,Expression,Identifier,List . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 14 @@ -57,12 +63,6 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: NilClass { -. . . . . Roles: Statement,Type,Null -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/u2_func_params_variadic_map.rb.native b/fixtures/u2_func_params_variadic_map.rb.native index 0460861..f71e643 100644 --- a/fixtures/u2_func_params_variadic_map.rb.native +++ b/fixtures/u2_func_params_variadic_map.rb.native @@ -3,37 +3,54 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "children": [ - { - "end_col": 16, - "end_line": 1, - "name": "a", - "start_col": 15, - "start_line": 1, - "type": "kwrestarg" - } - ], - "end_col": 17, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 }, - "body": [ + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@type": "args", + "children": [ { - "type": "NilClass" + "@end": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 16, + "line": 1 + }, + "@token": "a", + "@type": "kwrestarg" } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + ] + }, + "body": [ + { + "@type": "NilNode" + } + ] } } } diff --git a/fixtures/u2_func_params_variadic_map.rb.uast b/fixtures/u2_func_params_variadic_map.rb.uast index 53040a2..f0859bc 100644 --- a/fixtures/u2_func_params_variadic_map.rb.uast +++ b/fixtures/u2_func_params_variadic_map.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,17 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . 0: NilNode { +. . . . . Roles: Null +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . } +. . . . 1: args { +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 @@ -39,7 +45,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: kwrestarg { -. . . . . . . Roles: Expression,Argument,Incomplete,Identifier +. . . . . . . Roles: Argument,Expression,Identifier,Incomplete . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 15 @@ -57,12 +63,6 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: NilClass { -. . . . . Roles: Statement,Type,Null -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/u2_func_return_multiple.rb.native b/fixtures/u2_func_return_multiple.rb.native index 671b2f0..b08fbd3 100644 --- a/fixtures/u2_func_return_multiple.rb.native +++ b/fixtures/u2_func_return_multiple.rb.native @@ -3,39 +3,62 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "end_col": 14, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 1 }, - "body": [ - { - "end_col": 10, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": { - "end_col": 12, - "end_line": 2, - "start_col": 11, - "start_line": 2, - "token": 1, - "type": "int" + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "return", + "target": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 2 }, - "type": "return" + "@token": 1, + "@type": "int" } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + } + ] } } } diff --git a/fixtures/u2_func_return_multiple.rb.uast b/fixtures/u2_func_return_multiple.rb.uast index 0ccc1fa..c94ae29 100644 --- a/fixtures/u2_func_return_multiple.rb.uast +++ b/fixtures/u2_func_return_multiple.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . } . . . . 1: return { -. . . . . Roles: Unannotated +. . . . . Roles: Return,Statement . . . . . StartPosition: { . . . . . . Offset: 19 . . . . . . Line: 2 @@ -55,7 +55,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Left,Literal,Number,Primitive . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 26 diff --git a/fixtures/u2_func_simple.rb.native b/fixtures/u2_func_simple.rb.native index 59801d6..7af61cf 100644 --- a/fixtures/u2_func_simple.rb.native +++ b/fixtures/u2_func_simple.rb.native @@ -3,82 +3,135 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "children": [ + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@type": "args", + "children": [ + { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@token": "a", + "@type": "arg" + }, + { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@token": "b", + "@type": "arg" + } + ] + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "begin", + "body": [ { - "end_col": 14, - "end_line": 1, - "start_col": 13, - "start_line": 1, - "token": "a", - "type": "arg" + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } }, { - "end_col": 17, - "end_line": 1, - "start_col": 16, - "start_line": 1, - "token": "b", - "type": "arg" - } - ], - "end_col": 18, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" - }, - "body": [ - { - "body": [ - { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 3 }, - { - "end_col": 10, - "end_line": 3, - "start_col": 4, - "start_line": 3, - "target": { - "end_col": 12, - "end_line": 3, - "start_col": 11, - "start_line": 3, - "token": "a", - "type": "lvar" + "@type": "return", + "target": { + "@end": { + "@type": "ast:Position", + "col": 12, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 12, + "line": 3 }, - "type": "return" + "@token": "a", + "@type": "lvar" } - ], - "end_col": 12, - "end_line": 3, - "start_col": 4, - "start_line": 2, - "type": "begin" - } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + } + ] + } + ] } } } diff --git a/fixtures/u2_func_simple.rb.uast b/fixtures/u2_func_simple.rb.uast index 3e94e29..41d46d3 100644 --- a/fixtures/u2_func_simple.rb.uast +++ b/fixtures/u2_func_simple.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: arg { -. . . . . . . Roles: Expression,Argument,Name +. . . . . . . Roles: Argument,Expression,Identifier,Name . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 13 @@ -56,7 +56,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: arg { -. . . . . . . Roles: Expression,Argument,Name +. . . . . . . Roles: Argument,Expression,Identifier,Name . . . . . . . TOKEN "b" . . . . . . . StartPosition: { . . . . . . . . Offset: 16 @@ -91,7 +91,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 23 @@ -108,7 +108,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 27 @@ -127,7 +127,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: return { -. . . . . . . Roles: Unannotated +. . . . . . . Roles: Return,Statement . . . . . . . StartPosition: { . . . . . . . . Offset: 33 . . . . . . . . Line: 3 @@ -143,7 +143,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: lvar { -. . . . . . . . . Roles: Expression,Identifier +. . . . . . . . . Roles: Binary,Expression,Identifier,Left . . . . . . . . . TOKEN "a" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 40 diff --git a/fixtures/u2_func_specific_implicit_return.rb.native b/fixtures/u2_func_specific_implicit_return.rb.native index 1eba494..31a0092 100644 --- a/fixtures/u2_func_specific_implicit_return.rb.native +++ b/fixtures/u2_func_specific_implicit_return.rb.native @@ -3,32 +3,49 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "end_col": 14, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 1 }, - "body": [ - { - "end_col": 5, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "token": 1, - "type": "int" - } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 + }, + "@type": "args" + }, + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + ] } } } diff --git a/fixtures/u2_func_specific_implicit_return.rb.uast b/fixtures/u2_func_specific_implicit_return.rb.uast index 172958c..5be8057 100644 --- a/fixtures/u2_func_specific_implicit_return.rb.uast +++ b/fixtures/u2_func_specific_implicit_return.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 diff --git a/fixtures/u2_func_specific_kw_optional_param.rb.native b/fixtures/u2_func_specific_kw_optional_param.rb.native index a36257b..3fc7ed0 100644 --- a/fixtures/u2_func_specific_kw_optional_param.rb.native +++ b/fixtures/u2_func_specific_kw_optional_param.rb.native @@ -3,45 +3,68 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "children": [ - { - "default": { - "end_col": 17, - "end_line": 1, - "start_col": 16, - "start_line": 1, - "token": 1, - "type": "int" - }, - "end_col": 14, - "end_line": 1, - "start_col": 13, - "start_line": 1, - "token": "a", - "type": "kwoptarg" - } - ], - "end_col": 18, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 }, - "body": [ + "@type": "args", + "children": [ { - "type": "NilClass" + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@token": "a", + "@type": "kwoptarg", + "default": { + "@end": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 1 + }, + "@token": 1, + "@type": "int" + } } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + ] + }, + "body": [ + { + "@type": "NilNode" + } + ] } } } diff --git a/fixtures/u2_func_specific_kw_optional_param.rb.uast b/fixtures/u2_func_specific_kw_optional_param.rb.uast index 4bb5bf3..a9839f1 100644 --- a/fixtures/u2_func_specific_kw_optional_param.rb.uast +++ b/fixtures/u2_func_specific_kw_optional_param.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,17 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . 0: NilNode { +. . . . . Roles: Null +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . } +. . . . 1: args { +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 @@ -39,7 +45,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: kwoptarg { -. . . . . . . Roles: Expression,Argument,Name,Incomplete +. . . . . . . Roles: Argument,Expression,Incomplete,Name . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 13 @@ -76,12 +82,6 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: NilClass { -. . . . . Roles: Statement,Type,Null -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/u2_func_specific_params_required.rb.native b/fixtures/u2_func_specific_params_required.rb.native index dba8f25..901ce20 100644 --- a/fixtures/u2_func_specific_params_required.rb.native +++ b/fixtures/u2_func_specific_params_required.rb.native @@ -3,45 +3,68 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "args": { - "children": [ - { - "end_col": 14, - "end_line": 1, - "start_col": 13, - "start_line": 1, - "token": "a", - "type": "kwarg" - }, - { - "end_col": 18, - "end_line": 1, - "start_col": 17, - "start_line": 1, - "token": "b", - "type": "kwarg" - } - ], - "end_col": 20, - "end_line": 1, - "start_col": 12, - "start_line": 1, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 20, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 13, + "line": 1 }, - "body": [ + "@type": "args", + "children": [ { - "type": "NilClass" + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 14, + "line": 1 + }, + "@token": "a", + "@type": "kwarg" + }, + { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 1 + }, + "@token": "b", + "@type": "kwarg" } - ], - "end_col": 3, - "end_line": 1, - "name": "testfnc1", - "start_col": 0, - "start_line": 1, - "type": "def" - } + ] + }, + "body": [ + { + "@type": "NilNode" + } + ] } } } diff --git a/fixtures/u2_func_specific_params_required.rb.uast b/fixtures/u2_func_specific_params_required.rb.uast index 45f8a99..4f2af42 100644 --- a/fixtures/u2_func_specific_params_required.rb.uast +++ b/fixtures/u2_func_specific_params_required.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: def { -. . . Roles: Statement,Function,Declaration,Identifier +. . . Roles: Declaration,Function,Identifier,Statement . . . TOKEN "testfnc1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,17 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: args { -. . . . . Roles: Expression,Argument,Incomplete +. . . . 0: NilNode { +. . . . . Roles: Null +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . } +. . . . 1: args { +. . . . . Roles: Argument,Expression,Incomplete . . . . . StartPosition: { . . . . . . Offset: 12 . . . . . . Line: 1 @@ -39,7 +45,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: kwarg { -. . . . . . . Roles: Expression,Argument,Name,Map +. . . . . . . Roles: Argument,Expression,Map,Name . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 13 @@ -56,7 +62,7 @@ UAST: . . . . . . . } . . . . . . } . . . . . . 1: kwarg { -. . . . . . . Roles: Expression,Argument,Name,Map +. . . . . . . Roles: Argument,Expression,Map,Name . . . . . . . TOKEN "b" . . . . . . . StartPosition: { . . . . . . . . Offset: 17 @@ -74,12 +80,6 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: NilClass { -. . . . . Roles: Statement,Type,Null -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/u2_import_path.rb.native b/fixtures/u2_import_path.rb.native index 0f7e929..8421dab 100644 --- a/fixtures/u2_import_path.rb.native +++ b/fixtures/u2_import_path.rb.native @@ -3,54 +3,83 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": [ - { - "base": null, - "end_col": 25, - "end_line": 1, - "selector": "require", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 25, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": "./u2_class_this", - "type": "str" - } - ] + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 32, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "begin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 25, + "line": 1 }, - { - "base": null, - "end_col": 32, - "end_line": 2, - "selector": "require_relative", - "start_col": 0, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 32, - "end_line": 2, - "start_col": 17, - "start_line": 2, - "token": "u2_class_this", - "type": "str" - } - ] - } - ], - "end_col": 32, - "end_line": 2, - "start_col": 0, - "start_line": 1, - "type": "begin" - } + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_statement", + "base": null, + "selector": "require", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 25, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@token": "./u2_class_this", + "@type": "str" + } + ] + }, + { + "@end": { + "@type": "ast:Position", + "col": 32, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "require_relative", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 32, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 18, + "line": 2 + }, + "@token": "u2_class_this", + "@type": "str" + } + ] + } + ] } } } diff --git a/fixtures/u2_import_path.rb.uast b/fixtures/u2_import_path.rb.uast index 3af6f27..4284e92 100644 --- a/fixtures/u2_import_path.rb.uast +++ b/fixtures/u2_import_path.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: begin { . . . Roles: Block @@ -18,11 +18,11 @@ UAST: . . . . Col: 32 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Expression,Call,Identifier +. . . . 0: send_statement { +. . . . . Roles: Expression,Import . . . . . TOKEN "require" . . . . . StartPosition: { . . . . . . Offset: 0 @@ -39,7 +39,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: str { -. . . . . . . Roles: Expression,Literal,String,Primitive,Argument,Identifier +. . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . TOKEN "./u2_class_this" . . . . . . . StartPosition: { . . . . . . . . Offset: 8 @@ -57,9 +57,8 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: send { -. . . . . Roles: Expression,Call,Identifier -. . . . . TOKEN "require_relative" +. . . . 1: send_qualified { +. . . . . Roles: Expression,Identical,Qualified . . . . . StartPosition: { . . . . . . Offset: 26 . . . . . . Line: 2 @@ -72,10 +71,11 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: body +. . . . . . selector: require_relative . . . . . } . . . . . Children: { . . . . . . 0: str { -. . . . . . . Roles: Expression,Literal,String,Primitive,Argument,Identifier +. . . . . . . Roles: Expression,Literal,Primitive,String . . . . . . . TOKEN "u2_class_this" . . . . . . . StartPosition: { . . . . . . . . Offset: 43 diff --git a/fixtures/u2_import_simple.rb.native b/fixtures/u2_import_simple.rb.native index 72761cb..8ef1195 100644 --- a/fixtures/u2_import_simple.rb.native +++ b/fixtures/u2_import_simple.rb.native @@ -3,26 +3,37 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "base": null, - "end_col": 15, - "end_line": 1, - "selector": "require", - "start_col": 0, - "start_line": 1, - "type": "send", - "values": [ - { - "end_col": 15, - "end_line": 1, - "start_col": 8, - "start_line": 1, - "token": "while", - "type": "str" - } - ] - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "send_statement", + "base": null, + "selector": "require", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 15, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 1 + }, + "@token": "while", + "@type": "str" + } + ] } } } diff --git a/fixtures/u2_import_simple.rb.uast b/fixtures/u2_import_simple.rb.uast index 9edbf7d..f2519c8 100644 --- a/fixtures/u2_import_simple.rb.uast +++ b/fixtures/u2_import_simple.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { -. . 0: send { -. . . Roles: Expression,Call,Identifier +. . 0: send_statement { +. . . Roles: Expression,Import . . . TOKEN "require" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 15 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: str { -. . . . . Roles: Expression,Literal,String,Primitive,Argument,Identifier +. . . . . Roles: Expression,Literal,Primitive,String . . . . . TOKEN "while" . . . . . StartPosition: { . . . . . . Offset: 8 diff --git a/fixtures/u2_type_module_empty.rb.native b/fixtures/u2_type_module_empty.rb.native index cab6320..4483f07 100644 --- a/fixtures/u2_type_module_empty.rb.native +++ b/fixtures/u2_type_module_empty.rb.native @@ -3,20 +3,25 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "begin": [ - { - "type": "NilClass" - } - ], - "end_col": 6, - "end_line": 1, - "name": "Testmodule1", - "start_col": 0, - "start_line": 1, - "type": "module" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testmodule1", + "@type": "module", + "begin": [ + { + "@type": "NilNode" + } + ] } } } diff --git a/fixtures/u2_type_module_empty.rb.uast b/fixtures/u2_type_module_empty.rb.uast index f3d14a7..6dd2fff 100644 --- a/fixtures/u2_type_module_empty.rb.uast +++ b/fixtures/u2_type_module_empty.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: module { -. . . Roles: Statement,Module,Identifier +. . . Roles: Identifier,Module,Statement . . . TOKEN "Testmodule1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: NilClass { -. . . . . Roles: Statement,Type,Null +. . . . 0: NilNode { +. . . . . Roles: Null . . . . . Properties: { . . . . . . internalRole: begin . . . . . } diff --git a/fixtures/u2_type_module_field.rb.native b/fixtures/u2_type_module_field.rb.native index 015d65a..9decbd1 100644 --- a/fixtures/u2_type_module_field.rb.native +++ b/fixtures/u2_type_module_field.rb.native @@ -3,36 +3,53 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "begin": [ - { - "base": null, - "end_col": 11, - "end_line": 2, - "selector": "attr", - "start_col": 4, - "start_line": 2, - "type": "send", - "values": [ - { - "end_col": 11, - "end_line": 2, - "start_col": 9, - "start_line": 2, - "token": "a", - "type": "sym" - } - ] - } - ], - "end_col": 6, - "end_line": 1, - "name": "Testmodule1", - "start_col": 0, - "start_line": 1, - "type": "module" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testmodule1", + "@type": "module", + "begin": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "send_qualified", + "base": null, + "selector": "attr", + "values": [ + { + "@end": { + "@type": "ast:Position", + "col": 11, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 10, + "line": 2 + }, + "@token": "a", + "@type": "sym" + } + ] + } + ] } } } diff --git a/fixtures/u2_type_module_field.rb.uast b/fixtures/u2_type_module_field.rb.uast index 496faf3..36888e2 100644 --- a/fixtures/u2_type_module_field.rb.uast +++ b/fixtures/u2_type_module_field.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: module { -. . . Roles: Statement,Module,Identifier +. . . Roles: Identifier,Module,Statement . . . TOKEN "Testmodule1" . . . StartPosition: { . . . . Offset: 0 @@ -19,12 +19,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: send { -. . . . . Roles: Unannotated -. . . . . TOKEN "attr" +. . . . 0: send_qualified { +. . . . . Roles: Expression,Identical,Qualified . . . . . StartPosition: { . . . . . . Offset: 23 . . . . . . Line: 2 @@ -37,6 +36,7 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: begin +. . . . . . selector: attr . . . . . } . . . . . Children: { . . . . . . 0: sym { diff --git a/fixtures/u2_type_module_method.rb.native b/fixtures/u2_type_module_method.rb.native index ba5ba01..66ba7ff 100644 --- a/fixtures/u2_type_module_method.rb.native +++ b/fixtures/u2_type_module_method.rb.native @@ -3,37 +3,54 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "begin": [ - { - "args": { - "end_col": 18, - "end_line": 2, - "start_col": 16, - "start_line": 2, - "type": "args" + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "Testmodule1", + "@type": "module", + "begin": [ + { + "@end": { + "@type": "ast:Position", + "col": 7, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@token": "testfnc1", + "@type": "def", + "args": { + "@end": { + "@type": "ast:Position", + "col": 18, + "line": 2 }, - "body": [ - { - "type": "NilClass" - } - ], - "end_col": 7, - "end_line": 2, - "name": "testfnc1", - "start_col": 4, - "start_line": 2, - "type": "def" - } - ], - "end_col": 6, - "end_line": 1, - "name": "Testmodule1", - "start_col": 0, - "start_line": 1, - "type": "module" - } + "@start": { + "@type": "ast:Position", + "col": 17, + "line": 2 + }, + "@type": "args" + }, + "body": [ + { + "@type": "NilNode" + } + ] + } + ] } } } diff --git a/fixtures/u2_type_module_method.rb.uast b/fixtures/u2_type_module_method.rb.uast index ddbdae4..dfee60e 100644 --- a/fixtures/u2_type_module_method.rb.uast +++ b/fixtures/u2_type_module_method.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: module { -. . . Roles: Statement,Module,Identifier +. . . Roles: Identifier,Module,Statement . . . TOKEN "Testmodule1" . . . StartPosition: { . . . . Offset: 0 @@ -19,11 +19,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: def { -. . . . . Roles: Statement,Function,Declaration,Identifier +. . . . . Roles: Declaration,Function,Identifier,Statement . . . . . TOKEN "testfnc1" . . . . . StartPosition: { . . . . . . Offset: 23 @@ -39,8 +39,14 @@ UAST: . . . . . . internalRole: begin . . . . . } . . . . . Children: { -. . . . . . 0: args { -. . . . . . . Roles: Expression,Argument,Incomplete +. . . . . . 0: NilNode { +. . . . . . . Roles: Null +. . . . . . . Properties: { +. . . . . . . . internalRole: body +. . . . . . . } +. . . . . . } +. . . . . . 1: args { +. . . . . . . Roles: Argument,Expression,Incomplete . . . . . . . StartPosition: { . . . . . . . . Offset: 35 . . . . . . . . Line: 2 @@ -55,12 +61,6 @@ UAST: . . . . . . . . internalRole: args . . . . . . . } . . . . . . } -. . . . . . 1: NilClass { -. . . . . . . Roles: Statement,Type,Null -. . . . . . . Properties: { -. . . . . . . . internalRole: body -. . . . . . . } -. . . . . . } . . . . . } . . . . } . . . } diff --git a/fixtures/unless.rb.native b/fixtures/unless.rb.native index 27ee3f6..df18bc5 100644 --- a/fixtures/unless.rb.native +++ b/fixtures/unless.rb.native @@ -3,54 +3,89 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "end_col": 9, - "end_line": 4, - "start_col": 4, - "start_line": 4, - "target": "b", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 4, - "start_col": 8, - "start_line": 4, - "token": 2, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 6, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "if", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 }, - "condition": { - "base": null, - "end_col": 10, - "end_line": 1, - "selector": "foo", - "start_col": 7, - "start_line": 1, - "type": "send" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 4 }, - "else": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "lvasgn", + "target": "b", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 4 + }, + "@token": 2, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 }, - "end_col": 6, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "if" + "@start": { + "@type": "ast:Position", + "col": 8, + "line": 1 + }, + "@type": "send_qualified", + "base": null, + "selector": "foo" + }, + "else": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } } } } diff --git a/fixtures/unless.rb.uast b/fixtures/unless.rb.uast index dd70d71..efd87f0 100644 --- a/fixtures/unless.rb.uast +++ b/fixtures/unless.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: if { -. . . Roles: Statement,If +. . . Roles: If,Statement . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,48 +18,11 @@ UAST: . . . . Col: 6 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Then -. . . . . TOKEN "b" -. . . . . StartPosition: { -. . . . . . Offset: 30 -. . . . . . Line: 4 -. . . . . . Col: 5 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 34 -. . . . . . Line: 4 -. . . . . . Col: 9 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: body -. . . . . } -. . . . . Children: { -. . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive -. . . . . . . TOKEN "2" -. . . . . . . StartPosition: { -. . . . . . . . Offset: 34 -. . . . . . . . Line: 4 -. . . . . . . . Col: 9 -. . . . . . . } -. . . . . . . EndPosition: { -. . . . . . . . Offset: 34 -. . . . . . . . Line: 4 -. . . . . . . . Col: 9 -. . . . . . . } -. . . . . . . Properties: { -. . . . . . . . internalRole: value -. . . . . . . } -. . . . . . } -. . . . . } -. . . . } -. . . . 1: send { -. . . . . Roles: Expression,Condition,If -. . . . . TOKEN "foo" +. . . . 0: send_qualified { +. . . . . Roles: Condition,Expression,Identical,Qualified . . . . . StartPosition: { . . . . . . Offset: 7 . . . . . . Line: 1 @@ -72,10 +35,11 @@ UAST: . . . . . } . . . . . Properties: { . . . . . . internalRole: condition +. . . . . . selector: foo . . . . . } . . . . } -. . . . 2: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,If,Else +. . . . 1: lvasgn { +. . . . . Roles: Assignment,Binary,Else,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 15 @@ -92,7 +56,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -110,6 +74,42 @@ UAST: . . . . . . } . . . . . } . . . . } +. . . . 2: lvasgn { +. . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left,Then +. . . . . TOKEN "b" +. . . . . StartPosition: { +. . . . . . Offset: 30 +. . . . . . Line: 4 +. . . . . . Col: 5 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 34 +. . . . . . Line: 4 +. . . . . . Col: 9 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: body +. . . . . } +. . . . . Children: { +. . . . . . 0: int { +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right +. . . . . . . TOKEN "2" +. . . . . . . StartPosition: { +. . . . . . . . Offset: 34 +. . . . . . . . Line: 4 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . EndPosition: { +. . . . . . . . Offset: 34 +. . . . . . . . Line: 4 +. . . . . . . . Col: 9 +. . . . . . . } +. . . . . . . Properties: { +. . . . . . . . internalRole: value +. . . . . . . } +. . . . . . } +. . . . . } +. . . . } . . . } . . } . } diff --git a/fixtures/until.rb.native b/fixtures/until.rb.native index e465c9b..7bc3332 100644 --- a/fixtures/until.rb.native +++ b/fixtures/until.rb.native @@ -3,36 +3,59 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "until", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "condition": { - "end_col": 10, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "type": "true" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "end_col": 3, - "end_line": 3, - "start_col": 0, - "start_line": 1, - "type": "until" + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "true" } } } diff --git a/fixtures/until.rb.uast b/fixtures/until.rb.uast index c620cab..c3eaca3 100644 --- a/fixtures/until.rb.uast +++ b/fixtures/until.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: until { -. . . Roles: Statement,Incomplete,While +. . . Roles: Statement,While . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,11 +18,28 @@ UAST: . . . . Col: 3 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,While,Body +. . . . 0: true { +. . . . . Roles: Boolean,Condition,Expression,Literal +. . . . . TOKEN "true" +. . . . . StartPosition: { +. . . . . . Offset: 6 +. . . . . . Line: 1 +. . . . . . Col: 7 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 9 +. . . . . . Line: 1 +. . . . . . Col: 10 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: condition +. . . . . } +. . . . } +. . . . 1: lvasgn { +. . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 15 @@ -39,7 +56,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -57,23 +74,6 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: true { -. . . . . Roles: Expression,Condition,While,Boolean,Literal -. . . . . TOKEN "true" -. . . . . StartPosition: { -. . . . . . Offset: 6 -. . . . . . Line: 1 -. . . . . . Col: 7 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 9 -. . . . . . Line: 1 -. . . . . . Col: 10 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: condition -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/until_end.rb.native b/fixtures/until_end.rb.native index 6667ffc..ea59aff 100644 --- a/fixtures/until_end.rb.native +++ b/fixtures/until_end.rb.native @@ -3,45 +3,74 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "body": [ - { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "until_post", + "body": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "kwbegin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" } - ], - "end_col": 3, - "end_line": 3, - "start_col": 0, - "start_line": 1, - "type": "kwbegin" + } + ] + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 3 }, - "condition": { - "end_col": 14, - "end_line": 3, - "start_col": 10, - "start_line": 3, - "type": "true" + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 3 }, - "end_col": 14, - "end_line": 3, - "start_col": 0, - "start_line": 1, - "type": "until_post" + "@type": "true" } } } diff --git a/fixtures/until_end.rb.uast b/fixtures/until_end.rb.uast index f109a7a..0b2c036 100644 --- a/fixtures/until_end.rb.uast +++ b/fixtures/until_end.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: until_post { -. . . Roles: Statement,Incomplete,While +. . . Roles: Statement,While . . . StartPosition: { . . . . Offset: 0 . . . . Line: 1 @@ -18,11 +18,11 @@ UAST: . . . . Col: 14 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: kwbegin { -. . . . . Roles: Expression,While,Body,Block +. . . . . Roles: Block,Body,Expression . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -38,7 +38,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 14 @@ -76,7 +76,7 @@ UAST: . . . . . } . . . . } . . . . 1: true { -. . . . . Roles: Expression,Condition,While,Boolean,Literal +. . . . . Roles: Boolean,Condition,Expression,Literal . . . . . TOKEN "true" . . . . . StartPosition: { . . . . . . Offset: 26 diff --git a/fixtures/var_class.rb.native b/fixtures/var_class.rb.native index 025aa56..e88e9c8 100644 --- a/fixtures/var_class.rb.native +++ b/fixtures/var_class.rb.native @@ -3,15 +3,20 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": "@@foo", - "type": "cvar" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "@@foo", + "@type": "cvar" } } } diff --git a/fixtures/var_class.rb.uast b/fixtures/var_class.rb.uast index 7aa9e97..463abe6 100644 --- a/fixtures/var_class.rb.uast +++ b/fixtures/var_class.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: cvar { -. . . Roles: Expression,Identifier,Visibility,Type +. . . Roles: Expression,Identifier,Type,Visibility . . . TOKEN "@@foo" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . } . } diff --git a/fixtures/var_global.rb.native b/fixtures/var_global.rb.native index bff18fc..e66a26b 100644 --- a/fixtures/var_global.rb.native +++ b/fixtures/var_global.rb.native @@ -3,15 +3,20 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 4, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": "$foo", - "type": "gvar" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "$foo", + "@type": "gvar" } } } diff --git a/fixtures/var_global.rb.uast b/fixtures/var_global.rb.uast index 039da95..4a7b986 100644 --- a/fixtures/var_global.rb.uast +++ b/fixtures/var_global.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: gvar { . . . Roles: Expression,Identifier,Visibility,World @@ -19,7 +19,7 @@ UAST: . . . . Col: 4 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . } . } diff --git a/fixtures/var_instance.rb.native b/fixtures/var_instance.rb.native index fc973e7..ded54e2 100644 --- a/fixtures/var_instance.rb.native +++ b/fixtures/var_instance.rb.native @@ -3,15 +3,20 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "end_col": 4, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "token": "@foo", - "type": "ivar" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 4, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@token": "@foo", + "@type": "ivar" } } } diff --git a/fixtures/var_instance.rb.uast b/fixtures/var_instance.rb.uast index 2df3f6e..3b9fc75 100644 --- a/fixtures/var_instance.rb.uast +++ b/fixtures/var_instance.rb.uast @@ -2,11 +2,11 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: ivar { -. . . Roles: Expression,Identifier,Visibility,Instance +. . . Roles: Expression,Identifier,Instance,Visibility . . . TOKEN "@foo" . . . StartPosition: { . . . . Offset: 0 @@ -19,7 +19,7 @@ UAST: . . . . Col: 4 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . } . } diff --git a/fixtures/while.rb.native b/fixtures/while.rb.native index 4cb6b2f..ada6ab2 100644 --- a/fixtures/while.rb.native +++ b/fixtures/while.rb.native @@ -3,36 +3,59 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 5, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "while", + "body": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 }, - "condition": { - "end_col": 10, - "end_line": 1, - "start_col": 6, - "start_line": 1, - "type": "true" + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 }, - "end_col": 5, - "end_line": 1, - "start_col": 0, - "start_line": 1, - "type": "while" + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" + } + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 10, + "line": 1 + }, + "@start": { + "@type": "ast:Position", + "col": 7, + "line": 1 + }, + "@type": "true" } } } diff --git a/fixtures/while.rb.uast b/fixtures/while.rb.uast index a28a9f1..2ad2e7c 100644 --- a/fixtures/while.rb.uast +++ b/fixtures/while.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: while { . . . Roles: Statement,While @@ -18,11 +18,28 @@ UAST: . . . . Col: 5 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { -. . . . 0: lvasgn { -. . . . . Roles: Expression,Assignment,Binary,Identifier,Left,While,Body +. . . . 0: true { +. . . . . Roles: Boolean,Condition,Expression,Literal +. . . . . TOKEN "true" +. . . . . StartPosition: { +. . . . . . Offset: 6 +. . . . . . Line: 1 +. . . . . . Col: 7 +. . . . . } +. . . . . EndPosition: { +. . . . . . Offset: 9 +. . . . . . Line: 1 +. . . . . . Col: 10 +. . . . . } +. . . . . Properties: { +. . . . . . internalRole: condition +. . . . . } +. . . . } +. . . . 1: lvasgn { +. . . . . Roles: Assignment,Binary,Body,Expression,Identifier,Left . . . . . TOKEN "a" . . . . . StartPosition: { . . . . . . Offset: 15 @@ -39,7 +56,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: int { -. . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . TOKEN "1" . . . . . . . StartPosition: { . . . . . . . . Offset: 19 @@ -57,23 +74,6 @@ UAST: . . . . . . } . . . . . } . . . . } -. . . . 1: true { -. . . . . Roles: Expression,Condition,While,Boolean,Literal -. . . . . TOKEN "true" -. . . . . StartPosition: { -. . . . . . Offset: 6 -. . . . . . Line: 1 -. . . . . . Col: 7 -. . . . . } -. . . . . EndPosition: { -. . . . . . Offset: 9 -. . . . . . Line: 1 -. . . . . . Col: 10 -. . . . . } -. . . . . Properties: { -. . . . . . internalRole: condition -. . . . . } -. . . . } . . . } . . } . } diff --git a/fixtures/while_end.rb.native b/fixtures/while_end.rb.native index 0477773..32e5fea 100644 --- a/fixtures/while_end.rb.native +++ b/fixtures/while_end.rb.native @@ -3,45 +3,74 @@ "language": "ruby", "errors": [], "ast": { - "RUBYAST": { - "module": { - "body": { - "body": [ - { - "end_col": 9, - "end_line": 2, - "start_col": 4, - "start_line": 2, - "target": "a", - "type": "lvasgn", - "value": { - "end_col": 9, - "end_line": 2, - "start_col": 8, - "start_line": 2, - "token": 1, - "type": "int" - } + "@type": "module", + "file": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "while_post", + "body": { + "@end": { + "@type": "ast:Position", + "col": 3, + "line": 3 + }, + "@start": { + "@type": "ast:Position", + "col": 1, + "line": 1 + }, + "@type": "kwbegin", + "body": [ + { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 5, + "line": 2 + }, + "@type": "lvasgn", + "target": "a", + "value": { + "@end": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@start": { + "@type": "ast:Position", + "col": 9, + "line": 2 + }, + "@token": 1, + "@type": "int" } - ], - "end_col": 3, - "end_line": 3, - "start_col": 0, - "start_line": 1, - "type": "kwbegin" + } + ] + }, + "condition": { + "@end": { + "@type": "ast:Position", + "col": 14, + "line": 3 }, - "condition": { - "end_col": 14, - "end_line": 3, - "start_col": 10, - "start_line": 3, - "type": "true" + "@start": { + "@type": "ast:Position", + "col": 11, + "line": 3 }, - "end_col": 14, - "end_line": 3, - "start_col": 0, - "start_line": 1, - "type": "while_post" + "@type": "true" } } } diff --git a/fixtures/while_end.rb.uast b/fixtures/while_end.rb.uast index 1f83a64..fc0c157 100644 --- a/fixtures/while_end.rb.uast +++ b/fixtures/while_end.rb.uast @@ -2,8 +2,8 @@ Status: ok Language: ruby Errors: UAST: - { -. Roles: Module,File +module { +. Roles: Identifier,Module,Statement . Children: { . . 0: while_post { . . . Roles: Statement,While @@ -18,11 +18,11 @@ UAST: . . . . Col: 14 . . . } . . . Properties: { -. . . . internalRole: module +. . . . internalRole: file . . . } . . . Children: { . . . . 0: kwbegin { -. . . . . Roles: Expression,While,Body,Block +. . . . . Roles: Block,Body,Expression . . . . . StartPosition: { . . . . . . Offset: 0 . . . . . . Line: 1 @@ -38,7 +38,7 @@ UAST: . . . . . } . . . . . Children: { . . . . . . 0: lvasgn { -. . . . . . . Roles: Expression,Assignment,Binary,Identifier,Left +. . . . . . . Roles: Assignment,Binary,Expression,Identifier,Left . . . . . . . TOKEN "a" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 @@ -55,7 +55,7 @@ UAST: . . . . . . . } . . . . . . . Children: { . . . . . . . . 0: int { -. . . . . . . . . Roles: Right,Expression,Literal,Number,Primitive +. . . . . . . . . Roles: Binary,Expression,Literal,Number,Primitive,Right . . . . . . . . . TOKEN "1" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 14 @@ -76,7 +76,7 @@ UAST: . . . . . } . . . . } . . . . 1: true { -. . . . . Roles: Expression,Condition,While,Boolean,Literal +. . . . . Roles: Boolean,Condition,Expression,Literal . . . . . TOKEN "true" . . . . . StartPosition: { . . . . . . Offset: 26 diff --git a/native/lib/ruby_driver.rb b/native/lib/ruby_driver.rb index 276e4f7..38ec7f5 100644 --- a/native/lib/ruby_driver.rb +++ b/native/lib/ruby_driver.rb @@ -1,5 +1,5 @@ -require 'ruby_driver/message' -require 'ruby_driver/node_converter' +require_relative './ruby_driver/message' +require_relative './ruby_driver/node_converter' require 'json' diff --git a/native/lib/ruby_driver/node_converter.rb b/native/lib/ruby_driver/node_converter.rb index f421ab6..f421211 100644 --- a/native/lib/ruby_driver/node_converter.rb +++ b/native/lib/ruby_driver/node_converter.rb @@ -5,6 +5,12 @@ module NodeConverter class Converter + @@typekey = "@type" + @@statement_send = ["continue", "lambda", "require", "each", "public", "protected", + "private"] + @@operators = ["+", "-", "*", "/", "%", "**", "&", "|", "^", "~", "<<", ">>", + "==", "===", "<=", ">=", "!=", "!", "eql?", "equal?", "<==>"] + def initialize(node, comments) @empty_with_comments = false if node.is_a?(NilClass) and comments != nil @@ -19,11 +25,10 @@ def initialize(node, comments) @root = node @comments = comments @dict = {} - end def tohash() - @dict["ast"] = {"RUBYAST": {"module": convert(@root)}} + @dict["ast"] = {"file" => convert(@root), @@typekey => "module"} add_comments() return @dict["ast"] end @@ -36,10 +41,10 @@ def convert(node) case type when "int", "float", "str" - return sexp_to_hash(node, {"l_token" => 0}) + return sexp_to_hash(node, {"l_@token" => 0}) when "lvar", "ivar", "cvar", "gvar", "arg", "kwarg", "restarg", "blockarg" - return sexp_to_hash(node, {"token.token" => 0}, 1, "children") + return sexp_to_hash(node, {"@token.@token" => 0}, 1, "children") when "pair", "irange", "erange", "alias", "iflipflop", "eflipflop" return sexp_to_hash(node, {"_1" => 0, "_2" => 1}) @@ -54,26 +59,23 @@ def convert(node) return sexp_to_hash(node, {}, 0, "contents") when "optarg", "kwoptarg" - return sexp_to_hash(node, {"token" => 0, "default" => 1}) + return sexp_to_hash(node, {"@token" => 0, "default" => 1}) when "splat", "kwsplat", "defined?", "kwrestarg" - return sexp_to_hash(node, {"name" => 0}) + return sexp_to_hash(node, {"@token" => 0}) when "casgn" return sexp_to_hash(node, {"base" => 0, "selector" => 1, "value" => 2}) when "csend", "send" - return sexp_to_hash(node, {"base" => 0, "selector" => 1}, 2, "values") + return process_send(node) when "complex", "rational", "sym" - return sexp_to_hash(node, {"token.token" => 0}) + return sexp_to_hash(node, {"@token.@token" => 0}) # the inner nodes of the above when "Complex", "Rational", "Symbol" - return {"type" => node_type(node), "token" => node.to_s} - - #when "mlhs" - #return node.children.map{ |x| convert(x) }.compact + return {@@typekey => node_type(node), "@token" => node.to_s} when "masgn" return sexp_to_hash(node, {"targets" => 0, "values" => 1}) @@ -83,19 +85,19 @@ def convert(node) when "module" d = sexp_to_hash(node, {}, 1, "begin") - d["name"] = node.children[0].children[1].to_s + d["@token"] = node.children[0].children[1].to_s return d when "class" d = sexp_to_hash(node, {"parent" => 1}, 2, "body") - d["name"] = node.children[0].children[1].to_s + d["@token"] = node.children[0].children[1].to_s return d when "sclass" return sexp_to_hash(node, {"object" => 0}, 1, "body") when "def" - return sexp_to_hash(node, {"s_name" => 0, "args" => 1}, 2, "body") + return sexp_to_hash(node, {"s_@token" => 0, "args" => 1}, 2, "body") when "undef", "yield", "break", "next", "return" return sexp_to_hash(node, {"target" => 0}) @@ -112,13 +114,13 @@ def convert(node) return d when "when" - d = {"type": "when"} + d = {@@typekey => "when"} d["conditions"] = node.children[0..-2].map{ |x| convert(x) }.compact d["body"] = convert(node.children[-1]) return d when "const" - return sexp_to_hash(node, {"base" => 0, "token" => 1}) + return sexp_to_hash(node, {"base" => 0, "@token" => 1}) when "while", "until", "while_post", "until_post" return sexp_to_hash(node, {"condition" => 0, "body" => 1}) @@ -147,7 +149,7 @@ def convert(node) return sexp_to_hash(node, {"condition" => 0, "body" => 1, "else" => 2}) when "defs" # "singleton method" - return sexp_to_hash(node, {"base" => 0, "name" => 1, "args.children" => 2, "class" => 3}) + return sexp_to_hash(node, {"base" => 0, "@token" => 1, "args.children" => 2, "class" => 3}) when "regexp" return sexp_to_hash(node, {"text" => 0, "options" => 1}) @@ -157,9 +159,9 @@ def convert(node) when "NilClass" if @empty_with_comments - return {"type" => "module", "name" => "empty_module"} + return {@@typekey=> "module", "@token" => "empty_module"} else - return {"type" => "NilNode"} + return {@@typekey=> "NilNode"} end else @@ -191,11 +193,11 @@ def node_type(node) # after cdr_index will be converted and assigned as a list of dictnodes to the cdr_key # property in the node. def sexp_to_hash(node, table, cdr_index=nil, cdr_key=nil) - d = {"type" => node_type(node)} + d = {@@typekey => node_type(node)} table.each do |propname, idx| if propname.start_with? "s_" - d[propname[2..-1]] = node.children[idx].to_s + d[propname[ 2..-1]] = node.children[idx].to_s elsif propname.start_with? "l_" d[propname[2..-1]] = node.children[idx] @@ -221,18 +223,56 @@ def sexp_to_hash(node, table, cdr_index=nil, cdr_key=nil) return add_position(node, d) end + def process_send(node) + hash_send = sexp_to_hash(node, {"base" => 0, "selector" => 1}, 2, "values") + selector = hash_send["selector"].to_s + + if @@statement_send.include? selector + hash_send[@@typekey] = "send_statement" + return hash_send + end + + if @@operators.include? selector + hash_send[@@typekey] = "send_operator" + return hash_send + end + + if selector[-1] == "=" and not hash_send["values"].nil? + hash_send[@@typekey] = "send_assign" + hash_send["@token"] = selector[0..-2] + return hash_send + end + + if hash_send["base"].nil? + hash_send[@@typekey] = "send_qualified" + elsif selector == "[]" + hash_send[@@typekey] = "send_array" + else + hash_send[@@typekey] = "send_call" + end + + return hash_send + end + def add_from_subelem(node, hash, key) subelem = node.loc.send(key) if subelem != nil - hash["start_line"] = subelem.begin.line - hash["end_line"] = subelem.end.line - hash["start_col"] = subelem.begin.column - hash["end_col"] = subelem.end.column + hash["@start"] = { + @@typekey => "ast:Position", + "line" => subelem.begin.line, + "col" => subelem.begin.column + 1 + } + hash["@end"] = { + @@typekey => "ast:Position", + "line" => subelem.end.line, + # str inside str have cols set at 0 from the native AST + "col" => subelem.end.column > 0 ? subelem.end.column : 1 + } end end def add_position(node, hash) - case hash["type"] + case hash[@@typekey] when "defined?", "module", "class", "sclass", "def", "defs", "undef", "alias", "super", "zsuper", "yield", "if", "when", @@ -251,7 +291,7 @@ def add_position(node, hash) subelem = "expression" end - if hash["type"] == "if" and not node.loc.respond_to?("keyword") + if hash[@@typekey] == "if" and not node.loc.respond_to?("keyword") subelem = "question" end @@ -272,20 +312,26 @@ def add_comments() @comments.each do |comment| commentdict = { - "type" => "comment", - "text" => comment.text, + @@typekey => "comment", + "@token" => comment.text[1..-1], "inline" => comment.inline?, "documentation" => comment.document?, - "start_line" => comment.loc.first_line, - "end_line" => comment.loc.last_line, - "start_col" => comment.loc.column, - "end_col" => comment.loc.last_column + "@start" => { + @@typekey => "ast:Position", + "line" => comment.loc.first_line, + "col" => comment.loc.column + 1 + }, + "@end" => { + @@typekey => "ast:Position", + "line" => comment.loc.last_line, + "col" => comment.loc.last_column + }, } comments.push(commentdict) end if comments.length > 0 - @dict["ast"][:RUBYAST][:module][:comments] = comments + @dict["ast"]["file"][:comments] = comments end end diff --git a/native/ruby-driver.gemspec b/native/ruby-driver.gemspec index ef206ef..6608368 100644 --- a/native/ruby-driver.gemspec +++ b/native/ruby-driver.gemspec @@ -28,4 +28,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", ">= 1.14" spec.add_development_dependency "rake", ">= 10.0" spec.add_development_dependency "minitest", ">= 5.0" + spec.add_development_dependency "json", ">= 1.8.3" end