notationComponentType function

String? notationComponentType(
  1. String text
)

The type a component's notation text declares (component Name "…", its first line that is not blank or a comment); null when it is not one.

Implementation

String? notationComponentType(String text) {
  for (final raw in const LineSplitter().convert(text)) {
    final line = raw.trim();
    if (line.isEmpty || line.startsWith('//') || line.startsWith('#')) continue;
    return RegExp(r'^component\s+([A-Za-z_][A-Za-z0-9_]*)').firstMatch(line)?[1];
  }
  return null;
}