eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SyntaxHighlighter2':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SyntaxHighlighter2


Inheritance:

   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

Description:


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.


Class protocol:

api highlighting
o  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.

o  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

o  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
o  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)

o  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).


Instance protocol:

accessing
o  elements

o  elements: aParseTreeIndexCollection
the element collection, to collect variables, selectors etc. into

o  tree: aParseNode
(comment from inherited method)
private: set the tree - for internal use only

initialization
o  initialize
must be called if redefined

parsing-expressions
o  _binaryExpressionFor: receiverArg
parse a binary-expression; return a node-tree, nil or #Error

o  _keywordExpressionFor: receiverArg
parse a keyword-expression; return a node-tree, nil or #Error.

keywordExpression ::= binaryexpression
| { KEYWORD-PART binaryExpression }

o  _unaryExpressionFor: receiverArg
parse a unary-expression; return a node-tree, nil or #Error

o  binaryExpression
(comment from inherited method)
parse a binary-expression; return a node-tree, nil or #Error

o  binaryExpressionFor: receiverArg
parse a binary-expression; return a node-tree, nil or #Error

o  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

o  keywordExpressionFor: receiverArg
parse a keyword-expression; return a node-tree, nil or #Error.

keywordExpression ::= binaryexpression
| { KEYWORD-PART binaryExpression }

o  unaryExpressionFor: receiverArg
parse a unary-expression; return a node-tree, nil or #Error

syntax detection
o  markBlockArgumentIdentifierFrom: pos1 to: pos2
in addition to marking, remember the variable reference

o  markLocalVariableDeclaration: name from: pos1 to: pos2
in addition to marking, remember the variable reference

o  markMethodArgumentIdentifierFrom: pos1 to: pos2
in addition to marking, remember the variable reference

o  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

o  markSelfFrom: pos1 to: pos2
in addition to marking, remember the variable reference

o  markSuperFrom: pos1 to: pos2
in addition to marking, remember the variable reference

o  markUnknownIdentifierFrom: pos1 to: pos2

o  markVariable: v from: pos1 to: pos2 assigned: assigned
(comment from inherited method)
support for syntaxColoring

o  rememberVariableElementFor: node from: pos1 to: pos2 assigned: assigned
node block



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 17 May 2022 21:30:33 GMT