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

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

Issue 628293004: Remove references to Engine classes from protocol.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
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.suggestion.builder; 5 library services.completion.suggestion.builder;
6 6
7 import 'package:analysis_server/src/protocol.dart' as protocol show Element, Ele mentKind; 7 import 'package:analysis_server/src/protocol_server.dart' as protocol;
8 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; 8 import 'package:analysis_server/src/protocol_server.dart' hide Element, ElementK ind;
9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
11 11
12 /** 12 /**
13 * This class visits elements in a class and provides suggestions based upon 13 * This class visits elements in a class and provides suggestions based upon
14 * the visible members in that class. Clients should call 14 * the visible members in that class. Clients should call
15 * [ClassElementSuggestionBuilder.suggestionsFor]. 15 * [ClassElementSuggestionBuilder.suggestionsFor].
16 */ 16 */
17 class ClassElementSuggestionBuilder extends GeneralizingElementVisitor { 17 class ClassElementSuggestionBuilder extends GeneralizingElementVisitor {
18 final DartCompletionRequest request; 18 final DartCompletionRequest request;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return; 89 return;
90 } 90 }
91 CompletionSuggestion suggestion = new CompletionSuggestion( 91 CompletionSuggestion suggestion = new CompletionSuggestion(
92 kind, 92 kind,
93 CompletionRelevance.DEFAULT, 93 CompletionRelevance.DEFAULT,
94 completion, 94 completion,
95 completion.length, 95 completion.length,
96 0, 96 0,
97 element.isDeprecated, 97 element.isDeprecated,
98 false); 98 false);
99 suggestion.element = new protocol.Element.fromEngine(element); 99 suggestion.element = newElement_fromEngine(element);
100 if (suggestion.element != null) { 100 if (suggestion.element != null) {
101 if (element is FieldElement) { 101 if (element is FieldElement) {
102 suggestion.element.kind = protocol.ElementKind.GETTER; 102 suggestion.element.kind = protocol.ElementKind.GETTER;
103 suggestion.element.returnType = 103 suggestion.element.returnType =
104 element.type != null ? element.type.displayName : 'dynamic'; 104 element.type != null ? element.type.displayName : 'dynamic';
105 } 105 }
106 } 106 }
107 if (enclosingElement != null) { 107 if (enclosingElement != null) {
108 suggestion.declaringType = enclosingElement.displayName; 108 suggestion.declaringType = enclosingElement.displayName;
109 } 109 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 @override 160 @override
161 visitTopLevelVariableElement(TopLevelVariableElement element) { 161 visitTopLevelVariableElement(TopLevelVariableElement element) {
162 _addSuggestion(element); 162 _addSuggestion(element);
163 } 163 }
164 164
165 void _addSuggestion(Element element) { 165 void _addSuggestion(Element element) {
166 if (element != null) { 166 if (element != null) {
167 String completion = element.name; 167 String completion = element.name;
168 if (completion != null && completion.length > 0) { 168 if (completion != null && completion.length > 0) {
169 CompletionSuggestion suggestion = new CompletionSuggestion( 169 CompletionSuggestion suggestion = new CompletionSuggestion(
170 new CompletionSuggestionKind.fromElementKind(element.kind), 170 protocol.newCompletionSuggestionKind_fromElementKind(element.kind),
171 CompletionRelevance.DEFAULT, 171 CompletionRelevance.DEFAULT,
172 completion, 172 completion,
173 completion.length, 173 completion.length,
174 0, 174 0,
175 element.isDeprecated, 175 element.isDeprecated,
176 false); 176 false);
177 177
178 suggestion.element = new protocol.Element.fromEngine(element); 178 suggestion.element = newElement_fromEngine(element);
179 179
180 request.suggestions.add(suggestion); 180 request.suggestions.add(suggestion);
181 } 181 }
182 } 182 }
183 } 183 }
184 184
185 /** 185 /**
186 * Add suggestions for the visible members in the given library 186 * Add suggestions for the visible members in the given library
187 */ 187 */
188 static void suggestionsFor(DartCompletionRequest request, 188 static void suggestionsFor(DartCompletionRequest request,
189 LibraryElement library) { 189 LibraryElement library) {
190 if (library != null) { 190 if (library != null) {
191 library.visitChildren(new LibraryElementSuggestionBuilder(request)); 191 library.visitChildren(new LibraryElementSuggestionBuilder(request));
192 } 192 }
193 } 193 }
194 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698