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

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

Issue 690793004: make deprecated elements have low suggestion relevance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 1 month 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_server.dart' as protocol; 7 import 'package:analysis_server/src/protocol_server.dart' as protocol;
8 import 'package:analysis_server/src/protocol_server.dart' hide Element, 8 import 'package:analysis_server/src/protocol_server.dart' hide Element,
9 ElementKind; 9 ElementKind;
10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 if (elementLibrary != unitLibrary) { 276 if (elementLibrary != unitLibrary) {
277 return; 277 return;
278 } 278 }
279 } 279 }
280 String completion = element.displayName; 280 String completion = element.displayName;
281 if (completion == null || 281 if (completion == null ||
282 completion.length <= 0 || 282 completion.length <= 0 ||
283 !_completions.add(completion)) { 283 !_completions.add(completion)) {
284 return; 284 return;
285 } 285 }
286 bool isDeprecated = element.isDeprecated;
286 CompletionSuggestion suggestion = new CompletionSuggestion( 287 CompletionSuggestion suggestion = new CompletionSuggestion(
287 kind, 288 kind,
288 CompletionRelevance.DEFAULT, 289 isDeprecated ? CompletionRelevance.LOW : CompletionRelevance.DEFAULT,
289 completion, 290 completion,
290 completion.length, 291 completion.length,
291 0, 292 0,
292 element.isDeprecated, 293 isDeprecated,
293 false); 294 false);
294 suggestion.element = protocol.newElement_fromEngine(element); 295 suggestion.element = protocol.newElement_fromEngine(element);
295 if (suggestion.element != null) { 296 if (suggestion.element != null) {
296 if (element is FieldElement) { 297 if (element is FieldElement) {
297 suggestion.element.kind = protocol.ElementKind.GETTER; 298 suggestion.element.kind = protocol.ElementKind.GETTER;
298 suggestion.element.returnType = 299 suggestion.element.returnType =
299 element.type != null ? element.type.displayName : 'dynamic'; 300 element.type != null ? element.type.displayName : 'dynamic';
300 } 301 }
301 } 302 }
302 if (enclosingElement != null) { 303 if (enclosingElement != null) {
303 suggestion.declaringType = enclosingElement.displayName; 304 suggestion.declaringType = enclosingElement.displayName;
304 } 305 }
305 if (type != null) { 306 if (type != null) {
306 String typeName = type.displayName; 307 String typeName = type.displayName;
307 if (typeName != null && typeName.length > 0 && typeName != 'dynamic') { 308 if (typeName != null && typeName.length > 0 && typeName != 'dynamic') {
308 suggestion.returnType = typeName; 309 suggestion.returnType = typeName;
309 } 310 }
310 } 311 }
311 request.suggestions.add(suggestion); 312 request.suggestions.add(suggestion);
312 } 313 }
313 } 314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698