The interesting changes are in pkg/analyzer/lib/dart/analysis/results.dart and pkg/analyzer/lib/dart/analysis/session.dart. I renamed 3 methods and 2 classes. All of the other files just reflect the impact of that renaming.
Patch set 1:Commit-Queue +1
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
Brian Wilkerson would like Paul Berry and Konstantin Shcheglov to review this change.
Rename some AnalysisSession methods for consistency
Change-Id: I96a15193447f2087f152907c4f546d3fbdfc1c62
---
M pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart
M pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart
M pkg/analysis_server/lib/src/computer/import_elements_computer.dart
M pkg/analysis_server/lib/src/edit/edit_dartfix.dart
M pkg/analysis_server/lib/src/edit/edit_domain.dart
M pkg/analysis_server/lib/src/edit/fix/prefer_int_literals_fix.dart
M pkg/analysis_server/lib/src/edit/fix/prefer_mixin_fix.dart
M pkg/analysis_server/lib/src/flutter/flutter_correction.dart
M pkg/analysis_server/lib/src/flutter/flutter_domain.dart
M pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart
M pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
M pkg/analysis_server/lib/src/services/correction/assist.dart
M pkg/analysis_server/lib/src/services/correction/fix.dart
M pkg/analysis_server/lib/src/services/correction/fix_internal.dart
M pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart
M pkg/analysis_server/lib/src/services/correction/util.dart
M pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
M pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
M pkg/analysis_server/lib/src/services/refactoring/extract_widget.dart
M pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
M pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
M pkg/analysis_server/lib/src/services/refactoring/move_file.dart
M pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
M pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
M pkg/analysis_server/test/services/correction/sort_members_test.dart
M pkg/analysis_server/test/services/refactoring/rename_local_test.dart
M pkg/analysis_server/test/src/computer/closingLabels_computer_test.dart
M pkg/analysis_server/test/src/computer/folding_computer_test.dart
M pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
M pkg/analysis_server/test/stress/completion/completion_runner.dart
M pkg/analyzer/lib/dart/analysis/results.dart
M pkg/analyzer/lib/dart/analysis/session.dart
M pkg/analyzer/lib/src/dart/analysis/driver.dart
M pkg/analyzer/lib/src/dart/analysis/session.dart
M pkg/analyzer/lib/src/dart/analysis/session_helper.dart
M pkg/analyzer/test/src/dart/analysis/driver_test.dart
M pkg/analyzer/test/src/dart/analysis/session_test.dart
M pkg/analyzer_plugin/lib/plugin/assist_mixin.dart
M pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
M pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
M pkg/analyzer_plugin/lib/plugin/folding_mixin.dart
M pkg/analyzer_plugin/lib/plugin/highlights_mixin.dart
M pkg/analyzer_plugin/lib/plugin/kythe_mixin.dart
M pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
M pkg/analyzer_plugin/lib/plugin/occurrences_mixin.dart
M pkg/analyzer_plugin/lib/plugin/outline_mixin.dart
M pkg/analyzer_plugin/lib/plugin/plugin.dart
M pkg/analyzer_plugin/lib/src/utilities/assist/assist.dart
M pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
M pkg/analyzer_plugin/lib/src/utilities/completion/completion_core.dart
M pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart
M pkg/analyzer_plugin/lib/src/utilities/folding/folding.dart
M pkg/analyzer_plugin/lib/src/utilities/highlights/highlights.dart
M pkg/analyzer_plugin/lib/src/utilities/kythe/entries.dart
M pkg/analyzer_plugin/lib/src/utilities/navigation/navigation.dart
M pkg/analyzer_plugin/lib/src/utilities/occurrences/occurrences.dart
M pkg/analyzer_plugin/lib/src/utilities/outline/outline.dart
M pkg/analyzer_plugin/lib/utilities/assist/assist.dart
M pkg/analyzer_plugin/lib/utilities/completion/completion_core.dart
M pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart
M pkg/analyzer_plugin/lib/utilities/folding/folding.dart
M pkg/analyzer_plugin/lib/utilities/highlights/highlights.dart
M pkg/analyzer_plugin/lib/utilities/kythe/entries.dart
M pkg/analyzer_plugin/lib/utilities/navigation/navigation.dart
M pkg/analyzer_plugin/lib/utilities/occurrences/occurrences.dart
M pkg/analyzer_plugin/lib/utilities/outline/outline.dart
M pkg/analyzer_plugin/test/utilities/completion/completion_contributor_util.dart
M pkg/analyzer_plugin/test/utilities/navigation_test.dart
68 files changed, 204 insertions(+), 129 deletions(-)
diff --git a/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart b/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart
index af136f2..f338cc5 100644
--- a/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart
+++ b/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart
@@ -13,7 +13,7 @@
/**
* The resolution result in which assist operates.
*/
- ResolveResult get resolveResult;
+ ResolvedUnitResult get resolveResult;
/**
* The length of the selection.
diff --git a/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart b/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart
index bfe5289..2ac36c5 100644
--- a/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart
+++ b/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart
@@ -14,5 +14,5 @@
/**
* The resolution result in which fix operates.
*/
- ResolveResult get resolveResult;
+ ResolvedUnitResult get resolveResult;
}
diff --git a/pkg/analysis_server/lib/src/computer/import_elements_computer.dart b/pkg/analysis_server/lib/src/computer/import_elements_computer.dart
index 292b748..7973eed 100644
--- a/pkg/analysis_server/lib/src/computer/import_elements_computer.dart
+++ b/pkg/analysis_server/lib/src/computer/import_elements_computer.dart
@@ -38,7 +38,7 @@
* The resolution result associated with the defining compilation unit of the
* library to which imports might be added.
*/
- final ResolveResult libraryResult;
+ final ResolvedUnitResult libraryResult;
/**
* Initialize a newly created builder.
diff --git a/pkg/analysis_server/lib/src/edit/edit_dartfix.dart b/pkg/analysis_server/lib/src/edit/edit_dartfix.dart
index 6c1c89d..037e5ba 100644
--- a/pkg/analysis_server/lib/src/edit/edit_dartfix.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_dartfix.dart
@@ -139,7 +139,7 @@
}
continue;
}
- ResolveResult result = await server.getAnalysisResult(res.path);
+ ResolvedUnitResult result = await server.getAnalysisResult(res.path);
CompilationUnit unit = result?.unit;
if (unit != null) {
if (!hasErrors) {
@@ -190,7 +190,7 @@
.toResponse(request.id);
}
- Future<bool> fixError(ResolveResult result, AnalysisError error) async {
+ Future<bool> fixError(ResolvedUnitResult result, AnalysisError error) async {
if (error.errorCode ==
StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR) {
// TODO(danrubel): Rather than comparing the error codes individually,
@@ -235,7 +235,7 @@
return false;
}
- Location locationFor(ResolveResult result, int offset, int length) {
+ Location locationFor(ResolvedUnitResult result, int offset, int length) {
final locInfo = result.unit.lineInfo.getLocation(offset);
final location = new Location(
result.path, offset, length, locInfo.lineNumber, locInfo.columnNumber);
@@ -252,7 +252,7 @@
LinterFix(this.dartFix);
/// Apply fixes for the current compilation unit.
- Future<void> applyLocalFixes(ResolveResult result);
+ Future<void> applyLocalFixes(ResolvedUnitResult result);
/// Apply any fixes remaining after analysis is complete.
Future<void> applyRemainingFixes();
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index bcef828..ea8e1e7 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -182,7 +182,7 @@
//
// Compute fixes associated with server-generated errors.
//
- ResolveResult result = await server.getAnalysisResult(file);
+ ResolvedUnitResult result = await server.getAnalysisResult(file);
if (result != null) {
var context = new DartAssistContextImpl(result, offset, length);
try {
@@ -274,7 +274,7 @@
var params = new EditGetPostfixCompletionParams.fromRequest(request);
SourceChange change;
- ResolveResult result = await server.getAnalysisResult(params.file);
+ ResolvedUnitResult result = await server.getAnalysisResult(params.file);
if (result != null) {
PostfixCompletionContext context = new PostfixCompletionContext(
result,
@@ -301,7 +301,7 @@
var params = new EditGetStatementCompletionParams.fromRequest(request);
SourceChange change;
- ResolveResult result = await server.getAnalysisResult(params.file);
+ ResolvedUnitResult result = await server.getAnalysisResult(params.file);
if (result != null) {
var context = new StatementCompletionContext(result, params.offset);
StatementCompletionProcessor processor =
@@ -377,7 +377,7 @@
//
// Prepare the resolved unit.
//
- ResolveResult result = await server.getAnalysisResult(params.file);
+ ResolvedUnitResult result = await server.getAnalysisResult(params.file);
if (result == null) {
server.sendResponse(new Response.importElementsInvalidFile(request));
}
@@ -412,7 +412,7 @@
var params = new EditGetPostfixCompletionParams.fromRequest(request);
bool value = false;
- ResolveResult result = await server.getAnalysisResult(params.file);
+ ResolvedUnitResult result = await server.getAnalysisResult(params.file);
if (result != null) {
var context = new PostfixCompletionContext(
result,
@@ -454,7 +454,7 @@
return;
}
// Prepare the file information.
- ResolveResult result = await server.getAnalysisResult(file);
+ ResolvedUnitResult result = await server.getAnalysisResult(file);
if (result == null) {
server.sendResponse(new Response.fileNotAnalyzed(request, file));
return;
@@ -490,7 +490,7 @@
}
// Prepare the file information.
var driver = server.getAnalysisDriver(file);
- ParseResult result = await driver?.parseFile(file);
+ ParsedUnitResult result = await driver?.parseFile(file);
if (result == null) {
server.sendResponse(new Response.fileNotAnalyzed(request, file));
return;
diff --git a/pkg/analysis_server/lib/src/edit/fix/prefer_int_literals_fix.dart b/pkg/analysis_server/lib/src/edit/fix/prefer_int_literals_fix.dart
index 9adc766..33097ad 100644
--- a/pkg/analysis_server/lib/src/edit/fix/prefer_int_literals_fix.dart
+++ b/pkg/analysis_server/lib/src/edit/fix/prefer_int_literals_fix.dart
@@ -16,7 +16,7 @@
PreferIntLiteralsFix(EditDartFix dartFix) : super(dartFix);
@override
- Future<void> applyLocalFixes(ResolveResult result) async {
+ Future<void> applyLocalFixes(ResolvedUnitResult result) async {
while (literalsToConvert.isNotEmpty) {
DoubleLiteral literal = literalsToConvert.removeLast();
AssistProcessor processor = new AssistProcessor(
diff --git a/pkg/analysis_server/lib/src/edit/fix/prefer_mixin_fix.dart b/pkg/analysis_server/lib/src/edit/fix/prefer_mixin_fix.dart
index 54d164a..0ebc48b 100644
--- a/pkg/analysis_server/lib/src/edit/fix/prefer_mixin_fix.dart
+++ b/pkg/analysis_server/lib/src/edit/fix/prefer_mixin_fix.dart
@@ -17,7 +17,7 @@
PreferMixinFix(EditDartFix dartFix) : super(dartFix);
@override
- Future<void> applyLocalFixes(ResolveResult result) {
+ Future<void> applyLocalFixes(ResolvedUnitResult result) {
// All fixes applied in [applyRemainingFixes]
return null;
}
@@ -30,7 +30,7 @@
}
Future<void> convertClassToMixin(Element elem) async {
- ResolveResult result =
+ ResolvedUnitResult result =
await dartFix.server.getAnalysisResult(elem.source?.fullName);
for (CompilationUnitMember declaration in result.unit.declarations) {
diff --git a/pkg/analysis_server/lib/src/flutter/flutter_correction.dart b/pkg/analysis_server/lib/src/flutter/flutter_correction.dart
index b7ca584..34e2864 100644
--- a/pkg/analysis_server/lib/src/flutter/flutter_correction.dart
+++ b/pkg/analysis_server/lib/src/flutter/flutter_correction.dart
@@ -13,7 +13,7 @@
import 'package:meta/meta.dart';
class FlutterCorrections {
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final int selectionOffset;
final int selectionLength;
final int selectionEnd;
diff --git a/pkg/analysis_server/lib/src/flutter/flutter_domain.dart b/pkg/analysis_server/lib/src/flutter/flutter_domain.dart
index 648e0bf..356faa4 100644
--- a/pkg/analysis_server/lib/src/flutter/flutter_domain.dart
+++ b/pkg/analysis_server/lib/src/flutter/flutter_domain.dart
@@ -33,7 +33,7 @@
String file = params.file;
int offset = params.offset;
- ResolveResult result = await server.getAnalysisResult(file);
+ ResolvedUnitResult result = await server.getAnalysisResult(file);
if (result != null) {
var corrections = new FlutterCorrections(
resolveResult: result,
diff --git a/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart b/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart
index 6d1262c..1c15d65 100644
--- a/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart
+++ b/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart
@@ -255,7 +255,7 @@
* The context for computing a postfix completion.
*/
class PostfixCompletionContext {
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final int selectionOffset;
final String key;
diff --git a/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart b/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
index 23581e8..c2fb919 100644
--- a/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
+++ b/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
@@ -82,7 +82,7 @@
* The context for computing a statement completion.
*/
class StatementCompletionContext {
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final int selectionOffset;
StatementCompletionContext(this.resolveResult, this.selectionOffset);
diff --git a/pkg/analysis_server/lib/src/services/correction/assist.dart b/pkg/analysis_server/lib/src/services/correction/assist.dart
index 861f37b..5075ec8 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist.dart
@@ -11,7 +11,7 @@
*/
class DartAssistContextImpl implements DartAssistContext {
@override
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
@override
final int selectionOffset;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index dbe34ef..575268c 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -88,7 +88,7 @@
*/
class DartFixContextImpl implements DartFixContext {
@override
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
@override
final AnalysisError error;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 25bd8ef..7edec83 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -3289,7 +3289,7 @@
}
// use different utils
var targetPath = targetClassElement.source.fullName;
- var targetResolveResult = await session.getResolvedAst(targetPath);
+ var targetResolveResult = await session.getResolvedUnit(targetPath);
utils = CorrectionUtils(targetResolveResult);
}
ClassMemberLocation targetLocation =
diff --git a/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart b/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart
index 89f18c3..db39ca8 100644
--- a/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart
+++ b/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart
@@ -37,7 +37,7 @@
* Analyzer to check if a selection covers a valid set of statements of AST.
*/
class StatementAnalyzer extends SelectionAnalyzer {
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final RefactoringStatus _status = new RefactoringStatus();
diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
index 188dadf..b8478d1 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -31,7 +31,7 @@
Future<void> addLibraryImports(AnalysisSession session, SourceChange change,
LibraryElement targetLibrary, Set<Source> libraries) async {
var libraryPath = targetLibrary.source.fullName;
- var resolveResult = await session.getResolvedAst(libraryPath);
+ var resolveResult = await session.getResolvedUnit(libraryPath);
var libUtils = new CorrectionUtils(resolveResult);
String eol = libUtils.endOfLine;
// Prepare information about existing imports.
@@ -616,7 +616,7 @@
String _endOfLine;
- CorrectionUtils(ResolveResult result)
+ CorrectionUtils(ResolvedUnitResult result)
: unit = result.unit,
_library = result.libraryElement,
_buffer = result.content;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
index fdcc912..41a470c 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
@@ -31,7 +31,7 @@
*/
class ExtractLocalRefactoringImpl extends RefactoringImpl
implements ExtractLocalRefactoring {
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final int selectionOffset;
final int selectionLength;
SourceRange selectionRange;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
index 5d1f7ba..a0929ed 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
@@ -73,7 +73,7 @@
'execution flows exit. Semantics may not be preserved.';
final SearchEngine searchEngine;
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final int selectionOffset;
final int selectionLength;
SourceRange selectionRange;
@@ -922,7 +922,8 @@
* [SelectionAnalyzer] for [ExtractMethodRefactoringImpl].
*/
class _ExtractMethodAnalyzer extends StatementAnalyzer {
- _ExtractMethodAnalyzer(ResolveResult resolveResult, SourceRange selection)
+ _ExtractMethodAnalyzer(
+ ResolvedUnitResult resolveResult, SourceRange selection)
: super(resolveResult, selection);
@override
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_widget.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_widget.dart
index 71d20a4..07c207f 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_widget.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_widget.dart
@@ -28,7 +28,7 @@
class ExtractWidgetRefactoringImpl extends RefactoringImpl
implements ExtractWidgetRefactoring {
final SearchEngine searchEngine;
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final AnalysisSessionHelper sessionHelper;
final int offset;
final int length;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart b/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
index 8b5c1f2..fb808e8 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
@@ -26,7 +26,7 @@
class InlineLocalRefactoringImpl extends RefactoringImpl
implements InlineLocalRefactoring {
final SearchEngine searchEngine;
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final int offset;
CorrectionUtils utils;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart b/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
index 1925d42..c78a591 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
@@ -187,7 +187,7 @@
class InlineMethodRefactoringImpl extends RefactoringImpl
implements InlineMethodRefactoring {
final SearchEngine searchEngine;
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final int offset;
ResolvedUnitCache _unitCache;
CorrectionUtils utils;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
index ac5fdf8..a068451 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
@@ -32,6 +32,8 @@
String oldFile;
String newFile;
+ final packagePrefixedStringPattern = new RegExp(r'''^r?['"]+package:''');
+
MoveFileRefactoringImpl(ResourceProvider resourceProvider, this.workspace,
this.source, this.oldFile)
: resourceProvider = resourceProvider,
@@ -90,7 +92,7 @@
});
} else {
// Otherwise, we need to update any relative part-of references.
- final result = await driver.currentSession.getResolvedAst(oldFile);
+ final result = await driver.currentSession.getResolvedUnit(oldFile);
Iterable<PartOfDirective> partOfs = result.unit.directives
.whereType<PartOfDirective>()
.where((po) => po.uri != null && _isRelativeUri(po.uri.stringValue));
@@ -140,7 +142,12 @@
return _getRelativeUri(newFile, refDir);
}
- final packagePrefixedStringPattern = new RegExp(r'''^r?['"]+package:''');
+ String _getRelativeUri(String path, String from) {
+ String uri = pathContext.relative(path, from: from);
+ List<String> parts = pathContext.split(uri);
+ return pathos.posix.joinAll(parts);
+ }
+
bool _isPackageReference(SourceReference reference) {
final Source source = reference.element.source;
final String quotedImportUri = source.contents.data.substring(
@@ -149,12 +156,6 @@
return packagePrefixedStringPattern.hasMatch(quotedImportUri);
}
- String _getRelativeUri(String path, String from) {
- String uri = pathContext.relative(path, from: from);
- List<String> parts = pathContext.split(uri);
- return pathos.posix.joinAll(parts);
- }
-
/**
* Checks if the given [path] represents a relative URI.
*
diff --git a/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart b/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
index 3798604..6dd21a3 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
@@ -68,7 +68,7 @@
/**
* Returns a new [ExtractLocalRefactoring] instance.
*/
- factory ExtractLocalRefactoring(ResolveResult resolveResult,
+ factory ExtractLocalRefactoring(ResolvedUnitResult resolveResult,
int selectionOffset, int selectionLength) = ExtractLocalRefactoringImpl;
/**
@@ -142,8 +142,11 @@
/**
* Returns a new [ExtractMethodRefactoring] instance.
*/
- factory ExtractMethodRefactoring(SearchEngine searchEngine,
- ResolveResult resolveResult, int selectionOffset, int selectionLength) {
+ factory ExtractMethodRefactoring(
+ SearchEngine searchEngine,
+ ResolvedUnitResult resolveResult,
+ int selectionOffset,
+ int selectionLength) {
return new ExtractMethodRefactoringImpl(
searchEngine, resolveResult, selectionOffset, selectionLength);
}
@@ -239,7 +242,7 @@
* Returns a new [ExtractWidgetRefactoring] instance.
*/
factory ExtractWidgetRefactoring(SearchEngine searchEngine,
- ResolveResult resolveResult, int offset, int length) {
+ ResolvedUnitResult resolveResult, int offset, int length) {
return new ExtractWidgetRefactoringImpl(
searchEngine, resolveResult, offset, length);
}
@@ -275,7 +278,7 @@
* Returns a new [InlineLocalRefactoring] instance.
*/
factory InlineLocalRefactoring(
- SearchEngine searchEngine, ResolveResult resolveResult, int offset) {
+ SearchEngine searchEngine, ResolvedUnitResult resolveResult, int offset) {
return new InlineLocalRefactoringImpl(searchEngine, resolveResult, offset);
}
@@ -298,7 +301,7 @@
* Returns a new [InlineMethodRefactoring] instance.
*/
factory InlineMethodRefactoring(
- SearchEngine searchEngine, ResolveResult resolveResult, int offset) {
+ SearchEngine searchEngine, ResolvedUnitResult resolveResult, int offset) {
return new InlineMethodRefactoringImpl(searchEngine, resolveResult, offset);
}
@@ -503,19 +506,19 @@
*/
class ResolvedUnitCache {
final AnalysisSession _session;
- final Map<String, ResolveResult> _map = {};
+ final Map<String, ResolvedUnitResult> _map = {};
- ResolvedUnitCache(ResolveResult result) : _session = result.session {
+ ResolvedUnitCache(ResolvedUnitResult result) : _session = result.session {
_map[result.path] = result;
}
ResolvedUnitCache.empty(AnalysisSession session) : _session = session;
- Future<ResolveResult> getResolvedAst(Element element) async {
+ Future<ResolvedUnitResult> getResolvedAst(Element element) async {
var path = element.source.fullName;
var result = _map[path];
if (result == null) {
- result = await _session.getResolvedAst(path);
+ result = await _session.getResolvedUnit(path);
_map[path] = result;
}
return result;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart b/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
index f54b9b4..bde2c49 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/rename_import.dart
@@ -111,7 +111,7 @@
await null;
LibraryElement library = element.library;
String path = library.source.fullName;
- CompilationUnit unit = (await session.getParsedAstSync(path)).unit;
+ CompilationUnit unit = (await session.getParsedUnitSync(path)).unit;
int index = library.imports.indexOf(element);
return unit.directives.where((d) => d is ImportDirective).toList()[index];
}
@@ -126,7 +126,7 @@
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
Source source = reference.element.source;
- CompilationUnit unit = (await session.getParsedAst(source.fullName)).unit;
+ CompilationUnit unit = (await session.getParsedUnit(source.fullName)).unit;
NodeLocator nodeLocator = new NodeLocator(reference.range.offset);
AstNode node = nodeLocator.searchWithin(unit);
if (node is SimpleIdentifier) {
diff --git a/pkg/analysis_server/test/services/correction/sort_members_test.dart b/pkg/analysis_server/test/services/correction/sort_members_test.dart
index d89bb36..f1cc1a6 100644
--- a/pkg/analysis_server/test/services/correction/sort_members_test.dart
+++ b/pkg/analysis_server/test/services/correction/sort_members_test.dart
@@ -804,7 +804,7 @@
Future<void> _parseTestUnit(String code) async {
addTestSource(code);
- ParseResult result = await driver.parseFile(testSource.fullName);
+ ParsedUnitResult result = await driver.parseFile(testSource.fullName);
testUnit = result.unit;
}
}
diff --git a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
index bdd0ac9..8217bf9 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
@@ -461,7 +461,7 @@
driver.addFile(b);
var session = driver.currentSession;
- testAnalysisResult = await session.getResolvedAst(a);
+ testAnalysisResult = await session.getResolvedUnit(a);
testFile = testAnalysisResult.path;
testCode = testAnalysisResult.content;
testUnit = testAnalysisResult.unit;
diff --git a/pkg/analysis_server/test/src/computer/closingLabels_computer_test.dart b/pkg/analysis_server/test/src/computer/closingLabels_computer_test.dart
index 1c5ec8d..3f97c08 100644
--- a/pkg/analysis_server/test/src/computer/closingLabels_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/closingLabels_computer_test.dart
@@ -400,7 +400,7 @@
Future<List<ClosingLabel>> _computeElements(String sourceContent) async {
newFile(sourcePath, content: sourceContent);
- ResolveResult result = await driver.getResult(sourcePath);
+ ResolvedUnitResult result = await driver.getResult(sourcePath);
DartUnitClosingLabelsComputer computer =
new DartUnitClosingLabelsComputer(result.lineInfo, result.unit);
return computer.compute();
diff --git a/pkg/analysis_server/test/src/computer/folding_computer_test.dart b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
index dee139a..ae9cc44 100644
--- a/pkg/analysis_server/test/src/computer/folding_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
@@ -449,7 +449,7 @@
Future<List<FoldingRegion>> _computeRegions(String sourceContent) async {
newFile(sourcePath, content: sourceContent);
- ResolveResult result = await driver.getResult(sourcePath);
+ ResolvedUnitResult result = await driver.getResult(sourcePath);
DartUnitFoldingComputer computer =
new DartUnitFoldingComputer(result.lineInfo, result.unit);
return computer.compute();
diff --git a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
index 55c106b..99324d9 100644
--- a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
@@ -392,7 +392,7 @@
Future<List<ImportedElements>> _computeElements(
String sourceContent, int offset, int length) async {
newFile(sourcePath, content: sourceContent);
- ResolveResult result = await driver.getResult(sourcePath);
+ ResolvedUnitResult result = await driver.getResult(sourcePath);
ImportedElementsComputer computer =
new ImportedElementsComputer(result.unit, offset, length);
return computer.compute();
diff --git a/pkg/analysis_server/test/stress/completion/completion_runner.dart b/pkg/analysis_server/test/stress/completion/completion_runner.dart
index 3605038..41a69b8 100644
--- a/pkg/analysis_server/test/stress/completion/completion_runner.dart
+++ b/pkg/analysis_server/test/stress/completion/completion_runner.dart
@@ -103,8 +103,8 @@
}
fileCount++;
output.write('.');
- ResolveResult result =
- await context.currentSession.getResolvedAst(path);
+ ResolvedUnitResult result =
+ await context.currentSession.getResolvedUnit(path);
String content = result.content;
LineInfo lineInfo = result.lineInfo;
List<SimpleIdentifier> identifiers = _identifiersIn(result.unit);
@@ -117,7 +117,7 @@
content.substring(identifier.end);
resourceProvider.setOverlay(path,
content: modifiedContent, modificationStamp: stamp++);
- result = await context.currentSession.getResolvedAst(path);
+ result = await context.currentSession.getResolvedUnit(path);
}
timer.start();
diff --git a/pkg/analyzer/lib/dart/analysis/results.dart b/pkg/analyzer/lib/dart/analysis/results.dart
index 635fe97..546b778 100644
--- a/pkg/analyzer/lib/dart/analysis/results.dart
+++ b/pkg/analyzer/lib/dart/analysis/results.dart
@@ -59,7 +59,7 @@
/**
* The result of computing some cheap information for a single file, when full
- * parsed file is not required, so [ParseResult] is not necessary.
+ * parsed file is not required, so [ParsedUnitResult] is not necessary.
*
* Clients may not extend, implement or mix-in this class.
*/
@@ -81,6 +81,16 @@
*
* Clients may not extend, implement or mix-in this class.
*/
+// ignore: deprecated_member_use
+abstract class ParsedUnitResult implements ParseResult {}
+
+/**
+ * The result of parsing of a single file. The errors returned include only
+ * those discovered during scanning and parsing.
+ *
+ * Clients may not extend, implement or mix-in this class.
+ */
+@deprecated
abstract class ParseResult implements AnalysisResultWithErrors {
/**
* The content of the file that was scanned and parsed.
@@ -99,6 +109,16 @@
*
* Clients may not extend, implement or mix-in this class.
*/
+// ignore: deprecated_member_use
+abstract class ResolvedUnitResult implements ResolveResult {}
+
+/**
+ * The result of building a resolved AST for a single file. The errors returned
+ * include both syntactic and semantic errors.
+ *
+ * Clients may not extend, implement or mix-in this class.
+ */
+@deprecated
abstract class ResolveResult implements AnalysisResultWithErrors {
/**
* The content of the file that was scanned, parsed and resolved.
diff --git a/pkg/analyzer/lib/dart/analysis/session.dart b/pkg/analyzer/lib/dart/analysis/session.dart
index 3c4d9cf..cf634eb 100644
--- a/pkg/analyzer/lib/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/dart/analysis/session.dart
@@ -70,20 +70,47 @@
/**
* Return a future that will complete with information about the results of
* parsing the file with the given absolute, normalized [path].
+ *
+ * Deprecated: Use [getParsedUnit] instead.
*/
+ @deprecated
Future<ParseResult> getParsedAst(String path);
/**
+ * Return a future that will complete with information about the results of
+ * parsing the file with the given absolute, normalized [path].
+ */
+ Future<ParsedUnitResult> getParsedUnit(String path);
+
+ /**
+ * Return information about the results of parsing the file with the given
+ * absolute, normalized [path].
+ *
+ * Deprecated: Use [getParsedUnitSync] instead.
+ */
+ @deprecated
+ ParseResult getParsedAstSync(String path);
+
+ /**
* Return information about the results of parsing the file with the given
* absolute, normalized [path].
*/
- ParseResult getParsedAstSync(String path);
+ ParsedUnitResult getParsedUnitSync(String path);
+
+ /**
+ * Return a future that will complete with information about the results of
+ * resolving the file with the given absolute, normalized [path].
+ *
+ * Deprecated: Use [getResolvedUnit] instead.
+ */
+ @deprecated
+ Future<ResolveResult> getResolvedAst(String path);
/**
* Return a future that will complete with information about the results of
* resolving the file with the given absolute, normalized [path].
*/
- Future<ResolveResult> getResolvedAst(String path);
+ Future<ResolvedUnitResult> getResolvedUnit(String path);
/**
* Return a future that will complete with the source kind of the file with
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 57384a9..3caaee0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -870,7 +870,7 @@
* produced through the [results] stream (just because it is not a fully
* resolved unit).
*/
- Future<ParseResult> parseFile(String path) async {
+ Future<ParsedUnitResult> parseFile(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
return parseFileSync(path);
@@ -887,13 +887,13 @@
* produced through the [results] stream (just because it is not a fully
* resolved unit).
*/
- ParseResult parseFileSync(String path) {
+ ParsedUnitResult parseFileSync(String path) {
_throwIfNotAbsolutePath(path);
FileState file = _fileTracker.verifyApiSignature(path);
RecordingErrorListener listener = new RecordingErrorListener();
CompilationUnit unit = file.parse(listener);
- return new ParseResult(currentSession, file.path, file.uri, file.content,
- file.lineInfo, file.isPart, unit, listener.errors);
+ return new ParsedUnitResult(currentSession, file.path, file.uri,
+ file.content, file.lineInfo, file.isPart, unit, listener.errors);
}
@override
@@ -1923,7 +1923,7 @@
* Every result is independent, and is not guaranteed to be consistent with
* any previously returned result, even inside of the same library.
*/
-class AnalysisResult extends FileResult implements results.ResolveResult {
+class AnalysisResult extends FileResult implements results.ResolvedUnitResult {
static final _UNCHANGED = new AnalysisResult(
null, null, null, null, null, null, null, null, null, null, null, null);
@@ -2099,7 +2099,7 @@
* parsed [unit] correspond to each other. But none of the results is
* guaranteed to be consistent with the state of the files.
*/
-class ParseResult extends FileResult implements results.ParseResult {
+class ParsedUnitResult extends FileResult implements results.ParsedUnitResult {
@override
final String content;
@@ -2109,7 +2109,7 @@
@override
final List<AnalysisError> errors;
- ParseResult(AnalysisSession session, String path, Uri uri, this.content,
+ ParsedUnitResult(AnalysisSession session, String path, Uri uri, this.content,
LineInfo lineInfo, bool isPart, this.unit, this.errors)
: super(session, path, uri, lineInfo, isPart);
diff --git a/pkg/analyzer/lib/src/dart/analysis/session.dart b/pkg/analyzer/lib/src/dart/analysis/session.dart
index ebbbf1d..0150c8b 100644
--- a/pkg/analyzer/lib/src/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/session.dart
@@ -106,21 +106,33 @@
return libraryElement;
}
+ @deprecated
@override
- Future<ParseResult> getParsedAst(String path) async {
+ Future<ParseResult> getParsedAst(String path) => getParsedUnit(path);
+
+ @deprecated
+ @override
+ ParseResult getParsedAstSync(String path) => getParsedUnitSync(path);
+
+ @override
+ Future<ParsedUnitResult> getParsedUnit(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- return getParsedAstSync(path);
+ return getParsedUnitSync(path);
}
@override
- ParseResult getParsedAstSync(String path) {
+ ParsedUnitResult getParsedUnitSync(String path) {
_checkConsistency();
return _driver.parseFileSync(path);
}
+ @deprecated
@override
- Future<ResolveResult> getResolvedAst(String path) {
+ Future<ResolveResult> getResolvedAst(String path) => getResolvedUnit(path);
+
+ @override
+ Future<ResolvedUnitResult> getResolvedUnit(String path) {
_checkConsistency();
return _driver.getResult(path);
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/session_helper.dart b/pkg/analyzer/lib/src/dart/analysis/session_helper.dart
index 8c908bb..191c1bc 100644
--- a/pkg/analyzer/lib/src/dart/analysis/session_helper.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/session_helper.dart
@@ -44,7 +44,7 @@
}
var path = element.source.fullName;
- var resolveResult = await session.getResolvedAst(path);
+ var resolveResult = await session.getResolvedUnit(path);
var unit = resolveResult.unit;
var locator = NodeLocator(element.nameOffset);
var declaration = locator.searchWithin(unit)?.parent;
@@ -72,7 +72,7 @@
/// The result of searching an [Element] declaration in the resolved AST for
/// the file where it is defined.
class ElementDeclarationResult {
- final ResolveResult resolveResult;
+ final ResolvedUnitResult resolveResult;
final AstNode declaration;
ElementDeclarationResult(this.resolveResult, this.declaration);
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 7cd32d8..cfcb6f7 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -2310,7 +2310,7 @@
var p = convertPath('/test/bin/a.txt');
newFile(p, content: 'class A {}');
- ParseResult parseResult = await driver.parseFile(p);
+ ParsedUnitResult parseResult = await driver.parseFile(p);
expect(parseResult, isNotNull);
expect(driver.knownFiles, contains(p));
}
@@ -2327,7 +2327,7 @@
// Update the file.
newFile(p, content: 'class A2 {}');
- ParseResult parseResult = await driver.parseFile(p);
+ ParsedUnitResult parseResult = await driver.parseFile(p);
var clazz = parseResult.unit.declarations[0] as ClassDeclaration;
expect(clazz.name.name, 'A2');
}
@@ -2343,7 +2343,7 @@
var p = convertPath('/test/bin/a.txt');
newFile(p, content: 'class A {}');
- ParseResult parseResult = driver.parseFileSync(p);
+ ParsedUnitResult parseResult = driver.parseFileSync(p);
expect(parseResult, isNotNull);
expect(driver.knownFiles, contains(p));
}
@@ -2360,7 +2360,7 @@
// Update the file.
newFile(p, content: 'class A2 {}');
- ParseResult parseResult = driver.parseFileSync(p);
+ ParsedUnitResult parseResult = driver.parseFileSync(p);
var clazz = parseResult.unit.declarations[0] as ClassDeclaration;
expect(clazz.name.name, 'A2');
}
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index c4304dc..7c8adb3 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -57,17 +57,17 @@
}
test_getParsedAst() async {
- ParseResult result =
- new ParseResult(null, null, null, null, null, null, null, null);
+ ParsedUnitResult result =
+ new ParsedUnitResult(null, null, null, null, null, null, null, null);
driver.parseResult = result;
- expect(await session.getParsedAst('path'), result);
+ expect(await session.getParsedUnit('path'), result);
}
- test_getResolvedAst() async {
+ test_getResolvedUnit() async {
AnalysisResult result = new AnalysisResult(driver, null, null, null, null,
null, null, null, null, null, null, null);
driver.result = result;
- expect(await session.getResolvedAst('path'), result);
+ expect(await session.getResolvedUnit('path'), result);
}
test_getSourceKind() async {
@@ -164,7 +164,7 @@
ErrorsResult errorsResult;
Map<String, LibraryElement> libraryMap = <String, LibraryElement>{};
- ParseResult parseResult;
+ ParsedUnitResult parseResult;
ResourceProvider resourceProvider;
AnalysisResult result;
SourceFactory sourceFactory;
@@ -218,12 +218,12 @@
}
@override
- Future<ParseResult> parseFile(String path) async {
+ Future<ParsedUnitResult> parseFile(String path) async {
return parseResult;
}
@override
- ParseResult parseFileSync(String path) {
+ ParsedUnitResult parseFileSync(String path) {
return parseResult;
}
}
diff --git a/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart b/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart
index 9eb8286..cef3fc1 100644
--- a/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart
@@ -67,7 +67,7 @@
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
String path = parameters.file;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
return new DartAssistRequestImpl(
resourceProvider, parameters.offset, parameters.length, result);
}
diff --git a/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart b/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
index 72de7ce..c612c7b 100644
--- a/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
@@ -68,7 +68,7 @@
CompletionGetSuggestionsParams parameters) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- ResolveResult result = await getResolveResult(parameters.file);
+ ResolvedUnitResult result = await getResolvedUnitResult(parameters.file);
return new DartCompletionRequestImpl(
resourceProvider, parameters.offset, result);
}
diff --git a/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart b/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
index 917dc3e..9efd6f9 100644
--- a/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
@@ -31,12 +31,12 @@
await null;
String path = parameters.file;
int offset = parameters.offset;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
return new DartFixesRequestImpl(
resourceProvider, offset, _getErrors(offset, result), result);
}
- List<AnalysisError> _getErrors(int offset, ResolveResult result) {
+ List<AnalysisError> _getErrors(int offset, ResolvedUnitResult result) {
LineInfo lineInfo = result.lineInfo;
int offsetLine = lineInfo.getLocation(offset).lineNumber;
return result.errors.where((AnalysisError error) {
diff --git a/pkg/analyzer_plugin/lib/plugin/folding_mixin.dart b/pkg/analyzer_plugin/lib/plugin/folding_mixin.dart
index 3c8d88c..43b0e0b 100644
--- a/pkg/analyzer_plugin/lib/plugin/folding_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/folding_mixin.dart
@@ -27,7 +27,7 @@
Future<FoldingRequest> getFoldingRequest(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
return new DartFoldingRequestImpl(resourceProvider, result);
}
}
diff --git a/pkg/analyzer_plugin/lib/plugin/highlights_mixin.dart b/pkg/analyzer_plugin/lib/plugin/highlights_mixin.dart
index a401db8..b80086d 100644
--- a/pkg/analyzer_plugin/lib/plugin/highlights_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/highlights_mixin.dart
@@ -27,7 +27,7 @@
Future<HighlightsRequest> getHighlightsRequest(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
return new DartHighlightsRequestImpl(resourceProvider, result);
}
}
diff --git a/pkg/analyzer_plugin/lib/plugin/kythe_mixin.dart b/pkg/analyzer_plugin/lib/plugin/kythe_mixin.dart
index 999ba57..d09821e 100644
--- a/pkg/analyzer_plugin/lib/plugin/kythe_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/kythe_mixin.dart
@@ -30,7 +30,7 @@
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
String path = parameters.file;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
return new DartEntryRequestImpl(resourceProvider, result);
}
}
diff --git a/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart b/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
index e1e6e28..094e015 100644
--- a/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
@@ -30,7 +30,7 @@
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
String path = parameters.file;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
int offset = parameters.offset;
int length = parameters.length;
if (offset < 0 && length < 0) {
diff --git a/pkg/analyzer_plugin/lib/plugin/occurrences_mixin.dart b/pkg/analyzer_plugin/lib/plugin/occurrences_mixin.dart
index 5766d9b..ffa3fa5 100644
--- a/pkg/analyzer_plugin/lib/plugin/occurrences_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/occurrences_mixin.dart
@@ -27,7 +27,7 @@
Future<OccurrencesRequest> getOccurrencesRequest(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
return new DartOccurrencesRequestImpl(resourceProvider, result);
}
}
diff --git a/pkg/analyzer_plugin/lib/plugin/outline_mixin.dart b/pkg/analyzer_plugin/lib/plugin/outline_mixin.dart
index 96bbdc4..b2040c6 100644
--- a/pkg/analyzer_plugin/lib/plugin/outline_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/outline_mixin.dart
@@ -27,7 +27,7 @@
Future<OutlineRequest> getOutlineRequest(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- ResolveResult result = await getResolveResult(path);
+ ResolvedUnitResult result = await getResolvedUnitResult(path);
return new DartOutlineRequestImpl(resourceProvider, result);
}
}
diff --git a/pkg/analyzer_plugin/lib/plugin/plugin.dart b/pkg/analyzer_plugin/lib/plugin/plugin.dart
index 5fb6296..44ad8e9 100644
--- a/pkg/analyzer_plugin/lib/plugin/plugin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/plugin.dart
@@ -208,7 +208,7 @@
* Throw a [RequestFailure] is the file cannot be analyzed or if the driver
* associated with the file is not an [AnalysisDriver].
*/
- Future<ResolveResult> getResolveResult(String path) async {
+ Future<ResolvedUnitResult> getResolvedUnitResult(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
AnalysisDriverGeneric driver = driverForPath(path);
@@ -217,7 +217,8 @@
throw new RequestFailure(
RequestErrorFactory.pluginError('Failed to analyze $path', null));
}
- ResolveResult result = await (driver as AnalysisDriver).getResult(path);
+ ResolvedUnitResult result =
+ await (driver as AnalysisDriver).getResult(path);
ResultState state = result.state;
if (state != ResultState.VALID) {
// Return an error from the request.
@@ -228,6 +229,16 @@
}
/**
+ * Return the result of analyzing the file with the given [path].
+ *
+ * Throw a [RequestFailure] is the file cannot be analyzed or if the driver
+ * associated with the file is not an [AnalysisDriver].
+ */
+ @deprecated
+ Future<ResolveResult> getResolveResult(String path) =>
+ getResolvedUnitResult(path);
+
+ /**
* Handle an 'analysis.getNavigation' request.
*
* Throw a [RequestFailure] if the request could not be handled.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/assist/assist.dart b/pkg/analyzer_plugin/lib/src/utilities/assist/assist.dart
index dcbe5eb..95b0893 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/assist/assist.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/assist/assist.dart
@@ -36,7 +36,7 @@
final int length;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
index 7618568..173082a 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
@@ -54,7 +54,7 @@
Future<DartFileEditBuilderImpl> createFileEditBuilder(String path) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- ResolveResult result = await session.getResolvedAst(path);
+ ResolvedUnitResult result = await session.getResolvedUnit(path);
ResultState state = result?.state ?? ResultState.INVALID_FILE_TYPE;
if (state == ResultState.INVALID_FILE_TYPE) {
throw new AnalysisException('Cannot analyze "$path"');
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/completion_core.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/completion_core.dart
index 209e451..7bf30d5 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/completion/completion_core.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion/completion_core.dart
@@ -84,7 +84,7 @@
final int offset;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* A flag indicating whether completion has been aborted.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart b/pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart
index 54d9b45..8973624 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart
@@ -23,7 +23,7 @@
final List<AnalysisError> errorsToFix;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/folding/folding.dart b/pkg/analyzer_plugin/lib/src/utilities/folding/folding.dart
index 1e7eb67..2d5578c 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/folding/folding.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/folding/folding.dart
@@ -17,7 +17,7 @@
final ResourceProvider resourceProvider;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/highlights/highlights.dart b/pkg/analyzer_plugin/lib/src/utilities/highlights/highlights.dart
index bb24bcb..8412dac 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/highlights/highlights.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/highlights/highlights.dart
@@ -17,7 +17,7 @@
final ResourceProvider resourceProvider;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/kythe/entries.dart b/pkg/analyzer_plugin/lib/src/utilities/kythe/entries.dart
index 72256df..eb4163a 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/kythe/entries.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/kythe/entries.dart
@@ -15,7 +15,7 @@
final ResourceProvider resourceProvider;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation.dart b/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation.dart
index f8b4b11..31e004b 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation.dart
@@ -23,7 +23,7 @@
final int offset;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/occurrences/occurrences.dart b/pkg/analyzer_plugin/lib/src/utilities/occurrences/occurrences.dart
index 42b95c2..2538191 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/occurrences/occurrences.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/occurrences/occurrences.dart
@@ -16,7 +16,7 @@
final ResourceProvider resourceProvider;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/src/utilities/outline/outline.dart b/pkg/analyzer_plugin/lib/src/utilities/outline/outline.dart
index f87c5fc..47fba67 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/outline/outline.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/outline/outline.dart
@@ -16,7 +16,7 @@
final ResourceProvider resourceProvider;
@override
- final ResolveResult result;
+ final ResolvedUnitResult result;
/**
* Initialize a newly create request with the given data.
diff --git a/pkg/analyzer_plugin/lib/utilities/assist/assist.dart b/pkg/analyzer_plugin/lib/utilities/assist/assist.dart
index 72c3e0d..7e02aea 100644
--- a/pkg/analyzer_plugin/lib/utilities/assist/assist.dart
+++ b/pkg/analyzer_plugin/lib/utilities/assist/assist.dart
@@ -145,5 +145,5 @@
/**
* The analysis result for the file in which the assists are being requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
diff --git a/pkg/analyzer_plugin/lib/utilities/completion/completion_core.dart b/pkg/analyzer_plugin/lib/utilities/completion/completion_core.dart
index c037112..6a354cd 100644
--- a/pkg/analyzer_plugin/lib/utilities/completion/completion_core.dart
+++ b/pkg/analyzer_plugin/lib/utilities/completion/completion_core.dart
@@ -160,5 +160,5 @@
* The analysis result for the file in which the completion is being
* requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
diff --git a/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart b/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart
index 3b0ab66..377fe37 100644
--- a/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart
+++ b/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart
@@ -20,7 +20,7 @@
/**
* The analysis result for the file in which the fixes are being requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
/**
@@ -147,11 +147,6 @@
final String appliedTogetherMessage;
/**
- * The change can be made with other fixes of this [FixKind].
- */
- bool canBeAppliedTogether() => appliedTogetherMessage != null;
-
- /**
* Initialize a newly created kind of fix to have the given [name],
* [priority], [message], and optionally [canBeAppliedTogether] and
* [appliedTogetherMessage].
@@ -160,11 +155,16 @@
{this.appliedTogetherMessage: null});
@override
- String toString() => name;
+ int get hashCode => name.hashCode;
@override
bool operator ==(o) => o is FixKind && o.name == name;
+ /**
+ * The change can be made with other fixes of this [FixKind].
+ */
+ bool canBeAppliedTogether() => appliedTogetherMessage != null;
+
@override
- int get hashCode => name.hashCode;
+ String toString() => name;
}
diff --git a/pkg/analyzer_plugin/lib/utilities/folding/folding.dart b/pkg/analyzer_plugin/lib/utilities/folding/folding.dart
index 7eab6ad..6408d2f 100644
--- a/pkg/analyzer_plugin/lib/utilities/folding/folding.dart
+++ b/pkg/analyzer_plugin/lib/utilities/folding/folding.dart
@@ -23,7 +23,7 @@
* The analysis result for the file for which the folding regions are being
* requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
/**
diff --git a/pkg/analyzer_plugin/lib/utilities/highlights/highlights.dart b/pkg/analyzer_plugin/lib/utilities/highlights/highlights.dart
index 59acbe4..f24b280 100644
--- a/pkg/analyzer_plugin/lib/utilities/highlights/highlights.dart
+++ b/pkg/analyzer_plugin/lib/utilities/highlights/highlights.dart
@@ -22,7 +22,7 @@
* The analysis result for the file for which the highlight regions are being
* requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
/**
diff --git a/pkg/analyzer_plugin/lib/utilities/kythe/entries.dart b/pkg/analyzer_plugin/lib/utilities/kythe/entries.dart
index b89cab9..11b42d1 100644
--- a/pkg/analyzer_plugin/lib/utilities/kythe/entries.dart
+++ b/pkg/analyzer_plugin/lib/utilities/kythe/entries.dart
@@ -20,7 +20,7 @@
/**
* The analysis result for the file in which the entries are being requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
/**
diff --git a/pkg/analyzer_plugin/lib/utilities/navigation/navigation.dart b/pkg/analyzer_plugin/lib/utilities/navigation/navigation.dart
index d3233bc..3bc3471 100644
--- a/pkg/analyzer_plugin/lib/utilities/navigation/navigation.dart
+++ b/pkg/analyzer_plugin/lib/utilities/navigation/navigation.dart
@@ -23,7 +23,7 @@
* The analysis result for the file in which the navigation regions are being
* requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
/**
diff --git a/pkg/analyzer_plugin/lib/utilities/occurrences/occurrences.dart b/pkg/analyzer_plugin/lib/utilities/occurrences/occurrences.dart
index 820f38e..1fe0c1b 100644
--- a/pkg/analyzer_plugin/lib/utilities/occurrences/occurrences.dart
+++ b/pkg/analyzer_plugin/lib/utilities/occurrences/occurrences.dart
@@ -22,7 +22,7 @@
* The analysis result for the file for which the occurrences information is
* being requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
/**
diff --git a/pkg/analyzer_plugin/lib/utilities/outline/outline.dart b/pkg/analyzer_plugin/lib/utilities/outline/outline.dart
index f675976..21983f6 100644
--- a/pkg/analyzer_plugin/lib/utilities/outline/outline.dart
+++ b/pkg/analyzer_plugin/lib/utilities/outline/outline.dart
@@ -21,7 +21,7 @@
/**
* The analysis result for the file for which the outline is being requested.
*/
- ResolveResult get result;
+ ResolvedUnitResult get result;
}
/**
diff --git a/pkg/analyzer_plugin/test/utilities/completion/completion_contributor_util.dart b/pkg/analyzer_plugin/test/utilities/completion/completion_contributor_util.dart
index f3c81e6..6fe32fb 100644
--- a/pkg/analyzer_plugin/test/utilities/completion/completion_contributor_util.dart
+++ b/pkg/analyzer_plugin/test/utilities/completion/completion_contributor_util.dart
@@ -451,7 +451,7 @@
}
Future computeSuggestions() async {
- ResolveResult result = await driver.getResult(testFile);
+ ResolvedUnitResult result = await driver.getResult(testFile);
testSource = result.unit.declaredElement.source;
request = new DartCompletionRequestImpl(
resourceProvider, completionOffset, result);
diff --git a/pkg/analyzer_plugin/test/utilities/navigation_test.dart b/pkg/analyzer_plugin/test/utilities/navigation_test.dart
index 2ea27bfd..4599c44 100644
--- a/pkg/analyzer_plugin/test/utilities/navigation_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/navigation_test.dart
@@ -18,7 +18,7 @@
@reflectiveTest
class NavigationGeneratorTest with ResourceProviderMixin {
- ResolveResult resolveResult = new MockAnalysisResult(path: 'a.dart');
+ ResolvedUnitResult resolveResult = new MockAnalysisResult(path: 'a.dart');
test_none() {
NavigationGenerator generator = new NavigationGenerator([]);
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
Patch set 1:Code-Review +1
1 comment:
File pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart:
Patch Set #1, Line 16: resolveResult
resolve_D_Result?
Or even `unitResult`?
Or postpone reviewing these names for later?
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
Patch Set #1, Line 16: resolveResult
resolve_D_Result? […]
Given that they're outside the public API, I'm fine with leaving them until later, but if you want to comment on them now (while it's easier to find them) I'm happy to change them now as well.
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
Patch Set #1, Line 16: resolveResult
Given that they're outside the public API, I'm fine with leaving them until later, but if you want t […]
It is not important for me when we do this.
I was just thinking what names we would want to have for these new results.
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
All the comments except the one at pkg/analyzer/lib/dart/analysis/session.dart:98 are just suggestions; I'm happy to defer to you for final nomenclature decisions.
6 comments:
Patch Set #1, Line 16: resolveResult
resolve_D_Result? […]
I also have a slight preference for "ResolveUnitResult", since it means "the result of resolving the unit". Sorry for saying "ResolvedUnitResult" earlier; I misquoted Konstantin's suggestion.
File pkg/analyzer/lib/dart/analysis/results.dart:
Patch Set #1, Line 85: ParsedUnitResult
Would "ParseUnitResult" be a better name?
File pkg/analyzer/lib/dart/analysis/session.dart:
Patch Set #1, Line 83: getParsedUnit
How about just "parseUnit"?
Patch Set #1, Line 98: ParsedUnitResult getParsedUnitSync(String path);
What's the relationship between "getParsedUnitSync" and "getParsedUnit"? Do they have the same capabilities? Or is the async version better in some way (e.g. maybe "getParsedUnitSync" will be removed in a future version of the API? Or maybe in some cases "getParsedUnitSync" might fail?)
If neither is better than the other, then I don't think we need both of them; we can just have a synchronous "getParsedUnit", and there's no problem if asynchronous clients call it.
If they the async version is better in some way, that should be documented.
Patch Set #1, Line 113: getResolvedUnit
How about "resolveUnit"?
File pkg/analyzer_plugin/lib/plugin/plugin.dart:
Patch Set #1, Line 211: getResolvedUnitResult
This name seems unwieldy to me. How about just "resolveUnit"?
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
File pkg/analyzer/lib/dart/analysis/session.dart:
Patch Set #1, Line 113: getResolvedUnit
How about "resolveUnit"?
`resolveUnit` would be better, sure.
What stopped me from suggesting this is that I don't know the consistent name for `getErrors()` or `getUnitElement()`.
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
3 comments:
Patch Set #1, Line 16: resolveResult
I also have a slight preference for "ResolveUnitResult" ...
Hm. I thought Konstantin was commenting on the name of the getter rather than the return type.
In any case, I chose this name because "resolve" is a verb while "resolved" is an adjective, and we generally name classes with noun phrases unless they represent an algorithm more than a data structure. Same for "parse" vs "parsed".
File pkg/analyzer/lib/dart/analysis/session.dart:
Patch Set #1, Line 98: ParsedUnitResult getParsedUnitSync(String path);
What's the relationship between "getParsedUnitSync" and "getParsedUnit"? Do they have the same capa […]
I think this was actually an historic accident. I think we had the async version first, then discovered clients that needed the sync version and added it. I'm happy to get rid of the async version. (The async just calls the sync version.)
Konstantin: any reason you know of not to simplify?
Patch Set #1, Line 113: getResolvedUnit
`resolveUnit` would be better, sure. […]
Consistency across the result returning methods isn't a requirement, but it's kind of nice in some ways. As it stands, a method that returns a "FooResult" is named "getFoo", but the inverse doesn't hold, so...
I'm also not fond of "get" as a prefix and considered using "compute" instead, in part because it sounds like more work and might help convey that these are not inexpensive methods.
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
Patch Set #1, Line 98: ParsedUnitResult getParsedUnitSync(String path);
I think this was actually an historic accident. […]
Yes, actually "async" was before "sync" here.
At least one client uses "sync" model before, and I migrated it to the "sync" version.
https://github.com/dart-lang/pub/blob/master/lib/src/dart.dart#L112
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.
Brian Wilkerson abandoned this change.
To view, visit change 81960. To unsubscribe, or for help writing mail filters, visit settings.