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

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

Issue 2908543002: Add result interfaces used by AnalysisSession (Closed)
Patch Set: Created 3 years, 7 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/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 2fa28a6fb26b4d67af2839d4129193bfa095186c..2755cc5925afe3b2e7ad0ed038dc8378e84f1231 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -8,6 +8,7 @@ import 'dart:typed_data';
import 'package:analyzer/context/context_root.dart';
import 'package:analyzer/context/declared_variables.dart';
+import 'package:analyzer/dart/analysis/results.dart' as results;
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart'
show CompilationUnitElement, LibraryElement;
@@ -1058,7 +1059,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
CompilationUnitElement element =
libraryContext.computeUnitElement(library.source, file.source);
String signature = library.transitiveSignature;
- return new UnitElementResult(path, signature, element);
+ return new UnitElementResult(path, file.uri, signature, element);
} finally {
libraryContext.dispose();
}
@@ -1590,7 +1591,7 @@ class AnalysisDriverTestView {
* Every result is independent, and is not guaranteed to be consistent with
* any previously returned result, even inside of the same library.
*/
-class AnalysisResult {
+class AnalysisResult implements results.ResolveResult {
static final _UNCHANGED = new AnalysisResult(
null, null, null, null, null, null, null, null, null, null, null);
@@ -1604,16 +1605,10 @@ class AnalysisResult {
*/
final SourceFactory sourceFactory;
- /**
- * The path of the analysed file, absolute and normalized.
- */
- final String path;
+ @override
+ final String filePath;
- /**
- * The URI of the file that corresponded to the [path] in the used
- * [SourceFactory] at some point. Is it not guaranteed to be still consistent
- * to the [path], and provided as FYI.
- */
+ @override
final Uri uri;
/**
@@ -1621,14 +1616,10 @@ class AnalysisResult {
*/
final bool exists;
- /**
- * The content of the file that was scanned, parsed and resolved.
- */
+ @override
final String content;
- /**
- * Information about lines in the [content].
- */
+ @override
final LineInfo lineInfo;
/**
@@ -1638,14 +1629,10 @@ class AnalysisResult {
*/
final String _signature;
- /**
- * The fully resolved compilation unit for the [content].
- */
+ @override
final CompilationUnit unit;
- /**
- * The full list of computed analysis errors, both syntactic and semantic.
- */
+ @override
final List<AnalysisError> errors;
/**
@@ -1656,7 +1643,7 @@ class AnalysisResult {
AnalysisResult(
this.driver,
this.sourceFactory,
- this.path,
+ this.filePath,
this.uri,
this.exists,
this.content,
@@ -1665,6 +1652,16 @@ class AnalysisResult {
this.unit,
this.errors,
this._index);
+
+ /**
+ * The path of the analysed file, absolute and normalized.
+ */
+ //@deprecated
+ String get path => filePath;
+
+ @override
+ results.ResultState get state =>
+ exists ? results.ResultState.VALID : results.ResultState.NOT_A_FILE;
}
/**
@@ -1692,28 +1689,29 @@ abstract class DriverWatcher {
* correspond to each other. But none of the results is guaranteed to be
* consistent with the state of the files.
*/
-class ErrorsResult {
- /**
- * The path of the parsed file, absolute and normalized.
- */
- final String path;
+class ErrorsResult implements results.ErrorsResult {
+ @override
+ final String filePath;
- /**
- * The URI of the file that corresponded to the [path].
- */
+ @override
final Uri uri;
- /**
- * Information about lines in the [content].
- */
+ @override
final LineInfo lineInfo;
+ @override
+ final List<AnalysisError> errors;
+
+ ErrorsResult(this.filePath, this.uri, this.lineInfo, this.errors);
+
/**
- * The full list of computed analysis errors, both syntactic and semantic.
+ * The path of the parsed file, absolute and normalized.
*/
- final List<AnalysisError> errors;
+ //@deprecated
+ String get path => filePath;
- ErrorsResult(this.path, this.uri, this.lineInfo, this.errors);
+ @override
+ results.ResultState get state => results.ResultState.VALID;
}
/**
@@ -1750,39 +1748,36 @@ class ExceptionResult {
* resolved [unit] correspond to each other. But none of the results is
* guaranteed to be consistent with the state of the files.
*/
-class ParseResult {
- /**
- * The path of the parsed file, absolute and normalized.
- */
- final String path;
+class ParseResult implements results.ParseResult {
+ @override
+ final String filePath;
- /**
- * The URI of the file that corresponded to the [path].
- */
+ @override
final Uri uri;
- /**
- * The content of the file that was scanned and parsed.
- */
+ @override
final String content;
- /**
- * Information about lines in the [content].
- */
+ @override
final LineInfo lineInfo;
- /**
- * The parsed, unresolved compilation unit for the [content].
- */
+ @override
final CompilationUnit unit;
+ @override
+ final List<AnalysisError> errors;
+
+ ParseResult(this.filePath, this.uri, this.content, this.lineInfo, this.unit,
+ this.errors);
+
/**
- * The scanning and parsing errors.
+ * The path of the parsed file, absolute and normalized.
*/
- final List<AnalysisError> errors;
+ //@deprecated
+ String get path => filePath;
- ParseResult(
- this.path, this.uri, this.content, this.lineInfo, this.unit, this.errors);
+ @override
+ results.ResultState get state => results.ResultState.VALID;
}
/**
@@ -1796,11 +1791,12 @@ class ParseResult {
* Every result is independent, and is not guaranteed to be consistent with
* any previously returned result, even inside of the same library.
*/
-class UnitElementResult {
- /**
- * The path of the file, absolute and normalized.
- */
- final String path;
+class UnitElementResult implements results.UnitElementResult {
+ @override
+ final String filePath;
+
+ @override
+ final Uri uri;
/**
* The signature of the [element] is based the APIs of the files of the
@@ -1814,7 +1810,16 @@ class UnitElementResult {
*/
final CompilationUnitElement element;
- UnitElementResult(this.path, this.signature, this.element);
+ UnitElementResult(this.filePath, this.uri, this.signature, this.element);
+
+ /**
+ * The path of the file, absolute and normalized.
+ */
+ //@deprecated
+ String get path => filePath;
+
+ @override
+ results.ResultState get state => results.ResultState.VALID;
}
/**
« pkg/analyzer/lib/dart/analysis/results.dart ('K') | « pkg/analyzer/lib/dart/analysis/results.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698