aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common/src/com/android/ide/common/resources/ResourceFolder.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-09-02 10:40:57 -0700
committerTor Norbye <tnorbye@google.com>2011-09-02 12:25:51 -0700
commit6a41615061dab508e87cbb18f005c5f7edb79dbd (patch)
tree86f1ae41cb5868491589fe2bae77516872527973 /ide_common/src/com/android/ide/common/resources/ResourceFolder.java
parent0c96c744e157c450f7d66bf62f9d569b9514e747 (diff)
downloadsdk-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/ResourceFolder.java')
-rw-r--r--ide_common/src/com/android/ide/common/resources/ResourceFolder.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/ide_common/src/com/android/ide/common/resources/ResourceFolder.java b/ide_common/src/com/android/ide/common/resources/ResourceFolder.java
index e55e14c..b8e0cda 100644
--- a/ide_common/src/com/android/ide/common/resources/ResourceFolder.java
+++ b/ide_common/src/com/android/ide/common/resources/ResourceFolder.java
@@ -47,7 +47,7 @@ public final class ResourceFolder implements Configurable {
* @param type The type of the folder
* @param config The configuration of the folder
* @param folder The associated {@link IAbstractFolder} object.
- * @param isFrameworkRepository
+ * @param repository The associated {@link ResourceRepository}
*/
protected ResourceFolder(ResourceFolderType type, FolderConfiguration config,
IAbstractFolder folder, ResourceRepository repository) {
@@ -59,12 +59,15 @@ public final class ResourceFolder implements Configurable {
/**
* Processes a file and adds it to its parent folder resource.
+ *
* @param file the underlying resource file.
- * @param folder the parent of the resource file.
* @param kind the file change kind.
+ * @param context a context object with state for the current update, such
+ * as a place to stash errors encountered
* @return the {@link ResourceFile} that was created.
*/
- public ResourceFile processFile(IAbstractFile file, ResourceDeltaKind kind) {
+ public ResourceFile processFile(IAbstractFile file, ResourceDeltaKind kind,
+ ScanningContext context) {
// look for this file if it's already been created
ResourceFile resFile = getFile(file);
@@ -84,7 +87,7 @@ public final class ResourceFolder implements Configurable {
if (types.size() == 1) {
resFile = new SingleResourceFile(file, this);
- } else if (types.contains(ResourceType.LAYOUT)){
+ } else if (types.contains(ResourceType.LAYOUT)) {
resFile = new IdGeneratingResourceFile(file, this, ResourceType.LAYOUT);
} else if (types.contains(ResourceType.MENU)) {
resFile = new IdGeneratingResourceFile(file, this, ResourceType.MENU);
@@ -92,16 +95,16 @@ public final class ResourceFolder implements Configurable {
resFile = new MultiResourceFile(file, this);
}
- resFile.load();
+ resFile.load(context);
// add it to the folder
addFile(resFile);
}
} else {
if (kind == ResourceDeltaKind.REMOVED) {
- removeFile(resFile);
+ removeFile(resFile, context);
} else {
- resFile.update();
+ resFile.update(context);
}
}
@@ -122,15 +125,15 @@ public final class ResourceFolder implements Configurable {
mFiles.add(file);
}
- protected void removeFile(ResourceFile file) {
- file.dispose();
+ protected void removeFile(ResourceFile file, ScanningContext context) {
+ file.dispose(context);
mFiles.remove(file);
}
- protected void dispose() {
+ protected void dispose(ScanningContext context) {
if (mFiles != null) {
for (ResourceFile file : mFiles) {
- file.dispose();
+ file.dispose(context);
}
mFiles.clear();