How to show syntax errors in an eclipse editor plugin

后端 未结 2 1443
不知归路
不知归路 2021-02-01 00:02

How can I indicate syntax errors (e.g. an illegal sequence of tokens) in an eclipse editor plugin just like in the eclipse Java editor, i.e. by red wriggly underlines, a red mar

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 00:42

    You should be using Markers.

    An example derived from "The Java Developer's Guide to Eclipse" follows:

      
          
          
        
    
    
    IMarker marker = res.createMarker("com.ibm.tool.resources.snakesyntax");
    
    marker.setAttribute(IMarker.SEVERITY, 0);
    marker.setAttribute(IMarker.CHAR_START, startOfSyntaxError);
    marker.setAttribute(IMarker.CHAR_END, endOfSyntaxError);
    marker.setAttribute(IMarker.LOCATION, "Snake file");
    marker.setAttribute(IMarker.MESSAGE, "Syntax error");
    

提交回复
热议问题