|
Class: AbstractSyntaxHighlighter
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
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.
copyrightCOPYRIGHT (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.
api highlighting
-
formatClassDefinition: aString in: aClass
-
format (recolor) a class definition expression in a given class.
Return the text containing font changes and color information.
-
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
-
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
|
-
formatExpression: aString in: aClass elementsInto: elementsCollection
( an extension from the stx:libtool package )
-
-
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
-
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) **
-
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) **
-
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) **
-
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
|
-
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
|
-
formatMethod: aMethodOrNil source: aString in: aClass using: preferencesOrNil elementsInto: elements
( an extension from the stx:libtool package )
-
-
formatMethodSource: aString in: aClass
-
format (recolor) a method in a given class.
Return the text containing font changes and color information.
-
formatMethodSource: aString in: aClass using: preferencesOrNil
-
format (recolor) a method in a given class.
Return the text containing font changes and color information.
highlighting
-
colorize: text forErrorAtPosition: pos withOriginal: originalString
-
mhmh - which is better ...
misc
-
collectionEnumerationSelectors
-
these are considered wellknown, builtin selectors of very common
collection enumeration methods.
These are optionally shown with another color (dark green)
-
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)
-
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)
-
errorRaisingSelectors
-
these are error raisers.
These are optionally shown with another color (red)
-
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
-
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
-
mark: sourceText from: pos1 to: pos2 withAddedEmphasis: addedEmphasis
-
-
mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp color: clrIn
-
-
mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp color: clrIn font: fontIn
-
all positions are 1-based
-
mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr
-
-
mark: sourceText from: pos1 to: pos2 withEmphasis: fontEmp ifNil: fontEmp2 color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr
-
accessing
-
fetchHeavilyUsedPreferenceValues
-
-
method: aMethod
-
the original method, if known (for subclasses which can make use of it)
-
preferences: aUserPreferencesInstance
-
-
sourceText
-
retrieve the updated source text after the highlighting process
-
sourceText: aString
-
this text will be updated by the highlighting process
api highlighting
-
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
|
-
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
|
-
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
-
parseError: aMessage position: position to: endPos
-
Transcript showCR:aMessage.
-
showErrorMessage: aMessage position: pos
-
Transcript showCR:aMessage.
-
syntaxError: aMessage position: position to: endPos
-
Transcript showCR:aMessage.
-
warning: msg position: pos1 to: pos2
-
self markUnknownIdentifierFrom:pos1 to:pos2
initialization
-
initialize
-
must be called if redefined
misc
-
collectionEnumerationSelectors
-
-
controlFlowSelectors
-
-
debugSelectors
-
-
defineAsUndeclaredVariable: aName
-
redefined to NOT declare undefined vars
-
errorRaisingSelectors
-
-
isSyntaxHighlighter
-
-
plausibilityCheck: aNode
-
redefined to NOT do checks
syntax detection
-
markCommentFrom: pos1 to: pos2
-
all positions are 1-based
-
markConstantFrom: pos1 to: pos2
-
(comment from inherited method)
intentionally left empty
-
markErrorFrom: pos1 to: pos2
-
-
markFrom: pos1 length: len withEmphasis: fontEmp color: clrIn
-
-
markFrom: pos1 to: pos2 withAddedEmphasis: addedEmphasis
-
-
markFrom: pos1 to: pos2 withEmphasis: fontEmp color: clrIn
-
-
markFrom: pos1 to: pos2 withEmphasis: fontEmp color: clrIn font: fontInOrNil
-
all positions are 1-based
-
markFrom: pos1 to: pos2 withEmphasis: fontEmp color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr
-
-
markFrom: pos1 to: pos2 withEmphasis: fontEmp ifNil: fontEmp2 color: fgClr1 ifNil: fgClr2 backgroundColor: bgClr
-
-
markVariable: v
-
(comment from inherited method)
intentionally left empty
-
postProcessTree: tree forText: text
-
allows for additional checks to be done on the tree
(checking arguments to a call-node in expecco, for example)
|