eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'AbstractSyntaxHighlighter':

Home

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

Class: AbstractSyntaxHighlighter


Inheritance:

   Object
   |
   +--Scanner
      |
      +--Parser
         |
         +--AbstractSyntaxHighlighter
            |
            +--CodeCoverageHighlighter
            |
            +--SyntaxHighlighter
            |
            +--Tools::NaiveSyntaxHighlighter

Package:
stx:libcomp
Category:
System-Compiler
Version:
rev: 1.50 date: 2021/11/26 13:56:21
user: cg
file: AbstractSyntaxHighlighter.st directory: libcomp
module: stx stc-classLibrary: libcomp

Description:


common superclass for (smalltalk-) syntax highlighting.

This will parse the source code and update the local copy of the
sourceText (in that instvar) by changing emphasis and color,
as syntax elements are encountered.
This is done by redefining appropriate markXXX methods, which are
called by the parser whenever an interesting syntactic construct is encountered.
These methods are no-ops in the Parser class, but redefined here to update
the colorization of sourceText.

Caveat:
    used to be a smalltalk syntax highlighter and therefore (wrongly) subclassed Parser.
    However, over time, much functionality was added, which is of use for other languages also
    and this class will therefore be changed to use composition and have parsing delegated.
    to be independent of the language and to not inherit stuff, which is not needed.

copyright

COPYRIGHT (c) 2006 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

api highlighting
o  formatClassDefinition: aString in: aClass
format (recolor) a class definition expression in a given class.
Return the text containing font changes and color information.

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
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  formatExpression: aString in: aClass elementsInto: elementsCollection
( an extension from the stx:libtool package )

o  formatFileContents: aString elementsInto: elementsCollection
( an extension from the stx:libtool package )
format (recolor) a file's contents.
Return the text containing font changes and color information.
Here, nothing is done ,just for protocol completeness

o  formatMethod: aString in: aClass
format (recolor) a method in a given class.
Return the text containing font changes and color information.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  formatMethod: aString in: aClass using: preferencesOrNil
format (recolor) a method in a given class.
Return the text containing font changes and color information.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  formatMethod: aString in: aClass using: preferencesOrNil elementsInto: elements
( an extension from the stx:libtool package )

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  formatMethod: methodOrNil source: aString in: aClass
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

o  formatMethod: methodOrNil source: aString in: aClass using: preferencesOrNil
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

o  formatMethod: aMethodOrNil source: aString in: aClass using: preferencesOrNil elementsInto: elements
( an extension from the stx:libtool package )

o  formatMethodSource: aString in: aClass
format (recolor) a method in a given class.
Return the text containing font changes and color information.

o  formatMethodSource: aString in: aClass using: preferencesOrNil
format (recolor) a method in a given class.
Return the text containing font changes and color information.

highlighting
o  colorize: text forErrorAtPosition: pos withOriginal: originalString
mhmh - which is better ...

misc
o  collectionEnumerationSelectors
these are considered wellknown, builtin selectors of very common
collection enumeration methods.
These are optionally shown with another color (dark green)

o  controlFlowSelectors
these are considered wellknown, builtin selectors of very common
control flow constructs. Correspond to syntax or special forms in other
languages. These are optionally shown with another color (blue)

o  debugSelectors
these are considered harmful if left in a deployed application:
selectors for debugging which open a debugger (unless haltSignal is
caught or disabled, which end-user apps should do).
These are optionally shown with another color (redish)

o  errorRaisingSelectors
these are error raisers.
These are optionally shown with another color (red)

o  isControlFlowSelector: aSelector
these are considered wellknown, builtin selectors of very common
control flow constructs. Correspond to syntax or special forms in other
languages. These are optionally shown with another color (blue)

queries
o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.

utilities
o  mark: sourceText from: pos1 to: pos2 withAddedEmphasis: addedEmphasis

o  mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp color: clrIn

o  mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp color: clrIn font: fontIn
all positions are 1-based

o  mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr

o  mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp ifNil: fontEmp2 color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr


Instance protocol:

accessing
o  fetchHeavilyUsedPreferenceValues

o  method: aMethod
the original method, if known (for subclasses which can make use of it)

o  preferences: aUserPreferencesInstance

o  sourceText
retrieve the updated source text after the highlighting process

o  sourceText: aString
this text will be updated by the highlighting process

api highlighting
o  formatExpression: aString in: aClass
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: methodOrNil source: aString in: aClass using: preferencesOrNil
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

o  formatMethodSource: aString in: aClass using: preferencesOrNil
format (recolor) a method in a given class.
Return the text containing font changes and color information.

error handling
o  parseError: aMessage position: position to: endPos
Transcript showCR:aMessage.

o  showErrorMessage: aMessage position: pos
Transcript showCR:aMessage.

o  syntaxError: aMessage position: position to: endPos
Transcript showCR:aMessage.

o  warning: msg position: pos1 to: pos2
self markUnknownIdentifierFrom:pos1 to:pos2

initialization
o  initialize
must be called if redefined

misc
o  collectionEnumerationSelectors

o  controlFlowSelectors

o  debugSelectors

o  defineAsUndeclaredVariable: aName
redefined to NOT declare undefined vars

o  errorRaisingSelectors

o  isSyntaxHighlighter

o  plausibilityCheck: aNode
redefined to NOT do checks

syntax detection
o  markCommentFrom: pos1 to: pos2
all positions are 1-based

o  markConstantFrom: pos1 to: pos2
(comment from inherited method)
intentionally left empty

o  markErrorFrom: pos1 to: pos2

o  markFrom: pos1 length: len withEmphasis: fontEmp color: clrIn

o  markFrom: pos1 to: pos2 withAddedEmphasis: addedEmphasis

o  markFrom: pos1 to: pos2 withEmphasis: fontEmp color: clrIn

o  markFrom: pos1 to: pos2 withEmphasis: fontEmp color: clrIn font: fontInOrNil
all positions are 1-based

o  markFrom: pos1 to: pos2 withEmphasis: fontEmp color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr

o  markFrom: pos1 to: pos2 withEmphasis: fontEmp ifNil: fontEmp2 color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr

o  markVariable: v
(comment from inherited method)
intentionally left empty

o  postProcessTree: tree forText: text
allows for additional checks to be done on the tree
(checking arguments to a call-node in expecco, for example)



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:30:57 GMT