Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
b88b38ac
Commit
b88b38ac
authored
Dec 02, 2010
by
Jamie Gennis
Committed by
Robert Griesemer
Dec 02, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/printer: preserve newlines in func parameter lists
Fixes #1179. R=gri CC=golang-dev
https://golang.org/cl/3225042
parent
4f852622
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
2 deletions
+128
-2
nodes.go
src/pkg/go/printer/nodes.go
+14
-2
declarations.golden
src/pkg/go/printer/testdata/declarations.golden
+57
-0
declarations.input
src/pkg/go/printer/testdata/declarations.input
+57
-0
No files found.
src/pkg/go/printer/nodes.go
View file @
b88b38ac
...
...
@@ -92,7 +92,7 @@ const (
// Sets multiLine to true if the identifier list spans multiple lines.
// If ident is set, a multi-line identifier list is indented after the
// If i
n
dent is set, a multi-line identifier list is indented after the
// first linebreak encountered.
func
(
p
*
printer
)
identList
(
list
[]
*
ast
.
Ident
,
indent
bool
,
multiLine
*
bool
)
{
// convert into an expression list so we can re-use exprList formatting
...
...
@@ -298,15 +298,27 @@ func (p *printer) exprList(prev token.Position, list []ast.Expr, depth int, mode
func
(
p
*
printer
)
parameters
(
fields
*
ast
.
FieldList
,
multiLine
*
bool
)
{
p
.
print
(
fields
.
Opening
,
token
.
LPAREN
)
if
len
(
fields
.
List
)
>
0
{
var
prevLine
,
line
int
for
i
,
par
:=
range
fields
.
List
{
if
i
>
0
{
p
.
print
(
token
.
COMMA
,
blank
)
p
.
print
(
token
.
COMMA
)
if
len
(
par
.
Names
)
>
0
{
line
=
par
.
Names
[
0
]
.
Pos
()
.
Line
}
else
{
line
=
par
.
Type
.
Pos
()
.
Line
}
if
0
<
prevLine
&&
prevLine
<
line
&&
p
.
linebreak
(
line
,
0
,
ignore
,
true
)
{
*
multiLine
=
true
}
else
{
p
.
print
(
blank
)
}
}
if
len
(
par
.
Names
)
>
0
{
p
.
identList
(
par
.
Names
,
false
,
multiLine
)
p
.
print
(
blank
)
}
p
.
expr
(
par
.
Type
,
multiLine
)
prevLine
=
par
.
Type
.
Pos
()
.
Line
}
}
p
.
print
(
fields
.
Closing
,
token
.
RPAREN
)
...
...
src/pkg/go/printer/testdata/declarations.golden
View file @
b88b38ac
...
...
@@ -656,3 +656,60 @@ func _(x ...func())
func _(x ...func(...int))
func _(x ...map[string]int)
func _(x ...chan int)
// these parameter lists must remain multi-line since they are multi-line in the source
func _(bool,
int) {
}
func _(x bool,
y int) {
}
func _(x,
y bool) {
}
func _(bool, // comment
int) {
}
func _(x bool, // comment
y int) {
}
func _(x, // comment
y bool) {
}
func _(bool, // comment
// comment
int) {
}
func _(x bool, // comment
// comment
y int) {
}
func _(x, // comment
// comment
y bool) {
}
func _(bool,
// comment
int) {
}
func _(x bool,
// comment
y int) {
}
func _(x,
// comment
y bool) {
}
func _(x, // comment
y, // comment
z bool) {
}
func _(x, // comment
y, // comment
z bool) {
}
func _(x int, // comment
y float, // comment
z bool) {
}
src/pkg/go/printer/testdata/declarations.input
View file @
b88b38ac
...
...
@@ -644,3 +644,60 @@ func _(x ...func())
func _(x ...func(...int))
func _(x ...map[string]int)
func _(x ...chan int)
// these parameter lists must remain multi-line since they are multi-line in the source
func _(bool,
int) {
}
func _(x bool,
y int) {
}
func _(x,
y bool) {
}
func _(bool, // comment
int) {
}
func _(x bool, // comment
y int) {
}
func _(x, // comment
y bool) {
}
func _(bool, // comment
// comment
int) {
}
func _(x bool, // comment
// comment
y int) {
}
func _(x, // comment
// comment
y bool) {
}
func _(bool,
// comment
int) {
}
func _(x bool,
// comment
y int) {
}
func _(x,
// comment
y bool) {
}
func _(x, // comment
y,// comment
z bool) {
}
func _(x, // comment
y,// comment
z bool) {
}
func _(x int, // comment
y float, // comment
z bool) {
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment