// IsGenerated gets and reads the file denoted by uri and reports // whether it contains a "generated file" comment as described at // https://golang.org/s/generatedcode. // // TODO(adonovan): opt: this function does too much. // Move snapshot.ReadFile into the caller (most of which have already done it). func IsGenerated(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) bool { … } // adjustedObjEnd returns the end position of obj, possibly modified for // package names. // // TODO(rfindley): eliminate this function, by inlining it at callsites where // it makes sense. func adjustedObjEnd(obj types.Object) token.Pos { … } var generatedRx … // FormatNode returns the "pretty-print" output for an ast node. func FormatNode(fset *token.FileSet, n ast.Node) string { … } // formatNodeFile is like FormatNode, but requires only the token.File for the // syntax containing the given ast node. func formatNodeFile(file *token.File, n ast.Node) string { … } // findFileInDeps finds package metadata containing URI in the transitive // dependencies of m. When using the Go command, the answer is unique. func findFileInDeps(s metadata.Source, mp *metadata.Package, uri protocol.DocumentURI) *metadata.Package { … } // CollectScopes returns all scopes in an ast path, ordered as innermost scope // first. func CollectScopes(info *types.Info, path []ast.Node, pos token.Pos) []*types.Scope { … } // requalifier returns a function that re-qualifies identifiers and qualified // identifiers contained in targetFile using the given metadata qualifier. func requalifier(s metadata.Source, targetFile *ast.File, targetMeta *metadata.Package, mq MetadataQualifier) func(string) string { … } type MetadataQualifier … // MetadataQualifierForFile returns a metadata qualifier that chooses the best // qualification of an imported package relative to the file f in package with // metadata m. func MetadataQualifierForFile(s metadata.Source, f *ast.File, mp *metadata.Package) MetadataQualifier { … } // importInfo collects information about the import specified by imp, // extracting its file-local name, package name, import path, and package path. // // If metadata is missing for the import, the resulting package name and // package path may be empty, and the file local name may be guessed based on // the import path. // // Note: previous versions of this helper used a PackageID->PackagePath map // extracted from m, for extracting package path even in the case where // metadata for a dep was missing. This should not be necessary, as we should // always have metadata for IDs contained in DepsByPkgPath. func importInfo(s metadata.Source, imp *ast.ImportSpec, mp *metadata.Package) (string, PackageName, ImportPath, PackagePath) { … } // isDirective reports whether c is a comment directive. // // Copied and adapted from go/src/go/ast/ast.go. func isDirective(c string) bool { … } // embeddedIdent returns the type name identifier for an embedding x, if x in a // valid embedding. Otherwise, it returns nil. // // Spec: An embedded field must be specified as a type name T or as a pointer // to a non-interface type name *T func embeddedIdent(x ast.Expr) *ast.Ident { … } type ImporterFunc … func (f ImporterFunc) Import(path string) (*types.Package, error) { … } // isBuiltin reports whether obj is a built-in symbol (e.g. append, iota, error.Error, unsafe.Slice). // All other symbols have a valid position and a valid package. func isBuiltin(obj types.Object) bool { … } // btoi returns int(b) as proposed in #64825. func btoi(b bool) int { … } // AbbreviateVarName returns an abbreviated var name based on the given full // name (which may be a type name, for example). // // See the simple heuristics documented in line. func AbbreviateVarName(s string) string { … } // copyrightComment returns the copyright comment group from the input file, or // nil if not found. func copyrightComment(file *ast.File) *ast.CommentGroup { … } var buildConstraintRe … // buildConstraintComment returns the build constraint comment from the input // file. // Returns nil if not found. func buildConstraintComment(file *ast.File) *ast.Comment { … }