Archive for the ‘RSTALanguageSupport’ Category

RSyntaxTextArea 2.5.2 Released!

Sunday, March 9th, 2014

RSyntaxTexArea 2.5.2 was just released on GitHub!  Here’s what’s new:

RSyntaxTextArea:

  1. Whether or not curly braces denote code blocks is now handled on a language-index level, not per TokenMaker. This means TokenMakers such as HTML, JSP, and PHP can provide auto-indentation and curly brace closing for ‘sub-languages’ such as JSP and CSS.
  2. Java syntax highlighting updated for Java 8 classes, interfaces, and enums.
  3. Added “mark occurrences” support for HTML.
  4. Curly braces can now be automatically closed when editing CSS.
  5. The SearchEngine class now automatically selects the next match after a Replace operation.
  6. Fixed errors when loading/saving Theme XML.
  7. Fixed several bugs.

AutoComplete:

  • Only minor changes to support/stay in sync with RSyntaxTextArea 2.5.2.

RSTAUI:

  • After doing a “replace” operation with the Replace tool bar, the next valid replacement region is selected in the editor.

RSTALanguageSupport:

  1. The JavaScript language support can now use JSHint for its squiggle underlining of errors and warnings. A .jshintrc file can be specified to override the default JSHint behavior.
  2. CSS code completion.
  3. Fixing bug in XML outline tree for XML files with DTDs specified.

The SpellChecker library was not updated; the 2.5.1 release is still the most current, and is compatible with RSTA 2.5.2.  The idea is that the most recent 2.5.x versions of all of the sister libraries are all compatible with one another.

Enjoy!

JSHint integration and more JS features in Language Support

Friday, February 7th, 2014

There are a few handy new features coming for JavaScript developers in RSTALanguageSupport.

Probably the coolest feature is JSHint integration.  By default, the JS support uses Rhino to provide syntax checking, code completion, and an outline tree view of code.  This continues to be the case, but you can now configure RSTA to use JSHint for syntax checking (code completion and outline views are still handled via the AST created by Rhino).  To do this, you can use the following new methods in the JavaScriptLanguageSupport class:

LanguageSupportFactory lsf = LanguageSupportFactory.get();
JavaScriptLanguageSupport jspf = (JavaScriptLanguageSupport)lsf.getSupportFor(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
jspf.setErrorParser(JsErrorParser.JSHINT);
jspf.setJsHintRCFile(new File("path/to/.jshintrc")); // This is optional

JsErrorParser is a simple enum that allows you to toggle between Rhino and JSHint for error checking.  Once JSHint is enabled, you can optionally point to a .jshintrc file to dictate what errors/warnings should be flagged.  If you don’t do this, JSHint’s defaults are used, but doing so allows you to fully tailor your JS editing experience.

Here’s an example screenshot showing some warnings and errors identified by JSHint, some of which aren’t caught by Rhino:

JSHint Warnings

JSHint Warnings

A word of caution:  currently, the JSHint parser is executed on the EDT.  This means there could be performance issues (most likely just a short pause when the code is re-parsed).  In the next release I plan on rejiggering the RSTA parsing API so such things can be done off the EDT.  But for typical JavaScript files (under a couple of thousand lines) the pause is pretty negligible, and you can always switch back to Rhino in the short term if it is an issue.

Next, the JS outline tree now recognizes JavaScript “classes” built by extending a prototype:

Prototype Support

Prototype Support

This is the first step in making the Outline Tree for JavaScript code smarter and smarter.

Finally, the current function scope of the caret position in a JavaScript file is now outlined in the gutter, similar to what is done for Java.  This is just a small but useful visual cue as to what scope you’re currently working on in the file:

Current Scope in the Gutter

Current Scope in the Gutter

Hopefully the next RSTA/AutoComplete/LanguageSupport release will be in the next couple of weeks.  Look for it soon!

CSS Code Completion

Tuesday, December 24th, 2013

Code completion for CSS files has been added to RSTALanguageSupport.  Icons were graciously borrowed from Eclipse (as usual).

You get code completion for at-rules and HTML tags for selectors:

at-rules and HTML tags

at-rules and HTML tags

As well as property names:

Property Completions

Property Completions

And for certain properties, you’ll also get code completion for their values:

Value Completions

Value Completions

By default, the completion popup is automatically triggered (after a delay) when typing the “@” character for at-rules, and when typing ‘:’ or a space after a property name.  As always, this is configurable.

Moving forward, short documentation for each CSS property (and values too!) would be awesome.  If anyone has time or motivation and wants to contribute, pull requests or patches are welcome!

RSyntaxTextArea repositories now on GitHub, require Java 5

Sunday, August 11th, 2013

Two big things going on with RSyntaxTextArea!

First, the source for RSTA ia being moved from our personal SVN server to GitHub.  Since GitHub is the place to host open source projects these days, hopefully this new home will provide RSTA with more exposure and accessibility.  AutoComplete, SpellChecker, and the other sister libraries are moving over as well.  I haven’t quite decided yet what will happen to the current SVN server; my current idea is to keep it up and available, but to edit the readme files and Ant scripts to talk about the new location (and not actually build anything in the case of the Ant scripts, to force people to notice!).  But I can’t decide whether it’s better to just remove the repository entirely – that will force users to see it’s no longer there, causing them to go to the site and realize the source is now on Github.  While it’s a little more harsh, it will keep the project from appearing “dead” to people who simply monitor the SVN and see no updates being made.

The second big change is that, starting with the next release, RSyntaxTextArea will require Java 5.  Yes, I’m finally retiring support for Java 1.4.  If you still need to run on such an ancient JVM, you can continue to use 2.0.7 (or even fork it on Github!).  If any huge issues are found I’ll be happy to create a maintenance branch based off 2.0.7 for you Java 1.4 folks, but I seriously doubt that’ll happen.

Migrating to Java 5 doesn’t do much for the library itself, but it does modernize the code base, and fixes a couple of odd issues here and there.  You’ll find “java5″ branches in each RSTA project now; that’s where all the action is.  I’m trying to embrace git’s painless branching and all.  :)  When the work is finally done (should be in a day or two) I’ll merge these branches back into master.

Finally, I’ll be adding all known issues into the GitHub issue tracker and any other bits and pieces left remaining.  As an aside, I’ve found GitHub’s interface to be painless, fast, and intuitive.  Much better than the clunky old SourceForge interface.

RSyntaxTextArea 2.0.7 Released

Sunday, April 28th, 2013

RSyntaxTextArea 2.0.7 was just released on SourceForge!  Here’s a list of the cool new stuff:

  • setBracketMatchingEnabled(boolean) now checks for brackets “to the right” of the caret if one is not found “to the left.”
  • Added API for applications to create custom hyperlinks in RSyntaxTextArea, though this API should not be considered stable.
  • Added “mark occurrences” support for XML. Currently just highlights the tag name at the current caret position and its match.
  • Fixed issue when auto-inserting spaces for tabs.
  • Major refactoring of rendering code.
  • “Traditional” selection rendering is now supported; that is, selected text can now be rendered as syntax highlighted tokens with a “selection” background (as it was previously), or as text as a single color with the “selection” background (as standard text components do). See RSyntaxTextArea.setUseSelectedTextColor(boolean).
  • Fixed performance issue in FoldingAwareIconRowHeader when it paints “active regions.”
  • Added some new token types to better differentiate markup tokens from “regular” language tokens. This allows for better syntax highlighting for stuff like HTML, JSP, and PHP.
  • JavaScript highlighting now highlights JSDoc.
  • Added Visual Basic syntax highlighting.
  • In RSTAUI, a new TextFilePropertiesDialog was added.  This dialog shows the currently edited text file’s path, size, word count, encoding, line terminator, and more.  Further, when using a TextEditorPane, you can modify the file’s encoding or line terminator directly from the dialog.
  • RSTALanguageSupport: Miscellaneous JavaScript code completion improvements (thanks Steve).
  • RSTALanguageSupport: JavaScript code now syntax highlights JSDoc.
  • RSTALanguageSupport: JavaScript code completion now offers suggestions for JSDoc when in documentation comments.
  • RSTALanguageSupport: HTML, PHP, JSP and XML now have an option to automatically add closing tags when opening tags are typed (e.g. add “</foo>” when “<foo>” is typed). By default this option is enabled. HTML, PHP and JSP only auto-close tags closeable in the HTML 5 spec; XML closes all tags. This option is separate from the XML “auto-complete closing tag name when ‘</’ is typed” option.

Below are a couple of screenshots showing off the new JSDoc syntax highlighting and code completion.  The first one shows auto-completion kicking in after typing “@” in a documentation comment.  The second screenshot shows the parameterized assistance you get for “@param”:

JSDoc Code Completion

JSDoc Code Completion

JSDoc Parameterized Completion in action

JSDoc Parameterized Completion in action

Go check it out!

RSyntaxTextArea 2.0.5 Released

Wednesday, November 21st, 2012

RSyntaxTextArea 2.0.5 was just released on SourceForge!  Here’s a recap of what’s new:

 

  1. Code folding added for HTML, JSP, and PHP.
  2. Added NSIS syntax highlighting and code folding.
  3. Added code folding and highlighting of multi-line strings for Scala.
  4. Added Java 7 features to Groovy highlighting (underscores in numeric literals, binary literals, and new core classes/interfaces/enums).
  5. Wildcards can be specified in Go to Member dialogs.
  6. Tool tips can now be specified for icons in IconRowHeader.
  7. Fixed an issue with CompleteMarkupTagAction and ToggleLineCommentAction conflicting with each other only on *nix (Windows and OS X didn’t have this issue).
  8. Allow for non-ConfigurableCarets to be set via setCaret(), to allow for Swing’s “composed text” changes (hidden in private API).
  9. Fixed possible NPE in XmlTreeCellUI for environments where desktop AA hints cannot be determined.
  10. Updated translations – Italian (Argaar), German (Domenic), Korean (Changkyoon), Japanese (Josh), and Hungarian (Zityi).

Enjoy!

Wildcards in Go to Member Dialog

Monday, October 1st, 2012

The Go to Member dialog (Ctrl+Shift+O) allows you to jump to a method or field simply by typing its name.  It’s a great way to quickly navigate through code.  It’s currently available in RSTALanguageSupport for Java, JavaScript, and XML, and it just got a nice enhancement:  it now allows you to type wildcards as part of the identifier to search for:

Wildcards in Go to Member Dialog

Wildcards in Go to Member Dialog

 

RSyntaxTextArea 2.0.4 Released

Sunday, September 2nd, 2012

RSyntaxTextArea 2.0.4 was just released!  Grab it either from SourceForge or SVN (see also web viewer, javadoc).  This release updates RSTA as well as the sister projects AutoComplete, RSTALanguageSupport, and SpellChecker, and adds yet another sister project:  RSTAUI!  Here’s the complete list of what’s new:

All:

  • Updated translations:  Chinese (peter_barnes), Russian (Nadiya), Polish (Chris), Spanish (Leonardo), Brazilian Portuguese (Pat), and Korean (Changkyoon).
  • Removed superfluous build warnings from projects when building with Ant 1.8+ (includeantruntime).

RSyntaxTextArea:

  • HTML, JSP, and PHP syntax highlighting now also highlight embedded CSS.
  • Background color highlighting for “secondary” languages (such as CSS and JS in HTML, JSP, and PHP).
  • Added code folding for Lisp and Clojure.
  • Minor Clojure syntax highlighting updates.
  • Changed default font to Consolas on Windows Vista and 7.
  • Decreased memory usage required for regex find and replace operations.
  • Improved performance of Mark Occurrences, especially when there are lots and lots of marked occurrences.
  • Added E4X highlighting to JavaScriptTokenMaker (can toggle on and off via a static property).
  • Added a property so that, when bracket matching is enabled, you can choose to have both brackets highlighted instead of just the “opposite” one.
  • Fix to RTextScrollPane class to facilitate using it in the NetBeans GUI designer.
  • Fixed misaligned icons in row header when code folding is enabled.
  • Fixed bug: FoldManager incorrectly auto-expanded deeply-nested folds for some edits that did not affect those folds.
  • Fixed bug: wrong initial width of line number margin when calling Gutter#setLineNumberingStartIndex(int).
  • GoToMemberWindow: Fixed occasional NPE.
  • TextEditorPane: Fixed bug: clear undo stack and dirty state when “loading” a new file.
  • TextEditorPane: Now automatically scrolls to top of file on load().
  • Fixed bug: NPE in DumbCompleteWordAction in some circumstances (whitespace at beginning of file).
  • TokenMakerFactory now allows user-defined TokenMakers to be loaded via different ClassLoaders.

AutoComplete:

  • Added template completions.  You can now create completions for constructs that have arbitrary structure and take any number of parameters, such as for-loops and other common boilerplate code.
  • Fixed memory leak when uninstalling AutoCompletes from text areas.

RSTALanguageSupport:

  • Tremendous updates to JavaScript code completion and syntax checking, all done by steve.  We now use Rhino 1.7R4 for parsing.  JS is now by far the best-supported language in RSTALanguageSupport.
  • JavaLanguageSupport: Much better display of Javadoc links in Javadoc completion popup.

RSTAUI:

  • New (optional) library providing fully functional, localized dialogs for Find and Replace operations in RSyntaxTextArea.  Supports searching forward and backward, regex searching, match case, mark all, and replace all.  The actual search operations are delegated to the RSTA library’s built-in SearchEngine class.
  • More common dialogs will be added to this library in the next release.  More information about this in a future blog post!

JavaScript Language Support Updates

Monday, February 6th, 2012

First, a quick note that RSyntaxTextArea 2.0.0-beta3 is available on SourceForge!  Among other things, this release greatly improves syntax highlighting for JavaScript, HTML, PHP and JSP.

I promise RSTA won’t stay on this “beta” release track forever…

Anyway, there’s also been progress in the JavaScript language support.  It’s been in SVN for serveral days now, I just never got around to blogging about it.  Some of the “polish” I spoke of in my last post is now there:

JavaScript Improvements

JavaScript Improvements

Note the icons in the completion choices window and the outline tree on the left-hand side.  Clicking on an element in the outline tree selects that element in the editor, just like in the Java support.  We also now have Go To Member support:

Go to Member

Go to Member

Ctrl+Shift+O (Cmd+Shift+O on OS X) displays this popup allowing you to type/select the name of a variable or function to navigate to in the editor.

Here’s what’s coming up next with JS support:

  1. Take scoping into account when displaying completion choices.
  2. Use knowledge of variable types to provide better completion choices.
  3. Clean up JSDoc descriptions in the completion description window.

 

Minor updates

Saturday, January 28th, 2012

Nothing bad has been found with code folding yet – so far so good!  A few tweaks in other areas were pushed recently, the most important probably being a scanning bug in HTML and other web languages.  A JavaScript line comment (“// …”) should not hide a closing </script> tag.

If you’ve watched this blog for any length of time, you might have noticed that my motivation often shifts from one area of the project to another (new language highlighting, code completion, code folding, etc.).  Well, since code folding is winding down, I’m turning my focus back to code completion.  The wonderful Rhino project, along with more web programming at work, has motivated me to look into JavaScript code completion.

A few months ago, somebody emailed me stating that they were working on this very thing.  We were hoping to get his work integrated into RSTALanguageSupport at some point, but unfortunately I stopped hearing from him, and I can no longer find that email thread (!).  In any case, I decided to dig into this myself.  The good news is that Rhino has an incredibly easy-to-use API.  I literally read no documentation at all – just Ctrl+Space’d and picked out the classes it looked like I needed.  Fantastic!  In a short while I already had squiggle underlining of syntax errors and working completion for functions and variables:

JS Code Completion - Day 1

JS Code Completion - Day 1

It’ll look prettier when it’s done of course; this is without any polish.  This will be made just as robust as the current Java language support, but with full syntax checking (Java currently doesn’t check for syntax errors in method bodies).  This should include both an outline tree component as well as Go to Member support.

I should also hopefully get off my bum and get back to work on the Java support.  When I do, I’ll be picking up where I left off, improving parameter completion (determining variables in scope of the right type/subtype for a parameter and suggesting them).