added proper interface support
This commit is contained in:
parent
c977f5084c
commit
21f120ce94
1 changed files with 7 additions and 2 deletions
|
@ -89,7 +89,7 @@ def get_field_visibility(line):
|
|||
return None # Return None if it's not a field declaration
|
||||
|
||||
|
||||
def is_line_method_declaration(line:str) -> bool:
|
||||
def is_line_method_declaration(line:str, class_type:str) -> bool:
|
||||
"""
|
||||
Check if a line is a method declaration.
|
||||
|
||||
|
@ -97,6 +97,10 @@ def is_line_method_declaration(line:str) -> bool:
|
|||
: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*{')
|
||||
|
||||
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*;$')
|
||||
|
||||
match = method_pattern.match(line.strip())
|
||||
return match is not None
|
||||
|
||||
|
@ -305,6 +309,7 @@ def class_to_puml(filename:str, base_package_slug:str) -> JavaClass:
|
|||
class_type = "enum"
|
||||
elif " interface " in javaline:
|
||||
class_type = "interface"
|
||||
reached_class = True
|
||||
elif " class " in javaline:
|
||||
reached_class = True
|
||||
elif is_line_field_declaration(javaline):
|
||||
|
@ -317,7 +322,7 @@ def class_to_puml(filename:str, base_package_slug:str) -> JavaClass:
|
|||
if class_setter:
|
||||
class_methods[f"set{field_name.capitalize()}"] = visibility
|
||||
|
||||
elif is_line_method_declaration(javaline):
|
||||
elif is_line_method_declaration(javaline, class_type=class_type):
|
||||
visibility = get_method_visibility(javaline)
|
||||
method_name = get_method_name_from_line(javaline)
|
||||
if method_name != class_name:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue