function

package
v0.0.0-...-bd4d0b6 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 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

func (f *FuncPos) Repr() string

type Graph

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

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

func (*Graph) DirectReferencedCount

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

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

func (*Graph) DrawDot

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

func (*Graph) DrawG6Html

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

func (*Graph) Dump

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

func (*Graph) DumpFile

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

func (*Graph) EntryIds

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

func (*Graph) FileCount

func (fg *Graph) FileCount() int

func (*Graph) FillWithOrange

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

func (*Graph) FillWithRed

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

func (*Graph) FillWithYellow

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

func (*Graph) FilterFunctions

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

func (*Graph) FuncCount

func (fg *Graph) FuncCount() int

func (*Graph) GetById

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

func (*Graph) GetFunctionsByFile

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

func (*Graph) GetFunctionsByFileLines

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

func (*Graph) GlobalStat

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

func (*Graph) ListEntries

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

func (*Graph) ListFiles

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

func (*Graph) ListFunctions

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

func (*Graph) RelationBetween

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

func (*Graph) RemoveNodeById

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

func (*Graph) Stat

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

func (*Graph) ToDirGraph

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

func (*Graph) ToFileGraph

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

func (*Graph) ToG6Data

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

func (*Graph) TransitiveReferenceIds

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

func (*Graph) TransitiveReferencedIds

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

type Vertex struct {
	*object.Function
	*FuncPos

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

func CreateFuncVertex

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

func (*Vertex) AddTag

func (fv *Vertex) AddTag(tag string)

func (*Vertex) ContainTag

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

func (*Vertex) Id

func (fv *Vertex) Id() string

func (*Vertex) ListTags

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

func (*Vertex) PosKey

func (fv *Vertex) PosKey() string

func (*Vertex) RemoveTag

func (fv *Vertex) RemoveTag(tag string)

Jump to

Keyboard shortcuts

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