From 9e832634abc3261fc0b6a1366a893dcb1517432f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 23 Feb 2019 04:13:33 +0000 Subject: [PATCH 1/2] Bump gopkg.in/bblfsh/sdk.v2 from 2.14.1 to 2.14.2 Bumps [gopkg.in/bblfsh/sdk.v2](https://github.com/bblfsh/sdk) from 2.14.1 to 2.14.2. - [Release notes](https://github.com/bblfsh/sdk/releases) - [Commits](https://github.com/bblfsh/sdk/compare/v2.14.1...v2.14.2) Signed-off-by: dependabot[bot] --- Gopkg.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 746a36b..55687dc 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -373,7 +373,7 @@ version = "v1.16.0" [[projects]] - digest = "1:365bd710f205af5d464fdf87df8979c37f168ee8785573f430814f8f42017fdf" + digest = "1:66b86144b638269dbbe254b0e72069ee3aff0ecd77454b012d5f7d43164f3a84" name = "gopkg.in/bblfsh/sdk.v2" packages = [ "driver", @@ -390,8 +390,8 @@ "uast/transformer", ] pruneopts = "NUT" - revision = "e39a01efecd8a8670471352b3276c17d5e0dd7a8" - version = "v2.14.1" + revision = "5a1a268859490ec2772d8106a331be1f7d0d85a3" + version = "v2.14.2" [[projects]] digest = "1:57a3ce4850faf6af62c1a8c9ae41870084cfabaeba01b57cdc81967c11246a04" From 120408a79c31f20e3a328c469e513f1c6e25bf2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 1 Mar 2019 17:10:32 +0000 Subject: [PATCH 2/2] Update vendor files for gopkg.in/bblfsh/sdk.v2 2.14.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Martín --- .../bblfsh/sdk.v2/protocol/driver.pb.go | 24 +++++++- .../gopkg.in/bblfsh/sdk.v2/uast/nodes/node.go | 26 +++++++++ .../gopkg.in/bblfsh/sdk.v2/uast/role/role.go | 57 ++++++++++--------- .../bblfsh/sdk.v2/uast/transformer/ops.go | 31 +++++++--- vendor/gopkg.in/bblfsh/sdk.v2/uast/uast.go | 37 ++++++++---- 5 files changed, 127 insertions(+), 48 deletions(-) diff --git a/vendor/gopkg.in/bblfsh/sdk.v2/protocol/driver.pb.go b/vendor/gopkg.in/bblfsh/sdk.v2/protocol/driver.pb.go index f80f58b..0f1cd29 100644 --- a/vendor/gopkg.in/bblfsh/sdk.v2/protocol/driver.pb.go +++ b/vendor/gopkg.in/bblfsh/sdk.v2/protocol/driver.pb.go @@ -19,8 +19,10 @@ import fmt "fmt" import math "math" import _ "github.com/gogo/protobuf/gogoproto" -import context "golang.org/x/net/context" -import grpc "google.golang.org/grpc" +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) import io "io" @@ -301,6 +303,24 @@ func (m *ParseError) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func encodeFixed64Driver(dAtA []byte, offset int, v uint64) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + dAtA[offset+4] = uint8(v >> 32) + dAtA[offset+5] = uint8(v >> 40) + dAtA[offset+6] = uint8(v >> 48) + dAtA[offset+7] = uint8(v >> 56) + return offset + 8 +} +func encodeFixed32Driver(dAtA []byte, offset int, v uint32) int { + dAtA[offset] = uint8(v) + dAtA[offset+1] = uint8(v >> 8) + dAtA[offset+2] = uint8(v >> 16) + dAtA[offset+3] = uint8(v >> 24) + return offset + 4 +} func encodeVarintDriver(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) diff --git a/vendor/gopkg.in/bblfsh/sdk.v2/uast/nodes/node.go b/vendor/gopkg.in/bblfsh/sdk.v2/uast/nodes/node.go index 8fd3ef6..1f97b5a 100644 --- a/vendor/gopkg.in/bblfsh/sdk.v2/uast/nodes/node.go +++ b/vendor/gopkg.in/bblfsh/sdk.v2/uast/nodes/node.go @@ -948,3 +948,29 @@ func UniqueKey(n Node) Comparable { return unkPtr(ptr) } } + +// ChildrenCount reports the number of immediate children of n. If n is an Array this is +// the length of the array. If n is an Object, each object in a field of n counts as +// one child and each array is counted as its length. +func ChildrenCount(n Node) int { + switch n := n.(type) { + case nil: + return 0 + case Value: + return 0 + case Array: + return len(n) + case Object: + c := 0 + for _, v := range n { + switch v := v.(type) { + case Object: + c++ + case Array: + c += len(v) + } + } + return c + } + return 0 +} diff --git a/vendor/gopkg.in/bblfsh/sdk.v2/uast/role/role.go b/vendor/gopkg.in/bblfsh/sdk.v2/uast/role/role.go index 5c30a37..4b41fd7 100644 --- a/vendor/gopkg.in/bblfsh/sdk.v2/uast/role/role.go +++ b/vendor/gopkg.in/bblfsh/sdk.v2/uast/role/role.go @@ -49,10 +49,11 @@ const ( // Operator is any form of operator. Operator - // Binary is any form of binary operator, in contrast with unary operators. + // Binary is any form of binary operator or expression in contrast with unary operators / + // expressions. Binary - // Unary is any form of unary operator, in contrast with binary operators. + // Unary is any form of unary operator or expression, in contrast with binary. Unary // Left is a left hand side in a binary expression. @@ -69,13 +70,13 @@ const ( // Nodes without Infix or Postfix mark are considered in prefix order by default. Postfix - // Bitwise is any form of bitwise operation. + // Bitwise is any form of bitwise operation, expression or declaration. Bitwise - // Boolean is any form of boolean operation. + // Boolean is any form of boolean operation, expression or declaration. Boolean - // Unsigned is an form of unsigned operation. + // Unsigned is an form of unsigned operation, expression or declaration. Unsigned // LeftShift is a left shift operation (i.e. `<<`, `rol`, etc.) @@ -96,7 +97,7 @@ const ( // Expression is a construct computed to produce some value. Expression - // Statement is some action to be carried out. + // Statement is some action to be carried out usually without producing a value. Statement // Equal is an eaquality predicate (i.e. `=`, `==`, etc.) @@ -111,7 +112,7 @@ const ( // LessThanOrEqual is a comparison predicate that checks if the lhs value is smaller or equal to the rhs value (i.e. `<=`.) LessThanOrEqual - // GreaterThan is a comparison predicate that checks if the lhs value is greather than the rhs value (i. e. `>`.) + // GreaterThan is a comparison predicate that checks if the lhs value is greater than the rhs value (i. e. `>`.) GreaterThan // GreaterThanOrEqual is a comparison predicate that checks if the lhs value is greather than or equal to the rhs value (i.e. 1>=`.) @@ -123,10 +124,10 @@ const ( // Contains is a membership predicate that checks if the lhs value is a member of the rhs container (i.e. `in` in Python.) Contains - // Increment is an arithmetic operator that increments a value (i. e. `++i`.) + // Increment is an arithmetic operator that increments a value (i.e. `++i`.) Increment - // Decrement is an arithmetic operator that decrements a value (i. e. `--i`.) + // Decrement is an arithmetic operator that decrements a value (i.e. `--i`.) Decrement // Negative is an arithmetic operator that negates a value (i.e. `-x`.) @@ -213,10 +214,10 @@ const ( // Module is a set of funcitonality grouped. Module - // Friend is an access granter for some private resources. + // Friend is an access granter for some private resources to "friend" types. Friend - // World is a set of every component. + // World is a public access granter. World // If is used for if-then[-else] statements or expressions. @@ -253,7 +254,7 @@ const ( // Else is the clause executed when the Condition is false. Else - // Switch is used to represent a broad of switch flavors. An expression + // Switch is used to represent many switch flavors. An expression // is evaluated and then compared to the values returned by different // case expressions, executing a body associated to the first case that // matches. Similar constructions that go beyond expression comparison @@ -293,11 +294,11 @@ const ( // Continue is a construct for continuation with the next iteration of a loop. Continue - // Goto is an unconditional transfer of control statement. + // Goto is an unconditional transfer of the program flow to another place. Goto // Block is a group of statements. If the source language has block scope, - // it should be annotated both with Block and BlockScope. + // it should be annotated both with Block and Scope. Block // Scope is a range in which a variable can be referred. @@ -313,14 +314,15 @@ const ( // Catch is a clause to capture exceptions. Catch - // Finally is a clause for a block executed after a block with exception handling. + // Finally defines a block or expression to be run inconditionally after an + // expression handling block. Finally - // Throw is a statement that creates an exception. + // Throw is a statement that creates and throw an exception. Throw - // Assert checks if an expression is true and if it is not, it signals - // an error/exception, possibly stopping the execution. + // Assert checks if an expression is true and, if it is not, signals + // an error/exception, usually stopping the program's execution. Assert // Call is any call, whether it is a function, procedure, method or macro. @@ -337,7 +339,8 @@ const ( // Positional is an element which position has meaning (i.e. a positional argument in a call). Positional - // Noop is a construct that does nothing. + // Noop is a construct that does nothing like comments, documentation or, in some + // languages like Python, annotations. Noop // Literal is a literal value. @@ -417,27 +420,29 @@ const ( // Unannotated will be automatically added by the SDK for nodes that did not receive // any annotations with the current version of the driver's `annotations.go` file. - // Added in BIP-002. + // Added in BIP-002. Having a driver produce Unannotated nodes should be considered + // a bug. Unannotated // Visibility is an access granter role, usually together with an specifier role Visibility - // Annotation is syntactic metadata + // Annotation is syntactic metadata with or without semantic meaning. Annotation - // Anonymous is an unbound construct + // Anonymous is an construct not bound to name i.e. lambda functions. Anonymous - // Enumeration is a distinct type that represents a set of named constants + // Enumeration is a distinct type that represents a set of named constants. Enumeration - // Arithmetic is a type of operation + // Arithmetic is a type of arithmetic operation. Arithmetic - // Relational is a type of operation + // Relational is a type of relational operation i.e. "equal", "not equal", + // "less than"... Relational - // Variable is a symbolic name associatend with a value + // Variable is a symbolic name associatend with a value. Variable ) diff --git a/vendor/gopkg.in/bblfsh/sdk.v2/uast/transformer/ops.go b/vendor/gopkg.in/bblfsh/sdk.v2/uast/transformer/ops.go index e27e4a0..24d8239 100644 --- a/vendor/gopkg.in/bblfsh/sdk.v2/uast/transformer/ops.go +++ b/vendor/gopkg.in/bblfsh/sdk.v2/uast/transformer/ops.go @@ -746,11 +746,26 @@ func (op opScope) Construct(st *State, n nodes.Node) (nodes.Node, error) { // Field is an operation on a specific field of an object. type Field struct { Name string // name of the field - // Optional can be set to make a field optional. Provided string is used as a variable name to the state of the field. - // Note that "optional" means that the field may not exists in the object, and it does not mean that the field can be nil. + // Optional can be set to make a field optional. Provided string is used as a variable + // name to the state of the field. Note that "optional" means that the field may not + // exists in the object, and it does not mean that the field can be nil. // To handle nil fields, see Opt operation. Optional string - Op Op // operation used to check/construct the field value + // Drop the field if it exists. Optional is implied, but the variable won't be created + // in this case. Op should be set and it will be called to check the value before + // dropping it. If the check fails, the whole transform will be canceled. + // + // Please note that you should avoid dropping fields with Any unless there is no + // reasonable alternative. + Drop bool + Op Op // operation used to check/construct the field value +} + +// Desc returns a field descriptor. +func (f Field) Desc() FieldDesc { + d := FieldDesc{Optional: f.Optional != "" || f.Drop} + d.SetValue(f.Op) + return d } var _ ObjectOp = Fields{} @@ -770,9 +785,7 @@ func (Fields) Kinds() nodes.Kind { func (o Fields) Fields() (FieldDescs, bool) { fields := make(FieldDescs, len(o)) for _, f := range o { - fld := FieldDesc{Optional: f.Optional != ""} - fld.SetValue(f.Op) - fields[f.Name] = fld + fields[f.Name] = f.Desc() } return fields, true } @@ -800,11 +813,11 @@ func (o Fields) CheckObj(st *State, n nodes.Object) (bool, error) { if err := st.SetVar(f.Optional, nodes.Bool(ok)); err != nil { return false, errKey.Wrap(err, f.Name) } - if !ok { - continue - } } if !ok { + if f.Optional != "" || f.Drop { + continue + } if errorOnFilterCheck { return filtered("field %+v is missing in %+v\n%+v", f, n, o) } diff --git a/vendor/gopkg.in/bblfsh/sdk.v2/uast/uast.go b/vendor/gopkg.in/bblfsh/sdk.v2/uast/uast.go index 226a4ba..7a54db4 100644 --- a/vendor/gopkg.in/bblfsh/sdk.v2/uast/uast.go +++ b/vendor/gopkg.in/bblfsh/sdk.v2/uast/uast.go @@ -182,7 +182,13 @@ func AsPosition(m nodes.Object) *Position { } // PositionsOf returns a complete positions map for the given UAST node. -func PositionsOf(m nodes.Object) Positions { +// The function will return nil for non-object nodes like arrays and values. To get +// positions for these nodes, PositionsOf should be called on their parent node. +func PositionsOf(n nodes.Node) Positions { + m, ok := n.(nodes.Object) + if !ok { + return nil + } o, _ := m[KeyPos].(nodes.Object) if len(o) == 0 { return nil @@ -216,7 +222,12 @@ func RoleList(roles ...role.Role) nodes.Array { } // RolesOf is a helper for getting node UAST roles (see KeyRoles). -func RolesOf(m nodes.Object) role.Roles { +// The function will returns nil roles array for non-object nodes like arrays and values. +func RolesOf(n nodes.Node) role.Roles { + m, ok := n.(nodes.Object) + if !ok { + return nil + } arr, ok := m[KeyRoles].(nodes.Array) if !ok || len(arr) == 0 { if tp := TypeOf(m); tp == "" || strings.HasPrefix(tp, NS+":") { @@ -234,15 +245,19 @@ func RolesOf(m nodes.Object) role.Roles { } // TokenOf is a helper for getting node token (see KeyToken). -func TokenOf(m nodes.Object) string { - t := m[KeyToken] - s, ok := t.(nodes.String) - if ok { - return string(s) - } - v, _ := t.(nodes.Value) - if v != nil { - return fmt.Sprint(v) +// It returns an empty string if the node is not an object, or there is no token. +func TokenOf(n nodes.Node) string { + switch n := n.(type) { + case nodes.String: + return string(n) + case nodes.Value: + return fmt.Sprint(n) + case nodes.Object: + t := n[KeyToken] + if t == nil { + return "" + } + return TokenOf(t) } return "" }