1

Hi, I m doing a eclipse plugin project to create an IDE like eclipse for a particular language.

when the program written in my IDE is having errors,it throws the errors to the console view which i have created in my IDE.but when the user clicks on a particular,i should highlight or set a marker for the line having the error.

I know the line number having the error.How shall i set the background color or a marker to indicate the user that this line is having the selected error?

How shall i do this in java?

Can anyone help me in doing this?

4

1 回答 1

1

你应该使用MarkerUtilities.createMarker(IResource, Map, String)这样的东西:

Map<String, Object> map = new HashMap<String, Object>();

map.put(IMarker.MESSAGE, "My message");
map.put(IMarker.LINE_NUMBER, Integer.valueOf(myLine));
map.put(IMarker.CHAR_START, Integer.valueOf(myStartRegion));
map.put(IMarker.CHAR_END, Integer.valueOf(myEndRegion));
map.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_INFO));
map.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_NORMAL));

org.eclipse.ui.texteditor.MarkerUtilities.createMarker(myFile, map, MARKER_ID);

与您MARKER_ID的 plugin.xml 中的“markerType”描述相匹配

查看扩展点

  • org.eclipse.ui.editors.annotationTypes
  • org.eclipse.ui.editors.markerAnnotationSpecification
  • org.eclipse.core.resources.markers

您可以在此 plugin.xml中找到错误标记的示例。寻找对标记的引用。标记的设计在 plugin.xml 中定义

于 2012-04-23T09:47:39.103 回答