Update: 2026-06-13 00:57:17
This commit is contained in:
44
list_methods.py
Normal file
44
list_methods.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import re
|
||||
|
||||
def parse_class_structure(filepath):
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Simple regex to match method declarations in Dart:
|
||||
# e.g., void methodName(...) or Future<type> methodName(...) or type methodName(...)
|
||||
# Let's find any sequence of word characters, optionally preceded by types, followed by open parentheses
|
||||
# Let's filter methods that are inside the class
|
||||
# Method pattern: (type|void)? methodName(args) { or =>
|
||||
# Better approach: match lines that look like method declarations:
|
||||
# e.g., " ReturnType methodName("
|
||||
# Let's find all methods inside the class by matching line patterns
|
||||
lines = content.split('\n')
|
||||
methods = []
|
||||
variables = []
|
||||
|
||||
# Simple scanner for declarations
|
||||
for i, line in enumerate(lines):
|
||||
line_stripped = line.strip()
|
||||
# Skip comments, annotations, imports
|
||||
if line_stripped.startswith('//') or line_stripped.startswith('/*') or line_stripped.startswith('*') or line_stripped.startswith('@'):
|
||||
continue
|
||||
|
||||
# Match variables: e.g., final type name = ... or type name;
|
||||
# Match methods: e.g., void name(...) or Future<type> name(...) or name(...) {
|
||||
# Method declaration regex:
|
||||
# Match methods with curly braces or arrow syntax on the same line or next
|
||||
method_match = re.match(r'^(?:[a-zA-Z0-9_<>\?]+)?\s*([a-zA-Z0-9_]+)\s*\(([^)]*)\)\s*(?:async)?\s*[\{{=]', line_stripped)
|
||||
if method_match:
|
||||
methods.append((i+1, method_match.group(1), method_match.group(2).strip()))
|
||||
elif line_stripped.startswith('Rx') or line_stripped.startswith('final ') or line_stripped.startswith('bool ') or line_stripped.startswith('String ') or line_stripped.startswith('int ') or line_stripped.startswith('double ') or line_stripped.startswith('Map '):
|
||||
variables.append((i+1, line_stripped))
|
||||
|
||||
print(f"--- Methods in {filepath} ---")
|
||||
for line_num, name, args in methods:
|
||||
print(f"Line {line_num:4d}: {name}({args})")
|
||||
|
||||
print(f"\n--- Key Variables in {filepath} ---")
|
||||
for line_num, var in variables[:30]:
|
||||
print(f"Line {line_num:4d}: {var}")
|
||||
|
||||
parse_class_structure('siro_rider/lib/controller/home/map/ride_lifecycle_controller.dart')
|
||||
Reference in New Issue
Block a user