Skip to content

Commit

Permalink
gopls: remove dead code
Browse files Browse the repository at this point in the history
This change removes functions reported as unreachable by
internal/cmd/deadcode. Also, move the "generated" file
marker to the correct positions.

Change-Id: I56f3c056cd010914ac5d4e410f1ee4a44289cc77
Reviewed-on: https://go-review.googlesource.com/c/tools/+/524760
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
adonovan authored and gopherbot committed Sep 1, 2023
1 parent 7663a40 commit a1a928d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 53 deletions.
9 changes: 0 additions & 9 deletions gopls/internal/lsp/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,6 @@ func (app *Application) connect(ctx context.Context, onProgress func(*protocol.P
}
}

// CloseTestConnections terminates shared connections used in command tests. It
// should only be called from tests.
func CloseTestConnections(ctx context.Context) {
for _, c := range internalConnections {
c.Shutdown(ctx)
c.Exit(ctx)
}
}

func (app *Application) connectRemote(ctx context.Context, remote string) (*connection, error) {
conn, err := lsprpc.ConnectToRemote(ctx, remote)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions gopls/internal/lsp/command/command_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gopls/internal/lsp/command/gen/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions gopls/internal/lsp/source/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,14 +1311,6 @@ func (e *SoftError) Error() string {
return e.msg
}

// softErrorf reports an error that does not affect the functionality of gopls
// (a warning in the UI).
// The formatted message will be shown to the user unmodified.
func (r *OptionResult) softErrorf(format string, values ...interface{}) {
msg := fmt.Sprintf(format, values...)
r.Error = &SoftError{msg}
}

// deprecated reports the current setting as deprecated. If 'replacement' is
// non-nil, it is suggested to the user.
func (r *OptionResult) deprecated(replacement string) {
Expand Down
32 changes: 0 additions & 32 deletions gopls/internal/lsp/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,38 +1159,6 @@ func SpanName(spn span.Span) string {
return fmt.Sprintf("%v_%v_%v", uriName(spn.URI()), spn.Start().Line(), spn.Start().Column())
}

func CopyFolderToTempDir(folder string) (string, error) {
if _, err := os.Stat(folder); err != nil {
return "", err
}
dst, err := ioutil.TempDir("", "modfile_test")
if err != nil {
return "", err
}
fds, err := ioutil.ReadDir(folder)
if err != nil {
return "", err
}
for _, fd := range fds {
srcfp := filepath.Join(folder, fd.Name())
stat, err := os.Stat(srcfp)
if err != nil {
return "", err
}
if !stat.Mode().IsRegular() {
return "", fmt.Errorf("cannot copy non regular file %s", srcfp)
}
contents, err := ioutil.ReadFile(srcfp)
if err != nil {
return "", err
}
if err := ioutil.WriteFile(filepath.Join(dst, fd.Name()), contents, stat.Mode()); err != nil {
return "", err
}
}
return dst, nil
}

func shouldSkip(data *Data, uri span.URI) bool {
if data.ModfileFlagAvailable {
return false
Expand Down

0 comments on commit a1a928d

Please sign in to comment.