|
Class: SyntaxHighlighter2
Object
|
+--Scanner
|
+--Parser
|
+--AbstractSyntaxHighlighter
|
+--SyntaxHighlighter
|
+--SyntaxHighlighter2
- Package:
- stx:libtool
- Category:
- Interface-CodeView-Syntax
- Version:
- rev:
1.35
date: 2021/12/03 10:26:30
- 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.
copyrightCOPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
All Rights Reserved
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
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
-
_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
|