@@ -13,7 +13,6 @@ const {getPackageRoot} = require('./helpers')
1313
1414module . exports = {
1515 activate ( ) {
16- console . log ( "Using local package snippets" )
1716 this . loaded = false
1817 this . userSnippetsPath = null
1918 this . snippetIdCounter = 0
@@ -100,8 +99,8 @@ module.exports = {
10099 this . loadPackageSnippets ( packageSnippets => {
101100 this . loadUserSnippets ( userSnippets => {
102101 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 ) {
105104 const snippetsBySelector = snippetSet [ filepath ]
106105 this . add ( filepath , snippetsBySelector )
107106 }
@@ -161,7 +160,7 @@ module.exports = {
161160
162161 callback ( userSnippetsFileDisposable )
163162 } else {
164- callback ( new Disposable ( ) ) // TODO: Work out why it was passed -> in coffeescript
163+ callback ( new Disposable ( ) )
165164 }
166165 } )
167166 } ,
@@ -183,23 +182,23 @@ module.exports = {
183182 handleDisabledPackagesDidChange ( newDisabledPackages = [ ] , oldDisabledPackages = [ ] ) {
184183 const packagesToAdd = [ ]
185184 const packagesToRemove = [ ]
186- for ( let p of oldDisabledPackages ) {
185+ for ( const p of oldDisabledPackages ) {
187186 if ( ! newDisabledPackages . includes ( p ) ) { packagesToAdd . push ( p ) }
188187 }
189188
190- for ( let p of newDisabledPackages ) {
189+ for ( const p of newDisabledPackages ) {
191190 if ( ! oldDisabledPackages . includes ( p ) ) { packagesToRemove . push ( p ) }
192191 }
193192
194193 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 ) }
197196 } )
198197 } ,
199198
200199 addSnippetsForPackage ( packageName ) {
201200 const snippetSet = this . snippetsByPackage . get ( packageName )
202- for ( let filePath in snippetSet ) {
201+ for ( const filePath in snippetSet ) {
203202 const snippetsBySelector = snippetSet [ filePath ]
204203 this . add ( filePath , snippetsBySelector )
205204 }
@@ -211,7 +210,7 @@ module.exports = {
211210 // remain present in the list of unparsed snippets reported to the settings
212211 // view.
213212 this . addSnippetsInDisabledPackage ( snippetSet )
214- for ( let filePath in snippetSet ) {
213+ for ( const filePath in snippetSet ) {
215214 this . clearSnippetsForPath ( filePath )
216215 }
217216 } ,
@@ -223,18 +222,18 @@ module.exports = {
223222 } )
224223
225224 const snippetsDirPaths = [ ]
226- for ( let pack of packages ) {
225+ for ( const pack of packages ) {
227226 snippetsDirPaths . push ( path . join ( pack . path , 'snippets' ) )
228227 }
229228
230229 async . map ( snippetsDirPaths , this . loadSnippetsDirectory . bind ( this ) , ( error , results ) => {
231230 const zipped = [ ]
232- for ( let key in results ) {
231+ for ( const key in results ) {
233232 zipped . push ( { result : results [ key ] , pack : packages [ key ] } )
234233 }
235234
236235 const enabledPackages = [ ]
237- for ( let o of zipped ) {
236+ for ( const o of zipped ) {
238237 // Skip packages that contain no snippets.
239238 if ( Object . keys ( o . result ) . length === 0 ) { continue }
240239 // Keep track of which snippets come from which packages so we can
@@ -277,7 +276,7 @@ module.exports = {
277276 fs . isDirectory ( snippetsDirPath , isDirectory => {
278277 if ( ! isDirectory ) { return callback ( null , { } ) }
279278
280- return fs . readdir ( snippetsDirPath , ( error , entries ) => {
279+ fs . readdir ( snippetsDirPath , ( error , entries ) => {
281280 if ( error ) {
282281 console . warn ( `Error reading snippets directory ${ snippetsDirPath } ` , error )
283282 return callback ( null , { } )
@@ -291,7 +290,7 @@ module.exports = {
291290 } ,
292291 ( error , results ) => {
293292 const snippetsByPath = { }
294- for ( let { filePath, snippets} of results ) {
293+ for ( const { filePath, snippets} of results ) {
295294 snippetsByPath [ filePath ] = snippets
296295 }
297296 callback ( null , snippetsByPath )
@@ -312,10 +311,10 @@ module.exports = {
312311 } ,
313312
314313 add ( filePath , snippetsBySelector , isDisabled = false ) {
315- for ( let selector in snippetsBySelector ) {
314+ for ( const selector in snippetsBySelector ) {
316315 const snippetsByName = snippetsBySelector [ selector ]
317316 const unparsedSnippetsByPrefix = { }
318- for ( let name in snippetsByName ) {
317+ for ( const name in snippetsByName ) {
319318 const attributes = snippetsByName [ name ]
320319 const { prefix, body} = attributes
321320 attributes . name = name
@@ -332,7 +331,7 @@ module.exports = {
332331 } ,
333332
334333 addSnippetsInDisabledPackage ( bundle ) {
335- for ( let filePath in bundle ) {
334+ for ( const filePath in bundle ) {
336335 const snippetsBySelector = bundle [ filePath ]
337336 this . add ( filePath , snippetsBySelector , true )
338337 }
@@ -358,13 +357,13 @@ module.exports = {
358357 const unparsedSnippets = { }
359358 unparsedSnippets [ selector ] = { "snippets" : value }
360359 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 ) } )
362361 } ,
363362
364363 clearSnippetsForPath ( path ) {
365- for ( let scopeSelector in this . scopedPropertyStore . propertiesForSource ( path ) ) {
364+ for ( const scopeSelector in this . scopedPropertyStore . propertiesForSource ( path ) ) {
366365 const object = this . scopedPropertyStore . propertiesForSourceAndSelector ( path , scopeSelector )
367- for ( let prefix in object ) {
366+ for ( const prefix in object ) {
368367 const attributes = object [ prefix ]
369368 this . parsedSnippetsById . delete ( attributes . id )
370369 }
@@ -374,8 +373,6 @@ module.exports = {
374373 } ,
375374
376375 parsedSnippetsForScopes ( scopeDescriptor ) {
377- let attributes
378- let prefix
379376 let unparsedLegacySnippetsByPrefix
380377
381378 const unparsedSnippetsByPrefix = this . scopedPropertyStore . getPropertyValue (
@@ -397,16 +394,16 @@ module.exports = {
397394 const snippets = { }
398395
399396 if ( unparsedSnippetsByPrefix ) {
400- for ( prefix in unparsedSnippetsByPrefix ) {
401- attributes = unparsedSnippetsByPrefix [ prefix ]
397+ for ( const prefix in unparsedSnippetsByPrefix ) {
398+ const attributes = unparsedSnippetsByPrefix [ prefix ]
402399 if ( typeof ( attributes != null ? attributes . body : undefined ) !== 'string' ) { continue }
403400 snippets [ prefix ] = this . getParsedSnippet ( attributes )
404401 }
405402 }
406403
407404 if ( unparsedLegacySnippetsByPrefix ) {
408- for ( prefix in unparsedLegacySnippetsByPrefix ) {
409- attributes = unparsedLegacySnippetsByPrefix [ prefix ]
405+ for ( const prefix in unparsedLegacySnippetsByPrefix ) {
406+ const attributes = unparsedLegacySnippetsByPrefix [ prefix ]
410407 if ( snippets [ prefix ] ) { continue }
411408 if ( typeof ( attributes != null ? attributes . body : undefined ) !== 'string' ) { continue }
412409 snippets [ prefix ] = this . getParsedSnippet ( attributes )
@@ -453,7 +450,7 @@ module.exports = {
453450 let snippetPrefix = null
454451 let wordPrefix = null
455452
456- for ( let cursor of editor . getCursors ( ) ) {
453+ for ( const cursor of editor . getCursors ( ) ) {
457454 const position = cursor . getBufferPosition ( )
458455
459456 const prefixStart = cursor . getBeginningOfCurrentWordBufferPosition ( { wordRegex} )
@@ -474,8 +471,8 @@ module.exports = {
474471 wordRegexForSnippets ( snippets ) {
475472 const prefixes = { }
476473
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 }
479476 }
480477
481478 const prefixCharacters = Object . keys ( prefixes ) . join ( '' )
@@ -487,7 +484,7 @@ module.exports = {
487484 snippetForPrefix ( snippets , prefix , wordPrefix ) {
488485 let longestPrefixMatch = null
489486
490- for ( let snippetPrefix in snippets ) {
487+ for ( const snippetPrefix in snippets ) {
491488 const snippet = snippets [ snippetPrefix ]
492489 if ( prefix . endsWith ( snippetPrefix ) && ( wordPrefix . length <= snippetPrefix . length ) ) {
493490 if ( ( longestPrefixMatch == null ) || ( snippetPrefix . length > longestPrefixMatch . prefix . length ) ) {
@@ -508,14 +505,14 @@ module.exports = {
508505 const snippets = this . getSnippets ( editor )
509506 if ( _ . isEmpty ( snippets ) ) { return false }
510507
511- let prefixData = this . getPrefixText ( snippets , editor )
508+ const prefixData = this . getPrefixText ( snippets , editor )
512509 if ( prefixData ) {
513510 return this . snippetForPrefix ( snippets , prefixData . snippetPrefix , prefixData . wordPrefix )
514511 }
515512 } ,
516513
517514 expandSnippetsUnderCursors ( editor ) {
518- let snippet = this . snippetToExpandUnderCursor ( editor )
515+ const snippet = this . snippetToExpandUnderCursor ( editor )
519516 if ( ! snippet ) { return false }
520517
521518 this . getStore ( editor ) . observeHistory ( {
@@ -526,7 +523,7 @@ module.exports = {
526523 this . findOrCreateMarkerLayer ( editor )
527524 editor . transact ( ( ) => {
528525 const cursors = editor . getCursors ( )
529- for ( let cursor of cursors ) {
526+ for ( const cursor of cursors ) {
530527 const cursorPosition = cursor . getBufferPosition ( )
531528 const startPoint = cursorPosition . translate ( [ 0 , - snippet . prefix . length ] , [ 0 , 0 ] )
532529 cursor . selection . setBufferRange ( [ startPoint , cursorPosition ] )
@@ -538,8 +535,8 @@ module.exports = {
538535
539536 goToNextTabStop ( editor ) {
540537 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 ( ) ) {
543540 nextTabStopVisited = true
544541 }
545542 }
@@ -548,8 +545,8 @@ module.exports = {
548545
549546 goToPreviousTabStop ( editor ) {
550547 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 ( ) ) {
553550 previousTabStopVisited = true
554551 }
555552 }
@@ -560,10 +557,6 @@ module.exports = {
560557 return EditorStore . findOrCreate ( editor )
561558 } ,
562559
563- // createMarkerLayer (editor) {
564- // this.editorMarkerLayers.set(editor, editor.addMarkerLayer({maintainHistory: true}))
565- // },
566-
567560 findOrCreateMarkerLayer ( editor ) {
568561 let layer = this . editorMarkerLayers . get ( editor )
569562 if ( layer === undefined ) {
@@ -598,9 +591,7 @@ module.exports = {
598591
599592 this . ignoringTextChangesForEditor ( editor , ( ) =>
600593 editor . transact ( ( ) =>
601- activeExpansions . map ( expansion =>
602- expansion . textChanged ( event ) )
603- )
594+ activeExpansions . map ( expansion => expansion . textChanged ( event ) ) )
604595 )
605596
606597 // Create a checkpoint here to consolidate all the changes we just made into
@@ -641,7 +632,7 @@ module.exports = {
641632 getUnparsedSnippets ( ) {
642633 const results = [ ]
643634 const iterate = sets => {
644- for ( let item of sets ) {
635+ for ( const item of sets ) {
645636 const newItem = _ . deepClone ( item )
646637 // The atom-slick library has already parsed the `selector` property, so
647638 // it's an AST here instead of a string. The object has a `toString`
0 commit comments