Incorrect partition detected by PartitionScanner in custom TextEditor for eclipse

好久不见. 提交于 2019-12-24 08:24:47

问题


I have a PartitionScanner that extends RuleBasedPartitionScanner in my custom text editor plugin for Eclipse. I am having issues with the partition scanner detecting character sequences within larger strings, resulting in document being partitioned incorrectly. For example, within the constructor of m partition scanner I have following rule set-up:

 public MyPartitionScanner() {
   ...
   rules.add(new MultiLineRule("SET", "ENDSET", mytoken));
   ...
 }

However, if I happen to use a token that contains the character sequence "SET," it seems like partition scanner would continue searching for endSequence("ENDSET") and will make the rest of the document as single partition set to "mytoken."

 var myRESULTSET34 = ...

Is there a way to make the partition scanner ignore the word "SET" from the token above? And only recognize the whole word "SET"?

Thank you.


回答1:


Using the MultilineRule as is, you won't be able to differentiate. But you can create your own subclass that overrides sequenceDetected and does a lookback/lookahead when the super impl returns true, to make sure that it's preceded/followed by EOF/whitespace. If it doesn't, then push back the characters onto the scanner and return false.



来源:https://stackoverflow.com/questions/5699642/incorrect-partition-detected-by-partitionscanner-in-custom-texteditor-for-eclips

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!