我可以合并语法着色和折叠吗?或从主文档信息中着色的投影

时间:2023-01-12 15:54:28

Example. I have an XML document:

例。我有一个XML文档:

<document>
<region type="type1">text of region1
</region>
some simple text
<region type="type2">text of region2
</region>

And I want it to be presented as

我希望它被呈现为

text of region1
some simple text
text of region2

region1的文本region2的一些简单文本文本

The basic Eclipse coloring works independent from folding, as I know. But I need text to be colored depending on the xml info. Or maybe I need something other, than folding? It's probably easier to just manipulate StyledText, but I need other Eclipse Editor functions to continue working.

正如我所知,基本的Eclipse着色与折叠无关。但我需要根据xml信息对文本进行着色。或者我可能需要其他东西,而不是折叠?操作StyledText可能更容易,但我还需要其他Eclipse Editor功能才能继续工作。

=========
upd: Still no suggestions? Is it at least possible?
I've looked at projection, but... does text attributes directly accessible from this branch of editor?
upd: Maybe at least some thoughts/articles about custom projections?

========= upd:还是没有建议吗?它至少可能吗?我看了一下投影,但是......文本属性可以直接从编辑器的这个分支访问吗? upd:也许至少有一些关于自定义预测的想法/文章?

1 个解决方案

#1


I've implementet it via document listener service, ProjectionDocument.removeMasterDocumentRange and ProjectionDocument.getDocumentInformationMapping(). Coloring by SourceViewer.getTextWidget().setStyleRange(). There is a little problem if PresentationReconciler will be added, but since I know it, its safe.

我通过文档监听器服务ProjectionDocument.removeMasterDocumentRange和ProjectionDocument.getDocumentInformationMapping()实现它。通过SourceViewer.getTextWidget()着色.setStyleRange()。如果添加PresentationReconciler会有一点问题,但是因为我知道它是安全的。

#1


I've implementet it via document listener service, ProjectionDocument.removeMasterDocumentRange and ProjectionDocument.getDocumentInformationMapping(). Coloring by SourceViewer.getTextWidget().setStyleRange(). There is a little problem if PresentationReconciler will be added, but since I know it, its safe.

我通过文档监听器服务ProjectionDocument.removeMasterDocumentRange和ProjectionDocument.getDocumentInformationMapping()实现它。通过SourceViewer.getTextWidget()着色.setStyleRange()。如果添加PresentationReconciler会有一点问题,但是因为我知道它是安全的。