Documentation
¶
Overview ¶
Package analyzers holds thrift-ls's built-in analyses: the checks, fixers, and action providers composed into the default pipeline. It is deliberately outside sema so the checks dogfood sema's public API — anything an analyzer needs (Index, SpanOf, TokenSpan, LineSpan, EnumMemberValues, codes) must exist for third-party analyzer authors too. Shared, analyzer-useful abstractions graduate to sema; anything specific to one check stays here, private.
Index ¶
- Constants
- func DefaultPipeline(cfg sema.Config) *sema.Pipeline
- func Defaults() []sema.Analyzer
- type AddIncludeFixer
- type CycleCheck
- type DuplicateCheck
- type EnumValueCheck
- type EnumValuesProvider
- type FieldIDCheck
- type FieldQualifierProvider
- type Include
- type IncludeShadowCheck
- type NonScalarMapKeyCheck
- type ParseCheck
- type SemanticAnalysis
- type UnusedIncludeCheck
Constants ¶
const NonScalarMapKeyCheckName = "NonScalarMapKeyCheck"
NonScalarMapKeyCheckName is the configuration name of NonScalarMapKeyCheck.
Variables ¶
This section is empty.
Functions ¶
func DefaultPipeline ¶
DefaultPipeline composes the built-in analyzers with their fixers and action providers.
Types ¶
type AddIncludeFixer ¶
type AddIncludeFixer struct{}
AddIncludeFixer offers the include that makes an undefined type resolve: the definition is searched across the workspace, so the fix works project-wide. It fixes only "undefined-type" diagnostics.
type CycleCheck ¶
type CycleCheck struct{}
CycleCheck reports include edges that close a cycle: the include X -> Y is reported when Y transitively includes X back. Cycles of any length are caught, including self-includes.
func (*CycleCheck) Name ¶
func (c *CycleCheck) Name() string
type DuplicateCheck ¶
type DuplicateCheck struct{}
DuplicateCheck reports the duplicates the compiler rejects: a name defined twice in one scope — structs, unions, exceptions, enums, members, fields, function arguments, service functions, typedefs, constants — enum members whose resolved value collides, and map keys or set values that repeat in a constant. Duplicates are ambiguous on the wire and in generated code, so they are errors.
func (*DuplicateCheck) AnalyzeFile ¶
func (c *DuplicateCheck) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error)
func (*DuplicateCheck) Name ¶
func (c *DuplicateCheck) Name() string
type EnumValueCheck ¶
type EnumValueCheck struct{}
func (*EnumValueCheck) AnalyzeFile ¶
func (c *EnumValueCheck) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error)
func (*EnumValueCheck) Name ¶
func (c *EnumValueCheck) Name() string
EnumValueCheck warns on enum members that lack an explicit value.
The compiler auto-increments implicit members: 0 for the first member, one greater than the preceding member's value otherwise. Their on-wire value therefore follows their position; inserting, removing, or reordering members silently changes serialized data.
type EnumValuesProvider ¶
type EnumValuesProvider struct{}
EnumValuesProvider offers the rewrite that appends an explicit value to every member of the enum containing the selection, mirroring the auto-incremented constants the compiler would assign. When a diagnostic overlaps the selection, the same action is also offered as its quickfix.
type FieldIDCheck ¶
type FieldIDCheck struct{}
func (*FieldIDCheck) AnalyzeFile ¶
func (c *FieldIDCheck) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error)
func (*FieldIDCheck) Name ¶
func (c *FieldIDCheck) Name() string
FieldIDCheck checks struct, union, exception, function parameter, and throws field ids: they must be unique positive integers in [1, 32767].
type FieldQualifierProvider ¶
type FieldQualifierProvider struct{}
FieldQualifierProvider offers the "Make field required" and "Make field optional" actions for the fields whose declaration line the selection covers. Every covered field yields one action per qualifier it does not already carry: an unqualified field gets both, a required field gets "Make field optional", and vice versa. Union fields never offer "Make field required": unions have no required members.
type IncludeShadowCheck ¶
type IncludeShadowCheck struct{}
IncludeShadowCheck warns when one include path matches files under more than one include path. The nearest include path wins; the warning names the rest.
func (*IncludeShadowCheck) AnalyzeFile ¶
func (c *IncludeShadowCheck) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error)
func (*IncludeShadowCheck) Name ¶
func (c *IncludeShadowCheck) Name() string
type NonScalarMapKeyCheck ¶
type NonScalarMapKeyCheck struct{}
NonScalarMapKeyCheck reports map key types that are not scalar or enum types. Structs, unions, exceptions, and containers are not valid map keys in standard Thrift, while typedefs are followed to their underlying type.
func (*NonScalarMapKeyCheck) AnalyzeFile ¶
func (c *NonScalarMapKeyCheck) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error)
func (*NonScalarMapKeyCheck) Name ¶
func (c *NonScalarMapKeyCheck) Name() string
type ParseCheck ¶
type ParseCheck struct{}
ParseCheck reports the lexer's and parser's errors and warnings for every changed file. It is a whole-run analyzer because it must see files whose AST is too broken for the other analyzers — they skip those, this one reports them.
func (*ParseCheck) Name ¶
func (p *ParseCheck) Name() string
type SemanticAnalysis ¶
type SemanticAnalysis struct{}
func (*SemanticAnalysis) AnalyzeFile ¶
func (s *SemanticAnalysis) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error)
func (*SemanticAnalysis) Name ¶
func (s *SemanticAnalysis) Name() string
type UnusedIncludeCheck ¶
type UnusedIncludeCheck struct{}
UnusedIncludeCheck reports an include no reference in the file resolves into. Unused includes bloat the compile and make the dependency graph look worse than it is.
func (*UnusedIncludeCheck) AnalyzeFile ¶
func (c *UnusedIncludeCheck) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error)
func (*UnusedIncludeCheck) Name ¶
func (c *UnusedIncludeCheck) Name() string