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