Skip to content

Commit 0d03fb8

Browse files
scheglovCommit Queue
authored andcommitted
Make more methods synchronous.
Change-Id: I116c3baea380208e10bbbe3de0b1d6258c2a896b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407503 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 448f0d4 commit 0d03fb8

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ class AnalysisDriver {
11681168

11691169
if (_resolveForCompletionRequests.removeLastOrNull() case var request?) {
11701170
try {
1171-
var result = await _resolveForCompletion(request);
1171+
var result = _resolveForCompletion(request);
11721172
request.completer.complete(result);
11731173
} catch (exception, stackTrace) {
11741174
_reportException(request.path, exception, stackTrace, null);
@@ -1180,31 +1180,31 @@ class AnalysisDriver {
11801180

11811181
// Analyze a requested file.
11821182
if (_requestedFiles.firstKey case var path?) {
1183-
await _analyzeFile(path);
1183+
_analyzeFile(path);
11841184
return;
11851185
}
11861186

11871187
// Analyze a requested library.
11881188
if (_requestedLibraries.firstKey case var path?) {
1189-
await _getResolvedLibrary(path);
1189+
_getResolvedLibrary(path);
11901190
return;
11911191
}
11921192

11931193
// Process an error request.
11941194
if (_errorsRequestedFiles.firstKey case var path?) {
1195-
await _getErrors(path);
1195+
_getErrors(path);
11961196
return;
11971197
}
11981198

11991199
// Process an index request.
12001200
if (_indexRequestedFiles.firstKey case var path?) {
1201-
await _getIndex(path);
1201+
_getIndex(path);
12021202
return;
12031203
}
12041204

12051205
// Process a unit element request.
12061206
if (_unitElementRequestedFiles.firstKey case var path?) {
1207-
await _getUnitElement(path);
1207+
_getUnitElement(path);
12081208
return;
12091209
}
12101210

@@ -1223,14 +1223,14 @@ class AnalysisDriver {
12231223
// Analyze a priority file.
12241224
for (var path in _priorityFiles) {
12251225
if (_fileTracker.isFilePending(path)) {
1226-
await _analyzeFile(path);
1226+
_analyzeFile(path);
12271227
return;
12281228
}
12291229
}
12301230

12311231
// Analyze a general file.
12321232
if (_fileTracker.anyPendingFile case var path?) {
1233-
await _produceErrors(path);
1233+
_produceErrors(path);
12341234
return;
12351235
}
12361236
}
@@ -1278,19 +1278,19 @@ class AnalysisDriver {
12781278
return request.completer.future;
12791279
}
12801280

1281-
Future<void> _analyzeFile(String path) async {
1282-
await scheduler.accumulatedPerformance.runAsync(
1281+
void _analyzeFile(String path) {
1282+
scheduler.accumulatedPerformance.run(
12831283
'analyzeFile',
1284-
(performance) async {
1285-
await _analyzeFileImpl(
1284+
(performance) {
1285+
_analyzeFileImpl(
12861286
path: path,
12871287
performance: performance,
12881288
);
12891289
},
12901290
);
12911291
}
12921292

1293-
Future<void> _analyzeFileImpl({
1293+
void _analyzeFileImpl({
12941294
required String path,
12951295
required OperationPerformanceImpl performance,
12961296
}) {
@@ -1305,7 +1305,7 @@ class AnalysisDriver {
13051305
var library = kind.library ?? kind.asLibrary;
13061306

13071307
// We need the fully resolved unit, or the result is not cached.
1308-
return _logger.runAsync('Compute analysis result for $path', () async {
1308+
return _logger.run('Compute analysis result for $path', () {
13091309
_logger.writeln('Work in $name');
13101310
try {
13111311
testView?.numOfAnalyzedLibraries++;
@@ -1637,7 +1637,7 @@ class AnalysisDriver {
16371637
}
16381638
}
16391639

1640-
Future<void> _getErrors(String path) async {
1640+
void _getErrors(String path) {
16411641
var file = _fsState.getFileForPath(path);
16421642

16431643
// Prepare the library - the file itself, or the known library.
@@ -1655,7 +1655,7 @@ class AnalysisDriver {
16551655
return;
16561656
}
16571657

1658-
await _analyzeFile(path);
1658+
_analyzeFile(path);
16591659
}
16601660

16611661
/// Return [AnalysisError]s for the given [serialized] errors.
@@ -1695,7 +1695,7 @@ class AnalysisDriver {
16951695
request.completer.complete(result);
16961696
}
16971697

1698-
Future<void> _getIndex(String path) async {
1698+
void _getIndex(String path) {
16991699
var file = _fsState.getFileForPath(path);
17001700

17011701
// Prepare the library - the file itself, or the known library.
@@ -1713,11 +1713,11 @@ class AnalysisDriver {
17131713
return;
17141714
}
17151715

1716-
await _analyzeFile(path);
1716+
_analyzeFile(path);
17171717
}
17181718

17191719
/// Completes the [getResolvedLibrary] request.
1720-
Future<void> _getResolvedLibrary(String path) async {
1720+
void _getResolvedLibrary(String path) {
17211721
var file = _fsState.getFileForPath(path);
17221722
var kind = file.kind;
17231723
switch (kind) {
@@ -1738,7 +1738,7 @@ class AnalysisDriver {
17381738
return;
17391739
}
17401740

1741-
await _analyzeFile(path);
1741+
_analyzeFile(path);
17421742
}
17431743

17441744
/// Return the key to store fully resolved results for the [signature].
@@ -1763,10 +1763,10 @@ class AnalysisDriver {
17631763
return signature.toHex();
17641764
}
17651765

1766-
Future<void> _getUnitElement(String path) async {
1767-
await scheduler.accumulatedPerformance.runAsync(
1766+
void _getUnitElement(String path) {
1767+
scheduler.accumulatedPerformance.run(
17681768
'getUnitElement',
1769-
(performance) async {
1769+
(performance) {
17701770
var file = _fsState.getFileForPath(path);
17711771

17721772
// Prepare the library - the file itself, or the known library.
@@ -1863,19 +1863,13 @@ class AnalysisDriver {
18631863
}
18641864
}
18651865

1866-
Future<void> _produceErrors(String path) async {
1866+
void _produceErrors(String path) {
18671867
var file = _fsState.getFileForPath(path);
18681868

18691869
// Prepare the library - the file itself, or the known library.
18701870
var kind = file.kind;
18711871
var library = kind.library ?? kind.asLibrary;
18721872

1873-
// Errors are based on elements, so load them.
1874-
libraryContext.load(
1875-
targetLibrary: library,
1876-
performance: OperationPerformanceImpl('<root>'),
1877-
);
1878-
18791873
// Check if we have cached errors for all library files.
18801874
List<(FileState, String, Uint8List)>? forAllFiles = [];
18811875
for (var file in library.files) {
@@ -1921,7 +1915,7 @@ class AnalysisDriver {
19211915
}
19221916

19231917
// Analyze, will produce results into the stream.
1924-
await _analyzeFile(path);
1918+
_analyzeFile(path);
19251919
}
19261920

19271921
void _removePotentiallyAffectedLibraries(
@@ -1987,10 +1981,10 @@ class AnalysisDriver {
19871981
);
19881982
}
19891983

1990-
Future<ResolvedForCompletionResultImpl?> _resolveForCompletion(
1984+
ResolvedForCompletionResultImpl? _resolveForCompletion(
19911985
_ResolveForCompletionRequest request,
19921986
) {
1993-
return request.performance.runAsync('body', (performance) async {
1987+
return request.performance.run('body', (performance) {
19941988
var path = request.path;
19951989
if (!_isAbsolutePath(path)) {
19961990
return null;

0 commit comments

Comments
 (0)