Skip to content

Commit

Permalink
internal/lsp/cache: remove unused code
Browse files Browse the repository at this point in the history
Change-Id: I7bafb1555ab7d35b9c49138c915b6c6c781e92c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/392656
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
  • Loading branch information
hyangah committed Mar 17, 2022
1 parent 85d68bc commit 877ec07
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 55 deletions.
15 changes: 0 additions & 15 deletions internal/lsp/cache/mod_tidy.go
Expand Up @@ -152,21 +152,6 @@ func (s *snapshot) ModTidy(ctx context.Context, pm *source.ParsedModule) (*sourc
return mth.tidy(ctx, s)
}

func (s *snapshot) uriToModDecl(ctx context.Context, uri span.URI) (protocol.Range, error) {
fh, err := s.GetFile(ctx, uri)
if err != nil {
return protocol.Range{}, nil
}
pmf, err := s.ParseMod(ctx, fh)
if err != nil {
return protocol.Range{}, nil
}
if pmf.File.Module == nil || pmf.File.Module.Syntax == nil {
return protocol.Range{}, nil
}
return rangeFromPositions(pmf.Mapper, pmf.File.Module.Syntax.Start, pmf.File.Module.Syntax.End)
}

func (s *snapshot) hashImports(ctx context.Context, wsPackages []*packageHandle) (string, error) {
seen := map[string]struct{}{}
var imports []string
Expand Down
7 changes: 0 additions & 7 deletions internal/lsp/cache/snapshot.go
Expand Up @@ -803,13 +803,6 @@ func (s *snapshot) isActiveLocked(id PackageID, seen map[PackageID]bool) (active
return false
}

func (s *snapshot) getWorkspacePkgPath(id PackageID) PackagePath {
s.mu.Lock()
defer s.mu.Unlock()

return s.workspacePackages[id]
}

const fileExtensions = "go,mod,sum,work"

func (s *snapshot) fileWatchingGlobPatterns(ctx context.Context) map[string]struct{} {
Expand Down
1 change: 0 additions & 1 deletion internal/lsp/cache/symbols.go
Expand Up @@ -69,7 +69,6 @@ func symbolize(ctx context.Context, snapshot *snapshot, fh source.FileHandle) ([

type symbolWalker struct {
curFile *source.ParsedGoFile
pkgName string
curURI protocol.DocumentURI
symbols []source.Symbol
firstError error
Expand Down
32 changes: 0 additions & 32 deletions internal/lsp/cache/view.go
Expand Up @@ -29,7 +29,6 @@ import (
"golang.org/x/tools/internal/imports"
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/memoize"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/xcontext"
errors "golang.org/x/xerrors"
Expand Down Expand Up @@ -139,10 +138,6 @@ const (
tempModfile
)

type builtinPackageHandle struct {
handle *memoize.Handle
}

// fileBase holds the common functionality for all files.
// It is intended to be embedded in the file implementations
type fileBase struct {
Expand All @@ -167,33 +162,6 @@ func (f *fileBase) addURI(uri span.URI) int {

func (v *View) ID() string { return v.id }

// TODO(rfindley): factor this out to use server.tempDir, and consolidate logic with tempModFile.
func tempWorkFile(workFH source.FileHandle) (tmpURI span.URI, cleanup func(), err error) {
filenameHash := hashContents([]byte(workFH.URI().Filename()))
tmpMod, err := ioutil.TempFile("", fmt.Sprintf("go.%s.*.work", filenameHash))
if err != nil {
return "", nil, err
}
defer tmpMod.Close()

tmpURI = span.URIFromPath(tmpMod.Name())

content, err := workFH.Read()
if err != nil {
return "", nil, err
}

if _, err := tmpMod.Write(content); err != nil {
return "", nil, err
}

cleanup = func() {
_ = os.Remove(tmpURI.Filename())
}

return tmpURI, cleanup, nil
}

// tempModFile creates a temporary go.mod file based on the contents of the
// given go.mod file. It is the caller's responsibility to clean up the files
// when they are done using them.
Expand Down

0 comments on commit 877ec07

Please sign in to comment.