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

Unified Diff: pkg/front_end/tool/fasta_perf.dart

Issue 2834543002: Remove use of package:analyzer in dependency_grapher (Closed)
Patch Set: cl comments Created 3 years, 8 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 | « pkg/front_end/test/subpackage_relationships_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/tool/fasta_perf.dart
diff --git a/pkg/front_end/tool/fasta_perf.dart b/pkg/front_end/tool/fasta_perf.dart
index 074bde4eb2cda30308f6a8b635ecb730c73b4599..10eea4d10fb59f37bf01d85aeb9ceaf01cde2631 100644
--- a/pkg/front_end/tool/fasta_perf.dart
+++ b/pkg/front_end/tool/fasta_perf.dart
@@ -13,6 +13,7 @@ import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
import 'package:front_end/src/fasta/kernel/kernel_target.dart'
show KernelTarget;
import 'package:front_end/src/fasta/parser.dart';
+import 'package:front_end/src/fasta/source/directive_listener.dart';
import 'package:front_end/src/fasta/scanner.dart';
import 'package:front_end/src/fasta/scanner/io.dart' show readBytesFromFileSync;
import 'package:front_end/src/fasta/ticker.dart' show Ticker;
@@ -156,51 +157,12 @@ Future<Null> collectSources(Uri start, Map<Uri, List<int>> files) async {
/// Parse [contents] as a Dart program and return the URIs that appear in its
/// import, export, and part directives.
Set<String> extractDirectiveUris(List<int> contents) {
- var listener = new DirectiveListener();
- new DirectiveParser(listener).parseUnit(tokenize(contents));
- return listener.uris;
-}
-
-/// Diet parser that stops eagerly at the first sign that we have seen all the
-/// import, export, and part directives.
-class DirectiveParser extends ClassMemberParser {
- DirectiveParser(listener) : super(listener);
-
- static final _endToken = new SymbolToken.eof(-1);
-
- Token parseClassOrNamedMixinApplication(Token token) => _endToken;
- Token parseEnum(Token token) => _endToken;
- parseTypedef(token) => _endToken;
- parseTopLevelMember(Token token) => _endToken;
-}
-
-/// Listener that records the URIs from imports, exports, and part directives.
-class DirectiveListener extends Listener {
- bool _inDirective = false;
- Set<String> uris = new Set<String>();
-
- void _enterDirective() {
- _inDirective = true;
- }
-
- void _exitDirective() {
- _inDirective = false;
- }
-
- beginImport(_) => _enterDirective();
- beginExport(_) => _enterDirective();
- beginPart(_) => _enterDirective();
-
- endExport(export, semicolon) => _exitDirective();
- endImport(import, deferred, asKeyword, semicolon) => _exitDirective();
- endPart(part, semicolon) => _exitDirective();
-
- void beginLiteralString(Token token) {
- if (_inDirective) {
- var quotedString = token.lexeme;
- uris.add(quotedString.substring(1, quotedString.length - 1));
- }
- }
+ var listener = new DirectiveListener(acceptsNativeClause: true);
+ new TopLevelParser(listener).parseUnit(tokenize(contents));
+ return new Set<String>()
+ ..addAll(listener.imports)
+ ..addAll(listener.exports)
+ ..addAll(listener.parts);
}
/// Parses every file in [files] and reports the time spent doing so.
« no previous file with comments | « pkg/front_end/test/subpackage_relationships_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698