const AnalysisProgressTitle … // Analyze applies the set of enabled analyzers to the packages in the pkgs // map, and returns their diagnostics. // // Notifications of progress may be sent to the optional reporter. func (s *Snapshot) Analyze(ctx context.Context, pkgs map[PackageID]*metadata.Package, reporter *progress.Tracker) ([]*Diagnostic, error) { … } func analyzers(staticcheck bool) []*settings.Analyzer { … } func (an *analysisNode) decrefPreds() { … } type analysisNode … func (an *analysisNode) String() string { … } // summaryHash computes the hash of the node summary, which may affect other // nodes depending on this node. // // The result is memoized to avoid redundant work when analyzing multiple // dependents. func (an *analysisNode) summaryHash() file.Hash { … } type analyzeSummary … type actionMap … var _ … var _ … type actionsMapEntry … func (m actionMap) GobEncode() ([]byte, error) { … } func (m *actionMap) GobDecode(data []byte) error { … } type actionSummary … var inFlightAnalyses … var cacheLimit … // runCached applies a list of analyzers (plus any others // transitively required by them) to a package. It succeeds as long // as it could produce a types.Package, even if there were direct or // indirect list/parse/type errors, and even if all the analysis // actions failed. It usually fails only if the package was unknown, // a file was missing, or the operation was cancelled. // // The provided key is the cache key for this package. func (an *analysisNode) runCached(ctx context.Context, key file.Hash) (*analyzeSummary, error) { … } // analysisCacheKey returns a cache key that is a cryptographic digest // of the all the values that might affect type checking and analysis: // the analyzer names, package metadata, names and contents of // compiled Go files, and vdeps (successor) information // (export data and facts). func (an *analysisNode) cacheKey() file.Hash { … } // run implements the cache-miss case. // This function does not access the snapshot. // // Postcondition: on success, the analyzeSummary.Actions // key set is {a.Name for a in analyzers}. func (an *analysisNode) run(ctx context.Context) (*analyzeSummary, error) { … } func (an *analysisNode) typeCheck(ctx context.Context) (*analysisPackage, error) { … } // typesLookup implements a concurrency safe depth-first traversal searching // imports of pkg for a given package path. func typesLookup(pkg *types.Package) func(string) *types.Package { … } type analysisPackage … type action … func (act *action) String() string { … } // execActions executes a set of action graph nodes in parallel. // Postcondition: each action.summary is set, even in case of error. func execActions(ctx context.Context, actions []*action) { … } // exec defines the execution of a single action. // It returns the (ephemeral) result of the analyzer's Run function, // along with its (serializable) facts and diagnostics. // Or it returns an error if the analyzer did not run to // completion and deliver a valid result. func (act *action) exec(ctx context.Context) (any, *actionSummary, error) { … } var analyzerRunTimesMu … var analyzerRunTimes … type LabelDuration … // AnalyzerRunTimes returns the accumulated time spent in each Analyzer's // Run function since process start, in descending order. func AnalyzerRunTimes() []LabelDuration { … } // requiredAnalyzers returns the transitive closure of required analyzers in preorder. func requiredAnalyzers(analyzers []*analysis.Analyzer) []*analysis.Analyzer { … } var analyzeSummaryCodec … var diagnosticsCodec … type gobDiagnostic … type gobRelatedInformation … type gobSuggestedFix … type gobCommand … type gobTextEdit … // toGobDiagnostic converts an analysis.Diagnosic to a serializable gobDiagnostic, // which requires expanding token.Pos positions into protocol.Location form. func toGobDiagnostic(posToLocation func(start, end token.Pos) (protocol.Location, error), a *analysis.Analyzer, diag analysis.Diagnostic) (gobDiagnostic, error) { … } // effectiveURL computes the effective URL of diag, // using the algorithm specified at Diagnostic.URL. func effectiveURL(a *analysis.Analyzer, diag analysis.Diagnostic) string { … } // stableName returns a name for the analyzer that is unique and // stable across address spaces. // // Analyzer names are not unique. For example, gopls includes // both x/tools/passes/nilness and staticcheck/nilness. // For serialization, we must assign each analyzer a unique identifier // that two gopls processes accessing the cache can agree on. func stableName(a *analysis.Analyzer) string { … }