Skip to content

Commit 0987f55

Browse files
committed
feat(vscode): use short CLI argument versions when calling robotcode
1 parent e69465b commit 0987f55

File tree

8 files changed

+133
-131
lines changed

8 files changed

+133
-131
lines changed

docs/03_reference/config.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,7 +2630,7 @@ exit_code_mask = "error|warn"
26302630

26312631
## tool.robotcode-analyze.code.exit-code-mask
26322632

2633-
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint']] | None`
2633+
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint', 'all']] | None`
26342634

26352635
Specifies the exit code mask for the code analysis.
26362636
This is useful if you want to ignore certain types of diagnostics in the result code.
@@ -2643,7 +2643,7 @@ exit_code_mask = ["error", "warn"]
26432643

26442644
## tool.robotcode-analyze.code.extend-exit-code-mask
26452645

2646-
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint']] | None`
2646+
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint', 'all']] | None`
26472647

26482648
Extend the exit code mask setting.
26492649

@@ -2741,7 +2741,7 @@ Extend the code analysis configuration.
27412741

27422742
## tool.robotcode-analyze.extend-code.exit-code-mask
27432743

2744-
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint']] | None`
2744+
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint', 'all']] | None`
27452745

27462746
Specifies the exit code mask for the code analysis.
27472747
This is useful if you want to ignore certain types of diagnostics in the result code.
@@ -2754,7 +2754,7 @@ exit_code_mask = ["error", "warn"]
27542754

27552755
## tool.robotcode-analyze.extend-code.extend-exit-code-mask
27562756

2757-
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint']] | None`
2757+
Type: `list[Literal['error', 'warn', 'warning', 'info', 'information', 'hint', 'all']] | None`
27582758

27592759
Extend the exit code mask setting.
27602760

intellij-client/src/main/kotlin/dev/robotcode/robotcode4ij/RobotCodeHelpers.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RobotCodeHelpers {
2222
val toolPath: Path = bundledPath.resolve("tool")
2323
val robotCodePath: Path = toolPath.resolve("robotcode")
2424
val checkRobotVersion: Path = toolPath.resolve("utils").resolve("check_robot_version.py")
25-
25+
2626
val PYTHON_AND_ROBOT_OK_KEY = Key.create<Boolean?>("ROBOTCODE_PYTHON_AND_ROBOT_OK")
2727
}
2828
}
@@ -38,28 +38,28 @@ fun Project.checkPythonAndRobotVersion(reset: Boolean = false): Boolean {
3838
if (!reset && this.getUserData(RobotCodeHelpers.PYTHON_AND_ROBOT_OK_KEY) == true) {
3939
return true
4040
}
41-
41+
4242
val result = ApplicationManager.getApplication().executeOnPooledThread<Boolean> {
43-
43+
4444
val pythonInterpreter = this.robotPythonSdk?.homePath
45-
45+
4646
if (pythonInterpreter == null) {
4747
thisLogger().info("No Python Interpreter defined for project '${this.name}'")
4848
return@executeOnPooledThread false
4949
}
50-
50+
5151
if (!Path(pythonInterpreter).exists()) {
5252
thisLogger().warn("Python Interpreter $pythonInterpreter not exists")
5353
return@executeOnPooledThread false
5454
}
55-
55+
5656
if (!Path(pythonInterpreter).isRegularFile()) {
5757
thisLogger().warn("Python Interpreter $pythonInterpreter is not a regular file")
5858
return@executeOnPooledThread false
5959
}
60-
60+
6161
thisLogger().info("Use Python Interpreter $pythonInterpreter for project '${this.name}'")
62-
62+
6363
val res = ExecUtil.execAndGetOutput(
6464
GeneralCommandLine(
6565
pythonInterpreter, "-u", "-c", "import sys; print(sys.version_info[:2]>=(3,8))"
@@ -69,7 +69,7 @@ fun Project.checkPythonAndRobotVersion(reset: Boolean = false): Boolean {
6969
thisLogger().warn("Invalid python version")
7070
return@executeOnPooledThread false
7171
}
72-
72+
7373
val res1 = ExecUtil.execAndGetOutput(
7474
GeneralCommandLine(pythonInterpreter, "-u", RobotCodeHelpers.checkRobotVersion.pathString),
7575
timeoutInMilliseconds = 5000
@@ -78,13 +78,13 @@ fun Project.checkPythonAndRobotVersion(reset: Boolean = false): Boolean {
7878
thisLogger().warn("Invalid Robot Framework version")
7979
return@executeOnPooledThread false
8080
}
81-
81+
8282
return@executeOnPooledThread true
83-
83+
8484
}.get()
85-
85+
8686
this.putUserData(RobotCodeHelpers.PYTHON_AND_ROBOT_OK_KEY, result)
87-
87+
8888
return result
8989
}
9090

@@ -100,7 +100,7 @@ fun Project.buildRobotCodeCommandLine(
100100
if (!this.checkPythonAndRobotVersion()) {
101101
throw IllegalArgumentException("PythonSDK is not defined or robot version is not valid for project ${this.name}")
102102
}
103-
103+
104104
val pythonInterpreter = this.robotPythonSdk?.homePath
105105
val commandLine = GeneralCommandLine(
106106
pythonInterpreter,
@@ -111,10 +111,10 @@ fun Project.buildRobotCodeCommandLine(
111111
*(if (format.isNotEmpty()) arrayOf("--format", format) else arrayOf()),
112112
*(if (noColor) arrayOf("--no-color") else arrayOf()),
113113
*(if (noPager) arrayOf("--no-pager") else arrayOf()),
114-
*profiles.flatMap { listOf("--profile", it) }.toTypedArray(),
114+
*profiles.flatMap { listOf("-p", it) }.toTypedArray(),
115115
*extraArgs,
116116
*args
117117
).withWorkDirectory(this.basePath).withCharset(Charsets.UTF_8)
118-
118+
119119
return commandLine
120120
}

intellij-client/src/main/kotlin/dev/robotcode/robotcode4ij/execution/RobotCodeRunProfileState.kt

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -46,56 +46,56 @@ import kotlin.uuid.Uuid
4646

4747
class RobotCodeRunProfileState(private val config: RobotCodeRunConfiguration, environment: ExecutionEnvironment) :
4848
CommandLineState(environment), ProcessListener {
49-
49+
5050
companion object {
5151
const val DEBUGGER_DEFAULT_PORT = 6612
5252
val DEBUG_PORT: Key<Int> = Key.create("ROBOTCODE_DEBUG_PORT")
5353
const val TESTFRAMEWORK_NAME = "RobotCode"
5454
}
55-
55+
5656
val debugClient = RobotCodeDebugProtocolClient()
5757
lateinit var debugServer: IDebugProtocolServer
5858
var isInitialized = false
5959
private set
6060
var isConfigurationDone = false
6161
private set
62-
62+
6363
val afterInitialize = Signal<Unit>()
6464
val afterConfigurationDone = Signal<Unit>()
65-
66-
65+
66+
6767
init {
6868
debugClient.onTerminated.adviseEternal {
6969
if (socket.isConnected) socket.close()
7070
}
7171
}
72-
72+
7373
private lateinit var socket: Socket
74-
74+
7575
override fun startProcess(): ProcessHandler {
7676
val project = environment.project
7777
val profile =
7878
environment.runProfile as? RobotCodeRunConfiguration ?: throw CantRunException("Invalid run configuration")
79-
79+
8080
// TODO: Add support for configurable paths
81-
val defaultPaths = arrayOf("--default-path", ".")
82-
81+
val defaultPaths = arrayOf("-dp", ".")
82+
8383
val debug = environment.runner is RobotCodeDebugProgramRunner
84-
84+
8585
val included = mutableListOf<String>()
8686
for (test in profile.includedTestItems) {
87-
included.add("--by-longname")
87+
included.add("--bl")
8888
included.add(test.longname)
8989
}
90-
90+
9191
val connection = mutableListOf<String>()
92-
92+
9393
val port = findFreePort(DEBUGGER_DEFAULT_PORT)
9494
if (port != DEBUGGER_DEFAULT_PORT) {
9595
included.add("--tcp")
9696
included.add(port.toString())
9797
}
98-
98+
9999
val commandLine = project.buildRobotCodeCommandLine(
100100
arrayOf(
101101
*defaultPaths,
@@ -104,30 +104,30 @@ class RobotCodeRunProfileState(private val config: RobotCodeRunConfiguration, en
104104
*(if (!debug) arrayOf("--no-debug") else arrayOf()),
105105
*(included.toTypedArray())
106106
), noColor = false // ,extraArgs = arrayOf("-v", "--log", "--log-level", "TRACE")
107-
107+
108108
)
109-
109+
110110
val handler = KillableColoredProcessHandler(commandLine) // handler.setHasPty(true)
111111
handler.putUserData(DEBUG_PORT, port)
112112
ProcessTerminatedListener.attach(handler)
113113
handler.addProcessListener(this)
114-
114+
115115
// RunContentManager.getInstance(project).showRunContent(environment.executor, handler)
116-
116+
117117
return handler
118118
}
119-
119+
120120
override fun execute(executor: Executor, runner: ProgramRunner<*>): ExecutionResult {
121121
val processHandler = startProcess()
122122
val (console, properties) = createAndAttachConsoleInEDT(processHandler, executor)
123-
123+
124124
val result = DefaultExecutionResult(console, processHandler, *createActions(console, processHandler))
125125
result.setRestartActions(properties.createRerunFailedTestsAction(console))
126-
126+
127127
return result
128128
}
129-
130-
129+
130+
131131
private fun createAndAttachConsoleInEDT(
132132
processHandler: ProcessHandler, executor: Executor
133133
): Pair<BaseTestsOutputConsoleView, SMTRunnerConsoleProperties> {
@@ -136,34 +136,34 @@ class RobotCodeRunProfileState(private val config: RobotCodeRunConfiguration, en
136136
ApplicationManager.getApplication().invokeAndWait {
137137
try {
138138
val propertiesProvider = config as SMRunnerConsolePropertiesProvider
139-
139+
140140
val consoleProperties = propertiesProvider.createTestConsoleProperties(executor)
141141
if (consoleProperties is RobotRunnerConsoleProperties) {
142142
consoleProperties.state = this
143143
}
144-
144+
145145
var splitterPropertyName = SMTestRunnerConnectionUtil.getSplitterPropertyName(TESTFRAMEWORK_NAME)
146146
var consoleView = RobotCodeRunnerConsoleView(consoleProperties, splitterPropertyName)
147147
SMTestRunnerConnectionUtil.initConsoleView(consoleView, TESTFRAMEWORK_NAME)
148148
consoleView.attachToProcess(processHandler)
149149
consoleRef.set(consoleView)
150150
// consoleRef.set(createAndAttachConsole("RobotCode", processHandler, consoleProperties))
151151
propertiesRef.set(consoleProperties)
152-
152+
153153
} catch (e: ExecutionException) {
154154
consoleRef.set(e)
155155
} catch (e: RuntimeException) {
156156
consoleRef.set(e)
157157
}
158158
}
159-
159+
160160
if (consoleRef.get() is ExecutionException) {
161161
throw consoleRef.get() as ExecutionException
162162
} else if (consoleRef.get() is RuntimeException) throw consoleRef.get() as RuntimeException
163-
163+
164164
return Pair(consoleRef.get() as BaseTestsOutputConsoleView, propertiesRef.get() as SMTRunnerConsoleProperties)
165165
}
166-
166+
167167
private suspend fun tryConnectToServerWithTimeout(
168168
host: String, port: Int, timeoutMillis: Long, retryIntervalMillis: Long
169169
): Socket? {
@@ -180,62 +180,62 @@ class RobotCodeRunProfileState(private val config: RobotCodeRunConfiguration, en
180180
} catch (_: Exception) {
181181
}
182182
delay(retryIntervalMillis)
183-
183+
184184
}
185185
socket
186186
}
187187
} catch (e: TimeoutCancellationException) {
188188
null
189189
}
190190
}
191-
191+
192192
@OptIn(ExperimentalUuidApi::class) override fun startNotified(event: ProcessEvent) {
193193
runBlocking(Dispatchers.IO) {
194-
194+
195195
var port = event.processHandler.getUserData(DEBUG_PORT) ?: throw CantRunException("No debug port found.")
196-
196+
197197
socket = tryConnectToServerWithTimeout("127.0.0.1", port, 10000, retryIntervalMillis = 100)
198198
?: throw CantRunException("Unable to establish connection to debug server.")
199-
199+
200200
val launcher: Launcher<IDebugProtocolServer> =
201201
DSPLauncher.createClientLauncher(debugClient, socket.getInputStream(), socket.getOutputStream())
202-
202+
203203
launcher.startListening()
204-
204+
205205
debugServer = launcher.remoteProxy
206-
206+
207207
val arguments = InitializeRequestArguments().apply {
208208
clientID = Uuid.random().toString()
209209
adapterID = Uuid.random().toString()
210-
210+
211211
clientName = "RobotCode4IJ"
212212
locale = "en_US"
213-
213+
214214
supportsRunInTerminalRequest = false
215215
supportsStartDebuggingRequest = false
216216
pathFormat = "path"
217217
supportsVariableType = true
218218
supportsVariablePaging = false
219-
219+
220220
linesStartAt1 = true
221221
columnsStartAt1 = true
222222
}
223-
223+
224224
val response = debugServer.initialize(arguments).await()
225225
isInitialized = true
226-
226+
227227
afterInitialize.fire(Unit)
228-
228+
229229
if (response.supportsConfigurationDoneRequest) {
230230
debugServer.configurationDone(ConfigurationDoneArguments()).await()
231231
isConfigurationDone = true
232232
}
233-
233+
234234
afterConfigurationDone.fire(Unit)
235235
debugServer.attach(emptyMap<String, Object>())
236236
}
237237
}
238-
238+
239239
override fun processTerminated(event: ProcessEvent) {
240240
if (socket.isConnected) socket.close()
241241
}

0 commit comments

Comments
 (0)