-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25d356b
commit d7f5512
Showing
19 changed files
with
303 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2021, Google Inc. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
import 'package:analyzer/dart/analysis/results.dart'; | ||
import 'package:analyzer/dart/element/element.dart'; | ||
|
||
/// Caches parsed library results across one generation. | ||
/// | ||
/// Substitutes a "throwing mock" if no parsed library is available. | ||
class ParsedLibraryResults { | ||
final Map<Uri, ParsedLibraryResult> _results = {}; | ||
|
||
ParsedLibraryResult parsedLibraryResultOrThrowingMock( | ||
LibraryElement element) { | ||
var uri = element.source.uri; | ||
return _results[uri] ??= _parsedLibraryResultOrThrowingMock(element); | ||
} | ||
|
||
ParsedLibraryResult _parsedLibraryResultOrThrowingMock( | ||
LibraryElement element) { | ||
var result = element.session.getParsedLibraryByElement(element); | ||
if (result is ParsedLibraryResult) { | ||
return result; | ||
} | ||
return _ParsedLibraryResultMock(); | ||
} | ||
} | ||
|
||
class _ParsedLibraryResultMock implements ParsedLibraryResult { | ||
@override | ||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | ||
} |
Oops, something went wrong.