Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Annotations = []Mapping{}/* 393 elements not displayed */
Annotations is a list of individual transformations to annotate a native AST with roles.
var Code []CodeTransformer // legacy stage, will be deprecated
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
var Normalize = Transformers([][]Transformer{ {Mappings(Normalizers...)}, }...)
var Normalizers = []Mapping{ Map( Check( Has{ uast.KeyType: String("IdentifierName"), "IsMissing": Bool(true), "Identifier": Has{ "Text": String(""), "Value": String(""), "ValueText": String(""), }, }, Any(), ), Is(nil), ), MapSemantic("IdentifierName", uast.Identifier{}, MapObj( Obj{ "Identifier": Obj{ uast.KeyType: String("IdentifierToken"), uast.KeyPos: Any(), "LeadingTrivia": Any(), "TrailingTrivia": Any(), "IsMissing": Bool(false), "Text": Var("name"), "Value": Var("name"), "ValueText": Var("name"), }, "Arity": Int(0), "IsMissing": Bool(false), "IsStructuredTrivia": Bool(false), "IsUnmanaged": Any(), "IsVar": Any(), }, Obj{ "Name": Var("name"), }, )), MapSemantic("StringLiteralExpression", uast.String{}, MapObj( Obj{ "Token": Obj{ uast.KeyType: String("StringLiteralToken"), uast.KeyPos: Any(), "LeadingTrivia": Any(), "TrailingTrivia": Any(), "IsMissing": Bool(false), "Text": Any(), "Value": Var("val"), "ValueText": Var("val"), }, "IsMissing": Bool(false), "IsStructuredTrivia": Bool(false), }, Obj{ "Value": Var("val"), }, )), MapSemantic("Block", uast.Block{}, MapObj( Obj{ "Statements": Var("stmts"), "OpenBraceToken": Any(), "CloseBraceToken": Any(), }, Obj{ "Statements": Var("stmts"), }, )), MapSemantic("SingleLineCommentTrivia", uast.Comment{}, MapObj( Obj{ uast.KeyToken: CommentText([2]string{"//", ""}, "text"), "IsDirective": Bool(false), }, CommentNode(false, "text", nil), )), MapSemantic("SingleLineDocumentationCommentTrivia", uast.Comment{}, MapObj( Obj{ uast.KeyToken: CommentText([2]string{"///", ""}, "text"), "IsDirective": Bool(false), }, CommentNode(false, "text", nil), )), MapSemantic("UsingDirective", uast.Import{}, MapObj( Obj{ "Name": Var("path"), "SemicolonToken": Any(), "UsingKeyword": Any(), }, Obj{ "Path": Var("path"), "All": Bool(true), }, )), MapSemantic("QualifiedName", uast.QualifiedIdentifier{}, MapObj( CasesObj("case", Obj{ "Right": Var("right"), }, Objs{ { "Left": Check(HasType(uast.Identifier{}), Var("left")), }, { "Left": UASTType(uast.QualifiedIdentifier{}, Obj{ uast.KeyPos: Any(), "Names": Var("names"), }), }, }, ), CasesObj("case", nil, Objs{ { "Names": Arr(Var("left"), Var("right")), }, { "Names": Append(Var("names"), Arr(Var("right"))), }, }, ), )), }
Normalizers is the main block of normalization rules to convert native AST to semantic UAST.
var Preprocess = Transformers([][]Transformer{ {Mappings(Preprocessors...)}, }...)
var PreprocessCode = []CodeTransformer{ positioner.FromOffset(), positioner.TokenFromSource{ Types: []string{ "SingleLineCommentTrivia", "SingleLineDocumentationCommentTrivia", }, }, }
PreprocessCode is a special block of transformations that are applied at the end and can access original source code file. It can be used to improve or fix positional information.
https://godoc.org/gopkg.in/bblfsh/sdk.v2/uast/transformer/positioner
var Preprocessors = []Mapping{ Map( Obj{ uast.KeyType: Check( In(nodes.String("WhitespaceTrivia"), nodes.String("EndOfLineTrivia")), Any(), ), "FullSpan": Any(), "Span": Any(), "SpanStart": Any(), "IsDirective": Bool(false), }, Is(nil), ), Map( Part("_", Obj{ "LeadingTrivia": dropNils{Var("arr")}, }), Part("_", Obj{ "LeadingTrivia": Var("arr"), }), ), Map( Part("_", Obj{ "TrailingTrivia": dropNils{Var("arr")}, }), Part("_", Obj{ "TrailingTrivia": Var("arr"), }), ), Map( Part("_", Obj{ uast.KeyType: String("TextSpan"), "IsEmpty": Any(), }), Part("_", Obj{ uast.KeyType: String("TextSpan"), }), ), Map( Part("_", Obj{ "SpanStart": Any(), }), Part("_", Obj{}), ), Map( Part("_", Obj{ "FullSpan": Obj{ uast.KeyType: String("TextSpan"), "Length": Any(), "Start": Var("start"), "End": Var("end"), }, "Span": Any(), }), Part("_", Obj{ "spanStart": Var("start"), "spanEnd": Var("end"), }), ), ObjectToNode{ OffsetKey: "spanStart", EndOffsetKey: "spanEnd", }.Mapping(), Map( Part("_", Obj{ uast.KeyType: String("SingleLineCommentTrivia"), }), Part("_", Obj{ uast.KeyType: String("SingleLineCommentTrivia"), uast.KeyToken: String(""), }), ), Map( Part("_", Obj{ uast.KeyType: String("SingleLineDocumentationCommentTrivia"), }), Part("_", Obj{ uast.KeyType: String("SingleLineDocumentationCommentTrivia"), uast.KeyToken: String(""), }), ), }
Preprocessors is a block of AST preprocessing rules rules.
var Transforms = driver.Transforms{ Namespace: "csharp", Preprocess: Preprocess, PreprocessCode: PreprocessCode, Normalize: Normalize, Annotations: Native, Code: Code, }
Functions ¶
This section is empty.
Types ¶
This section is empty.