Waiting for a command to complete [message #1752213] |
Fri, 20 January 2017 01:01 |
Arthur Mising name Messages: 4 Registered: July 2009 |
Junior Member |
|
|
I am working on a little script to do a refactoring (Scala's Organize Imports in this case) on every file in a project. However, I've run into a problem since it seems the script opens and tried to perform the refactor on the next file before the previous has finished. This means that if there is an error or something all the windows stack up.
How do I block my script until a command has finished?
The structure of the script is:
var files = findFiles(...);
for each (var f in files) {
var editor = showEditor(f);
executeUI(function() {
executeCommand("org.scalaide.refactoring.OrganizeImports");
editor.close(true);
});
}
I would like to save/close the a file when the refactor has totally completed and I would like to handle the next file when the previous editor has fully closed.
Any thoughts on a good approach?
To be clear: The script actually does work. It just tries to run the command and save all the files at once. The files start being processed at a rate of two or three a second, so it is waiting for something to start each one, but it is not waiting for completion.
Thanks.
The full script is:
loadModule('/System/Resources');
loadModule('/System/Environment');
loadModule('/System/Platform');
loadModule('/System/UI');
var files = findFiles("*.scala", "workspace://OrcScala/src/");
print("files: ");
for each (var f in files) {
print(f);
var editor = showEditor(f);
executeUI(function() {
executeCommand("org.scalaide.refactoring.OrganizeImports");
editor.close(true);
});
}
[Updated on: Fri, 20 January 2017 01:03] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03422 seconds