author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 27 Sep 2012 21:08:20 +0100 | |
branch | jv |
changeset 12296 | 6921627a8c27 |
parent 12128 | a7ff7d66ee85 |
child 12431 | 9f0c59c742d5 |
permissions | -rw-r--r-- |
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 |
||
10274 | 86 |
"Sure, it is broken, but we need it!!" |
10302 | 87 |
"JV2011-07-09: And I preferr SmallSense: this should work for both |
88 |
unless SmallSense is loaded in your image" |
|
10259 | 89 |
|
10302 | 90 |
^(Smalltalk at:#SmallSenseService) isNil. |
9981 | 91 |
|
92 |
"Created: / 03-04-2011 / 23:08:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10274 | 93 |
"Modified: / 08-07-2011 / 08:42:52 / cg" |
10413 | 94 |
"Modified: / 27-07-2011 / 11:47:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9981 | 95 |
! ! |
96 |
||
97 |
!CodeCompletionService methodsFor:'event handling'! |
|
98 |
||
99 |
keyPress: key x:x y:y in: view |
|
100 |
||
101 |
"Handles an event in given view (a subview of codeView). |
|
102 |
If the method returns true, the event will not be processed |
|
103 |
by the view." |
|
104 |
||
105 |
(view == textView and:[key == #'CodeCompletion']) ifTrue: |
|
106 |
[self complete. ^true]. |
|
107 |
^false |
|
108 |
||
109 |
"Created: / 07-03-2010 / 09:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
110 |
! ! |
|
111 |
||
112 |
!CodeCompletionService methodsFor:'private'! |
|
113 |
||
114 |
complete |
|
115 |
|cls |
|
116 |
"/ crsrPos interval node checkedNode |
|
117 |
"/ char start stop selectorSoFar matchingSelectors |
|
118 |
| |
|
119 |
||
120 |
codeView languageHolder value == SmalltalkLanguage instance |
|
121 |
ifFalse:[^self]. |
|
122 |
||
123 |
cls := codeView classHolder value. |
|
124 |
cls isNil ifTrue:[ |
|
125 |
self showInfo:'No class'. |
|
126 |
^ self. |
|
127 |
]. |
|
128 |
UserInformation handle:[:ex | |
|
129 |
codeView showInfo:(ex messageText). |
|
130 |
ex proceed. |
|
131 |
] do:[ |
|
132 |
codeView withWaitCursorDo:[ |
|
133 |
DoWhatIMeanSupport codeCompletionForClass:cls codeView:textView. |
|
134 |
] |
|
135 |
]. |
|
136 |
^ self. |
|
137 |
||
138 |
"/ |
|
139 |
"/ interval := self selectedInterval. |
|
140 |
"/ interval isEmpty ifTrue:[ |
|
141 |
"/ crsrPos := codeView characterPositionOfCursor - 1. |
|
142 |
"/ char := codeView characterUnderCursor. |
|
143 |
"/ [crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[ |
|
144 |
"/ crsrPos := crsrPos - 1. |
|
145 |
"/ char := codeView characterAtCharacterPosition:crsrPos. |
|
146 |
"/ ]. |
|
147 |
"/ interval := crsrPos to:crsrPos. |
|
148 |
"/ ]. |
|
149 |
"/ |
|
150 |
"/ node := self findNodeForInterval:interval allowErrors:true. |
|
151 |
"/ [node isNil] whileTrue:[ |
|
152 |
"/ "/ expand to the left ... |
|
153 |
"/ interval start > 1 ifFalse:[ |
|
154 |
"/ self showInfo:'No parseNode found'. |
|
155 |
"/ ^ self. |
|
156 |
"/ ]. |
|
157 |
"/ interval start:(interval start - 1). |
|
158 |
"/ node := self findNodeForInterval:interval allowErrors:true. |
|
159 |
"/ ]. |
|
160 |
"/ |
|
161 |
"/ node isVariable ifTrue:[ |
|
162 |
"/ self codeCompletionForVariable:node inClass:cls. |
|
163 |
"/ ^ self. |
|
164 |
"/ ]. |
|
165 |
"/ |
|
166 |
"/ checkedNode := node. |
|
167 |
"/ [checkedNode notNil] whileTrue:[ |
|
168 |
"/ checkedNode isMessage ifTrue:[ |
|
169 |
"/ self codeCompletionForMessage:checkedNode inClass:cls. |
|
170 |
"/ ^ self |
|
171 |
"/ ]. |
|
172 |
"/ checkedNode isMethod ifTrue:[ |
|
173 |
"/ self codeCompletionForMethod:checkedNode inClass:cls. |
|
174 |
"/ ^ self. |
|
175 |
"/ ]. |
|
176 |
"/ checkedNode := checkedNode parent. |
|
177 |
"/ ]. |
|
178 |
"/ |
|
179 |
"/ self showInfo:'Node is neither variable nor message.'. |
|
180 |
||
181 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
182 |
"Modified: / 20-11-2006 / 12:30:59 / cg" |
|
183 |
"Created: / 07-03-2010 / 09:37:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
184 |
! ! |
|
185 |
||
186 |
!CodeCompletionService class methodsFor:'documentation'! |
|
187 |
||
188 |
version_CVS |
|
12123
4bde08cebd48
trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10413
diff
changeset
|
189 |
^ '§Header: /cvs/stx/stx/libtool/Tools__CodeCompletionService.st,v 1.6 2011/07/27 12:34:03 vrany Exp §' |
9981 | 190 |
! |
191 |
||
192 |
version_SVN |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12123
diff
changeset
|
193 |
^ '$Id: Tools__CodeCompletionService.st 7854 2012-01-30 17:49:41Z vranyj1 $' |
12123
4bde08cebd48
trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10413
diff
changeset
|
194 |
! ! |