author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 29 Mar 2013 19:43:35 +0000 | |
branch | jv |
changeset 3206 | d720d5883a49 |
parent 3158 | f8c56a311307 |
child 3208 | e8bdf898d7ac |
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 |
||
14 |
Object subclass:#ProjectChecker |
|
3148 | 15 |
instanceVariableNames:'package packageDef classes methods problems phase |
16 |
checkExtensionsOnly' |
|
2967 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'System-Support-Projects' |
|
2707 | 20 |
! |
21 |
||
2797 | 22 |
!ProjectChecker class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
2707 | 36 |
! |
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
A simple project checker that can search whole projects or individual |
|
2853 | 41 |
classes or methods for various problems that may cause build problems such |
42 |
as: |
|
43 |
- inconsistent/messed up project definition class |
|
44 |
- method code problems |
|
2707 | 45 |
|
46 |
NOTE: Not yet finished. This code is meant as a single central entry for all the |
|
47 |
source code management tools like SCM Utilities, NewSystemBrowser ets. That code |
|
2797 | 48 |
will be refactored later once this tool prooves itself useful and mature enough. |
2707 | 49 |
|
50 |
[author:] |
|
51 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
52 |
||
53 |
[instance variables:] |
|
54 |
||
55 |
[class variables:] |
|
56 |
||
57 |
[see also:] |
|
2853 | 58 |
Tools::ProjectCheckerBrowser |
2707 | 59 |
|
60 |
" |
|
61 |
! |
|
62 |
||
63 |
examples |
|
64 |
||
65 |
" |
|
66 |
ProjectChecker check: 'stx:libbasic' |
|
2797 | 67 |
ProjectChecker check: 'stx:libtool' |
68 |
ProjectChecker check: 'stx:libbasic3' |
|
2707 | 69 |
" |
70 |
! ! |
|
71 |
||
2853 | 72 |
!ProjectChecker class methodsFor:'instance creation'! |
73 |
||
74 |
forPackage: packageId |
|
75 |
^self new |
|
76 |
package: packageId; |
|
77 |
yourself. |
|
78 |
||
79 |
"Created: / 25-07-2012 / 18:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2910 | 80 |
! |
81 |
||
82 |
new |
|
83 |
"return an initialized instance" |
|
84 |
||
85 |
^ self basicNew initialize. |
|
2853 | 86 |
! ! |
87 |
||
2707 | 88 |
!ProjectChecker class methodsFor:'checking'! |
89 |
||
90 |
check: package |
|
91 |
||
92 |
^self new check: package |
|
93 |
||
94 |
"Created: / 11-01-2012 / 16:46:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
95 |
! ! |
|
96 |
||
2910 | 97 |
!ProjectChecker class methodsFor:'others'! |
98 |
||
99 |
version_CVS |
|
3148 | 100 |
^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.14 2013-03-27 16:48:30 cg Exp $' |
2910 | 101 |
! ! |
102 |
||
2707 | 103 |
!ProjectChecker methodsFor:'accessing'! |
104 |
||
3148 | 105 |
checkExtensionsOnly:aBoolean |
106 |
checkExtensionsOnly := aBoolean. |
|
107 |
! |
|
108 |
||
2797 | 109 |
classes: aCollection |
110 |
classes := aCollection. |
|
111 |
||
112 |
"Created: / 13-02-2012 / 17:06:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
113 |
! |
|
114 |
||
115 |
methods |
|
116 |
^ methods |
|
117 |
! |
|
118 |
||
119 |
methods:something |
|
120 |
methods := something. |
|
121 |
! |
|
122 |
||
2707 | 123 |
package |
124 |
^ package |
|
125 |
! |
|
126 |
||
127 |
package:packageId |
|
2853 | 128 |
package := packageId asSymbol. |
129 |
||
130 |
"Modified: / 11-04-2012 / 16:00:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2797 | 131 |
! |
132 |
||
133 |
problems |
|
2853 | 134 |
^ problems |
2797 | 135 |
|
136 |
"Modified: / 23-02-2012 / 15:14:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2707 | 137 |
! ! |
138 |
||
139 |
!ProjectChecker methodsFor:'checking'! |
|
140 |
||
141 |
check |
|
142 |
||
2910 | 143 |
problems removeAll. |
2797 | 144 |
packageDef := ProjectDefinition definitionClassForPackage: package. |
145 |
packageDef isNil ifTrue:[ |
|
146 |
self addProblem: |
|
147 |
(ProjectProblem newProjectDefinitionDoesNotExist package: package). |
|
148 |
^self |
|
149 |
]. |
|
150 |
||
3148 | 151 |
ActivityNotification raiseRequestWith:self errorString:'Checking package...'. |
152 |
self checkPackage. |
|
153 |
(checkExtensionsOnly ? false) ifFalse:[ |
|
154 |
ActivityNotification raiseRequestWith:self errorString:'Checking classes...'. |
|
155 |
self checkClasses. |
|
156 |
]. |
|
157 |
ActivityNotification raiseRequestWith:self errorString:'Checking methods...'. |
|
158 |
self checkMethods. |
|
2707 | 159 |
|
160 |
"Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
161 |
! |
|
162 |
||
163 |
check: package |
|
164 |
||
165 |
self package: package. |
|
166 |
self check. |
|
167 |
||
168 |
"Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
169 |
! ! |
|
170 |
||
171 |
!ProjectChecker methodsFor:'checks-individual'! |
|
172 |
||
173 |
checkClassListConsistency |
|
174 |
"Checks whether all classes listed in #classNamesAndAttributes are present |
|
175 |
and if all present classes are listed" |
|
176 |
||
2910 | 177 |
|classesInImage classesInDescription classesInDescriptionChecked onlyInDescription| |
2707 | 178 |
"WARNING: Copy/paste of ProjectDefinition>>validateDescription" |
179 |
||
180 |
classesInImage := Smalltalk allClasses select:[:cls | (cls package = self package) and:[cls isPrivate not]]. |
|
181 |
"/ classesInDescription := self classes asIdentitySet. |
|
2910 | 182 |
classesInDescription := OrderedCollection new. |
2967 | 183 |
( (packageDef compiled_classNames_common) |
184 |
, (packageDef compiled_classNamesForPlatform:(OperatingSystem platformName)) |
|
2707 | 185 |
, (packageDef autoloaded_classNames)) do:[:nm | |
186 |
|cls| |
|
187 |
||
188 |
cls := Smalltalk at:nm asSymbol. |
|
189 |
cls isNil ifTrue:[ |
|
2797 | 190 |
self addProblem: |
191 |
(ProjectProblem newClassListedButDoesNotExist className: nm) |
|
2707 | 192 |
] ifFalse:[ |
193 |
classesInDescription add:cls. |
|
194 |
]. |
|
195 |
]. |
|
196 |
||
2910 | 197 |
classesInDescriptionChecked := OrderedCollection new. |
2707 | 198 |
classesInDescription do:[:eachClass | |
2910 | 199 |
(classesInDescriptionChecked includes: eachClass) ifTrue:[ |
200 |
self addProblem: |
|
201 |
(ProjectProblem newClassListedMultipleTimes |
|
202 |
className: eachClass name) |
|
203 |
]. |
|
204 |
||
2707 | 205 |
eachClass sharedPoolNames do:[:eachPoolName | |
206 |
|pool| |
|
207 |
||
208 |
pool := eachClass nameSpace classNamed:eachPoolName. |
|
209 |
pool isNil ifTrue:[ |
|
210 |
eachClass nameSpace ~~ Smalltalk ifTrue:[ |
|
211 |
pool := Smalltalk classNamed:eachPoolName. |
|
212 |
] |
|
213 |
]. |
|
214 |
pool isNil ifTrue:[ |
|
2797 | 215 |
self addProblem: |
216 |
(ProjectProblem newClassUsesPoolButItDoesNotExist |
|
217 |
className: eachClass name; |
|
218 |
poolName: eachPoolName). |
|
2707 | 219 |
] ifFalse:[ |
220 |
pool isSharedPool ifFalse:[ |
|
2797 | 221 |
self addProblem: |
222 |
(ProjectProblem newClassUsesPoolButItIsNotASharedPool |
|
223 |
className: eachClass name; |
|
224 |
poolName: eachPoolName). |
|
2707 | 225 |
]. |
226 |
]. |
|
227 |
]. |
|
2910 | 228 |
|
2966
bf5ea36104cd
Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents:
2965
diff
changeset
|
229 |
(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
|
230 |
and:[eachClass superclass package == eachClass package]) ifTrue:[ |
2910 | 231 |
(classesInDescriptionChecked includes: eachClass superclass) ifFalse:[ |
232 |
self addProblem: |
|
233 |
(ProjectProblem newClassListedBeforeItsSuperclass |
|
234 |
className: eachClass name; |
|
235 |
superClassName: eachClass superclass name) |
|
236 |
]. |
|
237 |
]. |
|
238 |
eachClass sharedPools do:[:eachPool| |
|
239 |
eachPool package == eachClass package ifTrue:[ |
|
240 |
(classesInDescriptionChecked includes: eachPool) ifFalse:[ |
|
241 |
self addProblem: |
|
242 |
(ProjectProblem newClassListedBeforeItsPool |
|
243 |
className: eachClass name; |
|
244 |
poolName: eachPool name) |
|
245 |
]. |
|
246 |
]. |
|
247 |
]. |
|
248 |
||
249 |
classesInDescriptionChecked add: eachClass. |
|
2707 | 250 |
]. |
251 |
||
252 |
classesInImage ~= classesInDescription ifTrue:[ |
|
2856
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
253 |
"This is done later in checkClassesListedInProjectDefinition:" |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
254 |
"/ onlyInImage := (classesInImage reject:[:cls | classesInDescription includes:cls]). |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
255 |
"/ onlyInImage do:[:cls| |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
256 |
"/ self addProblem: |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
257 |
"/ (ProjectProblem newClassNotListed className: cls name). |
a1cee28488c0
changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents:
2853
diff
changeset
|
258 |
"/ ]. |
2707 | 259 |
onlyInDescription := (classesInDescription reject:[:cls | classesInImage includes:cls]). |
260 |
onlyInDescription do:[:cls| |
|
2797 | 261 |
self addProblem: |
262 |
(ProjectProblem newClassListedButDoesNotExist className: cls name) |
|
2707 | 263 |
]. |
264 |
]. |
|
265 |
||
266 |
"Created: / 11-01-2012 / 17:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2967 | 267 |
"Modified: / 31-10-2012 / 17:40:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2718 | 268 |
! |
269 |
||
2910 | 270 |
checkClassesForMethodsInNoProject:classesToCheck |
271 |
| checker | |
|
272 |
||
273 |
checker := [:cls | |
|
274 |
cls |
|
275 |
selectorsAndMethodsDo:[:sel :mth | |
|
276 |
(mth package isNil or:[ mth package == PackageId noProjectID ]) ifTrue:[ |
|
277 |
"Sigh, special hack for Expecco" |
|
278 |
((cls name = 'Expecco::AbstractApplication class' and:[ sel = 'flags' ]) or:[ |
|
279 |
(cls name = 'Expecco::Browser class' and:[ sel = 'flags' ])]) ifFalse:[ |
|
280 |
self addProblem:(ProjectProblem newMethodInNoPackage className:cls name |
|
281 |
selector:sel). |
|
282 |
] |
|
283 |
] |
|
284 |
] |
|
285 |
]. |
|
286 |
classesToCheck do:[:class | |
|
287 |
checker value:class theMetaclass. |
|
288 |
checker value:class theNonMetaclass. |
|
289 |
] |
|
290 |
||
291 |
"Created: / 13-02-2012 / 18:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
292 |
! |
|
293 |
||
294 |
checkClassesForNonQualifiedSharedPools: classesToCheck |
|
295 |
||
296 |
classesToCheck do:[:cls| |
|
297 |
cls sharedPoolNames do:[:poolName| |
|
298 |
(Smalltalk at: poolName asSymbol) isNil ifTrue:[ |
|
299 |
| ns | |
|
300 |
||
301 |
ns := cls nameSpace. |
|
302 |
(ns ~~ Smalltalk and:[(ns at: poolName asSymbol) notNil]) ifTrue:[ |
|
303 |
self addProblem: |
|
304 |
(ProjectProblem newClassUsesPoolButItIsNotASharedPool |
|
305 |
className: cls name; |
|
306 |
poolName: poolName) |
|
307 |
] |
|
308 |
] |
|
309 |
] |
|
310 |
]. |
|
311 |
||
312 |
"Created: / 13-09-2012 / 16:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
313 |
! |
|
314 |
||
2797 | 315 |
checkClassesListedInProjectDefinition: classesToCheck |
316 |
||
317 |
| classNamesListed | |
|
318 |
||
319 |
classNamesListed := packageDef classNames. |
|
320 |
||
321 |
classesToCheck do:[:class| |
|
322 |
(class isPrivate not and:[(classNamesListed includes: class name) not]) ifTrue:[ |
|
323 |
self addProblem: |
|
324 |
(ProjectProblem newClassNotListed className: class name). |
|
325 |
] |
|
326 |
]. |
|
327 |
||
328 |
"Created: / 13-02-2012 / 18:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
329 |
! |
|
330 |
||
2718 | 331 |
checkExtensionsListConsistency |
332 |
"Checks whether all extensions listed in #extensionMethodNames are present |
|
333 |
and if all extension methods are listed" |
|
334 |
||
335 |
| extensionsListed extensionsPresent | |
|
336 |
||
337 |
extensionsListed := OrderedCollection new. |
|
338 |
packageDef extensionMethodNames pairWiseDo:[:cls :sel| |
|
339 |
extensionsListed add: (Array with: cls with: sel) |
|
340 |
]. |
|
341 |
extensionsPresent := OrderedCollection new. |
|
342 |
packageDef searchForExtensions do:[:each| |
|
2910 | 343 |
"JV@2012-09-07: Do not take Java methods into an account, they |
344 |
should not be listed in extensionMethodNames. |
|
345 |
They are loaded lazily by JavaClassReader and if listed here, |
|
346 |
they would cause an error if the package is loaded from source. |
|
347 |
Sort of a HACK, indeed" |
|
3206
d720d5883a49
Fix in ProjectChecker>>checkExtensionsListConsistency.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3158
diff
changeset
|
348 |
each mclass theNonMetaclass isJavaClass ifFalse:[ |
2910 | 349 |
extensionsPresent add: (Array with: each mclass name with: each selector) |
350 |
]. |
|
2718 | 351 |
]. |
352 |
||
353 |
(extensionsListed \ extensionsPresent) do:[:clsAndSel| |
|
2797 | 354 |
self addProblem: |
355 |
(ProjectProblem newExtensionMethodListedButDoesNotExist |
|
356 |
className: clsAndSel first selector: clsAndSel second). |
|
2718 | 357 |
]. |
358 |
||
359 |
(extensionsPresent \ extensionsListed) do:[:clsAndSel| |
|
2797 | 360 |
self addProblem: |
361 |
(ProjectProblem newExtensionMethodNotListed |
|
362 |
className: clsAndSel first selector: clsAndSel second). |
|
2718 | 363 |
]. |
364 |
||
365 |
"Created: / 12-01-2012 / 12:31:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3206
d720d5883a49
Fix in ProjectChecker>>checkExtensionsListConsistency.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3158
diff
changeset
|
366 |
"Modified: / 29-03-2013 / 19:41:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2718 | 367 |
! |
368 |
||
369 |
checkExtensionsPrerequisites |
|
370 |
"Checks whether packages of all extensions method classes are listed |
|
371 |
in package prerequisites" |
|
372 |
||
3116 | 373 |
|preRequisites| |
374 |
||
375 |
preRequisites := packageDef effectivePreRequisites. |
|
2718 | 376 |
packageDef searchForExtensions do:[:mthd| |
3116 | 377 |
(preRequisites includes: mthd mclass package) ifFalse:[ |
2797 | 378 |
"/ self problem: ('%3 required by extension method but not in prerequisites' bindWith: mthd mclass package) |
379 |
"/ 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) |
|
380 |
"/ severity: #error data: mthd |
|
2718 | 381 |
]. |
382 |
] |
|
383 |
||
384 |
"Created: / 12-01-2012 / 12:41:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2797 | 385 |
! |
386 |
||
2853 | 387 |
checkMethodCodingStyle: method |
388 |
"Checks for various coding style violations such as 'self halt' or |
|
389 |
improper indentation :-)" |
|
390 |
||
391 |
"To be implemented" |
|
392 |
||
393 |
"Created: / 11-04-2012 / 12:38:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
394 |
! |
|
395 |
||
396 |
checkMethodSTCCompilability1: method into: problem |
|
397 |
"Checks is the method can be compiled by STC based on Parser error/warnings" |
|
398 |
||
399 |
| lang | |
|
400 |
lang := method programmingLanguage. |
|
401 |
lang isSmalltalk ifFalse:[ ^ self ]. |
|
402 |
||
403 |
lang compilerClass new |
|
404 |
compile:method source |
|
405 |
forClass:method mclass |
|
406 |
inCategory:'others' |
|
407 |
notifying:problem |
|
408 |
install:false |
|
409 |
skipIfSame:false |
|
410 |
silent:false |
|
411 |
foldConstants:true |
|
412 |
ifFail:[ ] |
|
413 |
||
414 |
"Created: / 11-04-2012 / 15:31:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
415 |
! |
|
416 |
||
417 |
checkMethodSTCCompilability2: method into: problem |
|
418 |
"Checks is the method can be compiled by STC based on selected lint rules" |
|
419 |
||
420 |
"Not yet implemented" |
|
421 |
||
422 |
"Created: / 11-04-2012 / 15:54:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
423 |
! |
|
424 |
||
425 |
checkMethodSTCCompilability: method |
|
426 |
"Checks is the method can be compiled by STC (since STC won't compile |
|
427 |
everything bytecode compiler/jit compiler does, sigh" |
|
428 |
||
429 |
| issue | |
|
430 |
||
431 |
"No need to check the method if the class is autoloaded" |
|
432 |
(packageDef autoloaded_classNames includes: method mclass theNonMetaclass name) ifTrue:[ |
|
433 |
^ self |
|
434 |
]. |
|
435 |
||
436 |
issue := ProjectProblem newMethodCompilabilityIssue. |
|
437 |
issue method: method. |
|
438 |
self checkMethodSTCCompilability1: method into: issue. |
|
439 |
self checkMethodSTCCompilability2: method into: issue. |
|
440 |
issue hasIssue ifTrue:[ |
|
441 |
self addProblem: issue |
|
442 |
] |
|
443 |
||
444 |
"Created: / 11-04-2012 / 12:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
445 |
! |
|
446 |
||
447 |
checkMethodSourceCode: method |
|
448 |
"Checks, whether method's source code is both |
|
449 |
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
|
450 |
is syntactically correct, false otherwise" |
2853 | 451 |
|
452 |
| source | |
|
453 |
||
454 |
[ |
|
455 |
source := method source. |
|
456 |
] on: Error do:[ |
|
457 |
self addProblem: |
|
458 |
(ProjectProblem newMethodSourceNotAvailable method: method). |
|
459 |
^false |
|
460 |
]. |
|
2913 | 461 |
method programmingLanguage isSmalltalk ifFalse:[ ^ false ]. |
462 |
||
2853 | 463 |
[ |
464 |
(Parser parseMethod: method source) == #Error ifTrue:[ |
|
465 |
self addProblem: |
|
466 |
(ProjectProblem newMethodSourceCorrupted method: method). |
|
467 |
^false. |
|
468 |
] |
|
469 |
] on: Error do:[ |
|
470 |
self addProblem: |
|
471 |
(ProjectProblem newMethodSourceCorrupted method: method). |
|
472 |
^false. |
|
473 |
]. |
|
474 |
||
475 |
^true |
|
476 |
||
477 |
"Created: / 11-04-2012 / 12:29:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2707 | 478 |
! ! |
479 |
||
480 |
!ProjectChecker methodsFor:'checks-private'! |
|
481 |
||
482 |
checkClasses |
|
2976 | 483 |
|myPackage| |
2797 | 484 |
|
485 |
classes notNil ifTrue:[ |
|
486 |
self checkClasses: classes |
|
487 |
] ifFalse:[ |
|
2976 | 488 |
myPackage := self package. |
489 |
self checkClasses: (Smalltalk allClasses select:[:cls | (cls package = myPackage)]). |
|
2797 | 490 |
]. |
2707 | 491 |
|
492 |
"Created: / 11-01-2012 / 16:55:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
493 |
! |
|
494 |
||
2797 | 495 |
checkClasses: classesToCheck |
496 |
||
497 |
self checkClassesListedInProjectDefinition: classesToCheck. |
|
2910 | 498 |
self checkClassesForMethodsInNoProject:classesToCheck. |
499 |
self checkClassesForNonQualifiedSharedPools:classesToCheck. |
|
2797 | 500 |
|
501 |
"Created: / 13-02-2012 / 18:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
502 |
! |
|
503 |
||
2853 | 504 |
checkMethod: method |
505 |
(self checkMethodSourceCode: method) ifTrue:[ |
|
506 |
"/OK, method's source is OK, perform further checks |
|
3148 | 507 |
ActivityNotification raiseRequestWith:self errorString:'Checking stc compilability...'. |
2853 | 508 |
self checkMethodSTCCompilability: method. |
3148 | 509 |
ActivityNotification raiseRequestWith:self errorString:'Checking coding style...'. |
2853 | 510 |
self checkMethodCodingStyle: method. |
511 |
] |
|
512 |
||
513 |
"Created: / 11-04-2012 / 12:27:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
514 |
! |
|
515 |
||
2707 | 516 |
checkMethods |
2853 | 517 |
methods notEmptyOrNil ifTrue:[ |
518 |
self checkMethods: methods. |
|
519 |
^self. |
|
520 |
]. |
|
521 |
||
522 |
self checkMethods: |
|
523 |
(Iterator on:[:whatToDo| |
|
524 |
(classes notNil ifTrue:[classes] ifFalse:[Smalltalk allClasses]) do:[:cls| |
|
525 |
cls theNonMetaclass withAllPrivateClassesDo:[:each | |
|
3148 | 526 |
each instAndClassSelectorsAndMethodsDo:[:s :m | |
527 |
m package = package ifTrue:[ |
|
528 |
((checkExtensionsOnly ? false) not |
|
529 |
or:[ m package ~~ cls package "isExtension" ]) ifTrue:[ |
|
530 |
whatToDo value:m |
|
531 |
] |
|
532 |
] |
|
533 |
] |
|
2853 | 534 |
]. |
535 |
] |
|
536 |
]) |
|
2707 | 537 |
|
538 |
"Created: / 11-01-2012 / 16:55:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
539 |
! |
|
540 |
||
2853 | 541 |
checkMethods: methodsToCheck |
542 |
||
543 |
methodsToCheck do:[:m|self checkMethod: m]. |
|
544 |
||
545 |
"Created: / 11-04-2012 / 12:16:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
546 |
! |
|
547 |
||
2707 | 548 |
checkPackage |
3148 | 549 |
(checkExtensionsOnly ? false) ifFalse:[ |
550 |
self checkClassListConsistency. |
|
551 |
]. |
|
2718 | 552 |
self checkExtensionsListConsistency. |
553 |
self checkExtensionsPrerequisites. |
|
554 |
||
2716
9a74597bcd4b
Do not use annotations as stc crashes when compiling them
vrany
parents:
2707
diff
changeset
|
555 |
"add more here..." |
2707 | 556 |
|
557 |
"Created: / 11-01-2012 / 16:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
558 |
! ! |
|
559 |
||
2910 | 560 |
!ProjectChecker methodsFor:'initialization'! |
561 |
||
562 |
initialize |
|
563 |
"Invoked when a new instance is created." |
|
564 |
||
565 |
"/ please change as required (and remove this comment) |
|
566 |
"/ package := nil. |
|
567 |
"/ packageDef := nil. |
|
568 |
"/ classes := nil. |
|
569 |
"/ methods := nil. |
|
570 |
problems := List new. |
|
571 |
"/ phase := nil. |
|
572 |
||
573 |
"/ super initialize. -- commented since inherited method does nothing |
|
574 |
||
575 |
"Modified: / 13-09-2012 / 17:24:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
576 |
! ! |
|
577 |
||
2707 | 578 |
!ProjectChecker methodsFor:'reporting'! |
579 |
||
2797 | 580 |
addProblem: aProjectProblem |
581 |
aProjectProblem package: self package. |
|
2707 | 582 |
problems isNil ifTrue:[problems := OrderedCollection new]. |
2797 | 583 |
problems add: aProjectProblem |
2707 | 584 |
|
2797 | 585 |
"Created: / 23-02-2012 / 13:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2718 | 586 |
! ! |
587 |
||
2707 | 588 |
!ProjectChecker class methodsFor:'documentation'! |
589 |
||
590 |
version |
|
3148 | 591 |
^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.14 2013-03-27 16:48:30 cg Exp $' |
2707 | 592 |
! |
593 |
||
3206
d720d5883a49
Fix in ProjectChecker>>checkExtensionsListConsistency.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3158
diff
changeset
|
594 |
version_HG |
d720d5883a49
Fix in ProjectChecker>>checkExtensionsListConsistency.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3158
diff
changeset
|
595 |
|
d720d5883a49
Fix in ProjectChecker>>checkExtensionsListConsistency.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3158
diff
changeset
|
596 |
^ '$Changeset: <not expanded> $' |
d720d5883a49
Fix in ProjectChecker>>checkExtensionsListConsistency.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3158
diff
changeset
|
597 |
! |
d720d5883a49
Fix in ProjectChecker>>checkExtensionsListConsistency.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3158
diff
changeset
|
598 |
|
2797 | 599 |
version_SVN |
2966
bf5ea36104cd
Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents:
2965
diff
changeset
|
600 |
^ '§Id: ProjectChecker.st 1971 2012-09-27 19:37:25Z vranyj1 §' |
2707 | 601 |
! ! |
3116 | 602 |