diff options
author | Tor Norbye <tnorbye@google.com> | 2011-12-19 19:27:34 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2011-12-19 19:27:34 -0800 |
commit | 402af1286193f536946b36979b259511d6a9bb06 (patch) | |
tree | 7978bf3ad5809d4381722b8c5a3054bafe156072 | |
parent | 3d73211da767ae07698d12db1f6d6f8a0b0ed7bd (diff) | |
download | sdk-402af1286193f536946b36979b259511d6a9bb06.zip sdk-402af1286193f536946b36979b259511d6a9bb06.tar.gz sdk-402af1286193f536946b36979b259511d6a9bb06.tar.bz2 |
Fix 23215: "Run Android Lint" throws errors to Java Error Log
Make sure that an IResource is accessible before attempting to add a
marker to it. And if it isn't, just add the markers to the original
resource (usually the project) instead.
Change-Id: I679a249ed6e4280f46f041f15990ab79091c4f39
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java index ef42f44..959c75e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java @@ -170,37 +170,36 @@ public class EclipseLintClient extends LintClient implements IDomParser { int severity = getMarkerSeverity(s); IMarker marker = null; - if (location == null) { - marker = BaseProjectHelper.markResource(mResource, MARKER_LINT, - message, 0, severity); - } else { + if (location != null) { Position startPosition = location.getStart(); if (startPosition == null) { - IResource resource = null; if (location.getFile() != null) { - resource = AdtUtils.fileToResource(location.getFile()); - } - if (resource == null) { - resource = mResource; + IResource resource = AdtUtils.fileToResource(location.getFile()); + if (resource != null && resource.isAccessible()) { + marker = BaseProjectHelper.markResource(resource, MARKER_LINT, + message, 0, severity); + } } - marker = BaseProjectHelper.markResource(resource, MARKER_LINT, - message, 0, severity); } else { Position endPosition = location.getEnd(); int line = startPosition.getLine() + 1; // Marker API is 1-based IFile file = AdtUtils.fileToIFile(location.getFile()); - if (file != null) { + if (file != null && file.isAccessible()) { Pair<Integer, Integer> r = getRange(file, mDocument, startPosition, endPosition); int startOffset = r.getFirst(); int endOffset = r.getSecond(); - marker = BaseProjectHelper.markResource(file, MARKER_LINT, message, line, startOffset, endOffset, severity); } } } + if (marker == null) { + marker = BaseProjectHelper.markResource(mResource, MARKER_LINT, + message, 0, severity); + } + if (marker != null) { // Store marker id such that we can recognize it from the suppress quickfix try { @@ -279,7 +278,9 @@ public class EclipseLintClient extends LintClient implements IDomParser { */ public static IMarker[] getMarkers(IResource resource) { try { - return resource.findMarkers(MARKER_LINT, false, IResource.DEPTH_INFINITE); + if (resource.isAccessible()) { + return resource.findMarkers(MARKER_LINT, false, IResource.DEPTH_INFINITE); + } } catch (CoreException e) { AdtPlugin.log(e, null); } |