@@ -21,7 +21,6 @@ import com.intellij.openapi.diagnostic.logger
21
21
import com.intellij.openapi.editor.Editor
22
22
import com.intellij.openapi.project.Project
23
23
import com.intellij.openapi.project.guessProjectDir
24
- import com.intellij.openapi.util.NlsSafe
25
24
import com.intellij.psi.PsiElement
26
25
import com.intellij.psi.util.elementType
27
26
import kotlinx.coroutines.Dispatchers
@@ -59,6 +58,7 @@ class DevInsCompiler(
59
58
60
59
output.append(text)
61
60
}
61
+
62
62
DevInTypes .USED -> processUsed(it as DevInUsed )
63
63
DevInTypes .COMMENTS -> {
64
64
if (text.startsWith(" [flow]:" )) {
@@ -74,6 +74,7 @@ class DevInsCompiler(
74
74
}
75
75
}
76
76
}
77
+
77
78
else -> {
78
79
output.append(text)
79
80
logger.warn(" Unknown element type: ${it.elementType} " )
@@ -129,7 +130,7 @@ class DevInsCompiler(
129
130
return
130
131
}
131
132
132
- val propText = runReadAction { propElement?.text } ? : " "
133
+ val propText = runReadAction { propElement?.text } ? : " "
133
134
processingCommand(command, propText, used, fallbackText = usedText, originCmdName)
134
135
}
135
136
@@ -176,13 +177,13 @@ class DevInsCompiler(
176
177
prop : String ,
177
178
used : DevInUsed ,
178
179
fallbackText : String ,
179
- originCmdName : @NlsSafe String
180
+ originCmdName : String
180
181
) {
181
182
val command: InsCommand = toInsCommand(commandNode, prop, used, originCmdName)
182
183
183
184
val execResult = command.execute()
184
185
185
- val isSucceed = execResult?.contains(" $ DEVINS_ERROR" ) == false
186
+ val isSucceed = execResult?.contains(DEVINS_ERROR ) == false
186
187
val result = if (isSucceed) {
187
188
val hasReadCodeBlock = commandNode in listOf (
188
189
BuiltinCommand .WRITE ,
@@ -206,7 +207,12 @@ class DevInsCompiler(
206
207
output.append(result)
207
208
}
208
209
209
- suspend fun toInsCommand (commandNode : BuiltinCommand , prop : String , used : DevInUsed , originCmdName : String ): InsCommand = when (commandNode) {
210
+ suspend fun toInsCommand (
211
+ commandNode : BuiltinCommand ,
212
+ prop : String ,
213
+ used : DevInUsed ,
214
+ originCmdName : String
215
+ ): InsCommand = when (commandNode) {
210
216
BuiltinCommand .FILE -> {
211
217
FileInsCommand (myProject, prop)
212
218
}
@@ -362,12 +368,12 @@ class DevInsCompiler(
362
368
363
369
val result = try {
364
370
val cmd = runReadAction { used.text.removePrefix(" /" ) }
365
- provider.execute(myProject!! , prop, args, emptyMap(), cmd).toString()
371
+ provider.execute(myProject, prop, args, emptyMap(), cmd).toString()
366
372
} catch (e: Exception ) {
367
373
logger<DevInsCompiler >().warn(e)
368
374
val text = runReadAction { used.text }
369
375
val error = " Error executing toolchain function: $text + $prop "
370
- AutoDevNotifications .notify(myProject!! , error)
376
+ AutoDevNotifications .notify(myProject, error)
371
377
error
372
378
}
373
379
@@ -414,7 +420,7 @@ class DevInsCompiler(
414
420
companion object {
415
421
suspend fun transpileCommand (file : DevInFile ): List <BuiltinCommand > {
416
422
val children = runReadAction { file.children }
417
- val result = children.mapNotNull { it ->
423
+ return children.mapNotNull { it ->
418
424
when (it.elementType) {
419
425
DevInTypes .USED -> {
420
426
val used = it as DevInUsed
@@ -431,14 +437,14 @@ class DevInsCompiler(
431
437
432
438
command
433
439
}
440
+
434
441
else -> null
435
442
}
436
443
}
444
+
437
445
else -> null
438
446
}
439
447
}
440
-
441
- return result
442
448
}
443
449
}
444
450
}
0 commit comments