{"action":"created","comment":{"url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/comments/211660319","pull_request_review_id":148129341,"id":211660319,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTY2MDMxOQ==","diff_hunk":"@@ -0,0 +1,82 @@\n+import { IGrammar, IExtensionPackage } from \"./IExtensionGrammar\";\r\n+\r\n+\"use strict\";\r\n+import * as path from \"path\";\r\n+import * as vscode from \"vscode\";\r\n+import fs = require(\"fs\");\r\n+\r\n+export class TextMateLoader {\r\n+    private readonly grammarPaths: Map<string, { scopeName: string; path: string; }>;\r\n+    private readonly vsctm: any;\r\n+    private readonly textMateRegistry = new Map<string, IGrammar>();\r\n+    constructor() {\r\n+        this.grammarPaths = this.getGrammarPaths();\r\n+        this.vsctm = this.loadTextMate();\r\n+    }\r\n+\r\n+    public tryGetTokenizer(languageID: string) {\r\n+        const existingTokenizer = this.textMateRegistry.get(languageID);\r\n+        if (existingTokenizer) {\r\n+            return existingTokenizer;\r\n+        }\r\n+\r\n+        const paths = this.grammarPaths.get(languageID);\r\n+\r\n+        if (!paths) {\r\n+            return;\r\n+        }\r\n+\r\n+        const registry = new this.vsctm.Registry({\r\n+            // tslint:disable-next-line:object-literal-shorthand\r\n+            loadGrammar: (scopeName: string) => {\r\n+                const path = paths.path;\r\n+                return new Promise((resolve, reject) => {\r\n+                    fs.readFile(path, (error, content) => {\r\n+                        if (error) {\r\n+                            reject(error);\r\n+                        } else {\r\n+                            const text = content.toString();\r\n+                            const rawGrammar = this.vsctm.parseRawGrammar(text, path);\r\n+                            resolve(rawGrammar);\r\n+                        }\r\n+                    });\r\n+                });\r\n+            },\r\n+        });\r\n+\r\n+        // Load the JavaScript grammar and any other grammars included by it async.\r\n+        return (registry.loadGrammar(paths.scopeName) as Thenable<IGrammar | undefined | null>).then((grammar) => {\r\n+            if (grammar) {\r\n+                this.textMateRegistry.set(languageID, grammar);\r\n+            }\r\n+            return grammar;\r\n+        });\r\n+    }\r\n+\r\n+    private getNodeModule(moduleName: string) {\r\n+        return require(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);\r\n+    }\r\n+\r\n+    private loadTextMate(): any {\r\n+        return this.getNodeModule(\"vscode-textmate\");\r\n+    }\r\n+\r\n+    private getGrammarPaths() {\r\n+        const dict = new Map<string, { scopeName: string, path: string }>();\r\n+        vscode.extensions.all.forEach((extension) => {\r\n+            const packageJSON = extension.packageJSON as IExtensionPackage;\r\n+            if (packageJSON.contributes && packageJSON.contributes.grammars && packageJSON.contributes.grammars) {\r","path":"src/textMateLoader.ts","position":68,"original_position":68,"commit_id":"546976689a9d700e4b0c40aa9dda9485eb75e390","original_commit_id":"546976689a9d700e4b0c40aa9dda9485eb75e390","user":{"login":"CoenraadS","id":5593825,"node_id":"MDQ6VXNlcjU1OTM4MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/5593825?v=4","gravatar_id":"","url":"https://api.github.com/users/CoenraadS","html_url":"https://github.com/CoenraadS","followers_url":"https://api.github.com/users/CoenraadS/followers","following_url":"https://api.github.com/users/CoenraadS/following{/other_user}","gists_url":"https://api.github.com/users/CoenraadS/gists{/gist_id}","starred_url":"https://api.github.com/users/CoenraadS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoenraadS/subscriptions","organizations_url":"https://api.github.com/users/CoenraadS/orgs","repos_url":"https://api.github.com/users/CoenraadS/repos","events_url":"https://api.github.com/users/CoenraadS/events{/privacy}","received_events_url":"https://api.github.com/users/CoenraadS/received_events","type":"User","site_admin":false},"body":"2x packageJSON.contributes.grammars","created_at":"2018-08-21T15:52:50Z","updated_at":"2018-08-21T15:52:50Z","html_url":"https://github.com/CoenraadS/BracketPair/pull/171#discussion_r211660319","pull_request_url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/comments/211660319"},"html":{"href":"https://github.com/CoenraadS/BracketPair/pull/171#discussion_r211660319"},"pull_request":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171"}}},"pull_request":{"url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171","id":208083784,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4MDgzNzg0","html_url":"https://github.com/CoenraadS/BracketPair/pull/171","diff_url":"https://github.com/CoenraadS/BracketPair/pull/171.diff","patch_url":"https://github.com/CoenraadS/BracketPair/pull/171.patch","issue_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues/171","number":171,"state":"open","locked":false,"title":"Use VSCode TextMate engine for parsing (wip)","user":{"login":"CoenraadS","id":5593825,"node_id":"MDQ6VXNlcjU1OTM4MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/5593825?v=4","gravatar_id":"","url":"https://api.github.com/users/CoenraadS","html_url":"https://github.com/CoenraadS","followers_url":"https://api.github.com/users/CoenraadS/followers","following_url":"https://api.github.com/users/CoenraadS/following{/other_user}","gists_url":"https://api.github.com/users/CoenraadS/gists{/gist_id}","starred_url":"https://api.github.com/users/CoenraadS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoenraadS/subscriptions","organizations_url":"https://api.github.com/users/CoenraadS/orgs","repos_url":"https://api.github.com/users/CoenraadS/repos","events_url":"https://api.github.com/users/CoenraadS/events{/privacy}","received_events_url":"https://api.github.com/users/CoenraadS/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-13T19:49:00Z","updated_at":"2018-08-21T15:52:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"716ea441ebece21d7b43e0d7badec4c4c930e0cd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171/commits","review_comments_url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171/comments","review_comment_url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues/171/comments","statuses_url":"https://api.github.com/repos/CoenraadS/BracketPair/statuses/546976689a9d700e4b0c40aa9dda9485eb75e390","head":{"label":"CoenraadS:textmate","ref":"textmate","sha":"546976689a9d700e4b0c40aa9dda9485eb75e390","user":{"login":"CoenraadS","id":5593825,"node_id":"MDQ6VXNlcjU1OTM4MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/5593825?v=4","gravatar_id":"","url":"https://api.github.com/users/CoenraadS","html_url":"https://github.com/CoenraadS","followers_url":"https://api.github.com/users/CoenraadS/followers","following_url":"https://api.github.com/users/CoenraadS/following{/other_user}","gists_url":"https://api.github.com/users/CoenraadS/gists{/gist_id}","starred_url":"https://api.github.com/users/CoenraadS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoenraadS/subscriptions","organizations_url":"https://api.github.com/users/CoenraadS/orgs","repos_url":"https://api.github.com/users/CoenraadS/repos","events_url":"https://api.github.com/users/CoenraadS/events{/privacy}","received_events_url":"https://api.github.com/users/CoenraadS/received_events","type":"User","site_admin":false},"repo":{"id":74071696,"node_id":"MDEwOlJlcG9zaXRvcnk3NDA3MTY5Ng==","name":"BracketPair","full_name":"CoenraadS/BracketPair","owner":{"login":"CoenraadS","id":5593825,"node_id":"MDQ6VXNlcjU1OTM4MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/5593825?v=4","gravatar_id":"","url":"https://api.github.com/users/CoenraadS","html_url":"https://github.com/CoenraadS","followers_url":"https://api.github.com/users/CoenraadS/followers","following_url":"https://api.github.com/users/CoenraadS/following{/other_user}","gists_url":"https://api.github.com/users/CoenraadS/gists{/gist_id}","starred_url":"https://api.github.com/users/CoenraadS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoenraadS/subscriptions","organizations_url":"https://api.github.com/users/CoenraadS/orgs","repos_url":"https://api.github.com/users/CoenraadS/repos","events_url":"https://api.github.com/users/CoenraadS/events{/privacy}","received_events_url":"https://api.github.com/users/CoenraadS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/CoenraadS/BracketPair","description":"Bracket Colorizer Extension for VSCode","fork":false,"url":"https://api.github.com/repos/CoenraadS/BracketPair","forks_url":"https://api.github.com/repos/CoenraadS/BracketPair/forks","keys_url":"https://api.github.com/repos/CoenraadS/BracketPair/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CoenraadS/BracketPair/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CoenraadS/BracketPair/teams","hooks_url":"https://api.github.com/repos/CoenraadS/BracketPair/hooks","issue_events_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues/events{/number}","events_url":"https://api.github.com/repos/CoenraadS/BracketPair/events","assignees_url":"https://api.github.com/repos/CoenraadS/BracketPair/assignees{/user}","branches_url":"https://api.github.com/repos/CoenraadS/BracketPair/branches{/branch}","tags_url":"https://api.github.com/repos/CoenraadS/BracketPair/tags","blobs_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/refs{/sha}","trees_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CoenraadS/BracketPair/statuses/{sha}","languages_url":"https://api.github.com/repos/CoenraadS/BracketPair/languages","stargazers_url":"https://api.github.com/repos/CoenraadS/BracketPair/stargazers","contributors_url":"https://api.github.com/repos/CoenraadS/BracketPair/contributors","subscribers_url":"https://api.github.com/repos/CoenraadS/BracketPair/subscribers","subscription_url":"https://api.github.com/repos/CoenraadS/BracketPair/subscription","commits_url":"https://api.github.com/repos/CoenraadS/BracketPair/commits{/sha}","git_commits_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/commits{/sha}","comments_url":"https://api.github.com/repos/CoenraadS/BracketPair/comments{/number}","issue_comment_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues/comments{/number}","contents_url":"https://api.github.com/repos/CoenraadS/BracketPair/contents/{+path}","compare_url":"https://api.github.com/repos/CoenraadS/BracketPair/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CoenraadS/BracketPair/merges","archive_url":"https://api.github.com/repos/CoenraadS/BracketPair/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CoenraadS/BracketPair/downloads","issues_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues{/number}","pulls_url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls{/number}","milestones_url":"https://api.github.com/repos/CoenraadS/BracketPair/milestones{/number}","notifications_url":"https://api.github.com/repos/CoenraadS/BracketPair/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CoenraadS/BracketPair/labels{/name}","releases_url":"https://api.github.com/repos/CoenraadS/BracketPair/releases{/id}","deployments_url":"https://api.github.com/repos/CoenraadS/BracketPair/deployments","created_at":"2016-11-17T22:07:08Z","updated_at":"2018-08-20T20:21:42Z","pushed_at":"2018-08-19T20:01:12Z","git_url":"git://github.com/CoenraadS/BracketPair.git","ssh_url":"git@github.com:CoenraadS/BracketPair.git","clone_url":"https://github.com/CoenraadS/BracketPair.git","svn_url":"https://github.com/CoenraadS/BracketPair","homepage":"https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer","size":694,"stargazers_count":217,"watchers_count":217,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":59,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":19,"open_issues":59,"watchers":217,"default_branch":"master"}},"base":{"label":"CoenraadS:master","ref":"master","sha":"994f9d37c34cf130ba14049aac84e3ae1a152426","user":{"login":"CoenraadS","id":5593825,"node_id":"MDQ6VXNlcjU1OTM4MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/5593825?v=4","gravatar_id":"","url":"https://api.github.com/users/CoenraadS","html_url":"https://github.com/CoenraadS","followers_url":"https://api.github.com/users/CoenraadS/followers","following_url":"https://api.github.com/users/CoenraadS/following{/other_user}","gists_url":"https://api.github.com/users/CoenraadS/gists{/gist_id}","starred_url":"https://api.github.com/users/CoenraadS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoenraadS/subscriptions","organizations_url":"https://api.github.com/users/CoenraadS/orgs","repos_url":"https://api.github.com/users/CoenraadS/repos","events_url":"https://api.github.com/users/CoenraadS/events{/privacy}","received_events_url":"https://api.github.com/users/CoenraadS/received_events","type":"User","site_admin":false},"repo":{"id":74071696,"node_id":"MDEwOlJlcG9zaXRvcnk3NDA3MTY5Ng==","name":"BracketPair","full_name":"CoenraadS/BracketPair","owner":{"login":"CoenraadS","id":5593825,"node_id":"MDQ6VXNlcjU1OTM4MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/5593825?v=4","gravatar_id":"","url":"https://api.github.com/users/CoenraadS","html_url":"https://github.com/CoenraadS","followers_url":"https://api.github.com/users/CoenraadS/followers","following_url":"https://api.github.com/users/CoenraadS/following{/other_user}","gists_url":"https://api.github.com/users/CoenraadS/gists{/gist_id}","starred_url":"https://api.github.com/users/CoenraadS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoenraadS/subscriptions","organizations_url":"https://api.github.com/users/CoenraadS/orgs","repos_url":"https://api.github.com/users/CoenraadS/repos","events_url":"https://api.github.com/users/CoenraadS/events{/privacy}","received_events_url":"https://api.github.com/users/CoenraadS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/CoenraadS/BracketPair","description":"Bracket Colorizer Extension for VSCode","fork":false,"url":"https://api.github.com/repos/CoenraadS/BracketPair","forks_url":"https://api.github.com/repos/CoenraadS/BracketPair/forks","keys_url":"https://api.github.com/repos/CoenraadS/BracketPair/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CoenraadS/BracketPair/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CoenraadS/BracketPair/teams","hooks_url":"https://api.github.com/repos/CoenraadS/BracketPair/hooks","issue_events_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues/events{/number}","events_url":"https://api.github.com/repos/CoenraadS/BracketPair/events","assignees_url":"https://api.github.com/repos/CoenraadS/BracketPair/assignees{/user}","branches_url":"https://api.github.com/repos/CoenraadS/BracketPair/branches{/branch}","tags_url":"https://api.github.com/repos/CoenraadS/BracketPair/tags","blobs_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/refs{/sha}","trees_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CoenraadS/BracketPair/statuses/{sha}","languages_url":"https://api.github.com/repos/CoenraadS/BracketPair/languages","stargazers_url":"https://api.github.com/repos/CoenraadS/BracketPair/stargazers","contributors_url":"https://api.github.com/repos/CoenraadS/BracketPair/contributors","subscribers_url":"https://api.github.com/repos/CoenraadS/BracketPair/subscribers","subscription_url":"https://api.github.com/repos/CoenraadS/BracketPair/subscription","commits_url":"https://api.github.com/repos/CoenraadS/BracketPair/commits{/sha}","git_commits_url":"https://api.github.com/repos/CoenraadS/BracketPair/git/commits{/sha}","comments_url":"https://api.github.com/repos/CoenraadS/BracketPair/comments{/number}","issue_comment_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues/comments{/number}","contents_url":"https://api.github.com/repos/CoenraadS/BracketPair/contents/{+path}","compare_url":"https://api.github.com/repos/CoenraadS/BracketPair/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CoenraadS/BracketPair/merges","archive_url":"https://api.github.com/repos/CoenraadS/BracketPair/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CoenraadS/BracketPair/downloads","issues_url":"https://api.github.com/repos/CoenraadS/BracketPair/issues{/number}","pulls_url":"https://api.github.com/repos/CoenraadS/BracketPair/pulls{/number}","milestones_url":"https://api.github.com/repos/CoenraadS/BracketPair/milestones{/number}","notifications_url":"https://api.github.com/repos/CoenraadS/BracketPair/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CoenraadS/BracketPair/labels{/name}","releases_url":"https://api.github.com/repos/CoenraadS/BracketPair/releases{/id}","deployments_url":"https://api.github.com/repos/CoenraadS/BracketPair/deployments","created_at":"2016-11-17T22:07:08Z","updated_at":"2018-08-20T20:21:42Z","pushed_at":"2018-08-19T20:01:12Z","git_url":"git://github.com/CoenraadS/BracketPair.git","ssh_url":"git@github.com:CoenraadS/BracketPair.git","clone_url":"https://github.com/CoenraadS/BracketPair.git","svn_url":"https://github.com/CoenraadS/BracketPair","homepage":"https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer","size":694,"stargazers_count":217,"watchers_count":217,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":59,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":19,"open_issues":59,"watchers":217,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171"},"html":{"href":"https://github.com/CoenraadS/BracketPair/pull/171"},"issue":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/issues/171"},"comments":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/issues/171/comments"},"review_comments":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171/comments"},"review_comment":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/pulls/171/commits"},"statuses":{"href":"https://api.github.com/repos/CoenraadS/BracketPair/statuses/546976689a9d700e4b0c40aa9dda9485eb75e390"}},"author_association":"OWNER"}}
{"actor":{"display_login":"CoenraadS"}}