static_analysis

package
v0.0.0-...-293c848 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package static_analysis declares the types used to represent metadata extracted from the Go source. The source code is transformed to an Abstract Syntax Tree via go/ast module. Said AST is visited through the Visitor pattern all the metadata available are extractred and agglomerated in a single comprehensive struct.

Package static_analysis declares the types used to represent metadata extracted from the Go source. The source code is transformed to an Abstract Syntax Tree via go/ast module. Said AST is visited through the Visitor pattern all the metadata available are extractred and agglomerated in a single comprehensive struct.

Package static_analysis declares the types used to represent metadata extracted from the Go source. The source code is transformed to an Abstract Syntax Tree via go/ast module. Said AST is visited through the Visitor pattern all the metadata available are extractred and agglomerated in a single comprehensive struct.

Package static_analysis declares the types used to represent metadata extracted from the Go source. The source code is transformed to an Abstract Syntax Tree via go/ast module. Said AST is visited through the Visitor pattern all the metadata available are extractred and agglomerated in a single comprehensive struct.

Package static_analysis declares the types used to represent metadata extracted from the Go source. The source code is transformed to an Abstract Syntax Tree via go/ast module. Said AST is visited through the Visitor pattern all the metadata available are extractred and agglomerated in a single comprehensive struct.

Package static_analysis declares the types used to represent metadata extracted from the Go source. The source code is transformed to an Abstract Syntax Tree via go/ast module. Said AST is visited through the Visitor pattern all the metadata available are extractred and agglomerated in a single comprehensive struct.

Package static_analysis declares the types used to represent metadata extracted from the Go source. The source code is transformed to an Abstract Syntax Tree via go/ast module. Said AST is visited through the Visitor pattern all the metadata available are extractred and agglomerated in a single comprehensive struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgType

type ArgType int // Enum of the arguments type that we're interested in
const (
	Function ArgType = iota // Possible value of FuncArg.type
	Channel
)

type ChanMetadata

type ChanMetadata struct {
	Name  string // The name of the channel
	Type  string // The type of message the channel supports (int, string, interface{}, ...)
	Async bool   // Is the channel unbuffered (synchronous) or buffered (asynchronous)
}

A ChanMetadata contains the metadata available about a Go channel

A struct containing all the metadata that the Visitor algorithm has been able to extrapolate. This kind of date are derived both from channel declaration and assignment. Only the channel declared in the file are evaluated (channel returned from function call or imported from another module are ignored)

type FileMetadata

type FileMetadata struct {
	GlobalChanMeta map[string]ChanMetadata // The channel declared in the global scope
	FunctionMeta   map[string]FuncMetadata // The top-level function declared in the file
}

A FileMetadata contains the metadata available about a Go source file

A struct containing all the metadata that the Visitor has been able to gather from the parsed file. The data are structured hierarchically: Module -> File -> Function -> Channels

func ExtractMetadata

func ExtractMetadata(filePath string, traceOpts TraceMode) FileMetadata

Parses the file identified by the given path, if the latter is valid, if the user opted in the available trace option handles the traces as well then extracts the metadata from the AST and returns said metadata to the caller

func (FileMetadata) Visit

func (fm FileMetadata) Visit(node ast.Node) ast.Visitor

In order to satisfy the ast.Visitor interface FileMetadata implements the Visit() method with this function signature. The Visit method takes as only argument an ast.Node interface and evaluates all the meaningful cases, when the function steps into that it tries to extract metada from the subtree

type FuncArg

type FuncArg struct {
	Offset int     // The position of the arg in the function declaration
	Name   string  // The identifier of the argument inside the function
	Type   ArgType // The type of the argument (only Function or Channel)
}

type FuncMetadata

type FuncMetadata struct {
	Name       string                  // The identifier of the function
	ChanMeta   map[string]ChanMetadata // The channels available inside the function scope
	InlineArgs []FuncArg               // The argument of the function to be inlined (Callbacks/Functions or Channels)
	Automaton  *fsa.FSA                // A graph representing the transition made inside the function body
}

A FuncMetadata contains the metadata available about a Go function

A struct containing all the metadata that the algorithm has been able to extrapolate from the function declaration. Only the function declared in the file by the user are evaluated (built-in and external functions are ignored)

func (FuncMetadata) Visit

func (fm FuncMetadata) Visit(node ast.Node) ast.Visitor

In order to satisfy the ast.Visitor interface FuncMetadata implements the Visit() method with this function signature. The Visit method takes as only argument an ast.Node interface and evaluates all the meaningful cases, when the function steps into that it tries to extract metada from the subtree

type TraceMode

type TraceMode int

Simple type alias to wrap trace option definition

const (
	NoTrace TraceMode = iota
	Trace
)

Jump to

Keyboard shortcuts

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