Bug 564318 [Scripting] fork() should accept script extension parameter

  3rd parameter now also accepts a script enxtension to lookup

Change-Id: Ib0db2c990a487d3efa8236aafa2469ff6e922985
diff --git a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ScriptingModule.java b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ScriptingModule.java
index 76a0290..d179ff9 100644
--- a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ScriptingModule.java
+++ b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ScriptingModule.java
@@ -120,13 +120,13 @@
 	 *            optional script arguments delimited by commas ','. When the string arguments contains commas ',', or for arguments that are not string, the
 	 *            caller may set a shared object with {@module #setSharedObject(String, Object, boolean, boolean)} and pass the key here. The callee can then
 	 *            retrieve it with the {@module #getSharedObject(String)} method.
-	 * @param engineID
-	 *            engine ID to be used
+	 * @param engineIdOrExtension
+	 *            engine ID to be used or a file extension to look for engines (eg: js)
 	 * @return execution result
 	 */
 	@WrapToScript
 	public ScriptResult fork(final Object resource, @ScriptParameter(defaultValue = ScriptParameter.NULL) final String arguments,
-			@ScriptParameter(defaultValue = ScriptParameter.NULL) String engineID) {
+			@ScriptParameter(defaultValue = ScriptParameter.NULL) String engineIdOrExtension) {
 
 		final ILaunch currentLaunch = getScriptEngine().getLaunch();
 		final boolean useDebugger = (currentLaunch != null) && (currentLaunch.getDebugTarget() != null);
@@ -140,11 +140,22 @@
 		}
 
 		EngineDescription description = null;
-		if (engineID != null) {
-			description = scriptService.getEngineByID(engineID);
+		if (engineIdOrExtension != null) {
+			description = scriptService.getEngineByID(engineIdOrExtension);
+
+			if (description == null) {
+				final ScriptType scriptType = scriptService.getScriptType("." + engineIdOrExtension);
+				if (scriptType != null) {
+					if (useDebugger)
+						description = scriptType.getDebugEngine();
+
+					if (description == null)
+						description = scriptType.getEngine();
+				}
+			}
 
 			if (description == null)
-				throw new RuntimeException("No script engine found for ID = \"" + engineID + "\"");
+				throw new RuntimeException("No script engine found for ID = \"" + engineIdOrExtension + "\"");
 		}
 
 		if (description == null) {