Moved getFile, setFile and switchFile to new API

pull/4/head
ioedeveloper 5 years ago
parent 0e7e1e5ff6
commit a545296b33
  1. 2
      src/app.js
  2. 2
      src/app/editor/contextView.js
  3. 2
      src/app/editor/sourceHighlighter.js
  4. 4
      src/app/files/file-explorer.js
  5. 13
      src/app/files/fileManager.js
  6. 4
      src/app/panels/tab-proxy.js
  7. 2
      src/app/tabs/runTab/model/recorder.js
  8. 2
      src/app/tabs/testTab/testTab.js
  9. 2
      src/app/ui/renderer.js
  10. 1
      src/app/ui/tooltip.js
  11. 4
      src/lib/cmdInterpreterAPI.js

@ -419,7 +419,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
if (error) console.error(error)
if (Object.keys(filesList).length === 0) {
for (let file in examples) {
fileManager.setFile(examples[file].name, examples[file].content)
fileManager.writeFile(examples[file].name, examples[file].content)
}
}
})

@ -112,7 +112,7 @@ class ContextView {
if (provider) {
provider.exists(filename, (error, exist) => {
if (error) return console.log(error)
this._deps.fileManager.switchFile(filename)
this._deps.fileManager.open(filename)
jumpToLine(lineColumn)
})
}

@ -40,7 +40,7 @@ class SourceHighlighter {
if (lineColumnPos) {
this.source = filePath
if (this._deps.config.get('currentFile') !== this.source) {
this._deps.fileManager.switchFile(this.source)
this._deps.fileManager.open(this.source)
}
const css = csjs`

@ -60,7 +60,7 @@ function fileExplorer (localRegistry, files, menuItems) {
}
self.events.register('focus', function (path) {
self._deps.fileManager.switchFile(path)
self._deps.fileManager.open(path)
})
self._components.registry.put({ api: self, name: `fileexplorer/${self.files.type}` })
@ -584,7 +584,7 @@ fileExplorer.prototype.createNewFile = function (parentFolder = 'browser') {
if (!self.files.set(newName, '')) {
tooltip('Failed to create file ' + newName)
} else {
self._deps.fileManager.switchFile(newName)
self._deps.fileManager.open(newName)
if (newName.includes('_test.sol')) {
self.events.trigger('newTestFileCreated', [newName])
}

@ -23,7 +23,7 @@ const profile = {
icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNjk2IDM4NHE0MCAwIDY4IDI4dDI4IDY4djEyMTZxMCA0MC0yOCA2OHQtNjggMjhoLTk2MHEtNDAgMC02OC0yOHQtMjgtNjh2LTI4OGgtNTQ0cS00MCAwLTY4LTI4dC0yOC02OHYtNjcycTAtNDAgMjAtODh0NDgtNzZsNDA4LTQwOHEyOC0yOCA3Ni00OHQ4OC0yMGg0MTZxNDAgMCA2OCAyOHQyOCA2OHYzMjhxNjgtNDAgMTI4LTQwaDQxNnptLTU0NCAyMTNsLTI5OSAyOTloMjk5di0yOTl6bS02NDAtMzg0bC0yOTkgMjk5aDI5OXYtMjk5em0xOTYgNjQ3bDMxNi0zMTZ2LTQxNmgtMzg0djQxNnEwIDQwLTI4IDY4dC02OCAyOGgtNDE2djY0MGg1MTJ2LTI1NnEwLTQwIDIwLTg4dDQ4LTc2em05NTYgODA0di0xMTUyaC0zODR2NDE2cTAgNDAtMjggNjh0LTY4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4=',
permission: true,
version: packageJson.version,
methods: ['setFile', 'switchFile', 'file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'unlink', 'rename', 'readdir', 'rmdir'],
methods: ['file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'unlink', 'rename', 'readdir', 'rmdir'],
kind: 'file-system'
}
@ -76,7 +76,7 @@ class FileManager extends Plugin {
}
/**
* Emit error based on error code
* Emits error based on error code
* @param {object} error error { code, message }
*/
_handleError (error) {
@ -129,10 +129,9 @@ class FileManager extends Plugin {
* @returns {boolean} true if path is a file.
*/
isFile (path) {
const extension = path.split('.').pop()
const splitExtension = extension.split('/')
return !!extension && splitExtension.length === 1 && splitExtension[0] === extension
const extension = path.split('/').pop()
return extension && extension.indexOf('.') > -1
}
/**
@ -165,7 +164,7 @@ class FileManager extends Plugin {
readFile (path) {
this._handleExists(path, `Cannot read file ${path}`)
this._handleIsFile(path, `Cannot read file ${path}`)
this.getFile(path)
return this.getFile(path)
}
/**

@ -34,7 +34,7 @@ export class TabProxy {
return
}
this.addTab(file, '', () => {
this.fileManager.switchFile(file)
this.fileManager.open(file)
this.event.emit('switchFile', file)
},
() => {
@ -47,7 +47,7 @@ export class TabProxy {
if (isFolder) return
// should change the tab title too
this.addTab(newName, '', () => {
this.fileManager.switchFile(newName)
this.fileManager.open(newName)
this.event.emit('switchFile', newName)
},
() => {

@ -319,7 +319,7 @@ class Recorder {
helper.createNonClashingName(newFile, fileProvider, (error, newFile) => {
if (error) return cb('Failed to create file. ' + newFile + ' ' + error)
if (!fileProvider.set(newFile, txJSON)) return cb('Failed to create file ' + newFile)
this.fileManager.switchFile(newFile)
this.fileManager.open(newFile)
})
})
}

@ -19,7 +19,7 @@ class TestTabLogic {
// This should be updated to pass complete path, if test file comes from different directory/path
const fileNameToImport = splittedFileName[splittedFileName.length - 1]
if (!fileProvider.set(newFile, this.generateTestContractSample(fileNameToImport))) return modalDialogCustom.alert('Failed to create test file ' + newFile)
this.fileManager.switchFile(newFile)
this.fileManager.open(newFile)
})
}

@ -41,7 +41,7 @@ Renderer.prototype._errorClick = function (errFile, errLine, errCol) {
if (provider) {
provider.exists(errFile, (error, exist) => {
if (error) return console.log(error)
self._deps.fileManager.switchFile(errFile)
self._deps.fileManager.open(errFile)
editor.gotoLine(errLine, errCol)
})
}

@ -34,7 +34,6 @@ class Toaster {
}
render (tooltipText, actionElement, opts) {
console.log('tooltipText: ', tooltipText)
opts = defaultOptions(opts)
let canShorten = true
if (tooltipText instanceof Element) {

@ -151,7 +151,7 @@ class CmdInterpreterAPI {
toolTip(`Unable to load ${url}: ${err}`)
if (cb) cb(err)
} else {
self._deps.fileManager.setFile(type + '/' + cleanUrl, content)
self._deps.fileManager.writeFile(type + '/' + cleanUrl, content)
try {
content = JSON.parse(content)
async.eachOfSeries(content.sources, (value, file, callbackSource) => {
@ -164,7 +164,7 @@ class CmdInterpreterAPI {
return callbackSource(`Cannot retrieve the content of ${url}: ${error}`)
} else {
try {
await self._deps.fileManager.setFile(type + '/' + cleanUrl, content)
await self._deps.fileManager.writeFile(type + '/' + cleanUrl, content)
callbackSource()
} catch (e) {
callbackSource(e.message)

Loading…
Cancel
Save