OSDN Git Service

Cherrypick fcd339 from master. do not merge.
authorTor Norbye <tnorbye@google.com>
Wed, 28 Sep 2011 14:42:38 +0000 (07:42 -0700)
committerXavier Ducrohet <xav@android.com>
Thu, 29 Sep 2011 21:18:21 +0000 (14:18 -0700)
commit3f05dce571bfedfdabf6b1f7d8f8a1c05c62317e
tree3344f4e68cf340c47ad05a4520f97d762593c317
parent0f2c305640a83b480691dc9002eb2ff5c808dff2
Cherrypick fcd339 from master. do not merge.

Find non-constant expr errors and offer migration explanation

In ADT 14, library projects will generate R fields that are not
constant, which means you cannot use them as case labels in a switch
statement. This means some existing projects may not compile. However,
the reason for this isn't obvious until you know the details of how
library projects work. Also, converting switch statements to if/else
statements is easy in Eclipse but that may not be known to all users.

This changeset adds a quickfix processor which recognizes the specific
compilation error (non-constant expressions cannot be used in case
statements), and if it looks related to Android R fields, then it
creates a fix proposal.

The fix proposal is simple: it just opens a dialog which explains the
problem, and explains how to fix it (along with a hyperlink to more
information on the ADT 14 update process).

The main advantage of this approach is that it shows up as a lightbulb
right in the editor margin (for those users who are affected by this
error only), and even just hovering over the error will show the fix
display string which talks about Migrating Android code and the extra
info states that the fix can be invoked for more info.

Change-Id: Ieb208ac459454310f5a6cce6e933d9115a135322
eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/ConvertSwitchDialog.java [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/ConvertSwitchQuickFixProcessor.java [new file with mode: 0644]