author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sun, 03 Mar 2013 12:50:54 +0100 | |
changeset 119 | 318a202597cc |
parent 118 | 7e93ef8c5417 |
child 141 | 9265bed28ff5 |
permissions | -rw-r--r-- |
71 | 1 |
"{ Package: 'stx:goodies/builder/reports' }" |
2 |
||
3 |
"{ NameSpace: Builder }" |
|
4 |
||
5 |
Report subclass:#LintReport |
|
6 |
instanceVariableNames:'environment rules' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'Builder-Reports' |
|
10 |
! |
|
11 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
12 |
Object subclass:#SourceInfo |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
13 |
instanceVariableNames:'klass filename offsets lineEnds' |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
14 |
classVariableNames:'' |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
15 |
poolDictionaries:'' |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
16 |
privateIn:LintReport |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
17 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
18 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
19 |
Stream subclass:#LineCountingStream |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
20 |
instanceVariableNames:'position lineEnds' |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
21 |
classVariableNames:'' |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
22 |
poolDictionaries:'' |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
23 |
privateIn:LintReport::SourceInfo |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
24 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
25 |
|
71 | 26 |
|
27 |
!LintReport class methodsFor:'class initialization'! |
|
28 |
||
29 |
initialize |
|
30 |
||
31 |
Smalltalk loadPackage: 'stx:goodies/refactoryBrowser/lint'. |
|
32 |
||
33 |
"Modified: / 01-04-2011 / 12:58:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
34 |
! ! |
|
35 |
||
36 |
!LintReport methodsFor:'accessing - defaults'! |
|
37 |
||
38 |
defaultFileSuffix |
|
39 |
||
40 |
^ 'Lint' |
|
41 |
||
42 |
"Modified: / 08-10-2011 / 10:49:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
43 |
! |
|
44 |
||
45 |
defaultFormat |
|
46 |
"raise an error: must be redefined in concrete subclass(es)" |
|
47 |
||
48 |
^ LintReportFormat::PMD new |
|
49 |
||
50 |
"Modified: / 25-11-2011 / 22:06:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
79
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
51 |
! |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
52 |
|
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
53 |
defaultName |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
54 |
|
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
55 |
environment isNil ifTrue:[^super defaultName]. |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
56 |
^environment label |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
57 |
|
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
58 |
"Modified: / 25-11-2011 / 22:06:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
59 |
"Created: / 13-01-2012 / 12:43:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 60 |
! ! |
61 |
||
117
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
62 |
!LintReport methodsFor:'command line options'! |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
63 |
|
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
64 |
cmdlineOptionRuleset |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
65 |
|
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
66 |
^CmdLineOption new |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
67 |
short: $s; |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
68 |
long: 'ruleset'; |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
69 |
description: 'Rule set '; |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
70 |
action:[:option | |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
71 |
self setupRulesFrom: option. |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
72 |
]; |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
73 |
yourself |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
74 |
|
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
75 |
"Created: / 28-02-2013 / 23:13:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
76 |
! ! |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
77 |
|
71 | 78 |
!LintReport methodsFor:'generating'! |
79 |
||
80 |
generateClass: aClass |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
81 |
| sourceInfo sourceName | |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
82 |
sourceInfo := SourceInfo for: aClass. |
71 | 83 |
sourceName := self encodeFilename: (self sourceFilenameFor: aClass). |
84 |
||
85 |
format writeFile: sourceName with: [ |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
86 |
self generateClass: aClass source: sourceInfo. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
87 |
self generateClass: aClass class source: sourceInfo. |
71 | 88 |
]. |
89 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
90 |
format writeSource: sourceInfo contents to: sourceName |
71 | 91 |
|
92 |
"Created: / 06-10-2011 / 23:54:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
93 |
"Modified: / 01-03-2013 / 17:59:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 94 |
! |
95 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
96 |
generateClass: aClass selector: aSelector source: sourceInfo |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
97 |
| matching | |
71 | 98 |
matching := rules select: [ :each | |
99 |
(self isSelectorEnvironment: each result) |
|
100 |
and: [ each result includesSelector: aSelector in: aClass ] ]. |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
101 |
self generateViolations: matching class: aClass selector: aSelector source: sourceInfo |
71 | 102 |
|
103 |
"Created: / 07-10-2011 / 11:04:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
104 |
"Modified: / 01-03-2013 / 18:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 105 |
! |
106 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
107 |
generateClass: aClass source: sourceInfo |
71 | 108 |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
109 |
| matching | |
71 | 110 |
(environment definesClass: aClass) ifTrue: [ |
111 |
matching := rules select: [ :rule | |
|
112 |
(self isClassEnvironment: rule result) |
|
113 |
and: [ rule result includesClass: aClass ] ]. |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
114 |
self generateViolations: matching class: aClass selector: nil source: sourceInfo]. |
71 | 115 |
(environment selectorsForClass: aClass) asSortedCollection |
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
116 |
do: [ :selector | self generateClass: aClass selector: selector source: sourceInfo] |
71 | 117 |
|
118 |
"Created: / 07-10-2011 / 10:29:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
119 |
"Modified: / 01-03-2013 / 18:11:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 120 |
! |
121 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
122 |
generateViolations: aCollection class: aClass selector: aSelector source: sourceInfo |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
123 |
| method offset | |
71 | 124 |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
125 |
method := aClass compiledMethodAt: aSelector. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
126 |
offset := sourceInfo offsetOfMethod: method. |
71 | 127 |
aCollection do: [ :rule | |
128 |
| interval start stop | |
|
129 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
130 |
interval := (rule result selectionIntervalFor: method source) isNil ifTrue: [ 1 to: method source size ]. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
131 |
start := sourceInfo lineAndColumnOfOffset: offset + interval first - 1. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
132 |
stop := sourceInfo lineAndColumnOfOffset: offset + interval last - 1. |
71 | 133 |
|
134 |
format writeViolation: rule |
|
135 |
class: aClass selector: aSelector |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
136 |
startLine: start x column: start y |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
137 |
stopLine: stop x column: stop y. |
71 | 138 |
] |
139 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
140 |
"Created: / 01-03-2013 / 18:05:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 141 |
! ! |
142 |
||
143 |
!LintReport methodsFor:'initialization'! |
|
144 |
||
145 |
setupForClasses: classes |
|
146 |
||
147 |
environment := BrowserEnvironment new forClasses: classes. |
|
148 |
environment label: name |
|
149 |
||
150 |
"Created: / 04-08-2011 / 14:40:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
151 |
! |
|
152 |
||
153 |
setupForPackages: packages |
|
154 |
||
79
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
155 |
packages isEmpty ifTrue:[^self]. |
71 | 156 |
environment := PackageEnvironment |
157 |
onEnvironment: BrowserEnvironment new |
|
158 |
packageNames: packages. |
|
79
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
159 |
name isNil ifTrue:[ |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
160 |
packages size > 1 ifTrue:[ |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
161 |
name := packages size printString , ' packages'. |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
162 |
] ifFalse:[ |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
163 |
name := packages anElement |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
164 |
] |
889d3747a0a8
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
71
diff
changeset
|
165 |
]. |
71 | 166 |
|
167 |
environment label: name. |
|
168 |
||
169 |
" |
|
170 |
LintReport runPackage:'stx:goodies/monticello'. |
|
171 |
LintReport runPackage:'stx:libjava' |
|
172 |
" |
|
173 |
||
174 |
"Created: / 04-08-2011 / 14:40:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
175 |
! ! |
|
176 |
||
177 |
!LintReport methodsFor:'private'! |
|
178 |
||
179 |
lineAndColumn: aString at: anInteger |
|
180 |
| line last stream | |
|
181 |
line := 1. |
|
182 |
last := 0. |
|
183 |
stream := aString readStream. |
|
184 |
[ (stream nextLine isNil or: [ anInteger <= stream position ]) |
|
185 |
ifTrue: [ ^ line @ (anInteger - last) ]. |
|
186 |
last := stream position. |
|
187 |
line := line + 1 ] |
|
188 |
repeat |
|
189 |
! |
|
190 |
||
191 |
sourceFilenameFor: aClass |
|
192 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
193 |
| fn cls | |
71 | 194 |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
195 |
cls := aClass theNonMetaclass. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
196 |
fn := cls package asString replaceAll:$: with:$_;replaceAll:$/ with:$_. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
197 |
fn := fn , '_' , (cls asString copyReplaceAll:$: with: $_), '.' , cls programmingLanguage sourceFileSuffix. |
71 | 198 |
|
199 |
^self encodeFilename: fn. |
|
200 |
||
201 |
" |
|
202 |
Builder::LintReportFormat::CheckStyle basicNew |
|
203 |
sourceFilenameFor: Class |
|
204 |
||
205 |
Builder::LintReportFormat::CheckStyle basicNew |
|
206 |
sourceFilenameFor: Builder::LintReportFormat |
|
207 |
" |
|
208 |
||
209 |
"Created: / 07-10-2011 / 09:06:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
210 |
"Modified: / 01-03-2013 / 18:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 211 |
! ! |
212 |
||
213 |
!LintReport methodsFor:'running'! |
|
214 |
||
215 |
runReport |
|
82 | 216 |
| wasTryLocalSources | |
71 | 217 |
|
82 | 218 |
[ |
219 |
wasTryLocalSources := Class tryLocalSourceFirst. |
|
84 | 220 |
Class tryLocalSourceFirst: true. |
82 | 221 |
SmalllintChecker |
222 |
runRule: (RBCompositeLintRule rules: rules) |
|
223 |
onEnvironment: environment. |
|
71 | 224 |
|
82 | 225 |
(environment classes asSortedCollection: [ :a :b | a name <= b name ]) |
226 |
do: [ :class | self generateClass: class]. |
|
227 |
] ensure:[ |
|
228 |
Class tryLocalSourceFirst: wasTryLocalSources |
|
229 |
] |
|
71 | 230 |
|
84 | 231 |
"Modified: / 23-01-2012 / 09:04:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 232 |
! |
233 |
||
234 |
setUp |
|
235 |
||
236 |
super setUp. |
|
117
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
237 |
rules isNil ifTrue:[ |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
238 |
rules := (RBCompositeLintRule rulesFor: RBBasicLintRule) |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
239 |
reject: [ :each | each class name endsWith: 'SpellingRule' ] |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
240 |
]. |
71 | 241 |
|
242 |
"Created: / 04-08-2011 / 14:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
117
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
243 |
"Modified: / 28-02-2013 / 23:18:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
244 |
! |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
245 |
|
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
246 |
setupRulesFrom: filename |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
247 |
| file | |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
248 |
file := filename asFilename. |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
249 |
file readingFileDo:[:s| |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
250 |
| spec | |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
251 |
spec := Parser parseLiteralArray: s. |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
252 |
rules := spec decodeAsLiteralArray rules. |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
253 |
] |
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
254 |
|
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
255 |
"Created: / 28-02-2013 / 23:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 | 256 |
! ! |
257 |
||
258 |
!LintReport methodsFor:'testing'! |
|
259 |
||
260 |
isClassEnvironment: anEnvironment |
|
261 |
^ #(CategoryEnvironment ClassEnvironment VariableEnvironment) includes: anEnvironment class name |
|
262 |
! |
|
263 |
||
264 |
isSelectorEnvironment: anEnvironment |
|
265 |
^ #(SelectorEnvironment ParseTreeEnvironment VariableEnvironment) includes: anEnvironment class name |
|
266 |
! ! |
|
267 |
||
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
268 |
!LintReport::SourceInfo class methodsFor:'instance creation'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
269 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
270 |
for: aClass |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
271 |
^self new setClass: aClass |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
272 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
273 |
"Created: / 01-03-2013 / 17:50:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
274 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
275 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
276 |
!LintReport::SourceInfo methodsFor:'initialization'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
277 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
278 |
setClass: aClass |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
279 |
klass := aClass theNonMetaclass. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
280 |
self setup. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
281 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
282 |
"Created: / 01-03-2013 / 17:49:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
283 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
284 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
285 |
setup |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
286 |
"To be called after class is set" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
287 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
288 |
| stream | |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
289 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
290 |
stream := LineCountingStream new. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
291 |
offsets := Dictionary new. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
292 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
293 |
[ |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
294 |
self fileOutOn: stream. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
295 |
] on: AbstractSourceFileWriter methodSourceRewriteQuery do:[:rewriteQuery | |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
296 |
| m | |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
297 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
298 |
m := rewriteQuery method. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
299 |
offsets at: m put: stream position + 1. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
300 |
rewriteQuery proceed. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
301 |
]. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
302 |
lineEnds := stream lineEnds |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
303 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
304 |
" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
305 |
SourceInfo for: Builder::ReportRunner |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
306 |
" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
307 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
308 |
"Created: / 01-03-2013 / 17:30:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
119
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
309 |
"Modified: / 03-03-2013 / 11:09:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
310 |
! ! |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
311 |
|
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
312 |
!LintReport::SourceInfo methodsFor:'queries'! |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
313 |
|
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
314 |
lineAndColumnOfOffset: offset |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
315 |
| low high middle element line col | |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
316 |
|
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
317 |
low := 1. |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
318 |
high := lineEnds size. |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
319 |
[low > high] whileFalse:[ |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
320 |
middle := (low + high) // 2. |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
321 |
element := lineEnds at:middle. |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
322 |
element < offset ifTrue:[ |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
323 |
"middleelement is smaller than object" |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
324 |
low := middle + 1 |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
325 |
] ifFalse:[ |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
326 |
high := middle - 1 |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
327 |
] |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
328 |
]. |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
329 |
|
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
330 |
line := low. |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
331 |
col := offset - (line > 1 ifTrue:[lineEnds at: line - 1] ifFalse:[0]). |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
332 |
^line @ col. |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
333 |
|
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
334 |
"Created: / 03-03-2013 / 10:50:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
335 |
! |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
336 |
|
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
337 |
offsetOfMethod: aMethod |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
338 |
^offsets at: aMethod |
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
339 |
|
318a202597cc
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
340 |
"Created: / 03-03-2013 / 10:49:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
118
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
341 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
342 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
343 |
!LintReport::SourceInfo methodsFor:'utilities'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
344 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
345 |
fileOutOn:aStream |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
346 |
klass fileOutOn: aStream withTimeStamp:false |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
347 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
348 |
"Created: / 01-03-2013 / 17:51:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
349 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
350 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
351 |
!LintReport::SourceInfo::LineCountingStream class methodsFor:'instance creation'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
352 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
353 |
new |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
354 |
"return an initialized instance" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
355 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
356 |
^ self basicNew initialize. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
357 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
358 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
359 |
!LintReport::SourceInfo::LineCountingStream methodsFor:'accessing'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
360 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
361 |
contents |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
362 |
"return the entire contents of the stream. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
363 |
For a readStream, that is the rest (i.e. upToEnd), |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
364 |
for a writeStream, that is the collected data. As we do not know here, |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
365 |
what we are, this is the responsibility of a subclass..." |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
366 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
367 |
^ self shouldNotImplement |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
368 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
369 |
"Modified: / 01-03-2013 / 17:36:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
370 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
371 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
372 |
lineEnds |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
373 |
^ lineEnds |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
374 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
375 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
376 |
position |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
377 |
^ position |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
378 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
379 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
380 |
!LintReport::SourceInfo::LineCountingStream methodsFor:'initialization'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
381 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
382 |
initialize |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
383 |
"Invoked when a new instance is created." |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
384 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
385 |
"/ please change as required (and remove this comment) |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
386 |
position := 0. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
387 |
lineEnds := OrderedCollection new. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
388 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
389 |
"/ super initialize. -- commented since inherited method does nothing |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
390 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
391 |
"Modified: / 01-03-2013 / 17:39:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
392 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
393 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
394 |
!LintReport::SourceInfo::LineCountingStream methodsFor:'queries'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
395 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
396 |
isReadable |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
397 |
"return true, if reading is supported by the recevier. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
398 |
This has to be redefined in concrete subclasses." |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
399 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
400 |
^ false |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
401 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
402 |
"Modified: / 01-03-2013 / 17:36:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
403 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
404 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
405 |
isWritable |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
406 |
"return true, if writing is supported by the recevier. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
407 |
This has to be redefined in concrete subclasses." |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
408 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
409 |
^ true |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
410 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
411 |
"Modified: / 01-03-2013 / 17:37:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
412 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
413 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
414 |
size |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
415 |
"return the number of elements in the streamed collection." |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
416 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
417 |
^ self shouldImplement |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
418 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
419 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
420 |
!LintReport::SourceInfo::LineCountingStream methodsFor:'reading'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
421 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
422 |
next |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
423 |
"return the next element of the stream |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
424 |
- we do not know here how to do it, it must be redefined in subclass" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
425 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
426 |
^ self shouldNotImplement |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
427 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
428 |
"Modified: / 01-03-2013 / 17:37:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
429 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
430 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
431 |
!LintReport::SourceInfo::LineCountingStream methodsFor:'testing'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
432 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
433 |
atEnd |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
434 |
"return true if the end of the stream has been reached; |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
435 |
- we do not know here how to do it, it must be redefined in subclass" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
436 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
437 |
^ false |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
438 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
439 |
"Modified: / 01-03-2013 / 17:37:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
440 |
! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
441 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
442 |
isEmpty |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
443 |
"return true, if the contents of the stream is empty" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
444 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
445 |
^ self shouldNotImplement |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
446 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
447 |
"Modified: / 01-03-2013 / 17:37:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
448 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
449 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
450 |
!LintReport::SourceInfo::LineCountingStream methodsFor:'writing'! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
451 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
452 |
nextPut:aCharacter |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
453 |
"put the argument, anObject onto the receiver |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
454 |
- we do not know here how to do it, it must be redefined in subclass" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
455 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
456 |
position := position + 1. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
457 |
aCharacter == Character cr ifTrue:[ |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
458 |
lineEnds add: position |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
459 |
]. |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
460 |
|
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
461 |
"Modified: / 01-03-2013 / 17:39:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
462 |
! ! |
7e93ef8c5417
Builder::LintReport refactoring - not yet finished!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
463 |
|
71 | 464 |
!LintReport class methodsFor:'documentation'! |
465 |
||
466 |
version |
|
467 |
^ '$Header$' |
|
468 |
! |
|
469 |
||
470 |
version_CVS |
|
471 |
^ '$Header$' |
|
472 |
! |
|
473 |
||
474 |
version_SVN |
|
475 |
^ '§Id: Builder__LintReport.st 293 2011-11-25 21:42:31Z vranyj1 §' |
|
476 |
! ! |
|
477 |
||
117
d7f87303b984
class: Builder::LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
84
diff
changeset
|
478 |
|
71 | 479 |
LintReport initialize! |