aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-08-31 10:09:11 -0700
committerandroid code review <noreply-gerritcodereview@google.com>2012-08-31 10:09:12 -0700
commitb783ba0d7b4bc773abc78a9ea1cc3d519aa39cbd (patch)
tree0351ed0340ac9a20b6938cdfb5f3948bd1c2c685 /eclipse/plugins
parenta7a42ea1fc7e1783fb37fc1b839574468f24e9a8 (diff)
parentca6ebe92816189f5387a4e1e73571dd959f0c708 (diff)
downloadsdk-b783ba0d7b4bc773abc78a9ea1cc3d519aa39cbd.zip
sdk-b783ba0d7b4bc773abc78a9ea1cc3d519aa39cbd.tar.gz
sdk-b783ba0d7b4bc773abc78a9ea1cc3d519aa39cbd.tar.bz2
Merge "Avoid "Marker id: 123456789 not found" errors"
Diffstat (limited to 'eclipse/plugins')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java15
2 files changed, 18 insertions, 5 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java
index 403b17b..ebcf9e3 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java
@@ -81,7 +81,7 @@ abstract class BaseClasspathContainerInitializer extends ClasspathContainerIniti
} else {
// no error, remove existing markers.
try {
- if (project.exists()) {
+ if (project.isAccessible()) {
project.deleteMarkers(markerType, true,
IResource.DEPTH_INFINITE);
}
@@ -92,8 +92,10 @@ abstract class BaseClasspathContainerInitializer extends ClasspathContainerIniti
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- project.deleteMarkers(markerType, true,
- IResource.DEPTH_INFINITE);
+ if (project.isAccessible()) {
+ project.deleteMarkers(markerType, true,
+ IResource.DEPTH_INFINITE);
+ }
} catch (CoreException e2) {
return e2.getStatus();
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java
index d51530c..a7db983 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java
@@ -131,8 +131,13 @@ public final class BaseProjectHelper {
* @param severity the severity of the marker.
* @return the IMarker that was added or null if it failed to add one.
*/
+ @Nullable
public final static IMarker markResource(IResource resource, String markerId,
String message, int lineNumber, int startOffset, int endOffset, int severity) {
+ if (!resource.isAccessible()) {
+ return null;
+ }
+
try {
IMarker marker = resource.createMarker(markerId);
marker.setAttribute(IMarker.MESSAGE, message);
@@ -176,6 +181,7 @@ public final class BaseProjectHelper {
* @param severity the severity of the marker.
* @return the IMarker that was added or null if it failed to add one.
*/
+ @Nullable
public final static IMarker markResource(IResource resource, String markerId,
String message, int severity) {
return markResource(resource, markerId, message, -1, severity);
@@ -185,16 +191,21 @@ public final class BaseProjectHelper {
* Adds a marker to an {@link IProject}. This method does not catch {@link CoreException}, like
* {@link #markResource(IResource, String, String, int)}.
*
- * @param resource the file to be marked
+ * @param project the project to be marked
* @param markerId The id of the marker to add.
* @param message the message associated with the mark
* @param severity the severity of the marker.
* @param priority the priority of the marker
* @return the IMarker that was added.
- * @throws CoreException
+ * @throws CoreException if the marker cannot be added
*/
+ @Nullable
public final static IMarker markProject(IProject project, String markerId,
String message, int severity, int priority) throws CoreException {
+ if (!project.isAccessible()) {
+ return null;
+ }
+
IMarker marker = project.createMarker(markerId);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, severity);