diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 17e13486f4..eea9461749 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -79,6 +79,11 @@ class FileManager { return null } + currentFile () { + var self = this + return self._deps.config.get('currentFile') + } + currentPath () { var self = this var currentFile = self._deps.config.get('currentFile') diff --git a/src/app/plugin/pluginAPI.js b/src/app/plugin/pluginAPI.js index c0d1f2f389..fb9844efd5 100644 --- a/src/app/plugin/pluginAPI.js +++ b/src/app/plugin/pluginAPI.js @@ -67,7 +67,7 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => }, editor: { getCurrentFile: (mod, cb) => { - var path = fileManager.currentPath() + var path = fileManager.currentFile() if (!path) { cb('no file selected') } else { @@ -78,7 +78,7 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => var provider = fileManager.fileProviderOf(path) if (provider) { // TODO add approval to user for external plugin to get the content of the given `path` - provider.get(mod + '/' + path, (error, content) => { + provider.get(path, (error, content) => { cb(error, content) }) } else { @@ -89,7 +89,7 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => var provider = fileManager.fileProviderOf(path) if (provider) { // TODO add approval to user for external plugin to set the content of the given `path` - provider.set(mod + '/' + path, content, (error) => { + provider.set(path, content, (error) => { cb(error) }) } else { @@ -97,8 +97,15 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => } }, highlight: (mod, lineColumnPos, filePath, hexColor, cb) => { + var position + try { + position = JSON.parse(lineColumnPos) + } catch (e) { + return cb(e.message) + } highlighter.currentSourceLocation(null) - highlighter.currentSourceLocation(lineColumnPos, filePath, hexColor) + highlighter.currentSourceLocationFromfileName(position, filePath, hexColor) + cb() } } } diff --git a/test-browser/plugin/index.html b/test-browser/plugin/index.html index ff73cb0a23..f81dc19b70 100644 --- a/test-browser/plugin/index.html +++ b/test-browser/plugin/index.html @@ -37,13 +37,17 @@
PLUGIN
-
+
add config
remove config
get config
oraclize contract creation
account creation
change title
+ setcontentof
+ getcontentof
+ getcurrent
+ sethighlight

diff --git a/test-browser/plugin/plugin.js b/test-browser/plugin/plugin.js index cb85e84672..27e1305de3 100644 --- a/test-browser/plugin/plugin.js +++ b/test-browser/plugin/plugin.js @@ -53,4 +53,24 @@ window.onload = function () { extension.call('app', 'updateTitle', ['changed title ' + k++], function (error, result) { console.log(error, result) }) }) + + document.querySelector('input#setcontentof').addEventListener('click', function () { + extension.call('editor', 'setFile', [document.getElementById('filename').value, document.getElementById('valuetosend').value], + function (error, result) { console.log(error, result) }) + }) + + document.querySelector('input#getcontentof').addEventListener('click', function () { + extension.call('editor', 'getFile', [document.getElementById('filename').value], + function (error, result) { console.log(error, result) }) + }) + + document.querySelector('input#getcurrent').addEventListener('click', function () { + extension.call('editor', 'getCurrentFile', [], + function (error, result) { console.log(error, result) }) + }) + + document.querySelector('input#sethighlight').addEventListener('click', function () { + extension.call('editor', 'highlight', [document.getElementById('filename').value, document.getElementById('valuetosend').value, document.getElementById('valuetosend2').value], + function (error, result) { console.log(error, result) }) + }) }