parseCompilationUnit function

  1. @Deprecated('Please use parseString instead')
CompilationUnit parseCompilationUnit (
  1. String contents,
  2. {String name,
  3. bool suppressErrors: false,
  4. bool parseFunctionBodies: true,
  5. FeatureSet featureSet}
)

Parses a string of Dart code into an AST.

If name is passed, it's used in error messages as the name of the code being parsed.

Throws an AnalyzerErrorGroup if any errors occurred, unless suppressErrors is true, in which case any errors are discarded.

If parseFunctionBodies is false then only function signatures will be parsed. (Currently broken; function bodies are always parsed).

Deprecated - please use the parseString function (from package:analyzer/dart/analysis/utilities.dart) instead.

Note that parseString does not support the parseFunctionBodies option; callers that don't require function bodies should simply ignore them.

Implementation

@Deprecated('Please use parseString instead')
CompilationUnit parseCompilationUnit(String contents,
    {String name,
    bool suppressErrors = false,
    bool parseFunctionBodies = true,
    FeatureSet featureSet}) {
  // TODO(paulberry): make featureSet a required parameter
  featureSet ??= FeatureSet.fromEnableFlags([]);
  Source source = StringSource(contents, name);
  return _parseSource(contents, source, featureSet,
      suppressErrors: suppressErrors, parseFunctionBodies: parseFunctionBodies);
}