From 9b8186512a40197d67ad0e5f66823b51276b27ac Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 8 Jun 2020 07:25:23 -0500 Subject: [PATCH] named export + remove this. Since this is was a module, it remained a module I analyzed these files. All except debugger (updated here) and julia-client (updated in other PR) use named import: File connection.js Found usages (24 usages found) Unclassified usage (17 usages found) lib\runtime (16 usages found) completions.js (1 usage found) 10 import { client } from '../connection' console.js (1 usage found) 3 import { client } from '../connection' datatip.js (1 usage found) 11 import { client } from '../connection' debugger.js (2 usages found) 6 import { client } from '../connection' 7 import connection from '../connection' debuginfo.js (1 usage found) 3 import { client } from '../connection' environments.js (1 usage found) 6 import { client } from '../connection' formatter.js (1 usage found) 4 import { client } from '../connection' frontend.js (1 usage found) 3 import { client } from '../connection' goto.js (1 usage found) 7 import { client } from '../connection' linter.js (1 usage found) 4 import { client } from '../connection' outline.js (1 usage found) 5 import { client } from '../connection' packages.js (1 usage found) 3 import { client } from '../connection' plots.js (1 usage found) 3 import { client } from '../connection' profiler.js (1 usage found) 3 import { client } from '../connection' urihandler.js (1 usage found) 3 import { client } from '../connection' lib\ui (1 usage found) docs.js (1 usage found) 4 import { client } from '../connection' Usage in string literals (7 usages found) lib (1 usage found) julia-client.coffee (1 usage found) 21 connection: require './connection' lib\package (1 usage found) config.coffee (1 usage found) 1 {terminal} = require '../connection' lib\runtime (3 usages found) evaluation.coffee (1 usage found) 5 {client} = require '../connection' modules.coffee (1 usage found) 6 {client} = require '../connection' workspace.coffee (1 usage found) 3 {client} = require '../connection' lib\ui (2 usages found) progress.coffee (1 usage found) 2 {client} = require '../connection' views.coffee (1 usage found) 3 {client} = require '../connection' --- lib/connection.js | 91 ++++++++++++++++++++--------------------- lib/runtime/debugger.js | 27 ++++++------ 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/lib/connection.js b/lib/connection.js index 2351f764..884fd0c1 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -9,70 +9,69 @@ import client from './connection/client' import local from './connection/local' import terminal from './connection/terminal' -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) - IPC: IPC, - messages: messages, - client: client, - local: local, - terminal: terminal, +exports.IPC = IPC +exports.messages = messages +exports.client = client +exports.local = local +exports.terminal = terminal - activate() { - this.messages.activate(); - this.client.activate(); - this.client.boot = () => this.boot(); - this.local.activate(); - this.booting = false; - }, +let booting = false; +let ink; - deactivate() { - this.client.deactivate(); - }, +export function activate() { + messages.activate(); + client.activate(); + client.boot = () => boot(); + local.activate(); + booting = false; +} - consumeInk(ink) { - this.IPC.consumeInk(ink); - this.ink = ink; - }, +export function deactivate() { + client.deactivate(); +} - consumeGetServerConfig(getconf) { - this.local.consumeGetServerConfig(getconf); - }, +export function consumeInk(ink_in) { + ink = ink_in; + IPC.consumeInk(ink); +} - consumeGetServerName(name) { - this.local.consumeGetServerName(name); - }, +export function consumeGetServerConfig(getconf) { + local.consumeGetServerConfig(getconf); +} - _boot(provider) { - if (!this.client.isActive() && !this.booting) { - this.booting = true; - this.client.setBootMode(provider); +export function consumeGetServerName(name) { + local.consumeGetServerName(name); +} + +export function _boot(provider) { + if (!client.isActive() && !booting) { + booting = true; + client.setBootMode(provider); let p; if (provider === 'External Terminal') { p = externalTerminal.connectedRepl(); } else { - p = this.local.start(provider); + p = local.start(provider); } - if (this.ink) { - this.ink.Opener.allowRemoteFiles(provider === 'Remote'); + if (ink) { + ink.Opener.allowRemoteFiles(provider === 'Remote'); } p.then(() => { - this.booting = false; + booting = false; }); p.catch(() => { - this.booting = false; + booting = false; }); - return time("Julia Boot", this.client.import('ping')()); + return time("Julia Boot", client.import('ping')()); } - }, +} - bootRemote() { - return this._boot('Remote'); - }, +export function bootRemote() { + return _boot('Remote'); +} - boot() { - return this._boot(atom.config.get('julia-client.juliaOptions.bootMode')); - } -}; +export function boot() { + return _boot(atom.config.get('julia-client.juliaOptions.bootMode')); +} diff --git a/lib/runtime/debugger.js b/lib/runtime/debugger.js index 03bed5e7..253fb973 100644 --- a/lib/runtime/debugger.js +++ b/lib/runtime/debugger.js @@ -3,8 +3,7 @@ import { CompositeDisposable } from 'atom' import { views } from '../ui' -import { client } from '../connection' -import connection from '../connection' +import { client, boot as connection_boot } from '../connection' import { blocks, cells, paths } from '../misc' import modules from './modules' @@ -273,53 +272,53 @@ export function debugBlock(shouldStep, cell) { } export function clearbps() { - connection.boot() + connection_boot() breakpoints.clear() if (client.isActive()) client.import('clearbps')() } function toggleJuliaBP (item) { - connection.boot() + connection_boot() return client.import('toggleBP')(item) } function clearJulia () { - connection.boot() + connection_boot() return client.import('clearbps')() } function toggleUncaughtJulia () { - connection.boot() + connection_boot() return client.import('toggleUncaught')() } function toggleExceptionJulia () { - connection.boot() + connection_boot() return client.import('toggleException')() } function toggleCompiled () { - connection.boot() + connection_boot() return client.import('toggleCompiled')() } function getBreakpoints () { - connection.boot() + connection_boot() return client.import('getBreakpoints')() } function addArgsJulia (args) { - connection.boot() + connection_boot() return client.import('addArgs')(args) } function toggleAllActiveJulia (args) { - connection.boot() + connection_boot() return client.import('toggleAllActiveBP')(args) } function toggleActiveJulia (item) { - connection.boot() + connection_boot() return client.import('toggleActiveBP')(item) } function addCondition (item, cond) { - connection.boot() + connection_boot() return client.import('addConditionById')(item, cond) } function setLevel (level) { - connection.boot() + connection_boot() return client.import('setStackLevel')(level) }