[RSS]
JavaFX Plugin - Highlighting Specification
Document Status Initial Draft Top-level document JavaFXPlugin
This is living document. Some parts of it are still unwritten.
Note: This specification is a subject to changes until the specification of the JavaFX language is not finalized.
If you are interested in changes in this document you might want to sign to this page RSS feed. You can find the feed icon for the page on the Page Info tab or use this link.

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

This part of the specification should be additionally revised and synchronized with the latest specification of the JavaFX grammar when it will be finalized. Current edition of the part is based on the v3.g rev 1927
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

TODO review the section. Last revision against the v3.g rev 2184

Keyword Directive Comments
keyword tokens that can start a statement/definition
abstract
assert X
attribute
bind
bound added rev 2184
lazy deleted rev 2184
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
Not in list:
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

Q: Whether the tween token is the operator or the keyword? TODO provide the section

Separators

TODO provide the section

Semantic Highlighting

TODO

Built-in data types

TODO JavaFX script provides four built-in data types: String, Boolean, Number, and Integer. Also, there is a special type Void. And, finally, the JavaFX runtime defines javafx.lang.Time type. // Note, the Time class has been renamed according to the JFXC-860: renamed javafx.lang.Time to javafx.lang.Duration.

Dynamic Highlighting

See the following articles for more info about Dynamic 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.

The Application Highlighting layer isn't specified and it isn't supported for the present.