parse method

CompilationUnit parse(
  1. Asset src, {
  2. bool allowSyntaxErrors = false,
})

Parses a Dart asset into a compilation unit, with caching.

If the asset has been previously parsed, returns the cached result. Otherwise, parses the content and caches the result.

@param src The asset to parse @param allowSyntaxErrors Whether to continue parsing even with syntax errors @return The parsed compilation unit

Implementation

CompilationUnit parse(Asset src, {bool allowSyntaxErrors = false}) {
  return parseContent(
    src.readAsStringSync,
    key: src.id,
    throwIfDiagnostics: !allowSyntaxErrors,
  );
}