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