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>
diff --git a/gopls/internal/regtest/diagnostics_test.go b/gopls/internal/regtest/diagnostics_test.go
index 8404ea1..18f19c0 100644
--- a/gopls/internal/regtest/diagnostics_test.go
+++ b/gopls/internal/regtest/diagnostics_test.go
@@ -1004,7 +1004,7 @@
 		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 @@
 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),
 		)
diff --git a/gopls/internal/regtest/formatting_test.go b/gopls/internal/regtest/formatting_test.go
index f0d3afa..3a9ffdb 100644
--- a/gopls/internal/regtest/formatting_test.go
+++ b/gopls/internal/regtest/formatting_test.go
@@ -173,7 +173,7 @@
 }
 `
 		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 {
diff --git a/gopls/internal/regtest/wrappers.go b/gopls/internal/regtest/wrappers.go
index 12bb26b..53f7952 100644
--- a/gopls/internal/regtest/wrappers.go
+++ b/gopls/internal/regtest/wrappers.go
@@ -67,13 +67,6 @@
 	}
 }
 
-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()
diff --git a/internal/lsp/fake/editor.go b/internal/lsp/fake/editor.go
index 34f6826..5567f46 100644
--- a/internal/lsp/fake/editor.go
+++ b/internal/lsp/fake/editor.go
@@ -277,26 +277,7 @@
 	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 {