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