如何在 Eclipse 中向语言添加合法语法

发布于 2024-12-01 20:31:49 字数 256 浏览 4 评论 0原文

我在 StackOverflow 上看到过类似的问题,涉及向语言添加突出显示,但我关心的是让 Eclipse(我猜是 xtext?)停止将某些语法标记为对于语言不正确。

具体来说,我有一个包装器,我从中调用 PIG 文件,该包装器在 PIG 文件中查找通常在 PIG 中非法的某些语法,并用模板代替它。我希望 Eclipse 停止将此语法标记为不正确,并因此在我的文件夹结构中给出丑陋的红色 x。有没有一种简单的方法可以做到这一点?或者如果做不到这一点,至少要禁用该语言的错误标记?

I've seen similar questions to this on StackOverflow regarding adding highlighting to a language, but what I'm concerned with is getting Eclipse (I'm guessing xtext?) to stop marking certain syntax as incorrect for a language.

Specifically, I have a wrapper from which I call PIG files that looks for certain syntax in the PIG file that would normally be illegal in PIG and substitutes a template for it. I'd like Eclipse to stop marking this syntax as incorrect and giving me ugly red x's in my folder structure because of it. Is there a simple way to do this? Or failing that, to at least disable marking of incorrect for that language in general?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城之時有危險 2024-12-08 20:31:49

一般来说,错误标记是由两个实体创建的:编辑器和构建器(编译器)。如果您现有的编辑器支持 PIG 格式,则在您键入时,它可能会在打开的编辑器中显示解析错误。禁用此功能的唯一方法是使用不同的编辑器重新打开文件(右键单击文件,选择打开方式...并查找编辑器 - 例如纯文本编辑器)。为了支持其他部分的语法突出显示/错误显示,但不支持特殊部分,您必须提供自己的编辑器 - 可以使用 Xtext 编写。

如果使用构建器提供错误标记,则它们仅在保存时刷新 - 当它尝试理解格式并提供输出时。在这种情况下,您只需确保在执行文件之前替换模板(如果需要,您可以在项目首选项中对构建器重新排序)。如果您没有这样的构建器,您可以禁用 PIG 构建器,这将防止显示错误的标记(但是,它也会禁用显示正确的标记)。

Generally, error markers are created by two entities: editors and builders (compilers). If your existing editor understands the PIG format, it might display parse errors in the opened editor as you are typing. The only way to disable this feature is to re-open the file using a different editor (right-click the file, select Open with... and find an editor - e.g. plain text editor). To support syntax highlighting/error display in other parts, but not in special parts, you have to provide your own editor - that can be written using Xtext.

If the error markers are provided using a builder, then they are only refreshed on save - when it tries to understand the format, and provide an output. In this case, you only have to make sure that the templates are substituted before the file is executed (you can reorder the builder in the project preferences if needed). If you have no such builder, you could disable the PIG builder, that would prevent displaying the erroneous markers (however, it also disables displaying the correct ones as well).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文