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