Eclipse marker is invisible

I am having a weird problem adding a custom eclipse token. The scenario is that when adding a marker, when the resource (which I need to add a marker) is open, then the marker icon is displayed. But if the resource is not open, a marker is added, but the icon is not displayed.

Here is the code snippet I am using

<extension id="HighPriority" name="High Priority problem" point="org.eclipse.core.resources.markers"> <persistent value="true"> </persistent> <super type="org.eclipse.core.resources.problemmarker"/> <super type="org.eclipse.core.resources.textmarker"/> </extension> <extension point="org.eclipse.ui.editors.annotationTypes"> <type name="XXXHighPriorityAnnotation" super="org.eclipse.ui.workbench.texteditor.warning" markerType="XXXHighPriority"/> </extension> <extension point="XXXmarkerAnnotationSpecification"> <specification annotationType="XXXHighPriorityAnnotation" icon="icons\img.gif" /> </extension> 

And the code to create the marker

 IMarker marker = markerNode.getTargetFile().createMarker(markerNode.getPriority().getMarkerName()); Map<String, Object> attributes = new HashMap<String,Object>(); attributes.put(IMarker.LINE_NUMBER, markerNode.getLineNumber()); attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING)); attributes.put(IMarker.MESSAGE, markerNode.getMessage()); attributes.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_HIGH)); marker.setAttributes(attributes); 

To open the editor, I use the following code

 IDE.openEditor(this.getSite().getPage(), marker, OpenStrategy.activateOnOpen()); 

Is there anything else to do when opening the editor?

Any suggestions...???

+4
source share
2 answers

You can compare your code with those that should work fine, as indicated in error 73420 .
The context of this old error (eclipse 3.1) does not match yours, but may give you some clues or ideas on what to try.
What version of Eclipse and Java are you using?

Extract this error report:

This code also works great

 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IMarker[] markers = root.findMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO); for (int i = 0; i < markers.length; i++) { String message = (String) markers[i].getAttribute(IMarker.MESSAGE); if (message != null && message.startsWith("this is a test")) { markers[i].delete(); } } //IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); Map attribs = new HashMap(); for (int i = 0; i < 8; i++) { attribs.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); attribs.put(IMarker.MESSAGE, "this is a test " + i); attribs.put("bogus field", "some text"); MarkerUtilities.createMarker(root, attribs, IMarker.PROBLEM); } 
+2
source

I used to dump code into action. But after I replaced it with a project, it started to work ...

I don’t know what went wrong .. :)

0
source

All Articles