@@ -41,18 +41,20 @@ import 'package:analyzer/src/string_source.dart';
4141/// produced because of syntactic errors in the file an `ArgumentError` will be
4242/// thrown. If the parameter is `false` , then the caller can check the result
4343/// to see whether there are any errors.
44- ParseStringResult parseFile (
45- {required String path,
46- ResourceProvider ? resourceProvider,
47- required FeatureSet featureSet,
48- bool throwIfDiagnostics = true }) {
44+ ParseStringResult parseFile ({
45+ required String path,
46+ ResourceProvider ? resourceProvider,
47+ required FeatureSet featureSet,
48+ bool throwIfDiagnostics = true ,
49+ }) {
4950 resourceProvider ?? = PhysicalResourceProvider .INSTANCE ;
5051 var content = (resourceProvider.getResource (path) as File ).readAsStringSync ();
5152 return parseString (
52- content: content,
53- path: path,
54- featureSet: featureSet,
55- throwIfDiagnostics: throwIfDiagnostics);
53+ content: content,
54+ path: path,
55+ featureSet: featureSet,
56+ throwIfDiagnostics: throwIfDiagnostics,
57+ );
5658}
5759
5860/// Returns the result of parsing the given [content] as a compilation unit.
@@ -72,24 +74,25 @@ ParseStringResult parseFile(
7274/// in the presence of parse errors). Clients interested in details about parse
7375/// errors should pass `false` and check `result.errors` to determine what parse
7476/// errors, if any, have occurred.
75- ParseStringResult parseString (
76- {required String content,
77- FeatureSet ? featureSet,
78- String ? path,
79- bool throwIfDiagnostics = true }) {
77+ ParseStringResult parseString ({
78+ required String content,
79+ FeatureSet ? featureSet,
80+ String ? path,
81+ bool throwIfDiagnostics = true ,
82+ }) {
8083 featureSet ?? = FeatureSet .latestLanguageVersion ();
8184 var source = StringSource (content, path ?? '' );
8285 var reader = CharSequenceReader (content);
8386 var errorCollector = RecordingErrorListener ();
84- var scanner = Scanner (source, reader, errorCollector)
85- ..configureFeatures (
86- featureSetForOverriding: featureSet,
87- featureSet: featureSet,
88- );
87+ var scanner = Scanner (source, reader, errorCollector)..configureFeatures (
88+ featureSetForOverriding: featureSet,
89+ featureSet: featureSet,
90+ );
8991 var token = scanner.tokenize ();
9092 var languageVersion = LibraryLanguageVersion (
91- package: ExperimentStatus .currentVersion,
92- override: scanner.overrideVersion);
93+ package: ExperimentStatus .currentVersion,
94+ override: scanner.overrideVersion,
95+ );
9396 var lineInfo = LineInfo (scanner.lineStarts);
9497 var parser = Parser (
9598 source,
@@ -99,14 +102,19 @@ ParseStringResult parseString(
99102 lineInfo: lineInfo,
100103 );
101104 var unit = parser.parseCompilationUnit (token);
102- ParseStringResult result =
103- ParseStringResultImpl (content, unit, errorCollector.errors);
105+ ParseStringResult result = ParseStringResultImpl (
106+ content,
107+ unit,
108+ errorCollector.errors,
109+ );
104110 if (throwIfDiagnostics && result.errors.isNotEmpty) {
105111 var buffer = StringBuffer ();
106112 for (var error in result.errors) {
107113 var location = lineInfo.getLocation (error.offset);
108- buffer.writeln (' ${error .errorCode .name }: ${error .message } - '
109- '${location .lineNumber }:${location .columnNumber }' );
114+ buffer.writeln (
115+ ' ${error .errorCode .name }: ${error .message } - '
116+ '${location .lineNumber }:${location .columnNumber }' ,
117+ );
110118 }
111119 throw ArgumentError ('Content produced diagnostics when parsed:\n $buffer ' );
112120 }
@@ -120,19 +128,25 @@ ParseStringResult parseString(
120128/// Note that if more than one file is going to be resolved then this function
121129/// is inefficient. Clients should instead use [AnalysisContextCollection] to
122130/// create one or more contexts and use those contexts to resolve the files.
123- Future <SomeResolvedUnitResult > resolveFile2 (
124- {required String path, ResourceProvider ? resourceProvider}) async {
125- AnalysisContext context =
126- _createAnalysisContext (path: path, resourceProvider: resourceProvider);
131+ Future <SomeResolvedUnitResult > resolveFile2 ({
132+ required String path,
133+ ResourceProvider ? resourceProvider,
134+ }) async {
135+ AnalysisContext context = _createAnalysisContext (
136+ path: path,
137+ resourceProvider: resourceProvider,
138+ );
127139 return await context.currentSession.getResolvedUnit (path);
128140}
129141
130142/// Return a newly create analysis context in which the file at the given [path]
131143/// can be analyzed.
132144///
133145/// If a [resourceProvider] is given, it will be used to access the file system.
134- AnalysisContext _createAnalysisContext (
135- {required String path, ResourceProvider ? resourceProvider}) {
146+ AnalysisContext _createAnalysisContext ({
147+ required String path,
148+ ResourceProvider ? resourceProvider,
149+ }) {
136150 AnalysisContextCollection collection = AnalysisContextCollection (
137151 includedPaths: < String > [path],
138152 resourceProvider: resourceProvider ?? PhysicalResourceProvider .INSTANCE ,
0 commit comments