extractReference method

List<String> extractReference(
  1. String stringCode
)

Extracts references (classes, enums, mixins, typedefs) from the given stringCode.

Implementation

List<String> extractReference(String stringCode) {
  final List<String> elements = [];

  final regex = RegExp(
    r'\b(class|enum|mixin|typedef)\b\s+(\w+)',
    caseSensitive: true,
  );

  final matches = regex.allMatches(stringCode);

  for (final match in matches) {
    final elementName = match.group(2);
    if (elementName != null) {
      elements.add(elementName);
    }
  }
  return elements;
}