Usage Examples
Among the rather simple use-cases, like having detailed syntax checks for all kinds of "micro-languages" that are used e.g. in Pattern.compile()
, XPath.compile()
and so on, here are some less obvious, yet very useful examples how IntelliLang can leverage PhpStorm's support for a much better coding assistance.
The new scripting support in the upcoming Java 1.6 is another case where it will be important to get as much as possible edit-time assistance when script-code is constructed from Java code.
Extended JavaScript support
When dealing with JavaScript that's not directly embedded inside an HTML page, PhpStorm usually just treats it as plain text. Consider the following example that creates an HTML page from an XSLT script. Without the JavaScript language being injected into the script tag with the XHTML namespace as shown in the screenshot below, this would be treated as plain text, with no further code assistance.
Support for JSP custom tags
With IntelliLang it's also possible to make the content and attributes of custom JSP tags being treated as another language. This can be useful e.g. for server-side scripting using JavaScript or any other Language implementation available for PhpStorm.
One thing that's important to know is that the taglib's URI which supplies a custom tag should be used as the namespace URI of the XML tag to inject a language into. The namespace-textfields contain a list of all known taglib URIs in the project.
Pattern validation
Here's an obvious example right from PhpStorm's OpenAPI:
/** com.intellij.codeInspection.LocalInspectionTool
* @return descriptive name to be used in <annotation>suppress</annotation> comments and annotations,
* must consist of [a-zA-Z_0-9]+
*/
@NonNls @NotNull public String getID() {
return getShortName();
}
The contract of the method getID()
is that it should only return strings that match the pattern "[a-zA-Z_0-9]+". The short note in the JavaDoc can be easily overlooked though because the contract isn't specified in an automatically verifiable way.
However, if this method were annotated as @Pattern("[a-zA-Z_0-9]+")
, any attempt to return a string that doesn't match that pattern would be flagged in the editor:
Pattern completion
If a regular expression pattern represents an enumeration of different literal values, the plugin offers completion for those values:
Editing regular expressions
Here are some examples of the enhanced coding support for regular expression patterns:
Backref validation
Surround with
Character category validation
Character category completion