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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2658983004: Implement AnalysisDriver.getSourceKind() and use it in analyzer-cli. (Closed)
Patch Set: Created 3 years, 11 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/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 34dee148973a167079ac578ab93bd78383fe3c77..05d8f46a6010f56acef900a2ca00a3eeb5d002d7 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -587,6 +587,21 @@ class AnalysisDriver {
}
/**
+ * Return a [Future] that completes with the [SourceKind] for the Dart
+ * file with the given [path]. If the file is not a Dart file or cannot
+ * be analyzed, the [Future] completes with `null`.
+ *
+ * The [path] must be absolute and normalized.
+ */
+ Future<SourceKind> getSourceKind(String path) async {
+ if (AnalysisEngine.isDartFileName(path)) {
+ FileState file = _fsState.getFileForPath(path);
+ return file.isPart ? SourceKind.PART : SourceKind.LIBRARY;
+ }
+ return null;
+ }
+
+ /**
* Return a [Future] that completes with top-level declarations with the
* given [name] in all known libraries.
*/
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698