How to add code folding and syntax checking?

Questions on using RSyntaxTextArea should go here.

Moderator: robert

How to add code folding and syntax checking?

Postby Debels » Tue Mar 04, 2014 10:09 pm

The title says it all, how can I implement code folding and syntax checking to a custom language?

I already made the jflex and java file.

Thanks
Debels
 
Posts: 9
Joined: Fri Feb 14, 2014 4:02 pm

Re: How to add code folding and syntax checking?

Postby robert » Fri Mar 07, 2014 1:36 pm

There will (hopefully soon) be guides on the wiki on GitHub, but in the mean time your best bet is to examine how it's implemented by looking at the classes in the org.fife.ui.rsyntaxtextarea.folding package. Basically, you create your own implementation of FoldParser, register with the singleton FoldParserManager for the application, then create an RSTA instance and set it up to use your language. The folding will automatically be used (assuming folding is enabled in the RSyntaxTextArea).

Check out the CurlyFoldParser class for a concrete example. It's used for many languages: C, C++, Java, Perl, etc. The key piece of a FoldParser is the getFolds() method. It's called whenever the document changes (after a small delay, to coalesce small changes), and is supposed to return a list of all folds for the entire document.
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

Re: How to add code folding and syntax checking?

Postby Debels » Fri Mar 07, 2014 4:42 pm

Thanks again, can't wait for the syntax checking guide :)
Debels
 
Posts: 9
Joined: Fri Feb 14, 2014 4:02 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 4 guests

cron