summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Aubry2012-10-04 05:35:17 (EDT)
committersbernard2012-10-04 05:35:17 (EDT)
commitce42e93d64a507881a4068c4c22369e209f6f100 (patch)
tree71feecd25a26b20c3fb897b101920a3effea05a7
parentd06e6193b4ab0fc5bab7f6f7f969e5ec53a37c66 (diff)
downloadorg.eclipse.koneki.ldt-ce42e93d64a507881a4068c4c22369e209f6f100.zip
org.eclipse.koneki.ldt-ce42e93d64a507881a4068c4c22369e209f6f100.tar.gz
org.eclipse.koneki.ldt-ce42e93d64a507881a4068c4c22369e209f6f100.tar.bz2
bug 390674: [remote] Remote launch configuration, fix the script
launched on the remote
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java21
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java1
-rw-r--r--plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties1
-rw-r--r--plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/LuaUtils.java62
4 files changed, 68 insertions, 17 deletions
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
index 9e4ad32..5e1bcbe 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationDelegate.java
@@ -22,10 +22,12 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
@@ -35,6 +37,7 @@ import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.dltk.compiler.env.IModuleSource;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.dbgp.DbgpSessionIdGenerator;
@@ -42,6 +45,7 @@ import org.eclipse.dltk.debug.core.DLTKDebugLaunchConstants;
import org.eclipse.dltk.debug.core.DLTKDebugPlugin;
import org.eclipse.dltk.launching.InterpreterConfig;
import org.eclipse.koneki.ldt.core.LuaConstants;
+import org.eclipse.koneki.ldt.core.LuaUtils;
import org.eclipse.koneki.ldt.debug.core.internal.LuaDebugConstants;
import org.eclipse.koneki.ldt.remote.core.internal.NetworkUtil;
import org.eclipse.koneki.ldt.remote.core.internal.RSEUtil;
@@ -110,12 +114,24 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
Messages.LuaRemoteLaunchConfigurationDelegate_error_connectionfailed, e));
}
+ // create script project
+ IScriptProject scriptProject = DLTKCore.create(project);
+
// compute the remote project workingdir
if (submonitor.isCanceled())
return;
String outputDirectory = luaSubSystem.getOutputDirectory();
String remoteApplicationFolderPath = LuaRemoteLaunchConfigurationUtil.getRemoteApplicationPath(configuration);
+ // compute script file source path relative path
+ String scriptProjectRelativePath = configuration.getAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, LuaConstants.DEFAULT_MAIN_FILE);
+ IFile scriptFile = project.getFile(scriptProjectRelativePath);
+ IModuleSource moduleSource = LuaUtils.getModuleSourceFromAbsoluteURI(scriptFile.getLocationURI(), scriptProject);
+ if (moduleSource == null)
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(
+ Messages.LuaRemoteLaunchConfigurationDelegate_error_unabletofindsourcerelativepath, scriptProjectRelativePath)));
+ IPath scriptSourcePathRelativePath = LuaUtils.getSourcePathRelativePath(moduleSource);
+
// kill Process if already running
// could happen if connection is closed and last process launch is not terminate
Session session = RSEUtil.getCurrentSshSession(host.getConnectorServices());
@@ -157,7 +173,6 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
remoteFileSubSystem.createFolder(remoteWorkingFolder, submonitor.newChild(1));
// upload sourcecode
- IScriptProject scriptProject = DLTKCore.create(project);
LuaRSEUtil.uploadFiles(remoteFileSubSystem, scriptProject, remoteApplicationFolderPath, submonitor.newChild(2));
// upload Debug module
@@ -228,8 +243,6 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
}
// create lua execution command
- // TODO get value from launch configuration
- String mainRelativePath = LuaConstants.DEFAULT_MAIN_FILE;
List<String> cmd = new ArrayList<String>(6);
// FIXME is there a cleaner way to control buffering ?
// see: http://lua-users.org/lists/lua-l/2011-05/msg00549.html
@@ -243,7 +256,7 @@ public class LuaRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
}
cmd.add("-e"); //$NON-NLS-1$
cmd.add(bootstrapCode);
- cmd.add(mainRelativePath);
+ cmd.add(scriptSourcePathRelativePath.toPortableString());
submonitor.setWorkRemaining(1);
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java
index c0c6252..6d4601c 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/Messages.java
@@ -21,6 +21,7 @@ public class Messages extends NLS {
public static String LuaRemoteLaunchConfigurationDelegate_error_noremotefilesystem;
public static String LuaRemoteLaunchConfigurationDelegate_error_unable_to_define_ideip;
public static String LuaRemoteLaunchConfigurationDelegate_error_unabletoaccestoremoteapplicationdir;
+ public static String LuaRemoteLaunchConfigurationDelegate_error_unabletofindsourcerelativepath;
public static String LuaRemoteLaunchConfigurationDelegate_error_unabletouploaddebuggerfiles;
public static String LuaRemoteLaunchConfigurationUtil_error_closed_project;
public static String LuaRemoteLaunchConfigurationUtil_error_no_host_selected;
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties
index 80cbe1c..ff46634 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/messages.properties
@@ -4,6 +4,7 @@ LuaRemoteLaunchConfigurationDelegate_error_noluasystem=The host for this launch
LuaRemoteLaunchConfigurationDelegate_error_noremotefilesystem=The host for this launch configuration has no remote file system. Unable to copy file on the host.
LuaRemoteLaunchConfigurationDelegate_error_unable_to_define_ideip=Unable to define IDE IP address, you could set it manualy by adding the {0} environment variable to your launch configuration.
LuaRemoteLaunchConfigurationDelegate_error_unabletoaccestoremoteapplicationdir=Error when trying to access to remote application path :{0}
+LuaRemoteLaunchConfigurationDelegate_error_unabletofindsourcerelativepath=Unable to get relative source path for the script :{0}, This file is maybe not in the source path.
LuaRemoteLaunchConfigurationDelegate_error_unabletouploaddebuggerfiles=Unable to upload debugger files
LuaRemoteLaunchConfigurationUtil_error_no_project=A project must be selected.
LuaRemoteLaunchConfigurationUtil_error_unexisted_project=The project ''{0}'' doesn't exist.
diff --git a/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/LuaUtils.java b/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/LuaUtils.java
index 7773980..c37432d 100644
--- a/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/LuaUtils.java
+++ b/plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/LuaUtils.java
@@ -96,42 +96,77 @@ public final class LuaUtils {
* e.g. : socket.core
*/
public static String getModuleFullName(final ISourceModule module) {
+ IPath path = getSourcePathRelativePath(module);
+
+ // replace file name by the module name
String moduleName = getModuleName(module);
+ path = path.removeLastSegments(1);
+ // handle the case of a package with a init module
+ if (path.segmentCount() == 0 || !"init".equals(moduleName)) { //$NON-NLS-1$
+ path = path.append(moduleName);
+ }
+
+ // build package prefix from the path
+ StringBuilder fullNameBuilder = new StringBuilder();
+ for (String segment : path.segments()) {
+ if (fullNameBuilder.length() > 0) {
+ fullNameBuilder.append("."); //$NON-NLS-1$
+ }
+ fullNameBuilder.append(segment);
+ }
+
+ return fullNameBuilder.toString();
+ }
+
+ /**
+ * @return the source path relative path of the given module
+ */
+ public static IPath getSourcePathRelativePath(IModuleSource module) {
+ final IModelElement modelElement = module.getModelElement();
+ if (modelElement instanceof ISourceModule) {
+ return getSourcePathRelativePath((ISourceModule) modelElement);
+ } else {
+ return new Path(module.getFileName());
+ }
+ }
+
+ /**
+ * @return the source path relative path of the given module
+ */
+ public static IPath getSourcePathRelativePath(ISourceModule module) {
+ String moduleName = module.getElementName();
// get prefix
- String prefix = null;
+ IPath prefix = null;
if (module.getParent() instanceof IScriptFolder) {
- prefix = getFolderFullName((IScriptFolder) module.getParent());
+ prefix = getFolderSourcePathRelativePath((IScriptFolder) module.getParent());
}
if (prefix != null)
- if ("init".equalsIgnoreCase(moduleName))//$NON-NLS-1$
- return prefix;
- else
- return prefix + "." + moduleName; //$NON-NLS-1$
+ return prefix.append(moduleName);
else
- return moduleName;
+ return new Path(moduleName);
}
/*
* @return the source folder full name with module dot syntax
*/
- private static String getFolderFullName(final IScriptFolder folder) {
+ private static IPath getFolderSourcePathRelativePath(final IScriptFolder folder) {
if (!folder.isRootFolder()) {
// get folder name
- final String folderName = folder.getElementName().replace("/", "."); //$NON-NLS-1$//$NON-NLS-2$
+ final String folderName = folder.getElementName();
// get prefix
final IModelElement parent = folder.getParent();
- String prefix = null;
+ IPath prefix = null;
if (parent instanceof IScriptFolder) {
- prefix = getFolderFullName((IScriptFolder) parent) + "."; //$NON-NLS-1$
+ prefix = getFolderSourcePathRelativePath((IScriptFolder) parent);
}
if (prefix != null)
- return prefix + "." + folderName; //$NON-NLS-1$
+ return prefix.append(folderName);
else
- return folderName;
+ return new Path(folderName);
}
return null;
}
@@ -466,4 +501,5 @@ public final class LuaUtils {
}
return false;
}
+
}