AbstractSyntaxHighlighter.st
author Stefan Vogel <sv@exept.de>
Mon, 26 Mar 2018 15:53:53 +0200
changeset 4222 9757ab066985
parent 4202 b74cb013e847
child 4229 35f7bbf9efa4
permissions -rw-r--r--
#REFACTORING by stefan class: BreakpointNode changed: #codeForCascadeOn:inBlock:for: #codeForSideEffectOn:inBlock:for: #codeOn:inBlock:for: create UnaryNodes for unary messages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     1
"
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     3
	      All Rights Reserved
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     4
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     5
 This software is furnished under a license and may be used
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     6
 only in accordance with the terms of that license and with the
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
     9
 other person.  No title to or ownership of the software is
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    10
 hereby transferred.
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    11
"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libcomp' }"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
3561
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
    14
"{ NameSpace: Smalltalk }"
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
    15
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Parser subclass:#AbstractSyntaxHighlighter
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
    17
	instanceVariableNames:'method sourceText preferences fullSelectorCheck commentColor
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
    18
		commentEmphasis commentFont constantColor constantEmphasis'
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'System-Compiler'
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    24
!AbstractSyntaxHighlighter class methodsFor:'documentation'!
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    25
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    26
copyright
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    27
"
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    28
 COPYRIGHT (c) 2006 by eXept Software AG
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    29
	      All Rights Reserved
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    30
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    31
 This software is furnished under a license and may be used
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    32
 only in accordance with the terms of that license and with the
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    34
 be provided or otherwise made available to, or used by, any
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    35
 other person.  No title to or ownership of the software is
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    36
 hereby transferred.
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    37
"
3345
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    38
!
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    39
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    40
documentation
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    41
"
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    42
    common superclass for (smalltalk-) syntax highlighting.
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    43
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    44
    This will parse the source code and update the local copy of the
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    45
    sourceText (in that instvar) by changing emphasis and color,
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    46
    as syntax elements are encountered.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    47
    This is done by redefining appropriate markXXX methods, which are
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    48
    called by the parser whenever an interesting syntactic construct is encountered.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    49
    These methods are no-ops in the Parser class, but redefined here to update
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    50
    the colorization of sourceText.
4200
e0b3fd0f438c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
    51
e0b3fd0f438c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
    52
    Caveat:
e0b3fd0f438c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
    53
        used to be a smalltalk syntax highlighter and therefore (wrongly) subclassed Parser.
e0b3fd0f438c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
    54
        However, over time, much functionality was added, which is of use for other languages also
e0b3fd0f438c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
    55
        and this class will therefore be changed to use composition and have parsing delegated.
e0b3fd0f438c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
    56
        to be independent of the language and to not inherit stuff, which is not needed.
3345
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    57
"
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    58
! !
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
!AbstractSyntaxHighlighter class methodsFor:'api highlighting'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
formatClassDefinition:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "format (recolor) a class definition expression in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    ^ self formatExpression:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    69
formatClassDefinition:aString in:aClass elementsInto: elements
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    70
    "format (recolor) a class definition expression in a given class.
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    71
     Return the text containing font changes and color information."
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    72
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    73
    ^ self formatExpression:aString in:aClass
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    74
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    75
    "Created: / 10-04-2011 / 18:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    76
!
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    77
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
formatExpression:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    "format (recolor) an expression in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    82
    |parser tree text|
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    aString isNil ifTrue:[^ nil].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    parser := self for:(ReadStream on:aString string) in:aClass.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    parser ignoreErrors:true.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    parser ignoreWarnings:true.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    parser sourceText:(text := aString string asText).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    "/ use an array here - this can be changed much faster using #at:put:
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    text emphasisCollection:(Array new:aString size).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    parser nextToken.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    tree := parser expression.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    "/ now, convert the emphasis-array to a runArray
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    text emphasisCollection:(text emphasis asRunArray).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    tree == #Error ifTrue:[
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
    99
        ^ self colorize:text forErrorAtPosition:parser sourceStream position withOriginal:aString.
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ text
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
     self
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   105
        formatExpression:'(1 + 2) max:5'
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   106
        in:UndefinedObject
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    "Modified: / 7.4.1998 / 09:57:19 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    "Created: / 9.4.1998 / 16:57:16 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
4198
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   113
formatFileContents:aString elementsInto:elementsCollection
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   114
    "format (recolor) a file's contents.
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   115
     Return the text containing font changes and color information.
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   116
     Here, nothing is done ,just for protocol completeness"
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   117
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   118
    ^ aString
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   119
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   120
    "Created: / 21-10-2017 / 13:28:35 / cg"
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   121
!
a1425e29fce7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4114
diff changeset
   122
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
formatMethod:aString in:aClass
3191
e538b29d3cfb Mark methods as obsolete
Stefan Vogel <sv@exept.de>
parents: 3189
diff changeset
   124
    <resource: #obsolete>
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    self obsoleteMethodWarning:'use #formatMethodSource:in:'.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    ^ self formatMethod:nil source:aString in:aClass using:nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
     self
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   133
	formatMethod:'foo
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
'
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   138
	in:UndefinedObject
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "Modified: / 28-04-2010 / 13:03:04 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
formatMethod:aString in:aClass using:preferencesOrNil
3191
e538b29d3cfb Mark methods as obsolete
Stefan Vogel <sv@exept.de>
parents: 3189
diff changeset
   145
    <resource: #obsolete>
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    self obsoleteMethodWarning:'use #formatMethodSource:in:using:'.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    ^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    "Modified: / 28-04-2010 / 13:03:15 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
formatMethod:methodOrNil source:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    ^ self formatMethod:methodOrNil source:aString in:aClass using:nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
     self
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   163
	formatMethod:'foo
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
'
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   168
	in:UndefinedObject
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    "Created: / 28-04-2010 / 13:44:24 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
formatMethod:methodOrNil source:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   178
    "/ cg: I smell a wumpus: I don't think, all of this must be copied to subclasses
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   179
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   180
    |highlighter tree newText|
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    aString isNil ifTrue:[^ nil].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    Error handle:[:ex |
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   185
        "/ Transcript showCR:ex description.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   186
        self breakPoint:#cg.
3201
13eb554c3f26 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3191
diff changeset
   187
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   188
        (ParseError handles:ex) ifFalse:[
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   189
            ex creator isHandled ifTrue:[
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   190
                "/ Transcript showCR:'handled' .
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   191
                ex reject.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   192
            ].
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   193
            "Parse error may happen when re-formatting incomplete code while editing"
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   194
            ('SyntaxHighlighter [info]: error during highlight: ' , ex description) infoPrintCR.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   195
            "/ ex suspendedContext fullPrintAll.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   196
        ].
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   197
        highlighter notNil ifTrue:[
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   198
            ^ self colorize:(newText ? aString) forErrorAtPosition:highlighter sourceStream position withOriginal:aString
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   199
        ].
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   200
        ^ aString
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    ] do:[
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   202
        |sourceString|
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   204
        sourceString := aString string.
3675
6a75a2fe7a83 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3599
diff changeset
   205
        newText := sourceString "asUnicode16String" asText.
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   206
        "/ use an array here (instead of the RunArray) - this can be changed much faster using #at:put:
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   207
        newText emphasisCollection:(Array new:sourceString size).
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   208
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   209
        highlighter := self for:(ReadStream on:aString string) in:aClass.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   210
        highlighter method:methodOrNil.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   211
        preferencesOrNil notNil ifTrue:[highlighter preferences:preferencesOrNil].
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   212
        "/ highlighter ignoreErrors:true.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   213
        highlighter ignoreWarnings:true.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   214
        highlighter sourceText:newText.
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   216
        tree := highlighter parseMethod.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   217
        newText := highlighter sourceText.  "/ might have changed identity
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   218
        "/ now, convert the emphasis-array to a runArray
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   219
        newText emphasisCollection:(newText emphasis asRunArray).
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   221
        tree == #Error ifTrue:[
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   222
            ^ self colorize:newText forErrorAtPosition:highlighter sourceStream position withOriginal:aString.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   223
        ].
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   224
        ^ newText
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    ]
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   226
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
     self
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   229
        formatMethod:'foo
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
'
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   234
        in:UndefinedObject
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "Created: / 28-04-2010 / 13:01:42 / cg"
2527
a87cf2c8edf2 changed: #formatMethod:source:in:using:
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   238
    "Modified: / 05-07-2011 / 11:22:20 / cg"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
2526
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   241
formatMethod:aMethodOrNil source:aString in:aClass using:preferencesOrNil elementsInto: elements
2568
44f3c6ce19f1 fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2527
diff changeset
   242
44f3c6ce19f1 fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2527
diff changeset
   243
    ^ self formatMethod:aMethodOrNil source:aString in:aClass using:preferencesOrNil
2526
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   244
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   245
    "Created: / 05-07-2011 / 10:41:14 / cg"
2568
44f3c6ce19f1 fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2527
diff changeset
   246
    "Modified: / 20-07-2011 / 16:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2526
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   247
!
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   248
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
formatMethodSource:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    ^ self formatMethod:nil source:aString in:aClass using:nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
     self
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   257
	formatMethod:'foo
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
'
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   262
	in:UndefinedObject
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "Created: / 28-04-2010 / 12:58:13 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
formatMethodSource:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    ^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    "Modified: / 28-04-2010 / 13:02:11 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   277
!AbstractSyntaxHighlighter class methodsFor:'highlighting'!
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   278
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   279
colorize:text forErrorAtPosition:pos withOriginal:originalString
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   280
    |eColor endPos|
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   281
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   282
    endPos := pos + 1.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   283
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   284
    "/ mhmh - which is better ...
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   285
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   286
    "/ alternative1: colorize the rest after the error in red
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   287
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   288
    eColor := UserPreferences current errorColor.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   289
    eColor notNil ifTrue:[
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   290
        ^ text
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   291
            emphasizeFrom:endPos 
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   292
            to:text size 
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   293
            with:(#color->eColor).
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   294
    ].
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   295
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   296
    "/ alternative2: take the original emphasis for the rest
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   297
    endPos >= text size ifTrue:[
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   298
        ^ text
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   299
    ] ifFalse:[
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   300
        ^ (text copyTo:endPos) , (originalString copyFrom:(endPos+1))
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   301
    ].
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   302
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   303
    "/ alternative3: no emphasis for rest.
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   304
    ^ text
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   305
! !
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   306
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   307
!AbstractSyntaxHighlighter class methodsFor:'misc'!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   308
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   309
collectionEnumerationSelectors
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   310
    "these are considered wellknown, builtin selectors of very common
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   311
     collection enumeration methods.
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   312
     These are optionally shown with another color (dark green)"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   313
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   314
    ^ #(
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   315
	collect:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   316
	select:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   317
	inject:into:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   318
	count:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   319
	collect:thenSelect:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   320
	select:thenCollect:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   321
    )
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   322
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   323
    "Created: / 14-02-2012 / 15:56:59 / cg"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   324
!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   325
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   326
controlFlowSelectors
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   327
    "these are considered wellknown, builtin selectors of very common
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   328
     control flow constructs. Correspond to syntax or special forms in other
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   329
     languages. These are optionally shown with another color (blue)"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   330
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   331
    ^ #(
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   332
        ifTrue: ifFalse:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   333
        ifTrue:ifFalse: ifFalse:ifTrue:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   334
        ifNil: ifNotNil:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   335
        ifNil:ifNotNil: ifNotNil:ifNil:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   336
        and: or:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   337
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   338
        whileTrue:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   339
        whileFalse:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   340
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   341
        to:do:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   342
        downTo:do:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   343
        to:by:do:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   344
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   345
        loop
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   346
        repeat
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   347
        whileTrue
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   348
        whileFalse
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   349
        doWhile:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   350
        doUntil:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   351
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   352
        do:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   353
        doWithIndex:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   354
        pairWiseDo:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   355
        keysAndValuesDo:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   356
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   357
        withPriority:do:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   358
        handle:do:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   359
        on:do:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   360
        catch:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   361
        ignoreIn:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   362
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   363
        "/ newProcess
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   364
        fork:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   365
        ensure:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   366
        ifCurtailed:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   367
        valueOnUnwindDo:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   368
        valueNowOrOnUnwindDo:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   369
3977
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   370
        caseOf:
39fe23d7db13 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
   371
        caseOf:otherwise:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   372
    )
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   373
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   374
    "Created: / 08-09-2006 / 15:56:47 / cg"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   375
!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   376
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   377
debugSelectors
3235
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   378
    "these are considered harmful if left in a deployed application:
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   379
     selectors for debugging which open a debugger (unless haltSignal is
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   380
     caught or disabled, which end-user apps should do).
3235
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   381
     These are optionally shown with another color (redish)"
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   382
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   383
    ^ #(
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   384
	halt halt:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   385
    )
3235
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   386
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   387
    "Modified (comment): / 27-07-2013 / 11:45:07 / cg"
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   388
!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   389
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   390
errorRaisingSelectors
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   391
    "these are error raisers.
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   392
     These are optionally shown with another color (red)"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   393
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   394
    ^ #(
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   395
	error error:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   396
	raise raiseRequest:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   397
	raiseErrorString: raiseRequestErrorString:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   398
	raiseWith: raiseRequestWith:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   399
	raiseWith:errorString: raiseRequestWith:errorString:
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   400
	subclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   401
	obsoleteMethodWarning obsoleteMethodWarning:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   402
    )
3342
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   403
!
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   404
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   405
isControlFlowSelector:aSelector
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   406
    "these are considered wellknown, builtin selectors of very common
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   407
     control flow constructs. Correspond to syntax or special forms in other
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   408
     languages. These are optionally shown with another color (blue)"
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   409
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   410
    (self controlFlowSelectors includesIdentical:aSelector) ifTrue:[^ true].
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   411
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   412
    true "((aSelector startsWith:'with') or:[ aSelector startsWith:'all'])" ifTrue:[
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   413
	((aSelector endsWith:'do:') or:[ aSelector endsWith:'Do:']) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   414
	    ^ true
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   415
	]
3342
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   416
    ].
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   417
    ^ false.
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   418
! !
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   419
3732
afcdb234bf38 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   420
!AbstractSyntaxHighlighter class methodsFor:'queries'!
afcdb234bf38 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   421
afcdb234bf38 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   422
isAbstract
afcdb234bf38 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   423
    ^ self == AbstractSyntaxHighlighter
afcdb234bf38 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   424
! !
afcdb234bf38 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   425
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   426
!AbstractSyntaxHighlighter class methodsFor:'utilities'!
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   427
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   428
mark:sourceText from:pos1 to:pos2 withAddedEmphasis:addedEmphasis
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   429
    sourceText emphasisFrom:pos1 to:pos2 add:addedEmphasis
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   430
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   431
    "Created: / 01-06-2012 / 21:43:36 / cg"
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   432
!
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   433
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   434
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   435
    self mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:nil
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   436
!
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   437
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   438
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontIn
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   439
    "all positions are 1-based"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   440
    
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   441
    |e p2 clr|
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   442
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   443
    (clrIn isNil or:[clrIn = Color black]) ifTrue:[
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   444
        e := fontEmp
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   445
    ] ifFalse:[
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   446
        clr := clrIn onDevice:Screen current.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   447
        fontEmp isNil ifTrue:[
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   448
            e := (#color->clr)
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   449
        ] ifFalse:[
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   450
            e := Text addEmphasis:fontEmp to:(#color->clr).
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   451
        ]
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   452
    ].
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   453
    fontIn notNil ifTrue:[
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   454
        e := Text addEmphasis:e to:(#font->fontIn)
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   455
    ].
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   456
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   457
    (p2 := pos2) isNil ifTrue:[
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   458
        p2 := sourceText size
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   459
    ] ifFalse:[
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   460
        p2 := p2 min:sourceText size
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   461
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   462
    sourceText emphasizeFrom:pos1 to:p2 with:e
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   463
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   464
    "Created: / 01-06-2012 / 21:42:41 / cg"
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   465
    "Modified (comment): / 21-10-2017 / 14:24:20 / cg"
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   466
!
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   467
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   468
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   469
    |e p2 clr fgClr|
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   470
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   471
    fgClr := fgClr1 ? fgClr2.
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   472
    (fgClr isNil or:[fgClr = Color black]) ifTrue:[
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   473
	e := fontEmp
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   474
    ] ifFalse:[
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   475
	clr := fgClr onDevice:Screen current.
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   476
	fontEmp isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   477
	    e := (#color->clr)
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   478
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   479
	    e := Text addEmphasis:fontEmp to:(#color->clr).
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   480
	]
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   481
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   482
    bgClr notNil ifTrue:[
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   483
	e := Text addEmphasis:(#backgroundColor->bgClr) to:e.
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   484
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   485
    (p2 := pos2) isNil ifTrue:[
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   486
	p2 := sourceText size
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   487
    ] ifFalse:[
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   488
	p2 := p2 min:sourceText size
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   489
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   490
    sourceText emphasizeFrom:pos1 to:p2 with:e
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   491
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   492
    "Created: / 01-06-2012 / 21:44:17 / cg"
3561
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   493
!
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   494
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   495
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   496
    |e p2 clr fgClr|
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   497
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   498
    fgClr := fgClr1 ? fgClr2.
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   499
    (fgClr isNil or:[fgClr = Color black]) ifTrue:[
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   500
        e := fontEmp ? fontEmp2
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   501
    ] ifFalse:[
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   502
        clr := fgClr onDevice:Screen current.
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   503
        (fontEmp ? fontEmp2) isNil ifTrue:[
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   504
            e := (#color->clr)
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   505
        ] ifFalse:[
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   506
            e := Text addEmphasis:(fontEmp ? fontEmp2) to:(#color->clr).
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   507
        ]
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   508
    ].
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   509
    bgClr notNil ifTrue:[
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   510
        e := Text addEmphasis:(#backgroundColor->bgClr) to:e.
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   511
    ].
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   512
    (p2 := pos2) isNil ifTrue:[
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   513
        p2 := sourceText size
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   514
    ] ifFalse:[
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   515
        p2 := p2 min:sourceText size
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   516
    ].
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   517
    sourceText emphasizeFrom:pos1 to:p2 with:e
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   518
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   519
    "Created: / 01-06-2012 / 21:44:17 / cg"
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   520
! !
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   521
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
!AbstractSyntaxHighlighter methodsFor:'accessing'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   524
fetchHeavilyUsedPreferenceValues
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   525
    preferences isNil ifTrue:[
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   526
        commentColor :=  commentEmphasis := commentFont := nil.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   527
        constantColor := constantEmphasis := nil.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   528
        ^ self.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   529
    ].
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   530
    
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   531
    commentColor := preferences commentColor.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   532
    commentEmphasis := preferences commentEmphasis.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   533
    commentFont := preferences commentFont.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   534
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   535
    constantColor := preferences constantColor.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   536
    constantEmphasis := preferences constantEmphasis.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   537
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   538
    "Created: / 21-10-2017 / 14:13:33 / cg"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   539
!
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   540
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
method:aMethod
2525
f08c56018d9b lifted the method instvar
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
   542
    "the original method, if known (for subclasses which can make use of it)"
f08c56018d9b lifted the method instvar
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
   543
f08c56018d9b lifted the method instvar
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
   544
    method := aMethod.
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
    "Created: / 28-04-2010 / 13:15:33 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   549
preferences:aUserPreferencesInstance
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   550
    preferences := aUserPreferencesInstance.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   551
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   552
    fullSelectorCheck := preferences fullSelectorCheck.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   553
    self fetchHeavilyUsedPreferenceValues.
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   554
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   555
    "Modified: / 21-10-2017 / 14:20:06 / cg"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
sourceText
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   559
    "retrieve the updated source text after the highlighting process"
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   560
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
    ^ sourceText
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
    "Created: / 31.3.1998 / 11:49:05 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
sourceText:aString
3599
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   567
    "this text will be updated by the highlighting process"
a999663bd83f some code cleanup
Claus Gittinger <cg@exept.de>
parents: 3561
diff changeset
   568
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
    sourceText := aString.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
    "Created: / 31-03-1998 / 11:49:05 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
    "Modified: / 28-04-2010 / 13:22:27 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
!AbstractSyntaxHighlighter methodsFor:'error handling'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
parseError:aMessage position:position to:endPos
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
"/ Transcript showCR:aMessage.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
    super parseError:aMessage position:position to:endPos.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   581
    self
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   582
	markFrom:position to:endPos
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   583
	withEmphasis:nil color:UserPreferences current errorColor
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
showErrorMessage:aMessage position:pos
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
"/ Transcript showCR:aMessage.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
    super showErrorMessage:aMessage position:pos.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   590
    self
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   591
	markFrom:pos to:nil
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   592
	withEmphasis:nil color:UserPreferences current errorColor
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
syntaxError:aMessage position:position to:endPos
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
"/ Transcript showCR:aMessage.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
    super syntaxError:aMessage position:position to:endPos.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   599
    self
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   600
	markFrom:position to:endPos
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   601
	withEmphasis:nil color:UserPreferences current errorColor
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
warning:msg position:pos1 to:pos2
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
"/    self markUnknownIdentifierFrom:pos1 to:pos2
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
"/    self
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   608
"/        markFrom:pos1 to:pos2
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
"/        withEmphasis:nil color:UserPreferences current errorColor
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
    "Modified: / 25.9.1999 / 18:42:30 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
!AbstractSyntaxHighlighter methodsFor:'initialization'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
initialize
4114
a68e6f98cb02 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3977
diff changeset
   617
    <modifier: #super> "must be called if redefined"
a68e6f98cb02 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3977
diff changeset
   618
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    super initialize.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
    foldConstants := false.
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   622
    self preferences:(UserPreferences current).
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    "Created: / 31-03-1998 / 15:12:55 / cg"
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   625
    "Modified: / 21-10-2017 / 14:20:11 / cg"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
!AbstractSyntaxHighlighter methodsFor:'misc'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
2817
b92ea70a5a9f added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
   630
collectionEnumerationSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   631
    ^ self class collectionEnumerationSelectors
2817
b92ea70a5a9f added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
   632
!
b92ea70a5a9f added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
   633
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
controlFlowSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   635
    ^ self class controlFlowSelectors
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   638
debugSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   639
    ^ self class debugSelectors
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   640
!
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   641
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
defineAsUndeclaredVariable:aName
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    "redefined to NOT declare undefined vars"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
    ^ VariableNode globalNamed:aName
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    "Modified: / 19.10.1998 / 19:38:12 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   650
errorRaisingSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   651
    ^ self class errorRaisingSelectors
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   652
!
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   653
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
isSyntaxHighlighter
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    ^ true
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
plausibilityCheck:aNode
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
    "redefined to NOT do checks"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
    ^ nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
    "Modified: / 19.10.1998 / 19:38:12 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
    "Created: / 19.10.1998 / 19:57:18 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
!AbstractSyntaxHighlighter methodsFor:'syntax detection'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   670
markCommentFrom:pos1 to:pos2
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   671
    "all positions are 1-based"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   672
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   673
    self 
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   674
        markFrom:pos1 to:pos2 
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   675
        withEmphasis:commentEmphasis 
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   676
        color:commentColor
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   677
        font:commentFont
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   678
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   679
    "
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   680
     UserPreferences current commentEmphasis
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   681
     UserPreferences current commentColor
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   682
    "
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   683
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   684
    "Modified (comment): / 21-10-2017 / 14:24:51 / cg"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   685
!
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   686
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   687
markConstantFrom:pos1 to:pos2
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   688
    self 
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   689
        markFrom:pos1 to:pos2 
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   690
        withEmphasis:constantEmphasis 
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   691
        color:constantColor
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   692
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   693
    "Created: / 31-03-1998 / 18:09:22 / cg"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   694
    "Modified: / 21-10-2017 / 14:15:48 / cg"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   695
!
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   696
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   697
markFrom:pos1 length:len withEmphasis:fontEmp color:clrIn
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   698
    self markFrom:pos1 to:pos1+len-1 withEmphasis:fontEmp color:clrIn
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   699
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   700
    "Created: / 21-10-2017 / 14:47:46 / cg"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   701
!
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   702
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
markFrom:pos1 to:pos2 withAddedEmphasis:addedEmphasis
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   704
    self class
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   705
	mark:sourceText from:pos1 to:pos2 withAddedEmphasis:addedEmphasis
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
    "Created: / 15-01-2008 / 11:48:18 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:clrIn
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   711
    self class
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   712
	mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
    "Created: / 31-03-1998 / 13:26:53 / cg"
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   715
    "Modified: / 01-06-2012 / 21:43:04 / cg"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   718
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontInOrNil
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   719
    "all positions are 1-based"
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   720
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   721
    self class
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   722
        mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontInOrNil
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   723
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   724
    "Created: / 31-03-1998 / 13:26:53 / cg"
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   725
    "Modified: / 01-06-2012 / 21:43:04 / cg"
4202
b74cb013e847 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4200
diff changeset
   726
    "Modified (comment): / 21-10-2017 / 14:24:47 / cg"
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   727
!
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   728
2813
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   729
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   730
    self class
3469
Claus Gittinger <cg@exept.de>
parents: 3352
diff changeset
   731
	mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
2813
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   732
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   733
    "Created: / 13-02-2012 / 11:48:09 / cg"
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   734
!
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   735
3561
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   736
markFrom:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   737
    self class
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   738
        mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   739
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   740
    "Created: / 13-02-2012 / 11:48:09 / cg"
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   741
!
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   742
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
markVariable:v
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
    |pos endPos|
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
    pos := tokenPosition.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
    endPos := pos+tokenName size-1.
3189
5a4bb1727d08 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   748
    self markVariable:v from:pos to:endPos assigned:false
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
2464
595ec0d9efa9 comment/format in: #markVariable:
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   750
    "Modified: / 30-11-2010 / 14:44:28 / cg"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
!AbstractSyntaxHighlighter class methodsFor:'documentation'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
2663
e94fe6b650ad changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents: 2662
diff changeset
   755
version
3675
6a75a2fe7a83 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3599
diff changeset
   756
    ^ '$Header$'
2663
e94fe6b650ad changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents: 2662
diff changeset
   757
!
e94fe6b650ad changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents: 2662
diff changeset
   758
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
version_CVS
3675
6a75a2fe7a83 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3599
diff changeset
   760
    ^ '$Header$'
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
   761
!
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
   762
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
   763
version_SVN
3189
5a4bb1727d08 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   764
    ^ '$ Id $'
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
! !
3561
f04a8db1590f class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3469
diff changeset
   766