Komodo has always been adept at working with multiple languages. When we realized that multi-language templating systems were becoming more common, we made it easier to create new colorizers for them. But until now, Komodo wasn't very flexible at checking the syntax of these documents.
For example, Komodo has always supported running HTML documents through HTML Tidy, which can be quite draconian in its requirements. Unfortunately, HTML Tidy skips embedded CSS style and JavaScript script elements, so those have to be checked manually at runtime. And as most web developers know too well, most browsers respond to errors in CSS and JavaScript with the silent treatment. You have to test by looking for what's missing, always a recipe for frustration.
Checking Parts
Komodo 7 now identifies the different parts of a document, and hands each part over to a particular syntax checker. It then collects any error or warning messages from the different checkers, weaves them back together, and presents them all in one shot. We even integrated the Syntax Checking Status panel from Davide Ficano's KLint extension, so now you can see all the highlighted parts of a document in one view. Figure 1 shows a typical snapshot with the classic Komodo HTML sample file with some errors introduced.
The syntax checker also looks at JavaScript and CSS fragments in HTML code as well -- these are the contents of event-handling and "style" attributes. Figure 2 shows Komodo complaining about a missing quote in a handler.
Multiple Choices
Since the syntax checking internals were redesigned to handle multiple languages, we also made it easier to select different checkers for a particular language. Perl programmers had this option in earlier versions, where they could install Perl-Critic and choose which of its levels to use to examine Perl code. Now we've expanded this choice to several other languages.
JavaScript programmers can select jslint (or the more recent jshint), configure it, and have their JS code checked for problems other than missing return statements. We also found not one but two Perl modules, HTML-Tidy and HTML-Lint, that have different takes on checking HTML code. You'll need to install these modules in your local Perl library to access them.
Similarly, we've added support for three other Python syntax checkers: pylint, pyflakes, and pychecker. My personal preference is for the annoyingly picky pylint, but other people swear by pyflakes. If you're looking for a higher degree of accuracy, pychecker can supply that. Note that if you select it, Komodo will give a warning that pychecker actually loads and executes your editor's code as part of its operation. I prefer the safety of static checking, but if you know that your code isn't going near the file system or manipulating database connections, pychecker might do it for you. Figure 3 shows the new Syntax Checking page in Preferences, where all languages can be found. You can also tweak the Syntax Checking prefs on a per-file and per-project basis as well.
CSS Checking is Back
Before version 6, Komodo relied on a CSS syntax-checking component buried deep in the Mozilla codebase. Then we upgraded, lost the checker, and couldn't find a suitable third-party CSS checker anywhere. In fact, the only ones we could find were online. Meanwhile, new wrappers for CSS have emerged. One thing they all have in common is an attempt to reduce the duplication and complexity that tend to worm their way into all too many real-world stylesheets. Here's the rundown on the most common variants:
- Sass: an indentation-driven variant from the creators of Haml
- SCSS: essentially Sass with braces rather than whitespace
- Less: another brace-based wrapper, with some overlap with SCSS
Komodo now supports SCSS and Less, and offers syntax-checking for them as well. It turns out that Sass is syntactically so different from SCSS that separate coding efforts are needed to support it.
Up Next: Hopping on the Brave New World of Syntax Checkers
The new syntax checking system is full of extensibility points. The next article will cover the following topics:
- Writing a checker (aka "linter") for your own new language
- Writing a new linter for a current language, like a better jslint
- Tapping into existing templating languages
- Supporting a new templating language.
Try it yourself
If you'd like to test out these new syntax checking capabilities, you can download a 21-day free trial of Komodo IDE 7.
Komodo IDE 7 is currently on sale, starting at $245 ($295) until March 15th.
Trackback URL for this post:
Comments
It is really awesome that there is a free trial of this available. But what is even more awesome is that I bought version 6 half a year ago, just logged in, and the license and download for version 7 were already there! Very cool- I am installing it now.
-
Just because something is supposed to be really great without the cards, if people don't know how to use it then the software or tools will do them no good.
I have been have quite a few issues with synxtax highlighting in CSS files on Komodo 7. It seems quite random actually. If I add a property, the line below it changes color. If I add a comment, it might change back. It's actually quite distracting when trying to edit a file.
Thanks for this informational article. I'm so grateful since there is a 21-day trial period. That would be enough to test it first and once I'm satisfied, I can buy the full version. I am really excited to try this. I'm downloading it now.
-
What a wonderful Online-Pokies review site for australian wager fans. There is even an option to do sports betting but most of the focus is dedicated to online casino games, especifically pokies.
Javascript
since it is allowed to have diacritical characters in variable and function names,( just the first letter needs to be a-Z,) it would be a great benefit for me if that was implemented. The debugger always stops at the first missinterpretation, and continues to stay there until i change
var räknare=""; // means counter in Swedish
to
var rknare=""; // this doesn't men anything but is correct
so please accept åäö!! it is simple utf-8
oscar carserud
Hej, Oscar,
There are three possible checkers for JavaScript code in Komodo.
The "Basic Checking" module is based on the SpiderMonkey JS engine
that ships with Mozilla (Komodo and Firefox, to name two), and it
supports non-ASCII characters.
Jshint has been updated to include them. I need to find out how
to incorporate the changes into a version, as it's not in the
current default jshint.js
As for jslint, here's what it's creator had to say on the subject:
"""
It isn't a matter of legitimacy, it is a matter of portability. I have not found
that the forms you are demanding are actually used in the wild except by
crackers. If you want your program to be useful to the greatest number of
people, you should, perhaps regrettably, stick with the ASCII set of lower case
letters for variables names.
"""
http://tech.groups.yahoo.com/group/jslint_com/message/1435


