added fix for method declaration edgecase

This commit is contained in:
Jonas_Jones 2025-03-04 20:42:18 +01:00
parent 21f120ce94
commit 254a7a7dff

View file

@ -96,7 +96,10 @@ def is_line_method_declaration(line:str, class_type:str) -> bool:
:param line: The line to check.
:return: True if the line is a method declaration, False otherwise.
"""
method_pattern = re.compile(r'^\s*(public|private|protected|\s)*\s*(static|final|\s)*\s*(\w[\w\d]*)\s+(\w[\w\d]*)\s*\(.*\)\s*{')
# Sometimes these slip in as method declarations
if "else if" in line:
return False
method_pattern = re.compile(r'^\s*(public|private|protected|\s)*\s*(static|final|\s)*\s*(\w[\w\d]*)\s+(\w[\w\d]*)\s*\(.*\)\s*(?:throws\s+\w[\w\d]*)?\s*{')
if class_type == "interface":
method_pattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*\s+[a-zA-Z_][a-zA-Z0-9_]*\(\)\s*;$')