p.print("BadStmt")
case *ast.DeclStmt:
- p.decl(s.Decl, inStmtList, multiLine)
+ p.decl(s.Decl, multiLine)
case *ast.EmptyStmt:
// nothing to do
// ----------------------------------------------------------------------------
// Declarations
-type declContext uint
-
-const (
- atTop declContext = iota
- inGroup
- inStmtList
-)
-
-// The parameter n is the number of specs in the group; context specifies
-// the surroundings of the declaration. Separating semicolons are printed
-// depending on the context. If indent is set, a multi-line identifier lists
-// in the spec are indented when the first linebreak is encountered. Sets
-// multiLine to true if the spec spans multiple lines.
+// The parameter n is the number of specs in the group. If indent is set,
+// multi-line identifier lists in the spec are indented when the first
+// linebreak is encountered.
+// Sets multiLine to true if the spec spans multiple lines.
//
-func (p *printer) spec(spec ast.Spec, n int, context declContext, indent bool, multiLine *bool) {
+func (p *printer) spec(spec ast.Spec, n int, indent bool, multiLine *bool) {
switch s := spec.(type) {
case *ast.ImportSpec:
p.setComment(s.Doc)
// Sets multiLine to true if the declaration spans multiple lines.
-func (p *printer) genDecl(d *ast.GenDecl, context declContext, multiLine *bool) {
+func (p *printer) genDecl(d *ast.GenDecl, multiLine *bool) {
p.setComment(d.Doc)
p.print(d.Pos(), d.Tok, blank)
p.linebreak(s.Pos().Line, 1, 2, ignore, ml)
}
ml = false
- p.spec(s, len(d.Specs), inGroup, false, &ml)
+ p.spec(s, len(d.Specs), false, &ml)
}
p.print(unindent, formfeed)
*multiLine = true
} else {
// single declaration
- p.spec(d.Specs[0], 1, context, true, multiLine)
+ p.spec(d.Specs[0], 1, true, multiLine)
}
}
// Sets multiLine to true if the declaration spans multiple lines.
-func (p *printer) decl(decl ast.Decl, context declContext, multiLine *bool) {
+func (p *printer) decl(decl ast.Decl, multiLine *bool) {
switch d := decl.(type) {
case *ast.BadDecl:
p.print(d.Pos(), "BadDecl")
case *ast.GenDecl:
- p.genDecl(d, context, multiLine)
+ p.genDecl(d, multiLine)
case *ast.FuncDecl:
p.funcDecl(d, multiLine)
default:
min = 2
}
p.linebreak(d.Pos().Line, min, maxDeclNewlines, ignore, false)
- p.decl(d, atTop, ignoreMultiLine)
+ p.decl(d, ignoreMultiLine)
}
}