From 23d223581ab0073c9a0ca27c017d8de581d8205a Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 03:00:05 -0500 Subject: [PATCH 01/16] decaffeinate lib/runtime --- lib/runtime.coffee | 77 ---------------------------------- lib/runtime.js | 102 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 77 deletions(-) delete mode 100644 lib/runtime.coffee create mode 100644 lib/runtime.js diff --git a/lib/runtime.coffee b/lib/runtime.coffee deleted file mode 100644 index 5c10db2ae..000000000 --- a/lib/runtime.coffee +++ /dev/null @@ -1,77 +0,0 @@ -{ CompositeDisposable, Disposable } = require 'atom' - -module.exports = - modules: require './runtime/modules' - environments: require './runtime/environments' - evaluation: require './runtime/evaluation' - console: require './runtime/console' - completions: require './runtime/completions' - workspace: require './runtime/workspace' - plots: require './runtime/plots' - frontend: require './runtime/frontend' - debugger: require './runtime/debugger' - profiler: require './runtime/profiler' - outline: require './runtime/outline' - linter: require './runtime/linter' - packages: require './runtime/packages' - debuginfo: require './runtime/debuginfo' - formatter: require './runtime/formatter' - goto: require './runtime/goto' - - activate: -> - @subs = new CompositeDisposable() - - @modules.activate() - @completions.activate() - @subs.add atom.config.observe 'julia-client.juliaOptions.formatOnSave', (val) => - if val - @formatter.activate() - else - @formatter.deactivate() - - @subs.add new Disposable(=> - mod.deactivate() for mod in [@modules, @completions, @formatter]) - - deactivate: -> - @subs.dispose() - - consumeInk: (ink) -> - @evaluation.ink = ink - for mod in [@console, @debugger, @profiler, @linter, @goto, @outline, @frontend] - mod.activate(ink) - for mod in [@workspace, @plots] - mod.ink = ink - mod.activate() - @subs.add new Disposable => - mod.deactivate() for mod in [@console, @debugger, @profiler, @linter, @goto, @outline] - @environments.consumeInk(ink) - - provideAutoComplete: -> @completions - - provideHyperclick: -> @goto.provideHyperclick() - - consumeStatusBar: (bar) -> - m = @modules.consumeStatusBar bar - e = @environments.consumeStatusBar bar - d = new Disposable => - m.dispose() - e.dispose() - @subs.add d - return d - - consumeDatatip: (datatipService) -> - datatipProvider = require './runtime/datatip' - # @NOTE: Check if the service is passed by Atom-IDE-UI's datatip service: - # currently atom-ide-datatip can't render code snippets correctly. - if datatipService.constructor.name == 'DatatipManager' - datatipProvider.useAtomIDEUI = true - else - # @NOTE: Overwrite the weird default config settings of atom-ide-datatip - atom.config.set 'atom-ide-datatip', - showDataTipOnCursorMove: false - showDataTipOnMouseMove: true - datatipDisposable = datatipService.addProvider(datatipProvider) - @subs.add(datatipDisposable) - datatipDisposable - - handleURI: require './runtime/urihandler' diff --git a/lib/runtime.js b/lib/runtime.js new file mode 100644 index 000000000..c224705fe --- /dev/null +++ b/lib/runtime.js @@ -0,0 +1,102 @@ +'use babel' +import { CompositeDisposable, Disposable } from 'atom'; + +export default { + modules: require('./runtime/modules'), + environments: require('./runtime/environments'), + evaluation: require('./runtime/evaluation'), + console: require('./runtime/console'), + completions: require('./runtime/completions'), + workspace: require('./runtime/workspace'), + plots: require('./runtime/plots'), + frontend: require('./runtime/frontend'), + debugger: require('./runtime/debugger'), + profiler: require('./runtime/profiler'), + outline: require('./runtime/outline'), + linter: require('./runtime/linter'), + packages: require('./runtime/packages'), + debuginfo: require('./runtime/debuginfo'), + formatter: require('./runtime/formatter'), + goto: require('./runtime/goto'), + + activate() { + this.subs = new CompositeDisposable(); + + this.modules.activate(); + this.completions.activate(); + this.subs.add(atom.config.observe('julia-client.juliaOptions.formatOnSave', val => { + if (val) { + this.formatter.activate(); + } else { + this.formatter.deactivate(); + } + }) + ); + + this.subs.add(new Disposable(() => { + [this.modules, this.completions, this.formatter].map((mod) => mod.deactivate()); + }) + ); + }, + + deactivate() { + this.subs.dispose(); + }, + + consumeInk(ink) { + this.evaluation.ink = ink; + for (let mod of [this.console, this.debugger, this.profiler, this.linter, this.goto, this.outline, this.frontend]) { + mod.activate(ink); + } + for (let mod of [this.workspace, this.plots]) { + mod.ink = ink; + mod.activate(); + } + + this.subs.add( + new Disposable(() => { + for (let mod of [this.console, this.debugger, this.profiler, this.linter, this.goto, this.outline]) { + mod.deactivate(); + } + }) + ); + + this.environments.consumeInk(ink); + }, + + provideAutoComplete() { return this.completions; }, + + provideHyperclick() { return this.goto.provideHyperclick(); }, + + consumeStatusBar(bar) { + const m = this.modules.consumeStatusBar(bar); + const e = this.environments.consumeStatusBar(bar); + const d = new Disposable(() => { + m.dispose(); + e.dispose(); + }); + this.subs.add(d); + return d; + }, + + consumeDatatip(datatipService) { + const datatipProvider = require('./runtime/datatip'); + // @NOTE: Check if the service is passed by Atom-IDE-UI's datatip service: + // currently atom-ide-datatip can't render code snippets correctly. + if (datatipService.constructor.name === 'DatatipManager') { + datatipProvider.useAtomIDEUI = true; + } else { + // @NOTE: Overwrite the weird default config settings of atom-ide-datatip + atom.config.set('atom-ide-datatip', { + showDataTipOnCursorMove: false, + showDataTipOnMouseMove: true + } + ); + } + const datatipDisposable = datatipService.addProvider(datatipProvider); + this.subs.add(datatipDisposable); + return datatipDisposable; + }, + + handleURI: require('./runtime/urihandler') +}; From 32f12833cdc72e1a1be9a1c726a6a1fe4c73d44f Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 03:02:34 -0500 Subject: [PATCH 02/16] Add TODO --- lib/runtime.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/runtime.js b/lib/runtime.js index c224705fe..21c562b02 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -1,6 +1,8 @@ 'use babel' import { CompositeDisposable, Disposable } from 'atom'; +// TODO Fix all of these dynamic requires and circular dependencies + export default { modules: require('./runtime/modules'), environments: require('./runtime/environments'), From c34ecf1a4431a2953edf89d5a7ba2aa9f08edcbc Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 03:12:30 -0500 Subject: [PATCH 03/16] decaffeinate lib/ui --- lib/ui.coffee | 42 ----------------------------------- lib/ui.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 42 deletions(-) delete mode 100644 lib/ui.coffee create mode 100644 lib/ui.js diff --git a/lib/ui.coffee b/lib/ui.coffee deleted file mode 100644 index caf613e8a..000000000 --- a/lib/ui.coffee +++ /dev/null @@ -1,42 +0,0 @@ -{CompositeDisposable, Disposable} = require 'atom' - -module.exports = - notifications: require './ui/notifications' - selector: require './ui/selector' - views: require './ui/views' - progress: require './ui/progress' - layout: require './ui/layout' - docpane: require './ui/docs' - focusutils: require './ui/focusutils' - cellhighlighter: require './ui/cellhighlighter' - - activate: (@client) -> - @subs = new CompositeDisposable - - @notifications.activate() - @subs.add atom.config.observe 'julia-client.uiOptions.highlightCells', (val) => - if val - @cellhighlighter.activate() - else - @cellhighlighter.deactivate() - @subs.add new Disposable => - @cellhighlighter.deactivate() - - @subs.add @client.onAttached => - @notifications.show("Client Connected") - @subs.add @client.onDetached => - @ink?.Result.invalidateAll() - - deactivate: -> - @subs.dispose() - - consumeInk: (@ink) -> - @views.ink = @ink - @selector.activate(@ink) - @docpane.activate(@ink) - @progress.activate(@ink) - @focusutils.activate(@ink) - @subs.add(new Disposable(=> - @docpane.deactivate() - @progress.deactivate() - @focusutils.deactivate())) diff --git a/lib/ui.js b/lib/ui.js new file mode 100644 index 000000000..48dac395c --- /dev/null +++ b/lib/ui.js @@ -0,0 +1,61 @@ +'use babel' +import { CompositeDisposable, Disposable } from 'atom'; + +export default { + // TODO Fix all of these dynamic requires and circular dependencies + notifications: require('./ui/notifications'), + selector: require('./ui/selector'), + views: require('./ui/views'), + progress: require('./ui/progress'), + layout: require('./ui/layout'), + docpane: require('./ui/docs'), + focusutils: require('./ui/focusutils'), + cellhighlighter: require('./ui/cellhighlighter'), + + activate(client) { + this.client = client; + this.subs = new CompositeDisposable; + + this.notifications.activate(); + this.subs.add(atom.config.observe('julia-client.uiOptions.highlightCells', val => { + if (val) { + this.cellhighlighter.activate(); + } else { + this.cellhighlighter.deactivate(); + } + }) + ); + this.subs.add(new Disposable(() => { + this.cellhighlighter.deactivate(); + }) + ); + + this.subs.add(this.client.onAttached(() => { + this.notifications.show("Client Connected"); + }) + ); + this.subs.add(this.client.onDetached(() => { + // TODO do we need this optional chaining check? + this.ink && this.ink.Result && this.ink.Result.invalidateAll() + }) + ); + }, + + deactivate() { + this.subs.dispose(); + }, + + consumeInk(ink) { + this.ink = ink; + this.views.ink = this.ink; + this.selector.activate(this.ink); + this.docpane.activate(this.ink); + this.progress.activate(this.ink); + this.focusutils.activate(this.ink); + this.subs.add(new Disposable(() => { + this.docpane.deactivate(); + this.progress.deactivate(); + this.focusutils.deactivate(); + })); + } +}; From 283481ef85180906c11e54f5b9af68e14af281ce Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 04:12:18 -0500 Subject: [PATCH 04/16] fix dynamic requires --- lib/ui.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/ui.js b/lib/ui.js index 48dac395c..b64e39018 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -1,16 +1,27 @@ 'use babel' import { CompositeDisposable, Disposable } from 'atom'; +// TODO use babel to export ... from ... +import notifications from './ui/notifications' +import * as selector from './ui/selector' +import views from './ui/views' +import progress from './ui/progress' +import * as layout from './ui/layout' +import * as docpane from './ui/docs' +import * as focusutils from './ui/focusutils' +import * as cellhighlighter from './ui/cellhighlighter' + export default { - // TODO Fix all of these dynamic requires and circular dependencies - notifications: require('./ui/notifications'), - selector: require('./ui/selector'), - views: require('./ui/views'), - progress: require('./ui/progress'), - layout: require('./ui/layout'), - docpane: require('./ui/docs'), - focusutils: require('./ui/focusutils'), - cellhighlighter: require('./ui/cellhighlighter'), + // TODO remove these from the export default and export them directly (prevents expensive copy) + // TODO don't use this.message use message directly (prevents expensive copy) + notifications: notifications, + selector: selector, + views: views, + progress: progress, + layout: layout, + docpane: docpane, + focusutils: focusutils, + cellhighlighter: cellhighlighter, activate(client) { this.client = client; From c11b519f84843275667817396e9c1c59232c448b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 06:12:43 -0500 Subject: [PATCH 05/16] Fix dynamic requires --- lib/runtime.js | 56 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/lib/runtime.js b/lib/runtime.js index 21c562b02..a5778092a 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -1,25 +1,45 @@ 'use babel' import { CompositeDisposable, Disposable } from 'atom'; -// TODO Fix all of these dynamic requires and circular dependencies +// TODO use babel to export ... from ... +import modules from './runtime/modules' +import * as environments from './runtime/environments' +import evaluation from './runtime/evaluation' +import * as console from './runtime/console' +import completions from './runtime/completions' +import workspace from './runtime/workspace' +import plots from './runtime/plots' +import * as frontend from './runtime/frontend' +import * as debug from './runtime/debugger' +import * as profiler from './runtime/profiler' +import * as outline from './runtime/outline' +import * as linter from './runtime/linter' +import * as packages from './runtime/packages' +import debuginfo from './runtime/debuginfo' +import * as formatter from './runtime/formatter' +import goto from './runtime/goto' +import handleURI from "./runtime/urihandler"; + export default { - modules: require('./runtime/modules'), - environments: require('./runtime/environments'), - evaluation: require('./runtime/evaluation'), - console: require('./runtime/console'), - completions: require('./runtime/completions'), - workspace: require('./runtime/workspace'), - plots: require('./runtime/plots'), - frontend: require('./runtime/frontend'), - debugger: require('./runtime/debugger'), - profiler: require('./runtime/profiler'), - outline: require('./runtime/outline'), - linter: require('./runtime/linter'), - packages: require('./runtime/packages'), - debuginfo: require('./runtime/debuginfo'), - formatter: require('./runtime/formatter'), - goto: require('./runtime/goto'), + // TODO remove these from the export default and export them directly (prevents expensive copy) + // TODO don't use this.message use message directly (prevents expensive copy) + modules: modules, + environments: environments, + evaluation: evaluation, + console: console, + completions: completions, + workspace: workspace, + plots: plots, + frontend: frontend, + debugger: debug, + profiler: profiler, + outline: outline, + linter: linter, + packages: packages, + debuginfo: debuginfo, + formatter: formatter, + goto: goto, activate() { this.subs = new CompositeDisposable(); @@ -100,5 +120,5 @@ export default { return datatipDisposable; }, - handleURI: require('./runtime/urihandler') + handleURI: handleURI, }; From c51638c9857d6936b8897ff7d4cc61e9e6a62d52 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 06:46:10 -0500 Subject: [PATCH 06/16] use if for checking ink --- lib/ui.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ui.js b/lib/ui.js index b64e39018..8dcb79f95 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -45,9 +45,10 @@ export default { this.notifications.show("Client Connected"); }) ); - this.subs.add(this.client.onDetached(() => { - // TODO do we need this optional chaining check? - this.ink && this.ink.Result && this.ink.Result.invalidateAll() + subs.add(client.onDetached(() => { + if (ink) { + ink.Result.invalidateAll() + } }) ); }, From 2d390ce5f0d0b00ca588c82dfd1d57d61e6a45f8 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 06:52:37 -0500 Subject: [PATCH 07/16] named export ui I analyzed these: File ui.js Found usages (10 usages found) Unclassified usage (6 usages found) lib\runtime (6 usages found) console.js (1 usage found) 11 import { selector } from '../ui' debugger.js (1 usage found) 5 import { views } from '../ui' frontend.js (1 usage found) 4 import { selector, notifications } from '../ui' packages.js (1 usage found) 4 import { selector } from '../ui' plots.js (1 usage found) 4 import { views } from '../ui' urihandler.js (1 usage found) 4 import { docpane, views } from '../ui' Usage in string literals (4 usages found) lib (1 usage found) julia-client.coffee (1 usage found) 20 ui: require './ui' lib\runtime (2 usages found) evaluation.coffee (1 usage found) 6 {notifications, views, selector, docpane} = require '../ui' workspace.coffee (1 usage found) 4 {views} = require '../ui' lib\ui (1 usage found) layout.js (1 usage found) documentation (1 usage found) 10 return require('../ui').docpane --- lib/ui.js | 78 ++++++++++++++++++++++++------------------------ lib/ui/layout.js | 6 ++-- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/ui.js b/lib/ui.js index 8dcb79f95..c82622614 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -11,38 +11,39 @@ import * as docpane from './ui/docs' import * as focusutils from './ui/focusutils' import * as cellhighlighter from './ui/cellhighlighter' -export default { - // TODO remove these from the export default and export them directly (prevents expensive copy) - // TODO don't use this.message use message directly (prevents expensive copy) - notifications: notifications, - selector: selector, - views: views, - progress: progress, - layout: layout, - docpane: docpane, - focusutils: focusutils, - cellhighlighter: cellhighlighter, +exports.notifications = notifications +exports.selector = selector +exports.views = views +exports.progress = progress +exports.layout = layout +exports.docpane = docpane +exports.focusutils = focusutils +exports.cellhighlighter = cellhighlighter - activate(client) { - this.client = client; - this.subs = new CompositeDisposable; +let client; +let subs; +let ink; - this.notifications.activate(); - this.subs.add(atom.config.observe('julia-client.uiOptions.highlightCells', val => { +export function activate(client_in) { + client = client_in; + subs = new CompositeDisposable; + + notifications.activate(); + subs.add(atom.config.observe('julia-client.uiOptions.highlightCells', val => { if (val) { - this.cellhighlighter.activate(); + cellhighlighter.activate(); } else { - this.cellhighlighter.deactivate(); + cellhighlighter.deactivate(); } }) ); - this.subs.add(new Disposable(() => { - this.cellhighlighter.deactivate(); + subs.add(new Disposable(() => { + cellhighlighter.deactivate(); }) ); - this.subs.add(this.client.onAttached(() => { - this.notifications.show("Client Connected"); + subs.add(client.onAttached(() => { + notifications.show("Client Connected"); }) ); subs.add(client.onDetached(() => { @@ -51,23 +52,22 @@ export default { } }) ); - }, +} - deactivate() { - this.subs.dispose(); - }, +export function deactivate() { + subs.dispose(); +} - consumeInk(ink) { - this.ink = ink; - this.views.ink = this.ink; - this.selector.activate(this.ink); - this.docpane.activate(this.ink); - this.progress.activate(this.ink); - this.focusutils.activate(this.ink); - this.subs.add(new Disposable(() => { - this.docpane.deactivate(); - this.progress.deactivate(); - this.focusutils.deactivate(); +export function consumeInk(ink_in) { + ink = ink_in; + views.ink = ink; + selector.activate(ink); + docpane.activate(ink); + progress.activate(ink); + focusutils.activate(ink); + subs.add(new Disposable(() => { + docpane.deactivate(); + progress.deactivate(); + focusutils.deactivate(); })); - } -}; +} diff --git a/lib/ui/layout.js b/lib/ui/layout.js index 0e4dadbc1..f40551d77 100644 --- a/lib/ui/layout.js +++ b/lib/ui/layout.js @@ -6,9 +6,9 @@ const repl = () => { const workspace = () => { return require('../runtime').workspace } -const documentation = () => { - return require('../ui').docpane -} + +import {docpane as documentation} from '../ui' + const plotPane = () => { return require('../runtime').plots } From b7d46b8987795191ebec59d45fbb6d6dcdf75efd Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 07:01:03 -0500 Subject: [PATCH 08/16] Fixing dynamic requires --- lib/runtime.js | 105 +++++++++++++++++++++++------------------------ lib/ui/layout.js | 27 ++++-------- 2 files changed, 60 insertions(+), 72 deletions(-) diff --git a/lib/runtime.js b/lib/runtime.js index a5778092a..aff96c0f4 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -5,12 +5,12 @@ import { CompositeDisposable, Disposable } from 'atom'; import modules from './runtime/modules' import * as environments from './runtime/environments' import evaluation from './runtime/evaluation' -import * as console from './runtime/console' +import * as repl from './runtime/console' // console is a is a reserved keyword import completions from './runtime/completions' import workspace from './runtime/workspace' import plots from './runtime/plots' import * as frontend from './runtime/frontend' -import * as debug from './runtime/debugger' +import * as debug from './runtime/debugger' // debugger is a is a reserved keyword import * as profiler from './runtime/profiler' import * as outline from './runtime/outline' import * as linter from './runtime/linter' @@ -20,88 +20,87 @@ import * as formatter from './runtime/formatter' import goto from './runtime/goto' import handleURI from "./runtime/urihandler"; +exports.modules = modules +exports.environments = environments +exports.evaluation = evaluation +exports.repl = repl +exports.completions = completions +exports.workspace = workspace +exports.plots = plots +exports.frontend = frontend +exports.debug = debug +exports.profiler = profiler +exports.outline = outline +exports.linter = linter +exports.packages = packages +exports.debuginfo = debuginfo +exports.formatter = formatter +exports.goto = goto +exports.handleURI = handleURI -export default { - // TODO remove these from the export default and export them directly (prevents expensive copy) - // TODO don't use this.message use message directly (prevents expensive copy) - modules: modules, - environments: environments, - evaluation: evaluation, - console: console, - completions: completions, - workspace: workspace, - plots: plots, - frontend: frontend, - debugger: debug, - profiler: profiler, - outline: outline, - linter: linter, - packages: packages, - debuginfo: debuginfo, - formatter: formatter, - goto: goto, +let subs; - activate() { - this.subs = new CompositeDisposable(); +export function activate() { + subs = new CompositeDisposable(); - this.modules.activate(); - this.completions.activate(); - this.subs.add(atom.config.observe('julia-client.juliaOptions.formatOnSave', val => { + modules.activate(); + completions.activate(); + subs.add(atom.config.observe('julia-client.juliaOptions.formatOnSave', val => { if (val) { - this.formatter.activate(); + formatter.activate(); } else { - this.formatter.deactivate(); + formatter.deactivate(); } }) ); - this.subs.add(new Disposable(() => { - [this.modules, this.completions, this.formatter].map((mod) => mod.deactivate()); + subs.add(new Disposable(() => { + [modules, completions, formatter].map((mod) => mod.deactivate()); }) ); - }, +} - deactivate() { - this.subs.dispose(); - }, +export function deactivate() { + subs.dispose(); +} - consumeInk(ink) { - this.evaluation.ink = ink; - for (let mod of [this.console, this.debugger, this.profiler, this.linter, this.goto, this.outline, this.frontend]) { +export function consumeInk(ink) { + evaluation.ink = ink; + for (let mod of [repl, debug, profiler, linter, goto, outline, frontend]) { mod.activate(ink); } - for (let mod of [this.workspace, this.plots]) { + for (let mod of [workspace, plots]) { mod.ink = ink; mod.activate(); } - this.subs.add( + subs.add( new Disposable(() => { - for (let mod of [this.console, this.debugger, this.profiler, this.linter, this.goto, this.outline]) { + for (let mod of [repl, debug, profiler, linter, goto, outline]) { mod.deactivate(); } }) ); - this.environments.consumeInk(ink); - }, + environments.consumeInk(ink); +} - provideAutoComplete() { return this.completions; }, +export function provideAutoComplete() { return completions; } - provideHyperclick() { return this.goto.provideHyperclick(); }, +export function provideHyperclick() { return goto.provideHyperclick(); } - consumeStatusBar(bar) { - const m = this.modules.consumeStatusBar(bar); - const e = this.environments.consumeStatusBar(bar); +export function consumeStatusBar(bar) { + const m = modules.consumeStatusBar(bar); + const e = environments.consumeStatusBar(bar); const d = new Disposable(() => { m.dispose(); e.dispose(); }); - this.subs.add(d); + subs.add(d); return d; - }, +} - consumeDatatip(datatipService) { +export function consumeDatatip(datatipService) { const datatipProvider = require('./runtime/datatip'); // @NOTE: Check if the service is passed by Atom-IDE-UI's datatip service: // currently atom-ide-datatip can't render code snippets correctly. @@ -116,9 +115,7 @@ export default { ); } const datatipDisposable = datatipService.addProvider(datatipProvider); - this.subs.add(datatipDisposable); + subs.add(datatipDisposable); return datatipDisposable; - }, +} - handleURI: handleURI, -}; diff --git a/lib/ui/layout.js b/lib/ui/layout.js index 0e4dadbc1..a22a3482d 100644 --- a/lib/ui/layout.js +++ b/lib/ui/layout.js @@ -1,26 +1,17 @@ 'use babel' -const repl = () => { - return require('../runtime').console -} -const workspace = () => { - return require('../runtime').workspace -} +import { + repl, + workspace, + plots as plotPane, + debug as debuggerPane, + linter, + outline +} from '../runtime' + const documentation = () => { return require('../ui').docpane } -const plotPane = () => { - return require('../runtime').plots -} -const debuggerPane = () => { - return require('../runtime').debugger -} -const linter = () => { - return require('../runtime').linter -} -const outline = () => { - return require('../runtime').outline -} function specifiedPanes () { const panes = [] From 779c5954c404e20f99ddcef61788164a970e6b69 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 07:06:59 -0500 Subject: [PATCH 09/16] plots - fix circular deps --- lib/runtime/plots.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/runtime/plots.js b/lib/runtime/plots.js index 9ce7802cc..4e788135b 100644 --- a/lib/runtime/plots.js +++ b/lib/runtime/plots.js @@ -1,9 +1,9 @@ 'use babel' import { client } from '../connection' -import { views } from '../ui' +import views from '../ui/views' -const { webview } = views.tags +const { webview } = views.tags // TODO named import function consoleLog (e) { let log From e49ad75d4df157bb368a65604fc60958bde8d1b7 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 07:44:36 -0500 Subject: [PATCH 10/16] fix pane function calling --- lib/ui/layout.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ui/layout.js b/lib/ui/layout.js index 9159ea75e..73f1753be 100644 --- a/lib/ui/layout.js +++ b/lib/ui/layout.js @@ -30,7 +30,7 @@ export function closePromises () { const panes = specifiedPanes() const promises = panes.map(pane => { - return pane().close() + return pane.close() }) return promises @@ -75,10 +75,10 @@ function openPanesHelper (panes) { } const pane = panes.shift() - pane().open().catch((err) => { + pane.open().catch((err) => { // @FIXME: This is a temporal remedy for https://github.com/JunoLab/atom-julia-client/pull/561#issuecomment-500150318 console.error(err) - pane().open() + pane.open() }).finally(() => { // Re-focus the previously focused pane (i.e. the bundled pane by `bundlePanes`) after each opening // This prevents opening multiple panes with the same splitting rule in a same location from From fbaa169ec78c8dd46165a767d22dd2f9e16309d1 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 08:21:54 -0500 Subject: [PATCH 11/16] put exports at the end --- lib/runtime.js | 35 +++++++++++++++++------------------ lib/ui.js | 18 +++++++++--------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/lib/runtime.js b/lib/runtime.js index aff96c0f4..3e4cfd459 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -20,24 +20,6 @@ import * as formatter from './runtime/formatter' import goto from './runtime/goto' import handleURI from "./runtime/urihandler"; -exports.modules = modules -exports.environments = environments -exports.evaluation = evaluation -exports.repl = repl -exports.completions = completions -exports.workspace = workspace -exports.plots = plots -exports.frontend = frontend -exports.debug = debug -exports.profiler = profiler -exports.outline = outline -exports.linter = linter -exports.packages = packages -exports.debuginfo = debuginfo -exports.formatter = formatter -exports.goto = goto -exports.handleURI = handleURI - let subs; export function activate() { @@ -119,3 +101,20 @@ export function consumeDatatip(datatipService) { return datatipDisposable; } +exports.modules = modules +exports.environments = environments +exports.evaluation = evaluation +exports.repl = repl +exports.completions = completions +exports.workspace = workspace +exports.plots = plots +exports.frontend = frontend +exports.debug = debug +exports.profiler = profiler +exports.outline = outline +exports.linter = linter +exports.packages = packages +exports.debuginfo = debuginfo +exports.formatter = formatter +exports.goto = goto +exports.handleURI = handleURI diff --git a/lib/ui.js b/lib/ui.js index c82622614..27ce7a3aa 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -11,15 +11,6 @@ import * as docpane from './ui/docs' import * as focusutils from './ui/focusutils' import * as cellhighlighter from './ui/cellhighlighter' -exports.notifications = notifications -exports.selector = selector -exports.views = views -exports.progress = progress -exports.layout = layout -exports.docpane = docpane -exports.focusutils = focusutils -exports.cellhighlighter = cellhighlighter - let client; let subs; let ink; @@ -71,3 +62,12 @@ export function consumeInk(ink_in) { focusutils.deactivate(); })); } + +exports.notifications = notifications +exports.selector = selector +exports.views = views +exports.progress = progress +exports.layout = layout +exports.docpane = docpane +exports.focusutils = focusutils +exports.cellhighlighter = cellhighlighter From 65548ee49acc8b263664e0c283a46c7cb7b12689 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 08:37:13 -0500 Subject: [PATCH 12/16] require directly in coffeescript files --- lib/runtime/evaluation.coffee | 7 ++++++- lib/runtime/workspace.coffee | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/runtime/evaluation.coffee b/lib/runtime/evaluation.coffee index b9c687810..2219bc420 100644 --- a/lib/runtime/evaluation.coffee +++ b/lib/runtime/evaluation.coffee @@ -3,7 +3,12 @@ path = require 'path' {dialog, BrowserWindow} = require('electron').remote {client} = require '../connection' -{notifications, views, selector, docpane} = require '../ui' + +views = require '../ui/views' +notifications = require '../ui/notifications' +selector = require '../ui/selector' +docpane = require '../ui/docs' + {paths, blocks, cells, words, weave} = require '../misc' {processLinks} = require '../ui/docs' workspace = require './workspace' diff --git a/lib/runtime/workspace.coffee b/lib/runtime/workspace.coffee index e4e9d172d..70ba2858e 100644 --- a/lib/runtime/workspace.coffee +++ b/lib/runtime/workspace.coffee @@ -1,7 +1,7 @@ {CompositeDisposable} = require 'atom' -{client} = require '../connection' -{views} = require '../ui' +client = require '../connection/client' +views = require '../ui/views' goto = require './goto' modules = require './modules' From 922750d3f3e2875dfd943e6b70bf525e42f24a27 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 11 Jun 2020 19:53:18 -0500 Subject: [PATCH 13/16] named import views https://github.com/JunoLab/atom-julia-client/pull/761 --- lib/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui.js b/lib/ui.js index 27ce7a3aa..126a7f984 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -4,7 +4,7 @@ import { CompositeDisposable, Disposable } from 'atom'; // TODO use babel to export ... from ... import notifications from './ui/notifications' import * as selector from './ui/selector' -import views from './ui/views' +import * as views from './ui/views' import progress from './ui/progress' import * as layout from './ui/layout' import * as docpane from './ui/docs' From a8355c22e32d30f58ab81818f22582891de6ca67 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 11 Jun 2020 23:28:39 -0500 Subject: [PATCH 14/16] named import progress --- lib/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui.js b/lib/ui.js index 126a7f984..cf54bfe6c 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -5,7 +5,7 @@ import { CompositeDisposable, Disposable } from 'atom'; import notifications from './ui/notifications' import * as selector from './ui/selector' import * as views from './ui/views' -import progress from './ui/progress' +import * as progress from './ui/progress' import * as layout from './ui/layout' import * as docpane from './ui/docs' import * as focusutils from './ui/focusutils' From 004bcf338489702d76d4273433eef7603e9987ce Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 11 Jun 2020 23:31:29 -0500 Subject: [PATCH 15/16] plots tags named import --- lib/runtime/plots.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/runtime/plots.js b/lib/runtime/plots.js index 4e788135b..1d475cef5 100644 --- a/lib/runtime/plots.js +++ b/lib/runtime/plots.js @@ -1,9 +1,7 @@ 'use babel' import { client } from '../connection' -import views from '../ui/views' - -const { webview } = views.tags // TODO named import +import { tags } from '../ui/views' function consoleLog (e) { let log From 22bbb4d9e375f4306175fcdda598160703504dad Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 11 Jun 2020 23:57:43 -0500 Subject: [PATCH 16/16] views.activate --- lib/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui.js b/lib/ui.js index cf54bfe6c..404708703 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -51,7 +51,7 @@ export function deactivate() { export function consumeInk(ink_in) { ink = ink_in; - views.ink = ink; + views.activate(ink); selector.activate(ink); docpane.activate(ink); progress.activate(ink);