Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Annotations = []Mapping{}/* 137 elements not displayed */
Annotations is a list of individual transformations to annotate a native AST with roles.
View Source
var Code []CodeTransformer // TODO(dennwc): deprecated
View Source
var Native = Transformers([][]Transformer{ {Mappings(Annotations...)}, { RolesDedup(), }, }...)
Native is the of list `transformer.Transformer` to apply to a native AST. To learn more about the Transformers and the available ones take a look to: https://godoc.org/gopkg.in/bblfsh/sdk.v2/uast/transformer
View Source
var Normalize = Transformers([][]Transformer{ {Mappings(Normalizers...)}, }...)
View Source
var Normalizers = []Mapping{ Map( Part("_", Fields{ {Name: uast.KeyType, Op: Check(In(allNormalizedTypes...), Var("t"))}, {Name: "leadingComments", Drop: true, Op: Any()}, }), Part("_", Obj{uast.KeyType: Var("t")}), ), Map( Part("_", Fields{ {Name: uast.KeyType, Op: Check(In(allNormalizedTypes...), Var("t"))}, {Name: "innerComments", Drop: true, Op: Any()}, }), Part("_", Obj{uast.KeyType: Var("t")}), ), Map( Part("_", Fields{ {Name: uast.KeyType, Op: Check(In(allNormalizedTypes...), Var("t"))}, {Name: "trailingComments", Drop: true, Op: Any()}, }), Part("_", Obj{uast.KeyType: Var("t")}), ), MapSemantic("Identifier", uast.Identifier{}, MapObj( Fields{ {Name: "name", Op: Var("name")}, {Name: "typeAnnotation", Drop: true, Op: Any()}, {Name: "optional", Drop: true, Op: Any()}, }, Obj{ "Name": Var("name"), }, )), MapSemantic("JSXIdentifier", uast.Identifier{}, MapObj( Obj{ "name": Var("name"), }, Obj{ "Name": Var("name"), }, )), MapSemantic("StringLiteral", uast.String{}, MapObj( Fields{ {Name: "value", Op: singleQuote{Var("val")}}, }, Obj{ "Value": Var("val"), "Format": String("single"), }, )), MapSemantic("StringLiteral", uast.String{}, MapObj( Fields{ {Name: "value", Op: doubleQuote(Var("val"))}, }, Obj{ "Value": Var("val"), }, )), MapSemantic("CommentLine", uast.Comment{}, MapObj( Obj{ "value": CommentText([2]string{"", ""}, "comm"), }, CommentNode(false, "comm", nil), )), MapSemantic("CommentBlock", uast.Comment{}, MapObj( Obj{ "value": CommentText([2]string{"", ""}, "comm"), }, CommentNode(true, "comm", nil), )), MapSemantic("BlockStatement", uast.Block{}, MapObj( Fields{ {Name: "body", Op: Var("stmts")}, {Name: "directives", Op: Arr()}, }, Obj{ "Statements": Var("stmts"), }, )), MapSemantic("ImportDeclaration", uast.Import{}, MapObj( Fields{ {Name: "source", Op: Var("path")}, {Name: "specifiers", Drop: true, Op: Arr()}, }, Obj{ "Path": Var("path"), }, )), MapSemantic("ImportDeclaration", uast.Import{}, MapObj( CasesObj("case", Fields{ {Name: "source", Op: Var("path")}, }, Objs{ { "importKind": String("value"), "specifiers": ArrWith(Var("names"), Fields{ {Name: uast.KeyType, Op: String("ImportNamespaceSpecifier")}, {Name: uast.KeyPos, Op: Var("local_pos")}, {Name: "local", Op: Var("local")}, }), }, { "importKind": String("type"), "specifiers": ArrWith(Var("names"), UASTType(uast.Alias{}, Obj{ uast.KeyPos: Var("local_pos"), "Name": Var("local"), "Node": UASTType(uast.Identifier{}, Obj{ uast.KeyPos: Any(), "Name": Any(), }), })), }, { "importKind": String("value"), "specifiers": Check(Not(Arr()), Var("names")), }, }, ), CasesObj("case", nil, Objs{ { "Path": UASTType(uast.Alias{}, Obj{ uast.KeyPos: Var("local_pos"), "Name": Var("local"), "Node": Var("path"), }), "Names": Var("names"), "All": Bool(true), }, { "Path": UASTType(uast.Alias{}, Obj{ uast.KeyPos: Var("local_pos"), "Name": Var("local"), "Node": Var("path"), }), "Names": Var("names"), "All": Bool(true), }, { "Path": Var("path"), "Names": Var("names"), "All": Bool(false), }, }, ), )), MapSemantic("ImportSpecifier", uast.Alias{}, MapObj( Obj{ "importKind": Is(nil), "local": Var("local"), "imported": Var("imp"), }, Obj{ "Name": Var("local"), "Node": Var("imp"), }, )), MapSemantic("ImportDefaultSpecifier", uast.Alias{}, MapObj( Fields{ {Name: "local", Op: Var("local")}, }, Obj{ "Name": Var("local"), "Node": UASTType(uast.Identifier{}, Obj{ uast.KeyPos: Any(), "Name": String("."), }), }, )), MapSemantic("FunctionDeclaration", uast.FunctionGroup{}, MapObj( Fields{ {Name: "id", Op: Var("name")}, {Name: "generator", Op: Var("gen")}, {Name: "async", Op: Var("async")}, {Name: "body", Op: Var("body")}, {Name: "predicate", Drop: true, Op: Any()}, {Name: "returnType", Drop: true, Op: Any()}, {Name: "typeParameters", Drop: true, Op: Any()}, {Name: "params", Op: Each("params", Cases("param_case", Check( HasType(uast.Identifier{}), Var("arg_name"), ), Obj{ uast.KeyType: String("AssignmentPattern"), uast.KeyPos: Var("arg_pos"), "left": Var("arg_name"), "right": Var("arg_init"), }, Obj{ uast.KeyType: String("RestElement"), uast.KeyPos: Var("arg_pos"), "argument": Var("arg_name"), }, ))}, }, Obj{ "Nodes": Arr( Obj{ "async": Var("async"), "generator": Var("gen"), }, UASTType(uast.Alias{}, Obj{ "Name": Var("name"), "Node": UASTType(uast.Function{}, Obj{ "Type": UASTType(uast.FunctionType{}, Obj{ "Arguments": Each("params", Cases("param_case", UASTType(uast.Argument{}, Obj{ "Name": Var("arg_name"), }), UASTType(uast.Argument{}, Obj{ uast.KeyPos: Var("arg_pos"), "Name": Var("arg_name"), "Init": Var("arg_init"), }), UASTType(uast.Argument{}, Obj{ uast.KeyPos: Var("arg_pos"), "Name": Var("arg_name"), "Variadic": Bool(true), }), )), "Returns": Arr( UASTType(uast.Argument{}, Obj{ "Init": Is(uast.Identifier{ Name: "undefined", }), }), ), }), "Body": Var("body"), }), }), ), }, )), }
Normalizers is the main block of normalization rules to convert native AST to semantic UAST.
View Source
var Preprocess = Transformers([][]Transformer{ {Mappings(Preprocessors...)}, }...)
View Source
var PreprocessCode = []CodeTransformer{ positioner.FromUTF16Offset(), }
PreprocessCode is a preprocessor stage that can use the source code to fix tokens and positional information.
View Source
var Preprocessors = []Mapping{ ObjectToNode{ InternalTypeKey: "type", OffsetKey: "start", EndOffsetKey: "end", }.Mapping(), Map( Part("_", Obj{"loc": Any()}), Part("_", Obj{}), ), Map( Part("_", Obj{ uast.KeyType: String("StringLiteral"), "value": Any(), "extra": Fields{ {Name: "raw", Op: Var("raw")}, {Name: "rawValue", Op: Any()}, {Name: "parenthesized", Drop: true, Op: Any()}, {Name: "parenStart", Drop: true, Op: Any()}, }, }), Part("_", Obj{ uast.KeyType: String("StringLiteral"), "value": Var("raw"), }), ), Map( Part("_", Obj{ uast.KeyType: String("RegExpLiteral"), "extra": Fields{ {Name: "raw", Op: Var("raw")}, {Name: "parenthesized", Drop: true, Op: Any()}, {Name: "parenStart", Drop: true, Op: Any()}, }, }), Part("_", Obj{ uast.KeyType: String("RegExpLiteral"), "raw": Var("raw"), }), ), Map( Part("_", Obj{"extra": Any()}), Part("_", Obj{}), ), }
Preprocessors is a block of AST preprocessing rules rules.
View Source
var Transforms = driver.Transforms{ Namespace: "javascript", Preprocess: Preprocess, PreprocessCode: PreprocessCode, Normalize: Normalize, Annotations: Native, Code: Code, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.