1
- " use babel"
1
+ ' use babel'
2
2
/** @jsx etch.dom */
3
3
4
4
import etch from 'etch'
5
- import { Emitter , Disposable , CompositeDisposable } from 'atom'
5
+ import { Disposable , CompositeDisposable } from 'atom'
6
6
import { OutputPanelButtons } from './views/output-panel-buttons'
7
7
import { OutputPanelCheckbox } from './views/output-panel-checkbox'
8
8
import { ProgressBar } from './views/progress-bar'
9
9
import { OutputPanelItems } from './views/output-panel-items'
10
- const $ = etch . dom ;
10
+ const $ = etch . dom
11
11
12
12
export class OutputPanel {
13
- constructor ( state , results ) {
13
+ constructor ( state , results ) {
14
14
this . state = state || { }
15
15
this . results = results
16
16
17
17
this . hiddenOutput = true
18
18
19
- this . elements = new Set
19
+ this . elements = new Set ( )
20
20
21
21
this . statusMap = new Map
22
22
23
23
this . disposables = new CompositeDisposable
24
24
25
- etch . initialize ( this ) ;
25
+ etch . initialize ( this )
26
26
27
- atom . config . observe ( 'ide-haskell.panelPosition' , ( value ) => {
27
+ atom . config . observe ( 'ide-haskell.panelPosition' , ( value ) => {
28
28
this . pos = value
29
29
this . panel = atom . workspace . addPanel ( this . pos , {
30
30
item : this ,
31
- visible : this . state . visibility || true ,
31
+ visible : this . state . visibility || true
32
32
} )
33
- if ( this . element )
33
+ if ( this . element ) {
34
34
this . update ( )
35
+ }
35
36
} )
36
37
37
38
this . disposables . add ( atom . tooltips . add ( this . refs . status , {
@@ -51,34 +52,37 @@ export class OutputPanel {
51
52
52
53
this . disposables . add ( this . results . onDidUpdate ( ( { types} ) => {
53
54
this . currentResult = null
54
- if ( atom . config . get ( 'ide-haskell.autoHideOutput' ) &&
55
- types . map ( ( type ) => this . results . filter ( { severity : type } ) . length ) . every ( ( l ) => l == 0 ) )
55
+ if ( atom . config . get ( 'ide-haskell.autoHideOutput' ) &&
56
+ types . map ( ( type ) => this . results . filter ( { severity : type } ) . length ) . every ( ( l ) => l === 0 ) ) {
56
57
this . buttons . disableAll ( )
57
- else
58
- if ( atom . config . get ( 'ide-haskell.switchTabOnCheck' ) )
58
+ } else {
59
+ if ( atom . config . get ( 'ide-haskell.switchTabOnCheck' ) ) {
59
60
this . activateFirstNonEmptyTab ( types )
61
+ }
62
+ }
60
63
this . updateItems ( )
61
- } ) ) ;
64
+ } ) )
62
65
63
66
this . refs . progressBar . setProgress ( 0 )
64
67
65
68
this . disposables . add ( this . refs . buttons . onButtonClicked ( ( ) => this . updateItems ( ) ) )
66
69
this . disposables . add ( this . refs . checkboxUriFilter . onCheckboxSwitched ( ( ) => this . updateItems ( ) ) )
67
70
this . disposables . add ( atom . workspace . onDidChangeActivePaneItem ( ( ) => {
68
- if ( this . refs . checkboxUriFilter . getFileFilter ( ) ) this . updateItems ( ) } ) )
71
+ if ( this . refs . checkboxUriFilter . getFileFilter ( ) ) this . updateItems ( )
72
+ } ) )
69
73
}
70
74
71
- render ( ) {
75
+ render ( ) {
72
76
let orientMap = {
73
77
'top' : 'horizontal' ,
74
78
'bottom' : 'horizontal' ,
75
79
'left' : 'vertical' ,
76
- 'right' : 'vertical' ,
80
+ 'right' : 'vertical'
77
81
}
78
82
return (
79
83
< ide-haskell-panel style = { { width : this . state . width , height : this . state . height } }
80
84
dataset = { { pos : this . pos } }
81
- class = { this . hiddenOutput ? 'hidden-output' : '' } >
85
+ class = { this . hiddenOutput ? 'hidden-output' : '' } >
82
86
< resize-handle on = { { mousedown : this . resizeStart } } />
83
87
< ide-haskell-panel-heading ref = 'heading' >
84
88
< ide-haskell-status-icon ref = 'status' id = 'status' dataset = { { status : 'ready' } } />
@@ -91,15 +95,15 @@ export class OutputPanel {
91
95
</ ide-haskell-panel-heading >
92
96
< OutputPanelItems model = { this . results } ref = 'items' id = 'items' />
93
97
</ ide-haskell-panel >
94
- ) ;
98
+ )
95
99
}
96
100
97
- resizeStart ( e ) {
101
+ resizeStart ( e ) {
98
102
let varsMap = {
99
103
'top' : { axis : 'Y' , param : 'height' , dir : 1 } ,
100
104
'bottom' : { axis : 'Y' , param : 'height' , dir : - 1 } ,
101
105
'left' : { axis : 'X' , param : 'width' , dir : 1 } ,
102
- 'right' : { axis : 'X' , param : 'width' , dir : - 1 } ,
106
+ 'right' : { axis : 'X' , param : 'width' , dir : - 1 }
103
107
}
104
108
105
109
let vars = varsMap [ this . pos ]
@@ -110,7 +114,7 @@ export class OutputPanel {
110
114
111
115
let doDrag = ( e ) => {
112
116
this . state [ vars . param ] =
113
- ( startParam + vars . dir * ( e [ vars . axis ] - startAxis ) ) + 'px' ;
117
+ ( startParam + vars . dir * ( e [ vars . axis ] - startAxis ) ) + 'px'
114
118
this . update ( )
115
119
}
116
120
let stopDrag = ( ) => {
@@ -122,38 +126,34 @@ export class OutputPanel {
122
126
document . documentElement . addEventListener ( 'mouseup' , stopDrag )
123
127
}
124
128
125
- update ( ) {
129
+ update ( ) {
126
130
return etch . update ( this )
127
131
}
128
132
129
- async destroy ( ) {
133
+ async destroy ( ) {
130
134
await etch . destroy ( this )
131
135
this . disposables . dispose ( )
132
136
this . panel . destroy ( )
133
137
this . statusMap . clear ( )
134
138
this . statusMap = null
135
139
}
136
140
137
- addPanelControl ( element , opts ) {
138
- if ( typeof element == 'string' ) {
141
+ addPanelControl ( element , opts ) {
142
+ if ( typeof element = == 'string' ) {
139
143
let { events, classes, style, attrs} = opts
140
144
let props = { }
141
- if ( classes )
142
- props . class = classes . join ( ' ' )
143
- if ( style )
144
- props . style = style
145
- if ( attrs )
146
- props . attributes = attrs
147
- if ( events )
148
- props . on = events
145
+ if ( classes ) props . class = classes . join ( ' ' )
146
+ if ( style ) props . style = style
147
+ if ( attrs ) props . attributes = attrs
148
+ if ( events ) props . on = events
149
149
150
150
element = $ ( element , props )
151
151
this . elements . add ( element )
152
- this . update ( ) ;
152
+ this . update ( )
153
153
return new Disposable ( ( ) => {
154
154
this . elements . delete ( element )
155
- this . update ( ) ;
156
- } ) ;
155
+ this . update ( )
156
+ } )
157
157
} else {
158
158
opts . ref = `${ opts . pluginName } .${ opts . name } .${ Date . now ( ) } `
159
159
element = $ ( element , opts )
@@ -163,99 +163,96 @@ export class OutputPanel {
163
163
let ref = this . refs [ opts . ref ]
164
164
ref . disposables . add ( new Disposable ( ( ) => {
165
165
this . elements . delete ( element )
166
- this . update ( ) ;
167
- } ) ) ;
168
- return ref ;
166
+ this . update ( )
167
+ } ) )
168
+ return ref
169
169
} )
170
170
}
171
171
}
172
172
173
- setHideParameterValues ( value ) {
173
+ setHideParameterValues ( value ) {
174
174
Array . prototype . slice . call ( this . refs . heading . querySelectorAll ( 'ide-haskell-param' ) ) . forEach ( ( el ) => {
175
- if ( value )
176
- el . classList . add ( 'hidden-value' )
177
- else
178
- el . classList . remove ( 'hidden-value' )
179
- } )
175
+ if ( value ) el . classList . add ( 'hidden-value' )
176
+ else el . classList . remove ( 'hidden-value' )
177
+ } )
180
178
}
181
179
182
- updateItems ( ) {
183
- activeTab = this . getActiveTab ( )
180
+ updateItems ( ) {
181
+ let activeTab = this . getActiveTab ( )
184
182
let uri
185
- if ( activeTab ) {
183
+ if ( activeTab ) {
186
184
this . hiddenOutput = false
187
185
let filter = { severity : activeTab }
188
- if ( this . refs . checkboxUriFilter . getFileFilter ( ) ) {
186
+ if ( this . refs . checkboxUriFilter . getFileFilter ( ) ) {
189
187
uri = atom . workspace . getActiveTextEditor ( ) . getPath ( )
190
- if ( uri && this . refs . buttons . options ( activeTab ) . uriFilter )
188
+ if ( uri && this . refs . buttons . options ( activeTab ) . uriFilter ) {
191
189
filter . uri = uri
190
+ }
192
191
}
193
- scroll = this . refs . buttons . options ( activeTab ) . autoScroll && this . refs . items . atEnd ( )
192
+ let scroll = this . refs . buttons . options ( activeTab ) . autoScroll && this . refs . items . atEnd ( )
194
193
this . refs . items . filter ( filter )
195
- if ( scroll ) this . refs . items . scrollToEnd ( )
194
+ if ( scroll ) this . refs . items . scrollToEnd ( )
196
195
} else {
197
196
this . hiddenOutput = true
198
197
}
199
198
200
199
this . refs . buttons . buttonNames ( ) . forEach ( ( btn ) => {
201
200
let f = { severity : btn }
202
- if ( uri && this . refs . buttons . options ( btn ) . uriFilter )
203
- f . uri = uri
201
+ if ( uri && this . refs . buttons . options ( btn ) . uriFilter ) f . uri = uri
204
202
this . refs . buttons . setCount ( btn , this . results . filter ( f ) . length )
205
203
} )
206
204
this . update ( )
207
205
}
208
206
209
- activateTab ( tab ) {
207
+ activateTab ( tab ) {
210
208
this . refs . buttons . clickButton ( tab , true )
211
209
}
212
210
213
- activateFirstNonEmptyTab ( types ) {
211
+ activateFirstNonEmptyTab ( types ) {
214
212
let names = this . refs . buttons . buttonNames ( )
215
- for ( i in names ) {
213
+ for ( let i in names ) {
216
214
let name = names [ i ]
217
- if ( ! types || types . includes ( name ) ) {
218
- if ( ( this . results . filter ( { severity : name } ) ) . length > 0 )
215
+ if ( ! types || types . includes ( name ) ) {
216
+ if ( ( this . results . filter ( { severity : name } ) ) . length > 0 ) {
219
217
this . activateTab ( name )
220
218
break
219
+ }
221
220
}
222
221
}
223
222
}
224
223
225
- showItem ( item ) {
224
+ showItem ( item ) {
226
225
this . activateTab ( item . severity )
227
226
this . refs . items . showItem ( item )
228
227
}
229
228
230
- getActiveTab ( ) {
229
+ getActiveTab ( ) {
231
230
return this . refs . buttons . getActive ( )
232
231
}
233
232
234
- createTab ( name , opts ) {
235
- if ( ! this . refs . buttons . buttonNames ( ) . includes ( name ) ) {
233
+ createTab ( name , opts ) {
234
+ if ( ! this . refs . buttons . buttonNames ( ) . includes ( name ) ) {
236
235
this . refs . buttons . createButton ( name , opts )
237
236
this . activateTab ( this . state . activeTab )
238
237
}
239
238
}
240
239
241
- setProgress ( progress ) {
240
+ setProgress ( progress ) {
242
241
this . refs . progressBar . setProgress ( progress )
243
242
}
244
243
245
- toggle ( ) {
246
- if ( this . panel . isVisible ( ) )
247
- this . panel . hide ( )
248
- else
249
- this . panel . show ( )
244
+ toggle ( ) {
245
+ if ( this . panel . isVisible ( ) ) this . panel . hide ( )
246
+ else this . panel . show ( )
250
247
}
251
248
252
- serialize ( ) {
249
+ serialize ( ) {
253
250
return {
254
251
visibility : this . panel . isVisible ( ) ,
255
252
height : this . element . style . height ,
256
253
width : this . element . style . width ,
257
254
activeTab : this . getActiveTab ( ) ,
258
- fileFilter : this . refs . checkboxUriFilter . getFileFilter ( ) ,
255
+ fileFilter : this . refs . checkboxUriFilter . getFileFilter ( )
259
256
}
260
257
}
261
258
@@ -274,30 +271,30 @@ export class OutputPanel {
274
271
this . setProgress ( progress )
275
272
}
276
273
277
- showNextError ( ) {
274
+ showNextError ( ) {
278
275
let rs = this . results . resultsWithURI ( )
279
- if ( rs . length == 0 ) return
276
+ if ( rs . length = == 0 ) return
280
277
281
- if ( this . currentResult !== null && this . currentResult !== undefined )
278
+ if ( this . currentResult !== null && this . currentResult !== undefined ) {
282
279
this . currentResult ++
283
- else
284
- this . currentResult = 0
285
- if ( this . currentResult >= rs . length )
280
+ } else {
286
281
this . currentResult = 0
282
+ }
283
+ if ( this . currentResult >= rs . length ) this . currentResult = 0
287
284
288
285
this . showItem ( rs [ this . currentResult ] )
289
286
}
290
287
291
- showPrevError ( ) {
288
+ showPrevError ( ) {
292
289
let rs = this . results . resultsWithURI ( )
293
- if ( rs . length == 0 ) return
290
+ if ( rs . length = == 0 ) return
294
291
295
- if ( this . currentResult !== null && this . currentResult !== undefined )
292
+ if ( this . currentResult !== null && this . currentResult !== undefined ) {
296
293
this . currentResult --
297
- else
298
- this . currentResult = rs . length - 1
299
- if ( this . currentResult < 0 )
294
+ } else {
300
295
this . currentResult = rs . length - 1
296
+ }
297
+ if ( this . currentResult < 0 ) this . currentResult = rs . length - 1
301
298
302
299
this . showItem ( rs [ this . currentResult ] )
303
300
}
0 commit comments