AbstractSyntaxHighlighter.st
author Claus Gittinger <cg@exept.de>
Sun, 02 Feb 2014 00:13:31 +0100
changeset 3352 42a5ad1adb52
parent 3345 718b64ff3db3
child 3469 a12113e5281d
permissions -rw-r--r--
class: AbstractSyntaxHighlighter added: #mark:from:to:withEmphasis:color:font: #markFrom:to:withEmphasis:color:font: changed: #mark:from:to:withEmphasis:color:
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
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Parser subclass:#AbstractSyntaxHighlighter
2525
f08c56018d9b lifted the method instvar
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
    15
	instanceVariableNames:'method sourceText preferences fullSelectorCheck'
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'System-Compiler'
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    21
!AbstractSyntaxHighlighter class methodsFor:'documentation'!
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    22
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    23
copyright
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    24
"
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    25
 COPYRIGHT (c) 2006 by eXept Software AG
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    26
	      All Rights Reserved
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
 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
    29
 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
    30
 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
    31
 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
    32
 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
    33
 hereby transferred.
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    34
"
3345
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    35
!
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    36
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    37
documentation
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
    common superclass for (smalltalk-) syntax highlighting.
718b64ff3db3 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
    40
"
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    41
! !
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
!AbstractSyntaxHighlighter class methodsFor:'api highlighting'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
formatClassDefinition:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    "format (recolor) a class definition expression in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    ^ self formatExpression:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    52
formatClassDefinition:aString in:aClass elementsInto: elements
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    53
    "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
    54
     Return the text containing font changes and color information."
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    55
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    56
    ^ self formatExpression:aString in:aClass
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    57
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    58
    "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
    59
!
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
    60
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
formatExpression:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    "format (recolor) an expression in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    |parser tree text endPos|
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    aString isNil ifTrue:[^ nil].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    parser := self for:(ReadStream on:aString string) in:aClass.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    parser ignoreErrors:true.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    parser ignoreWarnings:true.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    parser sourceText:(text := aString string asText).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    "/ use an array here - this can be changed much faster using #at:put:
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    text emphasisCollection:(Array new:aString size).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    parser nextToken.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    tree := parser expression.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    "/ now, convert the emphasis-array to a runArray
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    text emphasisCollection:(text emphasis asRunArray).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    tree == #Error ifTrue:[
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
        "/ mhmh - which is better ...
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        "/ alternative1: color rest after error in red
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
"/        text 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
"/            emphasizeFrom:(parser sourceStream position) 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
"/            to:text size 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
"/            with:(#color->Color red).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        "/ alternative2: take original emphasis for rest
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
3264
1d5dd6bf1257 class: AbstractSyntaxHighlighter
Stefan Vogel <sv@exept.de>
parents: 3235
diff changeset
    92
        endPos := parser sourceStream position + 1.
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
        endPos >= text size ifTrue:[
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
            ^ text
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        ].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
        ^ (text copyTo:endPos) , (aString copyFrom:(endPos+1))
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
        "/ alternative3: no emphasis for rest.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
"/        ^ text "/ aString
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    ^ text
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
     self
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
        formatExpression:'(1 + 2) max:5' 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
        in:UndefinedObject
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    "Modified: / 7.4.1998 / 09:57:19 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    "Created: / 9.4.1998 / 16:57:16 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
formatMethod:aString in:aClass
3191
e538b29d3cfb Mark methods as obsolete
Stefan Vogel <sv@exept.de>
parents: 3189
diff changeset
   115
    <resource: #obsolete>
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    self obsoleteMethodWarning:'use #formatMethodSource:in:'.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    ^ self formatMethod:nil source:aString in:aClass using:nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
     self
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        formatMethod:'foo 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
'
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        in:UndefinedObject
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
    "Modified: / 28-04-2010 / 13:03:04 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
formatMethod:aString in:aClass using:preferencesOrNil
3191
e538b29d3cfb Mark methods as obsolete
Stefan Vogel <sv@exept.de>
parents: 3189
diff changeset
   136
    <resource: #obsolete>
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    self obsoleteMethodWarning:'use #formatMethodSource:in:using:'.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    ^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    "Modified: / 28-04-2010 / 13:03:15 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
formatMethod:methodOrNil source:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    ^ self formatMethod:methodOrNil source:aString in:aClass using:nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
     self
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
        formatMethod:'foo 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
'
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
        in:UndefinedObject
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
    "Created: / 28-04-2010 / 13:44:24 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
formatMethod:methodOrNil source:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    |highlighter tree text endPos eColor|
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    aString isNil ifTrue:[^ nil].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    Error handle:[:ex |
3201
13eb554c3f26 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3191
diff changeset
   174
        Transcript showCR:ex description.
13eb554c3f26 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3191
diff changeset
   175
        self breakPoint:#cg.
13eb554c3f26 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3191
diff changeset
   176
3145
f3b8c89756fb class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3072
diff changeset
   177
        ex creator isHandled ifTrue:[
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
            ex reject.    
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
        ].
3072
51ffc65ee7b5 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 2873
diff changeset
   180
        (ParseError handles:ex) ifFalse:[
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
            "Parse error may happen when re-formatting incomplete code while editing"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
            ('SyntaxHighlighter [info]: error during highlight: ' , ex description) infoPrintCR.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
            "/ ex suspendedContext fullPrintAll.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
        ].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
        ^ aString
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    ] do:[
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
        highlighter := self for:(ReadStream on:aString string) in:aClass.    
2527
a87cf2c8edf2 changed: #formatMethod:source:in:using:
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   188
        highlighter method:methodOrNil.
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
        preferencesOrNil notNil ifTrue:[highlighter preferences:preferencesOrNil].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        "/ highlighter ignoreErrors:true.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
        highlighter ignoreWarnings:true.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
        highlighter sourceText:(text := aString string asText).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
        "/ use an array here - this can be changed much faster using #at:put:
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
        text emphasisCollection:(Array new:aString size).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
        tree := highlighter parseMethod.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
        "/ now, convert the emphasis-array to a runArray
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
        text emphasisCollection:(text emphasis asRunArray).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
        tree == #Error ifTrue:[
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
            eColor := UserPreferences current errorColor.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
            eColor notNil ifTrue:[
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
                "/ mhmh - which is better ...
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
                "/ alternative1: color rest after error in red
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
                text 
3264
1d5dd6bf1257 class: AbstractSyntaxHighlighter
Stefan Vogel <sv@exept.de>
parents: 3235
diff changeset
   207
                    emphasizeFrom:(highlighter sourceStream position + 1) 
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
                    to:text size 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
                    with:(#color->eColor).
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
            ] ifFalse:[
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
                "/ alternative2: take original emphasis for rest
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
3264
1d5dd6bf1257 class: AbstractSyntaxHighlighter
Stefan Vogel <sv@exept.de>
parents: 3235
diff changeset
   213
                endPos := highlighter sourceStream position + 1.
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
                endPos >= text size ifTrue:[
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
                    ^ text
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
                ].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
                ^ (text copyTo:endPos) , (aString copyFrom:(endPos+1))
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
            ].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
            "/ alternative3: no emphasis for rest.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
        ].
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
        ^ text
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    ]
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
     self
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
        formatMethod:'foo 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
'
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
        in:UndefinedObject
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    "Created: / 28-04-2010 / 13:01:42 / cg"
2527
a87cf2c8edf2 changed: #formatMethod:source:in:using:
Claus Gittinger <cg@exept.de>
parents: 2526
diff changeset
   234
    "Modified: / 05-07-2011 / 11:22:20 / cg"
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
2526
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   237
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
   238
44f3c6ce19f1 fixed #formatMethod:source:in:using:elementsInto:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2527
diff changeset
   239
    ^ 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
   240
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   241
    "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
   242
    "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
   243
!
ecd1ee8f03bc category of: #formatMethod:source:in:using:elementsInto:
Claus Gittinger <cg@exept.de>
parents: 2525
diff changeset
   244
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
formatMethodSource:aString in:aClass
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    ^ self formatMethod:nil source:aString in:aClass using:nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
     self
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
        formatMethod:'foo 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    ^ self bar:''hello''.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
'
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
        in:UndefinedObject
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    "
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    "Created: / 28-04-2010 / 12:58:13 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
formatMethodSource:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "format (recolor) a method in a given class.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
     Return the text containing font changes and color information."
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    ^ self formatMethod:nil source:aString in:aClass using:preferencesOrNil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    "Modified: / 28-04-2010 / 13:02:11 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   273
!AbstractSyntaxHighlighter class methodsFor:'misc'!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   274
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   275
collectionEnumerationSelectors
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   276
    "these are considered wellknown, builtin selectors of very common
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   277
     collection enumeration methods. 
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   278
     These are optionally shown with another color (dark green)"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   279
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   280
    ^ #(
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   281
        collect: 
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   282
        select:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   283
        inject:into:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   284
        count:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   285
        collect:thenSelect:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   286
        select:thenCollect:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   287
    )
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   288
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   289
    "Created: / 14-02-2012 / 15:56:59 / cg"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   290
!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   291
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   292
controlFlowSelectors
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   293
    "these are considered wellknown, builtin selectors of very common
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   294
     control flow constructs. Correspond to syntax or special forms in other
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   295
     languages. These are optionally shown with another color (blue)"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   296
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   297
    ^ #(
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   298
        ifTrue: ifFalse:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   299
        ifTrue:ifFalse: ifFalse:ifTrue:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   300
        ifNil: ifNotNil:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   301
        ifNil:ifNotNil: ifNotNil:ifNil:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   302
        and: or:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   303
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   304
        whileTrue:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   305
        whileFalse:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   306
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   307
        to:do:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   308
        downTo:do:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   309
        to:by:do:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   310
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   311
        loop
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   312
        whileTrue
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   313
        whileFalse
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   314
        doWhile:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   315
        doUntil:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   316
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   317
        do:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   318
        doWithIndex:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   319
        pairWiseDo:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   320
        keysAndValuesDo:
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
        withPriority:do:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   323
        handle:do:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   324
        on:do:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   325
        catch:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   326
        ignoreIn:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   327
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   328
        "/ newProcess
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   329
        fork:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   330
        ensure:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   331
        ifCurtailed:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   332
        valueOnUnwindDo:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   333
        valueNowOrOnUnwindDo:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   334
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   335
        caseOf:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   336
        caseOf:otherwise:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   337
    )
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   338
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   339
    "Created: / 08-09-2006 / 15:56:47 / cg"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   340
!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   341
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   342
debugSelectors
3235
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   343
    "these are considered harmful if left in a deployed application:
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   344
     selectors for debugging which open a debugger (unless haltSignal is
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   345
     cought or disabled, which end-user apps should do). 
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   346
     These are optionally shown with another color (redish)"
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   347
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   348
    ^ #(
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   349
        halt halt:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   350
    )
3235
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   351
6385bfe15842 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3231
diff changeset
   352
    "Modified (comment): / 27-07-2013 / 11:45:07 / cg"
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   353
!
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   354
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   355
errorRaisingSelectors
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   356
    "these are error raisers. 
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   357
     These are optionally shown with another color (red)"
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   358
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   359
    ^ #(
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   360
        error error:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   361
        raise raiseRequest:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   362
        raiseErrorString: raiseRequestErrorString:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   363
        raiseWith: raiseRequestWith:
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   364
        raiseWith:errorString: raiseRequestWith:errorString:
3342
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   365
        subclassResponsibility
3344
777dd2059712 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3342
diff changeset
   366
        obsoleteMethodWarning obsoleteMethodWarning:
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   367
    )
3342
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   368
!
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   369
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   370
isControlFlowSelector:aSelector
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   371
    "these are considered wellknown, builtin selectors of very common
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   372
     control flow constructs. Correspond to syntax or special forms in other
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   373
     languages. These are optionally shown with another color (blue)"
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   374
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   375
    (self controlFlowSelectors includesIdentical:aSelector) ifTrue:[^ true].
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   376
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   377
    true "((aSelector startsWith:'with') or:[ aSelector startsWith:'all'])" ifTrue:[
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   378
        ((aSelector endsWith:'do:') or:[ aSelector endsWith:'Do:']) ifTrue:[
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   379
            ^ true
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   380
        ]
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   381
    ].
d7aec03dc509 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3264
diff changeset
   382
    ^ false.
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   383
! !
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   384
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   385
!AbstractSyntaxHighlighter class methodsFor:'utilities'!
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   386
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   387
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
   388
    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
   389
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   390
    "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
   391
!
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   392
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   393
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   394
    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
   395
!
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   396
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   397
mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontIn
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   398
    |e p2 clr|
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   399
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   400
    (clrIn isNil or:[clrIn = Color black]) ifTrue:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   401
        e := fontEmp
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   402
    ] ifFalse:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   403
        clr := clrIn onDevice:Screen current.
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   404
        fontEmp isNil ifTrue:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   405
            e := (#color->clr)
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   406
        ] ifFalse:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   407
            e := Text addEmphasis:fontEmp to:(#color->clr).
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   408
        ]
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   409
    ].
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   410
    fontIn notNil ifTrue:[
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   411
        e := Text addEmphasis:e to:(#font->fontIn)
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   412
    ].
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   413
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   414
    (p2 := pos2) isNil ifTrue:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   415
        p2 := sourceText size
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   416
    ] ifFalse:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   417
        p2 := p2 min:sourceText size
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   418
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   419
    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
   420
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   421
    "Created: / 01-06-2012 / 21:42:41 / cg"
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   422
!
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   423
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   424
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
   425
    |e p2 clr fgClr|
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   426
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   427
    fgClr := fgClr1 ? fgClr2.
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   428
    (fgClr isNil or:[fgClr = Color black]) ifTrue:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   429
        e := fontEmp
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   430
    ] ifFalse:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   431
        clr := fgClr onDevice:Screen current.
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   432
        fontEmp isNil ifTrue:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   433
            e := (#color->clr)
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   434
        ] ifFalse:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   435
            e := Text addEmphasis:fontEmp to:(#color->clr).
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   436
        ]
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   437
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   438
    bgClr notNil ifTrue:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   439
        e := Text addEmphasis:(#backgroundColor->bgClr) to:e.
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   440
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   441
    (p2 := pos2) isNil ifTrue:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   442
        p2 := sourceText size
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   443
    ] ifFalse:[
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   444
        p2 := p2 min:sourceText size
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   445
    ].
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   446
    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
   447
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   448
    "Created: / 01-06-2012 / 21:44:17 / cg"
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   449
! !
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   450
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
!AbstractSyntaxHighlighter methodsFor:'accessing'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
method:aMethod
2525
f08c56018d9b lifted the method instvar
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
   454
    "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
   455
f08c56018d9b lifted the method instvar
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
   456
    method := aMethod.
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
    "Created: / 28-04-2010 / 13:15:33 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
preferences:something
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    preferences := something.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
sourceText
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    ^ sourceText
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
    "Created: / 31.3.1998 / 11:49:05 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
sourceText:aString
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
    sourceText := aString.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
    "Created: / 31-03-1998 / 11:49:05 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
    "Modified: / 28-04-2010 / 13:22:27 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
!AbstractSyntaxHighlighter methodsFor:'error handling'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
parseError:aMessage position:position to:endPos
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
"/ Transcript showCR:aMessage.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
    super parseError:aMessage position:position to:endPos.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
    self 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
        markFrom:position to:endPos 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
        withEmphasis:nil color:UserPreferences current errorColor
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
showErrorMessage:aMessage position:pos
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
"/ Transcript showCR:aMessage.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
    super showErrorMessage:aMessage position:pos.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
    self 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
        markFrom:pos to:nil 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
        withEmphasis:nil color:UserPreferences current errorColor
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
syntaxError:aMessage position:position to:endPos
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
"/ Transcript showCR:aMessage.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
    super syntaxError:aMessage position:position to:endPos.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    self 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
        markFrom:position to:endPos 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
        withEmphasis:nil color:UserPreferences current errorColor
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
warning:msg position:pos1 to:pos2
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
"/    self markUnknownIdentifierFrom:pos1 to:pos2
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
"/    self
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
"/        markFrom:pos1 to:pos2 
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
"/        withEmphasis:nil color:UserPreferences current errorColor
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
    "Modified: / 25.9.1999 / 18:42:30 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
!AbstractSyntaxHighlighter methodsFor:'initialization'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
initialize
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
    super initialize.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
    foldConstants := false.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
    preferences := UserPreferences current.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
    fullSelectorCheck := preferences fullSelectorCheck.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
    "Created: / 31-03-1998 / 15:12:55 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
    "Modified: / 28-04-2010 / 13:17:45 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
!AbstractSyntaxHighlighter methodsFor:'misc'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
2817
b92ea70a5a9f added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
   532
collectionEnumerationSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   533
    ^ self class collectionEnumerationSelectors
2817
b92ea70a5a9f added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
   534
!
b92ea70a5a9f added: #collectionEnumerationSelectors
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
   535
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
controlFlowSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   537
    ^ self class controlFlowSelectors
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   540
debugSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   541
    ^ self class debugSelectors
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   542
!
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   543
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
defineAsUndeclaredVariable:aName
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    "redefined to NOT declare undefined vars"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
    ^ VariableNode globalNamed:aName
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
    "Modified: / 19.10.1998 / 19:38:12 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   552
errorRaisingSelectors
3231
44b2709db25e class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3228
diff changeset
   553
    ^ self class errorRaisingSelectors
3228
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   554
!
e276f545e004 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   555
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
isSyntaxHighlighter
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
    ^ true
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
plausibilityCheck:aNode
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
    "redefined to NOT do checks"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
    ^ nil
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
    "Modified: / 19.10.1998 / 19:38:12 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
    "Created: / 19.10.1998 / 19:57:18 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
!AbstractSyntaxHighlighter methodsFor:'syntax detection'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
markFrom:pos1 to:pos2 withAddedEmphasis:addedEmphasis
2872
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   573
    self class 
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   574
        mark:sourceText from:pos1 to:pos2 withAddedEmphasis:addedEmphasis
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
    "Created: / 15-01-2008 / 11:48:18 / cg"
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
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
   580
    self class
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   581
        mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
    "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
   584
    "Modified: / 01-06-2012 / 21:43:04 / cg"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   587
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontInOrNil
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   588
    self class
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   589
        mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:clrIn font:fontInOrNil
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   590
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   591
    "Created: / 31-03-1998 / 13:26:53 / cg"
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   592
    "Modified: / 01-06-2012 / 21:43:04 / cg"
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   593
!
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   594
2813
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   595
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
   596
    self class
f992970ef1cd refactored mark code for reuse by other classes
Claus Gittinger <cg@exept.de>
parents: 2817
diff changeset
   597
        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
   598
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   599
    "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
   600
!
51e4b12f18dc added: #markFrom:to:withEmphasis:color:ifNil:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 2688
diff changeset
   601
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
markVariable:v
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    |pos endPos|
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
    pos := tokenPosition.
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    endPos := pos+tokenName size-1.
3189
5a4bb1727d08 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   607
    self markVariable:v from:pos to:endPos assigned:false
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
2464
595ec0d9efa9 comment/format in: #markVariable:
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   609
    "Modified: / 30-11-2010 / 14:44:28 / cg"
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
! !
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
!AbstractSyntaxHighlighter class methodsFor:'documentation'!
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
2663
e94fe6b650ad changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents: 2662
diff changeset
   614
version
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   615
    ^ '$Header: /cvs/stx/stx/libcomp/AbstractSyntaxHighlighter.st,v 1.31 2014-02-01 23:13:31 cg Exp $'
2663
e94fe6b650ad changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents: 2662
diff changeset
   616
!
e94fe6b650ad changed: #controlFlowSelectors
Claus Gittinger <cg@exept.de>
parents: 2662
diff changeset
   617
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
version_CVS
3352
42a5ad1adb52 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3345
diff changeset
   619
    ^ '$Header: /cvs/stx/stx/libcomp/AbstractSyntaxHighlighter.st,v 1.31 2014-02-01 23:13:31 cg Exp $'
2506
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
   620
!
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
   621
3a8b4a11428e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2464
diff changeset
   622
version_SVN
3189
5a4bb1727d08 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 3145
diff changeset
   623
    ^ '$ Id $'
2371
2348d09fb80e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
! !
3072
51ffc65ee7b5 class: AbstractSyntaxHighlighter
Claus Gittinger <cg@exept.de>
parents: 2873
diff changeset
   625