void _processSetInstruction()

in packages/code_excerpt_updater/lib/src/code_excerpt_updater.dart [150:181]


  void _processSetInstruction(InstrInfo info) {
    void _checkForMoreThan1ArgErr() {
      if (info.args.keys.length > 1) {
        _reporter.error(
          'set instruction should have at most one argument: '
          '${info.instruction}',
        );
      }
    }

    if (info.args.containsKey('path-base')) {
      _getter.pathBase = info.args['path-base'] ?? '';
      _checkForMoreThan1ArgErr();
    } else if (info.args.containsKey('replace')) {
      _fileGlobalCodeTransformer = info.args['replace']?.isNotEmpty ?? false
          ? _replace.codeTransformer(info.args['replace'])
          : null;
      _checkForMoreThan1ArgErr();
    } else if (info.args.containsKey('plaster')) {
      filePlasterTemplate = info.args['plaster'];
      _checkForMoreThan1ArgErr();
    } else if (info.args.keys.isEmpty ||
        info.args.keys.length == 1 && info.args['class'] != null) {
      // Ignore empty instruction, other tools process them.
    } else if (info.args.keys.length == 1 && info.args.containsKey('title')) {
      // Only asking for a title is ok.
    } else {
      _reporter
          .warn('instruction ignored: unrecognized set instruction argument: '
              '${info.instruction}');
    }
  }