@@ -9,6 +9,10 @@ import com.intellij.openapi.vfs.VirtualFile
9
9
class FileFuncInsCommand (val myProject : Project , val prop : String ) : InsCommand {
10
10
override fun execute (): String? {
11
11
val (functionName, args) = parseRegex(prop)
12
+ ? : return """ <DevInsError>: file-func is not in the format @file-func:<functionName>(<arg1>, <arg2>, ...)
13
+ |Example: @file-func:regex(".*\.kt")
14
+ """ .trimMargin()
15
+
12
16
val fileFunction = FileFunc .fromString(functionName) ? : return " <DevInsError>: Unknown function: $functionName "
13
17
when (fileFunction) {
14
18
FileFunc .Regex -> {
@@ -46,7 +50,7 @@ class FileFuncInsCommand(val myProject: Project, val prop: String) : InsCommand
46
50
* @return The function name and the list of arguments as a Pair object.
47
51
* @throws IllegalArgumentException if the property string has invalid regex pattern.
48
52
*/
49
- fun parseRegex (prop : String ): Pair <String , List <String >> {
53
+ fun parseRegex (prop : String ): Pair <String , List <String >>? {
50
54
val regexPattern = Regex (""" (\w+)\(([^)]+)\)""" )
51
55
val matchResult = regexPattern.find(prop)
52
56
@@ -55,6 +59,6 @@ fun parseRegex(prop: String): Pair<String, List<String>> {
55
59
val args = matchResult.groupValues[2 ].split(' ,' ).map { it.trim() }
56
60
return Pair (functionName, args)
57
61
} else {
58
- throw IllegalArgumentException ( " Invalid regex pattern: $prop " )
62
+ return null
59
63
}
60
64
}
0 commit comments