parseFile static method

List<EndpointMethod> parseFile(
  1. String filePath
)

Parse all methods from an endpoint file

Implementation

static List<EndpointMethod> parseFile(String filePath) {
  final file = File(filePath);
  if (!file.existsSync()) return [];

  final content = file.readAsLinesSync();
  final methods = <EndpointMethod>[];

  for (var i = 0; i < content.length; i++) {
    final line = content[i];

    // Skip comments and empty lines
    if (line.trim().isEmpty || line.trim().startsWith('//')) {
      continue;
    }

    final match = _methodPattern.firstMatch(line);
    if (match != null) {
      final returnType = match.group(1)!;
      final methodName = match.group(2)!;
      final paramsStr = match.group(3)!;

      methods.add(EndpointMethod(
        name: methodName,
        returnType: returnType,
        parameters: _parseParameters(paramsStr),
        filePath: filePath,
        lineNumber: i + 1,
      ));
    }
  }

  return methods;
}