Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 match any character between func name and ( #495

Open
wants to merge 8 commits into
base: 4.x
Choose a base branch
from

Conversation

KANAjetzt
Copy link
Member

@KANAjetzt KANAjetzt commented Dec 22, 2024

  • Changed func\\s+%s[\\\\\\s]*\\( to \\bfunc\\b\\s+\\b%s\\b(?:.*\\n*)*?\\s*\\(
    • Comments and non top level funcs are ignored with is_top_level_func() and not handled by this regex
  • Moved the regex to the top with the other regexes
  • Added a description comment
    ## \\bfunc\\b\\s+		->	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.

Tested with #476 and a smaller game via export plugin on 4.3.

closes #494

@KANAjetzt KANAjetzt added bug Something isn't working 4.x labels Dec 22, 2024
@KANAjetzt KANAjetzt added this to the 4.x - 7.0.0 milestone Dec 22, 2024
@KANAjetzt KANAjetzt requested a review from Qubus0 December 22, 2024 09:13
@KANAjetzt KANAjetzt self-assigned this Dec 22, 2024
@KANAjetzt KANAjetzt force-pushed the fix_match_func branch 2 times, most recently from b721387 to c1e7e92 Compare December 25, 2024 10:40
@Qubus0
Copy link
Collaborator

Qubus0 commented Jan 9, 2025

image

thought of another cursed but valid gdscript case

@Qubus0
Copy link
Collaborator

Qubus0 commented Jan 9, 2025

looks like we can also simplify (?:.*\n*)*? to just match everything except ( -> [^(]
\bfunc\b[^(]*?\btest\b[^(]*?\s*\( -> gds \\bfunc\\b[^(]*?\\btest\\b[^(]*?\\s*\\(

image

KANAjetzt and others added 8 commits January 9, 2025 14:30
moved the regex string to the top and added a description
and word boundary for the method name
It only handled one specific case, `#func`. Something like `# ` was still matched. To avoid giving a false impression, I removed it, and this case is now also handled by `is_top_level_func()`.
@KANAjetzt
Copy link
Member Author

"Vanilla" Source Code
image

"\\bfunc\\b\\s+\\b%s\\b(?:.*\\n*)*?\\s*\\("
image

\\bfunc\\b[^(]*?\\btest\\b[^(]*?\\s*\\(
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x bug Something isn't working
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants