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