SmallSense__SelectorNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 25 Oct 2017 23:42:41 +0100
changeset 1058 6d4bf422a7dd
parent 374 e65bd2bf892a
child 1061 d3919703de3c
permissions -rw-r--r--
Fix subscript out of bounds error in Smalltalk inderences ...caused by missing size-check when analysing typed prefix.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     1
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     2
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 300
diff changeset
     3
Copyright (C) 2013-2015 Jan Vrany
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     4
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     5
This library is free software; you can redistribute it and/or
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     6
modify it under the terms of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     7
License as published by the Free Software Foundation; either
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     8
version 2.1 of the License. 
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     9
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    10
This library is distributed in the hope that it will be useful,
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    11
but WITHOUT ANY WARRANTY; without even the implied warranty of
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    13
Lesser General Public License for more details.
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    14
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    15
You should have received a copy of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    16
License along with this library; if not, write to the Free Software
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    18
"
249
8bc64027b189 Package renamed to stx:goodies/smallsense
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 124
diff changeset
    19
"{ Package: 'stx:goodies/smallsense' }"
81
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
"{ NameSpace: SmallSense }"
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
ParseNode subclass:#SelectorNode
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
	instanceVariableNames:'value'
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
	classVariableNames:''
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	poolDictionaries:''
104
3b05b2d777dd Some more support for complete-as-you-type.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 102
diff changeset
    27
	category:'SmallSense-Smalltalk'
81
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
!
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
!SelectorNode class methodsFor:'documentation'!
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    32
copyright
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    33
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    34
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 300
diff changeset
    35
Copyright (C) 2013-2015 Jan Vrany
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    36
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    37
This library is free software; you can redistribute it and/or
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    38
modify it under the terms of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    39
License as published by the Free Software Foundation; either
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    40
version 2.1 of the License. 
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    41
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    42
This library is distributed in the hope that it will be useful,
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    43
but WITHOUT ANY WARRANTY; without even the implied warranty of
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    44
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    45
Lesser General Public License for more details.
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    46
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    47
You should have received a copy of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    48
License along with this library; if not, write to the Free Software
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    49
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    50
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    51
!
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    52
81
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
documentation
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
"
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
    A (helper) node that represents a selector (or its part).
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
    SelectorNodes are not directly created nor used by the
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    parser/compiler itself.
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
    Some custom subclasses (syntax highlighters for instance)
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
    makes use of it.
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
    [author:]
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
        Jan Vrany <jan.vrany@fit.cvut.cz>
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
    [instance variables:]
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
    [class variables:]
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
    [see also:]
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
        SyntaxHighlighter2
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
"
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
! !
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
!SelectorNode class methodsFor:'instance creation'!
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
value: selector from: start to: end
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
    ^self new
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
        value: selector;
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
        startPosition:start endPosition: end
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
    "Created: / 16-02-2012 / 20:56:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
! !
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
!SelectorNode methodsFor:'accessing'!
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
value
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
    ^ value
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
!
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
value:aString
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
    value := aString.
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
! !
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
104
3b05b2d777dd Some more support for complete-as-you-type.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 102
diff changeset
    96
!SelectorNode methodsFor:'navigation-SmallSense'!
3b05b2d777dd Some more support for complete-as-you-type.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 102
diff changeset
    97
3b05b2d777dd Some more support for complete-as-you-type.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 102
diff changeset
    98
navigateToUsing: navigator
300
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
    99
    | p |
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   100
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   101
    p := self parent.
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   102
    p notNil ifTrue:[
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   103
        p navigateToUsing: navigator
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   104
    ] ifFalse:[ 
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   105
        self breakPoint: #jv  
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   106
    ].
104
3b05b2d777dd Some more support for complete-as-you-type.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 102
diff changeset
   107
3b05b2d777dd Some more support for complete-as-you-type.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 102
diff changeset
   108
    "Created: / 24-09-2013 / 10:04:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
300
f5466d944367 Workaround for weird DNU in SelectorNode>>navigateToUsing:
Claus Gittinger
parents: 252
diff changeset
   109
    "Modified: / 19-11-2014 / 15:47:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
104
3b05b2d777dd Some more support for complete-as-you-type.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 102
diff changeset
   110
! !
102
538fc4ef040c CodeNavigation service refactored to support Java (not yet done, though)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 81
diff changeset
   111
81
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
!SelectorNode methodsFor:'testing'!
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
isSelector
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    ^true
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
    "Created: / 16-02-2012 / 21:04:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
! !
9ff3fb468c16 Oops, added lost mehods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
124
73fa59be4774 Oops, added lost method.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   121
!SelectorNode class methodsFor:'documentation'!
73fa59be4774 Oops, added lost method.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   122
73fa59be4774 Oops, added lost method.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   123
version_HG
73fa59be4774 Oops, added lost method.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   124
73fa59be4774 Oops, added lost method.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   125
    ^ '$Changeset: <not expanded> $'
73fa59be4774 Oops, added lost method.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   126
! !
73fa59be4774 Oops, added lost method.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   127