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

Package:
stx:libcomp
Category:
System-Compiler
Version:
rev: 1.45 date: 2018/12/22 12:46:18
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.


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

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

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



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 25 Apr 2024 00:30:05 GMT