summaryrefslogtreecommitdiff
path: root/src/cmd/godoc/parser.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-09-13 13:11:55 +0200
committerOndřej Surý <ondrej@sury.org>2011-09-13 13:11:55 +0200
commit80f18fc933cf3f3e829c5455a1023d69f7b86e52 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/cmd/godoc/parser.go
parent28592ee1ea1f5cdffcf85472f9de0285d928cf12 (diff)
downloadgolang-80f18fc933cf3f3e829c5455a1023d69f7b86e52.tar.gz
Imported Upstream version 60
Diffstat (limited to 'src/cmd/godoc/parser.go')
-rw-r--r--src/cmd/godoc/parser.go69
1 files changed, 0 insertions, 69 deletions
diff --git a/src/cmd/godoc/parser.go b/src/cmd/godoc/parser.go
deleted file mode 100644
index 423db222d..000000000
--- a/src/cmd/godoc/parser.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file contains support functions for parsing .go files.
-// Similar functionality is found in package go/parser but the
-// functions here operate using godoc's file system fs instead
-// of calling the OS's file operations directly.
-
-package main
-
-import (
- "go/ast"
- "go/parser"
- "go/token"
- "os"
- "path/filepath"
-)
-
-func parseFiles(fset *token.FileSet, filenames []string) (pkgs map[string]*ast.Package, first os.Error) {
- pkgs = make(map[string]*ast.Package)
- for _, filename := range filenames {
- src, err := fs.ReadFile(filename)
- if err != nil {
- if first == nil {
- first = err
- }
- continue
- }
-
- file, err := parser.ParseFile(fset, filename, src, parser.ParseComments)
- if err != nil {
- if first == nil {
- first = err
- }
- continue
- }
-
- name := file.Name.Name
- pkg, found := pkgs[name]
- if !found {
- // TODO(gri) Use NewPackage here; reconsider ParseFiles API.
- pkg = &ast.Package{name, nil, nil, make(map[string]*ast.File)}
- pkgs[name] = pkg
- }
- pkg.Files[filename] = file
- }
- return
-}
-
-
-func parseDir(fset *token.FileSet, path string, filter func(FileInfo) bool) (map[string]*ast.Package, os.Error) {
- list, err := fs.ReadDir(path)
- if err != nil {
- return nil, err
- }
-
- filenames := make([]string, len(list))
- i := 0
- for _, d := range list {
- if filter == nil || filter(d) {
- filenames[i] = filepath.Join(path, d.Name())
- i++
- }
- }
- filenames = filenames[0:i]
-
- return parseFiles(fset, filenames)
-}