@@ -48,10 +48,6 @@ define(function (require, exports, module) {
48
48
ternEnvironment = [ ] ,
49
49
pendingTernRequests = { } ,
50
50
rootTernDir = null ,
51
- outerScopeWorker = ( function ( ) {
52
- var path = module . uri . substring ( 0 , module . uri . lastIndexOf ( "/" ) + 1 ) ;
53
- return new Worker ( path + "parser-worker.js" ) ;
54
- } ( ) ) ,
55
51
ternWorker = ( function ( ) {
56
52
var path = module . uri . substring ( 0 , module . uri . lastIndexOf ( "/" ) + 1 ) ;
57
53
return new Worker ( path + "tern-worker.js" ) ;
@@ -191,15 +187,6 @@ define(function (require, exports, module) {
191
187
192
188
// the file will be clean since the last outer scope request
193
189
state . dirtyFile = false ;
194
-
195
- // send text to the parser worker
196
- outerScopeWorker . postMessage ( {
197
- type : HintUtils . SCOPE_MSG_TYPE ,
198
- dir : dir ,
199
- file : file ,
200
- text : text ,
201
- force : ! state . scope
202
- } ) ;
203
190
}
204
191
}
205
192
state . text = text ;
@@ -223,128 +210,6 @@ define(function (require, exports, module) {
223
210
*/
224
211
function refreshInnerScope ( dir , file , offset ) {
225
212
226
- /*
227
- * Filter a list of tokens using a given scope object
228
- *
229
- * @param {Array.<Object> } tokens - a list of identifier tokens
230
- * @param {Scope } scope - a scope object
231
- * @return {Array.<Object> } - the sublist of the input list that
232
- * contains all and only the identifier tokens in scope
233
- * w.r.t. to the given scope
234
- */
235
- function filterByScope ( tokens , scope ) {
236
- return tokens . filter ( function ( id ) {
237
- var level = scope . contains ( id . value ) ;
238
- return ( level >= 0 ) ;
239
- } ) ;
240
- }
241
-
242
- /*
243
- * Combine a particular property from a set of sets using a given add
244
- * operation
245
- *
246
- * @param {Object } sets - a set of sets
247
- * @param {string } propName - the property to pick out from each set
248
- * @param {Function } add - the function that combines properties from
249
- * each set
250
- * @return {Object }- the result of combining each set's property using
251
- * the add function
252
- */
253
- function merge ( sets , propName , add ) {
254
- var combinedSet = { } ,
255
- nextSet ,
256
- file ;
257
-
258
- for ( file in sets ) {
259
- if ( sets . hasOwnProperty ( file ) ) {
260
- nextSet = sets [ file ] [ propName ] ;
261
- if ( nextSet ) {
262
- add ( combinedSet , nextSet ) ;
263
- }
264
- }
265
- }
266
-
267
- return combinedSet ;
268
- }
269
-
270
- /*
271
- * Combine properties from files in the current file's directory into
272
- * a single list.
273
- *
274
- * @param {string } dir - the directory name of the files for which
275
- * property lists should be merged
276
- * @param {Array.<Object> } - the combined list of property tokens
277
- */
278
- function mergeProperties ( dir ) {
279
-
280
- function addPropObjs ( obj1 , obj2 ) {
281
- function addToObj ( obj , token ) {
282
- if ( ! Object . prototype . hasOwnProperty . call ( obj , token . value ) ) {
283
- obj [ token . value ] = token ;
284
- }
285
- }
286
-
287
- obj2 . forEach ( function ( token ) {
288
- addToObj ( obj1 , token ) ;
289
- } ) ;
290
- }
291
-
292
- var stateMap = getFileState ( dir ) ,
293
- propObj = merge ( stateMap , "properties" , addPropObjs ) ,
294
- propList = [ ] ,
295
- propName ;
296
-
297
- for ( propName in propObj ) {
298
- if ( Object . prototype . hasOwnProperty . call ( propObj , propName ) ) {
299
- propList . push ( propObj [ propName ] ) ;
300
- }
301
- }
302
-
303
- return propList ;
304
- }
305
-
306
- /*
307
- * Combine association set objects from all of the files in a given
308
- * directory
309
- *
310
- * @param {string } dir - the directory name of the files for which
311
- * association sets should be merged
312
- * @param {Object } - the combined association set object
313
- */
314
- function mergeAssociations ( dir ) {
315
- function addAssocSets ( list1 , list2 ) {
316
- var name ;
317
-
318
- function addAssocObjs ( assoc1 , assoc2 ) {
319
- var name ;
320
-
321
- for ( name in assoc2 ) {
322
- if ( Object . prototype . hasOwnProperty . call ( assoc2 , name ) ) {
323
- if ( Object . prototype . hasOwnProperty . call ( assoc1 , name ) ) {
324
- assoc1 [ name ] = assoc1 [ name ] + assoc2 [ name ] ;
325
- } else {
326
- assoc1 [ name ] = assoc2 [ name ] ;
327
- }
328
- }
329
- }
330
- }
331
-
332
- for ( name in list2 ) {
333
- if ( Object . prototype . hasOwnProperty . call ( list2 , name ) ) {
334
- if ( Object . prototype . hasOwnProperty . call ( list1 , name ) ) {
335
- addAssocObjs ( list1 [ name ] , list2 [ name ] ) ;
336
- } else {
337
- list1 [ name ] = list2 [ name ] ;
338
- }
339
- }
340
- }
341
- }
342
-
343
- var stateMap = getFileState ( dir ) ;
344
-
345
- return merge ( stateMap , "associations" , addAssocSets ) ;
346
- }
347
-
348
213
var state = getFileState ( dir , file ) ;
349
214
350
215
// If there is no outer scope, the inner scope request is deferred.
@@ -425,27 +290,13 @@ define(function (require, exports, module) {
425
290
dir = split . dir ,
426
291
file = split . file ;
427
292
428
- var $deferredHints = $ . Deferred ( ) ;
429
-
430
- var scopeInfo = refreshInnerScope ( dir , file , offset ) ;
293
+ var $deferredHints = $ . Deferred ( ) ,
294
+ ternPromise = getTernHints ( "dir" , "file" , offset , document . getText ( ) ) ;
431
295
432
- var scopePromise ;
433
- if ( scopeInfo . hasOwnProperty ( "promise" ) ) {
434
- scopePromise = scopeInfo . promise ;
435
- }
436
- else {
437
- // make a scopePromise that we can pass to when below
438
- var $scopeInfo = $ . Deferred ( ) ;
439
- scopePromise = $scopeInfo . promise ( ) ;
440
- $scopeInfo . resolveWith ( null , [ scopeInfo ] ) ;
441
- }
442
-
443
- var ternPromise = getTernHints ( "dir" , "file" , offset , document . getText ( ) ) ;
444
-
445
- $ . when ( scopePromise , ternPromise ) . done (
446
- function ( scopeInfo , ternHints ) {
296
+ $ . when ( ternPromise ) . done (
297
+ function ( ternHints ) {
447
298
session . setTernHints ( ternHints ) ;
448
- $deferredHints . resolveWith ( null , [ scopeInfo ] ) ;
299
+ $deferredHints . resolveWith ( null ) ;
449
300
} ) ;
450
301
return { promise :$deferredHints . promise ( ) } ;
451
302
}
@@ -654,18 +505,6 @@ define(function (require, exports, module) {
654
505
}
655
506
}
656
507
657
- // handle response objects, otherwise log the message
658
- outerScopeWorker . addEventListener ( "message" , function ( e ) {
659
- var response = e . data ,
660
- type = response . type ;
661
-
662
- if ( type === HintUtils . SCOPE_MSG_TYPE ) {
663
- handleOuterScope ( response ) ;
664
- } else {
665
- console . log ( "Worker: " + ( response . log || response ) ) ;
666
- }
667
- } ) ;
668
-
669
508
ternWorker . addEventListener ( "message" , function ( e ) {
670
509
var response = e . data ,
671
510
type = response . type ;
0 commit comments