summaryrefslogtreecommitdiffstats
path: root/jack
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-06-08 16:15:25 +0200
committerBenoit Lamarche <benoitlamarche@google.com>2015-06-18 17:04:39 +0200
commit9d72a29b44524ae41edf42d1f91f9253194389e0 (patch)
treeb022b8e0f6e9079f66ec46fbd8b0430d29fc4cb9 /jack
parentb26de5d409752dee416aa854fd22210e2e6080b7 (diff)
downloadtoolchain_jack-9d72a29b44524ae41edf42d1f91f9253194389e0.zip
toolchain_jack-9d72a29b44524ae41edf42d1f91f9253194389e0.tar.gz
toolchain_jack-9d72a29b44524ae41edf42d1f91f9253194389e0.tar.bz2
Rework ResourceImportConflictException
With CaseInsensitiveFS it seems obvious that the relative path of the resource should be mentioned in the error message. (cherry picked from commit f952e84878bc26f24bb19b7faaf0a4686cb60cee) Change-Id: Ie24a59f7d74748a8db4ebd7a37454693bb144838
Diffstat (limited to 'jack')
-rw-r--r--jack/src/com/android/jack/backend/jayce/JayceFileImporter.java3
-rw-r--r--jack/src/com/android/jack/resource/ResourceImportConflictException.java13
-rw-r--r--jack/src/com/android/jack/resource/ResourceImporter.java3
3 files changed, 9 insertions, 10 deletions
diff --git a/jack/src/com/android/jack/backend/jayce/JayceFileImporter.java b/jack/src/com/android/jack/backend/jayce/JayceFileImporter.java
index 796f760..783791c 100644
--- a/jack/src/com/android/jack/backend/jayce/JayceFileImporter.java
+++ b/jack/src/com/android/jack/backend/jayce/JayceFileImporter.java
@@ -206,8 +206,7 @@ public class JayceFileImporter {
Resource newResource = new Resource(path, file);
for (Resource existingResource : session.getResources()) {
if (existingResource.getPath().equals(path)) {
- throw new ResourceImportConflictException(newResource.getLocation(),
- existingResource.getLocation());
+ throw new ResourceImportConflictException(existingResource, newResource.getLocation());
}
}
session.addResource(newResource);
diff --git a/jack/src/com/android/jack/resource/ResourceImportConflictException.java b/jack/src/com/android/jack/resource/ResourceImportConflictException.java
index fcac334..ff8c828 100644
--- a/jack/src/com/android/jack/resource/ResourceImportConflictException.java
+++ b/jack/src/com/android/jack/resource/ResourceImportConflictException.java
@@ -17,6 +17,7 @@
package com.android.jack.resource;
import com.android.jack.backend.jayce.ImportConflictException;
+import com.android.jack.ir.ast.Resource;
import com.android.sched.util.location.Location;
import javax.annotation.Nonnull;
@@ -31,20 +32,20 @@ public class ResourceImportConflictException extends ImportConflictException {
@Nonnull
private final Location newResourceLocation;
@Nonnull
- private final Location existingResourceLocation;
+ private final Resource existingResource;
- public ResourceImportConflictException(@Nonnull Location newResourceLocation,
- @Nonnull Location existingResourceLocation) {
+ public ResourceImportConflictException(@Nonnull Resource existingResource,
+ @Nonnull Location newResourceLocation) {
this.newResourceLocation = newResourceLocation;
- this.existingResourceLocation = existingResourceLocation;
+ this.existingResource = existingResource;
}
@Override
@Nonnull
public String getMessage() {
- return "Resource in "
+ return "Resource \'" + existingResource.getPath().getPathAsString('/') + "\' from "
+ newResourceLocation.getDescription() + " has already been imported from "
- + existingResourceLocation.getDescription()
+ + existingResource.getLocation().getDescription()
+ " (see property '" + ResourceImporter.RESOURCE_COLLISION_POLICY.getName()
+ "' for resource collision policy)";
}
diff --git a/jack/src/com/android/jack/resource/ResourceImporter.java b/jack/src/com/android/jack/resource/ResourceImporter.java
index 68e6f9b..d4a6d14 100644
--- a/jack/src/com/android/jack/resource/ResourceImporter.java
+++ b/jack/src/com/android/jack/resource/ResourceImporter.java
@@ -72,8 +72,7 @@ public class ResourceImporter extends ResourceOrMetaImporter {
for (Resource existingResource : session.getResources()) {
if (existingResource.getPath().equals(path)) {
if (resourceCollisionPolicy == CollisionPolicy.FAIL) {
- throw new ResourceImportConflictException(newResource.getLocation(),
- existingResource.getLocation());
+ throw new ResourceImportConflictException(existingResource, newResource.getLocation());
} else {
session.getUserLogger().log(Level.INFO,
"Resource in {0} has already been imported from {1}: ignoring import", new Object[] {