parse static method

TtsrScope parse(
  1. List<String>? tokens, {
  2. required String ruleName,
  3. required List<String> warnings,
})

Parses scope tokens (omp's buildScope, without path globs).

Unrecognized tokens are collected into warnings and skipped. When tokens is null or every token is empty, the defaultScope applies.

Implementation

static TtsrScope parse(
  List<String>? tokens, {
  required String ruleName,
  required List<String> warnings,
}) {
  if (tokens == null || tokens.every((token) => token.trim().isEmpty)) {
    return defaultScope;
  }
  final flags = _ScopeFlags();
  for (final raw in tokens) {
    _applyScopeToken(flags, raw, ruleName: ruleName, warnings: warnings);
  }
  return TtsrScope(
    allowText: flags.allowText,
    allowThinking: flags.allowThinking,
    allowAnyTool: flags.allowAnyTool,
    toolNames: flags.toolNames,
  );
}