author | Claus Gittinger <cg@exept.de> |
Mon, 20 Aug 2018 10:11:25 +0200 | |
changeset 4346 | 6604af2f1554 |
parent 4315 | 0d6042c723e7 |
child 4357 | 2ff9600e08f5 |
permissions | -rw-r--r-- |
4315 | 1 |
"{ Encoding: utf8 }" |
2 |
||
2797 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2707 | 14 |
"{ Package: 'stx:libbasic3' }" |
15 |
||
3780 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
2707 | 18 |
Object subclass:#ProjectChecker |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
19 |
instanceVariableNames:'packages currentPackage currentPackageDef classes methods |
3686 | 20 |
problems phase checkExtensionsOnly rulesApplied' |
2967 | 21 |
classVariableNames:'' |
22 |
poolDictionaries:'' |
|
23 |
category:'System-Support-Projects' |
|
2707 | 24 |
! |
25 |
||
2797 | 26 |
!ProjectChecker class methodsFor:'documentation'! |
27 |
||
28 |
copyright |
|
29 |
" |
|
30 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
31 |
All Rights Reserved |
|
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
2707 | 40 |
! |
41 |
||
42 |
documentation |
|
43 |
" |
|
44 |
A simple project checker that can search whole projects or individual |
|
3791 | 45 |
classes or methods for various problems that may cause build problems, |
46 |
such as: |
|
2853 | 47 |
- inconsistent/messed up project definition class |
48 |
- method code problems |
|
2707 | 49 |
|
3791 | 50 |
NOTE: this is not a lint. It only checks for inconsitent configuration |
51 |
(projectDefinition class data vs. real data) and compilability (stc limitations). |
|
52 |
||
2707 | 53 |
NOTE: Not yet finished. This code is meant as a single central entry for all the |
54 |
source code management tools like SCM Utilities, NewSystemBrowser ets. That code |
|
2797 | 55 |
will be refactored later once this tool prooves itself useful and mature enough. |
2707 | 56 |
|
57 |
[author:] |
|
58 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
59 |
||
60 |
[instance variables:] |
|
61 |
||
62 |
[class variables:] |
|
63 |
||
64 |
[see also:] |
|
2853 | 65 |
Tools::ProjectCheckerBrowser |
2707 | 66 |
|
67 |
" |
|
68 |
! |
|
69 |
||
70 |
examples |
|
71 |
||
72 |
" |
|
73 |
ProjectChecker check: 'stx:libbasic' |
|
2797 | 74 |
ProjectChecker check: 'stx:libtool' |
75 |
ProjectChecker check: 'stx:libbasic3' |
|
2707 | 76 |
" |
77 |
! ! |
|
78 |
||
2853 | 79 |
!ProjectChecker class methodsFor:'instance creation'! |
80 |
||
81 |
forPackage: packageId |
|
82 |
^self new |
|
83 |
package: packageId; |
|
84 |
yourself. |
|
85 |
||
86 |
"Created: / 25-07-2012 / 18:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2910 | 87 |
! |
88 |
||
89 |
new |
|
90 |
"return an initialized instance" |
|
91 |
||
92 |
^ self basicNew initialize. |
|
2853 | 93 |
! ! |
94 |
||
2707 | 95 |
!ProjectChecker class methodsFor:'checking'! |
96 |
||
97 |
check: package |
|
98 |
||
99 |
^self new check: package |
|
100 |
||
101 |
"Created: / 11-01-2012 / 16:46:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
102 |
! ! |
|
103 |
||
104 |
!ProjectChecker methodsFor:'accessing'! |
|
105 |
||
3148 | 106 |
checkExtensionsOnly:aBoolean |
107 |
checkExtensionsOnly := aBoolean. |
|
108 |
! |
|
109 |
||
2797 | 110 |
classes: aCollection |
111 |
classes := aCollection. |
|
112 |
||
113 |
"Created: / 13-02-2012 / 17:06:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
114 |
! |
|
115 |
||
116 |
methods |
|
117 |
^ methods |
|
118 |
! |
|
119 |
||
120 |
methods:something |
|
121 |
methods := something. |
|
122 |
! |
|
123 |
||
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
124 |
package:packageId |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
125 |
"Adds `packageId` to set of checked packages" |
2707 | 126 |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
127 |
(packages includes: packageId) ifFalse:[ |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
128 |
packages add: packageId |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
129 |
]. |
2853 | 130 |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
131 |
"Modified (comment): / 22-02-2014 / 22:03:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2797 | 132 |
! |
133 |
||
134 |
problems |
|
2853 | 135 |
^ problems |
2797 | 136 |
|
137 |
"Modified: / 23-02-2012 / 15:14:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2707 | 138 |
! ! |
139 |
||
140 |
!ProjectChecker methodsFor:'checking'! |
|
141 |
||
142 |
check |
|
143 |
||
2910 | 144 |
problems removeAll. |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
145 |
packages do:[:each | |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
146 |
currentPackage := each. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
147 |
currentPackageDef := ProjectDefinition definitionClassForPackage: currentPackage. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
148 |
currentPackageDef isNil ifTrue:[ |
3807 | 149 |
self addProblem: (ProjectProblem newProjectDefinitionDoesNotExist package: currentPackage). |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
150 |
^self |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
151 |
]. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
152 |
|
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
153 |
ActivityNotification raiseRequestWith:self errorString:'Checking package...'. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
154 |
self checkPackage. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
155 |
(checkExtensionsOnly ? false) ifFalse:[ |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
156 |
ActivityNotification raiseRequestWith:self errorString:'Checking classes...'. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
157 |
self checkClasses. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
158 |
]. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
159 |
ActivityNotification raiseRequestWith:self errorString:'Checking methods...'. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
160 |
self checkMethods. |
2797 | 161 |
]. |
162 |
||
2707 | 163 |
"Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
164 |
"Modified: / 22-02-2014 / 21:59:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2707 | 165 |
! |
166 |
||
167 |
check: package |
|
168 |
||
169 |
self package: package. |
|
170 |
self check. |
|
171 |
||
172 |
"Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
173 |
! ! |
|
174 |
||
175 |
!ProjectChecker methodsFor:'checks-individual'! |
|
176 |
||
177 |
checkClassListConsistency |
|
178 |
"Checks whether all classes listed in #classNamesAndAttributes are present |
|
179 |
and if all present classes are listed" |
|
180 |
||
3807 | 181 |
|classesInImage classesInDescription classesInDescriptionChecked onlyInDescription onlyInImage| |
2707 | 182 |
"WARNING: Copy/paste of ProjectDefinition>>validateDescription" |
183 |
||
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
184 |
classesInImage := Smalltalk allClasses select:[:cls | (cls package = currentPackage) and:[cls isPrivate not]]. |
3807 | 185 |
|
2707 | 186 |
"/ classesInDescription := self classes asIdentitySet. |
2910 | 187 |
classesInDescription := OrderedCollection new. |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
188 |
( (currentPackageDef compiled_classNames_common) |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
189 |
, (currentPackageDef compiled_classNamesForPlatform:(OperatingSystem platformName)) |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
190 |
, (currentPackageDef autoloaded_classNames)) do:[:nm | |
2707 | 191 |
|cls| |
192 |
||
193 |
cls := Smalltalk at:nm asSymbol. |
|
194 |
cls isNil ifTrue:[ |
|
3807 | 195 |
self addProblem: (ProjectProblem newClassListedButDoesNotExist className: nm) |
2707 | 196 |
] ifFalse:[ |
3807 | 197 |
cls package ~= currentPackage ifTrue:[ |
198 |
self addProblem: (ProjectProblem newClassListedButInOtherPackage className: nm) |
|
199 |
] ifFalse:[ |
|
200 |
classesInDescription add:cls. |
|
201 |
] |
|
2707 | 202 |
]. |
203 |
]. |
|
204 |
||
3807 | 205 |
classesInDescriptionChecked := Set new. |
2707 | 206 |
classesInDescription do:[:eachClass | |
2910 | 207 |
(classesInDescriptionChecked includes: eachClass) ifTrue:[ |
3807 | 208 |
self addProblem: (ProjectProblem newClassListedMultipleTimes className: eachClass name) |
2910 | 209 |
]. |
210 |
||
2707 | 211 |
eachClass sharedPoolNames do:[:eachPoolName | |
212 |
|pool| |
|
213 |
||
214 |
pool := eachClass nameSpace classNamed:eachPoolName. |
|
215 |
pool isNil ifTrue:[ |
|
216 |
eachClass nameSpace ~~ Smalltalk ifTrue:[ |
|
217 |
pool := Smalltalk classNamed:eachPoolName. |
|
218 |
] |
|
219 |
]. |
|
220 |
pool isNil ifTrue:[ |
|
2797 | 221 |
self addProblem: |
222 |
(ProjectProblem newClassUsesPoolButItDoesNotExist |
|
223 |
className: eachClass name; |
|
224 |
poolName: eachPoolName). |
|
2707 | 225 |
] ifFalse:[ |
226 |
pool isSharedPool ifFalse:[ |
|
2797 | 227 |
self addProblem: |
228 |
(ProjectProblem newClassUsesPoolButItIsNotASharedPool |
|
229 |
className: eachClass name; |
|
230 |
poolName: eachPoolName). |
|
2707 | 231 |
]. |
232 |
]. |
|
233 |
]. |
|
2910 | 234 |
|
2966
bf5ea36104cd
Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents:
2965
diff
changeset
|
235 |
(eachClass superclass notNil "/Care about classes with nil superclass - Object & Autoload |
4217 | 236 |
and:[eachClass superclass package == eachClass package] |
237 |
) ifTrue:[ |
|
2910 | 238 |
(classesInDescriptionChecked includes: eachClass superclass) ifFalse:[ |
4217 | 239 |
((currentPackageDef autoloaded_classNames) includes:eachClass name) ifFalse:[ |
240 |
self addProblem: |
|
241 |
(ProjectProblem newClassListedBeforeItsSuperclass |
|
242 |
className: eachClass name; |
|
243 |
superClassName: eachClass superclass name) |
|
244 |
]. |
|
2910 | 245 |
]. |
246 |
]. |
|
247 |
eachClass sharedPools do:[:eachPool| |
|
248 |
eachPool package == eachClass package ifTrue:[ |
|
249 |
(classesInDescriptionChecked includes: eachPool) ifFalse:[ |
|
250 |
self addProblem: |
|
251 |
(ProjectProblem newClassListedBeforeItsPool |
|
252 |
className: eachClass name; |
|
253 |
poolName: eachPool name) |
|
254 |
]. |
|
255 |
]. |
|
256 |
]. |
|
257 |
||
258 |
classesInDescriptionChecked add: eachClass. |
|
2707 | 259 |
]. |
260 |
||
261 |
classesInImage ~= classesInDescription ifTrue:[ |
|
2856
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
262 |
"This is done later in checkClassesListedInProjectDefinition:" |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
263 |
"/ onlyInImage := (classesInImage reject:[:cls | classesInDescription includes:cls]). |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
264 |
"/ onlyInImage do:[:cls| |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
265 |
"/ self addProblem: |
3807 | 266 |
"/ (ProjectProblem newClassListedButInOtherPackage className: cls name). |
2856
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
267 |
"/ ]. |
2707 | 268 |
onlyInDescription := (classesInDescription reject:[:cls | classesInImage includes:cls]). |
269 |
onlyInDescription do:[:cls| |
|
2797 | 270 |
self addProblem: |
271 |
(ProjectProblem newClassListedButDoesNotExist className: cls name) |
|
2707 | 272 |
]. |
273 |
]. |
|
274 |
||
275 |
"Created: / 11-01-2012 / 17:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
276 |
"Modified: / 22-02-2014 / 21:46:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4217 | 277 |
"Modified: / 21-02-2017 / 16:17:46 / cg" |
2718 | 278 |
! |
279 |
||
3467 | 280 |
checkClassesAutoloadedSuperclasse: aCollection"of Class" |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
281 |
currentPackageDef classNamesAndAttributesDo:[:clsnm :attributes| |
3780 | 282 |
| cls superclass | |
3467 | 283 |
|
284 |
cls := Smalltalk at: clsnm. |
|
285 |
(aCollection includes: cls) ifTrue:[ |
|
286 |
(attributes includes: #autoload) ifFalse:[ |
|
287 |
"/ Care for Object!! |
|
3780 | 288 |
superclass := cls superclass. |
289 |
superclass notNil ifTrue:[ |
|
290 |
| superDef | |
|
3467 | 291 |
|
3780 | 292 |
superDef := ProjectDefinition definitionClassForPackage: superclass package. |
3467 | 293 |
superDef isNil ifTrue:[ |
294 |
problems add: |
|
295 |
(ProjectProblem newClassIsCompiledButSuperclassProjectDefinitionIsMissing |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
296 |
package: currentPackage; |
3467 | 297 |
className: clsnm; |
298 |
yourself) |
|
299 |
] ifFalse:[ |
|
3780 | 300 |
(superDef isAutoloaded:superclass) ifTrue:[ |
301 |
problems add: |
|
302 |
(ProjectProblem newClassIsCompiledButSuperclassIsAutoloaded |
|
303 |
package: currentPackage; |
|
304 |
className: clsnm; |
|
305 |
yourself) |
|
3467 | 306 |
]. |
307 |
] |
|
308 |
]. |
|
309 |
]. |
|
310 |
]. |
|
311 |
]. |
|
312 |
||
313 |
"Created: / 20-09-2013 / 11:08:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
314 |
"Modified: / 05-10-2013 / 12:45:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
315 |
! |
|
316 |
||
2910 | 317 |
checkClassesForMethodsInNoProject:classesToCheck |
318 |
| checker | |
|
319 |
||
320 |
checker := [:cls | |
|
321 |
cls |
|
322 |
selectorsAndMethodsDo:[:sel :mth | |
|
323 |
(mth package isNil or:[ mth package == PackageId noProjectID ]) ifTrue:[ |
|
324 |
"Sigh, special hack for Expecco" |
|
325 |
((cls name = 'Expecco::AbstractApplication class' and:[ sel = 'flags' ]) or:[ |
|
326 |
(cls name = 'Expecco::Browser class' and:[ sel = 'flags' ])]) ifFalse:[ |
|
327 |
self addProblem:(ProjectProblem newMethodInNoPackage className:cls name |
|
328 |
selector:sel). |
|
329 |
] |
|
330 |
] |
|
331 |
] |
|
332 |
]. |
|
333 |
classesToCheck do:[:class | |
|
334 |
checker value:class theMetaclass. |
|
335 |
checker value:class theNonMetaclass. |
|
336 |
] |
|
337 |
||
338 |
"Created: / 13-02-2012 / 18:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
339 |
! |
|
340 |
||
341 |
checkClassesForNonQualifiedSharedPools: classesToCheck |
|
342 |
||
343 |
classesToCheck do:[:cls| |
|
344 |
cls sharedPoolNames do:[:poolName| |
|
4315 | 345 |
|pool| |
2910 | 346 |
|
4315 | 347 |
pool := cls sharedPoolNamed:poolName. |
348 |
(pool notNil and:[pool isSharedPool]) ifFalse:[ |
|
349 |
self addProblem: |
|
350 |
(ProjectProblem newClassUsesPoolButItIsNotASharedPool |
|
351 |
className:(cls name); |
|
352 |
poolName: poolName) |
|
2910 | 353 |
] |
354 |
] |
|
355 |
]. |
|
356 |
||
357 |
"Created: / 13-09-2012 / 16:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
358 |
! |
|
359 |
||
2797 | 360 |
checkClassesListedInProjectDefinition: classesToCheck |
361 |
||
362 |
| classNamesListed | |
|
363 |
||
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
364 |
classNamesListed := currentPackageDef classNames. |
2797 | 365 |
|
366 |
classesToCheck do:[:class| |
|
367 |
(class isPrivate not and:[(classNamesListed includes: class name) not]) ifTrue:[ |
|
368 |
self addProblem: |
|
369 |
(ProjectProblem newClassNotListed className: class name). |
|
370 |
] |
|
371 |
]. |
|
372 |
||
373 |
"Created: / 13-02-2012 / 18:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
374 |
! |
|
375 |
||
2718 | 376 |
checkExtensionsListConsistency |
377 |
"Checks whether all extensions listed in #extensionMethodNames are present |
|
3791 | 378 |
and if all extension methods are listed. |
379 |
Also check if any regular or extension method is also listed in some other package |
|
380 |
(which may happen after a move, if the original package was not updated)" |
|
2718 | 381 |
|
3791 | 382 |
| extensionsListed extensionsPresent allOtherExtensions checkMethod| |
2718 | 383 |
|
384 |
extensionsListed := OrderedCollection new. |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
385 |
currentPackageDef extensionMethodNames pairWiseDo:[:cls :sel| |
2718 | 386 |
extensionsListed add: (Array with: cls with: sel) |
387 |
]. |
|
388 |
extensionsPresent := OrderedCollection new. |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
389 |
currentPackageDef searchForExtensions do:[:each| |
2910 | 390 |
"JV@2012-09-07: Do not take Java methods into an account, they |
391 |
should not be listed in extensionMethodNames. |
|
392 |
They are loaded lazily by JavaClassReader and if listed here, |
|
393 |
they would cause an error if the package is loaded from source. |
|
394 |
Sort of a HACK, indeed" |
|
3467 | 395 |
each mclass theNonMetaclass isJavaClass ifFalse:[ |
2910 | 396 |
extensionsPresent add: (Array with: each mclass name with: each selector) |
397 |
]. |
|
2718 | 398 |
]. |
399 |
||
400 |
(extensionsListed \ extensionsPresent) do:[:clsAndSel| |
|
3167 | 401 |
|cls clsName selector| |
402 |
||
403 |
clsName := clsAndSel first. |
|
404 |
selector := clsAndSel second. |
|
405 |
(cls := Smalltalk classNamed: clsName) isNil ifTrue:[ |
|
406 |
self addProblem: |
|
407 |
(ProjectProblem newExtensionMethodsClassDoesNotExist |
|
408 |
className: clsName selector: selector). |
|
409 |
] ifFalse:[ |
|
410 |
(cls compiledMethodAt:selector) isNil ifTrue:[ |
|
411 |
self addProblem: |
|
412 |
(ProjectProblem newExtensionMethodListedButDoesNotExist |
|
413 |
className: clsName selector: selector). |
|
414 |
] ifFalse:[ |
|
415 |
self addProblem: |
|
416 |
(ProjectProblem newExtensionMethodListedButInDifferentPackage |
|
417 |
className: clsName selector: selector). |
|
418 |
] |
|
419 |
] |
|
2718 | 420 |
]. |
421 |
||
422 |
(extensionsPresent \ extensionsListed) do:[:clsAndSel| |
|
2797 | 423 |
self addProblem: |
424 |
(ProjectProblem newExtensionMethodNotListed |
|
425 |
className: clsAndSel first selector: clsAndSel second). |
|
2718 | 426 |
]. |
427 |
||
3791 | 428 |
allOtherExtensions := Set new. |
429 |
ProjectDefinition allSubclassesDo:[:eachOther | |
|
430 |
eachOther ~~ currentPackageDef ifTrue:[ |
|
3805 | 431 |
Error handle:[:ex | |
432 |
Transcript showCR:('ProjetChecker [warning]: ignored error while asking ',eachOther name,' for extensionMethods'). |
|
433 |
ex return |
|
434 |
] do:[ |
|
435 |
allOtherExtensions addAll:(eachOther extensionMethods). |
|
436 |
]. |
|
3791 | 437 |
]. |
438 |
]. |
|
439 |
||
440 |
checkMethod := |
|
441 |
[:eachMethodHere | |
|
442 |
(allOtherExtensions includes:eachMethodHere) ifTrue:[ |
|
443 |
|otherProjectDefinitions| |
|
444 |
||
445 |
otherProjectDefinitions := OrderedCollection new. |
|
446 |
"/ where is it? |
|
447 |
ProjectDefinition allSubclassesDo:[:someOtherPackage | |
|
448 |
someOtherPackage ~~ currentPackageDef ifTrue:[ |
|
449 |
(someOtherPackage extensionMethods includes:eachMethodHere) ifTrue:[ |
|
450 |
otherProjectDefinitions add:someOtherPackage |
|
451 |
] |
|
452 |
] |
|
453 |
]. |
|
454 |
otherProjectDefinitions notEmptyOrNil ifTrue:[ |
|
455 |
otherProjectDefinitions sortBySelector:#package. |
|
456 |
self addProblem: |
|
457 |
(ProjectProblem newMethodListedInOtherPackage |
|
458 |
className: (eachMethodHere mclass name) selector: (eachMethodHere selector); |
|
459 |
otherProjectDefinitionClasses:otherProjectDefinitions; |
|
460 |
yourself). |
|
461 |
]. |
|
462 |
]. |
|
463 |
]. |
|
464 |
||
3795 | 465 |
currentPackageDef compiled_classesForPlatform do:[:eachClass | |
3791 | 466 |
eachClass instAndClassMethodsDo:[:m | |
467 |
(m package = currentPackage) ifTrue:[ checkMethod value:m]. |
|
468 |
]. |
|
469 |
]. |
|
470 |
currentPackageDef extensions do:checkMethod. |
|
2718 | 471 |
! |
472 |
||
473 |
checkExtensionsPrerequisites |
|
474 |
"Checks whether packages of all extensions method classes are listed |
|
475 |
in package prerequisites" |
|
476 |
||
3116 | 477 |
|preRequisites| |
478 |
||
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
479 |
preRequisites := currentPackageDef effectivePreRequisites. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
480 |
currentPackageDef searchForExtensions do:[:mthd| |
3116 | 481 |
(preRequisites includes: mthd mclass package) ifFalse:[ |
2797 | 482 |
"/ self problem: ('%3 required by extension method but not in prerequisites' bindWith: mthd mclass package) |
483 |
"/ description: ('An extension method %1>>%2 extends class in package %3 but the package is not listed in package''s prerequisited. This leads into missing methods and strange bugs when application is compiled and run!!' bindWith: mthd class with: mthd selector with: mthd class package) |
|
484 |
"/ severity: #error data: mthd |
|
2718 | 485 |
]. |
486 |
] |
|
487 |
||
488 |
"Created: / 12-01-2012 / 12:41:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2797 | 489 |
! |
490 |
||
2853 | 491 |
checkMethodCodingStyle: method |
492 |
"Checks for various coding style violations such as 'self halt' or |
|
493 |
improper indentation :-)" |
|
494 |
||
495 |
"To be implemented" |
|
496 |
||
497 |
"Created: / 11-04-2012 / 12:38:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
498 |
! |
|
499 |
||
3161 | 500 |
checkMethodSTCCompilability1: method into: problemIssue |
2853 | 501 |
"Checks is the method can be compiled by STC based on Parser error/warnings" |
502 |
||
3161 | 503 |
| lang compiler | |
504 |
||
2853 | 505 |
lang := method programmingLanguage. |
506 |
lang isSmalltalk ifFalse:[ ^ self ]. |
|
507 |
||
3161 | 508 |
compiler := lang compilerClass new. |
509 |
compiler |
|
2853 | 510 |
compile:method source |
511 |
forClass:method mclass |
|
512 |
inCategory:'others' |
|
3161 | 513 |
notifying:problemIssue |
2853 | 514 |
install:false |
515 |
skipIfSame:false |
|
516 |
silent:false |
|
517 |
foldConstants:true |
|
3161 | 518 |
ifFail:[ ]. |
519 |
||
520 |
compiler usedGlobals do:[:nm | |
|
521 |
(nm startsWith:Smalltalk undeclaredPrefix) ifTrue:[ |
|
522 |
problemIssue |
|
523 |
addWarning:'Contains unresolved reference to: ',(nm copyFrom:(Smalltalk undeclaredPrefix size + 1)) |
|
524 |
from:0 to:0 |
|
525 |
] |
|
526 |
]. |
|
2853 | 527 |
|
528 |
"Created: / 11-04-2012 / 15:31:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
529 |
! |
|
530 |
||
3161 | 531 |
checkMethodSTCCompilability2: method into: problemIssue |
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
532 |
| env rules violations | |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
533 |
|
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
534 |
"/ Check if SmallLint is available... |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
535 |
(Smalltalk at:#RBCompositeLintRule) isNil ifTrue:[ ^ self ]. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
536 |
|
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
537 |
env := SelectorEnvironment new. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
538 |
env addClass: method mclass selector: method selector. |
2853 | 539 |
|
3686 | 540 |
rulesApplied isNil ifTrue:[ |
541 |
rulesApplied := RBCompositeLintRule allRules |
|
3804 | 542 |
selectRules:[:rule | (rule isTaggedAs: #stc) and:[ rule severity == #error ]]. |
3686 | 543 |
]. |
544 |
rules := rulesApplied. |
|
545 |
||
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
546 |
rules runOnEnvironment: env. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
547 |
|
3804 | 548 |
violations := rules selectRules:[:each | each result includesSelector: method selector in: method mclass ]. |
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
549 |
violations flatten do:[:each | |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
550 |
problemIssue addViolation: each |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
551 |
]. |
2853 | 552 |
|
553 |
"Created: / 11-04-2012 / 15:54:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
554 |
"Modified: / 29-05-2014 / 16:59:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2853 | 555 |
! |
556 |
||
557 |
checkMethodSTCCompilability: method |
|
558 |
"Checks is the method can be compiled by STC (since STC won't compile |
|
559 |
everything bytecode compiler/jit compiler does, sigh" |
|
560 |
||
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
561 |
| cls issue1 issue2 | |
2853 | 562 |
|
563 |
"No need to check the method if the class is autoloaded" |
|
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
564 |
cls := method mclass theNonMetaclass. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
565 |
cls isPrivate ifTrue:[ |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
566 |
cls := cls topOwningClass. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
567 |
]. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
568 |
(currentPackageDef autoloaded_classNames includes: cls name) ifTrue:[ |
2853 | 569 |
^ self |
570 |
]. |
|
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
571 |
|
3570
52c403d0b881
Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3563
diff
changeset
|
572 |
"/ Speed optimization: do not check method if it was compiled by |
52c403d0b881
Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3563
diff
changeset
|
573 |
"/ stc and hasn't been changed since then. |
52c403d0b881
Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3563
diff
changeset
|
574 |
method byteCode isNil ifTrue:[ ^ self ]. |
52c403d0b881
Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3563
diff
changeset
|
575 |
|
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
576 |
issue1 := ProjectProblem newMethodCompilabilityIssue1. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
577 |
issue1 method: method. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
578 |
self checkMethodSTCCompilability1: method into: issue1. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
579 |
issue1 hasIssue ifTrue:[ |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
580 |
self addProblem: issue1 |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
581 |
]. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
582 |
|
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
583 |
issue2 := ProjectProblem newMethodCompilabilityIssue2. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
584 |
issue2 method: method. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
585 |
self checkMethodSTCCompilability2: method into: issue2. |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
586 |
issue2 hasIssue ifTrue:[ |
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
587 |
self addProblem: issue2 |
2853 | 588 |
] |
589 |
||
590 |
"Created: / 11-04-2012 / 12:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3570
52c403d0b881
Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3563
diff
changeset
|
591 |
"Modified (format): / 29-05-2014 / 16:54:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2853 | 592 |
! |
593 |
||
594 |
checkMethodSourceCode: method |
|
595 |
"Checks, whether method's source code is both |
|
596 |
available and parseable. Return true if the code |
|
2966
bf5ea36104cd
Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents:
2965
diff
changeset
|
597 |
is syntactically correct, false otherwise" |
2853 | 598 |
|
599 |
| source | |
|
600 |
||
601 |
[ |
|
602 |
source := method source. |
|
603 |
] on: Error do:[ |
|
604 |
self addProblem: |
|
605 |
(ProjectProblem newMethodSourceNotAvailable method: method). |
|
606 |
^false |
|
607 |
]. |
|
2913 | 608 |
method programmingLanguage isSmalltalk ifFalse:[ ^ false ]. |
609 |
||
2853 | 610 |
[ |
611 |
(Parser parseMethod: method source) == #Error ifTrue:[ |
|
612 |
self addProblem: |
|
613 |
(ProjectProblem newMethodSourceCorrupted method: method). |
|
614 |
^false. |
|
615 |
] |
|
616 |
] on: Error do:[ |
|
617 |
self addProblem: |
|
618 |
(ProjectProblem newMethodSourceCorrupted method: method). |
|
619 |
^false. |
|
620 |
]. |
|
621 |
||
622 |
^true |
|
623 |
||
624 |
"Created: / 11-04-2012 / 12:29:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4078 | 625 |
! |
626 |
||
627 |
checkSubProjects |
|
628 |
"Checks whether all subprojects listed in #subprojects are present." |
|
629 |
||
630 |
|isValidName subProjectsListed invalidNames validNames subProjectsNotPresent| |
|
631 |
||
632 |
isValidName := |
|
633 |
[:prj | |
|
634 |
(prj first isLetter |
|
635 |
and:[ ((prj occurrencesOf:$:) <= 1) |
|
636 |
and:[ ((prj copyReplaceAll:$: with:$/) |
|
637 |
conform:[:ch | ch isLetterOrDigit or:['/-_.' includes:ch]]) ]]) |
|
638 |
]. |
|
639 |
||
640 |
subProjectsListed := currentPackageDef subProjects. |
|
641 |
invalidNames := subProjectsListed select:[:prj | (isValidName value:prj) not]. |
|
642 |
validNames := subProjectsListed select:isValidName. |
|
643 |
||
644 |
subProjectsNotPresent := validNames select:[:prj | prj asPackageId projectDefinitionClass isNil]. |
|
645 |
||
646 |
invalidNames do:[:eachBadName | |
|
647 |
self addProblem: (ProjectProblem newInvalidPackageName badName:eachBadName). |
|
648 |
]. |
|
649 |
subProjectsNotPresent do:[:eachMissing | |
|
650 |
self addProblem: (ProjectProblem newProjectDefinitionDoesNotExist missing: eachMissing). |
|
651 |
]. |
|
2707 | 652 |
! ! |
653 |
||
654 |
!ProjectChecker methodsFor:'checks-private'! |
|
655 |
||
656 |
checkClasses |
|
3535
f02b2535dd15
Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3508
diff
changeset
|
657 |
| classesToCheck | |
f02b2535dd15
Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3508
diff
changeset
|
658 |
|
f02b2535dd15
Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3508
diff
changeset
|
659 |
classesToCheck := classes notNil ifTrue:[ classes ] ifFalse:[ Smalltalk allClasses ]. |
3618
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
660 |
classesToCheck := classesToCheck select:[:each | each programmingLanguage isSmalltalk and:[ each package = currentPackage ] ]. |
3589 | 661 |
|
662 |
(currentPackageDef notNil and:[currentPackageDef isFolderForProjectsDefinition]) ifTrue:[ |
|
663 |
classesToCheck remove:currentPackageDef ifAbsent:[] |
|
664 |
]. |
|
665 |
||
3535
f02b2535dd15
Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3508
diff
changeset
|
666 |
self checkClasses: classesToCheck. |
2707 | 667 |
|
3589 | 668 |
(currentPackageDef notNil and:[currentPackageDef isFolderForProjectsDefinition]) ifTrue:[ |
669 |
classesToCheck do:[:eachClass | |
|
670 |
self addProblem: |
|
671 |
(ProjectProblem newClassShouldNotBeInPackage className: eachClass name). |
|
672 |
]. |
|
673 |
]. |
|
674 |
||
2707 | 675 |
"Created: / 11-01-2012 / 16:55:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3618
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
676 |
"Modified: / 31-07-2014 / 09:47:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2707 | 677 |
! |
678 |
||
2797 | 679 |
checkClasses: classesToCheck |
680 |
||
681 |
self checkClassesListedInProjectDefinition: classesToCheck. |
|
2910 | 682 |
self checkClassesForMethodsInNoProject:classesToCheck. |
683 |
self checkClassesForNonQualifiedSharedPools:classesToCheck. |
|
3467 | 684 |
self checkClassesAutoloadedSuperclasse:classesToCheck. |
2797 | 685 |
|
686 |
"Created: / 13-02-2012 / 18:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3467 | 687 |
"Modified: / 20-09-2013 / 11:08:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2797 | 688 |
! |
689 |
||
2853 | 690 |
checkMethod: method |
3618
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
691 |
method programmingLanguage isSmalltalk ifTrue:[ |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
692 |
(self checkMethodSourceCode: method) ifTrue:[ |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
693 |
"/OK, method's source code is fine, perform more checks on |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
694 |
"/ it's source code. |
3563
1590b29dbdef
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3548
diff
changeset
|
695 |
|
3618
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
696 |
"/ ActivityNotification raiseRequestWith:self errorString:'Checking stc compilability...'. |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
697 |
self checkMethodSTCCompilability: method. |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
698 |
"/ ActivityNotification raiseRequestWith:self errorString:'Checking coding style...'. |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
699 |
self checkMethodCodingStyle: method. |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
700 |
] |
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
701 |
]. |
2853 | 702 |
|
703 |
"Created: / 11-04-2012 / 12:27:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3618
851e57ea8ad1
Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3607
diff
changeset
|
704 |
"Modified: / 31-07-2014 / 09:48:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2853 | 705 |
! |
706 |
||
2707 | 707 |
checkMethods |
2853 | 708 |
methods notEmptyOrNil ifTrue:[ |
709 |
self checkMethods: methods. |
|
710 |
^self. |
|
711 |
]. |
|
712 |
||
713 |
self checkMethods: |
|
714 |
(Iterator on:[:whatToDo| |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
715 |
| classesToCheck | |
3233 | 716 |
|
717 |
classes notNil ifTrue:[ |
|
718 |
classesToCheck := classes |
|
719 |
] ifFalse:[ |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
720 |
classesToCheck := (Smalltalk allClasses select:[:cls | (cls package = currentPackage)]). |
3233 | 721 |
]. |
722 |
classesToCheck do:[:cls| |
|
723 |
cls theNonMetaclass withAllPrivateClassesDo:[:eachClass | |
|
724 |
ActivityNotification raiseRequestWith:self errorString:('Checking %1...' bindWith:eachClass name). |
|
725 |
eachClass instAndClassSelectorsAndMethodsDo:[:s :m | |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
726 |
m package = currentPackage ifTrue:[ |
3148 | 727 |
((checkExtensionsOnly ? false) not |
728 |
or:[ m package ~~ cls package "isExtension" ]) ifTrue:[ |
|
729 |
whatToDo value:m |
|
730 |
] |
|
731 |
] |
|
732 |
] |
|
2853 | 733 |
]. |
734 |
] |
|
735 |
]) |
|
2707 | 736 |
|
737 |
"Created: / 11-01-2012 / 16:55:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
738 |
"Modified: / 22-02-2014 / 21:48:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2707 | 739 |
! |
740 |
||
2853 | 741 |
checkMethods: methodsToCheck |
742 |
||
743 |
methodsToCheck do:[:m|self checkMethod: m]. |
|
744 |
||
745 |
"Created: / 11-04-2012 / 12:16:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
746 |
! |
|
747 |
||
2707 | 748 |
checkPackage |
4078 | 749 |
currentPackageDef isNil ifTrue:[^ self]. |
750 |
currentPackageDef isFolderForProjectsDefinition ifFalse:[ |
|
751 |
(checkExtensionsOnly ? false) ifFalse:[ |
|
752 |
self checkClassListConsistency. |
|
753 |
]. |
|
754 |
self checkExtensionsListConsistency. |
|
755 |
self checkExtensionsPrerequisites. |
|
3148 | 756 |
]. |
4078 | 757 |
self checkSubProjects. |
2718 | 758 |
|
2716
9a74597bcd4b
Do not use annotations as stc crashes when compiling them
vrany
parents:
2707
diff
changeset
|
759 |
"add more here..." |
2707 | 760 |
|
761 |
"Created: / 11-01-2012 / 16:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
762 |
! ! |
|
763 |
||
2910 | 764 |
!ProjectChecker methodsFor:'initialization'! |
765 |
||
766 |
initialize |
|
767 |
"Invoked when a new instance is created." |
|
768 |
||
769 |
"/ please change as required (and remove this comment) |
|
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
770 |
packages := OrderedCollection new. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
771 |
"/ currentPackage := nil. |
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
772 |
"/ currentPackageDef := nil. |
2910 | 773 |
"/ classes := nil. |
774 |
"/ methods := nil. |
|
775 |
problems := List new. |
|
776 |
"/ phase := nil. |
|
777 |
||
778 |
"/ super initialize. -- commented since inherited method does nothing |
|
779 |
||
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
780 |
"Modified: / 22-02-2014 / 21:41:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2910 | 781 |
! ! |
782 |
||
2707 | 783 |
!ProjectChecker methodsFor:'reporting'! |
784 |
||
2797 | 785 |
addProblem: aProjectProblem |
3807 | 786 |
Transcript showCR:aProjectProblem. |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
787 |
aProjectProblem package: currentPackage. |
2707 | 788 |
problems isNil ifTrue:[problems := OrderedCollection new]. |
3548 | 789 |
problems add: aProjectProblem. |
790 |
aProjectProblem allProblems:problems. |
|
2707 | 791 |
|
2797 | 792 |
"Created: / 23-02-2012 / 13:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3508
dd0e9fe9c7e2
Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3467
diff
changeset
|
793 |
"Modified: / 22-02-2014 / 21:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2718 | 794 |
! ! |
795 |
||
2707 | 796 |
!ProjectChecker class methodsFor:'documentation'! |
797 |
||
798 |
version |
|
4078 | 799 |
^ '$Header$' |
3167 | 800 |
! |
801 |
||
802 |
version_CVS |
|
4078 | 803 |
^ '$Header$' |
2707 | 804 |
! |
805 |
||
2797 | 806 |
version_SVN |
4078 | 807 |
^ '$Id$' |
2707 | 808 |
! ! |
3116 | 809 |