function

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2023 License: Apache-2.0 Imports: 17 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, *FuncVertex], 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][]*FuncVertex `json:"cache"`
}

type FuncGraph

type FuncGraph struct {

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

func CreateFuncGraph

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

func CreateFuncGraphFromDirWithLSIF

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

func CreateFuncGraphFromDirWithSCIP

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

func CreateFuncGraphFromGolangDir

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

func Load

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

func LoadFile

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

func NewEmptyFuncGraph

func NewEmptyFuncGraph() *FuncGraph

func (*FuncGraph) DirectReferenceIds added in v0.9.4

func (fg *FuncGraph) DirectReferenceIds(f *FuncVertex) []string

func (*FuncGraph) DirectReferencedCount added in v0.9.4

func (fg *FuncGraph) DirectReferencedCount(f *FuncVertex) 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 (*FuncGraph) DirectReferencedIds added in v0.9.4

func (fg *FuncGraph) DirectReferencedIds(f *FuncVertex) []string

func (*FuncGraph) DrawDot

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

func (*FuncGraph) DrawG6Html

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

func (*FuncGraph) Dump

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

func (*FuncGraph) DumpFile

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

func (*FuncGraph) EntryIds added in v0.10.0

func (fg *FuncGraph) EntryIds(f *FuncVertex) []string

func (*FuncGraph) FileCount added in v0.9.4

func (fg *FuncGraph) FileCount() int

func (*FuncGraph) FillWithOrange added in v0.10.0

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

func (*FuncGraph) FillWithRed

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

func (*FuncGraph) FillWithYellow

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

func (*FuncGraph) FilterFunctions added in v0.10.0

func (fg *FuncGraph) FilterFunctions(f func(*FuncVertex) bool) []*FuncVertex

func (*FuncGraph) FuncCount

func (fg *FuncGraph) FuncCount() int

func (*FuncGraph) GetById

func (fg *FuncGraph) GetById(id string) (*FuncVertex, error)

func (*FuncGraph) GetFunctionsByFile

func (fg *FuncGraph) GetFunctionsByFile(fileName string) []*FuncVertex

func (*FuncGraph) GetFunctionsByFileLines

func (fg *FuncGraph) GetFunctionsByFileLines(fileName string, lines []int) []*FuncVertex

func (*FuncGraph) ListEntries added in v0.10.0

func (fg *FuncGraph) ListEntries() []*FuncVertex

func (*FuncGraph) ListFiles added in v0.9.4

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

func (*FuncGraph) ListFunctions added in v0.10.0

func (fg *FuncGraph) ListFunctions() []*FuncVertex

func (*FuncGraph) RemoveNodeById

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

func (*FuncGraph) Stat

func (fg *FuncGraph) Stat(f *FuncVertex) *object.ImpactUnit

func (*FuncGraph) ToDirGraph

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

func (*FuncGraph) ToFileGraph

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

func (*FuncGraph) ToG6Data

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

func (*FuncGraph) TransitiveReferenceIds

func (fg *FuncGraph) TransitiveReferenceIds(f *FuncVertex) []string

func (*FuncGraph) TransitiveReferencedIds

func (fg *FuncGraph) TransitiveReferencedIds(f *FuncVertex) []string

TransitiveReferencedIds This function takes a FuncGraph and a FuncVertex 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 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 FuncVertex

type FuncVertex struct {
	*object2.Function
	*FuncPos

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

func (*FuncVertex) AddTag added in v0.10.0

func (fv *FuncVertex) AddTag(tag string)

func (*FuncVertex) ContainTag added in v0.10.0

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

func (*FuncVertex) Id

func (fv *FuncVertex) Id() string

func (*FuncVertex) ListTags added in v0.10.0

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

func (*FuncVertex) PosKey

func (fv *FuncVertex) PosKey() string

func (*FuncVertex) RemoveTag added in v0.10.0

func (fv *FuncVertex) RemoveTag(tag string)

Jump to

Keyboard shortcuts

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