简体   繁体   中英

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.

Yes, although this sounds like something that would ideally start with a fork of the JSP Editor, from its parser all the way up...

If you defined a new content type using the org.eclipse.core.contenttype.contentTypes extension point (using your new file extension), and then supply a Validator to the source validation extension point, org.eclipse.wst.sse.ui.sourcevalidation , explicitly for your content type, the HTML validator should be skipped over in deference to the more specific one defined for your content type. 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 shows where it looks for validators specific to the content type and prefers those over any it would use defined in a base (less specific) content type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM