mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
internal/lsp: remove filename print from rename output
This prevents piping back to the file, a common pattern. Multi file forms should use the unified diff. Change-Id: I1ea140c59de24feb74a64b0cb41890536f23cd3a Reviewed-on: https://go-review.googlesource.com/c/tools/+/197157 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
125cfdbd7b
commit
ae58c0ff6b
@ -117,7 +117,9 @@ func (r *rename) Run(ctx context.Context, args ...string) error {
|
|||||||
diffs := diff.ToUnified(filename+".orig", filename, string(cmdFile.mapper.Content), myersEdits)
|
diffs := diff.ToUnified(filename+".orig", filename, string(cmdFile.mapper.Content), myersEdits)
|
||||||
fmt.Print(diffs)
|
fmt.Print(diffs)
|
||||||
default:
|
default:
|
||||||
fmt.Printf("%s:\n", filepath.Base(filename))
|
if len(keys) > 1 {
|
||||||
|
fmt.Printf("%s:\n", filepath.Base(filename))
|
||||||
|
}
|
||||||
fmt.Print(string(newContent))
|
fmt.Print(string(newContent))
|
||||||
if changeCount > 1 { // if this wasn't last change, print newline
|
if changeCount > 1 { // if this wasn't last change, print newline
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
@ -564,7 +564,10 @@ func (r *runner) Rename(t *testing.T, data tests.Renames) {
|
|||||||
}
|
}
|
||||||
filename := filepath.Base(m.URI.Filename())
|
filename := filepath.Base(m.URI.Filename())
|
||||||
contents := applyEdits(string(m.Content), sedits)
|
contents := applyEdits(string(m.Content), sedits)
|
||||||
res = append(res, fmt.Sprintf("%s:\n%s", filename, contents))
|
if len(*workspaceEdits.Changes) > 1 {
|
||||||
|
contents = fmt.Sprintf("%s:\n%s", filename, contents)
|
||||||
|
}
|
||||||
|
res = append(res, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort on filename
|
// Sort on filename
|
||||||
|
@ -687,7 +687,10 @@ func (r *runner) Rename(t *testing.T, data tests.Renames) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
contents := applyEdits(string(data), diffEdits)
|
contents := applyEdits(string(data), diffEdits)
|
||||||
res = append(res, fmt.Sprintf("%s:\n%s", filename, contents))
|
if len(changes) > 1 {
|
||||||
|
contents = fmt.Sprintf("%s:\n%s", filename, contents)
|
||||||
|
}
|
||||||
|
res = append(res, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort on filename
|
// Sort on filename
|
||||||
|
14
internal/lsp/testdata/rename/a/random.go.golden
vendored
14
internal/lsp/testdata/rename/a/random.go.golden
vendored
@ -19,7 +19,6 @@
|
|||||||
func sw() {
|
func sw() {
|
||||||
|
|
||||||
-- GetSum-rename --
|
-- GetSum-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -85,7 +84,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- f2name-rename --
|
-- f2name-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -151,7 +149,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- f2y-rename --
|
-- f2y-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -217,7 +214,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- fmt2-rename --
|
-- fmt2-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -284,7 +280,6 @@ func sw() {
|
|||||||
default:
|
default:
|
||||||
|
|
||||||
-- fmty-rename --
|
-- fmty-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -351,7 +346,6 @@ func sw() {
|
|||||||
default:
|
default:
|
||||||
|
|
||||||
-- format-rename --
|
-- format-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -418,7 +412,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- log-rename --
|
-- log-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -481,7 +474,6 @@ func sw() {
|
|||||||
func _() {
|
func _() {
|
||||||
|
|
||||||
-- myX-rename --
|
-- myX-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -541,7 +533,6 @@ func sw() {
|
|||||||
func sw() {
|
func sw() {
|
||||||
|
|
||||||
-- pos-rename --
|
-- pos-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -607,7 +598,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- y0-rename --
|
-- y0-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -673,7 +663,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- y1-rename --
|
-- y1-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -739,7 +728,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- y2-rename --
|
-- y2-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -805,7 +793,6 @@ func sw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- y3-rename --
|
-- y3-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -865,7 +852,6 @@ func sw() {
|
|||||||
type Pos struct {
|
type Pos struct {
|
||||||
|
|
||||||
-- z-rename --
|
-- z-rename --
|
||||||
random.go:
|
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- bar-rename --
|
-- bar-rename --
|
||||||
testy.go:
|
|
||||||
package testy
|
package testy
|
||||||
|
|
||||||
type tt int //@rename("tt", "testyType")
|
type tt int //@rename("tt", "testyType")
|
||||||
@ -32,7 +31,6 @@ func a() {
|
|||||||
foo := 42 //@rename("foo", "bar")
|
foo := 42 //@rename("foo", "bar")
|
||||||
|
|
||||||
-- testyType-rename --
|
-- testyType-rename --
|
||||||
testy.go:
|
|
||||||
package testy
|
package testy
|
||||||
|
|
||||||
type testyType int //@rename("tt", "testyType")
|
type testyType int //@rename("tt", "testyType")
|
||||||
|
@ -52,7 +52,6 @@ func TestSomething(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- testyX-rename --
|
-- testyX-rename --
|
||||||
testy_test.go:
|
|
||||||
package testy
|
package testy
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user