aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-11-01 11:48:38 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-01 11:48:38 -0700
commit42ce623240baf0aa2d1483bb25e08a9d80ec70a9 (patch)
tree02baa5c90ffde6f70b6c0f290c80149a2f538150
parentdca8a2a8e492cda47c61a8196f9c41cd6508394b (diff)
parent895858dfb29cb01564d3c93e9a1fb3576bb5a956 (diff)
downloadsdk-42ce623240baf0aa2d1483bb25e08a9d80ec70a9.zip
sdk-42ce623240baf0aa2d1483bb25e08a9d80ec70a9.tar.gz
sdk-42ce623240baf0aa2d1483bb25e08a9d80ec70a9.tar.bz2
Merge "Fix some issues with ADT reacting to project resource change."
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/IdeScanningContext.java33
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java15
3 files changed, 39 insertions, 13 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
index 5a7996e..9a9b41e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
@@ -275,10 +275,6 @@ public class PreCompilerBuilder extends BaseBuilder {
if (context.needsFullAapt()) {
mMustCompileResources = true;
- assert context.getAaptRequestedProjects() != null &&
- context.getAaptRequestedProjects().size() == 1 &&
- context.getAaptRequestedProjects().iterator().next() == project;
-
// Must also call markAaptRequested on the project to not just
// store "aapt required" on this project, but also on any projects
// depending on this project if it's a library project
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/IdeScanningContext.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/IdeScanningContext.java
index fb8caf2..5e849e6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/IdeScanningContext.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/IdeScanningContext.java
@@ -16,6 +16,7 @@
package com.android.ide.eclipse.adt.internal.resources.manager;
import static com.android.ide.eclipse.adt.AdtConstants.MARKER_AAPT_COMPILE;
+
import static org.eclipse.core.resources.IResource.DEPTH_ONE;
import static org.eclipse.core.resources.IResource.DEPTH_ZERO;
@@ -26,6 +27,7 @@ import com.android.ide.eclipse.adt.internal.build.AaptParser;
import com.android.util.Pair;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -113,7 +115,7 @@ public class IdeScanningContext extends ScanningContext {
}
// First clear out old/previous markers
- for (IResource resource :mScannedResources) {
+ for (IResource resource : mScannedResources) {
try {
if (resource.exists()) {
int depth = resource instanceof IFolder ? DEPTH_ONE : DEPTH_ZERO;
@@ -136,7 +138,34 @@ public class IdeScanningContext extends ScanningContext {
@Override
public boolean needsFullAapt() {
- return super.needsFullAapt();
+ // returns true if it was explicitly requested or if a file that has errors was modified.
+ // This handles the case where an edit doesn't add any new id but fix a compile error.
+ return super.needsFullAapt() || hasModifiedFilesWithErrors();
+ }
+
+ /**
+ * Returns true if any of the scanned resources has an error marker on it.
+ */
+ private boolean hasModifiedFilesWithErrors() {
+ for (IResource resource : mScannedResources) {
+ try {
+ int depth = resource instanceof IFolder ? DEPTH_ONE : DEPTH_ZERO;
+ if (resource.exists()) {
+ IMarker[] markers = resource.findMarkers(IMarker.PROBLEM,
+ true /*includeSubtypes*/, depth);
+ for (IMarker marker : markers) {
+ if (marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO) ==
+ IMarker.SEVERITY_ERROR) {
+ return true;
+ }
+ }
+ }
+ } catch (CoreException ce) {
+ // Pass
+ }
+ }
+
+ return false;
}
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
index 63c7fad..1c9687d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
@@ -174,13 +174,8 @@ public final class ResourceManager {
return;
}
- // Process children recursively
- IResourceDelta[] children = delta.getAffectedChildren();
- for (IResourceDelta child : children) {
- processDelta(child, context);
- }
-
- // Process this delta
+ // Process this delta first as we need to make sure new folders are created before
+ // we process their content
IResource r = delta.getResource();
int type = r.getType();
@@ -192,6 +187,12 @@ public final class ResourceManager {
updateFolder((IFolder)r, kind, context);
} // We only care about files and folders.
// Project deltas are handled by our project listener
+
+ // Now, process children recursively
+ IResourceDelta[] children = delta.getAffectedChildren();
+ for (IResourceDelta child : children) {
+ processDelta(child, context);
+ }
}
/**