10484
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
Permission is hereby granted, free of charge, to any person
|
|
6 |
obtaining a copy of this software and associated documentation
|
|
7 |
files (the 'Software'), to deal in the Software without
|
|
8 |
restriction, including without limitation the rights to use,
|
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 |
copies of the Software, and to permit persons to whom the
|
|
11 |
Software is furnished to do so, subject to the following
|
|
12 |
conditions:
|
|
13 |
|
|
14 |
The above copyright notice and this permission notice shall be
|
|
15 |
included in all copies or substantial portions of the Software.
|
|
16 |
|
|
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
25 |
"
|
|
26 |
"{ Package: 'stx:libtool' }"
|
|
27 |
|
|
28 |
"{ NameSpace: Tools }"
|
|
29 |
|
|
30 |
CodeViewService subclass:#LintService
|
|
31 |
instanceVariableNames:'ruleHolderFromApp highlighter'
|
|
32 |
classVariableNames:''
|
|
33 |
poolDictionaries:''
|
|
34 |
category:'Interface-Lint'
|
|
35 |
!
|
|
36 |
|
|
37 |
!LintService class methodsFor:'documentation'!
|
|
38 |
|
|
39 |
copyright
|
|
40 |
"
|
|
41 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
42 |
All Rights Reserved
|
|
43 |
|
|
44 |
Permission is hereby granted, free of charge, to any person
|
|
45 |
obtaining a copy of this software and associated documentation
|
|
46 |
files (the 'Software'), to deal in the Software without
|
|
47 |
restriction, including without limitation the rights to use,
|
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
49 |
copies of the Software, and to permit persons to whom the
|
|
50 |
Software is furnished to do so, subject to the following
|
|
51 |
conditions:
|
|
52 |
|
|
53 |
The above copyright notice and this permission notice shall be
|
|
54 |
included in all copies or substantial portions of the Software.
|
|
55 |
|
|
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
63 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
64 |
"
|
|
65 |
! !
|
|
66 |
|
|
67 |
!LintService class methodsFor:'accessing'!
|
|
68 |
|
|
69 |
label
|
|
70 |
|
|
71 |
"Answers short label - for UI"
|
|
72 |
|
|
73 |
^'SmallLint Checker'
|
|
74 |
|
|
75 |
"Created: / 05-08-2011 / 11:01:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
76 |
! !
|
|
77 |
|
|
78 |
!LintService methodsFor:'accessing'!
|
|
79 |
|
|
80 |
syntaxHighlighter
|
|
81 |
| app rules |
|
|
82 |
|
11382
|
83 |
app := codeView application.
|
|
84 |
app notNil ifTrue:[
|
|
85 |
true "(app respondsTo: #selectedLintRules)" ifTrue:[
|
|
86 |
rules := self ruleHolderFromApp value.
|
|
87 |
rules notEmptyOrNil ifTrue:[
|
|
88 |
highlighter rules: rules.
|
|
89 |
^ highlighter
|
|
90 |
]
|
|
91 |
].
|
10484
|
92 |
].
|
|
93 |
^nil
|
|
94 |
|
|
95 |
"Created: / 05-08-2011 / 10:59:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11382
|
96 |
"Modified (format): / 07-03-2012 / 17:22:14 / cg"
|
10484
|
97 |
! !
|
|
98 |
|
|
99 |
!LintService methodsFor:'aspects'!
|
|
100 |
|
|
101 |
ruleHolderFromApp
|
|
102 |
"return/create the 'ruleHolderFromApp' value holder (automatically generated)"
|
|
103 |
|
11382
|
104 |
|app|
|
|
105 |
|
10484
|
106 |
ruleHolderFromApp isNil ifTrue:[
|
11382
|
107 |
(app := self application) notNil ifTrue:[
|
|
108 |
self ruleHolderFromApp: app selectedLintRules
|
|
109 |
"/ ruleHolderFromApp := ValueHolder new.
|
|
110 |
"/ ruleHolderFromApp addDependent:self.
|
|
111 |
].
|
10484
|
112 |
].
|
|
113 |
^ ruleHolderFromApp
|
11382
|
114 |
|
|
115 |
"Modified: / 07-03-2012 / 17:20:42 / cg"
|
10484
|
116 |
!
|
|
117 |
|
|
118 |
ruleHolderFromApp:something
|
|
119 |
"set the 'ruleHolderFromApp' value holder (automatically generated)"
|
|
120 |
|
|
121 |
|oldValue newValue|
|
|
122 |
|
|
123 |
ruleHolderFromApp notNil ifTrue:[
|
|
124 |
oldValue := ruleHolderFromApp value.
|
|
125 |
ruleHolderFromApp removeDependent:self.
|
|
126 |
].
|
|
127 |
ruleHolderFromApp := something.
|
|
128 |
ruleHolderFromApp notNil ifTrue:[
|
|
129 |
ruleHolderFromApp addDependent:self.
|
|
130 |
].
|
|
131 |
newValue := ruleHolderFromApp value.
|
|
132 |
oldValue ~~ newValue ifTrue:[
|
|
133 |
self update:#value with:newValue from:ruleHolderFromApp.
|
|
134 |
].
|
|
135 |
! !
|
|
136 |
|
|
137 |
!LintService methodsFor:'change & update'!
|
|
138 |
|
|
139 |
update: aspect with: param from: sender
|
11382
|
140 |
aspect == #sizeOfView ifFalse:[
|
|
141 |
sender == ruleHolderFromApp ifTrue:[
|
|
142 |
self syntaxHighlight: true.
|
|
143 |
^ self.
|
|
144 |
]
|
|
145 |
].
|
|
146 |
super update: aspect with: param from: sender.
|
10484
|
147 |
|
|
148 |
"Created: / 05-08-2011 / 11:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11382
|
149 |
"Modified: / 07-03-2012 / 17:16:59 / cg"
|
10484
|
150 |
! !
|
|
151 |
|
|
152 |
!LintService methodsFor:'initialization'!
|
|
153 |
|
|
154 |
initialize
|
|
155 |
|
|
156 |
super initialize.
|
|
157 |
|
|
158 |
highlighter := LintHighlighter new
|
|
159 |
|
|
160 |
"Modified: / 03-09-2010 / 22:29:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
161 |
"Created: / 05-08-2011 / 11:53:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
162 |
! !
|
|
163 |
|
|
164 |
!LintService methodsFor:'private'!
|
|
165 |
|
|
166 |
syntaxHighlight: delayed
|
|
167 |
|
|
168 |
| service |
|
|
169 |
service := self service: #'Tools::CodeHighlightingService'.
|
|
170 |
service notNil ifTrue:[
|
11227
|
171 |
service process: delayed
|
10484
|
172 |
]
|
|
173 |
|
|
174 |
"Created: / 05-08-2011 / 11:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
175 |
! !
|
|
176 |
|
|
177 |
!LintService methodsFor:'registering'!
|
|
178 |
|
|
179 |
registerIn: aCodeView
|
11382
|
180 |
|app|
|
10484
|
181 |
|
|
182 |
super registerIn: aCodeView.
|
11382
|
183 |
|
|
184 |
app := self application.
|
|
185 |
app notNil ifTrue:[
|
|
186 |
"/ bad design; better idea would be to pass the lintRuleHolder back from the
|
|
187 |
"/ application to me explicitely (in a postBuild method for some ruleCanvas of the app)
|
|
188 |
true "(app respondsTo: #selectedLintRules)" ifTrue:[
|
|
189 |
self ruleHolderFromApp: app selectedLintRules
|
|
190 |
]
|
10484
|
191 |
].
|
|
192 |
|
|
193 |
"Modified: / 17-06-2011 / 13:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
194 |
"Created: / 05-08-2011 / 11:47:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11382
|
195 |
"Modified (format): / 07-03-2012 / 17:21:27 / cg"
|
10484
|
196 |
! !
|
|
197 |
|
|
198 |
!LintService class methodsFor:'documentation'!
|
|
199 |
|
|
200 |
version
|
11382
|
201 |
^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.3 2012-03-07 17:19:49 cg Exp $'
|
10484
|
202 |
!
|
|
203 |
|
|
204 |
version_CVS
|
11382
|
205 |
^ '$Header: /cvs/stx/stx/libtool/Tools__LintService.st,v 1.3 2012-03-07 17:19:49 cg Exp $'
|
10484
|
206 |
! !
|