Last active
January 2, 2016 11:39
-
-
Save DinisCruz/8297815 to your computer and use it in GitHub Desktop.
Eclipse Markers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.eclipse.core.resources.*; | |
| import org.eclipse.ui.texteditor.*; | |
| def root = eclipse.workspace.root | |
| Map attribs = new HashMap(); | |
| attribs.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); | |
| attribs.put(IMarker.MESSAGE, "this is a test "); | |
| attribs.put("bogus field", "some text"); | |
| MarkerUtilities.createMarker(root, attribs, IMarker.PROBLEM); | |
| return "ok"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.eclipse.core.resources.*; | |
| import org.eclipse.ui.texteditor.*; | |
| def activeEditor = eclipse.editors.active(); | |
| def javaCompilationUnit = eclipse.editors.javaCompilationUnit(activeEditor); | |
| def path = javaCompilationUnit.path(); | |
| def resource = eclipse.workspace.newResource(path, IResource.FILE); | |
| def lineNumber = 11; | |
| def severity = IMarker.SEVERITY_WARNING // IMarker.SEVERITY_ERROR; // IMarker.SEVERITY_INFO | |
| def message = "This is a custom Marker"; | |
| Map<String, Object> attributes = new HashMap<String,Object>(); | |
| attributes.put(IMarker.LINE_NUMBER, lineNumber); | |
| attributes.put(IMarker.SEVERITY, Integer.valueOf(severity)); | |
| attributes.put(IMarker.MESSAGE, message); | |
| MarkerUtilities.createMarker(resource, attributes, IMarker.PROBLEM); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.eclipse.core.resources.*; | |
| import org.eclipse.ui.texteditor.*; | |
| def activeEditor = eclipse.editors.active(); | |
| def javaCompilationUnit = eclipse.editors.javaCompilationUnit(activeEditor); | |
| def path = javaCompilationUnit.path(); | |
| def resource = eclipse.workspace.newResource(path, IResource.FILE); | |
| //find existing markers | |
| //resource.findMarkers(IMarker.PROBLEM,false, IResource.DEPTH_ZERO); | |
| //delete existing markers | |
| resource.deleteMarkers(IMarker.PROBLEM,false, IResource.DEPTH_ZERO); | |
| //return "before new marker"; | |
| def lineNumber = 11; | |
| def severity = IMarker.SEVERITY_WARNING // IMarker.SEVERITY_ERROR; // IMarker.SEVERITY_INFO | |
| def message = "This is a custom Marker"; | |
| Map<String, Object> attributes = new HashMap<String,Object>(); | |
| attributes.put(IMarker.LINE_NUMBER, lineNumber); | |
| attributes.put(IMarker.SEVERITY, Integer.valueOf(severity)); | |
| attributes.put(IMarker.MESSAGE, message); | |
| MarkerUtilities.createMarker(resource, attributes, IMarker.PROBLEM); | |
| return "new marker created"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.eclipse.core.resources.*; | |
| import org.eclipse.ui.texteditor.*; | |
| def activeEditor = eclipse.editors.active(); | |
| def javaCompilationUnit = eclipse.editors.javaCompilationUnit(activeEditor); | |
| def path = javaCompilationUnit.path(); | |
| def resource = eclipse.workspace.newResource(path, IResource.FILE); | |
| //find existing markers | |
| //resource.findMarkers(IMarker.PROBLEM,false, IResource.DEPTH_ZERO); | |
| //delete existing markers | |
| resource.deleteMarkers(IMarker.PROBLEM,false, IResource.DEPTH_ZERO); | |
| //return "before new marker"; | |
| def lineNumber = 11; | |
| def severity = IMarker.SEVERITY_WARNING // IMarker.SEVERITY_ERROR; // IMarker.SEVERITY_INFO | |
| def message = "This is a custom Marker"; | |
| def markerType = IMarker.PROBLEM; | |
| Map<String, Object> attributes = new HashMap<String,Object>(); | |
| attributes.put(IMarker.LINE_NUMBER, lineNumber); | |
| attributes.put(IMarker.SEVERITY, Integer.valueOf(severity)); | |
| attributes.put(IMarker.MESSAGE, message); | |
| IMarker marker= resource.createMarker(markerType); | |
| marker.setAttributes(attributes); | |
| //def marker = MarkerUtilities.createMarker(resource, attributes, IMarker.PROBLEM); | |
| import org.eclipse.ui.ide.*; | |
| import org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry | |
| def markerHelpRegistry = IDE.getMarkerHelpRegistry() | |
| //inspect(markerHelpRegistry);. | |
| //inspect(markerHelpRegistry); | |
| //return markerHelpRegistry; | |
| return markerHelpRegistry.getResolutions(marker); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.eclipse.ui.ide.*; | |
| import org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry | |
| def markerHelpRegistry = IDE.getMarkerHelpRegistry() | |
| return inspect(markerHelpRegistry.resolutionQueries); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment