gondex

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

gondex

GO source code indexer

Create indexer

indexer := gondex.CreateIndexer()
if e := indexer.Load(); e != nil {
    panic(e)
}

Find all structs by annotation

items := indexer.FindStructByAnnotation("gluon:Config")
for _, item := range items {
    fmt.Printf("Struct: %v\n", item.Id())
}

Find all implementation of the interface

s := indexer.FindInterfaceImplementation("github.com/go-gluon/generator/test/user.TestI")
for _, t := range s {
    fmt.Printf("Struct: %v\n", t.Id())
}    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotationInfo

type AnnotationInfo struct {
	Name   string
	Params map[string]string
}

AnnotationInfo represents annotation

type AstFuncDecl

type AstFuncDecl struct {
	// contains filtered or unexported fields
}

AstFuncDecl ast function declaration

func (*AstFuncDecl) Annotations

func (a *AstFuncDecl) Annotations() []*AnnotationInfo

Annotations returns list of annotations

func (*AstFuncDecl) FuncType

func (a *AstFuncDecl) FuncType() *ast.FuncType

FuncType struct type of the type

type AstInfo

type AstInfo struct {
	// contains filtered or unexported fields
}

AstInfo syntax info

type AstTypeDecl

type AstTypeDecl struct {
	// contains filtered or unexported fields
}

AstFuncDecl ast type declaration

func (*AstTypeDecl) Annotations

func (a *AstTypeDecl) Annotations() []*AnnotationInfo

Annotations returns list of annotations

func (*AstTypeDecl) GenDecl

func (a *AstTypeDecl) GenDecl() *ast.GenDecl

GenDecl struct type of the type

func (*AstTypeDecl) InterfaceType

func (a *AstTypeDecl) InterfaceType() *ast.InterfaceType

InterfaceType struct type of the type

func (*AstTypeDecl) StructType

func (a *AstTypeDecl) StructType() *ast.StructType

StructType struct type of the type

type FunctionInfo

type FunctionInfo struct {
	// contains filtered or unexported fields
}

FunctionInfo represents function

func (*FunctionInfo) Decl

func (s *FunctionInfo) Decl() *AstFuncDecl

Decl ast declaration of the type

type Indexer

type Indexer struct {
	// contains filtered or unexported fields
}

Indexer hold the information about the packages and types

func CreateIndexer

func CreateIndexer() *Indexer

CreateIndexer creates indexer

func (*Indexer) FindInterfaceByAnnotation

func (indexer *Indexer) FindInterfaceByAnnotation(name string) []*StructInfo

FindInterfaceByAnnotation find all interfaces by annotation

func (*Indexer) FindInterfaceImplementation

func (indexer *Indexer) FindInterfaceImplementation(name string) []*StructInfo

FindInterfaceImplementation find all interface implementations

func (*Indexer) FindStructByAnnotation

func (indexer *Indexer) FindStructByAnnotation(name string) []*StructInfo

FindStructByAnnotation find all structs by annotation

func (*Indexer) Interfaces

func (indexer *Indexer) Interfaces() map[string]*InterfaceInfo

Interfaces return map of all interfaces

func (*Indexer) Load

func (indexer *Indexer) Load() error

Load load packages by default pattern ./...

func (*Indexer) LoadPattern

func (indexer *Indexer) LoadPattern(pattern string) error

LoadPattern load packages by the pattern to the indexer

func (*Indexer) Packages

func (indexer *Indexer) Packages() map[string]*PackageInfo

Packages return map of all packages

func (*Indexer) Structs

func (indexer *Indexer) Structs() map[string]*StructInfo

Structs return map of all structs

type InterfaceInfo

type InterfaceInfo struct {
	// contains filtered or unexported fields
}

InterfaceInfo represents interface

func (*InterfaceInfo) Annotations

func (s *InterfaceInfo) Annotations() []*AnnotationInfo

Annotations returns list of interface annotations or emtpy list

func (*InterfaceInfo) Ast

func (s *InterfaceInfo) Ast() *AstTypeDecl

Ast ast declaration of the type

func (*InterfaceInfo) Id

func (s *InterfaceInfo) Id() string

Id of the interface

func (*InterfaceInfo) Name

func (s *InterfaceInfo) Name() string

Name of the interface

type PackageInfo

type PackageInfo struct {
	// contains filtered or unexported fields
}

PackageInfo struct represents the package information

func (*PackageInfo) Data

func (p *PackageInfo) Data() *packages.Package

Data of the package

func (*PackageInfo) Id

func (p *PackageInfo) Id() string

ID of the package

type StructInfo

type StructInfo struct {
	// contains filtered or unexported fields
}

StructInfo information about the struct

func (*StructInfo) Annotations

func (s *StructInfo) Annotations() []*AnnotationInfo

Annotations returns list of struct annotations of empty list

func (*StructInfo) Ast

func (s *StructInfo) Ast() *AstTypeDecl

Ast ast declaration of the type

func (*StructInfo) Id

func (s *StructInfo) Id() string

Id of the struct

func (*StructInfo) Name

func (s *StructInfo) Name() string

Name this is the name of the struct

func (*StructInfo) Named

func (s *StructInfo) Named() *types.Named

Named type named of struct

func (*StructInfo) Package

func (s *StructInfo) Package() *PackageInfo

Package struct package info

func (*StructInfo) Struct

func (s *StructInfo) Struct() *types.Struct

Struct type of struct

Jump to

Keyboard shortcuts

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