Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactorings of the Scion client code.
Now uses the Eclipse job scheduler to run commands. This is a lot cleaner than using our own command queue; moreover, it gives us more flexibility such as job priorities and cancellation. Also, made parts of ...scion.client internal for a cleaner separation of interface and implementation.
- Loading branch information
Thomas ten Cate
committed
Jul 18, 2009
1 parent
f385d2b
commit a28871e
Showing
47 changed files
with
1,057 additions
and
776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
source.. = src/ | ||
source.. = src/,\ | ||
lib/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
plugin.properties,\ | ||
about.html,\ | ||
plugin.xml | ||
about.html | ||
src.includes = src/,\ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
...clipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/CommandQueue.java
This file was deleted.
Oops, something went wrong.
149 changes: 0 additions & 149 deletions
149
net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/Scion.java
This file was deleted.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
...lipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/ScionInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package net.sf.eclipsefp.haskell.scion.client; | ||
|
||
import net.sf.eclipsefp.haskell.scion.internal.client.ScionThreadManager; | ||
import net.sf.eclipsefp.haskell.scion.internal.commands.BackgroundTypecheckFileCommand; | ||
import net.sf.eclipsefp.haskell.scion.internal.commands.ConnectionInfoCommand; | ||
import net.sf.eclipsefp.haskell.scion.internal.commands.LoadCommand; | ||
import net.sf.eclipsefp.haskell.scion.internal.commands.NameDefinitionsCommand; | ||
import net.sf.eclipsefp.haskell.scion.internal.commands.ThingAtPointCommand; | ||
import net.sf.eclipsefp.haskell.scion.internal.util.Multiset; | ||
import net.sf.eclipsefp.haskell.scion.types.Location; | ||
|
||
/** | ||
* Manages a single instance of the Scion server. | ||
* | ||
* This is one level above {@link ScionThreadManager}, in the sense that it is concerned | ||
* with the semantics of the commands, instead of the mechanics of sending and receiving. | ||
* | ||
* Objects from this class keep track of the state of the Scion server, so that the server | ||
* can be put into the same state after a restart (either of the server, or of the entire | ||
* workbench). | ||
* | ||
* @author Thomas ten Cate | ||
*/ | ||
public class ScionInstance { | ||
|
||
private String serverExecutable; | ||
private ScionThreadManager threadManager; | ||
private Multiset<String> loadedFiles = new Multiset<String>(); | ||
|
||
public ScionInstance(String serverExecutable) { | ||
this.serverExecutable = serverExecutable; | ||
createThreadManager(); | ||
} | ||
|
||
public String getServerExecutable() { | ||
return serverExecutable; | ||
} | ||
|
||
public void setServerExecutable(String serverExecutable) { | ||
if (!this.serverExecutable.equals(serverExecutable)) { | ||
destroyThreadManager(); | ||
this.serverExecutable = serverExecutable; | ||
createThreadManager(); | ||
} | ||
} | ||
|
||
public void stop() { | ||
destroyThreadManager(); | ||
} | ||
|
||
//////////////////////////// | ||
// Thread manager handling | ||
|
||
private void createThreadManager() { | ||
threadManager = new ScionThreadManager(serverExecutable); | ||
} | ||
|
||
private void destroyThreadManager() { | ||
threadManager.dispose(); | ||
threadManager = null; | ||
} | ||
|
||
//////////////// | ||
// State stuff | ||
|
||
|
||
////////////////////// | ||
// Specific commands | ||
|
||
private void checkProtocol() { | ||
ConnectionInfoCommand command = new ConnectionInfoCommand(threadManager); | ||
if (command.runSync().isOK()) { | ||
// TODO | ||
} | ||
} | ||
|
||
public void backgroundTypecheckFile(String fileName) { | ||
BackgroundTypecheckFileCommand command = new BackgroundTypecheckFileCommand(threadManager, fileName); | ||
command.runAsync(); | ||
} | ||
|
||
public void loadFile(String fileName) { | ||
loadedFiles.add(fileName); | ||
reloadFile(fileName); | ||
} | ||
|
||
public void reloadFile(String fileName) { | ||
LoadCommand loadCommand = new LoadCommand(threadManager, fileName); | ||
BackgroundTypecheckFileCommand typecheckCommand = new BackgroundTypecheckFileCommand(threadManager, fileName); | ||
typecheckCommand.runAsyncAfter(loadCommand); | ||
loadCommand.runAsync(); | ||
} | ||
|
||
public void unloadFile(String fileName) { | ||
// TODO Scion has no command for unloading yet! | ||
loadedFiles.remove(fileName); | ||
} | ||
|
||
public String thingAtPoint(Location location) { | ||
ThingAtPointCommand command = new ThingAtPointCommand(threadManager, location); | ||
command.runSync(); | ||
if (command.getResult().isOK()) { | ||
return command.getThing(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public Location firstDefinitionLocation(String name) { | ||
NameDefinitionsCommand command = new NameDefinitionsCommand(threadManager, name); | ||
command.runSync(); | ||
if (command.getResult().isOK() && command.isFound()) { | ||
return command.getFirstLocation(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.