|
|
@ -38,10 +38,17 @@ class CompilerContainer { |
|
|
|
} |
|
|
|
} |
|
|
|
if (!this._view.compilationButton) return |
|
|
|
if (!this._view.compilationButton) return |
|
|
|
const button = this.compilationButton(name.split('/').pop()) |
|
|
|
const button = this.compilationButton(name.split('/').pop()) |
|
|
|
this._disableCompileBtn(!name) |
|
|
|
this._disableCompileBtn(!name || (name && !this.isSolFileSelected(name))) |
|
|
|
yo.update(this._view.compilationButton, button) |
|
|
|
yo.update(this._view.compilationButton, button) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isSolFileSelected (currentFile = '') { |
|
|
|
|
|
|
|
if (!currentFile) currentFile = this.config.get('currentFile') |
|
|
|
|
|
|
|
if (!currentFile) return false |
|
|
|
|
|
|
|
return currentFile.substr(currentFile.length - 3, currentFile.length) === 'sol' || |
|
|
|
|
|
|
|
currentFile.substr(currentFile.length - 3, currentFile.length) === 'yul' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deactivate () { |
|
|
|
deactivate () { |
|
|
|
// deactivate editor listeners
|
|
|
|
// deactivate editor listeners
|
|
|
|
this.editor.event.unregister('contentChanged') |
|
|
|
this.editor.event.unregister('contentChanged') |
|
|
@ -113,7 +120,7 @@ class CompilerContainer { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
compilationButton (name = '') { |
|
|
|
compilationButton (name = '') { |
|
|
|
const displayed = name || '<no file selected>' |
|
|
|
const displayed = name || '<no file selected>' |
|
|
|
const disabled = name ? '' : 'disabled' |
|
|
|
const disabled = name && this.isSolFileSelected() ? '' : 'disabled' |
|
|
|
const compileBtn = yo` |
|
|
|
const compileBtn = yo` |
|
|
|
<button id="compileBtn" data-id="compilerContainerCompileBtn" class="btn btn-primary btn-block ${disabled}" title="Compile" onclick="${this.compile.bind(this)}"> |
|
|
|
<button id="compileBtn" data-id="compilerContainerCompileBtn" class="btn btn-primary btn-block ${disabled}" title="Compile" onclick="${this.compile.bind(this)}"> |
|
|
|
<span>${this._view.compileIcon} Compile ${displayed}</span> |
|
|
|
<span>${this._view.compileIcon} Compile ${displayed}</span> |
|
|
@ -131,7 +138,7 @@ class CompilerContainer { |
|
|
|
if (!btn) return |
|
|
|
if (!btn) return |
|
|
|
if (shouldDisable) { |
|
|
|
if (shouldDisable) { |
|
|
|
btn.classList.add('disabled') |
|
|
|
btn.classList.add('disabled') |
|
|
|
} else if (this.config.get('currentFile')) { |
|
|
|
} else if (this.isSolFileSelected()) { |
|
|
|
btn.classList.remove('disabled') |
|
|
|
btn.classList.remove('disabled') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -316,10 +323,11 @@ class CompilerContainer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
compile (event) { |
|
|
|
compile (event) { |
|
|
|
if (this.config.get('currentFile')) { |
|
|
|
const currentFile = this.config.get('currentFile') |
|
|
|
this._setCompilerVersionFromPragma(this.config.get('currentFile')) |
|
|
|
if (!this.isSolFileSelected()) return |
|
|
|
this.compileTabLogic.runCompiler() |
|
|
|
|
|
|
|
} |
|
|
|
this._setCompilerVersionFromPragma(currentFile) |
|
|
|
|
|
|
|
this.compileTabLogic.runCompiler() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
compileIfAutoCompileOn () { |
|
|
|
compileIfAutoCompileOn () { |
|
|
|