Documentation
¶
Index ¶
- Constants
- func IsDecimal(character rune) bool
- func IsIdentifier(character rune, index int) bool
- func IsLower(s string) bool
- func IsReservedMarker(marker string) bool
- func IsUpper(s string) bool
- func LowerCamelCase(str string) string
- func NewError(err error, fileName string, position Position) error
- func NewErrorList(errors []error) error
- func UpperCamelCase(str string) string
- type AliasMap
- type Argument
- type ArgumentType
- type ArgumentTypeInfo
- type Collector
- type Definition
- type DefinitionMap
- type DeprecatedMarker
- type Error
- type ErrorList
- type ImportError
- type ImportMarker
- type Marker
- type MarkerValues
- type Output
- type OverrideMarker
- type Parameter
- type ParameterEnum
- type ParserError
- type Position
- type Registry
- type Scanner
- func (scanner *Scanner) AddError(message string)
- func (scanner *Scanner) ErrorCount() int
- func (scanner *Scanner) Expect(expected rune, description string) bool
- func (scanner *Scanner) Next() rune
- func (scanner *Scanner) Peek() rune
- func (scanner *Scanner) Reset()
- func (scanner *Scanner) Scan() rune
- func (scanner *Scanner) ScanIdentifier() rune
- func (scanner *Scanner) ScanNumber() rune
- func (scanner *Scanner) ScanString(quote rune) (len int)
- func (scanner *Scanner) SearchIndex() int
- func (scanner *Scanner) SetSearchIndex(searchIndex int)
- func (scanner *Scanner) SkipWhitespaces() rune
- func (scanner *Scanner) SourceLength() int
- func (scanner *Scanner) Token() string
- type ScannerError
- type TargetLevel
- type Validate
Constants ¶
View Source
const ( ImportMarkerName = "import" DeprecatedMarkerName = "deprecated" OverrideMarkerName = "override" )
Reserved markers
View Source
const ( EOF = -(iota + 1) Identifier IntegerValue StringValue )
View Source
const ( // TypeLevel indicates that a marker is associated with any type. TypeLevel = StructTypeLevel | InterfaceTypeLevel // MethodLevel indicates that a marker is associated with a struct method or an interface method. MethodLevel = StructMethodLevel | InterfaceMethodLevel AllLevels = PackageLevel | TypeLevel | MethodLevel | FieldLevel | FunctionLevel )
Combined levels
View Source
const (
ValueArgument = "Value"
)
Argument names
View Source
const Whitespace = 1<<'\t' | 1<<'\r' | 1<<' '
Variables ¶
This section is empty.
Functions ¶
func IsIdentifier ¶
func IsReservedMarker ¶
func LowerCamelCase ¶
func NewErrorList ¶
func UpperCamelCase ¶
Types ¶
type AliasMap ¶
type AliasMap map[string]ImportMarker
type Argument ¶
type Argument struct { Name string TypeInfo ArgumentTypeInfo Required bool Deprecated bool Default any }
func ExtractArgument ¶
func ExtractArgument(structField reflect.StructField) (Argument, error)
type ArgumentType ¶
type ArgumentType int
const ( InvalidType ArgumentType = iota RawType AnyType BoolType SignedIntegerType UnsignedIntegerType StringType SliceType MapType GoFuncType GoType )
func (ArgumentType) String ¶
func (argumentType ArgumentType) String() string
type ArgumentTypeInfo ¶
type ArgumentTypeInfo struct { ActualType ArgumentType IsPointer bool ItemType *ArgumentTypeInfo Enum map[string]any }
func GetArgumentTypeInfo ¶
func GetArgumentTypeInfo(typ reflect.Type) (ArgumentTypeInfo, error)
type Definition ¶
type Definition struct { Name string Package string TargetLevel TargetLevel Repeatable bool Deprecated bool Output Output }
func MakeDefinition ¶
func MakeDefinition(name, pkg string, level TargetLevel, output any) (*Definition, error)
func (*Definition) Parse ¶
func (definition *Definition) Parse(comment string) (interface{}, error)
TODO fix parse method implementation
type DefinitionMap ¶
type DefinitionMap map[string]*Definition
type DeprecatedMarker ¶
type DeprecatedMarker struct {
Value string `parameter:"Value"`
}
type ImportError ¶
type ImportError struct {
Marker string
}
func (ImportError) Error ¶
func (err ImportError) Error() string
type ImportMarker ¶
type ImportMarker struct { Value string `parameter:"Value" required:"true"` Alias string `parameter:"Alias" required:"false"` Pkg string `parameter:"Pkg" required:"true"` }
func (ImportMarker) PkgId ¶
func (m ImportMarker) PkgId() string
func (ImportMarker) PkgVersion ¶
func (m ImportMarker) PkgVersion() string
func (ImportMarker) Validate ¶
func (m ImportMarker) Validate() error
type MarkerValues ¶
func (MarkerValues) AllMarkers ¶
func (markerValues MarkerValues) AllMarkers(name string) []any
func (MarkerValues) Count ¶
func (markerValues MarkerValues) Count() int
func (MarkerValues) CountByName ¶
func (markerValues MarkerValues) CountByName(name string) int
func (MarkerValues) First ¶
func (markerValues MarkerValues) First(name string) any
type OverrideMarker ¶
type OverrideMarker struct {
Value string `parameter:"Value"`
}
type ParameterEnum ¶
type ParserError ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry keeps the registered marker definitions.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry returns a new registry to register the markers.
func (*Registry) Lookup ¶
func (registry *Registry) Lookup(name, pkg string, targetLevel TargetLevel) (*Definition, bool)
Lookup fetches the definition corresponding to the given name and pkgId.
func (*Registry) Register ¶
func (registry *Registry) Register(name, pkg string, level TargetLevel, output any) error
Register registers a new marker with the given name, target level, and output type.
func (*Registry) RegisterWithDefinition ¶
func (registry *Registry) RegisterWithDefinition(definition *Definition) error
RegisterWithDefinition registers a new marker with the given definition.
type Scanner ¶
type Scanner struct { ErrorCallback func(scanner *Scanner, message string) // contains filtered or unexported fields }
func NewScanner ¶
func (*Scanner) ErrorCount ¶
func (*Scanner) ScanIdentifier ¶
func (*Scanner) ScanNumber ¶
func (*Scanner) ScanString ¶
func (*Scanner) SearchIndex ¶
func (*Scanner) SetSearchIndex ¶
func (*Scanner) SkipWhitespaces ¶
func (*Scanner) SourceLength ¶
type ScannerError ¶
type ScannerError struct {
Message string
}
func (ScannerError) Error ¶
func (err ScannerError) Error() string
type TargetLevel ¶
type TargetLevel int
TargetLevel describes which kind of nodes a given marker are associated with.
const ( // PackageLevel indicates that a marker is associated with a package. PackageLevel TargetLevel = 1 << iota // StructTypeLevel indicates that a marker is associated with a struct type. StructTypeLevel // InterfaceTypeLevel indicates that a marker is associated with an interface type. InterfaceTypeLevel // FieldLevel indicates that a marker is associated with a struct field. FieldLevel // FunctionLevel indicates that a marker is associated with a function. FunctionLevel // StructMethodLevel indicates that a marker is associated with a struct method. StructMethodLevel // InterfaceMethodLevel indicates that a marker is associated with an interface method. InterfaceMethodLevel )
func FindTargetLevelFromNode ¶
func FindTargetLevelFromNode(node ast.Node) TargetLevel