Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(41)

Delta Between Two Patch Sets: src/cmd/godoc/index.go

Issue 3050041: code review 3050041: go/ast: use token.Pos instead of token.Position; adjus... (Closed)
Left Patch Set: code review 3050041: go/ast: use token.Pos instead of token.Position; adjus... Created 14 years, 3 months ago
Right Patch Set: code review 3050041: go/ast: use token.Pos instead of token.Position; adjus... Created 14 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/godoc/godoc.go ('k') | src/cmd/godoc/main.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // This file contains the infrastructure to create an 5 // This file contains the infrastructure to create an
6 // (identifier) index for a set of Go files. 6 // (identifier) index for a set of Go files.
7 // 7 //
8 // Basic indexing algorithm: 8 // Basic indexing algorithm:
9 // - traverse all .go files of the file tree specified by root 9 // - traverse all .go files of the file tree specified by root
10 // - for each word (identifier) encountered, collect all occurences (spots) 10 // - for each word (identifier) encountered, collect all occurences (spots)
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 if err != nil { 651 if err != nil {
652 continue // ignore this directory 652 continue // ignore this directory
653 } 653 }
654 for _, f := range list { 654 for _, f := range list {
655 if !f.IsDirectory() { 655 if !f.IsDirectory() {
656 x.visitFile(dirname, f) 656 x.visitFile(dirname, f)
657 } 657 }
658 } 658 }
659 } 659 }
660 660
661 // the file set is not needed after indexing - help GC and clear it
662 x.fset = nil
663
661 // for each word, reduce the RunLists into a LookupResult; 664 // for each word, reduce the RunLists into a LookupResult;
662 // also collect the word with its canonical spelling in a 665 // also collect the word with its canonical spelling in a
663 // word list for later computation of alternative spellings 666 // word list for later computation of alternative spellings
664 words := make(map[string]*LookupResult) 667 words := make(map[string]*LookupResult)
665 var wlist RunList 668 var wlist RunList
666 for w, h := range x.words { 669 for w, h := range x.words {
667 decls := reduce(&h.Decls) 670 decls := reduce(&h.Decls)
668 others := reduce(&h.Others) 671 others := reduce(&h.Others)
669 words[w] = &LookupResult{ 672 words[w] = &LookupResult{
670 Decls: decls, 673 Decls: decls,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 764 }
762 765
763 766
764 func (x *Index) Snippet(i int) *Snippet { 767 func (x *Index) Snippet(i int) *Snippet {
765 // handle illegal snippet indices gracefully 768 // handle illegal snippet indices gracefully
766 if 0 <= i && i < len(x.snippets) { 769 if 0 <= i && i < len(x.snippets) {
767 return x.snippets[i] 770 return x.snippets[i]
768 } 771 }
769 return nil 772 return nil
770 } 773 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b