XUICEXojoFormatter
Inherits XUICEAbstractFormatter
Implements XUICEFormatter
Description
A formatter for the Xojo language. In addition to tokenising the language components you'd expect (keywords,
operators, etc) it also tokenises the components of Color literals (like the Xojo IDE) and escaped double
quotes within strings.
Properties
| Name | Type | Read-Only |
|---|---|---|
| BlockBoundaries() | XUICELineToken |
|
| Keywords | Dictionary |
✔ |
| MatchedLeftParentheses() | XUICELineToken |
|
| MatchedParentheses | Dictionary |
|
| Parentheses() | XUICELineToken |
Methods
| Name | Parameters | Returns |
|---|---|---|
| AddComment | Boolean |
|
| AddIdentifierOrKeywordToken | ||
| AddMatchingParentheses | lparen As XUICELineToken, rparen As XUICELineToken |
|
| AddNumberToken | ||
| AddPragmaToken | ||
| AddStringToken | ||
| AllowsLeadingWhitespace | Boolean |
|
| CanCloseBlock | blockStart As XojoKeywords, blockEnd As XojoKeywords |
Boolean |
| ClosestCodeLineAbove | lines() As XUICELine, lineNumber As Integer |
XUICELine |
| FirstNonCommentToken | line As XUICELine |
XUICELineToken |
| IndentLines | lines() As XUICELine |
|
| IsCommentLine | line As XUICELine |
Boolean |
| IsCommentToken | token As XUICELineToken |
Boolean |
| IsSingleLineIfStatement | line As XUICELine |
Boolean |
| LastNonCommentToken | line As XUICELine |
XUICELineToken |
| Name | String |
|
| NearestDelimitersForCaretPos | caretPos As Integer |
XUICEDelimiter |
| NextToken | ||
| Parse | lines() As XUICELine |
|
| ProcessParentheses | ||
| SkipWhitespace | ||
| SupportsDelimiterHighlighting | Boolean |
|
| SupportsUnmatchedBlockHighlighting | Boolean |
|
| TokenIsComment | token As XUICELineToken |
Boolean |
| Tokenise | lines() As XUICELine, firstVisibleLineNumber As Integer, lastVisibleLineNumber As Integer |
|
| TokeniseAll | lines() As XUICELine |
|
| TokenTypes | String() |
|
| TryAddBinaryLiteral | Boolean |
|
| TryAddColorLiteral | Boolean |
|
| TryAddHexLiteral | Boolean |
|
| TryAddOctalLiteral | Boolean |
|
| TryAddUnicodeLiteral | Boolean |
Constants
| Name | Type |
|---|---|
| TOKEN_ALPHA_COMPONENT | String |
| TOKEN_BLUE_COMPONENT | String |
| TOKEN_COLOR_PREFIX | String |
| TOKEN_ESCAPE | String |
| TOKEN_GREEN_COMPONENT | String |
| TOKEN_PRAGMA | String |
| TOKEN_RED_COMPONENT | String |
TOKEN_ALPHA_COMPONENT As String The alpha component of a color literal.
TOKEN_BLUE_COMPONENT As String The blue component of a color literal.
TOKEN_COLOR_PREFIX As String
Used for the &c prefix in Color literals.
TOKEN_ESCAPE As String Used for escape sequences.
TOKEN_GREEN_COMPONENT As String The green component of a color literal.
TOKEN_PRAGMA As String Used for the pragma keyword.
TOKEN_RED_COMPONENT As String The red component of a color literal.
Enumerations
XojoKeywords
Xojo's keywords.
| Name |
|---|
| AddHandler_ |
| AddressOf_ |
| Array_ |
| As_ |
| Assigns_ |
| Break_ |
| ByRef_ |
| ByVal_ |
| Call_ |
| Case_ |
| Catch_ |
| Class_ |
| Const_ |
| Continue_ |
| CType_ |
| Declare_ |
| Dim_ |
| Do_ |
| DownTo_ |
| Each_ |
| Else_ |
| ElseIf_ |
| End_ |
| Event_ |
| Exception_ |
| Exit_ |
| Extends_ |
| Finally_ |
| For_ |
| Function_ |
| GetTypeInfo_ |
| Global_ |
| GoTo_ |
| If_ |
| Implements_ |
| Inherits_ |
| Interface_ |
| Loop_ |
| Module_ |
| Next_ |
| Optional_ |
| ParamArray_ |
| Private_ |
| Property_ |
| Protected_ |
| Public_ |
| Raise_ |
| RaiseEvent_ |
| Redim_ |
| RemoveHandler_ |
| Return_ |
| Select_ |
| Self_ |
| Shared_ |
| Static_ |
| Sub_ |
| Super_ |
| Then_ |
| Try_ |
| Until_ |
| Using_ |
| Var_ |
| While_ |
| Wend_ |
Property Descriptions
BlockBoundaries() As XUICELineToken
A sorted array of all tokens that mark the start or end of a block.
Keywords As Dictionary
Case insensitive dictionary of keywords. Key = Keyword, Value = XojoKeywords enumeration.
MatchedLeftParentheses() As XUICELineToken
An array of all left parentheses with a matching right parenthesis sorted by their position in the source code (index 0 = first matched pair of parentheses in the source code).
MatchedParentheses As Dictionary
All pairs of matching parentheses in the source code. Key = Left parenthesis (XUICELineToken), Value = Matching right parenthesis (XUICELineToken).
Parentheses() As XUICELineToken
A sorted array of all parenthesis tokens in the source code.
Method Descriptions
AddComment() As Boolean
Attempts to add a comment beginning from the current position. Returns True if successful.
Assumes the pointer is yet to consume the opening delimiter.
Comments start with // , ' or rem and end at the end of the line:
// This is comment.
var age = 40 ' This is also a comment.
rem This is also a comment
AddIdentifierOrKeywordToken()
Adds either an identifier or keyword beginning at mTokenStartLocal.
Assumes that mTokenStartLocal is a valid identifier or keyword starting
character and that mCurrent is pointing to the character immediately following the starting character.
AddMatchingParentheses(lparen As XUICELineToken, rparen As XUICELineToken)
Adds the passed matching parentheses to the MatchedParentheses dictionary and
the MatchedOpeningParentheses array.
We add both parentheses as keys so we can find either.
AddNumberToken()
Consumes and adds a number token starting at mCurrent.
Assumes that mCurrent points at a digit.
AddPragmaToken()
Attempts to consume and add a pragma token starting at mCurrent.
Assumes we have just consumed the # character.
#Pragma Something
^
AddStringToken()
Attempts to consume and add a string token starting at mCurrent.
Assumes we have just consumed a double quote ("):
name = "Hello"
^
A successful string will have seaprate tokens for its opening and closing delimiters. This allows us to tokenise escaped quotes differently from the rest of the string.
AllowsLeadingWhitespace() As Boolean
True if this formatter allows whitespace at the beginning of a line. If False, the editor will strip it when pasting and prevent it from being typed.
Part of the XUICEFormatter interface.
CanCloseBlock(blockStart As XojoKeywords, blockEnd As XojoKeywords) As Boolean
Returns True if blockEnd can close blockStart.
ClosestCodeLineAbove(lines() As XUICELine, lineNumber As Integer) As XUICELine
Returns the line above lineNumber that is not blank not just a comment line. May return Nil.
FirstNonCommentToken(line As XUICELine) As XUICELineToken
Returns the first token on line that is not a comment or Nil if there are none.
Assumes line is not Nil.
IndentLines(lines() As XUICELine)
Sets the indentation / continuation status of the passed lines.
IsCommentLine(line As XUICELine) As Boolean
True if this entire line is a comment.
Part of the XUICEFormatter interface.
IsCommentToken(token As XUICELineToken) As Boolean
True if token is a comment.
Assumes token is not Nil.
IsSingleLineIfStatement(line As XUICELine) As Boolean
True if line is a single line if statement.
LastNonCommentToken(line As XUICELine) As XUICELineToken
Returns the last token on line that is not a comment or Nil if there is none.
Assumes line is not Nil.
Name() As String
The name of this formatter.
Part of the XUICEFormatter interface.
NearestDelimitersForCaretPos(caretPos As Integer) As XUICEDelimiter
Returns the nearest delimiters at the given caretPos. May be Nil.
Part of the XUICEFormatter interface.
NextToken()
Generates the next token and appends it to mLine.Tokens.
Parse(lines() As XUICELine)
Called periodically by the editor. An opportunity to parse the tokenised lines. Will always be called after the lines have been tokenised.
Part of the XUICEFormatter interface.
ProcessParentheses()
Finds the locations of parentheses and adds them to MatchedParentheses.
SkipWhitespace()
Advances past whitespace.
SupportsDelimiterHighlighting() As Boolean
Returns True as this formatter supports highlighting the parentheses around the caret.
Part of the XUICEFormatter interface.
SupportsUnmatchedBlockHighlighting() As Boolean
True if this formatter highlights unmatched blocks.
Part of the XUICEFormatter interface.
TokenIsComment(token As XUICELineToken) As Boolean
True if token is considered to be a comment.
Part of the XUICEFormatter interface.
Tokenise(lines() As XUICELine, firstVisibleLineNumber As Integer, lastVisibleLineNumber As Integer)
Tokenises a portion of lines.
Note that we tokenise all lines, even though this method is passed the visible line numbers.
Part of the XUICEFormatter interface.
TokeniseAll(lines() As XUICELine)
Tokenises an array of lines.
Part of the XUICEFormatter interface.
TokenTypes() As String()
Returns an array of any non standard token types used by this formatter.
Part of the XUICEFormatter interface.
TryAddBinaryLiteral() As Boolean
Tries to consume and add a binary literal token. Returns True if successful.
Assumes that mCurrent points here:
&b0110
^
TryAddColorLiteral() As Boolean
Tries to consume and add a Color literal token. Returns True if successful.
Assumes that mCurrent points here:
&c123456
^
Valid tokens (where R, G, B & A are hex digits):
&cRGB
&cRRGGBB
&cRRGGBBAA
TryAddHexLiteral() As Boolean
Tries to consume and add a hexadecimal literal token. Returns True if successful.
Assumes that mCurrent points here:
&hAB19
^
TryAddOctalLiteral() As Boolean
Tries to consume and add an octal literal token. Returns True if successful.
Assumes that mCurrent points here:
&o0134
^
TryAddUnicodeLiteral() As Boolean
Tries to consume and add a unicode literal token. Returns True if successful.
Assumes that mCurrent points here:
&u13
^