Rewrite of ImportRewriteAnalyzer, fixing several issues.

(This is the jdt.ui portion of the predominantly jdt.core change, fixing tests.)

Fixes the following Eclipse bugs:
Bug 71761 - [import rewrite] ImportRewrite should let me add explicit import to existing on demand import
Bug 318437 - Organize Imports ignores Number of Imports needed for .*
Bug 360789 - Organize imports changes static imports to .* even when that introduces compile errors
Bug 412929 - [organize import] Adding a type results in adding a package and later does not honor order
Bug 430303 - import group sorting is broken
Bug 457051 - comment is discarded when reducing imports to an on-demand import
Bug 457089 - imports are improperly reordered in the presence of a floating comment

Some changes in behavior, which are reflected in the tests:
ImportRewriteAnalyzer no longer attempts to place unmatched imports into their "best match" import groups, instead always placing all unmatched imports together in a single match-all group.
The relocation and/or removal of comments associated with removed imports has been made more consistent. The behavior of removing comments has been made consistent between the two rewrite modes (incremental mode and "Organize Imports" mode): if there is a corresponding on-demand import for a removed single import (or vice-versa), comments are moved there; otherwise they are removed entirely. (This behavior is also more consistent with the removal of comments when deleting e.g. a field or a type.)
Comments relocated from single import(s) to an on-demand import (or vice-versa) are now always placed on line(s) preceding the destination import, even if they had been trailing comments. This behavior makes more sense especially in cases where multiple single imports are reduced into an on-demand import or vice-versa.
The scope of the fix for bug 121428 has been reduced, in that comments after a package declaration are no longer treated as file header comments.
Blank lines around and between comments are now preserved. This preserves existing formatting and prevents comments from becoming associated with different imports.

Change-Id: I7b05e40d0c00531f85a889ae123f3162262f4284
Signed-off-by: John Glassmyer <jogl@google.com>
56 files changed