-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for non-standard syntax based on a custom TokenMaker #548
Comments
…xTextArea and RSyntaxDocument
Add methods to set TokenMaker with style key on RSyntaxTextArea and RSyntaxDocument
- add RSyntaxDocument.getTokenMaker() - remove proprietary changes tagged with DBVIS-9154 - bump version number to 240617
I just created a Pull Request with the desired changes. |
…r, String) - setSyntaxEditingStyle(TokenMaker, String) now matches the behavior of setSyntaxEditingStyle(String) with respect to null values and updating the document - extend test
@ptorngren Could you do something like this? I think this was my original idea, updating the AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory)TokenMakerFactory.getDfeaultInstance();
atmf.putMapping("text/myLanguage", "com.ptorngeren.MyTokenMaker"); Or, if you don't feel great about the casting, create a custom TokenMakerFactory that delegates to the original default if its set of keys don't match the input. |
Sorry for late answer .... Not sure, but I don't think it will do the trick. Don't remember the exact details, but we ended up calling the method I referenced for some reason. Still, even if the ATMF approach you suggest would work for us, it would still render the referenced method more or less unusable since I can never assign a style with the TokenMaker I set. It might also be the case that you need different TokenMakers for the same style, eg to handle different dialects of the same language (eg SQL). PS: I also found a glitch in the PR I created: |
Describe the solution you'd like
I'd like to set the syntax based on a custom
TokenMaker
with a specific syntax style key that is assigned both to theRSyntaxTextArea
and theRSyntaxDocument
.Are there any workarounds?
Not really.
RSyntaxDocument.setSyntaxStyle(TokenMaker)
always assigns the style keytext/unknown
andRSyntaxDocument.setSyntaxStyle(String)
always assigns aTokenMaker
that is fetched from thetokenMakerFactory
using the style key only.Additional context
As stated in the javadoc for
RSyntaxDocument.setSyntaxStyle(TokenMaker)
, this is the recommended method to call if you've created a custom token maker for a language not normally supported by RSyntaxTextArea.Alas, there is no way to call the recommended method AND register a style key on the document, and there is no way to set the style key on the editor without also calling
RSyntaxDocument.setSyntaxStyle(styleKey)
and consequently setting a registeredTokenMaker
on the document. There is no way to call the recommended method without making the text area and the document hold different style keys, which effectively invalidates any items registered for a specific style in the editor (eg theFoldParserManager
).A simple fix would be to add a method that sets a
TokenMaker
and a style key to both theRSyntaxTextArea
andRSyntaxDocument
Sample code
RSyntaxDocument
RSyntaxTextArea
The text was updated successfully, but these errors were encountered: