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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart

Issue 1520613003: simplify contributors by resolving declarations in scope (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart
index fdfb3537a12ad06e49c95d89df7ecfd760e94774..2ab41e3daa40a674273edc86864742333c2a9bbd 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart
@@ -26,26 +26,10 @@ class InheritedContributor implements DartCompletionContributor {
@override
Future<List<CompletionSuggestion>> computeSuggestions(
DartCompletionRequest request) async {
- // Determine if the target looks like a partial identifier
- // inside a class declaration
SimpleIdentifier targetId = _getTargetId(request.target);
if (targetId == null) {
return EMPTY_LIST;
}
-
- // Partially resolve the compilation unit
- CompilationUnit unit = await request.resolveDeclarationsInScope();
- // Gracefully degrade if the compilation unit could not be resolved
- // e.g. detached part file or source change
- if (unit == null) {
- return EMPTY_LIST;
- }
-
- // Recompute the target since resolution may have changed it
- targetId = _getTargetId(request.target);
- if (targetId == null) {
- return EMPTY_LIST;
- }
ClassDeclaration classDecl =
targetId.getAncestor((p) => p is ClassDeclaration);
if (classDecl == null) {
@@ -65,7 +49,7 @@ class InheritedContributor implements DartCompletionContributor {
// Gracefully degrade if the overridden element has not been resolved.
if (element.returnType != null) {
CompletionSuggestion suggestion =
- _buildSuggestion(request, targetId, unit, element);
+ _buildSuggestion(request, targetId, element);
if (suggestion != null) {
suggestions.add(suggestion);
}
@@ -119,13 +103,10 @@ class InheritedContributor implements DartCompletionContributor {
* Build a suggestion to replace [targetId] in the given [unit]
* with an override of the given [element].
*/
- CompletionSuggestion _buildSuggestion(
- DartCompletionRequest request,
- SimpleIdentifier targetId,
- CompilationUnit unit,
- ExecutableElement element) {
- String completion =
- _buildRepacementText(request.source, targetId, unit, element);
+ CompletionSuggestion _buildSuggestion(DartCompletionRequest request,
+ SimpleIdentifier targetId, ExecutableElement element) {
+ String completion = _buildRepacementText(
+ request.source, targetId, request.target.unit, element);
if (completion == null || completion.length == 0) {
return null;
}

Powered by Google App Engine
This is Rietveld 408576698