OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/error/listener.dart'; | 8 import 'package:analyzer/error/listener.dart'; |
9 import 'package:analyzer/src/dart/scanner/reader.dart'; | 9 import 'package:analyzer/src/dart/scanner/reader.dart'; |
10 import 'package:analyzer/src/generated/parser.dart'; | 10 import 'package:analyzer/src/generated/parser.dart'; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 @override | 98 @override |
99 Future<List<_WalkerNode>> computeDependencies() async { | 99 Future<List<_WalkerNode>> computeDependencies() async { |
100 var dependencies = <_WalkerNode>[]; | 100 var dependencies = <_WalkerNode>[]; |
101 // TODO(paulberry): add error recovery if the file can't be read. | 101 // TODO(paulberry): add error recovery if the file can't be read. |
102 var path = walker.uriResolver.resolve(uri); | 102 var path = walker.uriResolver.resolve(uri); |
103 if (path == null) { | 103 if (path == null) { |
104 // TODO(paulberry): If an error reporter was provided, report the error | 104 // TODO(paulberry): If an error reporter was provided, report the error |
105 // in the proper way and continue. | 105 // in the proper way and continue. |
106 throw new StateError('Invalid URI: $uri'); | 106 throw new StateError('Invalid URI: $uri'); |
107 } | 107 } |
108 var contents = await walker.fileSystem.entityForPath(path).readAsString(); | 108 var contents = await walker.fileSystem.entityForUri(path).readAsString(); |
danrubel
2017/01/08 17:07:38
rename "path" to "resolvedUri" ? "fileUri"?
| |
109 var scanner = new _Scanner(contents); | 109 var scanner = new _Scanner(contents); |
110 var token = scanner.tokenize(); | 110 var token = scanner.tokenize(); |
111 // TODO(paulberry): report errors. | 111 // TODO(paulberry): report errors. |
112 var parser = new Parser(null, AnalysisErrorListener.NULL_LISTENER); | 112 var parser = new Parser(null, AnalysisErrorListener.NULL_LISTENER); |
113 var unit = parser.parseDirectives(token); | 113 var unit = parser.parseDirectives(token); |
114 bool coreUriFound = false; | 114 bool coreUriFound = false; |
115 void handleDependency(Uri referencedUri) { | 115 void handleDependency(Uri referencedUri) { |
116 _WalkerNode dependencyNode = walker.nodeForUri(referencedUri); | 116 _WalkerNode dependencyNode = walker.nodeForUri(referencedUri); |
117 library.dependencies.add(dependencyNode.library); | 117 library.dependencies.add(dependencyNode.library); |
118 if (referencedUri.scheme != 'dart' || walker.compileSdk) { | 118 if (referencedUri.scheme != 'dart' || walker.compileSdk) { |
(...skipping 15 matching lines...) Expand all Loading... | |
134 handleDependency(referencedUri); | 134 handleDependency(referencedUri); |
135 } | 135 } |
136 } | 136 } |
137 } | 137 } |
138 if (!coreUriFound) { | 138 if (!coreUriFound) { |
139 handleDependency(dartCoreUri); | 139 handleDependency(dartCoreUri); |
140 } | 140 } |
141 return dependencies; | 141 return dependencies; |
142 } | 142 } |
143 } | 143 } |
OLD | NEW |