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

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

Issue 489813002: include inherited members in invocation suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/invocation_computer_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/services/completion/completion_suggestion.da rt'; 7 import 'package:analysis_server/src/services/completion/completion_suggestion.da rt';
8 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 8 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 10
11 /** 11 /**
12 * This class visits elements in a class and provides suggestions based upon 12 * This class visits elements in a class and provides suggestions based upon
13 * the visible members in that class. Clients should call 13 * the visible members in that class. Clients should call
14 * [ClassElementSuggestionBuilder.suggestionsFor]. 14 * [ClassElementSuggestionBuilder.suggestionsFor].
15 */ 15 */
16 class ClassElementSuggestionBuilder extends GeneralizingElementVisitor { 16 class ClassElementSuggestionBuilder extends GeneralizingElementVisitor {
17 final DartCompletionRequest request; 17 final DartCompletionRequest request;
18 final Set<String> _completions = new Set<String>();
18 19
19 ClassElementSuggestionBuilder(this.request); 20 ClassElementSuggestionBuilder(this.request);
20 21
21 @override 22 @override
22 visitClassElement(ClassElement element) { 23 visitClassElement(ClassElement element) {
23 element.visitChildren(this); 24 element.visitChildren(this);
25 element.allSupertypes.forEach((InterfaceType type) {
26 type.element.visitChildren(this);
27 });
24 } 28 }
25 29
26 @override 30 @override
27 visitElement(Element element) { 31 visitElement(Element element) {
28 // ignored 32 // ignored
29 } 33 }
30 34
31 @override 35 @override
32 visitFieldElement(FieldElement element) { 36 visitFieldElement(FieldElement element) {
33 _addSuggestion(element, CompletionSuggestionKind.FIELD); 37 _addSuggestion(element, CompletionSuggestionKind.FIELD);
(...skipping 20 matching lines...) Expand all
54 if (element.isPrivate) { 58 if (element.isPrivate) {
55 LibraryElement elementLibrary = 59 LibraryElement elementLibrary =
56 element.getAncestor((parent) => parent is LibraryElement); 60 element.getAncestor((parent) => parent is LibraryElement);
57 LibraryElement unitLibrary = 61 LibraryElement unitLibrary =
58 request.unit.element.getAncestor((parent) => parent is LibraryElement) ; 62 request.unit.element.getAncestor((parent) => parent is LibraryElement) ;
59 if (elementLibrary != unitLibrary) { 63 if (elementLibrary != unitLibrary) {
60 return; 64 return;
61 } 65 }
62 } 66 }
63 String completion = element.displayName; 67 String completion = element.displayName;
64 if (completion == null || completion.length <= 0) { 68 if (completion == null ||
69 completion.length <= 0 ||
70 !_completions.add(completion)) {
65 return; 71 return;
66 } 72 }
67 request.suggestions.add( 73 request.suggestions.add(
68 new CompletionSuggestion( 74 new CompletionSuggestion(
69 kind, 75 kind,
70 CompletionRelevance.DEFAULT, 76 CompletionRelevance.DEFAULT,
71 completion, 77 completion,
72 completion.length, 78 completion.length,
73 0, 79 0,
74 element.isDeprecated, 80 element.isDeprecated,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 /** 147 /**
142 * Add suggestions for the visible members in the given library 148 * Add suggestions for the visible members in the given library
143 */ 149 */
144 static void suggestionsFor(DartCompletionRequest request, 150 static void suggestionsFor(DartCompletionRequest request,
145 LibraryElement library) { 151 LibraryElement library) {
146 if (library != null) { 152 if (library != null) {
147 library.visitChildren(new LibraryElementSuggestionBuilder(request)); 153 library.visitChildren(new LibraryElementSuggestionBuilder(request));
148 } 154 }
149 } 155 }
150 } 156 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/invocation_computer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698