{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/25144557","id":25144557,"diff_hunk":"@@ -0,0 +1,810 @@\n+module ts {\r\n+    // Note(cyrusn): this enum is ordered from strongest match type to weakest match type.\r\n+    export enum PatternMatchKind {\r\n+        Exact,\r\n+        Prefix,\r\n+        Substring,\r\n+        CamelCase\r\n+    }\r\n+\r\n+    // Information about a match made by the pattern matcher between a candidate and the \r\n+    // search pattern.\r\n+    export interface PatternMatch {\r\n+        // What kind of match this was.  Exact matches are better than prefix matches which are \r\n+        // better than substring matches which are better than CamelCase matches.\r\n+        kind: PatternMatchKind;\r\n+\r\n+        // If this was a camel case match, how strong the match is.  Higher number means\r\n+        // it was a better match.\r\n+        camelCaseWeight: number;\r\n+\r\n+        // If this was a match where all consituent parts of the candidate and search pattern \r\n+        // matched case sensitively or case insensitively.  Case sensitive matches of the kind\r\n+        // are better matches than insensitive matches.\r\n+        isCaseSensitive: boolean;\r\n+\r\n+        // Whether or not this match occured with the punctuation from the search pattern stripped\r\n+        // out or not.  Matches without the punctuation stripped are better than ones with punctuation\r\n+        // stripped.\r\n+        punctuationStripped: boolean;\r\n+    }\r\n+\r\n+    // The pattern matcher maintains an internal cache of information as it is used.  Therefore,\r\n+    // you should not keep it around forever and should get and release the matcher appropriately\r\n+    // once you no longer need it.\r\n+    export interface PatternMatcher {\r\n+        // Used to match a candidate against the last segment of a possibly dotted pattern.  This\r\n+        // is useful as a quick check to prevent having to compute a container before calling \r\n+        // \"getMatches\".\r\n+        //\r\n+        // For example, if the search pattern is \"ts.c.SK\" and the candidate is \"SyntaxKind\", then\r\n+        // this will return a successful match, having only tested \"SK\" against \"SyntaxKind\".  At\r\n+        // that point a call can be made to 'getMatches(\"SyntaxKind\", \"ts.compiler\")', with the\r\n+        // work to create 'ts.compiler' only being done once the first match succeeded.\r\n+        getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[];\r\n+\r\n+        // Fully checks a candidate, with an optional dotted container against the search pattern.\r\n+        // The candidate must match the last part of the search pattern, and the dotted container\r\n+        // must match the preceding segments of the pattern.\r\n+        getMatches(candidate: string, dottedContainer: string): PatternMatch[];\r\n+        isDottedPattern: boolean;\r\n+    }\r\n+\r\n+    // First we break up the pattern given by dots.  Each portion of the pattern between the\r\n+    // dots is a 'Segment'.  The 'Segment' contains information about the entire section of \r\n+    // text between the dots, as well as information about any individual 'Words' that we \r\n+    // can break the segment into.  A 'Word' is simply a contiguous sequence of characters\r\n+    // that can appear in a typescript identifier.  So \"GetKeyword\" would be one word, while\r\n+    // \"Get Keyword\" would be two words.  Once we have the individual 'words', we break those\r\n+    // into constituent 'character spans' of interest.  For example, while 'UIElement' is one\r\n+    // word, it make character spans corresponding to \"U\", \"I\" and \"Element\".  These spans\r\n+    // are then used when doing camel cased matches against candidate patterns.\r\n+    interface Segment {\r\n+        // Information about the entire piece of text between the dots.  For example, if the \r\n+        // text between the dots is 'GetKeyword', then TotalTextChunk.Text will be 'GetKeyword' and \r\n+        // TotalTextChunk.CharacterSpans will correspond to 'Get', 'Keyword'.\r\n+        totalTextChunk: TextChunk;\r\n+\r\n+        // Information about the subwords compromising the total word.  For example, if the \r\n+        // text between the dots is 'GetFoo KeywordBar', then the subwords will be 'GetFoo' \r\n+        // and 'KeywordBar'.  Those individual words will have CharacterSpans of ('Get' and \r\n+        // 'Foo') and('Keyword' and 'Bar') respectively. \r\n+        subWordTextChunks: TextChunk[];\r\n+    }\r\n+\r\n+    // Information about a chunk of text from the pattern.  The chunk is a piece of text, with \r\n+    // cached information about the character spans within in.  Character spans are used for \r\n+    // camel case matching.\r\n+    interface TextChunk {\r\n+        // The text of the chunk.  This should be a contiguous sequence of character that could\r\n+        // occur in a symbol name.\r\n+        text: string;\r\n+\r\n+        // The text of a chunk in lower case.  Cached because it is needed often to check for\r\n+        // case insensitive matches.\r\n+        textLowerCase: string;\r\n+\r\n+        // Whether or not this chunk is entirely lowercase. We have different rules when searching\r\n+        // for something entirely lowercase or not.\r\n+        isLowerCase: boolean;\r\n+\r\n+        // The spans in this text chunk that we think are of interest and should be matched \r\n+        // independently.  For example, if the chunk is for \"UIElement\" the the spans of interest\r\n+        // correspond to \"U\", \"I\" and \"Element\".  If \"UIElement\" isn't found as an exaxt, prefix.\r\n+        // or substring match, then the character spans will be used to attempt a camel case match.\r\n+        characterSpans: TextSpan[];\r\n+    }\r\n+\r\n+    function createPatternMatch(kind: PatternMatchKind, punctuationStripped: boolean, isCaseSensitive: boolean, camelCaseWeight?: number): PatternMatch {\r\n+        return {\r\n+            kind,\r\n+            punctuationStripped,\r\n+            isCaseSensitive,\r\n+            camelCaseWeight\r\n+        };\r\n+    }\r\n+\r\n+    export function createPatternMatcher(pattern: string): PatternMatcher {\r\n+        // We'll often see the same candidate string many times when searching (For example, when\r\n+        // we see the name of a module that is used everywhere, or the name of an overload).  As \r\n+        // such, we cache the information we compute about the candidate for the life of this \r\n+        // pattern matcher so we don't have to compute it multiple times.\r\n+        var stringToWordSpans: Map<TextSpan[]> = {};\r\n+\r\n+        pattern = pattern.trim();\r\n+\r\n+        var fullPatternSegment = createSegment(pattern);\r\n+        var dotSeparatedSegments = pattern.split(\".\").map(p => createSegment(p.trim()));\r\n+        var invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);\r","path":"src/services/patternMatcher.ts","position":121,"original_position":118,"commit_id":"06a278458adec76b646354a779c2609b89888318","original_commit_id":"49c78968a32ab1be74dde85d64ec1f95ee03f193","user":{"login":"JsonFreeman","id":8052525,"avatar_url":"https://avatars.githubusercontent.com/u/8052525?v=3","gravatar_id":"","url":"https://api.github.com/users/JsonFreeman","html_url":"https://github.com/JsonFreeman","followers_url":"https://api.github.com/users/JsonFreeman/followers","following_url":"https://api.github.com/users/JsonFreeman/following{/other_user}","gists_url":"https://api.github.com/users/JsonFreeman/gists{/gist_id}","starred_url":"https://api.github.com/users/JsonFreeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JsonFreeman/subscriptions","organizations_url":"https://api.github.com/users/JsonFreeman/orgs","repos_url":"https://api.github.com/users/JsonFreeman/repos","events_url":"https://api.github.com/users/JsonFreeman/events{/privacy}","received_events_url":"https://api.github.com/users/JsonFreeman/received_events","type":"User","site_admin":false},"body":"Oh I forgot, we do this in order to avoid allocations.","created_at":"2015-02-23T05:33:06Z","updated_at":"2015-02-23T05:33:06Z","html_url":"https://github.com/Microsoft/TypeScript/pull/2094#discussion_r25144557","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/25144557"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/2094#discussion_r25144557"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094","id":29679426,"html_url":"https://github.com/Microsoft/TypeScript/pull/2094","diff_url":"https://github.com/Microsoft/TypeScript/pull/2094.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/2094.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2094","number":2094,"state":"closed","locked":false,"title":"Add a PatternMatcher API (similar to the one in Roslyn) for more advanced matching with features like NavigateTo.","user":{"login":"CyrusNajmabadi","id":4564579,"avatar_url":"https://avatars.githubusercontent.com/u/4564579?v=3","gravatar_id":"","url":"https://api.github.com/users/CyrusNajmabadi","html_url":"https://github.com/CyrusNajmabadi","followers_url":"https://api.github.com/users/CyrusNajmabadi/followers","following_url":"https://api.github.com/users/CyrusNajmabadi/following{/other_user}","gists_url":"https://api.github.com/users/CyrusNajmabadi/gists{/gist_id}","starred_url":"https://api.github.com/users/CyrusNajmabadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CyrusNajmabadi/subscriptions","organizations_url":"https://api.github.com/users/CyrusNajmabadi/orgs","repos_url":"https://api.github.com/users/CyrusNajmabadi/repos","events_url":"https://api.github.com/users/CyrusNajmabadi/events{/privacy}","received_events_url":"https://api.github.com/users/CyrusNajmabadi/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-20T08:25:39Z","updated_at":"2015-02-23T05:33:06Z","closed_at":"2015-02-21T22:56:11Z","merged_at":"2015-02-21T22:56:11Z","merge_commit_sha":"14caa4bfece7285e7ad89136e58f487a9c3e4bb9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2094/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/06a278458adec76b646354a779c2609b89888318","head":{"label":"Microsoft:patternMatcher","ref":"patternMatcher","sha":"06a278458adec76b646354a779c2609b89888318","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-02-23T05:04:14Z","pushed_at":"2015-02-23T05:26:20Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":568130,"stargazers_count":3521,"watchers_count":3521,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":334,"mirror_url":null,"open_issues_count":526,"forks":334,"open_issues":526,"watchers":3521,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"7393cf46b926687f94cf5e247121871ba358e96c","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-02-23T05:04:14Z","pushed_at":"2015-02-23T05:26:20Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":568130,"stargazers_count":3521,"watchers_count":3521,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":334,"mirror_url":null,"open_issues_count":526,"forks":334,"open_issues":526,"watchers":3521,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/2094"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/2094"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/2094/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2094/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/06a278458adec76b646354a779c2609b89888318"}}}}