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

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

Issue 657593002: include locally inherited members in suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/completion_test_util.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.computer.dart.local; 5 library services.completion.computer.dart.local;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 @override 97 @override
98 visitCatchClause(CatchClause node) { 98 visitCatchClause(CatchClause node) {
99 _addParamSuggestion(node.exceptionParameter, node.exceptionType); 99 _addParamSuggestion(node.exceptionParameter, node.exceptionType);
100 _addParamSuggestion(node.stackTraceParameter, STACKTRACE_TYPE); 100 _addParamSuggestion(node.stackTraceParameter, STACKTRACE_TYPE);
101 visitNode(node); 101 visitNode(node);
102 } 102 }
103 103
104 @override 104 @override
105 visitClassDeclaration(ClassDeclaration node) { 105 visitClassDeclaration(ClassDeclaration node) {
106 _addClassDeclarationMembers(node);
107 _addInheritedTypeMembers(node);
108 visitNode(node);
109 }
110
111 void _addInheritedTypeMembers(ClassDeclaration node) {
112 ExtendsClause extendsClause = node.extendsClause;
113 if (extendsClause != null) {
114 _addLocalTypeMembers(extendsClause.superclass, node);
115 }
116 ImplementsClause implementsClause = node.implementsClause;
117 if (implementsClause != null) {
118 NodeList<TypeName> interfaces = implementsClause.interfaces;
119 if (interfaces != null) {
120 interfaces.forEach((TypeName type) {
121 _addLocalTypeMembers(type, node);
122 });
123 }
124 }
125 WithClause withClause = node.withClause;
126 if (withClause != null) {
127 NodeList<TypeName> mixinTypes = withClause.mixinTypes;
128 if (mixinTypes != null) {
129 mixinTypes.forEach((TypeName type) {
130 _addLocalTypeMembers(type, node);
131 });
132 }
133 }
134 }
135
136 void _addLocalTypeMembers(TypeName type, ClassDeclaration node) {
137 if (type == null) {
138 return;
139 }
140 Identifier typeId = type.name;
141 if (typeId == null) {
142 return;
143 }
144 String typeName = typeId.name;
145 if (typeName == null || typeName.length == 0) {
146 return;
147 }
148 CompilationUnit unit = node.getAncestor((p) => p is CompilationUnit);
149 if (unit == null) {
150 return;
151 }
152 unit.declarations.forEach((CompilationUnitMember m) {
153 if (m is ClassDeclaration) {
154 SimpleIdentifier id = m.name;
155 if (id != null) {
156 if (id.name == typeName) {
157 _addClassDeclarationMembers(m);
158 _addInheritedTypeMembers(m);
159 }
160 }
161 }
162 });
163 }
164
165 void _addClassDeclarationMembers(ClassDeclaration node) {
106 node.members.forEach((ClassMember classMbr) { 166 node.members.forEach((ClassMember classMbr) {
107 if (classMbr is FieldDeclaration) { 167 if (classMbr is FieldDeclaration) {
108 _addFieldSuggestions(node, classMbr); 168 _addFieldSuggestions(node, classMbr);
109 } else if (classMbr is MethodDeclaration) { 169 } else if (classMbr is MethodDeclaration) {
110 _addMethodSuggestion(node, classMbr); 170 _addMethodSuggestion(node, classMbr);
111 } 171 }
112 }); 172 });
113 visitNode(node);
114 } 173 }
115 174
116 @override 175 @override
117 visitCombinator(Combinator node) { 176 visitCombinator(Combinator node) {
118 // Handled by ImportedComputer 177 // Handled by ImportedComputer
119 } 178 }
120 179
121 @override 180 @override
122 visitCompilationUnit(CompilationUnit node) { 181 visitCompilationUnit(CompilationUnit node) {
123 node.declarations.forEach((Declaration declaration) { 182 node.declarations.forEach((Declaration declaration) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (name == null || name.length <= 0) { 560 if (name == null || name.length <= 0) {
502 return DYNAMIC; 561 return DYNAMIC;
503 } 562 }
504 TypeArgumentList typeArgs = type.typeArguments; 563 TypeArgumentList typeArgs = type.typeArguments;
505 if (typeArgs != null) { 564 if (typeArgs != null) {
506 //TODO (danrubel) include type arguments 565 //TODO (danrubel) include type arguments
507 } 566 }
508 return name; 567 return name;
509 } 568 }
510 } 569 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/completion_test_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698