Documentation ¶
Index ¶
- Constants
- func PathStandardize(results []*FileResult, basedir string) error
- type BaseFileResult
- type Call
- type CallFileResult
- type CallSupport
- type DataType
- type DataTypes
- type ExtractType
- type Extractor
- type FileResult
- type FuncSignature
- type Function
- type FunctionFileResult
- type FunctionSupport
- type GolangExtractor
- func (extractor *GolangExtractor) ExtractCalls(units []*core.Unit) ([]*Call, error)
- func (extractor *GolangExtractor) ExtractFunction(unit *core.Unit) (*Function, error)
- func (extractor *GolangExtractor) ExtractFunctions(units []*core.Unit) ([]*Function, error)
- func (extractor *GolangExtractor) ExtractSymbols(unit []*core.Unit) ([]*Symbol, error)
- func (extractor *GolangExtractor) GetLang() core.LangType
- func (extractor *GolangExtractor) IsCall(unit *core.Unit) bool
- func (extractor *GolangExtractor) IsFunction(unit *core.Unit) bool
- func (extractor *GolangExtractor) IsSymbol(unit *core.Unit) bool
- type GolangFuncExtras
- type JavaClassInfo
- type JavaExtractor
- func (extractor *JavaExtractor) ExtractCalls(units []*core.Unit) ([]*Call, error)
- func (extractor *JavaExtractor) ExtractFunction(unit *core.Unit) (*Function, error)
- func (extractor *JavaExtractor) ExtractFunctions(units []*core.Unit) ([]*Function, error)
- func (extractor *JavaExtractor) ExtractSymbols(units []*core.Unit) ([]*Symbol, error)
- func (extractor *JavaExtractor) GetLang() core.LangType
- func (extractor *JavaExtractor) IsCall(unit *core.Unit) bool
- func (extractor *JavaExtractor) IsFunction(unit *core.Unit) bool
- func (extractor *JavaExtractor) IsSymbol(unit *core.Unit) bool
- type JavaFunctionExtras
- type PythonExtractor
- func (extractor *PythonExtractor) ExtractCalls(units []*core.Unit) ([]*Call, error)
- func (extractor *PythonExtractor) ExtractFunction(unit *core.Unit) (*Function, error)
- func (extractor *PythonExtractor) ExtractFunctions(units []*core.Unit) ([]*Function, error)
- func (extractor *PythonExtractor) ExtractSymbols(units []*core.Unit) ([]*Symbol, error)
- func (extractor *PythonExtractor) GetLang() core.LangType
- func (extractor *PythonExtractor) IsCall(unit *core.Unit) bool
- func (extractor *PythonExtractor) IsFunction(unit *core.Unit) bool
- func (extractor *PythonExtractor) IsSymbol(unit *core.Unit) bool
- type PythonFunctionExtras
- type Symbol
- type SymbolFileResult
- type SymbolSupport
- type ValueUnit
Constants ¶
const ( KindGolangMethodDecl core.KindRepr = "method_declaration" KindGolangFuncDecl core.KindRepr = "function_declaration" KindGolangIdentifier core.KindRepr = "identifier" KindGolangFieldIdentifier core.KindRepr = "field_identifier" KindGolangTypeIdentifier core.KindRepr = "type_identifier" KindGolangParameterList core.KindRepr = "parameter_list" KindGolangParameterDecl core.KindRepr = "parameter_declaration" KindGolangCallExpression core.KindRepr = "call_expression" FieldGolangType core.KindRepr = "type" FieldGolangName core.KindRepr = "name" FieldGolangParameters core.KindRepr = "parameters" FieldGolangFunction core.KindRepr = "function" FieldGolangArguments core.KindRepr = "arguments" FieldGolangResult core.KindRepr = "result" )
https://github.com/tree-sitter/tree-sitter-go/blob/master/src/node-types.json
const ( KindJavaProgram core.KindRepr = "program" KindJavaProgramDeclaration core.KindRepr = "package_declaration" KindJavaScopeIdentifier core.KindRepr = "scoped_identifier" KindJavaIdentifier core.KindRepr = "identifier" KindJavaClassDeclaration core.KindRepr = "class_declaration" KindJavaEnumDeclaration core.KindRepr = "enum_declaration" KindJavaInterfaceDeclaration core.KindRepr = "interface_declaration" KindJavaMethodDeclaration core.KindRepr = "method_declaration" KindJavaFormalParameters core.KindRepr = "formal_parameters" KindJavaFormalParameter core.KindRepr = "formal_parameter" KindJavaMethodInvocation core.KindRepr = "method_invocation" KindJavaModifiers core.KindRepr = "modifiers" KindJavaAnnotation core.KindRepr = "annotation" KindJavaMarkerAnnotation core.KindRepr = "marker_annotation" KindJavaBlock core.KindRepr = "block" FieldJavaType core.KindRepr = "type" FieldJavaDimensions core.KindRepr = "dimensions" FieldJavaObject core.KindRepr = "object" FieldJavaName core.KindRepr = "name" FieldJavaArguments core.KindRepr = "arguments" )
https://github.com/tree-sitter/tree-sitter-java/tree/master/src/node-types.json
const ( KindPythonFunctionDefinition core.KindRepr = "function_definition" KindPythonIdentifier core.KindRepr = "identifier" KindPythonDecoratedDefinition core.KindRepr = "decorated_definition" KindPythonDecorator core.KindRepr = "decorator" KindPythonBlock core.KindRepr = "block" )
https://github.com/tree-sitter/tree-sitter-python/blob/master/src/node-types.json
Variables ¶
This section is empty.
Functions ¶
func PathStandardize ¶
func PathStandardize(results []*FileResult, basedir string) error
Types ¶
type BaseFileResult ¶
type Call ¶
type Call struct { Src string `json:"src"` Caller string `json:"caller"` Arguments []string `json:"arguments"` Span core.Span `json:"span"` }
Call NON-PRECISE
func aFunc() { a.b(c, d) } aFunc == Src a.b == caller [c, d] == arguments
func (*Call) GetIndexName ¶
type CallFileResult ¶
type CallFileResult = BaseFileResult[*Call]
type CallSupport ¶
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 ¶
type ExtractType ¶
type ExtractType = string
const ( TypeExtractFunction ExtractType = "func" TypeExtractSymbol ExtractType = "symbol" TypeExtractCall ExtractType = "call" )
these extractors are independent with each other
type Extractor ¶
type Extractor interface { GetLang() core.LangType SymbolSupport FunctionSupport CallSupport }
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 ¶
type FileResult ¶
type FileResult = BaseFileResult[DataType]
type FuncSignature ¶
type FuncSignature = string
type Function ¶
type Function struct { Name string `json:"name"` Receiver string `json:"receiver"` Parameters []*ValueUnit `json:"parameters"` Returns []*ValueUnit `json:"returns"` // this span will include header and content Span core.Span `json:"span"` // which includes only body BodySpan core.Span `json:"bodySpan"` // which contains language-specific contents Extras interface{} `json:"extras"` // contains filtered or unexported fields }
func NewFunction ¶
func NewFunction() *Function
func (*Function) GetIndexName ¶
func (*Function) GetSignature ¶
func (f *Function) GetSignature() FuncSignature
type FunctionFileResult ¶
type FunctionFileResult = BaseFileResult[*Function]
type FunctionSupport ¶
type GolangExtractor ¶
type GolangExtractor struct { }
func (*GolangExtractor) ExtractCalls ¶
func (extractor *GolangExtractor) ExtractCalls(units []*core.Unit) ([]*Call, error)
func (*GolangExtractor) ExtractFunction ¶
func (extractor *GolangExtractor) ExtractFunction(unit *core.Unit) (*Function, error)
func (*GolangExtractor) ExtractFunctions ¶
func (extractor *GolangExtractor) ExtractFunctions(units []*core.Unit) ([]*Function, error)
func (*GolangExtractor) ExtractSymbols ¶
func (extractor *GolangExtractor) ExtractSymbols(unit []*core.Unit) ([]*Symbol, error)
func (*GolangExtractor) GetLang ¶
func (extractor *GolangExtractor) GetLang() core.LangType
func (*GolangExtractor) IsFunction ¶
func (extractor *GolangExtractor) IsFunction(unit *core.Unit) bool
type GolangFuncExtras ¶
type GolangFuncExtras struct { }
type JavaClassInfo ¶
type JavaExtractor ¶
type JavaExtractor struct { }
func (*JavaExtractor) ExtractCalls ¶
func (extractor *JavaExtractor) ExtractCalls(units []*core.Unit) ([]*Call, error)
func (*JavaExtractor) ExtractFunction ¶
func (extractor *JavaExtractor) ExtractFunction(unit *core.Unit) (*Function, error)
func (*JavaExtractor) ExtractFunctions ¶
func (extractor *JavaExtractor) ExtractFunctions(units []*core.Unit) ([]*Function, error)
func (*JavaExtractor) ExtractSymbols ¶
func (extractor *JavaExtractor) ExtractSymbols(units []*core.Unit) ([]*Symbol, error)
func (*JavaExtractor) GetLang ¶
func (extractor *JavaExtractor) GetLang() core.LangType
func (*JavaExtractor) IsFunction ¶
func (extractor *JavaExtractor) IsFunction(unit *core.Unit) bool
type JavaFunctionExtras ¶
type JavaFunctionExtras struct { Annotations []string `json:"annotations"` ClassInfo *JavaClassInfo `json:"classInfo"` }
JavaFunctionExtras
type PythonExtractor ¶
type PythonExtractor struct { }
func (*PythonExtractor) ExtractCalls ¶
func (extractor *PythonExtractor) ExtractCalls(units []*core.Unit) ([]*Call, error)
func (*PythonExtractor) ExtractFunction ¶
func (extractor *PythonExtractor) ExtractFunction(unit *core.Unit) (*Function, error)
func (*PythonExtractor) ExtractFunctions ¶
func (extractor *PythonExtractor) ExtractFunctions(units []*core.Unit) ([]*Function, error)
func (*PythonExtractor) ExtractSymbols ¶
func (extractor *PythonExtractor) ExtractSymbols(units []*core.Unit) ([]*Symbol, error)
func (*PythonExtractor) GetLang ¶
func (extractor *PythonExtractor) GetLang() core.LangType
func (*PythonExtractor) IsFunction ¶
func (extractor *PythonExtractor) IsFunction(unit *core.Unit) bool
type PythonFunctionExtras ¶
type PythonFunctionExtras struct {
Decorators []string `json:"decorators"`
}
type Symbol ¶
type Symbol struct { Symbol string `json:"symbol"` Kind string `json:"kind"` Span core.Span `json:"span"` FieldName string `json:"fieldName"` // contains filtered or unexported fields }
Symbol Units are named identifiers driven by the ASTs
https://github.com/github/semantic/blob/main/docs/examples.md#symbols https://github.com/github/semantic/blob/main/proto/semantic.proto
message Unit { string symbol = 1; string kind = 2; Span span = 4; NodeType node_type = 6; SyntaxType syntax_type = 7; } enum NodeType { ROOT_SCOPE = 0; JUMP_TO_SCOPE = 1; EXPORTED_SCOPE = 2; DEFINITION = 3; REFERENCE = 4; } enum SyntaxType { FUNCTION = 0; METHOD = 1; CLASS = 2; MODULE = 3; CALL = 4; TYPE = 5; INTERFACE = 6; IMPLEMENTATION = 7; }
func (*Symbol) GetIndexName ¶
type SymbolFileResult ¶
type SymbolFileResult = BaseFileResult[*Symbol]
type SymbolSupport ¶
Source Files ¶
- extractor_base.go
- extractor_golang.go
- extractor_golang_call.go
- extractor_golang_func.go
- extractor_golang_symbol.go
- extractor_java.go
- extractor_java_call.go
- extractor_java_func.go
- extractor_java_symbol.go
- extractor_python.go
- object_call.go
- object_datatype.go
- object_file.go
- object_func.go
- object_symbol.go