gopls/internal/golang: splitlines: s/parameter/arguments/ in CallExpr

(Another terminological nitpick that I missed until reading the docs.)

Also, commentary.

Change-Id: I8d985234637224be7b921bdaa8113baa9c54be66
Reviewed-on: https://go-review.googlesource.com/c/tools/+/595118
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
This commit is contained in:
Alan Donovan 2024-06-26 17:55:18 -04:00 коммит произвёл Gopher Robot
Родитель 5cc2d0b12c
Коммит c0ae6bbd24
3 изменённых файлов: 17 добавлений и 22 удалений

Просмотреть файл

@ -167,26 +167,21 @@ func findSplitJoinTarget(fset *token.FileSet, file *ast.File, src []byte, start,
for _, node := range path {
switch node := node.(type) {
case *ast.FuncType:
// target function signature parameters and results.
// type someFunc func (a int, b int, c int) (d int, e int)
params := node.Params
if isCursorInside(params.Opening, params.Closing) {
return "parameters", params, params.Opening, params.Closing
// params or results of func signature
// Note:
// - each ast.Field (e.g. "x, y, z int") is considered a single item.
// - splitting Params and Results lists is not usually good style.
if p := node.Params; isCursorInside(p.Opening, p.Closing) {
return "parameters", p, p.Opening, p.Closing
}
results := node.Results
if results != nil && isCursorInside(results.Opening, results.Closing) {
return "results", results, results.Opening, results.Closing
if r := node.Results; r != nil && isCursorInside(r.Opening, r.Closing) {
return "results", r, r.Opening, r.Closing
}
case *ast.CallExpr:
// target function calls.
// someFunction(a, b, c)
case *ast.CallExpr: // f(a, b, c)
if isCursorInside(node.Lparen, node.Rparen) {
return "parameters", node, node.Lparen, node.Rparen
return "arguments", node, node.Lparen, node.Rparen
}
case *ast.CompositeLit:
// target composite lit instantiation (structs, maps, arrays).
// A{b: 1, c: 2, d: 3}
case *ast.CompositeLit: // T{a, b, c}
if isCursorInside(node.Lbrace, node.Rbrace) {
return "elements", node, node.Lbrace, node.Rbrace
}

Просмотреть файл

@ -108,7 +108,7 @@ func a() {
2,
3,
fmt.Sprintf(
"hello %d" /*@codeaction("hello", "hello", "refactor.rewrite", indent, "Join parameters into one line")*/,
"hello %d" /*@codeaction("hello", "hello", "refactor.rewrite", indent, "Join arguments into one line")*/,
4,
))
}
@ -123,7 +123,7 @@ func a() {
1,
2,
3,
fmt.Sprintf("hello %d" /*@codeaction("hello", "hello", "refactor.rewrite", indent, "Join parameters into one line")*/, 4))
fmt.Sprintf("hello %d" /*@codeaction("hello", "hello", "refactor.rewrite", indent, "Join arguments into one line")*/, 4))
}
-- structelts/structelts.go --

Просмотреть файл

@ -103,7 +103,7 @@ package indent
import "fmt"
func a() {
fmt.Println(1, 2, 3, fmt.Sprintf("hello %d", 4)) //@codeaction("hello", "hello", "refactor.rewrite", indent, "Split parameters into separate lines")
fmt.Println(1, 2, 3, fmt.Sprintf("hello %d", 4)) //@codeaction("hello", "hello", "refactor.rewrite", indent, "Split arguments into separate lines")
}
-- @indent/indent/indent.go --
@ -115,7 +115,7 @@ func a() {
fmt.Println(1, 2, 3, fmt.Sprintf(
"hello %d",
4,
)) //@codeaction("hello", "hello", "refactor.rewrite", indent, "Split parameters into separate lines")
)) //@codeaction("hello", "hello", "refactor.rewrite", indent, "Split arguments into separate lines")
}
-- indent2/indent2.go --
@ -125,7 +125,7 @@ import "fmt"
func a() {
fmt.
Println(1, 2, 3, fmt.Sprintf("hello %d", 4)) //@codeaction("1", "1", "refactor.rewrite", indent2, "Split parameters into separate lines")
Println(1, 2, 3, fmt.Sprintf("hello %d", 4)) //@codeaction("1", "1", "refactor.rewrite", indent2, "Split arguments into separate lines")
}
-- @indent2/indent2/indent2.go --
@ -140,7 +140,7 @@ func a() {
2,
3,
fmt.Sprintf("hello %d", 4),
) //@codeaction("1", "1", "refactor.rewrite", indent2, "Split parameters into separate lines")
) //@codeaction("1", "1", "refactor.rewrite", indent2, "Split arguments into separate lines")
}
-- structelts/structelts.go --