@@ -97,28 +97,22 @@ namespace ts {
9797 } ;
9898 }
9999
100- export function createPatternMatcher ( pattern : string ) : PatternMatcher {
100+ export function createPatternMatcher ( pattern : string ) : PatternMatcher | undefined {
101101 // We'll often see the same candidate string many times when searching (For example, when
102102 // we see the name of a module that is used everywhere, or the name of an overload). As
103103 // such, we cache the information we compute about the candidate for the life of this
104104 // pattern matcher so we don't have to compute it multiple times.
105105 const stringToWordSpans = createMap < TextSpan [ ] > ( ) ;
106106
107- pattern = pattern . trim ( ) ;
108-
109- const dotSeparatedSegments = pattern . split ( "." ) . map ( p => createSegment ( p . trim ( ) ) ) ;
110- const invalidPattern = dotSeparatedSegments . length === 0 || forEach ( dotSeparatedSegments , segmentIsInvalid ) ;
107+ const dotSeparatedSegments = pattern . trim ( ) . split ( "." ) . map ( p => createSegment ( p . trim ( ) ) ) ;
108+ // A segment is considered invalid if we couldn't find any words in it.
109+ if ( dotSeparatedSegments . some ( segment => ! segment . subWordTextChunks . length ) ) return undefined ;
111110
112111 return {
113- getMatches : ( containers , candidate ) => skipMatch ( candidate ) ? undefined : getMatches ( containers , candidate , dotSeparatedSegments , stringToWordSpans ) ,
114- getMatchesForLastSegmentOfPattern : candidate => skipMatch ( candidate ) ? undefined : matchSegment ( candidate , lastOrUndefined ( dotSeparatedSegments ) , stringToWordSpans ) ,
112+ getMatches : ( containers , candidate ) => getMatches ( containers , candidate , dotSeparatedSegments , stringToWordSpans ) ,
113+ getMatchesForLastSegmentOfPattern : candidate => matchSegment ( candidate , last ( dotSeparatedSegments ) , stringToWordSpans ) ,
115114 patternContainsDots : dotSeparatedSegments . length > 1
116115 } ;
117-
118- // Quick checks so we can bail out when asked to match a candidate.
119- function skipMatch ( candidate : string ) {
120- return invalidPattern || ! candidate ;
121- }
122116 }
123117
124118 function getMatches ( candidateContainers : ReadonlyArray < string > , candidate : string , dotSeparatedSegments : ReadonlyArray < Segment > , stringToWordSpans : Map < TextSpan [ ] > ) : PatternMatch [ ] | undefined {
@@ -381,11 +375,6 @@ namespace ts {
381375 } ;
382376 }
383377
384- // A segment is considered invalid if we couldn't find any words in it.
385- function segmentIsInvalid ( segment : Segment ) {
386- return segment . subWordTextChunks . length === 0 ;
387- }
388-
389378 function isUpperCaseLetter ( ch : number ) {
390379 // Fast check for the ascii range.
391380 if ( ch >= CharacterCodes . A && ch <= CharacterCodes . Z ) {
0 commit comments