-
Russ Cox authored
cmd/cover rewrites Go source code to add coverage annotations. The approach to date has been to parse the code to AST, analyze it, rewrite the AST, and print it back out. This approach fails to preserve line numbers in the original code and has a very difficult time with comments, because go/printer does as well. This CL changes cmd/cover to decide what to modify based on the AST but to apply the modifications as purely textual substitutions. In this way, cmd/cover can be sure it never adds or removes a newline character, nor a comment, so all line numbers and comments are preserved. This also allows us to emit a single //line comment at the beginning of the translated file and have the compiler report errors with correct line numbers in the original file. Fixes #6329. Fixes #15757. Change-Id: Ia95f6f894bb498e80d1f91fde56cd4a8009d7f9b Reviewed-on: https://go-review.googlesource.com/77150Reviewed-by: Ian Lance Taylor <iant@golang.org>
2c00dea1
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
directives.go | ||
main.go | ||
p.go | ||
profile.cov | ||
test.go |