GoPLS Viewer

Home|gopls/cmd/cover/cover.go
1// Copyright 2013 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package main
6
7import (
8    "bytes"
9    "flag"
10    "fmt"
11    "go/ast"
12    "go/parser"
13    "go/printer"
14    "go/token"
15    "io"
16    "io/ioutil"
17    "log"
18    "os"
19    "path/filepath"
20    "sort"
21    "strconv"
22    "strings"
23)
24
25const usageMessage = "" +
26    `Usage of 'go tool cover':
27Given a coverage profile produced by 'go test':
28    go test -coverprofile=c.out
29
30Open a web browser displaying annotated source code:
31    go tool cover -html=c.out
32
33Write out an HTML file instead of launching a web browser:
34    go tool cover -html=c.out -o coverage.html
35
36Display coverage percentages to stdout for each function:
37    go tool cover -func=c.out
38
39Finally, to generate modified source code with coverage annotations
40(what go test -cover does):
41    go tool cover -mode=set -var=CoverageVariableName program.go
42`
43
44func usage() {
45    fmt.Fprint(os.StderrusageMessage)
46    fmt.Fprintln(os.Stderr"\nFlags:")
47    flag.PrintDefaults()
48    fmt.Fprintln(os.Stderr"\n  Only one of -html, -func, or -mode may be set.")
49    os.Exit(2)
50}
51
52var (
53    mode    = flag.String("mode""""coverage mode: set, count, atomic")
54    varVar  = flag.String("var""GoCover""name of coverage variable to generate")
55    output  = flag.String("o""""file for output; default: stdout")
56    htmlOut = flag.String("html""""generate HTML representation of coverage profile")
57    funcOut = flag.String("func""""output coverage profile information for each function")
58)
59
60var profile string // The profile to read; the value of -html or -func
61
62var counterStmt func(*Fileast.Exprast.Stmt
63
64const (
65    atomicPackagePath = "sync/atomic"
66    atomicPackageName = "_cover_atomic_"
67)
68
69func main() {
70    flag.Usage = usage
71    flag.Parse()
72
73    // Usage information when no arguments.
74    if flag.NFlag() == 0 && flag.NArg() == 0 {
75        flag.Usage()
76    }
77
78    err := parseFlags()
79    if err != nil {
80        fmt.Fprintln(os.Stderrerr)
81        fmt.Fprintln(os.Stderr`For usage information, run "go tool cover -help"`)
82        os.Exit(2)
83    }
84
85    // Generate coverage-annotated source.
86    if *mode != "" {
87        annotate(flag.Arg(0))
88        return
89    }
90
91    // Output HTML or function coverage information.
92    if *htmlOut != "" {
93        err = htmlOutput(profile, *output)
94    } else {
95        err = funcOutput(profile, *output)
96    }
97
98    if err != nil {
99        fmt.Fprintf(os.Stderr"cover: %v\n"err)
100        os.Exit(2)
101    }
102}
103
104// parseFlags sets the profile and counterStmt globals and performs validations.
105func parseFlags() error {
106    profile = *htmlOut
107    if *funcOut != "" {
108        if profile != "" {
109            return fmt.Errorf("too many options")
110        }
111        profile = *funcOut
112    }
113
114    // Must either display a profile or rewrite Go source.
115    if (profile == "") == (*mode == "") {
116        return fmt.Errorf("too many options")
117    }
118
119    if *mode != "" {
120        switch *mode {
121        case "set":
122            counterStmt = setCounterStmt
123        case "count":
124            counterStmt = incCounterStmt
125        case "atomic":
126            counterStmt = atomicCounterStmt
127        default:
128            return fmt.Errorf("unknown -mode %v", *mode)
129        }
130
131        if flag.NArg() == 0 {
132            return fmt.Errorf("missing source file")
133        } else if flag.NArg() == 1 {
134            return nil
135        }
136    } else if flag.NArg() == 0 {
137        return nil
138    }
139    return fmt.Errorf("too many arguments")
140}
141
142// Block represents the information about a basic block to be recorded in the analysis.
143// Note: Our definition of basic block is based on control structures; we don't break
144// apart && and ||. We could but it doesn't seem important enough to bother.
145type Block struct {
146    startByte token.Pos
147    endByte   token.Pos
148    numStmt   int
149}
150
151// File is a wrapper for the state of a file used in the parser.
152// The basic parse tree walker is a method of this type.
153type File struct {
154    fset      *token.FileSet
155    name      string // Name of file.
156    astFile   *ast.File
157    blocks    []Block
158    atomicPkg string // Package name for "sync/atomic" in this file.
159}
160
161// Visit implements the ast.Visitor interface.
162func (f *FileVisit(node ast.Nodeast.Visitor {
163    switch n := node.(type) {
164    case *ast.BlockStmt:
165        // If it's a switch or select, the body is a list of case clauses; don't tag the block itself.
166        if len(n.List) > 0 {
167            switch n.List[0].(type) {
168            case *ast.CaseClause// switch
169                for _n := range n.List {
170                    clause := n.(*ast.CaseClause)
171                    clause.Body = f.addCounters(clause.Pos(), clause.End(), clause.Bodyfalse)
172                }
173                return f
174            case *ast.CommClause// select
175                for _n := range n.List {
176                    clause := n.(*ast.CommClause)
177                    clause.Body = f.addCounters(clause.Pos(), clause.End(), clause.Bodyfalse)
178                }
179                return f
180            }
181        }
182        n.List = f.addCounters(n.Lbracen.Rbrace+1n.Listtrue// +1 to step past closing brace.
183    case *ast.IfStmt:
184        ast.Walk(fn.Body)
185        if n.Else == nil {
186            return nil
187        }
188        // The elses are special, because if we have
189        //    if x {
190        //    } else if y {
191        //    }
192        // we want to cover the "if y". To do this, we need a place to drop the counter,
193        // so we add a hidden block:
194        //    if x {
195        //    } else {
196        //        if y {
197        //        }
198        //    }
199        switch stmt := n.Else.(type) {
200        case *ast.IfStmt:
201            block := &ast.BlockStmt{
202                Lbracen.Body.End(), // Start at end of the "if" block so the covered part looks like it starts at the "else".
203                List:   []ast.Stmt{stmt},
204                Rbracestmt.End(),
205            }
206            n.Else = block
207        case *ast.BlockStmt:
208            stmt.Lbrace = n.Body.End() // Start at end of the "if" block so the covered part looks like it starts at the "else".
209        default:
210            panic("unexpected node type in if")
211        }
212        ast.Walk(fn.Else)
213        return nil
214    case *ast.SelectStmt:
215        // Don't annotate an empty select - creates a syntax error.
216        if n.Body == nil || len(n.Body.List) == 0 {
217            return nil
218        }
219    case *ast.SwitchStmt:
220        // Don't annotate an empty switch - creates a syntax error.
221        if n.Body == nil || len(n.Body.List) == 0 {
222            return nil
223        }
224    case *ast.TypeSwitchStmt:
225        // Don't annotate an empty type switch - creates a syntax error.
226        if n.Body == nil || len(n.Body.List) == 0 {
227            return nil
228        }
229    }
230    return f
231}
232
233// unquote returns the unquoted string.
234func unquote(s stringstring {
235    terr := strconv.Unquote(s)
236    if err != nil {
237        log.Fatalf("cover: improperly quoted string %q\n"s)
238    }
239    return t
240}
241
242// addImport adds an import for the specified path, if one does not already exist, and returns
243// the local package name.
244func (f *FileaddImport(path stringstring {
245    // Does the package already import it?
246    for _s := range f.astFile.Imports {
247        if unquote(s.Path.Value) == path {
248            if s.Name != nil {
249                return s.Name.Name
250            }
251            return filepath.Base(path)
252        }
253    }
254    newImport := &ast.ImportSpec{
255        Nameast.NewIdent(atomicPackageName),
256        Path: &ast.BasicLit{
257            Kind:  token.STRING,
258            Valuefmt.Sprintf("%q"path),
259        },
260    }
261    impDecl := &ast.GenDecl{
262        Toktoken.IMPORT,
263        Specs: []ast.Spec{
264            newImport,
265        },
266    }
267    // Make the new import the first Decl in the file.
268    astFile := f.astFile
269    astFile.Decls = append(astFile.Declsnil)
270    copy(astFile.Decls[1:], astFile.Decls[0:])
271    astFile.Decls[0] = impDecl
272    astFile.Imports = append(astFile.ImportsnewImport)
273
274    // Now refer to the package, just in case it ends up unused.
275    // That is, append to the end of the file the declaration
276    //    var _ = _cover_atomic_.AddUint32
277    reference := &ast.GenDecl{
278        Toktoken.VAR,
279        Specs: []ast.Spec{
280            &ast.ValueSpec{
281                Names: []*ast.Ident{
282                    ast.NewIdent("_"),
283                },
284                Values: []ast.Expr{
285                    &ast.SelectorExpr{
286                        X:   ast.NewIdent(atomicPackageName),
287                        Selast.NewIdent("AddUint32"),
288                    },
289                },
290            },
291        },
292    }
293    astFile.Decls = append(astFile.Declsreference)
294    return atomicPackageName
295}
296
297var slashslash = []byte("//")
298
299// initialComments returns the prefix of content containing only
300// whitespace and line comments.  Any +build directives must appear
301// within this region.  This approach is more reliable than using
302// go/printer to print a modified AST containing comments.
303func initialComments(content []byte) []byte {
304    // Derived from go/build.Context.shouldBuild.
305    end := 0
306    p := content
307    for len(p) > 0 {
308        line := p
309        if i := bytes.IndexByte(line'\n'); i >= 0 {
310            linep = line[:i], p[i+1:]
311        } else {
312            p = p[len(p):]
313        }
314        line = bytes.TrimSpace(line)
315        if len(line) == 0 { // Blank line.
316            end = len(content) - len(p)
317            continue
318        }
319        if !bytes.HasPrefix(lineslashslash) { // Not comment line.
320            break
321        }
322    }
323    return content[:end]
324}
325
326func annotate(name string) {
327    fset := token.NewFileSet()
328    contenterr := ioutil.ReadFile(name)
329    if err != nil {
330        log.Fatalf("cover: %s: %s"nameerr)
331    }
332    parsedFileerr := parser.ParseFile(fsetnamecontentparser.ParseComments)
333    if err != nil {
334        log.Fatalf("cover: %s: %s"nameerr)
335    }
336    parsedFile.Comments = trimComments(parsedFilefset)
337
338    file := &File{
339        fset:    fset,
340        name:    name,
341        astFileparsedFile,
342    }
343    if *mode == "atomic" {
344        file.atomicPkg = file.addImport(atomicPackagePath)
345    }
346    ast.Walk(filefile.astFile)
347    fd := os.Stdout
348    if *output != "" {
349        var err error
350        fderr = os.Create(*output)
351        if err != nil {
352            log.Fatalf("cover: %s"err)
353        }
354    }
355    fd.Write(initialComments(content)) // Retain '// +build' directives.
356    file.print(fd)
357    // After printing the source tree, add some declarations for the counters etc.
358    // We could do this by adding to the tree, but it's easier just to print the text.
359    file.addVariables(fd)
360}
361
362// trimComments drops all but the //go: comments, some of which are semantically important.
363// We drop all others because they can appear in places that cause our counters
364// to appear in syntactically incorrect places. //go: appears at the beginning of
365// the line and is syntactically safe.
366func trimComments(file *ast.Filefset *token.FileSet) []*ast.CommentGroup {
367    var comments []*ast.CommentGroup
368    for _group := range file.Comments {
369        var list []*ast.Comment
370        for _comment := range group.List {
371            if strings.HasPrefix(comment.Text"//go:") && fset.Position(comment.Slash).Column == 1 {
372                list = append(listcomment)
373            }
374        }
375        if list != nil {
376            comments = append(comments, &ast.CommentGroup{Listlist})
377        }
378    }
379    return comments
380}
381
382func (f *Fileprint(w io.Writer) {
383    printer.Fprint(wf.fsetf.astFile)
384}
385
386// intLiteral returns an ast.BasicLit representing the integer value.
387func (f *FileintLiteral(i int) *ast.BasicLit {
388    node := &ast.BasicLit{
389        Kind:  token.INT,
390        Valuefmt.Sprint(i),
391    }
392    return node
393}
394
395// index returns an ast.BasicLit representing the number of counters present.
396func (f *Fileindex() *ast.BasicLit {
397    return f.intLiteral(len(f.blocks))
398}
399
400// setCounterStmt returns the expression: __count[23] = 1.
401func setCounterStmt(f *Filecounter ast.Exprast.Stmt {
402    return &ast.AssignStmt{
403        Lhs: []ast.Expr{counter},
404        Toktoken.ASSIGN,
405        Rhs: []ast.Expr{f.intLiteral(1)},
406    }
407}
408
409// incCounterStmt returns the expression: __count[23]++.
410func incCounterStmt(f *Filecounter ast.Exprast.Stmt {
411    return &ast.IncDecStmt{
412        X:   counter,
413        Toktoken.INC,
414    }
415}
416
417// atomicCounterStmt returns the expression: atomic.AddUint32(&__count[23], 1)
418func atomicCounterStmt(f *Filecounter ast.Exprast.Stmt {
419    return &ast.ExprStmt{
420        X: &ast.CallExpr{
421            Fun: &ast.SelectorExpr{
422                X:   ast.NewIdent(f.atomicPkg),
423                Selast.NewIdent("AddUint32"),
424            },
425            Args: []ast.Expr{&ast.UnaryExpr{
426                Optoken.AND,
427                X:  counter,
428            },
429                f.intLiteral(1),
430            },
431        },
432    }
433}
434
435// newCounter creates a new counter expression of the appropriate form.
436func (f *FilenewCounter(startend token.PosnumStmt intast.Stmt {
437    counter := &ast.IndexExpr{
438        X: &ast.SelectorExpr{
439            X:   ast.NewIdent(*varVar),
440            Selast.NewIdent("Count"),
441        },
442        Indexf.index(),
443    }
444    stmt := counterStmt(fcounter)
445    f.blocks = append(f.blocksBlock{startendnumStmt})
446    return stmt
447}
448
449// addCounters takes a list of statements and adds counters to the beginning of
450// each basic block at the top level of that list. For instance, given
451//
452//    S1
453//    if cond {
454//        S2
455//    }
456//    S3
457//
458// counters will be added before S1 and before S3. The block containing S2
459// will be visited in a separate call.
460// TODO: Nested simple blocks get unnecessary (but correct) counters
461func (f *FileaddCounters(posblockEnd token.Poslist []ast.StmtextendToClosingBrace bool) []ast.Stmt {
462    // Special case: make sure we add a counter to an empty block. Can't do this below
463    // or we will add a counter to an empty statement list after, say, a return statement.
464    if len(list) == 0 {
465        return []ast.Stmt{f.newCounter(posblockEnd0)}
466    }
467    // We have a block (statement list), but it may have several basic blocks due to the
468    // appearance of statements that affect the flow of control.
469    var newList []ast.Stmt
470    for {
471        // Find first statement that affects flow of control (break, continue, if, etc.).
472        // It will be the last statement of this basic block.
473        var last int
474        end := blockEnd
475        for last = 0last < len(list); last++ {
476            end = f.statementBoundary(list[last])
477            if f.endsBasicSourceBlock(list[last]) {
478                extendToClosingBrace = false // Block is broken up now.
479                last++
480                break
481            }
482        }
483        if extendToClosingBrace {
484            end = blockEnd
485        }
486        if pos != end { // Can have no source to cover if e.g. blocks abut.
487            newList = append(newListf.newCounter(posendlast))
488        }
489        newList = append(newListlist[0:last]...)
490        list = list[last:]
491        if len(list) == 0 {
492            break
493        }
494        pos = list[0].Pos()
495    }
496    return newList
497}
498
499// hasFuncLiteral reports the existence and position of the first func literal
500// in the node, if any. If a func literal appears, it usually marks the termination
501// of a basic block because the function body is itself a block.
502// Therefore we draw a line at the start of the body of the first function literal we find.
503// TODO: what if there's more than one? Probably doesn't matter much.
504func hasFuncLiteral(n ast.Node) (booltoken.Pos) {
505    if n == nil {
506        return false0
507    }
508    var literal funcLitFinder
509    ast.Walk(&literaln)
510    return literal.found(), token.Pos(literal)
511}
512
513// statementBoundary finds the location in s that terminates the current basic
514// block in the source.
515func (f *FilestatementBoundary(s ast.Stmttoken.Pos {
516    // Control flow statements are easy.
517    switch s := s.(type) {
518    case *ast.BlockStmt:
519        // Treat blocks like basic blocks to avoid overlapping counters.
520        return s.Lbrace
521    case *ast.IfStmt:
522        foundpos := hasFuncLiteral(s.Init)
523        if found {
524            return pos
525        }
526        foundpos = hasFuncLiteral(s.Cond)
527        if found {
528            return pos
529        }
530        return s.Body.Lbrace
531    case *ast.ForStmt:
532        foundpos := hasFuncLiteral(s.Init)
533        if found {
534            return pos
535        }
536        foundpos = hasFuncLiteral(s.Cond)
537        if found {
538            return pos
539        }
540        foundpos = hasFuncLiteral(s.Post)
541        if found {
542            return pos
543        }
544        return s.Body.Lbrace
545    case *ast.LabeledStmt:
546        return f.statementBoundary(s.Stmt)
547    case *ast.RangeStmt:
548        foundpos := hasFuncLiteral(s.X)
549        if found {
550            return pos
551        }
552        return s.Body.Lbrace
553    case *ast.SwitchStmt:
554        foundpos := hasFuncLiteral(s.Init)
555        if found {
556            return pos
557        }
558        foundpos = hasFuncLiteral(s.Tag)
559        if found {
560            return pos
561        }
562        return s.Body.Lbrace
563    case *ast.SelectStmt:
564        return s.Body.Lbrace
565    case *ast.TypeSwitchStmt:
566        foundpos := hasFuncLiteral(s.Init)
567        if found {
568            return pos
569        }
570        return s.Body.Lbrace
571    }
572    // If not a control flow statement, it is a declaration, expression, call, etc. and it may have a function literal.
573    // If it does, that's tricky because we want to exclude the body of the function from this block.
574    // Draw a line at the start of the body of the first function literal we find.
575    // TODO: what if there's more than one? Probably doesn't matter much.
576    foundpos := hasFuncLiteral(s)
577    if found {
578        return pos
579    }
580    return s.End()
581}
582
583// endsBasicSourceBlock reports whether s changes the flow of control: break, if, etc.,
584// or if it's just problematic, for instance contains a function literal, which will complicate
585// accounting due to the block-within-an expression.
586func (f *FileendsBasicSourceBlock(s ast.Stmtbool {
587    switch s := s.(type) {
588    case *ast.BlockStmt:
589        // Treat blocks like basic blocks to avoid overlapping counters.
590        return true
591    case *ast.BranchStmt:
592        return true
593    case *ast.ForStmt:
594        return true
595    case *ast.IfStmt:
596        return true
597    case *ast.LabeledStmt:
598        return f.endsBasicSourceBlock(s.Stmt)
599    case *ast.RangeStmt:
600        return true
601    case *ast.SwitchStmt:
602        return true
603    case *ast.SelectStmt:
604        return true
605    case *ast.TypeSwitchStmt:
606        return true
607    case *ast.ExprStmt:
608        // Calls to panic change the flow.
609        // We really should verify that "panic" is the predefined function,
610        // but without type checking we can't and the likelihood of it being
611        // an actual problem is vanishingly small.
612        if callok := s.X.(*ast.CallExpr); ok {
613            if identok := call.Fun.(*ast.Ident); ok && ident.Name == "panic" && len(call.Args) == 1 {
614                return true
615            }
616        }
617    }
618    found_ := hasFuncLiteral(s)
619    return found
620}
621
622// funcLitFinder implements the ast.Visitor pattern to find the location of any
623// function literal in a subtree.
624type funcLitFinder token.Pos
625
626func (f *funcLitFinderVisit(node ast.Node) (w ast.Visitor) {
627    if f.found() {
628        return nil // Prune search.
629    }
630    switch n := node.(type) {
631    case *ast.FuncLit:
632        *f = funcLitFinder(n.Body.Lbrace)
633        return nil // Prune search.
634    }
635    return f
636}
637
638func (f *funcLitFinderfound() bool {
639    return token.Pos(*f) != token.NoPos
640}
641
642// Sort interface for []block1; used for self-check in addVariables.
643
644type block1 struct {
645    Block
646    index int
647}
648
649type blockSlice []block1
650
651func (b blockSliceLen() int           { return len(b) }
652func (b blockSliceLess(ij intbool { return b[i].startByte < b[j].startByte }
653func (b blockSliceSwap(ij int)      { b[i], b[j] = b[j], b[i] }
654
655// offset translates a token position into a 0-indexed byte offset.
656func (f *Fileoffset(pos token.Posint {
657    return f.fset.Position(pos).Offset
658}
659
660// addVariables adds to the end of the file the declarations to set up the counter and position variables.
661func (f *FileaddVariables(w io.Writer) {
662    // Self-check: Verify that the instrumented basic blocks are disjoint.
663    t := make([]block1len(f.blocks))
664    for i := range f.blocks {
665        t[i].Block = f.blocks[i]
666        t[i].index = i
667    }
668    sort.Sort(blockSlice(t))
669    for i := 1i < len(t); i++ {
670        if t[i-1].endByte > t[i].startByte {
671            fmt.Fprintf(os.Stderr"cover: internal error: block %d overlaps block %d\n"t[i-1].indext[i].index)
672            // Note: error message is in byte positions, not token positions.
673            fmt.Fprintf(os.Stderr"\t%s:#%d,#%d %s:#%d,#%d\n",
674                f.namef.offset(t[i-1].startByte), f.offset(t[i-1].endByte),
675                f.namef.offset(t[i].startByte), f.offset(t[i].endByte))
676        }
677    }
678
679    // Declare the coverage struct as a package-level variable.
680    fmt.Fprintf(w"\nvar %s = struct {\n", *varVar)
681    fmt.Fprintf(w"\tCount     [%d]uint32\n"len(f.blocks))
682    fmt.Fprintf(w"\tPos       [3 * %d]uint32\n"len(f.blocks))
683    fmt.Fprintf(w"\tNumStmt   [%d]uint16\n"len(f.blocks))
684    fmt.Fprintf(w"} {\n")
685
686    // Initialize the position array field.
687    fmt.Fprintf(w"\tPos: [3 * %d]uint32{\n"len(f.blocks))
688
689    // A nice long list of positions. Each position is encoded as follows to reduce size:
690    // - 32-bit starting line number
691    // - 32-bit ending line number
692    // - (16 bit ending column number << 16) | (16-bit starting column number).
693    for iblock := range f.blocks {
694        start := f.fset.Position(block.startByte)
695        end := f.fset.Position(block.endByte)
696        fmt.Fprintf(w"\t\t%d, %d, %#x, // [%d]\n"start.Lineend.Line, (end.Column&0xFFFF)<<16|(start.Column&0xFFFF), i)
697    }
698
699    // Close the position array.
700    fmt.Fprintf(w"\t},\n")
701
702    // Initialize the position array field.
703    fmt.Fprintf(w"\tNumStmt: [%d]uint16{\n"len(f.blocks))
704
705    // A nice long list of statements-per-block, so we can give a conventional
706    // valuation of "percent covered". To save space, it's a 16-bit number, so we
707    // clamp it if it overflows - won't matter in practice.
708    for iblock := range f.blocks {
709        n := block.numStmt
710        if n > 1<<16-1 {
711            n = 1<<16 - 1
712        }
713        fmt.Fprintf(w"\t\t%d, // %d\n"ni)
714    }
715
716    // Close the statements-per-block array.
717    fmt.Fprintf(w"\t},\n")
718
719    // Close the struct initialization.
720    fmt.Fprintf(w"}\n")
721}
722
MembersX
Block.startByte
atomicCounterStmt
funcLitFinder.Visit.f
File.addVariables.RangeStmt_19221.i
profile
File.addImport.f
initialComments.content
initialComments.BlockStmt.line
File.print
File.addVariables.RangeStmt_19221.BlockStmt.end
unquote.t
trimComments.RangeStmt_9684.BlockStmt.list
File.print.w
File.addCounters.BlockStmt.last
funcLitFinder.found.f
File.offset.f
printer
parseFlags
setCounterStmt
File.newCounter
hasFuncLiteral.literal
token
Block.numStmt
File.addImport.reference
initialComments.end
File.print.f
File.addCounters.f
File.addCounters.newList
block1.index
fmt
File.index
incCounterStmt
File.endsBasicSourceBlock.s
funcLitFinder.found
File.addVariables.RangeStmt_19832.BlockStmt.n
strings
File.blocks
File.addCounters.list
File.addCounters.extendToClosingBrace
bytes
os
File.name
File.Visit.BlockStmt.BlockStmt.BlockStmt.RangeStmt_4381.n
File.index.f
block1
File.addVariables.RangeStmt_18035.i
io
Block
File.fset
File.atomicPkg
File.newCounter.end
File.statementBoundary.pos
blockSlice
File.addImport
trimComments.comments
File.addCounters
File.statementBoundary
File.addVariables.w
initialComments.p
trimComments.fset
File.intLiteral
File.newCounter.numStmt
blockSlice.Len
filepath
File.statementBoundary.BlockStmt.found
File.Visit.BlockStmt.BlockStmt.block
File.statementBoundary.BlockStmt.pos
File.endsBasicSourceBlock
blockSlice.Less
blockSlice.Swap.b
File.offset
annotate.fd
File.intLiteral.f
atomicCounterStmt.f
File.newCounter.counter
funcLitFinder.Visit.node
File.addVariables.RangeStmt_19221.block
unquote.err
File.addImport.RangeStmt_6359.s
trimComments
trimComments.RangeStmt_9684.BlockStmt.RangeStmt_9750.comment
setCounterStmt.counter
annotate.fset
File.newCounter.start
funcLitFinder.Visit.w
File.offset.pos
File.addVariables.RangeStmt_19832.i
File
File.intLiteral.i
File.Visit.BlockStmt.BlockStmt.BlockStmt.RangeStmt_4180.n
setCounterStmt.f
incCounterStmt.counter
annotate
File.astFile
annotate.content
annotate.file
File.newCounter.f
funcLitFinder
blockSlice.Swap.i
flag
sort
File.addImport.impDecl
File.addCounters.BlockStmt.end
main.err
initialComments.BlockStmt.i
hasFuncLiteral
File.endsBasicSourceBlock._
blockSlice.Len.b
usage
File.Visit.f
File.addImport.path
File.addImport.newImport
File.addCounters.pos
funcLitFinder.Visit
blockSlice.Swap
main
annotate.err
trimComments.RangeStmt_9684.group
File.addVariables.t
File.Visit
File.addImport.astFile
annotate.BlockStmt.err
File.intLiteral.node
blockSlice.Less.b
File.addVariables.RangeStmt_19832.block
File.Visit.node
unquote
incCounterStmt.f
hasFuncLiteral.n
File.endsBasicSourceBlock.f
ast
strconv
unquote.s
File.addCounters.blockEnd
File.addVariables.RangeStmt_19221.BlockStmt.start
atomicCounterStmt.counter
blockSlice.Less.j
File.addVariables.f
log
annotate.name
File.addVariables.i
Block.endByte
File.statementBoundary.f
File.addVariables
atomicPackagePath
atomicPackageName
annotate.parsedFile
trimComments.file
File.statementBoundary.s
File.statementBoundary.found
File.endsBasicSourceBlock.found
parser
ioutil
initialComments
File.newCounter.stmt
blockSlice.Less.i
blockSlice.Swap.j
Members
X