JavaFXPluginHighlightingSpecification
JavaFX Plugin - Highlighting Specification
Document Status | Initial Draft | Top-level document | JavaFXPlugin |
---|
Contents |
Introduction
The JavaFX Plugin uses and extends the standard Netbeans editor infrastructure to provide highlighting both the JavaFX source code in the Editor window and the related elements in other GUI components of the IDE.
The JavaFX Plugin provides a set of the highlighting layers that are specified by this document.
Related Documents
From Wikipedia, the free encyclopedia:
Highlighting Layers
Syntax Highlighting
The Syntax Highlighting for the JavaFX language is based on the JavaFX language grammar. Current JavaFX version defines (specifies) own grammar via ANTLR. The ANTLR grammar source is located here: https://openjfx-compiler.dev.java.net/source/browse/openjfx-compiler/trunk/src/share/classes/com/sun/tools/javafx/antlr/v3.g
More specifically, the Syntax Highlighting is based on knowledge about tokens that is provided by a lexer. See the Lexical analysis article on the wikipedia site for more info about the process.
A main goal of the Syntax Highlighting is to highlight a role of each token in the JavaFX program. For this purpose, all JavaFX tokens are divided into the lexical categories or simply categories.
Categories of Tokens
An IDE lexer should provide more detailed info about tokens and lexems than it is usually required for both compiler and interpreter of a language. In difference to the original compiler lexer, the IDE lexer has more detailed classification of the JavaFX tokens. Note, such detailed classification is required not only for the Syntax Highlighting, other IDE services will also rely on this classification.
The functional classification is used as the main approach for classification of the JavaFX tokens.
Primary Category | Comments |
---|---|
comment | |
error | |
format | especially for the FORMAT_STRING_LITERAL token |
i18n-artifact | especially for the TRANSLATION_KEY token |
identifier | |
keyword | all keywords, excepting the keywords which belong to the following categories: keyword-directive, keyword-literal |
keyword-directive | keywords that can change control flow in the program |
keyword-literal | keywords that have the same function as a literal (e.g. true, null) |
literal | |
number | |
operator | |
separator | |
string | |
time | |
whitespace |
Keywords
Keyword | Directive | Comments |
---|---|---|
keyword tokens that can start a statement/definition | ||
abstract | ||
assert | X | |
attribute | ||
bind | ||
bound | {{{1}}}
| |
lazy | {{{1}}}
| |
break | X | |
class | ||
continue | X | |
delete | ||
for | X | |
function | ||
if | X | |
import | ||
init | ||
insert | ||
let | ||
new | ||
not | ||
override | ||
package | ||
postinit | ||
private | ||
protected | ||
public | ||
readonly | ||
return | X | |
super | ||
sizeof | ||
static | ||
this | ||
throw | X | |
try | X | |
var | ||
while | ||
keyword tokens that cannot start a statement/definition | ||
after | ||
and | ||
as | ||
before | ||
catch | X | |
else | X | |
exclusive | ||
extends | ||
finally | ||
first | ||
from | ||
in | ||
indexof | ||
instanceof | ||
into | ||
inverse | ||
last | ||
lazy | ||
on | ||
or | ||
replace | ||
reverse | ||
step | ||
then | Should we treat it as a separator? It seems this keyword is redundant, because according to the grammar the parentheses around a conditional expression after the if keyword are required in all cases and they are used as separator.
| |
typeof | ||
with | ||
where |
format distinct easeboth easein easeout fps linear nodebug order reverse by do dur
Literals
The JavaFX language establishes the following literals that can be recognized on the syntax analysis phase:
The details for each class of literals are specified in the sections below.
Keyword Literals
Literal | Comments |
---|---|
true | Boolean literal |
false | Boolean literal |
null | JavaFXObject reference literal |
Numerical Literals
Literal | Comments |
---|---|
DECIMAL_LITERAL | |
OCTAL_LITERAL | |
HEX_LITERAL | |
FLOATING_POINT_LITERAL | |
TIME_LITERAL |
Requirement: The numerical literals, including HEX_LITERAL, FLOATING_POINT_LITERAL, and TIME_LITERAL, have various attributes that let a user to distinguish these literals in the source text, e.g. the leading pair "0x" for HEX_LITERAL, the terminating letter(s) "h", "m", "s", and "ms" for TIME_LITERAL, the decimal point and/or an exponent letter ("e" or "E") for FLOATING_POINT_LITERAL.
In contrast, both DECIMAL_LITERAL and OCTAL_LITERAL haven't such "highlighted" attributes.
Therefore, IDE must provide highlighting of both DECIMAL_LITERAL and OCTAL_LITERAL so that it can be easy distinguished in the JavaFX source.
String Literals
Literal | Comments |
---|---|
STRING_LITERAL (double quote) | |
STRING_LITERAL (single quote) | |
QUOTE_LBRACE_STRING_LITERAL | |
RBRACE_QUOTE_STRING_LITERAL | |
RBRACE_LBRACE_STRING_LITERAL |
Requirement: All String Escape Sequences inside a string literal should be highlighted.
Operators
Separators
Semantic Highlighting
Built-in data types
Dynamic Highlighting
See the following articles for more info about Dynamic Highlighting:
- Java Editor Users Guide - How To Use Highlights
- Source Editing in NetBeans IDE 6.0 - Code Highlighting
Application Highlighting
The Application Highlighting layer is intended to highlight important elements the of the program and underline their roles in the application. Unlike other layers this layer relies on the knowledge about application rather than the language grammar.
E.g. declarations of the GUI components, action listeners and other parts of the GUI specific code might be highlighted in the source of the GUI application.