func srcAnnot()

in lib/coverage.go [185:219]


func srcAnnot(ast *cel.Ast, src common.Source, nodes []int64, mark string) string {
	if len(nodes) == 0 {
		return ""
	}
	var buf bytes.Buffer
	columns := make(map[int]bool)
	var snippet string
	for _, id := range nodes {
		loc := ast.NativeRep().SourceInfo().GetStopLocation(id)
		if columns[loc.Column()] {
			continue
		}
		columns[loc.Column()] = true
		if snippet == "" {
			var ok bool
			snippet, ok = src.Snippet(loc.Line())
			if !ok {
				continue
			}
		}
	}
	missed := make([]int, 0, len(columns))
	for col := range columns {
		missed = append(missed, col)
	}
	sort.Ints(missed)
	fmt.Fprintln(&buf, " | "+strings.Replace(snippet, "\t", " ", -1))
	fmt.Fprint(&buf, " | ")
	var last int
	for _, col := range missed {
		fmt.Fprint(&buf, strings.Repeat(" ", minInt(col, len(snippet))-last)+mark)
		last = col + 1
	}
	return buf.String()
}