const reservedForParsing … // fileSetWithBase returns a new token.FileSet with Base() equal to the // requested base. // // If base < 1, fileSetWithBase panics. // (1 is the smallest permitted FileSet base). func fileSetWithBase(base int) *token.FileSet { … } const parseCacheMinFiles … var parsePadding … type parseCache … // newParseCache creates a new parse cache and starts a goroutine to garbage // collect entries whose age is at least expireAfter. // // Callers must call parseCache.stop when the parse cache is no longer in use. func newParseCache(expireAfter time.Duration) *parseCache { … } // stop causes the GC goroutine to exit. func (c *parseCache) stop() { … } type parseKey … type parseCacheEntry … // startParse prepares a parsing pass, creating new promises in the cache for // any cache misses. // // The resulting slice has an entry for every given file handle, though some // entries may be nil if there was an error reading the file (in which case the // resulting error will be non-nil). func (c *parseCache) startParse(mode parser.Mode, purgeFuncBodies bool, fhs ...file.Handle) ([]*memoize.Promise, error) { … } func (c *parseCache) gc() { … } func (c *parseCache) gcOnce() { … } // allocateSpace reserves the next n bytes of token.Pos space in the // cache. // // It returns the resulting file base, next base, and an offset FileSet to use // for parsing. func (c *parseCache) allocateSpace(size int) (int, int) { … } // parseFiles returns a parsego.File for each file handle in fhs, in the // requested parse mode. // // For parsed files that already exists in the cache, access time will be // updated. For others, parseFiles will parse and store as many results in the // cache as space allows. // // The token.File for each resulting parsed file will be added to the provided // FileSet, using the tokeninternal.AddExistingFiles API. Consequently, the // given fset should only be used in other APIs if its base is >= // reservedForParsing. // // If parseFiles returns an error, it still returns a slice, // but with a nil entry for each file that could not be parsed. func (c *parseCache) parseFiles(ctx context.Context, fset *token.FileSet, mode parser.Mode, purgeFuncBodies bool, fhs ...file.Handle) ([]*parsego.File, error) { … } type queue … func (q queue) Len() int { … } func (q queue) Less(i, j int) bool { … } func (q queue) Swap(i, j int) { … } func (q *queue) Push(x interface{ … } func (q *queue) Pop() interface{ … }