From e84662743a515712672204cee89d00fd96e1ab21 Mon Sep 17 00:00:00 2001 From: Benjamin Gray Date: Sat, 16 Jun 2018 21:40:31 +1000 Subject: [PATCH 01/12] Support activation hooks by grammar scope --- src/workspace.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/workspace.js b/src/workspace.js index 00976759f..bd76dad0f 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -1268,6 +1268,7 @@ module.exports = class Workspace extends Model { handleGrammarUsed (grammar) { if (grammar == null) { return } + this.packageManager.triggerActivationHook(`${grammar.scopeName}:root-scope-used`) return this.packageManager.triggerActivationHook(`${grammar.packageName}:grammar-used`) } From ce7b8b2a7eadd86f4dcb7fa6c3c9832fa05c86c0 Mon Sep 17 00:00:00 2001 From: Benjamin Gray Date: Sat, 16 Jun 2018 22:00:46 +1000 Subject: [PATCH 02/12] :fire: useless return in handleGrammarUsed --- src/workspace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace.js b/src/workspace.js index bd76dad0f..a3f85ddeb 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -1269,7 +1269,7 @@ module.exports = class Workspace extends Model { handleGrammarUsed (grammar) { if (grammar == null) { return } this.packageManager.triggerActivationHook(`${grammar.scopeName}:root-scope-used`) - return this.packageManager.triggerActivationHook(`${grammar.packageName}:grammar-used`) + this.packageManager.triggerActivationHook(`${grammar.packageName}:grammar-used`) } // Public: Returns a {Boolean} that is `true` if `object` is a `TextEditor`. From e0041c3c24988574b3ca69b5b862af35c91887e5 Mon Sep 17 00:00:00 2001 From: Benjamin Gray Date: Sat, 16 Jun 2018 22:50:14 +1000 Subject: [PATCH 03/12] Add tests for root-scope-used activation hook --- spec/workspace-spec.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index 5d920363a..091588a70 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -1299,6 +1299,34 @@ describe('Workspace', () => { }) }) + describe('the root-scope-used hook', () => { + it('fires when opening a file or changing the grammar of an open file', async () => { + await atom.packages.activatePackage('language-javascript') + await atom.packages.activatePackage('language-coffee-script') + + const observeTextEditorsSpy = jasmine.createSpy('observeTextEditors') + const javascriptGrammarUsed = jasmine.createSpy('javascript') + const coffeeScriptGrammarUsed = jasmine.createSpy('coffeescript') + + atom.packages.triggerDeferredActivationHooks() + atom.packages.onDidTriggerActivationHook('source.js:root-scope-used', () => { + atom.workspace.observeTextEditors(observeTextEditorsSpy) + javascriptGrammarUsed() + }) + atom.packages.onDidTriggerActivationHook('source.coffee:root-scope-used', coffeeScriptGrammarUsed) + + expect(javascriptGrammarUsed).not.toHaveBeenCalled() + expect(observeTextEditorsSpy).not.toHaveBeenCalled() + const editor = await atom.workspace.open('sample.js', {autoIndent: false}) + expect(javascriptGrammarUsed).toHaveBeenCalled() + expect(observeTextEditorsSpy.callCount).toBe(1) + + expect(coffeeScriptGrammarUsed).not.toHaveBeenCalled() + atom.grammars.assignLanguageMode(editor, 'source.coffee') + expect(coffeeScriptGrammarUsed).toHaveBeenCalled() + }) + }) + describe('::reopenItem()', () => { it("opens the uri associated with the last closed pane that isn't currently open", () => { const pane = workspace.getActivePane() From 7195df9d17f136d8f1096f43757d9cb53429a631 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Thu, 21 Jun 2018 12:27:18 -0400 Subject: [PATCH 04/12] :arrow_up: :electron: 2.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a8e324668..d5b182d6a 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/atom/atom/issues" }, "license": "MIT", - "electronVersion": "2.0.2", + "electronVersion": "2.0.3", "dependencies": { "@atom/nsfw": "^1.0.18", "@atom/watcher": "1.0.3", From 2f827bfc23260eece024b8f179421fa833b1834d Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 25 Jun 2018 12:13:12 -0700 Subject: [PATCH 05/12] :arrow_up: metrics@1.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5b182d6a..8c829b583 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "line-ending-selector": "0.7.7", "link": "0.31.4", "markdown-preview": "0.159.20", - "metrics": "1.3.0", + "metrics": "1.3.1", "notifications": "0.70.5", "open-on-github": "1.3.1", "package-generator": "1.3.0", From e7c6a8f085d8242ce02a270f5aac691e2ec3f74e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 29 Jun 2018 12:31:09 -0700 Subject: [PATCH 06/12] Clear electron-link's snapshot cache in script/clean --- script/lib/clean-caches.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script/lib/clean-caches.js b/script/lib/clean-caches.js index 1df3aa9c2..3861908bb 100644 --- a/script/lib/clean-caches.js +++ b/script/lib/clean-caches.js @@ -14,6 +14,7 @@ module.exports = function () { path.join(CONFIG.atomHomeDirPath, '.apm'), path.join(CONFIG.atomHomeDirPath, '.npm'), path.join(CONFIG.atomHomeDirPath, 'compile-cache'), + path.join(CONFIG.atomHomeDirPath, 'snapshot-cache'), path.join(CONFIG.atomHomeDirPath, 'atom-shell'), path.join(CONFIG.atomHomeDirPath, 'electron'), path.join(os.tmpdir(), 'atom-build'), From a484ca9e654a1da25bab08d698de42dad46e9c36 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 29 Jun 2018 14:41:20 -0700 Subject: [PATCH 07/12] Allow for parsing injections in parallel --- src/tree-sitter-language-mode.js | 33 +++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/tree-sitter-language-mode.js b/src/tree-sitter-language-mode.js index 218f41cd5..b59f8c528 100644 --- a/src/tree-sitter-language-mode.js +++ b/src/tree-sitter-language-mode.js @@ -5,6 +5,7 @@ const {Emitter, Disposable} = require('event-kit') const ScopeDescriptor = require('./scope-descriptor') const TokenizedLine = require('./tokenized-line') const TextMateLanguageMode = require('./text-mate-language-mode') +const async = require('async') let nextId = 0 const MAX_RANGE = new Range(Point.ZERO, Point.INFINITY).freeze() @@ -30,6 +31,19 @@ class TreeSitterLanguageMode { this.parser = new Parser() this.rootLanguageLayer = new LanguageLayer(this, grammar) this.injectionsMarkerLayer = buffer.addMarkerLayer() + this.updatedGrammars = [] + + this.parsers = [] + this.parseQueue = async.queue(async ({language, oldTree, ranges}, done) => { + const parser = this.parsers.pop() || new Parser() + parser.setLanguage(language) + const newTree = await parser.parseTextBuffer(this.buffer.buffer, oldTree, { + syncOperationLimit: 1000, + includedRanges: ranges + }) + this.parsers.push(parser) + done(null, newTree) + }, 2) this.rootScopeDescriptor = new ScopeDescriptor({scopes: [this.grammar.id]}) this.emitter = new Emitter() @@ -80,6 +94,14 @@ class TreeSitterLanguageMode { } } + parse (language, oldTree, ranges) { + return new Promise(resolve => + this.parseQueue.push({language, oldTree, ranges}, (error, tree) => + resolve(tree) + ) + ) + } + get tree () { return this.rootLanguageLayer.tree } @@ -476,11 +498,10 @@ class LanguageLayer { if (includedRanges.length === 0) return } - this.languageMode.parser.setLanguage(this.grammar.languageModule) - const tree = await this.languageMode.parser.parseTextBuffer( - this.languageMode.buffer.buffer, + const tree = await this.languageMode.parse( + this.grammar.languageModule, this.tree, - {syncOperationLimit: 1000, includedRanges} + includedRanges ) tree.buffer = this.languageMode.buffer @@ -566,9 +587,11 @@ class LanguageLayer { } } + const promises = [] for (const [marker, injectionNode] of markersToUpdate) { - await marker.languageLayer.update(injectionNode) + promises.push(marker.languageLayer.update(injectionNode)) } + return Promise.all(promises) } _rangesForInjectionNode (node) { From 06ea494f46b17966573efef2f3f9a72aa4a006e6 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Sun, 1 Jul 2018 17:18:16 -0400 Subject: [PATCH 08/12] Update Jasmine stacktrace formatting --- spec/atom-reporter.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/atom-reporter.coffee b/spec/atom-reporter.coffee index a522d9298..9af21a7dd 100644 --- a/spec/atom-reporter.coffee +++ b/spec/atom-reporter.coffee @@ -33,6 +33,8 @@ formatStackTrace = (spec, message='', stackTrace) -> line = line.trim() # at jasmine.Spec. (path:1:2) -> at path:1:2 .replace(/^at jasmine\.Spec\. \(([^)]+)\)/, 'at $1') + # at jasmine.Spec.it (path:1:2) -> at path:1:2 + .replace(/^at jasmine\.Spec\.f*it \(([^)]+)\)/, 'at $1') # at it (path:1:2) -> at path:1:2 .replace(/^at f*it \(([^)]+)\)/, 'at $1') # at spec/file-test.js -> at file-test.js From 3e2520ebfd9e7297c64ed37386f96900d0b8f113 Mon Sep 17 00:00:00 2001 From: Tilde Ann Thurium Date: Mon, 2 Jul 2018 13:00:39 -0700 Subject: [PATCH 09/12] :arrow_up: metrics --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c829b583..e67fcfd9e 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "line-ending-selector": "0.7.7", "link": "0.31.4", "markdown-preview": "0.159.20", - "metrics": "1.3.1", + "metrics": "1.4.1", "notifications": "0.70.5", "open-on-github": "1.3.1", "package-generator": "1.3.0", From c99469cba120190612a5a647ff83eee44c558d3c Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Tue, 3 Jul 2018 09:22:18 -0400 Subject: [PATCH 10/12] :arrow_up: archive-view@0.65.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e67fcfd9e..c0c7786e6 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "solarized-dark-syntax": "1.1.5", "solarized-light-syntax": "1.1.5", "about": "1.9.1", - "archive-view": "0.65.0", + "archive-view": "0.65.1", "autocomplete-atom-api": "0.10.7", "autocomplete-css": "0.17.5", "autocomplete-html": "0.8.4", From a62462f66bfeaf6270cea2b373762c0532ad7e37 Mon Sep 17 00:00:00 2001 From: Tilde Ann Thurium Date: Tue, 3 Jul 2018 11:23:16 -0700 Subject: [PATCH 11/12] :arrow_up: metrics 1.4.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e67fcfd9e..e09661b94 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "line-ending-selector": "0.7.7", "link": "0.31.4", "markdown-preview": "0.159.20", - "metrics": "1.4.1", + "metrics": "1.4.3", "notifications": "0.70.5", "open-on-github": "1.3.1", "package-generator": "1.3.0", From c8be4e0bd43e70c865c189d0dc6c6cf23ee04416 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Tue, 3 Jul 2018 16:15:11 -0400 Subject: [PATCH 12/12] :arrow_up: :electron: 2.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 175fa6199..47ced8623 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/atom/atom/issues" }, "license": "MIT", - "electronVersion": "2.0.3", + "electronVersion": "2.0.4", "dependencies": { "@atom/nsfw": "^1.0.18", "@atom/watcher": "1.0.3",