Versions in this module Expand all Collapse all v3 v3.3.2 Nov 14, 2019 v3.3.1 Oct 23, 2019 v3.3.0 Oct 9, 2019 v3.2.5 Oct 2, 2019 v3.2.4 Sep 23, 2019 v3.2.3 Aug 7, 2019 v3.2.2 Jul 24, 2019 v3.2.1 Jul 23, 2019 v3.2.0 Jun 13, 2019 v3.1.0 May 21, 2019 v3.0.0 Apr 12, 2019 Changes in this version + var ErrAmbiguousValue = errors.NewKind("map has ambiguous value %v") + var ErrDuplicateField = errors.NewKind("duplicate field: %v") + var ErrExpectedList = errors.NewKind("expected list, got %T") + var ErrExpectedObject = errors.NewKind("expected object, got %T") + var ErrExpectedValue = errors.NewKind("expected value, got %T") + var ErrUndefinedField = errors.NewKind("undefined field: %v") + var ErrUnexpectedNode = errors.NewKind("expected node to be nil, got: %v") + var ErrUnexpectedType = errors.NewKind("unexpected type: exp %T vs got %T") + var ErrUnexpectedValue = errors.NewKind("unexpected value: %v") + var ErrUnhandledValueIn = errors.NewKind("unhandled value: %v in %v") + var ErrUnusedField = errors.NewKind("unused field(s) on node %v: %v") + var ErrVariableNotDefined = errors.NewKind("variable %q is not defined") + var ErrVariableRedeclared = errors.NewKind("variable %q redeclared (%v vs %v)") + var ErrVariableUnused = errors.NewKind("variables %q unused in the second part of the transform") + func NewErrUnusedField(n nodes.Object, fields []string) error + func NewMultiError(errs ...error) error + func StringToRolesMap(m map[string][]role.Role) map[nodes.Value]ArrayOp + type ArrayOp interface + func AppendArr(items ...ArrayOp) ArrayOp + func AppendRoles(old ArrayOp, roles ...role.Role) ArrayOp + func Arr(ops ...Op) ArrayOp + func LookupArrOpVar(vr string, cases map[nodes.Value]ArrayOp) ArrayOp + func One(op Op) ArrayOp + func Roles(roles ...role.Role) ArrayOp + type ByFieldName []Field + func (arr ByFieldName) Len() int + func (arr ByFieldName) Less(i, j int) bool + func (arr ByFieldName) Swap(i, j int) + type CodeTransformer interface + OnCode func(code string) Transformer + type Field struct + Drop bool + Name string + Op Op + Optional string + func RolesField(vr string, roles ...role.Role) Field + func RolesFieldOp(vr string, op ArrayOp, roles ...role.Role) Field + func (f Field) Desc() FieldDesc + type FieldDesc struct + Fixed *nodes.Node + Optional bool + func (f *FieldDesc) SetValue(sel Sel) + type FieldDescs struct + func NewFieldDescs(n int) FieldDescs + func (f *FieldDescs) CheckObj(n nodes.Object) bool + func (f *FieldDescs) Clone() FieldDescs + func (f *FieldDescs) Get(k string) (FieldDesc, bool) + func (f *FieldDescs) Has(k string) bool + func (f *FieldDescs) Index(i int) (FieldDesc, string) + func (f *FieldDescs) Len() int + func (f *FieldDescs) Set(k string, d FieldDesc) + type FieldRole struct + Add bool + Arr bool + Op Op + Opt bool + Rename string + Roles []role.Role + Skip bool + Sub ObjMapping + type FieldRoles map[string]FieldRole + func (f FieldRoles) Mapping() (src, dst Op) + func (f FieldRoles) ObjMapping() (src, dst ObjectOp) + type Fields []Field + func (Fields) Kinds() nodes.Kind + func (o Fields) Check(st *State, n nodes.Node) (_ bool, gerr error) + func (o Fields) CheckObj(st *State, n nodes.Object) (bool, error) + func (o Fields) Construct(st *State, n nodes.Node) (nodes.Node, error) + func (o Fields) ConstructObj(st *State, obj nodes.Object) (nodes.Object, error) + func (o Fields) Fields() (FieldDescs, bool) + type Has map[string]Sel + func (Has) Kinds() nodes.Kind + func (m Has) Check(st *State, n nodes.Node) (bool, error) + func (m Has) CheckObj(st *State, n nodes.Object) (bool, error) + func (m Has) Fields() (FieldDescs, bool) + type HasFields map[string]bool + func (HasFields) Kinds() nodes.Kind + func (m HasFields) Check(st *State, n nodes.Node) (bool, error) + func (m HasFields) CheckObj(st *State, n nodes.Object) (bool, error) + func (m HasFields) Fields() (FieldDescs, bool) + type Mapping interface + Mapping func() (src, dst Op) + func AnnotateIfNoRoles(typ string, roles ...role.Role) Mapping + func Identity(op Op) Mapping + func Map(src, dst Op) Mapping + func MapEach(vr string, m Mapping) Mapping + func Reverse(m Mapping) Mapping + func Scope(name string, m Mapping) Mapping + type MappingOp interface + func Bool(val bool) MappingOp + func Int(val int) MappingOp + func Is(o interface{}) MappingOp + func String(val string) MappingOp + func Uint(val uint) MappingOp + func Var(name string) MappingOp + type Mod interface + Construct func(st *State, n nodes.Node) (nodes.Node, error) + type MultiError struct + Errs []error + func (e *MultiError) Error() string + type Obj map[string]Op + func (Obj) Kinds() nodes.Kind + func (o Obj) Check(st *State, n nodes.Node) (bool, error) + func (o Obj) CheckObj(st *State, n nodes.Object) (bool, error) + func (o Obj) Construct(st *State, n nodes.Node) (nodes.Node, error) + func (o Obj) ConstructObj(st *State, n nodes.Object) (nodes.Object, error) + func (o Obj) Fields() (FieldDescs, bool) + type ObjMap map[string]Mapping + func (m ObjMap) Mapping() (src, dst Op) + func (m ObjMap) ObjMapping() (src, dst ObjectOp) + type ObjMapping interface + ObjMapping func() (src, dst ObjectOp) + func AnnotateType(typ string, fields ObjMapping, roles ...role.Role) ObjMapping + func AnnotateTypeCustom(typ string, fields ObjMapping, rop ArrayOp, roles ...role.Role) ObjMapping + func AnnotateTypeCustomMap(typ string, fields ObjMapping, fnc RolesByType, rop ArrayOp, ...) ObjMapping + func MapObj(src, dst ObjectOp) ObjMapping + func MapPart(vr string, m ObjMapping) ObjMapping + func MapSemantic(nativeType string, semType interface{}, m ObjMapping) ObjMapping + func MapSemanticPos(nativeType string, semType interface{}, pos map[string]string, m ObjMapping) ObjMapping + func ObjScope(name string, m ObjMapping) ObjMapping + type ObjRoles map[string][]role.Role + func (o ObjRoles) Mapping() (src, dst Op) + func (o ObjRoles) ObjMapping() (src, dst ObjectOp) + type ObjectOp interface + ConstructObj func(st *State, n nodes.Object) (nodes.Object, error) + func ASTObjectLeft(typ string, ast ObjectOp) ObjectOp + func ASTObjectRight(typ string, norm ObjectOp, rop ArrayOp, roles ...role.Role) ObjectOp + func ASTObjectRightCustom(typ string, norm ObjectOp, fnc RolesByType, rop ArrayOp, roles ...role.Role) ObjectOp + func CasesObj(vr string, common ObjectOp, cases ObjectOps) ObjectOp + func CheckObj(s ObjectSel, op ObjectOp) ObjectOp + func CommentNode(block bool, vr string, pos Op) ObjectOp + func JoinObj(ops ...ObjectOp) ObjectOp + func ObjOpScope(name string, op ObjectOp) ObjectOp + func Operator(vr string, lookup map[nodes.Value]ArrayOp, roles ...role.Role) ObjectOp + func Part(vr string, o ObjectOp) ObjectOp + func UASTType(uobj interface{}, op ObjectOp) ObjectOp + func UASTTypePart(vr string, uobj interface{}, op ObjectOp) ObjectOp + type ObjectOps interface + ObjectOps func() []ObjectOp + type ObjectSel interface + CheckObj func(st *State, n nodes.Object) (bool, error) + Fields func() (FieldDescs, bool) + func ObjNot(s ObjectSel) ObjectSel + type ObjectToNode struct + ColumnKey string + EndColumnKey string + EndLineKey string + EndOffsetKey string + InternalTypeKey string + LineKey string + OffsetKey string + func (n ObjectToNode) Mapping() Mapping + type Objects []ObjectOp + func (o Objects) ObjectOps() []ObjectOp + type Objs []Obj + func (o Objs) ObjectOps() []ObjectOp + type Op interface + func Any() Op + func AnyNode(create Mod) Op + func AnyVal(val nodes.Value) Op + func Append(to Op, items ...ArrayOp) Op + func ArrWith(arr Op, items ...Op) Op + func Cases(vr string, cases ...Op) Op + func Check(s Sel, op Op) Op + func CommentText(tokens [2]string, vr string) Op + func CommentTextTrimmed(tokens [2]string, vr string) Op + func Each(vr string, op Op) Op + func EachObjectRoles(vr string, roles ...role.Role) Op + func EachObjectRolesByType(vr string, types map[string][]role.Role, roles ...role.Role) Op + func EmptyObj() Op + func If(cond string, then, els Op) Op + func Lookup(op Op, m map[nodes.Value]nodes.Value) Op + func LookupOpVar(vr string, cases map[nodes.Value]Op) Op + func LookupVar(vr string, m map[nodes.Value]nodes.Value) Op + func NotEmpty(op Op) Op + func ObjectRoles(vr string, roles ...role.Role) Op + func ObjectRolesCustom(vr string, obj ObjectOp, roles ...role.Role) Op + func ObjectRolesCustomOp(vr string, obj ObjectOp, rop ArrayOp, roles ...role.Role) Op + func OpScope(name string, op Op) Op + func Opt(exists string, op Op) Op + func OptObjectRoles(vr string, roles ...role.Role) Op + func PrependOne(first Op, arr Op) Op + func Quote(op Op) Op + func SavePosLineCol(varLine, varCol string) Op + func SavePosOffset(vr string) Op + func Seq(ops ...Op) Op + func StringConv(on Op, conv, rev StringFunc) Op + func TypedObj(typ string, ops map[string]Op) Op + func Uncomment(vr string, tokens [2]string) Op + func UncommentCLike(vr string) Op + func ValueConv(on Op, conv, rev ValueFunc) Op + func VarKind(name string, k nodes.Kind) Op + type ResponseMetadata struct + TopLevelIsRootNode bool + func (n ResponseMetadata) Do(root nodes.Node) (nodes.Node, error) + type RolesByType func(typ string) role.Roles + type Sel interface + Check func(st *State, n nodes.Node) (bool, error) + Kinds func() nodes.Kind + func All(s Sel) Sel + func And(sels ...Sel) Sel + func AnyElem(s Sel) Sel + func HasType(o interface{}) Sel + func In(vals ...nodes.Value) Sel + func Not(s Sel) Sel + func NotNil() Sel + func OfKind(k nodes.Kind) Sel + type State struct + func NewState() *State + func (st *State) ApplyFrom(st2 *State) + func (st *State) Clone() *State + func (st *State) GetStateVar(name string) ([]*State, bool) + func (st *State) GetVar(name string) (nodes.Node, bool) + func (st *State) MustGetVar(name string) (nodes.Node, error) + func (st *State) MustGetVars(vars VarsPtrs) error + func (st *State) Reset() + func (st *State) SetStateVar(name string, sub []*State) error + func (st *State) SetVar(name string, val nodes.Node) error + func (st *State) SetVars(vars Vars) error + func (st *State) Validate() error + type StringFunc func(string) (string, error) + type TransformFunc func(n nodes.Node) (nodes.Node, bool, error) + func RolesDedup() TransformFunc + func (f TransformFunc) Do(n nodes.Node) (nodes.Node, error) + type TransformObjFunc func(n nodes.Object) (nodes.Object, bool, error) + func (f TransformObjFunc) Do(n nodes.Node) (nodes.Node, error) + func (f TransformObjFunc) Func() TransformFunc + type Transformer interface + Do func(root nodes.Node) (nodes.Node, error) + func DefaultNamespace(ns string) Transformer + func Mappings(maps ...Mapping) Transformer + func Transformers(arr ...[]Transformer) []Transformer + type ValueFunc func(nodes.Value) (nodes.Value, error) + type Vars map[string]nodes.Node + type VarsPtrs map[string]nodes.NodePtr Other modules containing this package github.com/bblfsh/sdk