Skip to content

Commit b5cce81

Browse files
committed
App Run: parameter supports
1 parent 8bb5c5e commit b5cce81

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

src/main/java/com/tang/intellij/lua/debugger/app/LuaAppAttachProcess.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ protected LuaAttachBridge startBridge() {
4040
bridge = new LuaAttachBridge(getSession());
4141
bridge.setProtoHandler(this);
4242
bridge.setProtoFactory(this);
43-
bridge.launch(configuration.getProgram(), workingDir, new String[] { configuration.getFile() });
43+
44+
bridge.launch(configuration.getProgram(), workingDir, configuration.getParametersArray());
4445

4546
return bridge;
4647
}

src/main/java/com/tang/intellij/lua/debugger/app/LuaAppRunConfiguration.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
import com.intellij.openapi.vfs.VirtualFile;
3434
import com.tang.intellij.lua.debugger.DebuggerType;
3535
import com.tang.intellij.lua.debugger.IRemoteConfiguration;
36-
import com.tang.intellij.lua.debugger.LuaRunConfiguration;
3736
import com.tang.intellij.lua.debugger.LuaCommandLineState;
37+
import com.tang.intellij.lua.debugger.LuaRunConfiguration;
3838
import com.tang.intellij.lua.psi.LuaFileUtil;
3939
import org.jdom.Element;
4040
import org.jetbrains.annotations.NotNull;
4141
import org.jetbrains.annotations.Nullable;
4242

4343
import java.io.File;
44+
import java.util.ArrayList;
45+
import java.util.Arrays;
4446
import java.util.Collection;
4547
import 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
}

src/main/java/com/tang/intellij/lua/debugger/app/LuaAppSettingsEditor.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<text value="Program:"/>
8080
</properties>
8181
</component>
82-
<component id="30b37" class="com.intellij.ui.RawCommandLineEditor">
82+
<component id="30b37" class="com.intellij.ui.RawCommandLineEditor" binding="parameters">
8383
<constraints>
8484
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
8585
</constraints>

src/main/java/com/tang/intellij/lua/debugger/app/LuaAppSettingsEditor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.intellij.openapi.roots.ProjectRootManager;
2727
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
2828
import com.intellij.openapi.util.SystemInfoRt;
29+
import com.intellij.ui.RawCommandLineEditor;
2930
import com.intellij.util.TextFieldCompletionProvider;
3031
import com.intellij.util.textCompletion.TextFieldWithCompletion;
3132
import com.tang.intellij.lua.debugger.DebuggerType;
@@ -46,6 +47,7 @@ public class LuaAppSettingsEditor extends SettingsEditor<LuaAppRunConfiguration>
4647
private JComboBox<DebuggerType> myDebugger;
4748
private TextFieldWithCompletion myFile;
4849
private TextFieldWithBrowseButton myWorkingDir;
50+
private RawCommandLineEditor parameters;
4951
private Project project;
5052

5153
LuaAppSettingsEditor(Project project) {
@@ -72,6 +74,7 @@ protected void resetEditorFrom(@NotNull LuaAppRunConfiguration luaAppRunConfigur
7274
myWorkingDir.setText(luaAppRunConfiguration.getWorkingDir());
7375
myFile.setText(luaAppRunConfiguration.getFile());
7476
myDebugger.setSelectedItem(luaAppRunConfiguration.getDebuggerType());
77+
parameters.setText(luaAppRunConfiguration.getParameters());
7578
}
7679

7780
@Override
@@ -80,6 +83,7 @@ protected void applyEditorTo(@NotNull LuaAppRunConfiguration luaAppRunConfigurat
8083
luaAppRunConfiguration.setWorkingDir(myWorkingDir.getText());
8184
luaAppRunConfiguration.setFile(myFile.getText());
8285
luaAppRunConfiguration.setDebuggerType((DebuggerType) myDebugger.getSelectedItem());
86+
luaAppRunConfiguration.setParameters(parameters.getText());
8387
}
8488

8589
@NotNull

0 commit comments

Comments
 (0)