mirror of https://github.com/golang/go.git
gopls/internal/regtest: delete OpenFileWithContent
OpenFileWithContent is identical to CreateBuffer. Delete it in favor of the latter, which (in my opinion) has the clearer name. Change-Id: Icf0f017a9a71a273ace6d697c7d669a2df2e3ba8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/263206 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Trust: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
593bd9b1d2
commit
2d76fa4fd5
|
|
@ -1004,7 +1004,7 @@ go 1.12
|
|||
env.WriteWorkspaceFile(name, "")
|
||||
env.Await(CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidChangeWatchedFiles), 1))
|
||||
|
||||
env.OpenFileWithContent(name, "\n")
|
||||
env.CreateBuffer(name, "\n")
|
||||
env.Await(CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1))
|
||||
|
||||
env.EditBuffer(name, fake.NewEdit(1, 0, 1, 0, content))
|
||||
|
|
@ -1142,7 +1142,7 @@ package main
|
|||
func main() {}
|
||||
`
|
||||
runner.Run(t, basic, func(t *testing.T, env *Env) {
|
||||
env.Editor.OpenFileWithContent(env.Ctx, "foo.go", `package main`)
|
||||
env.Editor.CreateBuffer(env.Ctx, "foo.go", `package main`)
|
||||
env.Await(
|
||||
CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ func Hi() {
|
|||
}
|
||||
`
|
||||
crlf := strings.ReplaceAll(want, "\n", "\r\n")
|
||||
env.OpenFileWithContent("main.go", crlf)
|
||||
env.CreateBuffer("main.go", crlf)
|
||||
env.SaveBuffer("main.go")
|
||||
got := env.Editor.BufferText("main.go")
|
||||
if want != got {
|
||||
|
|
|
|||
|
|
@ -67,13 +67,6 @@ func (e *Env) OpenFile(name string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (e *Env) OpenFileWithContent(name, content string) {
|
||||
e.T.Helper()
|
||||
if err := e.Editor.OpenFileWithContent(e.Ctx, name, content); err != nil {
|
||||
e.T.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// CreateBuffer creates a buffer in the editor, calling t.Fatal on any error.
|
||||
func (e *Env) CreateBuffer(name string, content string) {
|
||||
e.T.Helper()
|
||||
|
|
|
|||
|
|
@ -277,26 +277,7 @@ func (e *Editor) OpenFile(ctx context.Context, path string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return e.OpenFileWithContent(ctx, path, content)
|
||||
}
|
||||
|
||||
// OpenFileWithContent creates a buffer for the given workdir-relative file
|
||||
// with the given contents.
|
||||
func (e *Editor) OpenFileWithContent(ctx context.Context, path, content string) error {
|
||||
buf := newBuffer(path, content)
|
||||
e.mu.Lock()
|
||||
e.buffers[path] = buf
|
||||
item := textDocumentItem(e.sandbox.Workdir, buf)
|
||||
e.mu.Unlock()
|
||||
|
||||
if e.Server != nil {
|
||||
if err := e.Server.DidOpen(ctx, &protocol.DidOpenTextDocumentParams{
|
||||
TextDocument: item,
|
||||
}); err != nil {
|
||||
return errors.Errorf("DidOpen: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return e.CreateBuffer(ctx, path, content)
|
||||
}
|
||||
|
||||
func newBuffer(path, content string) buffer {
|
||||
|
|
|
|||
Loading…
Reference in New Issue