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

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

Issue 2928393004: Add FileState.hasMixin/hasMixinLibrary properties. (Closed)
Patch Set: 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
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..15faab032129124f784903f216e57c35fca3edf8 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 _hasMixin;
List<int> _apiSignature;
List<NamespaceExport> _exports;
@@ -85,6 +86,14 @@ class FileState {
@override
int get hashCode => uri.hashCode;
+ /// Whether the file has a mixin application.
+ bool get hasMixin => _hasMixin;
ahe 2017/06/12 19:22:03 Rename to hasMixinApplication? I think it's import
scheglov 2017/06/12 19:43:18 Yeah, I actually named it initially this way. But
+
+ /// Whether a unit of the library has a mixin application.
+ bool get hasMixinLibrary {
ahe 2017/06/12 19:22:03 hasMixinApplicationLibrary? But how about this: r
+ return _hasMixin || _partFiles.any((part) => part._hasMixin);
+ }
+
/// The list of the libraries imported by this library.
List<FileState> get importedLibraries => _importedLibraries;
@@ -138,8 +147,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 +219,16 @@ class FileState {
}
}
- /// Compute and return the API signature of the file.
+ /// Compute syntactic properties of the file: [_apiSignature] and [_hasMixin].
///
/// 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);
+ _hasMixin = parser.hasMixin;
+
ApiSignature apiSignature = new ApiSignature();
apiSignature.addBytes(_fsState._salt);
@@ -239,7 +250,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 +451,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 +465,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.

Powered by Google App Engine
This is Rietveld 408576698