author | sr |
Tue, 19 Sep 2017 10:06:46 +0200 | |
changeset 342 | 246d004b0d7c |
parent 274 | b13db8438e4a |
child 533 | 1bed627ec135 |
permissions | -rw-r--r-- |
274
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
1 |
"{ Encoding: utf8 }" |
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
2 |
|
204 | 3 |
"{ Package: 'stx:goodies/builder/reports' }" |
4 |
||
5 |
"{ NameSpace: Builder }" |
|
6 |
||
7 |
ReportSourceInfo subclass:#ReportExtensionsSourceInfo |
|
8 |
instanceVariableNames:'' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
11 |
category:'Builder-Reports-Utils' |
|
12 |
! |
|
13 |
||
14 |
||
264
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
15 |
!ReportExtensionsSourceInfo methodsFor:'accessing'! |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
16 |
|
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
17 |
pathNameAbsolute: aBoolean |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
18 |
"Return a path (as String) to file containing the source code. The file points to the |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
19 |
real source file. If `aBoolean` is true, then absolute path is returned, otherwise |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
20 |
realtive path to package root is returned." |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
21 |
|
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
22 |
| packageDir | |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
23 |
|
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
24 |
packageDir := aBoolean |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
25 |
ifTrue:[ (Smalltalk getPackageDirectoryForPackage: package) pathName ] |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
26 |
ifFalse: [ package asString replaceAll: $: with: Filename separator; replaceAll: $/ with: Filename separator ]. |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
27 |
|
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
28 |
^ packageDir , Filename separator , 'extensions.st'. |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
29 |
|
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
30 |
" |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
31 |
(Builder::ReportSourceInfo forExtensionsInPackage: 'stx:libtool') pathNameAbsolute: true |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
32 |
(Builder::ReportSourceInfo forExtensionsInPackage: 'stx:libtool') pathNameAbsolute: false |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
33 |
" |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
34 |
|
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
35 |
"Created: / 16-12-2014 / 10:27:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
36 |
! ! |
ff9647e01309
Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
204
diff
changeset
|
37 |
|
204 | 38 |
!ReportExtensionsSourceInfo methodsFor:'initialization'! |
39 |
||
40 |
initializeWithPackage: pkg |
|
41 |
package := pkg. |
|
42 |
self setup. |
|
43 |
||
44 |
"Created: / 29-07-2013 / 18:38:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
45 |
! ! |
|
46 |
||
47 |
!ReportExtensionsSourceInfo methodsFor:'utilities'! |
|
48 |
||
49 |
fileOutOn: streamArg |
|
50 |
"This code is stupid as it is a copy-paste of several methods here and there that |
|
51 |
files out an extension.st. But the the original code is so rubbish so I had |
|
52 |
to do it this way. Sorry." |
|
53 |
||
54 |
| extensions wide stream s methodsSortedByName defClass scmManagerOrNil | |
|
55 |
||
56 |
extensions := ProjectDefinition searchForExtensionsWithProject: package. |
|
274
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
57 |
extensions isEmptyOrNil ifTrue:[ ^ self ]. |
204 | 58 |
wide := false. |
59 |
stream := streamArg. |
|
60 |
extensions do:[:method| |
|
61 |
wide := wide or:[method source isWideString]. |
|
62 |
]. |
|
63 |
wide ifTrue:[ |
|
64 |
stream := EncodedStream stream: stream encoder: (CharacterEncoder encoderForUTF8). |
|
65 |
stream nextPutAll: '"{ Encoding: utf8 }"'; cr;cr. |
|
66 |
]. |
|
67 |
||
68 |
s := stream. |
|
69 |
||
70 |
s nextPutAll:'"{ Package: '''. |
|
71 |
s nextPutAll:package asString. |
|
72 |
s nextPutAll:''' }"'; nextPutChunkSeparator; cr; cr. |
|
73 |
||
74 |
"/ don't write a timestamp. Otherwise we would always generate a new version, even if nothing changed |
|
75 |
"/ s nextPutAll:(Smalltalk timeStamp). |
|
76 |
"/ s nextPutChunkSeparator. |
|
77 |
"/ s cr; cr. |
|
78 |
||
79 |
"/ sort them by name (to avoid conflicts due to SCM merge) |
|
80 |
methodsSortedByName := extensions asOrderedCollection. |
|
81 |
methodsSortedByName sort:[:a :b | |
|
82 |
|clsA clsB| |
|
83 |
||
84 |
clsA := a mclass name. |
|
85 |
clsB := b mclass name. |
|
86 |
clsA < clsB ifTrue:[ |
|
87 |
true |
|
88 |
] ifFalse:[ |
|
89 |
clsA > clsB ifTrue:[ |
|
90 |
false |
|
91 |
] ifFalse:[ |
|
92 |
a selector < b selector |
|
93 |
] |
|
94 |
] |
|
95 |
]. |
|
96 |
methodsSortedByName do:[:aMethod | |
|
274
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
97 |
|cat privacy aStream| |
204 | 98 |
|
99 |
aStream := s. |
|
100 |
||
101 |
aStream nextPutChunkSeparator. |
|
102 |
aMethod mclass name printOn:aStream. |
|
103 |
"/ self printClassNameOn:aStream. |
|
104 |
||
105 |
(privacy := aMethod privacy) ~~ #public ifTrue:[ |
|
106 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'. |
|
107 |
] ifFalse:[ |
|
108 |
aStream nextPutAll:' methodsFor:'. |
|
109 |
]. |
|
110 |
||
111 |
cat := aMethod category ? ''. |
|
112 |
aStream nextPutAll:cat asString storeString. |
|
113 |
aStream nextPutChunkSeparator; cr; cr. |
|
114 |
||
115 |
SmalltalkChunkFileSourceWriter new fileOutMethod:aMethod on:aStream. |
|
116 |
||
117 |
aStream space. |
|
118 |
aStream nextPutChunkSeparator. |
|
119 |
aStream cr. |
|
120 |
s cr. |
|
121 |
]. |
|
122 |
||
123 |
scmManagerOrNil := AbstractSourceCodeManager managerForPackage: package. |
|
124 |
scmManagerOrNil notNil ifTrue:[ |
|
125 |
defClass := ProjectDefinition definitionClassForPackage:package. |
|
126 |
defClass notNil ifTrue:[ |
|
127 |
"/ make sure, an extensionVersion_XXX method is included... |
|
128 |
"/ (notice: no need to support a secondary backward compatible non-manager related version method here) |
|
129 |
(methodsSortedByName contains:[:aMethod | aMethod selector == scmManagerOrNil nameOfVersionMethodForExtensions]) ifFalse:[ |
|
130 |
s nextPutLine:('!!%1 class methodsFor:''documentation''!!' bindWith:defClass name). |
|
131 |
s cr. |
|
132 |
s nextChunkPut: |
|
133 |
(scmManagerOrNil versionMethodTemplateForSmalltalkFor:(scmManagerOrNil nameOfVersionMethodForExtensions)). |
|
134 |
s space; nextPutChunkSeparator; cr. |
|
135 |
]. |
|
136 |
]. |
|
137 |
]. |
|
138 |
||
274
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
139 |
"Modified: / 09-03-2015 / 15:55:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
204 | 140 |
! |
141 |
||
142 |
validate |
|
274
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
143 |
| extensions file | |
204 | 144 |
|
274
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
145 |
extensions := ProjectDefinition searchForExtensionsWithProject: package. |
204 | 146 |
file := (Smalltalk getPackageDirectoryForPackage: package) / 'extensions.st'. |
147 |
||
274
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
148 |
extensions isEmptyOrNil ifTrue:[ |
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
149 |
self assert: file exists not. |
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
150 |
] ifFalse:[ |
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
151 |
self validateAgainstReference: file. |
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
152 |
] |
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
153 |
|
b13db8438e4a
Fix in validation of extensions source info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
264
diff
changeset
|
154 |
"Modified: / 09-03-2015 / 15:58:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
204 | 155 |
! ! |
156 |
||
157 |
!ReportExtensionsSourceInfo class methodsFor:'documentation'! |
|
158 |
||
159 |
version |
|
160 |
^ '$Header$' |
|
161 |
! |
|
162 |
||
163 |
version_CVS |
|
164 |
^ '$Header$' |
|
165 |
! ! |
|
166 |