Documentation ¶
Index ¶
- Constants
- func EmbededFieldsPath(embedding *EmbeddedField, b *strings.Builder, selName string, isField bool) (r string)
- func Kind(tt types.Type) reflect.Kind
- func PrintSelectors(title string, selectors []*Selector)
- type AstNode
- type AstValueSpecOwner
- type Attribute
- type CodeAnalyzer
- func (d *CodeAnalyzer) AnalyzePackages(onSubTaskDone func(int, time.Duration, ...int32))
- func (d *CodeAnalyzer) BuildCgoFileMappings(pkg *Package)
- func (d *CodeAnalyzer) BuildMethodSignatureFromFuncObject(funcObj *types.Func) MethodSignature
- func (d *CodeAnalyzer) BuildMethodSignatureFromFunctionSignature(funcSig *types.Signature, methodName string, pkgImportPath string) MethodSignature
- func (d *CodeAnalyzer) BuiltinPackge() *Package
- func (d *CodeAnalyzer) CacheSourceFiles()
- func (d *CodeAnalyzer) CheckTypeMethodContributingToTypeImplementations(pkg, typ, methodPkg, method string) bool
- func (d *CodeAnalyzer) CleanImplements(self *TypeInfo) []Implementation
- func (d *CodeAnalyzer) CollectIdentiferFromFile(pkg *Package, fileInfo *SourceFileInfo)
- func (d *CodeAnalyzer) CollectObjectReferences()
- func (d *CodeAnalyzer) CollectSourceFiles()
- func (d *CodeAnalyzer) Id1(p *types.Package, name string) string
- func (d *CodeAnalyzer) Id1b(pkg *Package, name string) string
- func (d *CodeAnalyzer) Id2(p *types.Package, name string) string
- func (d *CodeAnalyzer) Id2b(pkg *Package, name string) string
- func (d *CodeAnalyzer) IsStandardPackage(pkg *Package) bool
- func (d *CodeAnalyzer) IsStandardPackageByPath(path string) bool
- func (d *CodeAnalyzer) NumPackages() int
- func (d *CodeAnalyzer) NumSourceFiles() int
- func (d *CodeAnalyzer) ObjectReferences(obj types.Object) []Identifier
- func (d *CodeAnalyzer) OriginalGoSourceFile(filename string) string
- func (d *CodeAnalyzer) PackageAt(i int) *Package
- func (d *CodeAnalyzer) PackageByPath(path string) *Package
- func (d *CodeAnalyzer) ParsePackages(onSubTaskDone func(int, time.Duration, ...int32), args ...string) bool
- func (d *CodeAnalyzer) RegisterFunction(f *Function)
- func (d *CodeAnalyzer) RegisterType(t types.Type) *TypeInfo
- func (d *CodeAnalyzer) RegisterTypeName(tn *TypeName)
- func (d *CodeAnalyzer) RetrieveTypeName(t *TypeInfo) (*TypeName, bool)
- func (d *CodeAnalyzer) RoughExportedIdentifierCount() int32
- func (d *CodeAnalyzer) RoughTypeNameCount() int32
- func (d *CodeAnalyzer) RuntimeFunctionCodePosition(f string) token.Position
- func (d *CodeAnalyzer) RuntimePackage() *Package
- func (d *CodeAnalyzer) SourceFile2Package(path string) (*Package, bool)
- func (d *CodeAnalyzer) Statistics() Stats
- func (d *CodeAnalyzer) TryRegisteringType(t types.Type, createOnNonexist bool) *TypeInfo
- type Constant
- func (c *Constant) AstValueSpec() *ast.ValueSpec
- func (c *Constant) Comment() string
- func (c *Constant) Documentation() string
- func (c *Constant) Exported() bool
- func (c *Constant) Package() *Package
- func (c *Constant) Position() token.Position
- func (c *Constant) TType() types.Type
- func (c *Constant) TypeInfo(d *CodeAnalyzer) *TypeInfo
- type EmbedMode
- type EmbeddedField
- type Field
- type Function
- func (f *Function) AstFuncType() *ast.FuncType
- func (f *Function) AstPackage() *Package
- func (f *Function) Comment() string
- func (f *Function) Documentation() string
- func (f *Function) Exported() bool
- func (f *Function) IsMethod() bool
- func (f *Function) Name() string
- func (f *Function) Package() *Package
- func (f *Function) Position() token.Position
- func (f *Function) ReceiverTypeName() (paramField *ast.Field, typeIdent *ast.Ident, isStar bool)
- func (f *Function) String() string
- func (f *Function) TType() types.Type
- func (f *Function) TypeInfo(d *CodeAnalyzer) *TypeInfo
- type FunctionResource
- type Identifier
- type Implementation
- type Import
- type InterfaceMethod
- func (im *InterfaceMethod) AstFuncType() *ast.FuncType
- func (im *InterfaceMethod) AstPackage() *Package
- func (im *InterfaceMethod) Comment() string
- func (im *InterfaceMethod) Documentation() string
- func (im *InterfaceMethod) Exported() bool
- func (im *InterfaceMethod) IsMethod() bool
- func (im *InterfaceMethod) Name() string
- func (im *InterfaceMethod) Package() *Package
- func (im *InterfaceMethod) Position() token.Position
- func (im *InterfaceMethod) ReceiverTypeName() (paramField *ast.Field, typeIdent *ast.Ident, isStar bool)
- func (im *InterfaceMethod) String() string
- func (im *InterfaceMethod) TType() types.Type
- func (im *InterfaceMethod) TypeInfo(d *CodeAnalyzer) *TypeInfo
- type Method
- type MethodSignature
- type Module
- type Package
- type PackageAnalyzeResult
- type RefPos
- type Resource
- type SelectListManager
- type Selector
- type SelectorCond
- type SeleterMapManager
- type SourceFileInfo
- type Stats
- type TypeAlias
- type TypeInfo
- type TypeName
- type TypeSource
- type ValueResource
- type Variable
- func (v *Variable) AstValueSpec() *ast.ValueSpec
- func (v *Variable) Comment() string
- func (v *Variable) Documentation() string
- func (v *Variable) Exported() bool
- func (v *Variable) Package() *Package
- func (v *Variable) Position() token.Position
- func (v *Variable) TType() types.Type
- func (v *Variable) TypeInfo(d *CodeAnalyzer) *TypeInfo
Constants ¶
View Source
const ( SubTask_PreparationDone = iota SubTask_NFilesParsed SubTask_ParsePackagesDone SubTask_CollectPackages SubTask_SortPackagesByDependencies SubTask_CollectDeclarations SubTask_CollectRuntimeFunctionPositions SubTask_FindTypeSources SubTask_CollectSelectors SubTask_CheckCollectedSelectors SubTask_FindImplementations SubTask_RegisterInterfaceMethodsForTypes SubTask_MakeStatistics SubTask_CollectSourceFiles SubTask_CollectObjectReferences SubTask_CacheSourceFiles )
View Source
const KindCount = reflect.UnsafePointer + 1
Variables ¶
This section is empty.
Functions ¶
func EmbededFieldsPath ¶
func PrintSelectors ¶
Types ¶
type AstValueSpecOwner ¶
type Attribute ¶
type Attribute uint32
const ( // Higher bits are for runtime-only flags. AtributesPersistentMask Attribute = (1 << 25) - 1 // For functions, type aliases and named types. Builtin Attribute = 1 << 0 // For type aliases and named types. Embeddable Attribute = 1 << 1 PtrEmbeddable Attribute = 1 << 2 // For unnamed struct and interface types. HasUnexporteds Attribute = 1 << 3 // For all types. Defined Attribute = 1 << 4 Comparable Attribute = 1 << 5 // For channel types. Sendable Attribute = 1 << 6 Receivable Attribute = 1 << 7 // For funcitons. Variadic Attribute = 1 << 8 )
type CodeAnalyzer ¶
type CodeAnalyzer struct {
// contains filtered or unexported fields
}
func (*CodeAnalyzer) AnalyzePackages ¶
func (d *CodeAnalyzer) AnalyzePackages(onSubTaskDone func(int, time.Duration, ...int32))
func (*CodeAnalyzer) BuildCgoFileMappings ¶
func (d *CodeAnalyzer) BuildCgoFileMappings(pkg *Package)
func (*CodeAnalyzer) BuildMethodSignatureFromFuncObject ¶
func (d *CodeAnalyzer) BuildMethodSignatureFromFuncObject(funcObj *types.Func) MethodSignature
func (*CodeAnalyzer) BuildMethodSignatureFromFunctionSignature ¶
func (d *CodeAnalyzer) BuildMethodSignatureFromFunctionSignature(funcSig *types.Signature, methodName string, pkgImportPath string) MethodSignature
pkgImportPath should be only passed for unexported method names.
func (*CodeAnalyzer) BuiltinPackge ¶
func (d *CodeAnalyzer) BuiltinPackge() *Package
func (*CodeAnalyzer) CacheSourceFiles ¶ added in v0.1.0
func (d *CodeAnalyzer) CacheSourceFiles()
ToDo: can we get the content from the collected AST files?
Need to hack the std packages?
func (*CodeAnalyzer) CheckTypeMethodContributingToTypeImplementations ¶ added in v0.0.8
func (d *CodeAnalyzer) CheckTypeMethodContributingToTypeImplementations(pkg, typ, methodPkg, method string) bool
typeIndex must be the index of a non-interface type.
func (*CodeAnalyzer) CleanImplements ¶
func (d *CodeAnalyzer) CleanImplements(self *TypeInfo) []Implementation
func (*CodeAnalyzer) CollectIdentiferFromFile ¶ added in v0.1.0
func (d *CodeAnalyzer) CollectIdentiferFromFile(pkg *Package, fileInfo *SourceFileInfo)
func (*CodeAnalyzer) CollectObjectReferences ¶ added in v0.1.0
func (d *CodeAnalyzer) CollectObjectReferences()
func (*CodeAnalyzer) CollectSourceFiles ¶
func (d *CodeAnalyzer) CollectSourceFiles()
func (*CodeAnalyzer) IsStandardPackage ¶
func (d *CodeAnalyzer) IsStandardPackage(pkg *Package) bool
func (*CodeAnalyzer) IsStandardPackageByPath ¶
func (d *CodeAnalyzer) IsStandardPackageByPath(path string) bool
ToDo: add Standard field.
func (*CodeAnalyzer) NumPackages ¶
func (d *CodeAnalyzer) NumPackages() int
func (*CodeAnalyzer) NumSourceFiles ¶
func (d *CodeAnalyzer) NumSourceFiles() int
func (*CodeAnalyzer) ObjectReferences ¶ added in v0.1.0
func (d *CodeAnalyzer) ObjectReferences(obj types.Object) []Identifier
Package by package, file by file, by positions in source.
func (*CodeAnalyzer) OriginalGoSourceFile ¶
func (d *CodeAnalyzer) OriginalGoSourceFile(filename string) string
func (*CodeAnalyzer) PackageAt ¶
func (d *CodeAnalyzer) PackageAt(i int) *Package
func (*CodeAnalyzer) PackageByPath ¶
func (d *CodeAnalyzer) PackageByPath(path string) *Package
ToDo: remove the second result
func (*CodeAnalyzer) ParsePackages ¶
func (*CodeAnalyzer) RegisterFunction ¶
func (d *CodeAnalyzer) RegisterFunction(f *Function)
Declared functions.
func (*CodeAnalyzer) RegisterType ¶
func (d *CodeAnalyzer) RegisterType(t types.Type) *TypeInfo
func (*CodeAnalyzer) RegisterTypeName ¶
func (d *CodeAnalyzer) RegisterTypeName(tn *TypeName)
The registered name must be a package-level name.
func (*CodeAnalyzer) RetrieveTypeName ¶
func (d *CodeAnalyzer) RetrieveTypeName(t *TypeInfo) (*TypeName, bool)
func (*CodeAnalyzer) RoughExportedIdentifierCount ¶ added in v0.0.8
func (d *CodeAnalyzer) RoughExportedIdentifierCount() int32
func (*CodeAnalyzer) RoughTypeNameCount ¶ added in v0.0.8
func (d *CodeAnalyzer) RoughTypeNameCount() int32
func (*CodeAnalyzer) RuntimeFunctionCodePosition ¶
func (d *CodeAnalyzer) RuntimeFunctionCodePosition(f string) token.Position
func (*CodeAnalyzer) RuntimePackage ¶
func (d *CodeAnalyzer) RuntimePackage() *Package
func (*CodeAnalyzer) SourceFile2Package ¶
func (d *CodeAnalyzer) SourceFile2Package(path string) (*Package, bool)
func (*CodeAnalyzer) Statistics ¶
func (d *CodeAnalyzer) Statistics() Stats
func (*CodeAnalyzer) TryRegisteringType ¶
func (d *CodeAnalyzer) TryRegisteringType(t types.Type, createOnNonexist bool) *TypeInfo
type Constant ¶
type Constant struct { *types.Const Type *TypeInfo Pkg *Package // some duplicated with types.Const.Pkg() AstDecl *ast.GenDecl AstSpec *ast.ValueSpec }
func (*Constant) AstValueSpec ¶
func (*Constant) Documentation ¶
func (*Constant) TypeInfo ¶
func (c *Constant) TypeInfo(d *CodeAnalyzer) *TypeInfo
type EmbeddedField ¶
type EmbeddedField struct { *Field Prev *EmbeddedField }
type Field ¶
type Function ¶
type Function struct { *types.Func *types.Builtin // for builtin functions Type *TypeInfo Pkg *Package // some duplicated with types.Func.Pkg(), except builtin functions AstDecl *ast.FuncDecl // contains filtered or unexported fields }
func (*Function) AstFuncType ¶ added in v0.0.4
func (*Function) AstPackage ¶ added in v0.0.4
func (*Function) Documentation ¶
func (*Function) ReceiverTypeName ¶
Please make sure the Funciton is a method when calling this method.
func (*Function) TypeInfo ¶
func (f *Function) TypeInfo(d *CodeAnalyzer) *TypeInfo
type FunctionResource ¶ added in v0.0.4
type FunctionResource interface { ValueResource IsMethod() bool ReceiverTypeName() (paramField *ast.Field, typeIdent *ast.Ident, isStar bool) AstFuncType() *ast.FuncType // For *Function, the result is the same as ValueResource.Package(). // For *InterfaceMethod, this might be different (caused by embedding, or other reasons). AstPackage() *Package }
type Identifier ¶ added in v0.1.0
type Identifier struct { FileInfo *SourceFileInfo AstIdent *ast.Ident }
type Implementation ¶
type InterfaceMethod ¶ added in v0.0.4
type InterfaceMethod struct { InterfaceTypeName *TypeName Method *Method // .AstFunc == nil, .AstInterface != nil }
As Function.
func (*InterfaceMethod) AstFuncType ¶ added in v0.0.4
func (im *InterfaceMethod) AstFuncType() *ast.FuncType
func (*InterfaceMethod) AstPackage ¶ added in v0.0.4
func (im *InterfaceMethod) AstPackage() *Package
func (*InterfaceMethod) Comment ¶ added in v0.0.4
func (im *InterfaceMethod) Comment() string
func (*InterfaceMethod) Documentation ¶ added in v0.0.4
func (im *InterfaceMethod) Documentation() string
func (*InterfaceMethod) Exported ¶ added in v0.0.4
func (im *InterfaceMethod) Exported() bool
func (*InterfaceMethod) IsMethod ¶ added in v0.0.4
func (im *InterfaceMethod) IsMethod() bool
func (*InterfaceMethod) Name ¶ added in v0.0.4
func (im *InterfaceMethod) Name() string
func (*InterfaceMethod) Package ¶ added in v0.0.4
func (im *InterfaceMethod) Package() *Package
func (*InterfaceMethod) Position ¶ added in v0.0.4
func (im *InterfaceMethod) Position() token.Position
func (*InterfaceMethod) ReceiverTypeName ¶ added in v0.0.4
func (im *InterfaceMethod) ReceiverTypeName() (paramField *ast.Field, typeIdent *ast.Ident, isStar bool)
Please make sure the Funciton is a method when calling this method.
func (*InterfaceMethod) String ¶ added in v0.0.4
func (im *InterfaceMethod) String() string
func (*InterfaceMethod) TType ¶ added in v0.0.4
func (im *InterfaceMethod) TType() types.Type
func (*InterfaceMethod) TypeInfo ¶ added in v0.0.4
func (im *InterfaceMethod) TypeInfo(d *CodeAnalyzer) *TypeInfo
type Method ¶
type Method struct { AstFunc *ast.FuncDecl // for concrete methods AstInterface *ast.InterfaceType // for interface methods (the owner interface) AstField *ast.Field // for interface methods Pkg *Package // (nil for exported. ??? Seems not true.) Name string Type *TypeInfo // ToDo: use custom struct including PointerRecv instead. PointerRecv bool // duplicated info, for faster access ImplementsSomething bool // false if the method is unimportant for its reveiver to implement some interface type // contains filtered or unexported fields }
type MethodSignature ¶
type Package ¶
type Package struct { Index int PPkg *packages.Package // ToDo: renamed to PP to be consistent with TypeInfo.TT? Mod *Module Deps []*Package DepLevel int // 0 means the level is not determined yet DepedBys []*Package // This field might be shared with PackageForDisplay // for concurrent reads. *PackageAnalyzeResult }
type PackageAnalyzeResult ¶
type PackageAnalyzeResult struct { AllTypeNames []*TypeName AllFunctions []*Function AllVariables []*Variable AllConstants []*Constant AllImports []*Import SourceFiles []SourceFileInfo Directory string }
func NewPackageAnalyzeResult ¶
func NewPackageAnalyzeResult() *PackageAnalyzeResult
func (*PackageAnalyzeResult) SourceFileInfoByBareFilename ¶
func (r *PackageAnalyzeResult) SourceFileInfoByBareFilename(bareFilename string) *SourceFileInfo
func (*PackageAnalyzeResult) SourceFileInfoByFilePath ¶
func (r *PackageAnalyzeResult) SourceFileInfoByFilePath(srcPath string) *SourceFileInfo
ToDo: better to maintain a global sourceFilePath => SourceFileInfo table? func (r *PackageAnalyzeResult) SourceFileInfo(srcPath string) *SourceFileInfo {
type SelectListManager ¶
type SelectListManager struct {
// contains filtered or unexported fields
}
func NewSelectListManager ¶
func NewSelectListManager() *SelectListManager
type Selector ¶
type Selector struct { Id string // One and only one of the two is nil. *Field *Method EmbeddingChain *EmbeddedField // in the inverse order Depth uint16 // the chain length Indirect bool // whether the chain contains indirects or not // contains filtered or unexported fields }
func (*Selector) PointerReceiverOnly ¶
type SelectorCond ¶
type SelectorCond uint8
const ( SelectorCond_Normal SelectorCond = iota SelectorCond_Hidden )
type SeleterMapManager ¶
type SeleterMapManager struct {
// contains filtered or unexported fields
}
type SourceFileInfo ¶
type SourceFileInfo struct { Pkg *Package // to remove one field in Identifier. // Filename only. BareFilename string BareGeneratedFilename string // The full path of a (Go or others) source file. // It might be blank for some cgo generated files. OriginalFile string // The followings are blank for most files. GeneratedFile string // Non-nil for Go files. // If an original Go file has a corresponding generated file, // then the ast file is for that generated file. AstFile *ast.File // ... Content []byte }
func (*SourceFileInfo) AstBareFileName ¶ added in v0.1.0
func (info *SourceFileInfo) AstBareFileName() string
type Stats ¶
type Stats struct { Packages int32 StdPackages int32 AllPackageDeps int32 PackagesByDeps [100]int32 FilesWithoutGenerateds int32 // without generated ones FilesWithGenerateds int32 // with generated ones CodeLines int32 // ToDo: stat code lines. Use the info in AstFile? BlankCodeLines int32 CommentCodeLines int32 // To calculate imports per file. // Deps per packages are available in other ways. AstFiles int32 Imports int32 FilesByImportCount [100]int32 // Types ExportedTypeNamesByKind [KindCount]int32 ExportedTypeNames int32 ExportedTypeAliases int32 ExportedCompositeTypeNames int32 ExportedBasicTypeNames int32 ExportedNumericTypeNames int32 ExportedIntergerTypeNames int32 ExportedUnsignedTypeNames int32 //ExportedNamedStructTypeNames int32 // should be equal to ExportedTypeNamesByKind[reflect.Struct] ExportedNamedStructTypesWithEmbeddingFields int32 ExportedNamedStructTypesWithPromotedFields int32 ExportedNamedStructTypeFields int32 ExportedNamedStructTypeExplicitFields int32 ExportedNamedStructTypeExportedFields int32 ExportedNamedStructTypeExportedExplicitFields int32 ExportedNamedStructsByEmbeddingFieldCount [100]int32 ExportedNamedStructsByFieldCount [100]int32 // including promoteds and non-exporteds ExportedNamedStructsByExplicitFieldCount [100]int32 // including non-exporteds but not including promoted ExportedNamedStructsByExportedFieldCount [100]int32 // including promoteds ExportedNamedStructsByExportedExplicitFieldCount [100]int32 // not including promoteds ExportedNamedStructsByExportedPromotedFieldCount [100]int32 ExportedNamedNonInterfaceTypesByMethodCount [100]int32 // T and *T combined ExportedNamedNonInterfaceTypesByExportedMethodCount [100]int32 // T and *T combined ExportedNamedNonInterfacesExportedMethods int32 ExportedNamedNonInterfacesWithExportedMethods int32 ExportedNamedInterfacesByMethodCount [100]int32 ExportedNamedInterfacesByExportedMethodCount [100]int32 // the last element means (N-1)+ ExportedNamedInterfacesExportedMethods int32 // Values ExportedVariables int32 ExportedConstants int32 ExportedFunctions int32 ExportedMethods int32 // non-interface methods ExportedVariablesByTypeKind [KindCount]int32 ExportedConstantsByTypeKind [KindCount]int32 // ToDo: Methods corresponding the same interface method should be viewed as one method in counting. ExportedFunctionParameters int32 // including methods ExportedFunctionResults int32 // including methods ExportedFunctionWithLastErrorResult int32 // including methods ExportedFunctionsByParameterCount [100]int32 // including methods ExportedFunctionsByResultCount [100]int32 // including methods // Others. ExportedIdentifers int32 ExportedIdentifersSumLength int32 ExportedIdentifiersByLength [100]int32 // contains filtered or unexported fields }
type TypeInfo ¶
type TypeInfo struct { TT types.Type Underlying *TypeInfo //Implements []*TypeInfo ///StarImplements []*TypeInfo // if TT is neither pointer nor interface. Implements []Implementation // For interface types. ImplementedBys []*TypeInfo // For builtin and unnamed types only. Aliases []*TypeAlias // ToDo: // For named and basic types. TypeName *TypeName // For unnamed types. UsePositions []token.Position // Explicit fields and methods. // * For named types, only explicitly declared methods are included. // The field is only built for T. (*T).DirectSelectors is always nil. // * For named interface types, all explicitly specified methods and embedded types (as fields). // * For unnamed struct types, only direct fields. Only built for strct{...}, not for *struct{...}. DirectSelectors []*Selector EmbeddingFields int32 // for struct types only now. ToDo: also for interface types. // All methods, including extended/promoted ones. AllMethods []*Selector // All fields, including promoted ones. AllFields []*Selector // For .TypeName != nil AsTypesOf []ValueResource // variables and constants AsInputsOf []ValueResource // variables and functions AsOutputsOf []ValueResource // variables and functions // contains filtered or unexported fields }
type TypeName ¶
type TypeName struct { // One and only one of the two is nil. Alias *TypeAlias Named *TypeInfo // ToDo: simplify the source defintion. // Four kinds of sources to affect promoted selectors: // 1. typename // 2. *typename // 3. unnamed type // 4. *unname type Source TypeSource StarSource *TypeSource UsePositions []token.Position *types.TypeName Pkg *Package // some duplicated with types.TypeName.Pkg(), except builtin types AstDecl *ast.GenDecl AstSpec *ast.TypeSpec // contains filtered or unexported fields }
func (*TypeName) Documentation ¶
type TypeSource ¶
type ValueResource ¶
type ValueResource interface { Resource TType() types.Type // The result should not be used in comparisons. TypeInfo(d *CodeAnalyzer) *TypeInfo }
type Variable ¶
type Variable struct { *types.Var Type *TypeInfo Pkg *Package // some duplicated with types.Var.Pkg() AstDecl *ast.GenDecl AstSpec *ast.ValueSpec }
func (*Variable) AstValueSpec ¶
func (*Variable) Documentation ¶
func (*Variable) TypeInfo ¶
func (v *Variable) TypeInfo(d *CodeAnalyzer) *TypeInfo
Click to show internal directories.
Click to hide internal directories.