1) Change default gofmt default settings for

parsing and printing to new syntax.

                  Use -oldparser to parse the old syntax,
                  use -oldprinter to print the old syntax.

               2) Change default gofmt formatting settings
                  to use tabs for indentation only and to use
                  spaces for alignment. This will make the code
                  alignment insensitive to an editor's tabwidth.

                  Use -spaces=false to use tabs for alignment.

               3) Manually changed src/exp/parser/parser_test.go
                  so that it doesn't try to parse the parser's
                  source files using the old syntax (they have
                  new syntax now).

               4) gofmt -w src misc test/bench

	       1st set of files.

R=rsc
CC=agl, golang-dev, iant, ken2, r
https://golang.org/cl/180047
This commit is contained in:
Robert Griesemer 2009-12-15 15:33:31 -08:00
parent 34356e9a6a
commit 5a1d3323fe
139 changed files with 9422 additions and 9422 deletions

View file

@ -10,44 +10,44 @@
package main
import (
"bytes";
"go/ast";
"go/printer";
"fmt";
"strings";
"bytes"
"go/ast"
"go/printer"
"fmt"
"strings"
)
type Snippet struct {
Line int;
Text string;
Line int
Text string
}
type snippetStyler struct {
Styler; // defined in godoc.go
highlight *ast.Ident; // identifier to highlight
Styler // defined in godoc.go
highlight *ast.Ident // identifier to highlight
}
func (s *snippetStyler) LineTag(line int) (text []uint8, tag printer.HTMLTag) {
return // no LineTag for snippets
return // no LineTag for snippets
}
func (s *snippetStyler) Ident(id *ast.Ident) (text []byte, tag printer.HTMLTag) {
text = strings.Bytes(id.Value);
text = strings.Bytes(id.Value)
if s.highlight == id {
tag = printer.HTMLTag{"<span class=highlight>", "</span>"}
}
return;
return
}
func newSnippet(decl ast.Decl, id *ast.Ident) *Snippet {
var buf bytes.Buffer;
writeNode(&buf, decl, true, &snippetStyler{highlight: id});
return &Snippet{id.Pos().Line, buf.String()};
var buf bytes.Buffer
writeNode(&buf, decl, true, &snippetStyler{highlight: id})
return &Snippet{id.Pos().Line, buf.String()}
}
@ -70,32 +70,32 @@ func findSpec(list []ast.Spec, id *ast.Ident) ast.Spec {
}
}
}
return nil;
return nil
}
func genSnippet(d *ast.GenDecl, id *ast.Ident) *Snippet {
s := findSpec(d.Specs, id);
s := findSpec(d.Specs, id)
if s == nil {
return nil // declaration doesn't contain id - exit gracefully
return nil // declaration doesn't contain id - exit gracefully
}
// only use the spec containing the id for the snippet
dd := &ast.GenDecl{d.Doc, d.Position, d.Tok, d.Lparen, []ast.Spec{s}, d.Rparen};
dd := &ast.GenDecl{d.Doc, d.Position, d.Tok, d.Lparen, []ast.Spec{s}, d.Rparen}
return newSnippet(dd, id);
return newSnippet(dd, id)
}
func funcSnippet(d *ast.FuncDecl, id *ast.Ident) *Snippet {
if d.Name != id {
return nil // declaration doesn't contain id - exit gracefully
return nil // declaration doesn't contain id - exit gracefully
}
// only use the function signature for the snippet
dd := &ast.FuncDecl{d.Doc, d.Recv, d.Name, d.Type, nil};
dd := &ast.FuncDecl{d.Doc, d.Recv, d.Name, d.Type, nil}
return newSnippet(dd, id);
return newSnippet(dd, id)
}
@ -118,5 +118,5 @@ func NewSnippet(decl ast.Decl, id *ast.Ident) (s *Snippet) {
fmt.Sprintf(`could not generate a snippet for <span class="highlight">%s</span>`, id.Value),
}
}
return;
return
}