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