extractor

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PathStandardize

func PathStandardize(results []*FileResult, basedir string) error

func RegisterExtractor added in v0.15.2

func RegisterExtractor(langType core.LangType, extractor Extractor)

Types

type BaseFileResult

type BaseFileResult[T DataType] struct {
	Path     string        `json:"path"`
	Language core.LangType `json:"language"`
	Type     string        `json:"type"`
	Units    []T           `json:"units"`
}

func (*BaseFileResult[T]) IsEmpty added in v0.16.0

func (b *BaseFileResult[T]) IsEmpty() bool

type Call

type Call = object.Call

type CallFileResult

type CallFileResult = BaseFileResult[*Call]

type CallSupport

type CallSupport interface {
	IsCall(unit *core.Unit) bool
	ExtractCalls([]*core.Unit) ([]*Call, error)
}

type ClassSupport added in v0.10.0

type ClassSupport interface {
	IsClass(*core.Unit) bool
	ExtractClasses([]*core.Unit) ([]*Clazz, error)
	ExtractClass(*core.Unit) (*Clazz, error)
}

type Clazz added in v0.10.0

type Clazz = object.Clazz

type ClazzFileResult added in v0.10.0

type ClazzFileResult = BaseFileResult[*Clazz]

type ClazzWithPath added in v0.16.0

type ClazzWithPath struct {
	*Clazz `bson:",inline"`
	Path   string `json:"path"`
}

type DataType

type DataType interface {
	GetIndexName() string // for query and locate from outside
	GetDesc() string      // easy to understand what it actually contains
	GetSpan() *core.Span
}

func DataTypeOf

func DataTypeOf[T DataType](dataList []T) []DataType

type DataTypes

type DataTypes = []DataType

type ExtractType

type ExtractType = string
const (
	TypeExtractFunction ExtractType = "func"
	TypeExtractSymbol   ExtractType = "symbol"
	TypeExtractCall     ExtractType = "call"
	TypeExtractClazz    ExtractType = "class"
)

these extractors are independent with each other

type Extractor

type Extractor interface {
	GetLang() core.LangType
	SymbolSupport
	FunctionSupport
	CallSupport
	ClassSupport
}

Extractor

in tree-sitter, a specific language is ruled by grammar.js. https://github.com/tree-sitter/tree-sitter-java/blob/master/grammar.js

unlike other projects, we will only keep the necessary parts, not the whole grammar rule

func GetExtractor

func GetExtractor(lang core.LangType) Extractor

type FileResult

type FileResult = BaseFileResult[DataType]

type Function

type Function = object.Function

type FunctionFileResult

type FunctionFileResult = BaseFileResult[*Function]

type FunctionSupport

type FunctionSupport interface {
	IsFunction(*core.Unit) bool
	ExtractFunctions([]*core.Unit) ([]*Function, error)
	ExtractFunction(*core.Unit) (*Function, error)
}

type FunctionWithPath added in v0.16.0

type FunctionWithPath struct {
	*Function `bson:",inline"`
	Path      string `json:"path" bson:"path"`
}

FunctionWithPath original symbol and function do not have a path because they maybe not come from a real file

func WrapFuncWithPath added in v0.16.0

func WrapFuncWithPath(f *Function, p string) *FunctionWithPath

func (*FunctionWithPath) GetDescWithPath added in v0.16.0

func (fwp *FunctionWithPath) GetDescWithPath() string

type Symbol

type Symbol = object.Symbol

type SymbolFileResult

type SymbolFileResult = BaseFileResult[*Symbol]

type SymbolSupport

type SymbolSupport interface {
	IsSymbol(*core.Unit) bool
	ExtractSymbols([]*core.Unit) ([]*Symbol, error)
}

type SymbolWithPath added in v0.16.0

type SymbolWithPath struct {
	*Symbol `bson:",inline"`
	Path    string `json:"path"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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