From 2683c792b49bd10d92da20a689ef2d5ddbf73460 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 1 Oct 2024 15:24:23 -0400 Subject: [PATCH] gopls/internal/golang/stubmethods: rename analysis/stubmethods Change-Id: I378afe9f961e6a6b3363f464cde198f2ca0bb525 Reviewed-on: https://go-review.googlesource.com/c/tools/+/617255 Reviewed-by: Robert Findley Auto-Submit: Alan Donovan LUCI-TryBot-Result: Go LUCI --- gopls/internal/golang/codeaction.go | 2 +- gopls/internal/golang/hover.go | 4 ++++ gopls/internal/golang/stub.go | 2 +- .../{analysis => golang}/stubmethods/stubmethods.go | 9 ++++++--- 4 files changed, 12 insertions(+), 5 deletions(-) rename gopls/internal/{analysis => golang}/stubmethods/stubmethods.go (97%) diff --git a/gopls/internal/golang/codeaction.go b/gopls/internal/golang/codeaction.go index b68b317b6db..3c916628a1a 100644 --- a/gopls/internal/golang/codeaction.go +++ b/gopls/internal/golang/codeaction.go @@ -19,10 +19,10 @@ import ( "golang.org/x/tools/go/ast/astutil" "golang.org/x/tools/gopls/internal/analysis/fillstruct" "golang.org/x/tools/gopls/internal/analysis/fillswitch" - "golang.org/x/tools/gopls/internal/analysis/stubmethods" "golang.org/x/tools/gopls/internal/cache" "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/file" + "golang.org/x/tools/gopls/internal/golang/stubmethods" "golang.org/x/tools/gopls/internal/label" "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/protocol/command" diff --git a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go index 016222a7c76..a0622fd764e 100644 --- a/gopls/internal/golang/hover.go +++ b/gopls/internal/golang/hover.go @@ -1109,6 +1109,10 @@ func chooseDocComment(decl ast.Decl, spec ast.Spec, field *ast.Field) *ast.Comme // pos; the resulting File and Pos may belong to the same or a // different FileSet, such as one synthesized by the parser cache, if // parse-caching is enabled. +// +// TODO(adonovan): change this function to accept a filename and a +// byte offset, and eliminate the confusing (fset, pos) parameters. +// Then simplify stubmethods.StubInfo, which doesn't need a Fset. func parseFull(ctx context.Context, snapshot *cache.Snapshot, fset *token.FileSet, pos token.Pos) (*parsego.File, token.Pos, error) { f := fset.File(pos) if f == nil { diff --git a/gopls/internal/golang/stub.go b/gopls/internal/golang/stub.go index c8a47b609c4..ca5f0055c3b 100644 --- a/gopls/internal/golang/stub.go +++ b/gopls/internal/golang/stub.go @@ -18,10 +18,10 @@ import ( "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/ast/astutil" - "golang.org/x/tools/gopls/internal/analysis/stubmethods" "golang.org/x/tools/gopls/internal/cache" "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/cache/parsego" + "golang.org/x/tools/gopls/internal/golang/stubmethods" "golang.org/x/tools/gopls/internal/util/bug" "golang.org/x/tools/gopls/internal/util/safetoken" "golang.org/x/tools/internal/diff" diff --git a/gopls/internal/analysis/stubmethods/stubmethods.go b/gopls/internal/golang/stubmethods/stubmethods.go similarity index 97% rename from gopls/internal/analysis/stubmethods/stubmethods.go rename to gopls/internal/golang/stubmethods/stubmethods.go index bfb68a44753..ee7b525a6a0 100644 --- a/gopls/internal/analysis/stubmethods/stubmethods.go +++ b/gopls/internal/golang/stubmethods/stubmethods.go @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Package stubmethods provides the analysis logic for the quick fix +// to "Declare missing methods of TYPE" errors. (The fix logic lives +// in golang.stubMethodsFixer.) package stubmethods -// TODO(adonovan): rename package to golang/stubmethods or move -// functions to golang/stub.go. - import ( "fmt" "go/ast" @@ -14,6 +14,9 @@ import ( "go/types" ) +// TODO(adonovan): eliminate the confusing Fset parameter; only the +// file name and byte offset of Concrete are needed. + // StubInfo represents a concrete type // that wants to stub out an interface type type StubInfo struct {