normalizer

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2017 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Identifier               = ann.HasInternalType("Identifier")
	PrivateName              = ann.HasInternalType("PrivateName")
	Literal                  = ann.HasInternalType("Literal")
	RegExpLiteral            = ann.HasInternalType("RegExpLiteral")
	NullLiteral              = ann.HasInternalType("NullLiteral")
	StringLiteral            = ann.HasInternalType("StringLiteral")
	BooleanLiteral           = ann.HasInternalType("BooleanLiteral")
	NumericLiteral           = ann.HasInternalType("NumericLiteral")
	Program                  = ann.HasInternalType("Program")
	Function                 = ann.HasInternalType("Function")
	Statement                = ann.HasInternalType("Statement")
	ExpressionStatement      = ann.HasInternalType("ExpressionStatement")
	BlockStatement           = ann.HasInternalType("BlockStatement")
	EmptyStatement           = ann.HasInternalType("EmptyStatement")
	DebuggerStatement        = ann.HasInternalType("DebuggerStatement")
	WithStatement            = ann.HasInternalType("WithStatement")
	ReturnStatement          = ann.HasInternalType("ReturnStatement")
	LabeledStatement         = ann.HasInternalType("LabeledStatement")
	BreakStatement           = ann.HasInternalType("BreakStatement")
	ContinueStatement        = ann.HasInternalType("ContinueStatement")
	IfStatement              = ann.HasInternalType("IfStatement")
	SwitchStatement          = ann.HasInternalType("SwitchStatement")
	SwitchCase               = ann.HasInternalType("SwitchCase")
	ThrowStatement           = ann.HasInternalType("ThrowStatement")
	TryStatement             = ann.HasInternalType("TryStatement")
	CatchClause              = ann.HasInternalType("CatchClause")
	WhileStatement           = ann.HasInternalType("WhileStatement")
	DoWhileStatement         = ann.HasInternalType("DoWhileStatement")
	ForStatement             = ann.HasInternalType("ForStatement")
	ForInStatement           = ann.HasInternalType("ForInStatement")
	ForOfStatement           = ann.HasInternalType("ForOfStatement")
	Declaration              = ann.HasInternalType("Declaration")
	FunctionDeclaration      = ann.HasInternalType("FunctionDeclaration")
	VariableDeclaration      = ann.HasInternalType("VariableDeclaration")
	VariableDeclarator       = ann.HasInternalType("VariableDeclarator")
	Decorator                = ann.HasInternalType("Decorator")
	Directive                = ann.HasInternalType("Directive")
	DirectiveLiteral         = ann.HasInternalType("DirectiveLiteral")
	Expression               = ann.HasInternalType("Expression")
	Super                    = ann.HasInternalType("Super")
	Import                   = ann.HasInternalType("Import")
	ThisExpression           = ann.HasInternalType("ThisExpression")
	ArrowFunctionExpression  = ann.HasInternalType("ArrowFunctionExpression")
	YieldExpression          = ann.HasInternalType("YieldExpression")
	AwaitExpression          = ann.HasInternalType("AwaitExpression")
	ArrayExpression          = ann.HasInternalType("ArrayExpression")
	ObjectExpression         = ann.HasInternalType("ObjectExpression")
	ObjectMember             = ann.HasInternalType("ObjectMember")
	ObjectProperty           = ann.HasInternalType("ObjectProperty")
	ObjectMethod             = ann.HasInternalType("ObjectMethod")
	FunctionExpression       = ann.HasInternalType("FunctionExpression")
	UnaryExpression          = ann.HasInternalType("UnaryExpression")
	UnaryOperator            = ann.HasInternalType("UnaryOperator")
	UpdateExpression         = ann.HasInternalType("UpdateExpression")
	UpdateOperator           = ann.HasInternalType("UpdateOperator")
	BinaryExpression         = ann.HasInternalType("BinaryExpression")
	BinaryOperator           = ann.HasInternalType("BinaryOperator")
	AssignmentExpression     = ann.HasInternalType("AssignmentExpression")
	AssignmentOperator       = ann.HasInternalType("AssignmentOperator")
	LogicalExpression        = ann.HasInternalType("LogicalExpression")
	LogicalOperator          = ann.HasInternalType("LogicalOperator")
	SpreadElement            = ann.HasInternalType("SpreadElement")
	MemberExpression         = ann.HasInternalType("MemberExpression")
	BindExpression           = ann.HasInternalType("BindExpression")
	ConditionalExpression    = ann.HasInternalType("ConditionalExpression")
	CallExpression           = ann.HasInternalType("CallExpression")
	NewExpression            = ann.HasInternalType("NewExpression")
	SequenceExpression       = ann.HasInternalType("SequenceExpression")
	DoExpression             = ann.HasInternalType("DoExpression")
	TemplateLiteral          = ann.HasInternalType("TemplateLiteral")
	TaggedTemplateExpression = ann.HasInternalType("TaggedTemplateExpression")
	TemplateElement          = ann.HasInternalType("TemplateElement")
	Pattern                  = ann.HasInternalType("Pattern")
	AssignmentProperty       = ann.HasInternalType("AssignmentProperty")
	ObjectPattern            = ann.HasInternalType("ObjectPattern")
	ArrayPattern             = ann.HasInternalType("ArrayPattern")
	RestElement              = ann.HasInternalType("RestElement")
	AssignmentPattern        = ann.HasInternalType("AssignmentPattern")
	Class                    = ann.HasInternalType("Class")
	ClassBody                = ann.HasInternalType("ClassBody")
	ClassMethod              = ann.HasInternalType("ClassMethod")
	ClassPrivateMethod       = ann.HasInternalType("ClassPrivateMethod")
	ClassProperty            = ann.HasInternalType("ClassProperty")
	ClassPrivateProperty     = ann.HasInternalType("ClassPrivateProperty")
	ClassDeclaration         = ann.HasInternalType("ClassDeclaration")
	ClassExpression          = ann.HasInternalType("ClassExpression")
	MetaProperty             = ann.HasInternalType("MetaProperty")
	ModuleDeclaration        = ann.HasInternalType("ModuleDeclaration")
	ModuleSpecifier          = ann.HasInternalType("ModuleSpecifier")
	ImportDeclaration        = ann.HasInternalType("ImportDeclaration")
	ImportSpecifier          = ann.HasInternalType("ImportSpecifier")
	ImportDefaultSpecifier   = ann.HasInternalType("ImportDefaultSpecifier")
	ImportNamespaceSpecifier = ann.HasInternalType("ImportNamespaceSpecifier")
	ExportNamedDeclaration   = ann.HasInternalType("ExportNamedDeclaration")
	ExportSpecifier          = ann.HasInternalType("ExportSpecifier")
	OptFunctionDeclaration   = ann.HasInternalType("OptFunctionDeclaration")
	OptClasDeclaration       = ann.HasInternalType("OptClasDeclaration")
	ExportDefaultDeclaration = ann.HasInternalType("ExportDefaultDeclaration")
	ExportAllDeclaration     = ann.HasInternalType("ExportAllDeclaration")
)
View Source
var AnnotationRules = On(Any).Roles(uast.File)

AnnotationRules describes how a UAST should be annotated with `uast.Role`.

https://godoc.org/gopkg.in/bblfsh/sdk.v1/uast/ann

View Source
var ToNode = &uast.ObjectToNode{
	TopLevelIsRootNode: true,
	InternalTypeKey:    "type",
	OffsetKey:          "start",
	EndOffsetKey:       "end",
	LineKey:            "loc.start.line",
	EndLineKey:         "loc.end.line",
	ColumnKey:          "loc.start.column",
	EndColumnKey:       "loc.end.column",
	TokenKeys: map[string]bool{
		"value": true,
		"name":  true,
	},

	IsNode: func(v map[string]interface{}) bool {
		_, ok := v["type"].(string)
		return ok
	},

	Modifier: func(n map[string]interface{}) error {
		loc, ok := n["loc"].(map[string]interface{})
		if !ok {
			return nil
		}

		for _, key := range []string{"start", "end"} {
			p, ok := loc[key].(map[string]interface{})
			if !ok {
				continue
			}

			if c, ok := p["column"].(float64); ok {
				p["column"] = c + 1
			}
		}

		return nil
	},
}

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

Transformers is the list of `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

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL