MCPcopy
hub / github.com/golang/tools / parseGoImpl

Function parseGoImpl

gopls/internal/cache/parse.go:30–45  ·  view source on GitHub ↗

parseGoImpl parses the Go source file whose content is provided by fh.

(ctx context.Context, fset *token.FileSet, fh file.Handle, mode parser.Mode, purgeFuncBodies bool)

Source from the content-addressed store, hash-verified

28
29// parseGoImpl parses the Go source file whose content is provided by fh.
30func parseGoImpl(ctx context.Context, fset *token.FileSet, fh file.Handle, mode parser.Mode, purgeFuncBodies bool) (*parsego.File, error) {
31 ext := filepath.Ext(fh.URI().Path())
32 if ext != ".go" && ext != "" { // files generated by cgo have no extension
33 return nil, fmt.Errorf("cannot parse non-Go file %s", fh.URI())
34 }
35 content, err := fh.Content()
36 if err != nil {
37 return nil, err
38 }
39 // Check for context cancellation before actually doing the parse.
40 if ctx.Err() != nil {
41 return nil, ctx.Err()
42 }
43 pgf, _ := parsego.Parse(ctx, fset, fh.URI(), content, mode, purgeFuncBodies) // ignore 'fixes'
44 return pgf, nil
45}

Callers 3

parseFilesMethod · 0.85
checkPackageForImportMethod · 0.85
parseGoURIFunction · 0.85

Calls 6

ParseFunction · 0.92
PathMethod · 0.80
URIMethod · 0.65
ErrorfMethod · 0.65
ContentMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…