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

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

Issue 1516473002: CombinatorContributor and LibraryMemberContributor - consolidate common behavior (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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index fa0cf959fe6291f38be82ebac8d1ddc971c625b6..0e395fad544c849c022929eb8eaf12feb8b6e323 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -112,9 +112,9 @@ abstract class ElementSuggestionBuilder {
CompletionSuggestionKind get kind;
/**
- * Return the request on which the builder is operating.
+ * Return the library in which the completion is requested.
*/
- DartCompletionRequest get request;
+ LibraryElement get containingLibrary;
/**
* Add a suggestion based upon the given element.
@@ -122,13 +122,7 @@ abstract class ElementSuggestionBuilder {
void addSuggestion(Element element,
{String prefix, int relevance: DART_RELEVANCE_DEFAULT}) {
if (element.isPrivate) {
- LibraryElement elementLibrary = element.library;
- CompilationUnitElement unitElem = request.target.unit.element;
- if (unitElem == null) {
- return;
- }
- LibraryElement unitLibrary = unitElem.library;
- if (elementLibrary != unitLibrary) {
+ if (element.library != containingLibrary) {
return;
}
}
@@ -173,18 +167,17 @@ abstract class ElementSuggestionBuilder {
/**
* This class visits elements in a library and provides suggestions based upon
- * the visible members in that library. Clients should call
- * [LibraryElementSuggestionBuilder.suggestionsFor].
+ * the visible members in that library.
*/
class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor
with ElementSuggestionBuilder {
- final DartCompletionRequest request;
+ final LibraryElement containingLibrary;
final CompletionSuggestionKind kind;
final bool typesOnly;
final bool instCreation;
LibraryElementSuggestionBuilder(
- this.request, this.kind, this.typesOnly, this.instCreation);
+ this.containingLibrary, this.kind, this.typesOnly, this.instCreation);
@override
visitClassElement(ClassElement element) {
@@ -244,19 +237,4 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor
addSuggestion(element);
}
}
-
- /**
- * Add suggestions for the visible members in the given library
- */
- static void suggestionsFor(
- DartCompletionRequest request,
- CompletionSuggestionKind kind,
- LibraryElement library,
- bool typesOnly,
- bool instCreation) {
- if (library != null) {
- library.visitChildren(new LibraryElementSuggestionBuilder(
- request, kind, typesOnly, instCreation));
- }
- }
}
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698