Documentation ¶
Index ¶
- Constants
- type File
- func (pgf File) Fixed() bool
- func (pgf *File) NodeLocation(node ast.Node) (protocol.Location, error)
- func (pgf *File) NodeMappedRange(node ast.Node) (protocol.MappedRange, error)
- func (pgf *File) NodeRange(node ast.Node) (protocol.Range, error)
- func (pgf *File) PosLocation(start, end token.Pos) (protocol.Location, error)
- func (pgf *File) PosMappedRange(start, end token.Pos) (protocol.MappedRange, error)
- func (pgf *File) PosRange(start, end token.Pos) (protocol.Range, error)
- func (pgf *File) PositionPos(p protocol.Position) (token.Pos, error)
- func (pgf *File) RangePos(r protocol.Range) (token.Pos, token.Pos, error)
- func (pgf File) String() string
Constants ¶
const ( // Header specifies that the main package declaration and imports are needed. // This is the mode used when attempting to examine the package graph structure. Header = parser.AllErrors | parser.ParseComments | parser.ImportsOnly | parser.SkipObjectResolution // Full specifies the full AST is needed. // This is used for files of direct interest where the entire contents must // be considered. Full = parser.AllErrors | parser.ParseComments | parser.SkipObjectResolution )
Common parse modes; these should be reused wherever possible to increase cache hits.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { URI protocol.DocumentURI Mode parser.Mode File *ast.File Tok *token.File // Source code used to build the AST. It may be different from the // actual content of the file if we have fixed the AST. Src []byte Mapper *protocol.Mapper // may map fixed Src, not file content ParseErr scanner.ErrorList // contains filtered or unexported fields }
A File contains the results of parsing a Go file.
func Parse ¶
func Parse(ctx context.Context, fset *token.FileSet, uri protocol.DocumentURI, src []byte, mode parser.Mode, purgeFuncBodies bool) (res *File, fixes []fixType)
Parse parses a buffer of Go source, repairing the tree if necessary.
The provided ctx is used only for logging.
func (File) Fixed ¶
Fixed reports whether p was "Fixed", meaning that its source or positions may not correlate with the original file.
func (*File) NodeLocation ¶
NodeLocation returns a protocol Location for the ast.Node interval in this file.
func (*File) NodeMappedRange ¶
NodeMappedRange returns a MappedRange for the ast.Node interval in this file. A MappedRange can be converted to any other form.
func (*File) PosLocation ¶
PosLocation returns a protocol Location for the token.Pos interval in this file.
func (*File) PosMappedRange ¶
PosMappedRange returns a MappedRange for the token.Pos interval in this file. A MappedRange can be converted to any other form.
func (*File) PositionPos ¶
PositionPos returns the token.Pos of protocol position p within the file.