diff options
author | Tor Norbye <tnorbye@google.com> | 2011-09-02 10:40:57 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2011-09-02 12:25:51 -0700 |
commit | 6a41615061dab508e87cbb18f005c5f7edb79dbd (patch) | |
tree | 86f1ae41cb5868491589fe2bae77516872527973 /ide_common/src/com/android/ide/common/resources/SingleResourceFile.java | |
parent | 0c96c744e157c450f7d66bf62f9d569b9514e747 (diff) | |
download | sdk-6a41615061dab508e87cbb18f005c5f7edb79dbd.zip sdk-6a41615061dab508e87cbb18f005c5f7edb79dbd.tar.gz sdk-6a41615061dab508e87cbb18f005c5f7edb79dbd.tar.bz2 |
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
Diffstat (limited to 'ide_common/src/com/android/ide/common/resources/SingleResourceFile.java')
-rw-r--r-- | ide_common/src/com/android/ide/common/resources/SingleResourceFile.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java b/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java index b589b35..6b663e9 100644 --- a/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java +++ b/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java @@ -73,7 +73,7 @@ public class SingleResourceFile extends ResourceFile { } @Override - protected void load() { + protected void load(ScanningContext context) { // get a resource item matching the given type and name ResourceItem item = getRepository().getResourceItem(mType, mResourceName); @@ -81,22 +81,22 @@ public class SingleResourceFile extends ResourceFile { item.add(this); // Ask for an ID refresh since we're adding an item that will generate an ID - getRepository().markForIdRefresh(); + context.requestFullAapt(); } @Override - protected void update() { + protected void update(ScanningContext context) { // when this happens, nothing needs to be done since the file only generates // a single resources that doesn't actually change (its content is the file path) } @Override - protected void dispose() { + protected void dispose(ScanningContext context) { // only remove this file from the existing ResourceItem. getFolder().getRepository().removeFile(mType, this); // Ask for an ID refresh since we're removing an item that previously generated an ID - getRepository().markForIdRefresh(); + context.requestFullAapt(); // don't need to touch the content, it'll get reclaimed as this objects disappear. // In the mean time other objects may need to access it. |