diff options
author | Xavier Ducrohet <xav@android.com> | 2009-12-15 14:41:24 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2009-12-15 14:46:29 -0800 |
commit | 9a68767a27170689fd647276cb0b082d192448fd (patch) | |
tree | fdbc79df5921a69d43a0a65012ee65ea5a560c3b /eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java | |
parent | 2758c672a9d5bb9ef66e4aed5db1183be28b192c (diff) | |
download | device_generic_opengl-transport-9a68767a27170689fd647276cb0b082d192448fd.tar.gz device_generic_opengl-transport-9a68767a27170689fd647276cb0b082d192448fd.tar.bz2 device_generic_opengl-transport-9a68767a27170689fd647276cb0b082d192448fd.zip |
Cleaned up Markers in ADT.
New packaging marker specific to packaging error coming from
ApkBuilder. This prevent conflicts with other builders adding
or removing those same markers (which apparently prevent those
markers from appearing if ApkBuilder sets them.
Fixed some conflicts between different version of
BaseProjectHelper.addMarker. Renamed the method markResource
and markProject to make it clearer.
Change-Id: I53663a052e3014fd0bff1757a9ae3d642133689f
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java | 49 |
1 files changed, 20 insertions, 29 deletions
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 8a8d1a324..772470049 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 @@ -84,34 +84,40 @@ public final class BaseProjectHelper { /** * Adds a marker to a file on a specific line. This methods catches thrown * {@link CoreException}, and returns null instead. - * @param file the file to be marked + * @param resource the resource to be marked * @param markerId The id of the marker to add. * @param message the message associated with the mark * @param lineNumber the line number where to put the mark. If line is < 1, it puts the marker - * on line 1. + * on line 1, * @param severity the severity of the marker. * @return the IMarker that was added or null if it failed to add one. */ - public final static IMarker addMarker(IResource file, String markerId, + public final static IMarker markResource(IResource resource, String markerId, String message, int lineNumber, int severity) { try { - IMarker marker = file.createMarker(markerId); + IMarker marker = resource.createMarker(markerId); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.SEVERITY, severity); - if (lineNumber < 1) { + + // if marker is text type, enforce a line number so that it shows in the editor + // somewhere (line 1) + if (lineNumber < 1 && marker.isSubtypeOf(IMarker.TEXT)) { lineNumber = 1; } - marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); + + if (lineNumber >= 1) { + marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); + } // on Windows, when adding a marker to a project, it takes a refresh for the marker // to show. In order to fix this we're forcing a refresh of elements receiving // markers (and only the element, not its children), to force the marker display. - file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); + resource.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); return marker; } catch (CoreException e) { AdtPlugin.log(e, "Failed to add marker '%1$s' to '%2$s'", //$NON-NLS-1$ - markerId, file.getFullPath()); + markerId, resource.getFullPath()); } return null; @@ -126,30 +132,15 @@ 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. */ - public final static IMarker addMarker(IResource resource, String markerId, + public final static IMarker markResource(IResource resource, String markerId, String message, int severity) { - try { - IMarker marker = resource.createMarker(markerId); - marker.setAttribute(IMarker.MESSAGE, message); - marker.setAttribute(IMarker.SEVERITY, severity); - - // on Windows, when adding a marker to a project, it takes a refresh for the marker - // to show. In order to fix this we're forcing a refresh of elements receiving - // markers (and only the element, not its children), to force the marker display. - resource.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); - - return marker; - } catch (CoreException e) { - AdtPlugin.log(e, "Failed to add marker '%1$s' to '%2$s'", //$NON-NLS-1$ - markerId, resource.getFullPath()); - } - - return null; + return markResource(resource, markerId, message, -1, severity); } /** - * Adds a marker to a resource. This method does not catch {@link CoreException} and instead - * throw them. + * 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 markerId The id of the marker to add. * @param message the message associated with the mark @@ -158,7 +149,7 @@ public final class BaseProjectHelper { * @return the IMarker that was added. * @throws CoreException */ - public final static IMarker addMarker(IProject project, String markerId, + public final static IMarker markProject(IProject project, String markerId, String message, int severity, int priority) throws CoreException { IMarker marker = project.createMarker(markerId); marker.setAttribute(IMarker.MESSAGE, message); |