fromCommand static method
DartDeclaration
fromCommand(
- List<
Command> commandList, - DartDeclaration self, {
- required String key,
- dynamic testSubject,
- dynamic value,
Implementation
static DartDeclaration fromCommand(
List<Command> commandList,
DartDeclaration self, {
required String key,
dynamic testSubject,
dynamic value,
}) {
var newSelf = self;
for (var command in commandList) {
if (testSubject is String) {
if ((command.prefix != null && testSubject.startsWith(command.prefix!))) {
final commandPrefixMatch = command.prefix != null &&
command.command != null &&
testSubject.startsWith(command.prefix! + command.command!);
final commandMatch = command.command == null || testSubject.startsWith(command.command!);
if (commandPrefixMatch || commandMatch) {
final notprefixnull = command.notprefix == null;
final notprefix = !notprefixnull && !testSubject.startsWith(command.notprefix!);
if (notprefix || notprefixnull) {
newSelf = command.callback(self, testSubject, key: key, value: value);
break;
}
}
}
}
if (testSubject.runtimeType == command.type) {
newSelf = command.callback(self, testSubject, key: key, value: value);
break;
}
}
return newSelf;
}