@@ -13,7 +13,6 @@ const {getPackageRoot} = require('./helpers')
13
13
14
14
module . exports = {
15
15
activate ( ) {
16
- console . log ( "Using local package snippets" )
17
16
this . loaded = false
18
17
this . userSnippetsPath = null
19
18
this . snippetIdCounter = 0
@@ -100,8 +99,8 @@ module.exports = {
100
99
this . loadPackageSnippets ( packageSnippets => {
101
100
this . loadUserSnippets ( userSnippets => {
102
101
atom . config . transact ( ( ) => {
103
- for ( let snippetSet of [ bundledSnippets , packageSnippets , userSnippets ] ) {
104
- for ( let filepath in snippetSet ) {
102
+ for ( const snippetSet of [ bundledSnippets , packageSnippets , userSnippets ] ) {
103
+ for ( const filepath in snippetSet ) {
105
104
const snippetsBySelector = snippetSet [ filepath ]
106
105
this . add ( filepath , snippetsBySelector )
107
106
}
@@ -161,7 +160,7 @@ module.exports = {
161
160
162
161
callback ( userSnippetsFileDisposable )
163
162
} else {
164
- callback ( new Disposable ( ) ) // TODO: Work out why it was passed -> in coffeescript
163
+ callback ( new Disposable ( ) )
165
164
}
166
165
} )
167
166
} ,
@@ -183,23 +182,23 @@ module.exports = {
183
182
handleDisabledPackagesDidChange ( newDisabledPackages = [ ] , oldDisabledPackages = [ ] ) {
184
183
const packagesToAdd = [ ]
185
184
const packagesToRemove = [ ]
186
- for ( let p of oldDisabledPackages ) {
185
+ for ( const p of oldDisabledPackages ) {
187
186
if ( ! newDisabledPackages . includes ( p ) ) { packagesToAdd . push ( p ) }
188
187
}
189
188
190
- for ( let p of newDisabledPackages ) {
189
+ for ( const p of newDisabledPackages ) {
191
190
if ( ! oldDisabledPackages . includes ( p ) ) { packagesToRemove . push ( p ) }
192
191
}
193
192
194
193
atom . config . transact ( ( ) => {
195
- for ( let p of packagesToRemove ) { this . removeSnippetsForPackage ( p ) }
196
- for ( let p of packagesToAdd ) { this . addSnippetsForPackage ( p ) }
194
+ for ( const p of packagesToRemove ) { this . removeSnippetsForPackage ( p ) }
195
+ for ( const p of packagesToAdd ) { this . addSnippetsForPackage ( p ) }
197
196
} )
198
197
} ,
199
198
200
199
addSnippetsForPackage ( packageName ) {
201
200
const snippetSet = this . snippetsByPackage . get ( packageName )
202
- for ( let filePath in snippetSet ) {
201
+ for ( const filePath in snippetSet ) {
203
202
const snippetsBySelector = snippetSet [ filePath ]
204
203
this . add ( filePath , snippetsBySelector )
205
204
}
@@ -211,7 +210,7 @@ module.exports = {
211
210
// remain present in the list of unparsed snippets reported to the settings
212
211
// view.
213
212
this . addSnippetsInDisabledPackage ( snippetSet )
214
- for ( let filePath in snippetSet ) {
213
+ for ( const filePath in snippetSet ) {
215
214
this . clearSnippetsForPath ( filePath )
216
215
}
217
216
} ,
@@ -223,18 +222,18 @@ module.exports = {
223
222
} )
224
223
225
224
const snippetsDirPaths = [ ]
226
- for ( let pack of packages ) {
225
+ for ( const pack of packages ) {
227
226
snippetsDirPaths . push ( path . join ( pack . path , 'snippets' ) )
228
227
}
229
228
230
229
async . map ( snippetsDirPaths , this . loadSnippetsDirectory . bind ( this ) , ( error , results ) => {
231
230
const zipped = [ ]
232
- for ( let key in results ) {
231
+ for ( const key in results ) {
233
232
zipped . push ( { result : results [ key ] , pack : packages [ key ] } )
234
233
}
235
234
236
235
const enabledPackages = [ ]
237
- for ( let o of zipped ) {
236
+ for ( const o of zipped ) {
238
237
// Skip packages that contain no snippets.
239
238
if ( Object . keys ( o . result ) . length === 0 ) { continue }
240
239
// Keep track of which snippets come from which packages so we can
@@ -277,7 +276,7 @@ module.exports = {
277
276
fs . isDirectory ( snippetsDirPath , isDirectory => {
278
277
if ( ! isDirectory ) { return callback ( null , { } ) }
279
278
280
- return fs . readdir ( snippetsDirPath , ( error , entries ) => {
279
+ fs . readdir ( snippetsDirPath , ( error , entries ) => {
281
280
if ( error ) {
282
281
console . warn ( `Error reading snippets directory ${ snippetsDirPath } ` , error )
283
282
return callback ( null , { } )
@@ -291,7 +290,7 @@ module.exports = {
291
290
} ,
292
291
( error , results ) => {
293
292
const snippetsByPath = { }
294
- for ( let { filePath, snippets} of results ) {
293
+ for ( const { filePath, snippets} of results ) {
295
294
snippetsByPath [ filePath ] = snippets
296
295
}
297
296
callback ( null , snippetsByPath )
@@ -312,10 +311,10 @@ module.exports = {
312
311
} ,
313
312
314
313
add ( filePath , snippetsBySelector , isDisabled = false ) {
315
- for ( let selector in snippetsBySelector ) {
314
+ for ( const selector in snippetsBySelector ) {
316
315
const snippetsByName = snippetsBySelector [ selector ]
317
316
const unparsedSnippetsByPrefix = { }
318
- for ( let name in snippetsByName ) {
317
+ for ( const name in snippetsByName ) {
319
318
const attributes = snippetsByName [ name ]
320
319
const { prefix, body} = attributes
321
320
attributes . name = name
@@ -332,7 +331,7 @@ module.exports = {
332
331
} ,
333
332
334
333
addSnippetsInDisabledPackage ( bundle ) {
335
- for ( let filePath in bundle ) {
334
+ for ( const filePath in bundle ) {
336
335
const snippetsBySelector = bundle [ filePath ]
337
336
this . add ( filePath , snippetsBySelector , true )
338
337
}
@@ -358,13 +357,13 @@ module.exports = {
358
357
const unparsedSnippets = { }
359
358
unparsedSnippets [ selector ] = { "snippets" : value }
360
359
const store = isDisabled ? this . disabledSnippetsScopedPropertyStore : this . scopedPropertyStore
361
- return store . addProperties ( path , unparsedSnippets , { priority : this . priorityForSource ( path ) } )
360
+ store . addProperties ( path , unparsedSnippets , { priority : this . priorityForSource ( path ) } )
362
361
} ,
363
362
364
363
clearSnippetsForPath ( path ) {
365
- for ( let scopeSelector in this . scopedPropertyStore . propertiesForSource ( path ) ) {
364
+ for ( const scopeSelector in this . scopedPropertyStore . propertiesForSource ( path ) ) {
366
365
const object = this . scopedPropertyStore . propertiesForSourceAndSelector ( path , scopeSelector )
367
- for ( let prefix in object ) {
366
+ for ( const prefix in object ) {
368
367
const attributes = object [ prefix ]
369
368
this . parsedSnippetsById . delete ( attributes . id )
370
369
}
@@ -374,8 +373,6 @@ module.exports = {
374
373
} ,
375
374
376
375
parsedSnippetsForScopes ( scopeDescriptor ) {
377
- let attributes
378
- let prefix
379
376
let unparsedLegacySnippetsByPrefix
380
377
381
378
const unparsedSnippetsByPrefix = this . scopedPropertyStore . getPropertyValue (
@@ -397,16 +394,16 @@ module.exports = {
397
394
const snippets = { }
398
395
399
396
if ( unparsedSnippetsByPrefix ) {
400
- for ( prefix in unparsedSnippetsByPrefix ) {
401
- attributes = unparsedSnippetsByPrefix [ prefix ]
397
+ for ( const prefix in unparsedSnippetsByPrefix ) {
398
+ const attributes = unparsedSnippetsByPrefix [ prefix ]
402
399
if ( typeof ( attributes != null ? attributes . body : undefined ) !== 'string' ) { continue }
403
400
snippets [ prefix ] = this . getParsedSnippet ( attributes )
404
401
}
405
402
}
406
403
407
404
if ( unparsedLegacySnippetsByPrefix ) {
408
- for ( prefix in unparsedLegacySnippetsByPrefix ) {
409
- attributes = unparsedLegacySnippetsByPrefix [ prefix ]
405
+ for ( const prefix in unparsedLegacySnippetsByPrefix ) {
406
+ const attributes = unparsedLegacySnippetsByPrefix [ prefix ]
410
407
if ( snippets [ prefix ] ) { continue }
411
408
if ( typeof ( attributes != null ? attributes . body : undefined ) !== 'string' ) { continue }
412
409
snippets [ prefix ] = this . getParsedSnippet ( attributes )
@@ -453,7 +450,7 @@ module.exports = {
453
450
let snippetPrefix = null
454
451
let wordPrefix = null
455
452
456
- for ( let cursor of editor . getCursors ( ) ) {
453
+ for ( const cursor of editor . getCursors ( ) ) {
457
454
const position = cursor . getBufferPosition ( )
458
455
459
456
const prefixStart = cursor . getBeginningOfCurrentWordBufferPosition ( { wordRegex} )
@@ -474,8 +471,8 @@ module.exports = {
474
471
wordRegexForSnippets ( snippets ) {
475
472
const prefixes = { }
476
473
477
- for ( let prefix in snippets ) {
478
- for ( let character of prefix ) { prefixes [ character ] = true }
474
+ for ( const prefix in snippets ) {
475
+ for ( const character of prefix ) { prefixes [ character ] = true }
479
476
}
480
477
481
478
const prefixCharacters = Object . keys ( prefixes ) . join ( '' )
@@ -487,7 +484,7 @@ module.exports = {
487
484
snippetForPrefix ( snippets , prefix , wordPrefix ) {
488
485
let longestPrefixMatch = null
489
486
490
- for ( let snippetPrefix in snippets ) {
487
+ for ( const snippetPrefix in snippets ) {
491
488
const snippet = snippets [ snippetPrefix ]
492
489
if ( prefix . endsWith ( snippetPrefix ) && ( wordPrefix . length <= snippetPrefix . length ) ) {
493
490
if ( ( longestPrefixMatch == null ) || ( snippetPrefix . length > longestPrefixMatch . prefix . length ) ) {
@@ -508,14 +505,14 @@ module.exports = {
508
505
const snippets = this . getSnippets ( editor )
509
506
if ( _ . isEmpty ( snippets ) ) { return false }
510
507
511
- let prefixData = this . getPrefixText ( snippets , editor )
508
+ const prefixData = this . getPrefixText ( snippets , editor )
512
509
if ( prefixData ) {
513
510
return this . snippetForPrefix ( snippets , prefixData . snippetPrefix , prefixData . wordPrefix )
514
511
}
515
512
} ,
516
513
517
514
expandSnippetsUnderCursors ( editor ) {
518
- let snippet = this . snippetToExpandUnderCursor ( editor )
515
+ const snippet = this . snippetToExpandUnderCursor ( editor )
519
516
if ( ! snippet ) { return false }
520
517
521
518
this . getStore ( editor ) . observeHistory ( {
@@ -526,7 +523,7 @@ module.exports = {
526
523
this . findOrCreateMarkerLayer ( editor )
527
524
editor . transact ( ( ) => {
528
525
const cursors = editor . getCursors ( )
529
- for ( let cursor of cursors ) {
526
+ for ( const cursor of cursors ) {
530
527
const cursorPosition = cursor . getBufferPosition ( )
531
528
const startPoint = cursorPosition . translate ( [ 0 , - snippet . prefix . length ] , [ 0 , 0 ] )
532
529
cursor . selection . setBufferRange ( [ startPoint , cursorPosition ] )
@@ -538,8 +535,8 @@ module.exports = {
538
535
539
536
goToNextTabStop ( editor ) {
540
537
let nextTabStopVisited = false
541
- for ( let expansion of this . getExpansions ( editor ) ) {
542
- if ( expansion != null ? expansion . goToNextTabStop ( ) : undefined ) {
538
+ for ( const expansion of this . getExpansions ( editor ) ) {
539
+ if ( expansion && expansion . goToNextTabStop ( ) ) {
543
540
nextTabStopVisited = true
544
541
}
545
542
}
@@ -548,8 +545,8 @@ module.exports = {
548
545
549
546
goToPreviousTabStop ( editor ) {
550
547
let previousTabStopVisited = false
551
- for ( let expansion of this . getExpansions ( editor ) ) {
552
- if ( expansion != null ? expansion . goToPreviousTabStop ( ) : undefined ) {
548
+ for ( const expansion of this . getExpansions ( editor ) ) {
549
+ if ( expansion && expansion . goToPreviousTabStop ( ) ) {
553
550
previousTabStopVisited = true
554
551
}
555
552
}
@@ -560,10 +557,6 @@ module.exports = {
560
557
return EditorStore . findOrCreate ( editor )
561
558
} ,
562
559
563
- // createMarkerLayer (editor) {
564
- // this.editorMarkerLayers.set(editor, editor.addMarkerLayer({maintainHistory: true}))
565
- // },
566
-
567
560
findOrCreateMarkerLayer ( editor ) {
568
561
let layer = this . editorMarkerLayers . get ( editor )
569
562
if ( layer === undefined ) {
@@ -598,9 +591,7 @@ module.exports = {
598
591
599
592
this . ignoringTextChangesForEditor ( editor , ( ) =>
600
593
editor . transact ( ( ) =>
601
- activeExpansions . map ( expansion =>
602
- expansion . textChanged ( event ) )
603
- )
594
+ activeExpansions . map ( expansion => expansion . textChanged ( event ) ) )
604
595
)
605
596
606
597
// Create a checkpoint here to consolidate all the changes we just made into
@@ -641,7 +632,7 @@ module.exports = {
641
632
getUnparsedSnippets ( ) {
642
633
const results = [ ]
643
634
const iterate = sets => {
644
- for ( let item of sets ) {
635
+ for ( const item of sets ) {
645
636
const newItem = _ . deepClone ( item )
646
637
// The atom-slick library has already parsed the `selector` property, so
647
638
// it's an AST here instead of a string. The object has a `toString`
0 commit comments