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