Documentation
¶
Index ¶
- func CalculateOffsetForPosition(read io.Reader, line, character int) (int, error)
- func WithinPosition(target, start, end *token.Position) bool
- type DistinctPackage
- type File
- type FileError
- type Loader
- func (l *Loader) Errors(handleErrs func(file string, errs []FileError))
- func (l *Loader) FindDistinctPackage(absPath string) (*DistinctPackage, error)
- func (l *Loader) FindImportPath(dp *DistinctPackage, importPath string) (string, error)
- func (l *Loader) GetTags() string
- func (l *Loader) HandleTypeCheckerError(e error)
- func (l *Loader) LoadDirectory(startDir string) error
- func (l *Loader) Signal()
- func (l *Loader) String() string
- func (l *Loader) Wait()
- type LoaderEngine
- type LoaderOption
- type OpenedFiles
- type OverrunError
- type OverrunType
- type Package
- type Workspace
- func (w *Workspace) AssignLoader(l *Loader)
- func (w *Workspace) ChangeFile(absFilepath string, startLine, startCharacter, endLine, endCharacter int, ...) error
- func (w *Workspace) CloseFile(absPath string) error
- func (w *Workspace) Hover(p *token.Position) (string, error)
- func (w *Workspace) LocateDeclaration(p *token.Position) (*token.Position, error)
- func (w *Workspace) LocateIdent(p *token.Position) (*ast.Ident, error)
- func (w *Workspace) LocateReferences(p *token.Position) []token.Position
- func (w *Workspace) OpenFile(absFilepath, text string) error
- func (w *Workspace) ReplaceFile(absFilepath, text string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateOffsetForPosition ¶
CalculateOffsetForPosition scans a rope to get to the rune offset at the given line and character
func WithinPosition ¶
WithinPosition checks to see if a target position is inclusively within two other positions.
Types ¶
type DistinctPackage ¶
type DistinctPackage struct { Package *Package // contains filtered or unexported fields }
DistinctPackage contains the os/arch specific package AST
func NewDistinctPackage ¶
func NewDistinctPackage(l *Loader, p *Package) *DistinctPackage
NewDistinctPackage returns a new instance of DistinctPackage
func (*DistinctPackage) Hash ¶
func (dp *DistinctPackage) Hash() collections.Hash
Hash returns the hash for this distinct package
func (*DistinctPackage) Invalidate ¶
func (dp *DistinctPackage) Invalidate()
Invalidate sets the checker to nil and the loadState to unloaded
func (*DistinctPackage) String ¶
func (dp *DistinctPackage) String() string
func (*DistinctPackage) WaitUntilReady ¶
func (dp *DistinctPackage) WaitUntilReady(loadState loadState)
WaitUntilReady blocks until this distinct package has loaded sufficiently for the requested load state.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is an AST file and any errors that types.Config.Check discovers
type Loader ¶
type Loader struct { StartDir string Tags []string Log *log.Log // contains filtered or unexported fields }
Loader is the workspace-specific configuration and context for building and type-checking
func NewLoader ¶
func NewLoader(le *LoaderEngine, goos, goarch, goroot string, options ...LoaderOption) *Loader
NewLoader creates a new Loader
func (*Loader) Errors ¶
Errors exposes problems with code found during compilation on a file-by-file basis.
func (*Loader) FindDistinctPackage ¶
func (l *Loader) FindDistinctPackage(absPath string) (*DistinctPackage, error)
FindDistinctPackage will locate the distinct package at the provided path
func (*Loader) FindImportPath ¶
func (l *Loader) FindImportPath(dp *DistinctPackage, importPath string) (string, error)
func (*Loader) HandleTypeCheckerError ¶
HandleTypeCheckerError is invoked from the types.Checker when it encounters errors
func (*Loader) LoadDirectory ¶
LoadDirectory adds the contents of a directory to the Loader
type LoaderEngine ¶
LoaderEngine is a Go code loader
func (*LoaderEngine) Close ¶
func (le *LoaderEngine) Close() error
Close stops the loader engine processing
func (*LoaderEngine) InvalidatePackage ¶
func (le *LoaderEngine) InvalidatePackage(absPath string)
InvalidatePackage invalidates all the distinct packages that point to the package at this path, as well as any paths that import this, and down the import graph.
type LoaderOption ¶
type LoaderOption func(l *Loader)
LoaderOption provides a hook for NewLoader to set or modify the new loader's build.Context
type OpenedFiles ¶
type OpenedFiles struct {
// contains filtered or unexported fields
}
OpenedFiles is a collection of files opened across the caravan
func NewOpenedFiles ¶
func NewOpenedFiles() *OpenedFiles
NewOpenedFiles creates a new OpenedFiles instance
func (*OpenedFiles) Close ¶
func (of *OpenedFiles) Close(absFilepath string) error
Close will remove a rope from the collection
func (*OpenedFiles) EnsureOpened ¶
func (of *OpenedFiles) EnsureOpened(absFilepath, text string) error
EnsureOpened will create a new rope for a file that's not previously opened
func (*OpenedFiles) Get ¶
func (of *OpenedFiles) Get(absFilepath string) (*rope.Rope, error)
Get returns the rope for a file
func (*OpenedFiles) Replace ¶
func (of *OpenedFiles) Replace(absFilepath, text string) error
Replace will replace an existing rope with a completely new rope based on the provided text
type OverrunError ¶
type OverrunError struct {
// contains filtered or unexported fields
}
OverrunError is returned from CalculateOffsetForPosistion when the requested line does not have enough characters to find an offset
func NewOverrunError ¶
func NewOverrunError(overrun OverrunType, line, char int) *OverrunError
NewOverrunError creates a new OverrunError instance
func (*OverrunError) Error ¶
func (oe *OverrunError) Error() string
type OverrunType ¶
type OverrunType int
OverrunType describes the reason for the overrun error
const ( // Line indicates that the overrun occured because there were not enough // lines to get the offset for the requested position Line OverrunType = iota // Character indicates that the overrun occured because the line did not // have enough characters to get the offset for the requested position Character )
type Package ¶
type Package struct { AbsPath string Fset *token.FileSet // contains filtered or unexported fields }
Package is the contents of a package
func NewPackage ¶
NewPackage creates a new instance of a Package struct
func (*Package) Invalidate ¶
func (p *Package) Invalidate()
Invalidate resets the checker state for all distinct packages
type Workspace ¶
type Workspace struct { LoaderEngine *LoaderEngine Loader *Loader // contains filtered or unexported fields }
Workspace is a mass of code
func CreateWorkspace ¶
func CreateWorkspace(le *LoaderEngine, log *log.Log) *Workspace
CreateWorkspace returns a new instance of the Workspace struct
func (*Workspace) AssignLoader ¶
AssignLoader attaches the new loader context to the workspace. The workspace should start to reload the packages.
func (*Workspace) ChangeFile ¶
func (w *Workspace) ChangeFile(absFilepath string, startLine, startCharacter, endLine, endCharacter int, text string) error
ChangeFile applies changes to an opened file
func (*Workspace) LocateDeclaration ¶
LocateDeclaration returns the position where the provided identifier is declared & defined
func (*Workspace) LocateIdent ¶
LocateIdent scans the loaded fset for the identifier at the requested position
func (*Workspace) LocateReferences ¶
LocateReferences returns the array of positions where the given identifier is referenced or used
func (*Workspace) OpenFile ¶
OpenFile shadows the file read from the disk with an in-memory version, which the workspace can accept edits to.
func (*Workspace) ReplaceFile ¶
ReplaceFile replaces the entire contents of an opened file