Documentation ¶
Index ¶
- Variables
- func Errorf(pass *analysis.Pass, node ast.Node, format string, args ...interface{})
- func ExtractComments(doc *ast.CommentGroup) []string
- func ExtractType(pass *analysis.Pass, pos token.Pos, tnode types.Type) optional.Option[schema.Type]
- func ExtractTypeForNode(pass *analysis.Pass, obj types.Object, node ast.Node, index types.Type) optional.Option[schema.Type]
- func FtlModuleFromGoPackage(pkgPath string) (string, error)
- func GetAllFacts[T SchemaFactValue](pass *analysis.Pass) map[types.Object]T
- func GetAllFactsExtractionStatus(pass *analysis.Pass) map[types.Object]SchemaFactValue
- func GetCurrentPassFacts[T SchemaFactValue](pass *analysis.Pass) map[types.Object]T
- func GetDeclTypeName(d schema.Decl) string
- func GetFactForObject[T SchemaFactValue](pass *analysis.Pass, obj types.Object) optional.Option[T]
- func GetFactsForObject[T SchemaFactValue](pass *analysis.Pass, obj types.Object) []T
- func GetNativeName(obj types.Object) string
- func GetObjectForNode(typesInfo *types.Info, node ast.Node) optional.Option[types.Object]
- func GetTypeInfoForNode(node ast.Node, info *types.Info) types.Type
- func GoPosToSchemaPos(fset *token.FileSet, pos token.Pos) schema.Position
- func IsExternalType(obj types.Object) bool
- func IsPathInPkg(pkg *types.Package, path string) bool
- func IsSelfReference(pass *analysis.Pass, obj types.Object, t schema.Type) bool
- func IsType[T types.Type](t types.Type) bool
- func MarkFailedExtraction(pass *analysis.Pass, obj types.Object)
- func MarkMaybeTypeEnum(pass *analysis.Pass, obj types.Object, enum *schema.Enum)
- func MarkMaybeTypeEnumVariant(pass *analysis.Pass, obj types.Object, variant *schema.EnumVariant, ...)
- func MarkMaybeValueEnumVariant(pass *analysis.Pass, obj types.Object, variant *schema.EnumVariant)
- func MarkMetadata(pass *analysis.Pass, obj types.Object, md *ExtractedMetadata)
- func MarkNeedsExtraction(pass *analysis.Pass, obj types.Object)
- func MarkSchemaDecl(pass *analysis.Pass, obj types.Object, decl schema.Decl)
- func NewDeclExtractor[T schema.Decl, N ast.Node](name string, extractFunc ExtractDeclFunc[T, N]) *analysis.Analyzer
- func NewExtractor(name string, factType analysis.Fact, ...) *analysis.Analyzer
- func NoEndColumnErrorf(pass *analysis.Pass, pos token.Pos, format string, args ...interface{})
- func NoEndColumnWarnf(pass *analysis.Pass, pos token.Pos, format string, args ...interface{})
- func TokenErrorf(pass *analysis.Pass, pos token.Pos, tokenText string, format string, ...)
- func Wrapf(pass *analysis.Pass, node ast.Node, err error, format string, ...)
- type DefaultFact
- type DiagnosticCategory
- type Directive
- type DirectiveCronJob
- type DirectiveData
- type DirectiveEnum
- type DirectiveExport
- type DirectiveIngress
- type DirectiveRetry
- type DirectiveSubscriber
- type DirectiveTypeAlias
- func (d *DirectiveTypeAlias) GetPosition() token.Pos
- func (*DirectiveTypeAlias) GetTypeName() string
- func (d *DirectiveTypeAlias) IsExported() bool
- func (*DirectiveTypeAlias) MustAnnotate() []ast.Node
- func (d *DirectiveTypeAlias) SetPosition(pos token.Pos)
- func (d *DirectiveTypeAlias) String() string
- type DirectiveTypeMap
- type DirectiveVerb
- type Exportable
- type ExtractDeclFunc
- type ExtractedDecl
- type ExtractedMetadata
- type ExtractorResult
- type FailedExtraction
- type MaybeTypeEnum
- type MaybeTypeEnumVariant
- type MaybeValueEnumVariant
- type NeedsExtraction
- type SchemaFact
- type SchemaFactValue
Constants ¶
This section is empty.
Variables ¶
var ( // FtlUnitTypePath is the path to the FTL unit type. FtlUnitTypePath = "github.com/TBD54566975/ftl/go-runtime/ftl.Unit" FtlOptionTypePath = "github.com/TBD54566975/ftl/go-runtime/ftl.Option" )
Functions ¶
func ExtractComments ¶
func ExtractComments(doc *ast.CommentGroup) []string
func ExtractType ¶
func ExtractTypeForNode ¶
func FtlModuleFromGoPackage ¶
func GetAllFacts ¶ added in v0.287.0
func GetAllFacts[T SchemaFactValue](pass *analysis.Pass) map[types.Object]T
GetAllFacts returns all facts of the provided type marked on objects, across the current pass and results from prior passes. If multiple of the same fact type are marked on a single object, the first fact is returned.
func GetAllFactsExtractionStatus ¶ added in v0.287.0
func GetAllFactsExtractionStatus(pass *analysis.Pass) map[types.Object]SchemaFactValue
GetAllFactsExtractionStatus merges schema facts inclusive of all available results and the present pass facts. For a given object, it provides the current extraction status.
If multiple extraction facts are present for the same object, the facts will be prioritized by type: 1. ExtractedDecl 2. FailedExtraction 3. NeedsExtraction
All other fact types are ignored.
func GetCurrentPassFacts ¶ added in v0.287.0
func GetCurrentPassFacts[T SchemaFactValue](pass *analysis.Pass) map[types.Object]T
GetCurrentPassFacts returns all facts of the provided type marked on objects during the current pass. If multiple of the same fact type are marked on a single object, the first fact is returned.
func GetDeclTypeName ¶ added in v0.287.0
func GetFactForObject ¶
GetFactForObject returns the first fact of the provided type marked on the object.
func GetFactsForObject ¶
func GetFactsForObject[T SchemaFactValue](pass *analysis.Pass, obj types.Object) []T
GetFactsForObject returns the all facts of the provided type marked on the object.
func GetNativeName ¶ added in v0.261.0
func GetObjectForNode ¶
func GetTypeInfoForNode ¶ added in v0.282.0
func IsExternalType ¶ added in v0.282.0
func IsSelfReference ¶
func MarkFailedExtraction ¶
MarkFailedExtraction marks the given object as having failed extraction.
func MarkMaybeTypeEnum ¶ added in v0.287.0
MarkMaybeTypeEnum marks the given object as a possible type enum discriminator.
func MarkMaybeTypeEnumVariant ¶ added in v0.287.0
func MarkMaybeTypeEnumVariant(pass *analysis.Pass, obj types.Object, variant *schema.EnumVariant, parent types.Object, valueFunc func(pass *analysis.Pass) optional.Option[*schema.TypeValue])
MarkMaybeTypeEnumVariant marks the given object as a possible type enum variant.
func MarkMaybeValueEnumVariant ¶ added in v0.287.0
MarkMaybeValueEnumVariant marks the given object as a possible value enum variant.
func MarkMetadata ¶
func MarkMetadata(pass *analysis.Pass, obj types.Object, md *ExtractedMetadata)
func MarkNeedsExtraction ¶ added in v0.287.0
MarkNeedsExtraction marks the given object as needing extraction.
func MarkSchemaDecl ¶
MarkSchemaDecl marks the given object as having been extracted to the given schema decl.
func NewDeclExtractor ¶
func NewExtractor ¶
func NoEndColumnErrorf ¶
func NoEndColumnWarnf ¶ added in v0.282.0
func TokenErrorf ¶
Types ¶
type DefaultFact ¶ added in v0.260.0
type DefaultFact[T any] struct { // contains filtered or unexported fields }
DefaultFact should be used as the base type for all schema facts. Each Analyzer needs a uniuqe Fact type that is otherwise identical, and this type simply reduces that boilerplate.
Usage:
type Fact = common.DefaultFact[struct{}]
func (*DefaultFact[T]) AFact ¶ added in v0.260.0
func (*DefaultFact[T]) AFact()
func (*DefaultFact[T]) Add ¶ added in v0.287.0
func (t *DefaultFact[T]) Add(v SchemaFactValue)
func (*DefaultFact[T]) Get ¶ added in v0.260.0
func (t *DefaultFact[T]) Get() []SchemaFactValue
type DiagnosticCategory ¶
type DiagnosticCategory string
const ( Info DiagnosticCategory = "info" Warn DiagnosticCategory = "warn" Error DiagnosticCategory = "error" )
func (DiagnosticCategory) ToErrorLevel ¶
func (e DiagnosticCategory) ToErrorLevel() schema.ErrorLevel
type Directive ¶
type Directive interface { SetPosition(pos token.Pos) GetPosition() token.Pos GetTypeName() string // MustAnnotate returns the AST nodes that can be annotated by this directive. MustAnnotate() []ast.Node // contains filtered or unexported methods }
Directive is a directive in a Go FTL module, e.g. //ftl:ingress http GET /foo/bar
func ParseDirectives ¶
type DirectiveCronJob ¶
func (*DirectiveCronJob) GetPosition ¶
func (d *DirectiveCronJob) GetPosition() token.Pos
func (*DirectiveCronJob) GetTypeName ¶
func (*DirectiveCronJob) GetTypeName() string
func (*DirectiveCronJob) IsExported ¶
func (d *DirectiveCronJob) IsExported() bool
func (*DirectiveCronJob) MustAnnotate ¶
func (*DirectiveCronJob) MustAnnotate() []ast.Node
func (*DirectiveCronJob) SetPosition ¶
func (d *DirectiveCronJob) SetPosition(pos token.Pos)
func (*DirectiveCronJob) String ¶
func (d *DirectiveCronJob) String() string
type DirectiveData ¶
type DirectiveData struct { Pos token.Pos Data bool `parser:"@'data'"` Export bool `parser:"@'export'?"` }
func (*DirectiveData) GetPosition ¶
func (d *DirectiveData) GetPosition() token.Pos
func (*DirectiveData) GetTypeName ¶
func (*DirectiveData) GetTypeName() string
func (*DirectiveData) IsExported ¶
func (d *DirectiveData) IsExported() bool
func (*DirectiveData) MustAnnotate ¶
func (*DirectiveData) MustAnnotate() []ast.Node
func (*DirectiveData) SetPosition ¶
func (d *DirectiveData) SetPosition(pos token.Pos)
func (*DirectiveData) String ¶
func (d *DirectiveData) String() string
type DirectiveEnum ¶
type DirectiveEnum struct { Pos token.Pos Enum bool `parser:"@'enum'"` Export bool `parser:"@'export'?"` }
func (*DirectiveEnum) GetPosition ¶
func (d *DirectiveEnum) GetPosition() token.Pos
func (*DirectiveEnum) GetTypeName ¶
func (*DirectiveEnum) GetTypeName() string
func (*DirectiveEnum) IsExported ¶
func (d *DirectiveEnum) IsExported() bool
func (*DirectiveEnum) MustAnnotate ¶
func (*DirectiveEnum) MustAnnotate() []ast.Node
func (*DirectiveEnum) SetPosition ¶
func (d *DirectiveEnum) SetPosition(pos token.Pos)
func (*DirectiveEnum) String ¶
func (d *DirectiveEnum) String() string
type DirectiveExport ¶
DirectiveExport is used on declarations that don't include export in other directives.
func (*DirectiveExport) GetPosition ¶
func (d *DirectiveExport) GetPosition() token.Pos
func (*DirectiveExport) GetTypeName ¶
func (*DirectiveExport) GetTypeName() string
func (*DirectiveExport) MustAnnotate ¶
func (*DirectiveExport) MustAnnotate() []ast.Node
func (*DirectiveExport) SetPosition ¶
func (d *DirectiveExport) SetPosition(pos token.Pos)
func (*DirectiveExport) String ¶
func (d *DirectiveExport) String() string
type DirectiveIngress ¶
type DirectiveIngress struct { Pos token.Pos Type string `parser:"'ingress' @('http')?"` Method string `parser:"@('GET' | 'POST' | 'PUT' | 'DELETE')"` Path []schema.IngressPathComponent `parser:"('/' @@)+"` }
func (*DirectiveIngress) GetPosition ¶
func (d *DirectiveIngress) GetPosition() token.Pos
func (*DirectiveIngress) GetTypeName ¶
func (*DirectiveIngress) GetTypeName() string
func (*DirectiveIngress) IsExported ¶
func (d *DirectiveIngress) IsExported() bool
func (*DirectiveIngress) MustAnnotate ¶
func (*DirectiveIngress) MustAnnotate() []ast.Node
func (*DirectiveIngress) SetPosition ¶
func (d *DirectiveIngress) SetPosition(pos token.Pos)
func (*DirectiveIngress) String ¶
func (d *DirectiveIngress) String() string
type DirectiveRetry ¶
type DirectiveRetry struct { Pos token.Pos Count *int `parser:"'retry' (@Number Whitespace)?"` MinBackoff string `parser:"@(Number (?! Whitespace) Ident)?"` MaxBackoff string `parser:"@(Number (?! Whitespace) Ident)?"` }
func (*DirectiveRetry) GetPosition ¶
func (d *DirectiveRetry) GetPosition() token.Pos
func (*DirectiveRetry) GetTypeName ¶
func (*DirectiveRetry) GetTypeName() string
func (*DirectiveRetry) MustAnnotate ¶
func (*DirectiveRetry) MustAnnotate() []ast.Node
func (*DirectiveRetry) SetPosition ¶
func (d *DirectiveRetry) SetPosition(pos token.Pos)
func (*DirectiveRetry) String ¶
func (d *DirectiveRetry) String() string
type DirectiveSubscriber ¶
DirectiveSubscriber is used to subscribe a sink to a subscription
func (*DirectiveSubscriber) GetPosition ¶
func (d *DirectiveSubscriber) GetPosition() token.Pos
func (*DirectiveSubscriber) GetTypeName ¶
func (*DirectiveSubscriber) GetTypeName() string
func (*DirectiveSubscriber) MustAnnotate ¶
func (*DirectiveSubscriber) MustAnnotate() []ast.Node
func (*DirectiveSubscriber) SetPosition ¶
func (d *DirectiveSubscriber) SetPosition(pos token.Pos)
func (*DirectiveSubscriber) String ¶
func (d *DirectiveSubscriber) String() string
type DirectiveTypeAlias ¶
type DirectiveTypeAlias struct { Pos token.Pos TypeAlias bool `parser:"@'typealias'"` Export bool `parser:"@'export'?"` }
func (*DirectiveTypeAlias) GetPosition ¶
func (d *DirectiveTypeAlias) GetPosition() token.Pos
func (*DirectiveTypeAlias) GetTypeName ¶
func (*DirectiveTypeAlias) GetTypeName() string
func (*DirectiveTypeAlias) IsExported ¶
func (d *DirectiveTypeAlias) IsExported() bool
func (*DirectiveTypeAlias) MustAnnotate ¶
func (*DirectiveTypeAlias) MustAnnotate() []ast.Node
func (*DirectiveTypeAlias) SetPosition ¶
func (d *DirectiveTypeAlias) SetPosition(pos token.Pos)
func (*DirectiveTypeAlias) String ¶
func (d *DirectiveTypeAlias) String() string
type DirectiveTypeMap ¶ added in v0.282.0
type DirectiveTypeMap struct { Pos token.Pos Runtime string `parser:"'typemap' @('go' | 'kotlin')"` NativeName string `parser:"@String"` }
DirectiveTypeMap is used to declare a native type to deserialize to in a given runtime.
func (*DirectiveTypeMap) GetPosition ¶ added in v0.282.0
func (d *DirectiveTypeMap) GetPosition() token.Pos
func (*DirectiveTypeMap) GetTypeName ¶ added in v0.282.0
func (*DirectiveTypeMap) GetTypeName() string
func (*DirectiveTypeMap) MustAnnotate ¶ added in v0.282.0
func (*DirectiveTypeMap) MustAnnotate() []ast.Node
func (*DirectiveTypeMap) SetPosition ¶ added in v0.282.0
func (d *DirectiveTypeMap) SetPosition(pos token.Pos)
func (*DirectiveTypeMap) String ¶ added in v0.282.0
func (d *DirectiveTypeMap) String() string
type DirectiveVerb ¶
type DirectiveVerb struct { Pos token.Pos Verb bool `parser:"@'verb'"` Export bool `parser:"@'export'?"` }
func (*DirectiveVerb) GetPosition ¶
func (d *DirectiveVerb) GetPosition() token.Pos
func (*DirectiveVerb) GetTypeName ¶
func (*DirectiveVerb) GetTypeName() string
func (*DirectiveVerb) IsExported ¶
func (d *DirectiveVerb) IsExported() bool
func (*DirectiveVerb) MustAnnotate ¶
func (*DirectiveVerb) MustAnnotate() []ast.Node
func (*DirectiveVerb) SetPosition ¶
func (d *DirectiveVerb) SetPosition(pos token.Pos)
func (*DirectiveVerb) String ¶
func (d *DirectiveVerb) String() string
type Exportable ¶
type Exportable interface {
IsExported() bool
}
type ExtractDeclFunc ¶
type ExtractDeclFunc[T schema.Decl, N ast.Node] func(pass *analysis.Pass, node N, object types.Object) optional.Option[T]
func ExtractFuncForDecl ¶
type ExtractedDecl ¶
ExtractedDecl is a fact for associating an object with an extracted schema decl.
type ExtractedMetadata ¶
type ExtractedMetadata struct { Type schema.Decl IsExported bool Metadata []schema.Metadata Comments []string }
ExtractedMetadata is a fact for associating an object with extracted schema metadata.
type ExtractorResult ¶
type ExtractorResult struct {
Facts []analysis.ObjectFact
}
func NewExtractorResult ¶
func NewExtractorResult(pass *analysis.Pass) ExtractorResult
type FailedExtraction ¶
type FailedExtraction struct{}
FailedExtraction is a fact for marking a type that failed to be extracted by another extractor.
type MaybeTypeEnum ¶ added in v0.287.0
MaybeTypeEnum is a fact for marking an object as a possible type enum discriminator.
type MaybeTypeEnumVariant ¶ added in v0.287.0
type MaybeTypeEnumVariant struct { GetValue func(pass *analysis.Pass) optional.Option[*schema.TypeValue] // the parent enum Parent types.Object // this variant Variant *schema.EnumVariant }
MaybeTypeEnumVariant is a fact for marking an object as a possible type enum variant.
type MaybeValueEnumVariant ¶ added in v0.287.0
type MaybeValueEnumVariant struct { // this variant Variant *schema.EnumVariant }
MaybeValueEnumVariant is a fact for marking an object as a possible value enum variant.
type NeedsExtraction ¶
type NeedsExtraction struct{}
NeedsExtraction is a fact for marking a type that needs to be extracted by another extractor.
type SchemaFact ¶
type SchemaFact interface { analysis.Fact Add(v SchemaFactValue) Get() []SchemaFactValue }
SchemaFact is a fact that associates a schema node with a Go object.
type SchemaFactValue ¶
type SchemaFactValue interface {
// contains filtered or unexported methods
}
SchemaFactValue is the value of a SchemaFact.