From 0e5dae793da6a1c8773247799a3011199b78c9b0 Mon Sep 17 00:00:00 2001 From: KANAjetzt <41547570+KANAjetzt@users.noreply.github.com> Date: Fri, 24 Jan 2025 11:08:58 +0100 Subject: [PATCH] fix: :bug: match any character between func name and `(` (#495) * fix: :bug: match any character between func name and `(` * refactor: :recycle: use non-capturing group * fix: :bug: match white space before `(` * fix: Ignore comments * refactor: :fire: removed redundant whitespace token moved the regex string to the top and added a description * fix: :bug: match space before `(` and word boundary for the method name * refactor: :recycle: removed `(? Match the word 'func' and one or more whitespace characters +## \\b%s\\b -> the function name +## (?:.*\\n*)*?\\s*\\( -> Match any character between zero and unlimited times, but be lazy +## and only do this until a '(' is found. +const REGEX_MATCH_FUNC_WITH_WHITESPACE := "\\bfunc\\b\\s+\\b%s\\b(?:.*\\n*)*?\\s*\\(" ## finds function names used as setters and getters (excluding inline definitions) ## group 2 and 4 contain the xetter names @@ -338,7 +343,7 @@ func match_method_body(method_name: String, func_body_start_index: int, text: St static func match_func_with_whitespace(method_name: String, text: String, offset := 0) -> RegExMatch: # Dynamically create the new regex for that specific name - var func_with_whitespace := RegEx.create_from_string("func\\s+%s[\\\\\\s]*\\(" % method_name) + var func_with_whitespace := RegEx.create_from_string(REGEX_MATCH_FUNC_WITH_WHITESPACE % method_name) return func_with_whitespace.search(text, offset)