findSimplePrintInvocation method
ExpressionStatement?
findSimplePrintInvocation()
Returns the ExpressionStatement associated with this if this points
to the identifier for a simple print, and null otherwise.
Implementation
ExpressionStatement? findSimplePrintInvocation() {
final parent = this.parent;
final grandparent = parent?.parent;
if (this case SimpleIdentifier(:final element)) {
if (element is TopLevelFunctionElement &&
element.name == 'print' &&
element.library.isDartCore &&
parent is MethodInvocation &&
grandparent is ExpressionStatement) {
return grandparent;
}
}
return null;
}