|
Class: SyntaxHighlighter2
Object
|
+--Scanner
|
+--Parser
|
+--AbstractSyntaxHighlighter
|
+--SyntaxHighlighter
|
+--SyntaxHighlighter2
- Package:
- stx:libtool
- Category:
- Interface-CodeView-Syntax
- Version:
- rev:
1.32
date: 2018/08/04 17:02:16
- user: cg
- file: SyntaxHighlighter2.st directory: libtool
- module: stx stc-classLibrary: libtool
A slightly improved syntax highlighter.
In addition to the inherited colorization, this one also remembers
so called 'syntax elements' (variable tokens and selectors) and remembers
them in a list.
This can be later used by the codeView to highlight uses of a clicked-on
variable or a clicked-on selector.
Also this list could (but is not, at the moment) be used to forward/backward
search for the next use of some variable.
[caveat:]
This code has a smell: there is a lot of code duplication,
and most can be moved to the superclass. Actually, there is propably no
reason to have both classes around, so why not integrate all into the superclass.
api highlighting
-
formatClassDefinition: aString in: aClass elementsInto: elements
-
format (recolor) a class definition expression in a given class.
Return the text containing font changes and color information.
-
formatExpression: aString in: aClass elementsInto: elements
-
format (recolor) an expression in a given class.
Return the text containing font changes and color information.
usage example(s):
self
formatExpression:'(1 + 2) max:5'
in:UndefinedObject
|
-
formatMethod: aMethodOrNil source: aString in: aClass using: preferencesOrNil elementsInto: elements
-
format (recolor) a method in a given class.
Return the text containing font changes and color information.
usage example(s):
self formatMethod:'foo
^ self bar:''hello''.
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
'
in:UndefinedObject
|
highlighting
-
format: aString parsingWith: aBlock in: aClass elementsInto: elements
-
common code for formatStatementList, formatExpression, ...
format (recolor) whatever is parsed in aBlock (within the context of a given class).
Return the text containing font changes and color information.
As a side effect, put syntax elements into the passed in elements container
(for element-highlighting in codeView2)
-
formatStatementList: aString in: aClass elementsInto: elements
-
format (recolor) a statement list in a given class.
Return the text containing font changes and color information.
usage example(s):
self
formatStatementList:'(1 + 2) max:5. 1 + 2'
in:UndefinedObject
elementsInto:(OrderedCollection new).
|
accessing
-
elements
-
-
elements: aParseTreeIndexCollection
-
the element collection, to collect variables, selectors etc. into
-
tree: aParseNode
-
(comment from inherited method)
private: set the tree - for internal use only
initialization
-
initialize
-
must be called if redefined
parsing-expressions
-
_binaryExpressionFor: receiverArg
-
parse a binary-expression; return a node-tree, nil or #Error
-
_keywordExpressionFor: receiverArg
-
parse a keyword-expression; return a node-tree, nil or #Error.
keywordExpression ::= binaryexpression
| { KEYWORD-PART binaryExpression }
-
_unaryExpressionFor: receiverArg
-
parse a unary-expression; return a node-tree, nil or #Error
-
binaryExpression
-
(comment from inherited method)
parse a binary-expression; return a node-tree, nil or #Error
-
binaryExpressionFor: receiverArg
-
parse a binary-expression; return a node-tree, nil or #Error
-
expression
-
(comment from inherited method)
parse a cascade-expression; return a node-tree, nil or #Error.
expression ::= keywordExpression
| keywordExpression cascade
cascade ::= ';' expressionSendPart
| cascade ';' expressionSendPart
expressionSendPart ::= { KEYWORD binaryExpression }
| BINARYOPERATOR unaryExpression
| IDENTIFIER
-
keywordExpressionFor: receiverArg
-
parse a keyword-expression; return a node-tree, nil or #Error.
keywordExpression ::= binaryexpression
| { KEYWORD-PART binaryExpression }
-
unaryExpressionFor: receiverArg
-
parse a unary-expression; return a node-tree, nil or #Error
syntax detection
-
markBlockArgumentIdentifierFrom: pos1 to: pos2
-
in addition to marking, remember the variable reference
-
markLocalVariableDeclaration: name from: pos1 to: pos2
-
in addition to marking, remember the variable reference
-
markMethodArgumentIdentifierFrom: pos1 to: pos2
-
in addition to marking, remember the variable reference
-
markSelector: selectorString from: pos1 to: pos2 receiverNode: aReceiverNode
-
Special hack for Java class references - I would like to have them
marked specially (and not as an error when the class is not yet loaded -
the code is correct as JavaClassAccessor loads it lazily
-
markSelfFrom: pos1 to: pos2
-
in addition to marking, remember the variable reference
-
markSuperFrom: pos1 to: pos2
-
in addition to marking, remember the variable reference
-
markUnknownIdentifierFrom: pos1 to: pos2
-
-
markVariable: v from: pos1 to: pos2 assigned: assigned
-
(comment from inherited method)
support for syntaxColoring
-
rememberVariableElementFor: node from: pos1 to: pos2 assigned: assigned
-
node block
|