for i, x := range list {
xlist[i] = x
}
- p.exprList(noPos, xlist, 1, stringListMode, multiLine);
+ mode := stringListMode;
+ if p.Mode&NoStringConcat != 0 {
+ mode |= plusSep
+ }
+ p.exprList(noPos, xlist, 1, mode, multiLine);
}
const (
blankStart exprListMode = 1 << iota; // print a blank before a non-empty list
blankEnd; // print a blank after a non-empty list
+ plusSep; // elements are separared by + operators
commaSep; // elements are separated by commas
commaTerm; // elements are terminated by comma
noIndent; // no extra indentation in multi-line lists
// all list entries on a single line
for i, x := range list {
if i > 0 {
+ if mode&plusSep != 0 {
+ p.print(blank, token.ADD)
+ }
if mode&commaSep != 0 {
p.print(token.COMMA)
}
prev := line;
line = x.Pos().Line;
if i > 0 {
+ if mode&plusSep != 0 {
+ p.print(blank, token.ADD)
+ }
if mode&commaSep != 0 {
p.print(token.COMMA)
}
p.expr(&ast.StringList{f.Tag}, &ml);
extraTabs = 0;
}
- p.print(token.SEMICOLON);
+ if p.Mode&NoSemis == 0 {
+ p.print(token.SEMICOLON)
+ }
if f.Comment != nil {
for ; extraTabs > 0; extraTabs-- {
p.print(vtab)
// embedded interface
p.expr(f.Type, &ml)
}
- p.print(token.SEMICOLON);
+ if p.Mode&NoSemis == 0 {
+ p.print(token.SEMICOLON)
+ }
p.lineComment(f.Comment);
}
if isIncomplete {
// in those cases each clause is a new section
p.linebreak(s.Pos().Line, 1, maxStmtNewlines, ignore, i == 0 || _indent == 0 || multiLine);
multiLine = false;
- if !p.stmt(s, &multiLine) && (!fewerSemis || len(list) > 1) {
+ if !p.stmt(s, &multiLine) && (!fewerSemis || len(list) > 1) && p.Mode&NoSemis == 0 {
p.print(token.SEMICOLON)
}
}
panic("unreachable")
}
- if context == inGroup || context == inStmtList && !optSemi {
+ if (context == inGroup || context == inStmtList && !optSemi) && p.Mode&NoSemis == 0 {
p.print(token.SEMICOLON)
}