From 0355b4a281c8d3236b6c4c16bbe9bc5117397f10 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 16 Jul 2009 17:11:18 -0700 Subject: ast: - renamed Program -> SourceFile - added Package node representing the AST for an entire package - added filter function to create a source file mimicking the interface of an entire package parser: - parser entry to parse entire packages - unified naming of parser entry points - factored out entry points into new file (interface.go) gofmt: - extended to accept single .go files, and package paths: gofmt file.go // formatting of a single file gofmt -x file.go // interface of a single file gofmt -x ./MyPackage // interface of a local package gofmt -x math // interface of a $GOROOT relative package Various adjustments in dependent files, documentation. R=rsc DELTA=634 (369 added, 153 deleted, 112 changed) OCL=31743 CL=31748 --- src/pkg/go/doc/doc.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/pkg/go/doc') diff --git a/src/pkg/go/doc/doc.go b/src/pkg/go/doc/doc.go index 0e09a4d5d..860d6d54c 100644 --- a/src/pkg/go/doc/doc.go +++ b/src/pkg/go/doc/doc.go @@ -181,32 +181,32 @@ var ( ) -// AddProgram adds the AST for a source file to the DocReader. +// AddFile adds the AST for a source file to the DocReader. // Adding the same AST multiple times is a no-op. // -func (doc *DocReader) AddProgram(prog *ast.Program) { +func (doc *DocReader) AddFile(src *ast.File) { if bug_markers == nil { bug_markers = makeRex("^/[/*][ \t]*BUG\\(.*\\):[ \t]*"); // BUG(uid): bug_content = makeRex("[^ \n\r\t]+"); // at least one non-whitespace char } - if doc.name != prog.Name.Value { + if doc.name != src.Name.Value { panic("package names don't match"); } // add package documentation // TODO(gri) what to do if there are multiple files? - if prog.Doc != nil { - doc.doc = prog.Doc + if src.Doc != nil { + doc.doc = src.Doc } // add all declarations - for _, decl := range prog.Decls { + for _, decl := range src.Decls { doc.addDecl(decl); } // collect BUG(...) comments - for _, c := range prog.Comments { + for _, c := range src.Comments { text := c.List[0].Text; cstr := string(text); if m := bug_markers.Execute(cstr); len(m) > 0 { -- cgit v1.2.3