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