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