author | sr |
Tue, 29 May 2018 16:08:50 +0200 | |
changeset 521 | 7e3fd75d2f1c |
parent 265 | eb1cc3afb10c |
permissions | -rw-r--r-- |
201 | 1 |
"{ Package: 'stx:goodies/builder/reports' }" |
2 |
||
3 |
"{ NameSpace: Builder }" |
|
4 |
||
5 |
ReportSourceInfo subclass:#ReportClassSourceInfo |
|
6 |
instanceVariableNames:'klass' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'Builder-Reports-Utils' |
|
10 |
! |
|
11 |
||
12 |
||
265
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
13 |
!ReportClassSourceInfo methodsFor:'accessing'! |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
14 |
|
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
15 |
pathNameAbsolute: aBoolean |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
16 |
"Return a path (as String) to file containing the source code. The file points to the |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
17 |
real source file. If `aBoolean` is true, then absolute path is returned, otherwise |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
18 |
realtive path to package root is returned." |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
19 |
|
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
20 |
| sourceFile packageDir | |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
21 |
|
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
22 |
sourceFile := klass classFilename notNil |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
23 |
ifTrue: [ klass classFilename ] |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
24 |
ifFalse: [ (Smalltalk fileNameForClass:klass) , '.st' ]. |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
25 |
packageDir := aBoolean |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
26 |
ifTrue:[ (Smalltalk getPackageDirectoryForPackage: package) pathName ] |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
27 |
ifFalse: [ package asString replaceAll: $: with: Filename separator; replaceAll: $/ with: Filename separator ]. |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
28 |
|
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
29 |
^ packageDir , Filename separator , sourceFile. |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
30 |
|
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
31 |
" |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
32 |
(Builder::ReportSourceInfo forClass: Object inPackage: 'stx:libbasic') pathNameAbsolute: true |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
33 |
(Builder::ReportSourceInfo forClass: Object inPackage: 'stx:libbasic') pathNameAbsolute: false |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
34 |
" |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
35 |
|
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
36 |
"Created: / 16-12-2014 / 10:25:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
37 |
! ! |
eb1cc3afb10c
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
255
diff
changeset
|
38 |
|
201 | 39 |
!ReportClassSourceInfo methodsFor:'initialization'! |
40 |
||
41 |
initializeWithPackage:aSymbolOrString class:aClass |
|
42 |
package := aSymbolOrString asSymbol. |
|
43 |
klass := aClass theNonMetaclass. |
|
44 |
self setup. |
|
45 |
||
46 |
"Created: / 29-07-2013 / 18:37:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
47 |
! ! |
|
48 |
||
49 |
!ReportClassSourceInfo methodsFor:'utilities'! |
|
50 |
||
51 |
fileOutOn:aStream |
|
52 |
| filter | |
|
53 |
||
54 |
"JV@2012-02-02: Do not fileout extensionVersion methods, that one is filed out |
|
55 |
when extensions are filed out." |
|
56 |
(klass inheritsFrom: ProjectDefinition) ifTrue:[ |
|
57 |
filter := [:m| m package = package |
|
58 |
and:[ (AbstractSourceCodeManager isExtensionsVersionMethodSelector:m selector) not |
|
59 |
"m selector ~~ self nameOfVersionMethodForExtensions"] |
|
60 |
] |
|
61 |
] ifFalse:[ |
|
62 |
filter := [:mth | mth package = package ]. |
|
63 |
]. |
|
255 | 64 |
klass isLoaded ifFalse:[ klass autoload ]. |
65 |
klass fileOutOn:aStream |
|
66 |
withTimeStamp:false |
|
67 |
withInitialize:true |
|
68 |
withDefinition:true |
|
69 |
methodFilter:filter. |
|
201 | 70 |
|
71 |
"Created: / 01-03-2013 / 17:51:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
255 | 72 |
"Modified: / 15-12-2014 / 11:27:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
201 | 73 |
! |
74 |
||
75 |
validate |
|
76 |
| file | |
|
77 |
||
78 |
file := (Smalltalk getPackageDirectoryForPackage: klass package) / ((Smalltalk fileNameForClass: klass) , '.st'). |
|
79 |
^ self validateAgainstReference: file |
|
80 |
||
81 |
"Modified: / 29-07-2013 / 14:54:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
82 |
! ! |
|
83 |
||
84 |
!ReportClassSourceInfo class methodsFor:'documentation'! |
|
85 |
||
86 |
version |
|
87 |
^ '$Header$' |
|
88 |
! |
|
89 |
||
90 |
version_CVS |
|
91 |
^ '$Header$' |
|
92 |
! ! |
|
93 |