Commit 5b68cb65 authored by Agniva De Sarker's avatar Agniva De Sarker Committed by Robert Griesemer
Browse files

go/ast: fix SortImports to handle block comments

The current algorithm only assumed line comments which always
appear at the end of an import spec. This caused block comments
which can appear before a spec to be attached to the previous spec.

So while mapping a comment to an import spec, we maintain additional
information on whether the comment is supposed to appear on the left
or right of the spec.

And we also take into account the possibility of "//line" comments
in the source. So we use unadjusted line numbers.

While at it, added some more testcases from tools/go/ast/astutil/imports_test.go

Fixes #18929

Change-Id: If920426641702a8a93904b2ec1d3455749169f69
Reviewed-on: https://go-review.googlesource.com/c/go/+/162337


Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent d2cb5b78
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment