parseTag function

ParsedTag parseTag(
  1. String tag
)

Splits a tag into typename, identity and collection-ness.

Implementation

ParsedTag parseTag(String tag) {
  final bracket = tag.indexOf('[]');

  if (bracket >= 0) {
    return ParsedTag(
      raw: tag,
      type: tag.substring(0, bracket),
      id: null,
      collection: true,
      scope: tag.substring(bracket + 2),
    );
  }

  final colon = tag.indexOf(':');

  if (colon > 0) {
    return ParsedTag(
      raw: tag,
      type: tag.substring(0, colon),
      id: tag.substring(colon + 1),
      collection: false,
      scope: '',
    );
  }

  return ParsedTag(raw: tag, type: tag, id: null, collection: false, scope: '');
}