Fix NPE on creating a new launch remote config.
diff --git a/plugins/org.eclipse.koneki.ldt.remote.core/src/org/eclipse/koneki/ldt/remote/core/internal/lua/LuaRSEUtil.java b/plugins/org.eclipse.koneki.ldt.remote.core/src/org/eclipse/koneki/ldt/remote/core/internal/lua/LuaRSEUtil.java
index c0e7596..b60a360 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.core/src/org/eclipse/koneki/ldt/remote/core/internal/lua/LuaRSEUtil.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.core/src/org/eclipse/koneki/ldt/remote/core/internal/lua/LuaRSEUtil.java
@@ -79,6 +79,9 @@
}
public static LuaSubSystem getLuaSubSystem(IHost host) {
+ if (host == null)
+ return null;
+
for (ISubSystem subsytem : host.getSubSystems()) {
if (subsytem instanceof LuaSubSystem) {
return (LuaSubSystem) subsytem;
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
index c90f16d..faffda8 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.core/src/org/eclipse/koneki/ldt/remote/debug/core/internal/launch/LuaRemoteLaunchConfigurationUtil.java
@@ -166,15 +166,15 @@
}
public static String getRemoteApplicationPath(ILaunchConfiguration configuration) {
- IHost host = getHost(configuration);
+
+ final IHost host = getHost(configuration);
if (host == null)
return ""; //$NON-NLS-1$
- IRemoteFileSubSystem remoteFileSubSystem = RSEUtil.getRemoteFileSubsystem(host);
- if (remoteFileSubSystem == null)
+ final IRemoteFileSubSystem remoteFileSubSystem = RSEUtil.getRemoteFileSubsystem(host);
+ final LuaSubSystem luaSubSystem = LuaRSEUtil.getLuaSubSystem(host);
+ if (luaSubSystem == null || remoteFileSubSystem == null)
return ""; //$NON-NLS-1$
-
- LuaSubSystem luaSubSystem = LuaRSEUtil.getLuaSubSystem(host);
return luaSubSystem.getOutputDirectory() + remoteFileSubSystem.getSeparator() + configuration.getName();
}
}
diff --git a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java
index 0354fe4..e2da364 100644
--- a/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java
+++ b/plugins/org.eclipse.koneki.ldt.remote.debug.ui/src/org/eclipse/koneki/ldt/remote/debug/ui/internal/launch/tab/LuaRemoteLaunchConfigurationMainTab.java
@@ -27,6 +27,7 @@
import org.eclipse.koneki.ldt.core.LuaConstants;
import org.eclipse.koneki.ldt.core.LuaNature;
import org.eclipse.koneki.ldt.remote.core.internal.RSEUtil;
+import org.eclipse.koneki.ldt.remote.core.internal.lua.LuaRSEUtil;
import org.eclipse.koneki.ldt.remote.debug.core.internal.LuaRemoteDebugConstant;
import org.eclipse.koneki.ldt.remote.debug.core.internal.launch.LuaRemoteLaunchConfigurationUtil;
import org.eclipse.koneki.ldt.remote.debug.ui.internal.Activator;
@@ -215,10 +216,13 @@
}
configuration.setAttribute(LuaRemoteDebugConstant.SCRIPT_NAME, defaultScript);
- // get first available target
- IHost[] hosts = RSECorePlugin.getTheSystemRegistry().getHosts();
- if (hosts.length > 0) {
- LuaRemoteLaunchConfigurationUtil.setConnectionId(configuration, hosts[0]);
+ // get first available target with luaSsh subsystem
+ final IHost[] hosts = RSECorePlugin.getTheSystemRegistry().getHosts();
+ for (int i = 0; i < hosts.length && LuaRemoteLaunchConfigurationUtil.getHost(configuration) == null; i++) {
+ final IHost host = hosts[i];
+ if (LuaRSEUtil.getLuaSubSystem(host) != null) {
+ LuaRemoteLaunchConfigurationUtil.setConnectionId(configuration, host);
+ }
}
configuration.setAttribute(LuaRemoteDebugConstant.DBGP_LOGGING, false);
configuration.setAttribute(LuaRemoteDebugConstant.BREAK_ON_FIRST_LINE, false);