9981
|
1 |
"
|
10075
|
2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
3 |
All Rights Reserved
|
9981
|
4 |
|
10075
|
5 |
Permission is hereby granted, free of charge, to any person
|
|
6 |
obtaining a copy of this software and associated documentation
|
|
7 |
files (the 'Software'), to deal in the Software without
|
|
8 |
restriction, including without limitation the rights to use,
|
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 |
copies of the Software, and to permit persons to whom the
|
|
11 |
Software is furnished to do so, subject to the following
|
|
12 |
conditions:
|
|
13 |
|
|
14 |
The above copyright notice and this permission notice shall be
|
|
15 |
included in all copies or substantial portions of the Software.
|
|
16 |
|
|
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24 |
OTHER DEALINGS IN THE SOFTWARE.
|
9981
|
25 |
"
|
|
26 |
"{ Package: 'stx:libtool' }"
|
|
27 |
|
|
28 |
"{ NameSpace: Tools }"
|
|
29 |
|
|
30 |
CodeViewService subclass:#CodeCompletionService
|
|
31 |
instanceVariableNames:''
|
|
32 |
classVariableNames:''
|
|
33 |
poolDictionaries:''
|
|
34 |
category:'Interface-CodeView'
|
|
35 |
!
|
|
36 |
|
|
37 |
!CodeCompletionService class methodsFor:'documentation'!
|
|
38 |
|
|
39 |
copyright
|
|
40 |
"
|
10075
|
41 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
42 |
All Rights Reserved
|
|
43 |
|
|
44 |
Permission is hereby granted, free of charge, to any person
|
|
45 |
obtaining a copy of this software and associated documentation
|
|
46 |
files (the 'Software'), to deal in the Software without
|
|
47 |
restriction, including without limitation the rights to use,
|
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
49 |
copies of the Software, and to permit persons to whom the
|
|
50 |
Software is furnished to do so, subject to the following
|
|
51 |
conditions:
|
9981
|
52 |
|
10075
|
53 |
The above copyright notice and this permission notice shall be
|
|
54 |
included in all copies or substantial portions of the Software.
|
|
55 |
|
|
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
63 |
OTHER DEALINGS IN THE SOFTWARE.
|
9981
|
64 |
"
|
|
65 |
! !
|
|
66 |
|
|
67 |
!CodeCompletionService class methodsFor:'accessing'!
|
|
68 |
|
|
69 |
label
|
|
70 |
|
|
71 |
"Answers short label - for UI"
|
|
72 |
|
|
73 |
^'Code Completion'
|
|
74 |
|
|
75 |
"Created: / 07-03-2010 / 14:00:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
76 |
! !
|
|
77 |
|
|
78 |
!CodeCompletionService class methodsFor:'testing'!
|
|
79 |
|
|
80 |
isAvailable
|
|
81 |
|
|
82 |
"CodeCompletionService is superseded by SmallSense"
|
|
83 |
|
10259
|
84 |
"^(Smalltalk at:#SmallSenseService) isNil"
|
|
85 |
|
|
86 |
"Disable it, it is broken!!"
|
|
87 |
|
|
88 |
^ false.
|
9981
|
89 |
|
|
90 |
"Created: / 03-04-2011 / 23:08:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10259
|
91 |
"Modified: / 30-06-2011 / 19:02:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9981
|
92 |
! !
|
|
93 |
|
|
94 |
!CodeCompletionService methodsFor:'event handling'!
|
|
95 |
|
|
96 |
keyPress: key x:x y:y in: view
|
|
97 |
|
|
98 |
"Handles an event in given view (a subview of codeView).
|
|
99 |
If the method returns true, the event will not be processed
|
|
100 |
by the view."
|
|
101 |
|
|
102 |
(view == textView and:[key == #'CodeCompletion']) ifTrue:
|
|
103 |
[self complete. ^true].
|
|
104 |
^false
|
|
105 |
|
|
106 |
"Created: / 07-03-2010 / 09:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
107 |
! !
|
|
108 |
|
|
109 |
!CodeCompletionService methodsFor:'private'!
|
|
110 |
|
|
111 |
complete
|
|
112 |
|cls
|
|
113 |
"/ crsrPos interval node checkedNode
|
|
114 |
"/ char start stop selectorSoFar matchingSelectors
|
|
115 |
|
|
|
116 |
|
|
117 |
codeView languageHolder value == SmalltalkLanguage instance
|
|
118 |
ifFalse:[^self].
|
|
119 |
|
|
120 |
cls := codeView classHolder value.
|
|
121 |
cls isNil ifTrue:[
|
|
122 |
self showInfo:'No class'.
|
|
123 |
^ self.
|
|
124 |
].
|
|
125 |
UserInformation handle:[:ex |
|
|
126 |
codeView showInfo:(ex messageText).
|
|
127 |
ex proceed.
|
|
128 |
] do:[
|
|
129 |
codeView withWaitCursorDo:[
|
|
130 |
DoWhatIMeanSupport codeCompletionForClass:cls codeView:textView.
|
|
131 |
]
|
|
132 |
].
|
|
133 |
^ self.
|
|
134 |
|
|
135 |
"/
|
|
136 |
"/ interval := self selectedInterval.
|
|
137 |
"/ interval isEmpty ifTrue:[
|
|
138 |
"/ crsrPos := codeView characterPositionOfCursor - 1.
|
|
139 |
"/ char := codeView characterUnderCursor.
|
|
140 |
"/ [crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[
|
|
141 |
"/ crsrPos := crsrPos - 1.
|
|
142 |
"/ char := codeView characterAtCharacterPosition:crsrPos.
|
|
143 |
"/ ].
|
|
144 |
"/ interval := crsrPos to:crsrPos.
|
|
145 |
"/ ].
|
|
146 |
"/
|
|
147 |
"/ node := self findNodeForInterval:interval allowErrors:true.
|
|
148 |
"/ [node isNil] whileTrue:[
|
|
149 |
"/ "/ expand to the left ...
|
|
150 |
"/ interval start > 1 ifFalse:[
|
|
151 |
"/ self showInfo:'No parseNode found'.
|
|
152 |
"/ ^ self.
|
|
153 |
"/ ].
|
|
154 |
"/ interval start:(interval start - 1).
|
|
155 |
"/ node := self findNodeForInterval:interval allowErrors:true.
|
|
156 |
"/ ].
|
|
157 |
"/
|
|
158 |
"/ node isVariable ifTrue:[
|
|
159 |
"/ self codeCompletionForVariable:node inClass:cls.
|
|
160 |
"/ ^ self.
|
|
161 |
"/ ].
|
|
162 |
"/
|
|
163 |
"/ checkedNode := node.
|
|
164 |
"/ [checkedNode notNil] whileTrue:[
|
|
165 |
"/ checkedNode isMessage ifTrue:[
|
|
166 |
"/ self codeCompletionForMessage:checkedNode inClass:cls.
|
|
167 |
"/ ^ self
|
|
168 |
"/ ].
|
|
169 |
"/ checkedNode isMethod ifTrue:[
|
|
170 |
"/ self codeCompletionForMethod:checkedNode inClass:cls.
|
|
171 |
"/ ^ self.
|
|
172 |
"/ ].
|
|
173 |
"/ checkedNode := checkedNode parent.
|
|
174 |
"/ ].
|
|
175 |
"/
|
|
176 |
"/ self showInfo:'Node is neither variable nor message.'.
|
|
177 |
|
|
178 |
"Modified: / 04-07-2006 / 18:48:26 / fm"
|
|
179 |
"Modified: / 20-11-2006 / 12:30:59 / cg"
|
|
180 |
"Created: / 07-03-2010 / 09:37:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
181 |
! !
|
|
182 |
|
|
183 |
!CodeCompletionService class methodsFor:'documentation'!
|
|
184 |
|
|
185 |
version_CVS
|
10259
|
186 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeCompletionService.st,v 1.3 2011-07-07 14:15:04 vrany Exp $'
|
9981
|
187 |
!
|
|
188 |
|
|
189 |
version_SVN
|
|
190 |
^ '§Id: Tools__CodeCompletionService.st 7695 2011-04-04 20:09:17Z vranyj1 §'
|
|
191 |
! !
|