extractor

package
v0.10.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Map2Func = object.Map2Func

Functions

func PathStandardize

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

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"`
}

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 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 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 ValueUnit

type ValueUnit = object.ValueUnit

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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