Difference between revisions of "FAQ Why don't my markers appear in the editor's vertical ruler?"
Revision as of 16:53, 14 March 2006
Text editors in Eclipse can display markers in a number of ways. Most commonly, they appear as icons in the vertical rule on the left-hand side of the editor pane. Markers can also optionally be displayed as squiggly underlays in the text and in the overview ruler on the right-hand side of the editor. How each type of marker is displayed is chosen by the user on the editor preference pages (Workbench > Editors > Text Editor > Annotations and Java > Editor > Annotations). The IMarker interface declares a number of frequently used marker types. Any created marker that has either the LINE_NUMBER or CHAR_START and CHAR_END attributes set will be displayed by editors. These attributes must exist when the marker is created for the marker to appear in an editor. The most common mistake is to create the marker and then add the attributes in a separate operation. The text framework provides a utility class called MarkerUtilities to make this easier for you. Here is a sample snippet that adds a marker correctly:
int lineNumber = ...; HashMap map = new HashMap(); MarkerUtilities.setLineNumber(map, lineNumber); MarkerUtilities.createMarker(resource, map, IMarker.TEXT);
This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.