]> Cypherpunks repositories - gostls13.git/commit
cmd/cover: Fix compiler directives handling.
authorDhananjay Nakrani <dhananjayn@google.com>
Sun, 2 Oct 2016 01:01:30 +0000 (18:01 -0700)
committerRob Pike <r@golang.org>
Tue, 4 Oct 2016 16:40:40 +0000 (16:40 +0000)
commitf0636bf6f97478aca313052a9661828d01357d75
tree4952eba27598f6bf39847d951acee8a1bd6526d7
parent6300161d40e50902e16b3144c36aaf9279ab6208
cmd/cover: Fix compiler directives handling.

Currently, it separates comments from rest of the AST. This causes problems when
long counter increment statements are added before compiler directives.
See Issue #17315.

This change moves comments handling into AST Visitor so that when printer prints
code from AST, position of compiler directives relative to the associated function
is preserved.

Tested with https://gist.github.com/dhananjay92/837df6bc1f171b1350f85d7a7d59ca1e
and unit test.

Fixes #17315

Change-Id: I61a80332fc1923de6fc59ff63b953671598071fa
Reviewed-on: https://go-review.googlesource.com/30161
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/cover/cover.go
src/cmd/cover/cover_test.go
src/cmd/cover/testdata/main.go
src/cmd/cover/testdata/test.go