|
1 " |
|
2 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
|
3 Copyright (C) 2013-2014 Jan Vrany |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Lesser General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2.1 of the License. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Lesser General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Lesser General Public |
|
16 License along with this library; if not, write to the Free Software |
|
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 " |
|
19 "{ Package: 'stx:goodies/smallsense' }" |
|
20 |
|
21 "{ NameSpace: SmallSense }" |
|
22 |
|
23 PO subclass:#ClassPO |
|
24 instanceVariableNames:'showPrefix klass icon' |
|
25 classVariableNames:'' |
|
26 poolDictionaries:'' |
|
27 category:'SmallSense-Core-Interface-PO' |
|
28 ! |
|
29 |
|
30 !ClassPO class methodsFor:'documentation'! |
|
31 |
|
32 copyright |
|
33 " |
|
34 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
|
35 Copyright (C) 2013-2014 Jan Vrany |
|
36 |
|
37 This library is free software; you can redistribute it and/or |
|
38 modify it under the terms of the GNU Lesser General Public |
|
39 License as published by the Free Software Foundation; either |
|
40 version 2.1 of the License. |
|
41 |
|
42 This library is distributed in the hope that it will be useful, |
|
43 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
45 Lesser General Public License for more details. |
|
46 |
|
47 You should have received a copy of the GNU Lesser General Public |
|
48 License along with this library; if not, write to the Free Software |
|
49 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
50 " |
|
51 ! ! |
|
52 |
|
53 !ClassPO methodsFor:'accessing'! |
|
54 |
|
55 hint |
|
56 | namespace | |
|
57 |
|
58 namespace := nil. |
|
59 showPrefix ifFalse:[ |
|
60 namespace := klass isJavaClass |
|
61 ifTrue:[klass javaPackage] |
|
62 ifFalse:[ | ns | ns := klass nameSpace. [ ns isNameSpace ] whileFalse:[ ns := ns nameSpace ]. ns name]. |
|
63 (namespace notNil and:[namespace ~~ #Smalltalk]) ifTrue:[ |
|
64 ^ 'in ', namespace. |
|
65 ]. |
|
66 ]. |
|
67 ^ nil |
|
68 |
|
69 "Created: / 20-05-2014 / 12:21:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
70 "Modified: / 24-07-2014 / 17:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
71 ! |
|
72 |
|
73 icon |
|
74 |
|
75 icon ifNil:[icon := SystemBrowser iconForClass: klass]. |
|
76 ^icon |
|
77 |
|
78 "Created: / 06-04-2011 / 23:36:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
79 ! |
|
80 |
|
81 klass |
|
82 ^ klass |
|
83 |
|
84 "Created: / 25-08-2013 / 13:07:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
85 ! |
|
86 |
|
87 klass: aClass |
|
88 ^ klass := aClass |
|
89 |
|
90 "Created: / 25-08-2013 / 13:07:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
91 "Modified: / 20-05-2014 / 10:05:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
92 ! |
|
93 |
|
94 label |
|
95 label isNil ifTrue:[ |
|
96 showPrefix ifTrue:[ |
|
97 label := klass name. |
|
98 (context notNil and:[klass isJavaClass]) ifTrue:[ |
|
99 | lang | |
|
100 |
|
101 lang := context language. |
|
102 (lang notNil and:[lang isJava]) ifTrue:[ |
|
103 label := klass javaName |
|
104 ] ifFalse:[ |
|
105 (lang notNil and:[lang isSmalltalk]) ifTrue:[ |
|
106 label := 'JAVA ' , (klass binaryName copyReplaceAll: $/ with: Character space) |
|
107 ] ifFalse:[ |
|
108 label := klass nameWithoutNameSpacePrefix. |
|
109 ]. |
|
110 ] |
|
111 ]. |
|
112 ] ifFalse:[ |
|
113 label := klass nameWithoutNameSpacePrefix. |
|
114 ]. |
|
115 ]. |
|
116 |
|
117 ^label |
|
118 |
|
119 "Created: / 20-05-2014 / 11:29:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
120 "Modified: / 07-08-2014 / 16:19:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 ! |
|
122 |
|
123 showPrefix |
|
124 ^ showPrefix |
|
125 ! |
|
126 |
|
127 showPrefix:aBoolean |
|
128 showPrefix := aBoolean. |
|
129 ! |
|
130 |
|
131 stringAlreadyWritten |
|
132 "Answers a string already written in the textview" |
|
133 |
|
134 klass isJavaClass ifTrue:[ |
|
135 context language isSmalltalk ifTrue:[ |
|
136 | rec | |
|
137 |
|
138 rec := context node . |
|
139 [ rec isUnaryMessage ] whileTrue:[ |
|
140 rec := rec receiver. |
|
141 ]. |
|
142 (rec isVariableNode and:['JAVA' startsWith: rec name]) ifTrue:[ |
|
143 ^ context codeView contents string copyFrom: rec startPosition to: context node endPosition |
|
144 ]. |
|
145 ] ifFalse:[ |
|
146 context language isJavaLike ifTrue:[ |
|
147 ^ context wordBeforeCursorConsisitingOfCharactersMatching:[:c | c isAlphaNumeric or:['$_.' includes: c] ] |
|
148 ]]. |
|
149 ]. |
|
150 ^ super stringAlreadyWritten |
|
151 |
|
152 "Created: / 20-10-2013 / 02:46:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
153 "Modified: / 08-08-2014 / 16:23:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
154 ! |
|
155 |
|
156 stringToCompleteForLanguage: language |
|
157 ^ (klass isJavaClass and:[language isSmalltalk]) ifTrue:[ |
|
158 'JAVA ', (klass binaryName copyReplaceAll: $/ with: Character space) |
|
159 ] ifFalse:[ |
|
160 self label |
|
161 ]. |
|
162 |
|
163 "Created: / 03-10-2013 / 16:42:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
164 "Modified: / 20-05-2014 / 11:41:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
165 ! ! |
|
166 |
|
167 !ClassPO methodsFor:'converting'! |
|
168 |
|
169 asString |
|
170 ^klass isJavaClass ifTrue:[ |
|
171 klass javaName |
|
172 ] ifFalse:[ |
|
173 klass name |
|
174 ]. |
|
175 |
|
176 "Created: / 04-04-2012 / 13:00:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
177 "Modified: / 26-08-2013 / 10:27:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
178 ! ! |
|
179 |
|
180 !ClassPO methodsFor:'initialization'! |
|
181 |
|
182 initialize |
|
183 "Invoked when a new instance is created." |
|
184 |
|
185 "/ please change as required (and remove this comment) |
|
186 "/ showPrefix := nil. |
|
187 |
|
188 super initialize. |
|
189 showPrefix := false. |
|
190 |
|
191 "Modified: / 20-10-2013 / 02:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
192 ! |
|
193 |
|
194 initializeWithClass: aClass |
|
195 |
|
196 klass := aClass. |
|
197 showPrefix := false. |
|
198 |
|
199 "Created: / 20-05-2014 / 09:56:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
200 ! ! |
|
201 |
|
202 !ClassPO methodsFor:'testing'! |
|
203 |
|
204 isSmallSenseClassPO |
|
205 ^ true |
|
206 ! ! |
|
207 |
|
208 !ClassPO class methodsFor:'documentation'! |
|
209 |
|
210 version_HG |
|
211 |
|
212 ^ '$Changeset: <not expanded> $' |
|
213 ! |
|
214 |
|
215 version_SVN |
|
216 ^ '$Id$' |
|
217 ! ! |
|
218 |