如何获取 Eclipse 中光标所在位置的 XML Dom 节点?

如何在我正在构建的 Eclipse 自定义 XML 编辑器中获取指向光标所在位置的 xml dom 节点和 xpath.它是一个文本编辑器.到目前为止,我正在实施 IContentAssistProcessor.

How do I get the xml dom node and xpath to where my cursor is in an Eclipse custom XML editor that I am building. It is a textEditor. I am implementing IContentAssistProcessor thus far.

推荐答案

可以获取文本编辑器中的光标,您可以实现一个存储 XML 节点的位置 使用 SAX 定位器.对于鼠标事件,您可以扫描文档并找到最佳匹配节点.我不确定它的性能如何,但这是我要开始的地方.

You can get the position of the cursor in the text editor and you can implement an XML reader that stores the locations of the XML nodes using the SAX Locator. For a mouse event, you could then scan the document and find the best matching node. I am not sure how performant this is but this is where I would start.

相关文章