Skip to content

Commit

Permalink
Fix Class constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
lgeiger committed Dec 5, 2016
1 parent 066dab1 commit 2144042
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 50 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ rules:
default-case: [0]
guard-for-in: [0]
no-this-before-super: [0]
prefer-rest-params: [0]
11 changes: 2 additions & 9 deletions lib/code-context.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
'use babel';

export default class CodeContext {
static initClass() {
this.prototype.filename = null;
this.prototype.filepath = null;
this.prototype.lineNumber = null;
this.prototype.shebang = null;
this.prototype.textSource = null;
}

// Public: Initializes a new {CodeContext} object for the given file/line
//
// @filename - The {String} filename of the file to execute.
Expand All @@ -17,6 +9,8 @@ export default class CodeContext {
//
// Returns a newly created {CodeContext} object.
constructor(filename, filepath, textSource = null) {
this.lineNumber = null;
this.shebang = null;
this.filename = filename;
this.filepath = filepath;
this.textSource = textSource;
Expand Down Expand Up @@ -82,4 +76,3 @@ export default class CodeContext {
return this.shebang ? this.shebang.split(' ') : null;
}
}
CodeContext.initClass();
13 changes: 6 additions & 7 deletions lib/command-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import grammarMap from './grammars.coffee';

export default class CommandContext {
static initClass() {
this.prototype.command = null;
this.prototype.workingDirectory = null;
this.prototype.args = [];
this.prototype.options = {};
constructor() {
this.command = null;
this.workingDirectory = null;
this.args = [];
this.options = {};
}

static build(runtime, runOptions, codeContext) {
Expand All @@ -16,7 +16,7 @@ export default class CommandContext {
let buildArgsArray;

try {
if (!runOptions.cmd || runOptions.cmd === '') {
if (!runOptions.cmd) {
// Precondition: lang? and lang of grammarMap
commandContext.command = codeContext.shebangCommand() ||
grammarMap[codeContext.lang][codeContext.argType].command;
Expand Down Expand Up @@ -68,4 +68,3 @@ export default class CommandContext {
(scriptArgs ? ` ${scriptArgs}` : '');
}
}
CommandContext.initClass();
9 changes: 3 additions & 6 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ import fs from 'fs';
import path from 'path';

export default class Runner {
static initClass() {
this.prototype.bufferedProcess = null;
}

// Public: Creates a Runner instance
//
// * `scriptOptions` a {ScriptOptions} object instance
// * `emitter` Atom's {Emitter} instance. You probably don't need to overwrite it
constructor(scriptOptions, emitter = new Emitter()) {
constructor(scriptOptions) {
this.bufferedProcess = null;
this.stdoutFunc = this.stdoutFunc.bind(this);
this.stderrFunc = this.stderrFunc.bind(this);
this.onExit = this.onExit.bind(this);
this.createOnErrorFunc = this.createOnErrorFunc.bind(this);
this.scriptOptions = scriptOptions;
this.emitter = emitter;
this.emitter = new Emitter();
}

run(command, extraArgs, codeContext, inputString = null) {
Expand Down Expand Up @@ -175,4 +173,3 @@ export default class Runner {
return null;
}
}
Runner.initClass();
10 changes: 2 additions & 8 deletions lib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ import _ from 'underscore';
import CommandContext from './command-context';

export default class Runtime {
static initClass() {
this.prototype.observers = [];
}

// Public: Initializes a new {Runtime} instance
//
// This class is responsible for properly configuring {Runner}
constructor(runner, codeContextBuilder, observers = [], emitter = new Emitter()) {
constructor(runner, codeContextBuilder, observers = []) {
this.runner = runner;
this.codeContextBuilder = codeContextBuilder;
this.observers = observers;
this.emitter = emitter;
this.emitter = new Emitter();
this.scriptOptions = this.runner.scriptOptions;
_.each(this.observers, observer => observer.observe(this));
}
Expand Down Expand Up @@ -176,5 +172,3 @@ export default class Runtime {
this.emitter.emit('did-not-build-args', { error });
}
}

Runtime.initClass();
19 changes: 9 additions & 10 deletions lib/script-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import _ from 'underscore';

export default class ScriptOptions {
static initClass() {
this.prototype.name = '';
this.prototype.description = '';
this.prototype.lang = '';
this.prototype.workingDirectory = null;
this.prototype.cmd = null;
this.prototype.cmdArgs = [];
this.prototype.env = null;
this.prototype.scriptArgs = [];
constructor() {
this.name = '';
this.description = '';
this.lang = '';
this.workingDirectory = null;
this.cmd = null;
this.cmdArgs = [];
this.env = null;
this.scriptArgs = [];
}

static createFromOptions(name, options) {
Expand Down Expand Up @@ -71,4 +71,3 @@ export default class ScriptOptions {
return mergedEnv;
}
}
ScriptOptions.initClass();
6 changes: 2 additions & 4 deletions lib/script-profile-run-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ScriptInputView from './script-input-view';
export default class ScriptProfileRunView extends SelectListView {
initialize(profiles) {
this.profiles = profiles;
super();
super.initialize(...arguments);

this.emitter = new Emitter();

Expand All @@ -16,9 +16,7 @@ export default class ScriptProfileRunView extends SelectListView {
'core:cancel': () => this.hide(),
'core:close': () => this.hide(),
'script:run-with-profile': () => (this.panel.isVisible() ? this.hide() : this.show()),
},
),
);
}));

this.setItems(this.profiles);
this.initializeView();
Expand Down
10 changes: 4 additions & 6 deletions lib/script-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import linkPaths from './link-paths';

// Runs a portion of a script through an interpreter and displays it line by line
export default class ScriptView extends MessagePanelView {
static initClass() {
this.prototype.scrollTimeout = null;
}
constructor() {
super({ title: this.headerView, rawTitle: true, closeMethod: 'destroy' });
const headerView = new HeaderView();
super({ title: headerView, rawTitle: true, closeMethod: 'destroy' });

this.scrollTimeout = null;
this.ansiFilter = new AnsiFilter();
this.headerView = new HeaderView();
this.headerView = headerView;

this.showInTab = this.showInTab.bind(this);
this.setHeaderAndShowExecutionTime = this.setHeaderAndShowExecutionTime.bind(this);
Expand Down Expand Up @@ -219,4 +218,3 @@ new?title=Add%20support%20for%20${lang}`,
}
}
}
ScriptView.initClass();

0 comments on commit 2144042

Please sign in to comment.