PartitionScanner在自定义TextEditor for eclipse中检测到不正确的分区 [英] Incorrect partition detected by PartitionScanner in custom TextEditor for eclipse

查看:149
本文介绍了PartitionScanner在自定义TextEditor for eclipse中检测到不正确的分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PartitionScanner,在Eclipse的自定义文本编辑器插件中扩展了RuleBasedPartitionScanner。我有分区扫描器检测较大字符串中的字符序列的问题,导致文档分区不正确。例如,在m分区扫描器的构造函数中,我有以下规则设置:

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));
   ...
 }

但是,如果我碰巧使用令牌它包含字符序列SET,似乎分区扫描程序将继续搜索endSequence(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 = ...

有没有办法使分区扫描器从上面的令牌忽略单词SET?只能识别整个字SET?

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

谢谢。

推荐答案

使用MultilineRule,您将无法区分。但是您可以创建自己的子类,覆盖 sequenceDetected ,并在超级impl返回true时执行回溯/查找,以确保它在EOF /空格之前/之后。如果没有,则将字符推回扫描仪并返回false。

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.

这篇关于PartitionScanner在自定义TextEditor for eclipse中检测到不正确的分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆