author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 21 Mar 2012 17:50:14 +0000 | |
branch | jv |
changeset 12205 | f210b6224ef0 |
parent 12170 | 6c9c4b7981ee |
child 12236 | 8ec3d6230b65 |
permissions | -rw-r--r-- |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
1 |
" |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
3 |
All Rights Reserved |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
4 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
5 |
This software is furnished under a license and may be used |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
10 |
hereby transferred. |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
11 |
" |
10485 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
14 |
"{ NameSpace: Tools }" |
|
15 |
||
16 |
Object subclass:#LintHighlighter |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
17 |
instanceVariableNames:'rules annotations formattingMethod emphasisError |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
18 |
emphasisInformation emphasisWarning' |
10485 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Lint' |
|
22 |
! |
|
23 |
||
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
24 |
!LintHighlighter class methodsFor:'documentation'! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
25 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
26 |
copyright |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
27 |
" |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
28 |
COPYRIGHT (c) 2006 by eXept Software AG |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
29 |
All Rights Reserved |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
30 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
31 |
This software is furnished under a license and may be used |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
32 |
only in accordance with the terms of that license and with the |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
33 |
inclusion of the above copyright notice. This software may not |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
34 |
be provided or otherwise made available to, or used by, any |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
35 |
other person. No title to or ownership of the software is |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
36 |
hereby transferred. |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
37 |
" |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
38 |
! ! |
10485 | 39 |
|
40 |
!LintHighlighter methodsFor:'accessing'! |
|
41 |
||
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
42 |
annotations |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
43 |
^ annotations |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
44 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
45 |
|
10485 | 46 |
rules |
47 |
^ rules |
|
48 |
! |
|
49 |
||
12205 | 50 |
rules:aCollectionOfRules |
51 |
rules := aCollectionOfRules. |
|
52 |
||
53 |
"Modified (format): / 07-03-2012 / 17:24:02 / cg" |
|
10485 | 54 |
! ! |
55 |
||
56 |
!LintHighlighter methodsFor:'accessing-emphasis'! |
|
57 |
||
58 |
emphasisForError |
|
12205 | 59 |
|warnColor| |
10485 | 60 |
|
61 |
emphasisError isNil ifTrue:[ |
|
12205 | 62 |
warnColor := Color red. |
10485 | 63 |
emphasisError := Array |
12205 | 64 |
with: #backgroundColor -> warnColor lightened lightened |
10485 | 65 |
with: #underwave |
12205 | 66 |
with: #underlineColor -> warnColor |
10485 | 67 |
]. |
68 |
^emphasisError |
|
69 |
||
70 |
"Created: / 05-08-2011 / 09:31:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12205 | 71 |
"Modified: / 08-03-2012 / 03:00:51 / cg" |
10485 | 72 |
! |
73 |
||
74 |
emphasisForInformation |
|
12205 | 75 |
|warnColor| |
10485 | 76 |
|
77 |
emphasisInformation isNil ifTrue:[ |
|
12205 | 78 |
warnColor := Color blue lighter. |
10485 | 79 |
emphasisInformation := Array |
12205 | 80 |
with: #backgroundColor -> warnColor lightened lightened |
10485 | 81 |
with: #underwave |
12205 | 82 |
with: #underlineColor -> warnColor |
10485 | 83 |
]. |
84 |
^emphasisInformation |
|
85 |
||
86 |
"Created: / 05-08-2011 / 09:31:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12205 | 87 |
"Modified: / 08-03-2012 / 03:01:22 / cg" |
10485 | 88 |
! |
89 |
||
90 |
emphasisForSeverity: severity |
|
91 |
||
92 |
severity == #error ifTrue:[^self emphasisForError]. |
|
93 |
severity == #information ifTrue:[^self emphasisForInformation]. |
|
94 |
||
95 |
^self emphasisForWarning |
|
96 |
||
97 |
"Created: / 05-08-2011 / 09:31:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
98 |
! |
|
99 |
||
100 |
emphasisForWarning |
|
12205 | 101 |
|warnColor| |
10485 | 102 |
|
103 |
emphasisWarning isNil ifTrue:[ |
|
12205 | 104 |
warnColor := (Color redByte: 224 greenByte: 200 blueByte: 45). |
10485 | 105 |
emphasisWarning := Array |
12205 | 106 |
with: #backgroundColor -> warnColor lightened lightened |
10485 | 107 |
with: #underwave |
12205 | 108 |
with: #underlineColor -> warnColor |
10485 | 109 |
]. |
110 |
^emphasisWarning |
|
111 |
||
112 |
"Created: / 05-08-2011 / 09:31:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12205 | 113 |
"Modified: / 08-03-2012 / 03:00:19 / cg" |
10485 | 114 |
! ! |
115 |
||
116 |
!LintHighlighter methodsFor:'formatting'! |
|
117 |
||
118 |
formatClassDefinition:source in:class |
|
119 |
||
120 |
formattingMethod := false. |
|
121 |
^ self format: source |
|
122 |
||
123 |
"Created: / 04-08-2011 / 23:44:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
124 |
! |
|
125 |
||
126 |
formatClassDefinition:source in:class elementsInto: elements |
|
127 |
||
128 |
formattingMethod := false. |
|
129 |
^ self format: source |
|
130 |
||
131 |
"Created: / 04-08-2011 / 23:44:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
132 |
! |
|
133 |
||
134 |
formatExpression:source in:class |
|
135 |
||
136 |
formattingMethod := false. |
|
137 |
^ self format: source |
|
138 |
||
139 |
"Created: / 04-08-2011 / 23:45:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 |
! |
|
141 |
||
142 |
formatExpression:source in:class elementsInto: elements |
|
143 |
||
144 |
formattingMethod := false. |
|
145 |
^ self format: source |
|
146 |
||
147 |
"Created: / 04-08-2011 / 23:43:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
148 |
! |
|
149 |
||
150 |
formatMethod:mth source:source in:class using: preferences |
|
151 |
||
152 |
formattingMethod := true. |
|
153 |
^ self format: source |
|
154 |
||
155 |
"Created: / 04-08-2011 / 23:45:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
156 |
! |
|
157 |
||
158 |
formatMethod:mth source:source in:class using: preferences elementsInto: elements |
|
159 |
||
160 |
formattingMethod := true. |
|
161 |
^ self format: source |
|
162 |
||
163 |
"Created: / 04-08-2011 / 23:42:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
164 |
! ! |
|
165 |
||
166 |
!LintHighlighter methodsFor:'formatting-private'! |
|
167 |
||
168 |
format: text |
|
169 |
||
12141 | 170 |
| tree | |
171 |
tree := RBParser parseMethod: text string onError:[:error :pos| ^ text ]. |
|
172 |
self format: text tree: tree. |
|
10485 | 173 |
^text |
174 |
||
175 |
"Created: / 04-08-2011 / 23:51:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
176 |
! |
|
177 |
||
12205 | 178 |
|
179 |
||
12141 | 180 |
format: text tree: tree |
181 |
||
182 |
annotations := SortedCollection new. |
|
183 |
rules ? #() do:[:rule| |
|
184 |
self format: text tree: tree rule: rule |
|
185 |
]. |
|
186 |
^text |
|
187 |
||
188 |
"Created: / 02-02-2012 / 23:32:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
189 |
! |
|
190 |
||
191 |
format: text tree: tree rule: rule |
|
10485 | 192 |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
193 |
| string | |
10485 | 194 |
|
12141 | 195 |
string := text string. |
10485 | 196 |
rule result isParseTreeEnvironment ifTrue:[ |
197 |
formattingMethod ifTrue:[ |
|
12141 | 198 |
rule result selectionIntervalsForSource: string tree: tree do: [:interval| |
199 |
interval notNil ifTrue:[ |
|
200 |
self mark: text from: interval first to: interval last for: rule. |
|
201 |
] |
|
12125 | 202 |
]. |
10485 | 203 |
]. |
12141 | 204 |
] ifFalse: [ |
10485 | 205 |
| searches | |
206 |
||
207 |
searches := rule result searchStrings asSet. |
|
208 |
||
209 |
searches do:[:search| |
|
210 |
| i | |
|
211 |
i := 1. |
|
212 |
[ |
|
213 |
i := string findString: search startingAt: i. |
|
214 |
i ~~ 0 |
|
215 |
] whileTrue:[ |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
216 |
self mark: text from: i to: (i + search size - 1) for: rule. |
10485 | 217 |
i := i + search size + 1. |
218 |
] |
|
219 |
||
220 |
||
221 |
] |
|
222 |
] |
|
223 |
||
12141 | 224 |
"Created: / 03-02-2012 / 10:39:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10485 | 225 |
! ! |
226 |
||
12170
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
227 |
!LintHighlighter methodsFor:'initialization'! |
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
228 |
|
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
229 |
reset |
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
230 |
annotations := #(). |
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
231 |
|
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
232 |
"Created: / 18-02-2012 / 22:54:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
233 |
! ! |
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12141
diff
changeset
|
234 |
|
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
235 |
!LintHighlighter methodsFor:'markup'! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
236 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
237 |
mark: text from: start to: end for: rule |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
238 |
| emphasis | |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
239 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
240 |
emphasis := self emphasisForSeverity: rule severity. |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
241 |
text emphasisFrom: start to: end add: emphasis. |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
242 |
annotations add: |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
243 |
(LintAnnotation from: start to: end rule: rule) |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
244 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
245 |
"Created: / 30-01-2012 / 15:30:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
246 |
! ! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
247 |
|
10485 | 248 |
!LintHighlighter class methodsFor:'documentation'! |
249 |
||
250 |
version |
|
12205 | 251 |
^ '$Header: /cvs/stx/stx/libtool/Tools__LintHighlighter.st,v 1.5 2012/03/08 03:16:18 cg Exp $' |
10485 | 252 |
! |
253 |
||
254 |
version_CVS |
|
12205 | 255 |
^ '§Header: /cvs/stx/stx/libtool/Tools__LintHighlighter.st,v 1.5 2012/03/08 03:16:18 cg Exp §' |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
256 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
257 |
|
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
258 |
version_SVN |
12205 | 259 |
^ '$Id: Tools__LintHighlighter.st 7952 2012-03-21 17:50:14Z vranyj1 $' |
12125 | 260 |
! ! |