function

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagYellow = "yellow"
	TagRed    = "red"
	TagOrange = "orange"
)
View Source
const (
	TagEntry = "entry"
)

Variables

This section is empty.

Functions

func FuncGraph2FileGraph

func FuncGraph2FileGraph(f graph.Graph[string, *Vertex], g graph.Graph[string, *file.Vertex]) error

Types

type FactStorage

type FactStorage struct {
	// contains filtered or unexported fields
}

FactStorage fact is some extra metadata extracted from source code something like: function definitions with their annotations/params/receiver ... these data can be used for enhancing relationship

func CreateFact

func CreateFact(root string, lang core.LangType) (*FactStorage, error)

func (*FactStorage) GetFunctionsByFile

func (fs *FactStorage) GetFunctionsByFile(fileName string) *extractor.FunctionFileResult

func (*FactStorage) GetSymbolsByFileAndLine

func (fs *FactStorage) GetSymbolsByFileAndLine(fileName string, line int) []*extractor.Symbol

type FgStorage

type FgStorage struct {
	VertexIds map[int]string       `json:"vertexIds"`
	GEdges    map[int][]int        `json:"gEdges"`
	RGEdges   map[int][]int        `json:"rgEdges"`
	Cache     map[string][]*Vertex `json:"cache"`
}

type FuncPos

type FuncPos struct {
	Path  string `json:"path,omitempty"`
	Lang  string `json:"lang,omitempty"`
	Start int    `json:"start,omitempty"`
	End   int    `json:"end,omitempty"`
}

func (*FuncPos) Repr added in v0.9.4

func (f *FuncPos) Repr() string

type Graph added in v0.10.1

type Graph struct {

	// k: file, v: function
	Cache map[string][]*Vertex
	// k: id, v: function
	IdCache map[string]*Vertex
	// contains filtered or unexported fields
}

func CreateFuncGraph

func CreateFuncGraph(fact *FactStorage, relationship *object.SourceContext) (*Graph, error)

func CreateFuncGraphFromDirWithLSIF

func CreateFuncGraphFromDirWithLSIF(src string, lsifFile string, lang core.LangType) (*Graph, error)

func CreateFuncGraphFromDirWithSCIP

func CreateFuncGraphFromDirWithSCIP(src string, scipFile string, lang core.LangType) (*Graph, error)

func CreateFuncGraphFromGolangDir

func CreateFuncGraphFromGolangDir(src string) (*Graph, error)

func Load

func Load(fgs *FgStorage) (*Graph, error)

func LoadFile

func LoadFile(fp string) (*Graph, error)

func NewEmptyFuncGraph

func NewEmptyFuncGraph() *Graph

func (*Graph) DirectReferenceIds added in v0.10.1

func (fg *Graph) DirectReferenceIds(f *Vertex) []string

func (*Graph) DirectReferencedCount added in v0.10.1

func (fg *Graph) DirectReferencedCount(f *Vertex) int

DirectReferencedCount This function returns the number of direct references to a given function vertex in the function graph. It does so by counting the length of the slice of IDs of the function vertices that directly reference the given function vertex.

func (*Graph) DirectReferencedIds added in v0.10.1

func (fg *Graph) DirectReferencedIds(f *Vertex) []string

func (*Graph) DrawDot added in v0.10.1

func (fg *Graph) DrawDot(filename string) error

func (*Graph) DrawG6Html added in v0.10.1

func (fg *Graph) DrawG6Html(filename string) error

func (*Graph) Dump added in v0.10.1

func (fg *Graph) Dump() (*FgStorage, error)

func (*Graph) DumpFile added in v0.10.1

func (fg *Graph) DumpFile(fp string) error

func (*Graph) EntryIds added in v0.10.1

func (fg *Graph) EntryIds(f *Vertex) []string

func (*Graph) FileCount added in v0.10.1

func (fg *Graph) FileCount() int

func (*Graph) FillWithOrange added in v0.10.1

func (fg *Graph) FillWithOrange(vertexHash string) error

func (*Graph) FillWithRed added in v0.10.1

func (fg *Graph) FillWithRed(vertexHash string) error

func (*Graph) FillWithYellow added in v0.10.1

func (fg *Graph) FillWithYellow(vertexHash string) error

func (*Graph) FilterFunctions added in v0.10.1

func (fg *Graph) FilterFunctions(f func(*Vertex) bool) []*Vertex

func (*Graph) FuncCount added in v0.10.1

func (fg *Graph) FuncCount() int

func (*Graph) GetById added in v0.10.1

func (fg *Graph) GetById(id string) (*Vertex, error)

func (*Graph) GetFunctionsByFile added in v0.10.1

func (fg *Graph) GetFunctionsByFile(fileName string) []*Vertex

func (*Graph) GetFunctionsByFileLines added in v0.10.1

func (fg *Graph) GetFunctionsByFileLines(fileName string, lines []int) []*Vertex

func (*Graph) GlobalStat added in v0.10.2

func (fg *Graph) GlobalStat(points []*Vertex) *object.StatGlobal

func (*Graph) ListEntries added in v0.10.1

func (fg *Graph) ListEntries() []*Vertex

func (*Graph) ListFiles added in v0.10.1

func (fg *Graph) ListFiles() []string

func (*Graph) ListFunctions added in v0.10.1

func (fg *Graph) ListFunctions() []*Vertex

func (*Graph) RelationBetween added in v0.10.1

func (fg *Graph) RelationBetween(a string, b string) (*common.EdgeStorage, error)

func (*Graph) RemoveNodeById added in v0.10.1

func (fg *Graph) RemoveNodeById(funcId string) error

func (*Graph) Stat added in v0.10.1

func (fg *Graph) Stat(f *Vertex) *object.ImpactUnit

func (*Graph) ToDirGraph added in v0.10.1

func (fg *Graph) ToDirGraph() (*file.Graph, error)

func (*Graph) ToFileGraph added in v0.10.1

func (fg *Graph) ToFileGraph() (*file.Graph, error)

func (*Graph) ToG6Data added in v0.10.1

func (fg *Graph) ToG6Data() (*g6.Data, error)

func (*Graph) TransitiveReferenceIds added in v0.10.1

func (fg *Graph) TransitiveReferenceIds(f *Vertex) []string

func (*Graph) TransitiveReferencedIds added in v0.10.1

func (fg *Graph) TransitiveReferencedIds(f *Vertex) []string

TransitiveReferencedIds This function takes a Graph and a Vertex as input and returns a slice of strings containing all the transitive referenced ids. It uses a map to store the referenced ids and a BFS algorithm to traverse the graph and add the referenced ids to the map. Finally, it returns the keys of the map as a slice of strings.

type Vertex added in v0.10.1

type Vertex struct {
	*object.Function
	*FuncPos

	// https://github.com/williamfzc/srctx/issues/41
	Tags map[string]struct{} `json:"tags,omitempty"`
}

func CreateFuncVertex

func CreateFuncVertex(f *object.Function, fr *extractor.FunctionFileResult) *Vertex

func (*Vertex) AddTag added in v0.10.1

func (fv *Vertex) AddTag(tag string)

func (*Vertex) ContainTag added in v0.10.1

func (fv *Vertex) ContainTag(tag string) bool

func (*Vertex) Id added in v0.10.1

func (fv *Vertex) Id() string

func (*Vertex) ListTags added in v0.10.1

func (fv *Vertex) ListTags() []string

func (*Vertex) PosKey added in v0.10.1

func (fv *Vertex) PosKey() string

func (*Vertex) RemoveTag added in v0.10.1

func (fv *Vertex) RemoveTag(tag string)

Jump to

Keyboard shortcuts

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