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.35 date: 2021/12/03 10:26:30
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.

copyright

COPYRIGHT (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.

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  _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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 17:00:21 GMT