8000 x/tools/gopls: Extract Function refactor doesn't put testing.T/B first · Issue #69341 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

x/tools/gopls: Extract Function refactor doesn't put testing.T/B first #69341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vikstrous2 opened this issue Sep 8, 2024 · 3 comments
Closed
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@vikstrous2
Copy link

gopls version

Build info

golang.org/x/tools/gopls v0.16.2
golang.org/x/tools/gopls@v0.16.2 h1:K1z03MlikHfaMTtG01cUeL5FAOTJnITuNe0TWOcg8tM=
github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/mod@v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/sync@v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/telemetry@v0.0.0-20240829154258-f29ab539cc98 h1:Wm3cG5X6sZ0RSVRc/H1/sciC4AT6HAKgLCSH2lbpR/c=
golang.org/x/text@v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/tools@v0.22.1-0.20240829175637-39126e24d653 h1:6bJEg2w2kUHWlfdJaESYsmNfI1LKAZQi6zCa7LUn7eI=
golang.org/x/vuln@v1.0.4 h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
honnef.co/go/tools@v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.22.3

go env

n/a

What did you do?

Extract the body of AddPWithB into a new function with gopls

package extract

import (
	"context"
	"testing"
)

type B struct {
	x int
	y int
}

func (b *B) AddPWithB(ctx context.Context, t *testing.T) (int, error) {
	sum := b.x + b.y
	t.Skip()
	return sum, ctx.Err()
}

What did you see happen?

package extract

import (
	"context"
	"testing"
)

type B struct {
	x int
	y int
}

func (b *B) AddPWithB(ctx context.Context, t *testing.T) (int, error) {
	return newFunction(ctx, b, t)
}

func newFunction(ctx context.Context, b *B, t *testing.T) (int, error) {
	sum := b.x + b.y
	t.Skip()
	return sum, ctx.Err()
}

What did you expect to see?

package extract

import (
	"context"
	"testing"
)

type B struct {
	x int
	y int
}

func (b *B) AddPWithB(ctx context.Context, t *testing.T) (int, error) {
	return newFunction(ctx, t, b)
}

func newFunction(ctx context.Context, t *testing.T, b *B) (int, error) {
	sum := b.x + b.y
	t.Skip()
	return sum, ctx.Err()
}

Editor and settings

vs code

Logs

No response

@vikstrous2 vikstrous2 added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Sep 8, 2024
@gopherbot gopherbot added this to the Unreleased milestone Sep 8, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/610976 mentions this issue: gopls/internal/lsp/source: put testing.T/B first when extracting

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/612036 mentions this issue: gopls/internal/lsp/source: put testing.T/B first when extracting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0