Documentation ¶
Overview ¶
Package fake provides a fake implementation of an LSP-enabled text editor, its LSP client plugin, and a Sandbox environment for use in integration tests.
The Editor type provides a high level API for text editor operations (open/modify/save/close a buffer, jump to definition, etc.), and the Client type exposes an LSP client for the editor that can be connected to a language server. By default, the Editor and Client should be compliant with the LSP spec: their intended use is to verify server compliance with the spec in a variety of environment. Possible future enhancements of these types may allow them to misbehave in configurable ways, but that is not their primary use.
The Sandbox type provides a facility for executing tests with a temporary directory, module proxy, and GOPATH.
Index ¶
- Variables
- func NewEdit(startLine, startColumn, endLine, endColumn uint32, text string) protocol.TextEdit
- func Tempdir(files map[string][]byte) (string, error)
- func UnpackTxt(txt string) map[string][]byte
- func WriteProxy(tmpdir string, files map[string][]byte) (string, error)
- type CallCounts
- type Client
- func (c *Client) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error)
- func (c *Client) CodeLensRefresh(context.Context) error
- func (c *Client) Configuration(_ context.Context, p *protocol.ParamConfiguration) ([]interface{}, error)
- func (c *Client) DiagnosticRefresh(context.Context) error
- func (c *Client) Event(ctx context.Context, event *interface{}) error
- func (c *Client) FoldingRangeRefresh(context.Context) error
- func (c *Client) InlayHintRefresh(context.Context) error
- func (c *Client) InlineValueRefresh(context.Context) error
- func (c *Client) LogMessage(ctx context.Context, params *protocol.LogMessageParams) error
- func (c *Client) LogTrace(context.Context, *protocol.LogTraceParams) error
- func (c *Client) Progress(ctx context.Context, params *protocol.ProgressParams) error
- func (c *Client) PublishDiagnostics(ctx context.Context, params *protocol.PublishDiagnosticsParams) error
- func (c *Client) RegisterCapability(ctx context.Context, params *protocol.RegistrationParams) error
- func (c *Client) SemanticTokensRefresh(context.Context) error
- func (c *Client) ShowDocument(ctx context.Context, params *protocol.ShowDocumentParams) (*protocol.ShowDocumentResult, error)
- func (c *Client) ShowMessage(ctx context.Context, params *protocol.ShowMessageParams) error
- func (c *Client) ShowMessageRequest(ctx context.Context, params *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error)
- func (c *Client) UnregisterCapability(ctx context.Context, params *protocol.UnregistrationParams) error
- func (c *Client) WorkDoneProgressCreate(ctx context.Context, params *protocol.WorkDoneProgressCreateParams) error
- func (c *Client) WorkspaceFolders(context.Context) ([]protocol.WorkspaceFolder, error)
- type ClientHooks
- type Editor
- func (e *Editor) AcceptCompletion(ctx context.Context, loc protocol.Location, item protocol.CompletionItem) error
- func (e *Editor) ApplyCodeAction(ctx context.Context, action protocol.CodeAction) error
- func (e *Editor) ApplyQuickFixes(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic) error
- func (e *Editor) BufferText(name string) (string, bool)
- func (e *Editor) BufferVersion(name string) int
- func (e *Editor) ChangeConfiguration(ctx context.Context, newConfig EditorConfig) error
- func (e *Editor) ChangeWorkspaceFolders(ctx context.Context, folders []string) error
- func (e *Editor) Client() *Client
- func (e *Editor) Close(ctx context.Context) error
- func (e *Editor) CloseBuffer(ctx context.Context, path string) error
- func (e *Editor) CodeAction(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic) ([]protocol.CodeAction, error)
- func (e *Editor) CodeActions(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic, ...) ([]protocol.CodeAction, error)
- func (e *Editor) CodeLens(ctx context.Context, path string) ([]protocol.CodeLens, error)
- func (e *Editor) Completion(ctx context.Context, loc protocol.Location) (*protocol.CompletionList, error)
- func (e *Editor) Config() EditorConfig
- func (e *Editor) Connect(ctx context.Context, connector servertest.Connector, hooks ClientHooks, ...) (*Editor, error)
- func (e *Editor) CreateBuffer(ctx context.Context, path, content string) error
- func (e *Editor) Definition(ctx context.Context, loc protocol.Location) (protocol.Location, error)
- func (e *Editor) DocumentHighlight(ctx context.Context, loc protocol.Location) ([]protocol.DocumentHighlight, error)
- func (e *Editor) DocumentLink(ctx context.Context, path string) ([]protocol.DocumentLink, error)
- func (e *Editor) EditBuffer(ctx context.Context, path string, edits []protocol.TextEdit) error
- func (e *Editor) EditResolveSupport() (bool, error)
- func (e *Editor) ExecuteCommand(ctx context.Context, params *protocol.ExecuteCommandParams) (interface{}, error)
- func (e *Editor) Exit(ctx context.Context) error
- func (e *Editor) FormatBuffer(ctx context.Context, path string) error
- func (e *Editor) GetQuickFixes(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic) ([]protocol.CodeAction, error)
- func (e *Editor) HasBuffer(name string) bool
- func (e *Editor) HasCommand(id string) bool
- func (e *Editor) Hover(ctx context.Context, loc protocol.Location) (*protocol.MarkupContent, protocol.Location, error)
- func (e *Editor) Implementations(ctx context.Context, loc protocol.Location) ([]protocol.Location, error)
- func (e *Editor) InlayHint(ctx context.Context, path string) ([]protocol.InlayHint, error)
- func (e *Editor) Mapper(name string) (*protocol.Mapper, error)
- func (e *Editor) OpenFile(ctx context.Context, path string) error
- func (e *Editor) OrganizeImports(ctx context.Context, path string) error
- func (e *Editor) RefactorRewrite(ctx context.Context, loc protocol.Location) error
- func (e *Editor) References(ctx context.Context, loc protocol.Location) ([]protocol.Location, error)
- func (e *Editor) RegexpReplace(ctx context.Context, path, re, replace string) error
- func (e *Editor) RegexpSearch(bufName, re string) (protocol.Location, error)
- func (e *Editor) Rename(ctx context.Context, loc protocol.Location, newName string) error
- func (e *Editor) RenameFile(ctx context.Context, oldPath, newPath string) error
- func (e *Editor) RunGenerate(ctx context.Context, dir string) error
- func (e *Editor) SaveBuffer(ctx context.Context, path string) error
- func (e *Editor) SaveBufferWithoutActions(ctx context.Context, path string) error
- func (e *Editor) SemanticTokensFull(ctx context.Context, path string) ([]SemanticToken, error)
- func (e *Editor) SemanticTokensRange(ctx context.Context, loc protocol.Location) ([]SemanticToken, error)
- func (e *Editor) SetBufferContent(ctx context.Context, path, content string) error
- func (e *Editor) SetConfig(cfg EditorConfig)
- func (e *Editor) Shutdown(ctx context.Context) error
- func (e *Editor) SignatureHelp(ctx context.Context, loc protocol.Location) (*protocol.SignatureHelp, error)
- func (e *Editor) Stats() CallCounts
- func (e *Editor) Symbol(ctx context.Context, query string) ([]protocol.SymbolInformation, error)
- func (e *Editor) Symbols(ctx context.Context, sym string) ([]protocol.SymbolInformation, error)
- func (e *Editor) TextDocumentIdentifier(path string) protocol.TextDocumentIdentifier
- func (e *Editor) TypeDefinition(ctx context.Context, loc protocol.Location) (protocol.Location, error)
- type EditorConfig
- type RelativeTo
- type Sandbox
- func (sb *Sandbox) Close() error
- func (sb *Sandbox) GOPATH() string
- func (sb *Sandbox) GoEnv() map[string]string
- func (sb *Sandbox) GoVersion(ctx context.Context) (int, error)
- func (sb *Sandbox) RootDir() string
- func (sb *Sandbox) RunGoCommand(ctx context.Context, dir, verb string, args, env []string, ...) error
- type SandboxConfig
- type SemanticToken
- type Workdir
- func (w *Workdir) AddWatcher(watcher func(context.Context, []protocol.FileEvent))
- func (w *Workdir) CheckForFileChanges(ctx context.Context) error
- func (w *Workdir) ListFiles(dir string) ([]string, error)
- func (w *Workdir) ReadFile(path string) ([]byte, error)
- func (w *Workdir) RegexpSearch(path string, re string) (protocol.Location, error)
- func (w *Workdir) RemoveFile(ctx context.Context, path string) error
- func (w *Workdir) RenameFile(ctx context.Context, oldPath, newPath string) error
- func (w *Workdir) RootURI() protocol.DocumentURI
- func (w *Workdir) URI(path string) protocol.DocumentURI
- func (w *Workdir) URIToPath(uri protocol.DocumentURI) string
- func (w *Workdir) WriteFile(ctx context.Context, path, content string) error
- func (w *Workdir) WriteFiles(ctx context.Context, files map[string]string) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoMatch = errors.New("no match") ErrUnknownBuffer = errors.New("unknown buffer") )
ErrNoMatch is returned if a regexp search fails.
Functions ¶
func NewEdit ¶
NewEdit creates an edit replacing all content between the 0-based (startLine, startColumn) and (endLine, endColumn) with text.
Columns measure UTF-16 codes.
Types ¶
type CallCounts ¶
type CallCounts struct {
DidOpen, DidChange, DidSave, DidChangeWatchedFiles, DidClose, DidChangeConfiguration uint64
}
CallCounts tracks the number of protocol notifications of different types.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an implementation of the protocol.Client interface based on the test's fake Editor. It mostly delegates functionality to hooks that can be configured by tests.
func (*Client) ApplyEdit ¶
func (c *Client) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error)
func (*Client) Configuration ¶
func (*Client) LogMessage ¶
func (*Client) PublishDiagnostics ¶
func (*Client) RegisterCapability ¶
func (*Client) SemanticTokensRefresh ¶
func (*Client) ShowDocument ¶
func (c *Client) ShowDocument(ctx context.Context, params *protocol.ShowDocumentParams) (*protocol.ShowDocumentResult, error)
func (*Client) ShowMessage ¶
func (*Client) ShowMessageRequest ¶
func (c *Client) ShowMessageRequest(ctx context.Context, params *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error)
func (*Client) UnregisterCapability ¶
func (*Client) WorkDoneProgressCreate ¶
func (*Client) WorkspaceFolders ¶
type ClientHooks ¶
type ClientHooks struct { OnLogMessage func(context.Context, *protocol.LogMessageParams) error OnDiagnostics func(context.Context, *protocol.PublishDiagnosticsParams) error OnWorkDoneProgressCreate func(context.Context, *protocol.WorkDoneProgressCreateParams) error OnProgress func(context.Context, *protocol.ProgressParams) error OnShowDocument func(context.Context, *protocol.ShowDocumentParams) error OnShowMessage func(context.Context, *protocol.ShowMessageParams) error OnShowMessageRequest func(context.Context, *protocol.ShowMessageRequestParams) error OnRegisterCapability func(context.Context, *protocol.RegistrationParams) error OnUnregisterCapability func(context.Context, *protocol.UnregistrationParams) error OnApplyEdit func(context.Context, *protocol.ApplyWorkspaceEditParams) error }
ClientHooks are a set of optional hooks called during handling of the corresponding client method (see protocol.Client for the LSP server-to-client RPCs) in order to make test expectations awaitable.
type Editor ¶
type Editor struct { // Server, client, and sandbox are concurrency safe and written only // at construction time, so do not require synchronization. Server protocol.Server // contains filtered or unexported fields }
Editor is a fake client editor. It keeps track of client state and can be used for writing LSP tests.
func NewEditor ¶
func NewEditor(sandbox *Sandbox, config EditorConfig) *Editor
NewEditor creates a new Editor.
func (*Editor) AcceptCompletion ¶
func (e *Editor) AcceptCompletion(ctx context.Context, loc protocol.Location, item protocol.CompletionItem) error
AcceptCompletion accepts a completion for the given item at the given position.
func (*Editor) ApplyCodeAction ¶
ApplyCodeAction applies the given code action.
func (*Editor) ApplyQuickFixes ¶
func (e *Editor) ApplyQuickFixes(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic) error
ApplyQuickFixes requests and performs the quickfix codeAction.
func (*Editor) BufferText ¶
BufferText returns the content of the buffer with the given name, or "" if the file at that path is not open. The second return value reports whether the file is open.
func (*Editor) BufferVersion ¶
BufferVersion returns the current version of the buffer corresponding to name (or 0 if it is not being edited).
func (*Editor) ChangeConfiguration ¶
func (e *Editor) ChangeConfiguration(ctx context.Context, newConfig EditorConfig) error
ChangeConfiguration sets the new editor configuration, and if applicable sends a didChangeConfiguration notification.
An error is returned if the change notification failed to send.
func (*Editor) ChangeWorkspaceFolders ¶
ChangeWorkspaceFolders sets the new workspace folders, and sends a didChangeWorkspaceFolders notification to the server.
The given folders must all be unique.
func (*Editor) CloseBuffer ¶
CloseBuffer removes the current buffer (regardless of whether it is saved).
func (*Editor) CodeAction ¶
func (e *Editor) CodeAction(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic) ([]protocol.CodeAction, error)
CodeAction executes a codeAction request on the server. If loc.Range is zero, the whole file is implied.
func (*Editor) CodeActions ¶
func (e *Editor) CodeActions(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic, only ...protocol.CodeActionKind) ([]protocol.CodeAction, error)
func (*Editor) Completion ¶
func (e *Editor) Completion(ctx context.Context, loc protocol.Location) (*protocol.CompletionList, error)
Completion executes a completion request on the server.
func (*Editor) Config ¶
func (e *Editor) Config() EditorConfig
Config returns the current editor configuration.
func (*Editor) Connect ¶
func (e *Editor) Connect(ctx context.Context, connector servertest.Connector, hooks ClientHooks, skipApplyEdits bool) (*Editor, error)
Connect configures the editor to communicate with an LSP server on conn. It is not concurrency safe, and should be called at most once, before using the editor.
It returns the editor, so that it may be called as follows:
editor, err := NewEditor(s).Connect(ctx, conn, hooks)
func (*Editor) CreateBuffer ¶
CreateBuffer creates a new unsaved buffer corresponding to the workdir path, containing the given textual content.
func (*Editor) Definition ¶
GoToDefinition jumps to the definition of the symbol at the given position in an open buffer. It returns the location of the resulting jump.
func (*Editor) DocumentHighlight ¶
func (*Editor) DocumentLink ¶
func (*Editor) EditBuffer ¶
EditBuffer applies the given test edits to the buffer identified by path.
func (*Editor) EditResolveSupport ¶
func (*Editor) ExecuteCommand ¶
func (*Editor) FormatBuffer ¶
FormatBuffer gofmts a Go file.
func (*Editor) GetQuickFixes ¶
func (e *Editor) GetQuickFixes(ctx context.Context, loc protocol.Location, diagnostics []protocol.Diagnostic) ([]protocol.CodeAction, error)
GetQuickFixes returns the available quick fix code actions.
func (*Editor) HasCommand ¶
HasCommand reports whether the connected server supports the command with the given ID.
func (*Editor) Hover ¶
func (e *Editor) Hover(ctx context.Context, loc protocol.Location) (*protocol.MarkupContent, protocol.Location, error)
Hover triggers a hover at the given position in an open buffer.
func (*Editor) Implementations ¶
func (e *Editor) Implementations(ctx context.Context, loc protocol.Location) ([]protocol.Location, error)
Implementations returns implementations for the object at loc, as returned by the connected LSP server. If no server is connected, it returns (nil, nil).
func (*Editor) Mapper ¶
Mapper returns the protocol.Mapper for the given buffer name, if it is open.
func (*Editor) OpenFile ¶
OpenFile creates a buffer for the given workdir-relative file.
If the file is already open, it is a no-op.
func (*Editor) OrganizeImports ¶
OrganizeImports requests and performs the source.organizeImports codeAction.
func (*Editor) RefactorRewrite ¶
RefactorRewrite requests and performs the source.refactorRewrite codeAction.
func (*Editor) References ¶
func (e *Editor) References(ctx context.Context, loc protocol.Location) ([]protocol.Location, error)
References returns references to the object at loc, as returned by the connected LSP server. If no server is connected, it returns (nil, nil).
func (*Editor) RegexpReplace ¶
RegexpReplace edits the buffer corresponding to path by replacing the first instance of re, or its first subgroup, with the replace text. See RegexpSearch for more explanation of these two modes. It returns an error if re is invalid, has more than one subgroup, or doesn't match the buffer.
func (*Editor) RegexpSearch ¶
RegexpSearch returns the Location of the first match for re in the buffer bufName. For convenience, RegexpSearch supports the following two modes:
- If re has no subgroups, return the position of the match for re itself.
- If re has one subgroup, return the position of the first subgroup.
It returns an error re is invalid, has more than one subgroup, or doesn't match the buffer.
func (*Editor) Rename ¶
Rename performs a rename of the object at loc to newName, using the connected LSP server. If no server is connected, it returns nil.
func (*Editor) RenameFile ¶
func (*Editor) RunGenerate ¶
RunGenerate runs `go generate` non-recursively in the workdir-relative dir path. It does not report any resulting file changes as a watched file change, so must be followed by a call to Workdir.CheckForFileChanges once the generate command has completed. TODO(rFindley): this shouldn't be necessary anymore. Delete it.
func (*Editor) SaveBuffer ¶
SaveBuffer writes the content of the buffer specified by the given path to the filesystem.
func (*Editor) SaveBufferWithoutActions ¶
func (*Editor) SemanticTokensFull ¶
SemanticTokensFull invokes textDocument/semanticTokens/full, and interprets its result.
func (*Editor) SemanticTokensRange ¶
func (e *Editor) SemanticTokensRange(ctx context.Context, loc protocol.Location) ([]SemanticToken, error)
SemanticTokensRange invokes textDocument/semanticTokens/range, and interprets its result.
func (*Editor) SetBufferContent ¶
func (*Editor) SetConfig ¶
func (e *Editor) SetConfig(cfg EditorConfig)
func (*Editor) SignatureHelp ¶
func (*Editor) Stats ¶
func (e *Editor) Stats() CallCounts
func (*Editor) TextDocumentIdentifier ¶
func (e *Editor) TextDocumentIdentifier(path string) protocol.TextDocumentIdentifier
type EditorConfig ¶
type EditorConfig struct { // ClientName sets the clientInfo.name for the LSP session (in the initialize request). // // Since this can only be set during initialization, changing this field via // Editor.ChangeConfiguration has no effect. ClientName string // Env holds environment variables to apply on top of the default editor // environment. When applying these variables, the special string // $SANDBOX_WORKDIR is replaced by the absolute path to the sandbox working // directory. Env map[string]string // WorkspaceFolders is the workspace folders to configure on the LSP server, // relative to the sandbox workdir. // // As a special case, if WorkspaceFolders is nil the editor defaults to // configuring a single workspace folder corresponding to the workdir root. // To explicitly send no workspace folders, use an empty (non-nil) slice. WorkspaceFolders []string // Whether to edit files with windows line endings. WindowsLineEndings bool // Map of language ID -> regexp to match, used to set the file type of new // buffers. Applied as an overlay on top of the following defaults: // "go" -> ".*\.go" // "go.mod" -> "go\.mod" // "go.sum" -> "go\.sum" // "gotmpl" -> ".*tmpl" FileAssociations map[string]string // Settings holds user-provided configuration for the LSP server. Settings map[string]any // FolderSettings holds user-provided per-folder configuration, if any. // // It maps each folder (as a relative path to the sandbox workdir) to its // configuration mapping (like Settings). FolderSettings map[string]map[string]any // CapabilitiesJSON holds JSON client capabilities to overlay over the // editor's default client capabilities. // // Specifically, this JSON string will be unmarshalled into the editor's // client capabilities struct, before sending to the server. CapabilitiesJSON []byte // If non-nil, MessageResponder is used to respond to ShowMessageRequest // messages. MessageResponder func(params *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error) }
EditorConfig configures the editor's LSP session. This is similar to golang.UserOptions, but we use a separate type here so that we expose only that configuration which we support.
The zero value for EditorConfig is the default configuration.
type RelativeTo ¶
type RelativeTo string
RelativeTo is a helper for operations relative to a given directory.
func (RelativeTo) AbsPath ¶
func (r RelativeTo) AbsPath(path string) string
AbsPath returns an absolute filesystem path for the workdir-relative path.
func (RelativeTo) RelPath ¶
func (r RelativeTo) RelPath(fp string) string
RelPath returns a '/'-encoded path relative to the working directory (or an absolute path if the file is outside of workdir)
type Sandbox ¶
type Sandbox struct { Workdir *Workdir // contains filtered or unexported fields }
Sandbox holds a collection of temporary resources to use for working with Go code in tests.
func NewSandbox ¶
func NewSandbox(config *SandboxConfig) (_ *Sandbox, err error)
NewSandbox creates a collection of named temporary resources, with a working directory populated by the txtar-encoded content in srctxt, and a file-based module proxy populated with the txtar-encoded content in proxytxt.
If rootDir is non-empty, it will be used as the root of temporary directories created for the sandbox. Otherwise, a new temporary directory will be used as root.
TODO(rfindley): the sandbox abstraction doesn't seem to carry its weight. Sandboxes should be composed out of their building-blocks, rather than via a monolithic configuration.
func (*Sandbox) GoEnv ¶
GoEnv returns the default environment variables that can be used for invoking Go commands in the sandbox.
func (*Sandbox) GoVersion ¶
GoVersion checks the version of the go command. It returns the X in Go 1.X.
func (*Sandbox) RunGoCommand ¶
func (sb *Sandbox) RunGoCommand(ctx context.Context, dir, verb string, args, env []string, checkForFileChanges bool) error
RunGoCommand executes a go command in the sandbox. If checkForFileChanges is true, the sandbox scans the working directory and emits file change events for any file changes it finds.
type SandboxConfig ¶
type SandboxConfig struct { // RootDir sets the base directory to use when creating temporary // directories. If not specified, defaults to a new temporary directory. RootDir string // Files holds a txtar-encoded archive of files to populate the initial state // of the working directory. // // For convenience, the special substring "$SANDBOX_WORKDIR" is replaced with // the sandbox's resolved working directory before writing files. Files map[string][]byte // InGoPath specifies that the working directory should be within the // temporary GOPATH. InGoPath bool // Workdir configures the working directory of the Sandbox. It behaves as // follows: // - if set to an absolute path, use that path as the working directory. // - if set to a relative path, create and use that path relative to the // sandbox. // - if unset, default to a the 'work' subdirectory of the sandbox. // // This option is incompatible with InGoPath or Files. Workdir string // ProxyFiles holds a txtar-encoded archive of files to populate a file-based // Go proxy. ProxyFiles map[string][]byte // GOPROXY is the explicit GOPROXY value that should be used for the sandbox. // // This option is incompatible with ProxyFiles. GOPROXY string }
SandboxConfig controls the behavior of a test sandbox. The zero value defines a reasonable default.
type SemanticToken ¶
A SemanticToken is an interpreted semantic token value.
type Workdir ¶
type Workdir struct { RelativeTo // contains filtered or unexported fields }
Workdir is a temporary working directory for tests. It exposes file operations in terms of relative paths, and fakes file watching by triggering events on file operations.
func NewWorkdir ¶
NewWorkdir writes the txtar-encoded file data in txt to dir, and returns a Workir for operating on these files using
func (*Workdir) AddWatcher ¶
AddWatcher registers the given func to be called on any file change.
func (*Workdir) CheckForFileChanges ¶
CheckForFileChanges walks the working directory and checks for any files that have changed since the last poll.
func (*Workdir) ListFiles ¶
ListFiles returns a new sorted list of the relative paths of files in dir, recursively.
func (*Workdir) RegexpSearch ¶
RegexpSearch searches the file corresponding to path for the first position matching re.
func (*Workdir) RemoveFile ¶
RemoveFile removes a workdir-relative file path and notifies watchers of the change.
func (*Workdir) RenameFile ¶
RenameFile performs an on disk-renaming of the workdir-relative oldPath to workdir-relative newPath, and notifies watchers of the changes.
oldPath must either be a regular file or in the same directory as newPath.
func (*Workdir) RootURI ¶
func (w *Workdir) RootURI() protocol.DocumentURI
RootURI returns the root URI for this working directory of this scratch environment.
func (*Workdir) URI ¶
func (w *Workdir) URI(path string) protocol.DocumentURI
URI returns the URI to a the workdir-relative path.
func (*Workdir) URIToPath ¶
func (w *Workdir) URIToPath(uri protocol.DocumentURI) string
URIToPath converts a uri to a workdir-relative path (or an absolute path, if the uri is outside of the workdir).