java - Eclipse plugin to remove validation from existing editor
问题描述
I'm creating an Eclipse RCP application that handle a custom file format which is very similar to HTML so for the most part I can use the regular HTML editor that comes with Eclipse to take advantage of its features like syntax highlight and content assist, but this custom format includes some characters/tags that are invalid in HTML, for example <#= my text #>
so when adding that to a file, like the following line:
<body><#= my text #></body>
the editor's validator will display this error:
Invalid character used in text string (<#= my text #>).
So I was wondering if it is possible to modify the behavior of an existing editor/validator to remove some specific validations and maybe add other ones.
解决方案
是的,尽管这听起来像是理想情况下从 JSP 编辑器的一个分支开始,从它的解析器一直向上......
如果您使用org.eclipse.core.contenttype.contentTypes
扩展点定义了一个新的内容类型(使用您的新文件扩展名),然后为源验证扩展点提供一个验证器org.eclipse.wst.sse.ui.sourcevalidation
,明确地为您的内容类型,应跳过 HTML 验证器以尊重更多为您的内容类型定义的特定内容。https://github.com/eclipse/webtools.sourceediting/blob/0c532000ad09e53c9fb8ddfb1c3f1def983f57c0/core/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor。 java#L266显示了它在哪里寻找特定于内容类型的验证器,并且比它在基本(不太具体)内容类型中定义的任何验证器更喜欢那些。
推荐阅读
- c# - 如何成功存储和加载游戏角色的数据?
- javascript - React 被认为是一个库,Angular 被认为是一个框架。为什么这样?
- asp.net-core - Servicestack 未经授权
- python - 如何暂停 OpenCV 视频视频流以获得积分?
- php - 如何在laravel 6中使用`@`作为函数
- powershell - 您可以在 PowerShell 属性中指定单位吗?
- git - Git - 如何将主分支移动到其他分支和头部
- sql-server - System.Data.SqlClient.SqlException 过程没有提供参数和参数。我应该如何解决这个错误?
- algorithm - 前 k 个最大元素插入 O(logn) 和 O(k) 的数据结构
- asynchronous - 如何在 Kotlin 中同步检查和设置变量?