declaresMain function

bool declaresMain(
  1. List<String> lines
)

Whether lines declare a top-level main — the mark of an entry point.

Matched at column 0 on lines that begin in executable code, so a main( inside a comment, a string, or a class body does not count. void main(), Future<void> main() async, dynamic main(List<String> args) and a bare main() all do.

Implementation

bool declaresMain(List<String> lines) {
  final scanner = _SourceScanner();
  for (final line in lines) {
    if (scanner.startsInCode && _mainDeclaration.hasMatch(line)) return true;
    scanner.consume(line);
  }
  return false;
}