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 GetFact[T SchemaFactValue](facts []SchemaFact) optional.Option[T]
- func GetFactForObject[T SchemaFactValue](pass *analysis.Pass, obj types.Object) optional.Option[T]
- func GetFacts[T SchemaFactValue](pass *analysis.Pass) map[types.Object]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 MarkMetadata(pass *analysis.Pass, obj types.Object, md *ExtractedMetadata)
- func MarkSchemaDecl(pass *analysis.Pass, obj types.Object, decl schema.Decl)
- func MergeAllFacts(pass *analysis.Pass) map[types.Object]SchemaFact
- 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 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 GetFact ¶
func GetFact[T SchemaFactValue](facts []SchemaFact) optional.Option[T]
func GetFactForObject ¶
GetFactForObject returns the first fact of the provided type marked on the object.
func GetFacts ¶ added in v0.261.0
func GetFacts[T SchemaFactValue](pass *analysis.Pass) map[types.Object]T
func GetFactsForObject ¶
func GetFactsForObject[T SchemaFactValue](pass *analysis.Pass, obj types.Object) []T
GetFactsForObject returns all facts 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 MarkMetadata ¶
func MarkMetadata(pass *analysis.Pass, obj types.Object, md *ExtractedMetadata)
func MarkSchemaDecl ¶
MarkSchemaDecl marks the given object as having been extracted to the given schema node.
func MergeAllFacts ¶
func MergeAllFacts(pass *analysis.Pass) map[types.Object]SchemaFact
MergeAllFacts merges schema facts inclusive of all available results and the present pass facts.
If multiple facts are present for the same object, the facts will be prioritized by type: 1. ExtractedDecl 2. FailedExtraction 4. NeedsExtraction
ExtractedMetadata facts are ignored.
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]) Get ¶ added in v0.260.0
func (t *DefaultFact[T]) Get() SchemaFactValue
func (*DefaultFact[T]) Set ¶ added in v0.260.0
func (t *DefaultFact[T]) Set(v 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 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 Set(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.