3333import com .intellij .openapi .vfs .VirtualFile ;
3434import com .tang .intellij .lua .debugger .DebuggerType ;
3535import com .tang .intellij .lua .debugger .IRemoteConfiguration ;
36- import com .tang .intellij .lua .debugger .LuaRunConfiguration ;
3736import com .tang .intellij .lua .debugger .LuaCommandLineState ;
37+ import com .tang .intellij .lua .debugger .LuaRunConfiguration ;
3838import com .tang .intellij .lua .psi .LuaFileUtil ;
3939import org .jdom .Element ;
4040import org .jetbrains .annotations .NotNull ;
4141import org .jetbrains .annotations .Nullable ;
4242
4343import java .io .File ;
44+ import java .util .ArrayList ;
45+ import java .util .Arrays ;
4446import java .util .Collection ;
4547import java .util .Collections ;
4648
@@ -52,6 +54,7 @@ public class LuaAppRunConfiguration extends LuaRunConfiguration implements IRemo
5254 private String program = SystemInfoRt .isWindows ? "lua.exe" : "lua" ;
5355 private String file ;
5456 private String workingDir ;
57+ private String params ;
5558 private DebuggerType debuggerType = DebuggerType .Attach ;
5659
5760 LuaAppRunConfiguration (Project project , ConfigurationFactory factory ) {
@@ -92,6 +95,7 @@ public void writeExternal(Element element) throws WriteExternalException {
9295 JDOMExternalizerUtil .writeField (element , "file" , file );
9396 JDOMExternalizerUtil .writeField (element , "workingDir" , workingDir );
9497 JDOMExternalizerUtil .writeField (element , "debuggerType" , String .valueOf (debuggerType .value ()));
98+ JDOMExternalizerUtil .writeField (element , "params" , params );
9599 }
96100
97101 @ Override
@@ -106,6 +110,8 @@ public void readExternal(Element element) throws InvalidDataException {
106110 String debuggerType = JDOMExternalizerUtil .readField (element , "debuggerType" );
107111 if (debuggerType != null )
108112 this .debuggerType = DebuggerType .valueOf (Integer .parseInt (debuggerType ));
113+
114+ params = JDOMExternalizerUtil .readField (element , "params" );
109115 }
110116
111117 @ Override
@@ -134,6 +140,27 @@ public void setDebuggerType(DebuggerType debuggerType) {
134140 this .debuggerType = debuggerType ;
135141 }
136142
143+ public void setParameters (@ Nullable String params ) {
144+ this .params = params ;
145+ }
146+
147+ public String getParameters () {
148+ return params ;
149+ }
150+
151+ @ NotNull
152+ public String [] getParametersArray () {
153+ ArrayList <String > list = new ArrayList <>();
154+ if (params != null && !params .isEmpty ()) {
155+ String [] strings = params .split ("\\ s+" );
156+ list .addAll (Arrays .asList (strings ));
157+ }
158+ if (file != null && !file .isEmpty ()) {
159+ list .add (file );
160+ }
161+ return list .toArray (new String [list .size ()]);
162+ }
163+
137164 public String getWorkingDir () {
138165 if (workingDir == null || workingDir .isEmpty ())
139166 workingDir = getDefaultWorkingDir ();
@@ -180,7 +207,8 @@ public void checkConfiguration() throws RuntimeConfigurationException {
180207 @ Override
181208 public GeneralCommandLine createCommandLine () {
182209 GeneralCommandLine commandLine = new GeneralCommandLine ().withExePath (program );
183- commandLine .addParameters (getFile ());
210+ String [] params = getParametersArray ();
211+ commandLine .addParameters (params );
184212 commandLine .setWorkDirectory (getWorkingDir ());
185213 return commandLine ;
186214 }
0 commit comments