Documentation
¶
Index ¶
- func ExtractTypeName(t types.Type) string
- type AttachmentsMap
- func (t *AttachmentsMap) AddPkgAttachment(pkg string, attachment string)
- func (t *AttachmentsMap) AddPkgFunctionAttachment(pkg string, funcname string, attachment string)
- func (t *AttachmentsMap) AddPkgTypeAttachment(pkg string, typename string, attachment string)
- func (t *AttachmentsMap) AddPkgTypeFieldAttachment(pkg string, typename string, field string, attachment string)
- func (t *AttachmentsMap) AddPkgTypeMethodAttachment(pkg string, typename string, method string, attachment string)
- func (am *AttachmentsMap) Empty() bool
- func (am *AttachmentsMap) GetAttachmentsForFunction(pkgPath string, funcName string, excludes ...string) []string
- func (am *AttachmentsMap) GetAttachmentsForMethod(pkgPath string, typeName string, methodName string, excludes ...string) []string
- func (am *AttachmentsMap) GetAttachmentsForType(pkgPath string, typeName string, excludes ...string) []string
- func (am *AttachmentsMap) GetPackageAttachments(pkgPath string) *PackageAttachments
- func (am *AttachmentsMap) HasAnyFunctionAttachments(pkgPath string, funcName string) bool
- func (am *AttachmentsMap) HasAnyMethodAttachments(pkgPath string, typeName string, methodName string) bool
- func (am *AttachmentsMap) HasAnyTypeAttachments(pkgPath string, typeName string) bool
- func (t *AttachmentsMap) HasPkgAttachment(pkg string, attachment string) bool
- func (t *AttachmentsMap) HasPkgFunctionAttachment(pkg string, funcname string, attachment string) bool
- func (t *AttachmentsMap) HasPkgTypeAttachment(pkg string, typename string, attachment string) bool
- func (t *AttachmentsMap) HasPkgTypeFieldAttachment(pkg string, typename string, field string, attachment string) bool
- func (t *AttachmentsMap) HasPkgTypeMethodAttachment(pkg string, typename string, method string, attachment string) bool
- type IgnoreAnnotation
- type IgnoreMarker
- type IgnoreSet
- type Import
- type ImportMap
- type PackageAttachments
- func (t *PackageAttachments) AddAttachment(attachment string)
- func (t *PackageAttachments) AddFunctionAttachment(funcname string, attachment string)
- func (t *PackageAttachments) AddTypeAttachment(typename string, attachment string)
- func (t *PackageAttachments) AddTypeFieldAttachment(typename string, field string, attachment string)
- func (t *PackageAttachments) AddTypeMethodAttachment(typename string, method string, attachment string)
- func (pa *PackageAttachments) GetTypeAttachments(typeName string) *TypeAttachments
- func (t *PackageAttachments) HasAttachment(attachment string) bool
- func (t *PackageAttachments) HasFunctionAttachment(funcname string, attachment string) bool
- func (t *PackageAttachments) HasTypeAttachment(typename string, attachment string) bool
- func (t *PackageAttachments) HasTypeFieldAttachment(typename string, field string, attachment string) bool
- func (t *PackageAttachments) HasTypeMethodAttachment(typename string, method string, attachment string) bool
- type TypeAssociationRegistry
- func (tar TypeAssociationRegistry) Add(pkgPath string, associatedName string, typeName string)
- func (tar TypeAssociationRegistry) Empty() bool
- func (tar TypeAssociationRegistry) GetAssociated(pkgPath string, typeName string) []string
- func (tar TypeAssociationRegistry) HasType(pkgPath string, typeName string) bool
- func (tar TypeAssociationRegistry) Len() int
- func (tar TypeAssociationRegistry) Match(pkgPath string, associatedName string, expectedType string) bool
- type TypeAttachments
- func (t *TypeAttachments) AddAttachment(attachment string)
- func (t *TypeAttachments) AddFieldAttachment(field string, attachment string)
- func (t *TypeAttachments) AddMethodAttachment(method string, attachment string)
- func (t *TypeAttachments) HasAttachment(attachment string) bool
- func (t *TypeAttachments) HasFieldAttachment(field string, attachment string) bool
- func (t *TypeAttachments) HasMethodAttachment(method string, attachment string) bool
- type TypeInfo
- type TypesMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTypeName ¶
ExtractTypeName extracts just the type name from a types.Type Returns empty string if the type is not a named type
Types ¶
type AttachmentsMap ¶
type AttachmentsMap struct {
// contains filtered or unexported fields
}
AttachmentsMap is a special data structure that allows attaching arrays of strings within packages to types, methods, functions, and fields
func (*AttachmentsMap) AddPkgAttachment ¶
func (t *AttachmentsMap) AddPkgAttachment(pkg string, attachment string)
AddPkgAttachment adds an attachment to package
func (*AttachmentsMap) AddPkgFunctionAttachment ¶
func (t *AttachmentsMap) AddPkgFunctionAttachment(pkg string, funcname string, attachment string)
AddPkgFunctionAttachment adds an attachment to package function
func (*AttachmentsMap) AddPkgTypeAttachment ¶
func (t *AttachmentsMap) AddPkgTypeAttachment(pkg string, typename string, attachment string)
AddPkgTypeAttachment adds an attachment to package type
func (*AttachmentsMap) AddPkgTypeFieldAttachment ¶
func (t *AttachmentsMap) AddPkgTypeFieldAttachment(pkg string, typename string, field string, attachment string)
AddPkgTypeFieldAttachment adds an attachment to package type field
func (*AttachmentsMap) AddPkgTypeMethodAttachment ¶
func (t *AttachmentsMap) AddPkgTypeMethodAttachment(pkg string, typename string, method string, attachment string)
AddPkgTypeMethodAttachment adds an attachment to package type method
func (*AttachmentsMap) Empty ¶
func (am *AttachmentsMap) Empty() bool
Empty returns true if the AttachmentsMap contains no packages
func (*AttachmentsMap) GetAttachmentsForFunction ¶
func (am *AttachmentsMap) GetAttachmentsForFunction(pkgPath string, funcName string, excludes ...string) []string
GetAttachmentsForFunction returns all attachments for a function, excluding specified values
func (*AttachmentsMap) GetAttachmentsForMethod ¶
func (am *AttachmentsMap) GetAttachmentsForMethod(pkgPath string, typeName string, methodName string, excludes ...string) []string
GetAttachmentsForMethod returns all attachments for a method, excluding specified values
func (*AttachmentsMap) GetAttachmentsForType ¶
func (am *AttachmentsMap) GetAttachmentsForType(pkgPath string, typeName string, excludes ...string) []string
GetAttachmentsForType returns all attachments for a type, excluding specified values
func (*AttachmentsMap) GetPackageAttachments ¶
func (am *AttachmentsMap) GetPackageAttachments(pkgPath string) *PackageAttachments
GetPackageAttachments returns PackageAttachments for a given package path
func (*AttachmentsMap) HasAnyFunctionAttachments ¶
func (am *AttachmentsMap) HasAnyFunctionAttachments(pkgPath string, funcName string) bool
HasAnyFunctionAttachments checks if a function has any attachments at all
func (*AttachmentsMap) HasAnyMethodAttachments ¶
func (am *AttachmentsMap) HasAnyMethodAttachments(pkgPath string, typeName string, methodName string) bool
HasAnyMethodAttachments checks if a method has any attachments at all
func (*AttachmentsMap) HasAnyTypeAttachments ¶
func (am *AttachmentsMap) HasAnyTypeAttachments(pkgPath string, typeName string) bool
HasAnyTypeAttachments checks if a type has any attachments at all
func (*AttachmentsMap) HasPkgAttachment ¶
func (t *AttachmentsMap) HasPkgAttachment(pkg string, attachment string) bool
HasPkgAttachment checks if package has the attachment
func (*AttachmentsMap) HasPkgFunctionAttachment ¶
func (t *AttachmentsMap) HasPkgFunctionAttachment(pkg string, funcname string, attachment string) bool
HasPkgFunctionAttachment checks if package function has the attachment
func (*AttachmentsMap) HasPkgTypeAttachment ¶
func (t *AttachmentsMap) HasPkgTypeAttachment(pkg string, typename string, attachment string) bool
HasPkgTypeAttachment checks if package type has the attachment
func (*AttachmentsMap) HasPkgTypeFieldAttachment ¶
func (t *AttachmentsMap) HasPkgTypeFieldAttachment(pkg string, typename string, field string, attachment string) bool
HasPkgTypeFieldAttachment checks if package type field has the attachment
func (*AttachmentsMap) HasPkgTypeMethodAttachment ¶
func (t *AttachmentsMap) HasPkgTypeMethodAttachment(pkg string, typename string, method string, attachment string) bool
HasPkgTypeMethodAttachment checks if package type method has the attachment
type IgnoreAnnotation ¶
type IgnoreAnnotation interface {
GetCodes() []string
GetStartPos() token.Pos
GetEndPos() token.Pos
}
IgnoreAnnotation interface for adding annotations to the set This allows adding from ignore.IgnoreAnnotation without circular dependency
type IgnoreMarker ¶
IgnoreMarker is the internal storage type for ignore annotations Using a concrete struct instead of interface ensures proper gob serialization @immutable
type IgnoreSet ¶
type IgnoreSet struct {
// All markers in order they were added
Markers []IgnoreMarker
// Index: code -> list of marker indices that contain this code
CodeIndex map[string][]int
// Min and max positions for quick range check
MinPos token.Pos
MaxPos token.Pos
// Flag to track if the set has been initialized
Initialized bool
// contains filtered or unexported fields
}
IgnoreSet provides fast lookup for ignore annotations by code and position Can be initialized as &IgnoreSet{}
func (*IgnoreSet) Add ¶
func (s *IgnoreSet) Add(annotation IgnoreAnnotation)
Add adds an annotation to the set and updates indices Safe to call on nil receiver - does nothing if receiver is nil.
func (*IgnoreSet) AddModuleIgnore ¶
AddModuleIgnore adds ignore for entire module/flag from position 0 to max int This will ignore all violations for the specified codes everywhere
func (*IgnoreSet) Contains ¶
Contains checks if the given code is ignored at the specified position. Returns true if there's an @ignore annotation that covers the position.
The method checks codes in hierarchical order using codes.GetCodesForCheck(): - First checks "ALL" (universal ignore) - Then checks category prefix (e.g., "IMM" for "IMM01") - Finally checks the specific code (e.g., "IMM01")
Example: for code "IMM01", it checks: "ALL", "IMM", "IMM01" Safe to call on nil receiver - returns false.
type Import ¶
type Import struct {
Alias string // explicit alias (if present) or empty
FullPath string // full import path like "io" or "github.com/user/pkg"
PackageName string // actual package name from the code (e.g., "importmap" for "github.com/a14e/gogreement/src/util")
}
Import represents a single import from AST @immutable
type ImportMap ¶
type ImportMap []Import
ImportMap is a collection of imports with lookup methods
func (*ImportMap) Add ¶
func (m *ImportMap) Add(spec *ast.ImportSpec, pkg *types.Package)
Add adds an import spec to the map If pkg is provided, the actual package name will be stored If pkg is nil, only path information will be stored
func (*ImportMap) Find ¶
Find searches for an import by short name with the following priority: 1. Explicit alias (highest priority) 2. Package name (actual name from package declaration) 3. Exact match (e.g., "io" matches "io") 4. Path component match (e.g., "bar" matches "foo/bar") Returns nil if not found
type PackageAttachments ¶
type PackageAttachments struct {
LocalAttachments []string
FunctionsAttachments map[string][]string
TypesAttachments map[string]TypeAttachments
}
PackageAttachments stores all attachments within a single package
func (*PackageAttachments) AddAttachment ¶
func (t *PackageAttachments) AddAttachment(attachment string)
AddAttachment adds an attachment to package
func (*PackageAttachments) AddFunctionAttachment ¶
func (t *PackageAttachments) AddFunctionAttachment(funcname string, attachment string)
AddFunctionAttachment adds an attachment to function
func (*PackageAttachments) AddTypeAttachment ¶
func (t *PackageAttachments) AddTypeAttachment(typename string, attachment string)
AddTypeAttachment adds an attachment to type
func (*PackageAttachments) AddTypeFieldAttachment ¶
func (t *PackageAttachments) AddTypeFieldAttachment(typename string, field string, attachment string)
AddTypeFieldAttachment adds an attachment to type field
func (*PackageAttachments) AddTypeMethodAttachment ¶
func (t *PackageAttachments) AddTypeMethodAttachment(typename string, method string, attachment string)
AddTypeMethodAttachment adds an attachment to type method
func (*PackageAttachments) GetTypeAttachments ¶
func (pa *PackageAttachments) GetTypeAttachments(typeName string) *TypeAttachments
GetTypeAttachments returns TypeAttachments for a given type in a package
func (*PackageAttachments) HasAttachment ¶
func (t *PackageAttachments) HasAttachment(attachment string) bool
HasAttachment checks if package has the attachment
func (*PackageAttachments) HasFunctionAttachment ¶
func (t *PackageAttachments) HasFunctionAttachment(funcname string, attachment string) bool
HasFunctionAttachment checks if function has the attachment
func (*PackageAttachments) HasTypeAttachment ¶
func (t *PackageAttachments) HasTypeAttachment(typename string, attachment string) bool
HasTypeAttachment checks if type has the attachment
func (*PackageAttachments) HasTypeFieldAttachment ¶
func (t *PackageAttachments) HasTypeFieldAttachment(typename string, field string, attachment string) bool
HasTypeFieldAttachment checks if type field has the attachment
func (*PackageAttachments) HasTypeMethodAttachment ¶
func (t *PackageAttachments) HasTypeMethodAttachment(typename string, method string, attachment string) bool
HasTypeMethodAttachment checks if type method has the attachment
type TypeAssociationRegistry ¶
TypeAssociationRegistry is a two-level map for tracking associations with types across packages Can be used for functions, fields, methods, etc. First level: package path ("" for current package) Second level: type name -> list of associated names (constructors, methods, fields, etc.) @constructor NewTypeAssociationRegistry
func NewTypeAssociationRegistry ¶
func NewTypeAssociationRegistry() TypeAssociationRegistry
NewTypeAssociationRegistry creates a new TypeAssociationRegistry
func (TypeAssociationRegistry) Add ¶
func (tar TypeAssociationRegistry) Add(pkgPath string, associatedName string, typeName string)
Add adds an association to the map for a specific package pkgPath: package path (use "" for current package) associatedName: name of the associated item (function, field, method, etc.) typeName: name of the type this item relates to
func (TypeAssociationRegistry) Empty ¶
func (tar TypeAssociationRegistry) Empty() bool
Empty returns true if the registry contains no associations
func (TypeAssociationRegistry) GetAssociated ¶
func (tar TypeAssociationRegistry) GetAssociated(pkgPath string, typeName string) []string
GetAssociated returns list of associated names for a type Returns nil if type not found or has no associated items
func (TypeAssociationRegistry) HasType ¶
func (tar TypeAssociationRegistry) HasType(pkgPath string, typeName string) bool
HasType checks if a type has any associated items
func (TypeAssociationRegistry) Len ¶
func (tar TypeAssociationRegistry) Len() int
Len returns the total number of associations across all packages
func (TypeAssociationRegistry) Match ¶
func (tar TypeAssociationRegistry) Match(pkgPath string, associatedName string, expectedType string) bool
Match checks if an item is associated with the expected type This is the primary method for checking if we're in a valid context (constructor, method, field, etc.)
type TypeAttachments ¶
type TypeAttachments struct {
LocalAttachments []string
FieldsAttachments map[string][]string
MethodsAttachments map[string][]string
}
TypeAttachments stores all attachments for a specific type
func (*TypeAttachments) AddAttachment ¶
func (t *TypeAttachments) AddAttachment(attachment string)
AddAttachment adds an attachment to type
func (*TypeAttachments) AddFieldAttachment ¶
func (t *TypeAttachments) AddFieldAttachment(field string, attachment string)
AddFieldAttachment adds an attachment to field
func (*TypeAttachments) AddMethodAttachment ¶
func (t *TypeAttachments) AddMethodAttachment(method string, attachment string)
AddMethodAttachment adds an attachment to method
func (*TypeAttachments) HasAttachment ¶
func (t *TypeAttachments) HasAttachment(attachment string) bool
HasAttachment checks if type has the attachment
func (*TypeAttachments) HasFieldAttachment ¶
func (t *TypeAttachments) HasFieldAttachment(field string, attachment string) bool
HasFieldAttachment checks if field has the attachment
func (*TypeAttachments) HasMethodAttachment ¶
func (t *TypeAttachments) HasMethodAttachment(method string, attachment string) bool
HasMethodAttachment checks if method has the attachment
type TypeInfo ¶
type TypeInfo struct {
// TypeName is the name of the type (e.g., "MyStruct")
TypeName string
// PkgPath is the full package path (e.g., "github.com/user/pkg")
// Empty for builtin types
PkgPath string
}
TypeInfo contains information about a Go type extracted from types.Type @immutable @constructor ExtractTypeInfo
func ExtractTypeInfo ¶
ExtractTypeInfo extracts type name and package path from a types.Type Returns nil if the type is not a named type or has no package