Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var InspectorAnalyzer = &Analyzer{ Run: func(pass *Pass) interface{} { return ast.NewInspector(pass.Program.Program) }, }
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer struct { Description string Run func(*Pass) interface{} // Requires is a set of analyzers that must run before this one. // This analyzer may inspect the outputs produced by each analyzer in Requires. // The graph over analyzers implied by Requires edges must be acyclic Requires []*Analyzer }
Analyzer describes an analysis function and its options
type Config ¶
type Config struct { // ResolveAddressContractNames is called to resolve the contract names of an address location ResolveAddressContractNames func(address common.Address) ([]string, error) // ResolveCode is called to resolve an import to its source code ResolveCode func( location common.Location, importingLocation common.Location, importRange ast.Range, ) ([]byte, error) // Mode controls the level of information returned for each program Mode LoadMode // HandleParserError is called when a parser error occurs instead of returning it HandleParserError func(err ParsingCheckingError, program *ast.Program) error // HandleCheckerError is called when a checker error occurs instead of returning it HandleCheckerError func(err ParsingCheckingError, checker *sema.Checker) error // CryptoContractElaboration is the elaboration of the Crypto contract CryptoContractElaboration *sema.Elaboration }
A Config specifies details about how programs should be loaded. The zero value is a valid configuration. Calls to Load do not modify this struct.
type Diagnostic ¶
type Diagnostic struct { Location common.Location Category string Message string SecondaryMessage string Code string // Diagnostic code (e.g. "unused-variable") URL string // URL to documentation SuggestedFixes []SuggestedFix ast.Range }
func (Diagnostic) SuggestFixes ¶ added in v0.40.0
func (d Diagnostic) SuggestFixes(_ string) []SuggestedFix
type LoadMode ¶
type LoadMode int
LoadMode controls the amount of detail to return when loading. The bits below can be combined to specify what information is required.
const ( // NeedSyntax provides the AST. NeedSyntax LoadMode = 0 // NeedTypes provides the elaboration. NeedTypes LoadMode = 1 << iota // NeedPositionInfo provides position information (e.g. occurrences). NeedPositionInfo // NeedExtendedElaboration provides an extended elaboration. NeedExtendedElaboration )
type ParsingCheckingError ¶
type ParsingCheckingError struct {
// contains filtered or unexported fields
}
func (ParsingCheckingError) ChildErrors ¶
func (e ParsingCheckingError) ChildErrors() []error
func (ParsingCheckingError) ImportLocation ¶
func (e ParsingCheckingError) ImportLocation() common.Location
func (ParsingCheckingError) Unwrap ¶
func (e ParsingCheckingError) Unwrap() error
type Pass ¶
type Pass struct { Program *Program // Report reports a Diagnostic, a finding about a specific location // in the analyzed source code such as a potential mistake. // It may be called by the Analyzer.Run function. Report func(Diagnostic) // ResultOf provides the inputs to this analysis pass, // which are the corresponding results of its prerequisite analyzers. // The map keys are the elements of Analyzer.Requires. ResultOf map[*Analyzer]interface{} }
Pass provides information to the Analyzer.Run function, which applies a specific analyzer to a single location.
type Program ¶
type Program struct { Location common.Location Program *ast.Program Checker *sema.Checker Code []byte LoadError error }
func (*Program) Run ¶
func (program *Program) Run(analyzers []*Analyzer, report func(Diagnostic))
Run runs the given DAG of analyzers in parallel
type Programs ¶
type Programs struct { Programs map[common.Location]*Program CryptoContractElaboration *sema.Elaboration }
type SuggestedFix ¶ added in v0.39.6
type SuggestedFix = errors.SuggestedFix[ast.TextEdit]
Click to show internal directories.
Click to hide internal directories.