Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: pkg/front_end/lib/src/incremental/file_state.dart

Issue 2928393004: Add FileState.hasMixin/hasMixinLibrary properties. (Closed)
Patch Set: Tweaks for review comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/file_state_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/incremental/file_state.dart
diff --git a/pkg/front_end/lib/src/incremental/file_state.dart b/pkg/front_end/lib/src/incremental/file_state.dart
index 61400d6f12b0f816c885a60b7004f6b9377682fa..87c5323f1e696f2bbccfacc23315a045b880da79 100644
--- a/pkg/front_end/lib/src/incremental/file_state.dart
+++ b/pkg/front_end/lib/src/incremental/file_state.dart
@@ -44,6 +44,7 @@ class FileState {
bool _exists;
List<int> _content;
List<int> _contentHash;
+ bool _hasMixinApplication;
List<int> _apiSignature;
List<NamespaceExport> _exports;
@@ -85,6 +86,15 @@ class FileState {
@override
int get hashCode => uri.hashCode;
+ /// Whether the file has a mixin application.
+ bool get hasMixinApplication => _hasMixinApplication;
+
+ /// Whether a unit of the library has a mixin application.
+ bool get hasMixinApplicationLibrary {
+ return _hasMixinApplication ||
+ _partFiles.any((part) => part._hasMixinApplication);
+ }
+
/// The list of the libraries imported by this library.
List<FileState> get importedLibraries => _importedLibraries;
@@ -138,8 +148,8 @@ class FileState {
// Scan the content.
ScannerResult scanResult = _scan();
- // Compute the API signature.
- _apiSignature = _computeApiSignature(scanResult.tokens);
+ // Compute syntactic properties.
+ _computeSyntacticProperties(scanResult.tokens);
// Parse directives.
var listener = new _DirectiveListenerWithNative();
@@ -210,14 +220,16 @@ class FileState {
}
}
- /// Compute and return the API signature of the file.
+ /// Compute syntactic properties of the file: [_apiSignature] and [_hasMixinApplication].
///
/// The signature is based on non-comment tokens of the file outside
/// of function bodies.
- List<int> _computeApiSignature(Token token) {
+ void _computeSyntacticProperties(Token token) {
var parser = new _BodySkippingParser();
parser.parseUnit(token);
+ _hasMixinApplication = parser.hasMixin;
+
ApiSignature apiSignature = new ApiSignature();
apiSignature.addBytes(_fsState._salt);
@@ -239,7 +251,8 @@ class FileState {
apiSignature.addString(token.lexeme);
}
- return apiSignature.toByteList();
+ // Store the API signature.
+ _apiSignature = apiSignature.toByteList();
}
/// Exclude all `native 'xyz';` token sequences.
@@ -439,6 +452,7 @@ class _BodyRange {
/// The [Parser] that skips function bodies and remembers their token ranges.
class _BodySkippingParser extends Parser {
+ bool hasMixin = false;
final List<_BodyRange> bodyRanges = [];
_BodySkippingParser() : super(new Listener());
@@ -452,6 +466,11 @@ class _BodySkippingParser extends Parser {
}
return super.parseFunctionBody(token, isExpression, allowAbstract);
}
+
+ Token parseMixinApplication(Token token) {
+ hasMixin = true;
+ return super.parseMixinApplication(token);
+ }
}
/// [DirectiveListener] that skips native clauses.
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/file_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698