OSDN Git Service

Clean up layout and menu file scanning code
authorTor Norbye <tnorbye@google.com>
Fri, 2 Sep 2011 17:40:57 +0000 (10:40 -0700)
committerTor Norbye <tnorbye@google.com>
Fri, 2 Sep 2011 19:25:51 +0000 (12:25 -0700)
commit6a41615061dab508e87cbb18f005c5f7edb79dbd
tree86f1ae41cb5868491589fe2bae77516872527973
parent0c96c744e157c450f7d66bf62f9d569b9514e747
Clean up layout and menu file scanning code

This changeset fixes some issues around the new lazy scanning of
layout and menu files.

First, it partly fixes "19657: AAPT errors aren't shown when adding an
error to a valid XML file". With the new optimization of not running
aapt on layout files where no ids have changed, we would no longer
pick up changes where an invalid or nonexistent resource is added. We
now perform some basic validation of resources as well as XML parsing
errors.

Second, it fixes a bug in the id before and after comparison used to
determine if aapt needs to run: The code would call map.keySet()
before and after the ids were added, but this resolved to the same
keyset so the equals comparison was always true regardless of the
content.

Third, it fixes an infinite loop issue with library projects, and
avoids doing unnecessary classpath modifications when there are no
changed projects.

Finally, it changes the "needsId" flag. The state of whether aapt
needs to be run was stored per repository, and there is a bug where it
does not get cleared properly which can yield a compilation loop. This
changeset introduces a new "ScanningContext" object which is passed
down to the various resource file updater methods. This context object
now holds the needsId state object (which is renamed to
"needsFullAapt"), and it is also the object where errors can be
registered.

Change-Id: I5632612c2d93e2f10f0803e9223921adb67602be
19 files changed:
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/GlobalProjectMonitor.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/IdeScanningContext.java [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/ProjectState.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java
ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java
ide_common/src/com/android/ide/common/resources/IdResourceParser.java
ide_common/src/com/android/ide/common/resources/MultiResourceFile.java
ide_common/src/com/android/ide/common/resources/ResourceFile.java
ide_common/src/com/android/ide/common/resources/ResourceFolder.java
ide_common/src/com/android/ide/common/resources/ResourceRepository.java
ide_common/src/com/android/ide/common/resources/ScanningContext.java [new file with mode: 0644]
ide_common/src/com/android/ide/common/resources/SingleResourceFile.java