Code Beautifier/Formatter

General Discussion on RSyntaxTextArea.

Moderator: robert

Code Beautifier/Formatter

Postby kenston » Fri Apr 30, 2010 4:55 am

Hello.

Are there any plans of integrating a code beautifier/formatter which will auto-format the code, placing necessary indentions, new lines, etc. for different syntax?

Thanks!
kenston
 
Posts: 8
Joined: Sat Dec 19, 2009 4:32 am

Re: Code Beautifier/Formatter

Postby robert » Fri Apr 30, 2010 1:01 pm

Hi Kenston,

There aren't currently plans to add a beautifier library. In the RText editor which uses RSTA, there will be a beautifier plug-in in the next release, though it will likely only handle HTML/XML via JTidy, a Java port of HTMLTidy.

Do you know of high-quality beautifiers for other languages? Preferably (though not required to be) written in Java for in-process integration? There are a few for Java, but it appears that many are no longer maintained and don't handle Java 5 syntax properly. One project that looks promising for Java is JIndent, but unfortunately I could not ship the library with RText (or an RSTA add-on), judging from the license - I would require the user to download it themselves and drop it into a certain location for the add-on to pick up.

Any ideas or suggestions?
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

Re: Code Beautifier/Formatter

Postby kenston » Sat May 01, 2010 2:41 am

Hi Robert,

I think the idea of allowing user to define their formatter library would be good. Here are some libraries shared by other people http://stackoverflow.com/questions/996646/stand-alone-java-code-formatter-beautifier-pretty-printer. I was thinking of using Eclipse' Source format, which actually has a lot of customizable features like line width etc., but I'm not sure how we can port these things to RText. Thanks
kenston
 
Posts: 8
Joined: Sat Dec 19, 2009 4:32 am

Re: Code Beautifier/Formatter

Postby franz » Thu Aug 04, 2011 4:47 pm

Hi, I think about implementing a SQL code formatter myself.
Do you think it is possible to reuse the tokens generated by SQLTokenMaker.java for this task?

Thanks and kind regards,

Franz
franz
 
Posts: 5
Joined: Fri Jul 29, 2011 3:29 pm

Re: Code Beautifier/Formatter

Postby robert » Mon Aug 08, 2011 1:37 am

Yes, you should be able to use the tokens made by RSTA. Get the tokens for a line via:

Code: Select all
Token tokenList = textArea.getTokenListForLine(int line);


This is a linked list of tokens.
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron