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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart/inherited_reference_contributor.dart

Issue 2565633002: Reorganize InheritedRefenenceContributor to serve angular completion (Closed)
Patch Set: Fix bad merge. Tests passing. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.completion.contributor.dart.inherited_ref; 5 library services.completion.contributor.dart.inherited_ref;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart'; 9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart';
10 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart'; 10 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 @override 56 @override
57 CompletionSuggestionKind kind; 57 CompletionSuggestionKind kind;
58 58
59 @override 59 @override
60 Future<List<CompletionSuggestion>> computeSuggestions( 60 Future<List<CompletionSuggestion>> computeSuggestions(
61 DartCompletionRequest request) async { 61 DartCompletionRequest request) async {
62 if (!request.includeIdentifiers) { 62 if (!request.includeIdentifiers) {
63 return EMPTY_LIST; 63 return EMPTY_LIST;
64 } 64 }
65
65 ClassDeclaration classDecl = _enclosingClass(request.target); 66 ClassDeclaration classDecl = _enclosingClass(request.target);
66 if (classDecl == null || classDecl.element == null) { 67 if (classDecl == null || classDecl.element == null) {
67 return EMPTY_LIST; 68 return EMPTY_LIST;
68 } 69 }
70 containingLibrary = request.libraryElement;
71 return _computeSuggestionsForClass2(resolutionMap
72 .elementDeclaredByClassDeclaration(classDecl), request);
73 }
69 74
70 containingLibrary = request.libraryElement; 75 List<CompletionSuggestion> _computeSuggestionsForClass2(
76 ClassElement classElement, DartCompletionRequest request,
77 {bool skipChildClass: true}) {
71 bool isFunctionalArgument = request.target.isFunctionalArgument(); 78 bool isFunctionalArgument = request.target.isFunctionalArgument();
72 kind = isFunctionalArgument 79 kind = isFunctionalArgument
73 ? CompletionSuggestionKind.IDENTIFIER 80 ? CompletionSuggestionKind.IDENTIFIER
74 : CompletionSuggestionKind.INVOCATION; 81 : CompletionSuggestionKind.INVOCATION;
75 OpType optype = (request as DartCompletionRequestImpl).opType; 82 OpType optype = request.opType;
76 for (InterfaceType type in resolutionMap 83
77 .elementDeclaredByClassDeclaration(classDecl) 84 if (!skipChildClass) {
78 .allSupertypes) { 85 _addSuggestionsForType(classElement.type, optype,
79 if (!isFunctionalArgument) { 86 isFunctionalArgument: isFunctionalArgument);
80 for (PropertyAccessorElement elem in type.accessors) { 87 }
81 if (elem.isGetter) { 88
82 if (optype.includeReturnValueSuggestions) { 89 for (InterfaceType type in classElement.allSupertypes) {
83 addSuggestion(elem); 90 _addSuggestionsForType(type, optype,
84 } 91 isFunctionalArgument: isFunctionalArgument);
85 } else { 92 }
86 if (optype.includeVoidReturnSuggestions) { 93 return suggestions;
87 addSuggestion(elem); 94 }
88 } 95
89 } 96 List<CompletionSuggestion> computeSuggestionsForClass(
90 } 97 ClassElement classElement, DartCompletionRequest request,
91 } 98 {bool skipChildClass: true}) {
92 for (MethodElement elem in type.methods) { 99 if (!request.includeIdentifiers) {
93 if (elem.returnType == null) { 100 return EMPTY_LIST;
94 addSuggestion(elem); 101 }
95 } else if (!elem.returnType.isVoid) { 102 containingLibrary = request.libraryElement;
103
104 return _computeSuggestionsForClass2(classElement, request,
105 skipChildClass: skipChildClass);
106 }
107
108 _addSuggestionsForType(InterfaceType type, OpType optype,
109 {bool isFunctionalArgument: false}) {
110 if (!isFunctionalArgument) {
111 for (PropertyAccessorElement elem in type.accessors) {
112 if (elem.isGetter) {
96 if (optype.includeReturnValueSuggestions) { 113 if (optype.includeReturnValueSuggestions) {
97 addSuggestion(elem); 114 addSuggestion(elem);
98 } 115 }
99 } else { 116 } else {
100 if (optype.includeVoidReturnSuggestions) { 117 if (optype.includeVoidReturnSuggestions) {
101 addSuggestion(elem); 118 addSuggestion(elem);
102 } 119 }
103 } 120 }
104 } 121 }
105 } 122 }
106 return suggestions; 123 for (MethodElement elem in type.methods) {
124 if (elem.returnType == null) {
125 addSuggestion(elem);
126 } else if (!elem.returnType.isVoid) {
127 if (optype.includeReturnValueSuggestions) {
128 addSuggestion(elem);
129 }
130 } else {
131 if (optype.includeVoidReturnSuggestions) {
132 addSuggestion(elem);
133 }
134 }
135 }
107 } 136 }
108 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698