nl_tokens: Given an initial searchMeaning extracted from a location widen the search scope based on the declarations of the corresponding symbol . e . g . if we are searching for Foo in value position but Foo references a class then we need to widen the search to include type positions as well . On the contrary if we are searching for Bar in type position and we trace bar to an interface and an uninstantiated module we want to keep the search limited to only types as the two declarations ( interface and uninstantiated module ) do not intersect in any of the three spaces .
pl_tokens: function getIntersectingMeaningFromDeclarations ( meaning , declarations ) { if ( declarations ) { var lastIterationMeaning ; <mask> { // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module // intersects with the class in the value space. // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning ; for ( var _i = 0 ; _i < declarations . length ; _i ++ ) { var declaration = declarations [ _i ] ; var declarationMeaning = getMeaningFromDeclaration ( declaration ) ; if ( declarationMeaning & meaning ) { meaning |= declarationMeaning ; } } } while ( meaning !== lastIterationMeaning ) ; } return meaning ; }