XUICEObjoScriptFormatter
Inherits XUICEAbstractFormatter
Implements XUICEFormatter
Description
A XUICodeEditor
formatter for the Wren programming language.
Properties
Name | Type | Read-Only |
---|---|---|
Delimiters() | XUICELineToken |
|
Keywords | Dictionary |
✔ |
MatchedDelimiters | Dictionary |
|
MatchedOpeningDelimiters() | XUICELineToken |
Methods
Name | Parameters | Returns |
---|---|---|
AddComment | Boolean |
|
AddHexNumberToken | ||
AddIdentifierOrKeywordToken | ||
AddMatchingDelimiters | openingDelimiter As XUICELineToken , closingDelimiter As XUICELineToken |
|
AddNumberToken | ||
AddStringToken | ||
AllowsLeadingWhitespace | Boolean |
|
FirstNonCommentToken | line As XUICELine |
XUICELineToken |
IndentLines | ||
InitialiseKeywordsDictionary | Dictionary |
|
IsClosingDelimiter | t As XUICELineToken |
Boolean |
IsCommentLine | line As XUICELine |
Boolean |
IsCommentToken | token As XUICELineToken |
Boolean |
IsLCurly | t As XUICELineToken |
Boolean |
IsOpeningDelimiter | t As XUICELineToken |
Boolean |
LastNonCommentToken | line As XUICELine |
XUICELineToken |
Name | String |
|
NearestDelimitersForCaretPos | caretPos As Integer |
XUICEDelimiter |
NextToken | ||
Parse | lines() As XUICELine |
|
ProcessDelimiters | ||
SetContinuationStatus | line As XUICELine , previousLineLastToken As XUICELineToken |
|
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() |
Constants
Name | Type |
---|---|
TOKEN_ESCAPE | String |
TOKEN_ESCAPE As String Used for escape sequences.
Enumerations
CommentTypes
Used internally. The different types of supported comments.
Name |
---|
Block |
SingleLine |
Property Descriptions
Delimiters() As XUICELineToken
A sorted array of all delimiter tokens in the source code.
Keywords As Dictionary
Case sensitive dictionary of keywords. Key = Keyword, Value = Nil.
MatchedDelimiters As Dictionary
All matched delimiters in the source code. Key = Delimiter A
(XUICELineToken
), Value = Delimiter matching Delimiter A
(XUICELineToken
).
MatchedOpeningDelimiters() As XUICELineToken
An array of all opening delimiters that have a matching closing delimiter sorted by their position in the source code (index 0 = first matched delimiter 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 //
and end at the end of the line:
// This is comment.
var age = 40 // This is also a comment.
AddHexNumberToken()
Consumes and adds a hex number token starting at mCurrent
.
Assumes that mCurrent
points at the first hex digit (which has been verified to exist).
0xFF
^
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.
AddMatchingDelimiters(openingDelimiter As XUICELineToken, closingDelimiter As XUICELineToken)
Adds the passed matching delimiters the MatchedDelimiters
dictionary and
the SortedMatchedDelimiters
array.
We add both delimiters as keys so we can find either.
AddNumberToken()
Consumes and adds a number token starting at mCurrent
.
Assumes that mCurrent
points at a digit.
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 separate 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.
FirstNonCommentToken(line As XUICELine) As XUICELineToken
Returns the first token on line
that is not a comment or Nil if the line there are none.
Assumes line
is not Nil.
IndentLines()
Sets the indentation and continuation levels for each line.
Assumes ProcessDelimiters()
has been called prior to this method.
InitialiseKeywordsDictionary() As Dictionary
Returns a case-sensitive dictionary of ObjoScript's keywords / reserved words.
IsClosingDelimiter(t As XUICELineToken) As Boolean
True if t
is a closing delimiter like }
, )
or ]
.
Assumes t
is not Nil.
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.
IsLCurly(t As XUICELineToken) As Boolean
True if t
is a left curly bracket.
Assumes t
is not Nil.
IsOpeningDelimiter(t As XUICELineToken) As Boolean
True if t
is an opening delimiter like {
, (
or [
.
Assumes t
is not Nil.
LastNonCommentToken(line As XUICELine) As XUICELineToken
Returns the last token on line
that is not a comment or Nil if the line there are 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.
ProcessDelimiters()
Finds the locations of matching delimiters (e.g: braces, parentheses, etc) and
adds them to MatchedDelimiters
.
SetContinuationStatus(line As XUICELine, previousLineLastToken As XUICELineToken)
Sets line.IsContinuation
based on the last token of the previous line.
Assumes line
is not Nil.
previousLineLastToken
may be Nil.
SkipWhitespace()
Advances past whitespace.
SupportsDelimiterHighlighting() As Boolean
Returns True as this formatter supports highlighting the delimiters 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 all token types used by this formatter.
Part of the XUICEFormatter
interface.