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

Unified Diff: pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart

Issue 2934133002: Change to accommade Angular plugin and finalize removal of dependency to analysis_server (Closed)
Patch Set: Feedback changes Created 3 years, 6 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 | « pkg/analyzer_plugin/lib/utilities/completion/inherited_reference_contributor.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart
diff --git a/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart b/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart
index ec5b94ba7cae02006cf7a3e7bf1e5371bca5884b..d6cb2e8648ed3f04623f5e491d41be1a2841e52d 100644
--- a/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart
+++ b/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart
@@ -22,6 +22,32 @@ import 'package:analyzer_plugin/utilities/completion/suggestion_builder.dart';
* invocations and accesses.
*/
class TypeMemberContributor implements CompletionContributor {
+ /**
+ * Clients should not overload this function.
+ */
+ Future<Null> computeSuggestionsWithEntryPoint(CompletionRequest request,
+ CompletionCollector collector, AstNode entryPoint) async {
+ LibraryElement containingLibrary = request.result.libraryElement;
+ // Gracefully degrade if the library element is not resolved
+ // e.g. detached part file or source change
+ if (containingLibrary == null) {
+ return;
+ }
+
+ // Recompute the target since resolution may have changed it
+ Expression expression = _computeDotTarget(request, entryPoint);
+ if (expression == null || expression.isSynthetic) {
+ return;
+ }
+ _computeSuggestions(request, collector, containingLibrary, expression);
+ }
+
+ /**
+ * Plugin contributors should primarily overload this function.
+ * Should more parameters be needed for autocompletion needs, the
+ * overloaded function should define those parameters and
+ * call on `computeSuggestionsWithEntryPoint`.
+ */
@override
Future<Null> computeSuggestions(
CompletionRequest request, CompletionCollector collector) async {
@@ -33,10 +59,18 @@ class TypeMemberContributor implements CompletionContributor {
}
// Recompute the target since resolution may have changed it
- Expression expression = _computeDotTarget(request);
+ Expression expression = _computeDotTarget(request, null);
if (expression == null || expression.isSynthetic) {
return;
}
+ _computeSuggestions(request, collector, containingLibrary, expression);
+ }
+
+ void _computeSuggestions(
+ CompletionRequest request,
+ CompletionCollector collector,
+ LibraryElement containingLibrary,
+ Expression expression) {
if (expression is Identifier) {
Element element = expression.bestElement;
if (element is ClassElement) {
@@ -106,9 +140,10 @@ class TypeMemberContributor implements CompletionContributor {
/**
* Update the completion [target] and [dotTarget] based on the given [unit].
*/
- Expression _computeDotTarget(CompletionRequest request) {
- CompletionTarget target =
- new CompletionTarget.forOffset(request.result.unit, request.offset);
+ Expression _computeDotTarget(CompletionRequest request, AstNode entryPoint) {
+ CompletionTarget target = new CompletionTarget.forOffset(
+ request.result.unit, request.offset,
+ entryPoint: entryPoint);
AstNode node = target.containingNode;
if (node is MethodInvocation) {
if (identical(node.methodName, target.entity)) {
« no previous file with comments | « pkg/analyzer_plugin/lib/utilities/completion/inherited_reference_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698