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

Side by Side Diff: pkg/analysis_server/lib/src/computer/element.dart

Issue 367973006: Implementation for 'analysis.occurrences' notification. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 computer.element; 5 library computer.element;
6 6
7 import 'package:analysis_server/src/constants.dart'; 7 import 'package:analysis_server/src/constants.dart';
8 import 'package:analyzer/src/generated/element.dart' as engine; 8 import 'package:analyzer/src/generated/element.dart' as engine;
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/generated/utilities_dart.dart' as engine; 10 import 'package:analyzer/src/generated/utilities_dart.dart' as engine;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 }; 104 };
105 if (parameters != null) { 105 if (parameters != null) {
106 json[PARAMETERS] = parameters; 106 json[PARAMETERS] = parameters;
107 } 107 }
108 if (returnType != null) { 108 if (returnType != null) {
109 json[RETURN_TYPE] = returnType; 109 json[RETURN_TYPE] = returnType;
110 } 110 }
111 return json; 111 return json;
112 } 112 }
113 113
114 @override
115 String toString() => toJson().toString();
116
114 static String _getParametersString(engine.Element element) { 117 static String _getParametersString(engine.Element element) {
115 // TODO(scheglov) expose the corresponding feature from ExecutableElement 118 // TODO(scheglov) expose the corresponding feature from ExecutableElement
116 if (element is engine.ExecutableElement) { 119 if (element is engine.ExecutableElement) {
117 var sb = new StringBuffer(); 120 var sb = new StringBuffer();
118 String closeOptionalString = ''; 121 String closeOptionalString = '';
119 for (var parameter in element.parameters) { 122 for (var parameter in element.parameters) {
120 if (sb.isNotEmpty) { 123 if (sb.isNotEmpty) {
121 sb.write(', '); 124 sb.write(', ');
122 } 125 }
123 if (closeOptionalString.isEmpty) { 126 if (closeOptionalString.isEmpty) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 class ElementKind { 204 class ElementKind {
202 static const CLASS = const ElementKind('CLASS'); 205 static const CLASS = const ElementKind('CLASS');
203 static const CLASS_TYPE_ALIAS = const ElementKind('CLASS_TYPE_ALIAS'); 206 static const CLASS_TYPE_ALIAS = const ElementKind('CLASS_TYPE_ALIAS');
204 static const COMPILATION_UNIT = const ElementKind('COMPILATION_UNIT'); 207 static const COMPILATION_UNIT = const ElementKind('COMPILATION_UNIT');
205 static const CONSTRUCTOR = const ElementKind('CONSTRUCTOR'); 208 static const CONSTRUCTOR = const ElementKind('CONSTRUCTOR');
206 static const FIELD = const ElementKind('FIELD'); 209 static const FIELD = const ElementKind('FIELD');
207 static const FUNCTION = const ElementKind('FUNCTION'); 210 static const FUNCTION = const ElementKind('FUNCTION');
208 static const FUNCTION_TYPE_ALIAS = const ElementKind('FUNCTION_TYPE_ALIAS'); 211 static const FUNCTION_TYPE_ALIAS = const ElementKind('FUNCTION_TYPE_ALIAS');
209 static const GETTER = const ElementKind('GETTER'); 212 static const GETTER = const ElementKind('GETTER');
210 static const LIBRARY = const ElementKind('LIBRARY'); 213 static const LIBRARY = const ElementKind('LIBRARY');
214 static const LOCAL_VARIABLE = const ElementKind('LOCAL_VARIABLE');
211 static const METHOD = const ElementKind('METHOD'); 215 static const METHOD = const ElementKind('METHOD');
212 static const SETTER = const ElementKind('SETTER'); 216 static const SETTER = const ElementKind('SETTER');
213 static const TOP_LEVEL_VARIABLE = const ElementKind('TOP_LEVEL_VARIABLE'); 217 static const TOP_LEVEL_VARIABLE = const ElementKind('TOP_LEVEL_VARIABLE');
214 static const UNIT_TEST_CASE = const ElementKind('UNIT_TEST_CASE'); 218 static const UNIT_TEST_CASE = const ElementKind('UNIT_TEST_CASE');
215 static const UNIT_TEST_GROUP = const ElementKind('UNIT_TEST_GROUP'); 219 static const UNIT_TEST_GROUP = const ElementKind('UNIT_TEST_GROUP');
216 static const UNKNOWN = const ElementKind('UNKNOWN'); 220 static const UNKNOWN = const ElementKind('UNKNOWN');
217 221
218 final String name; 222 final String name;
219 223
220 const ElementKind(this.name); 224 const ElementKind(this.name);
221 225
222 @override 226 @override
223 String toString() => name; 227 String toString() => name;
224 228
225 static ElementKind valueOf(String name) { 229 static ElementKind valueOf(String name) {
226 if (CLASS.name == name) return CLASS; 230 if (CLASS.name == name) return CLASS;
227 if (CLASS_TYPE_ALIAS.name == name) return CLASS_TYPE_ALIAS; 231 if (CLASS_TYPE_ALIAS.name == name) return CLASS_TYPE_ALIAS;
228 if (COMPILATION_UNIT.name == name) return COMPILATION_UNIT; 232 if (COMPILATION_UNIT.name == name) return COMPILATION_UNIT;
229 if (CONSTRUCTOR.name == name) return CONSTRUCTOR; 233 if (CONSTRUCTOR.name == name) return CONSTRUCTOR;
230 if (FIELD.name == name) return FIELD; 234 if (FIELD.name == name) return FIELD;
231 if (FUNCTION.name == name) return FUNCTION; 235 if (FUNCTION.name == name) return FUNCTION;
232 if (FUNCTION_TYPE_ALIAS.name == name) return FUNCTION_TYPE_ALIAS; 236 if (FUNCTION_TYPE_ALIAS.name == name) return FUNCTION_TYPE_ALIAS;
233 if (GETTER.name == name) return GETTER; 237 if (GETTER.name == name) return GETTER;
234 if (LIBRARY.name == name) return LIBRARY; 238 if (LIBRARY.name == name) return LIBRARY;
239 if (LOCAL_VARIABLE.name == name) return LOCAL_VARIABLE;
235 if (METHOD.name == name) return METHOD; 240 if (METHOD.name == name) return METHOD;
236 if (SETTER.name == name) return SETTER; 241 if (SETTER.name == name) return SETTER;
237 if (TOP_LEVEL_VARIABLE.name == name) return TOP_LEVEL_VARIABLE; 242 if (TOP_LEVEL_VARIABLE.name == name) return TOP_LEVEL_VARIABLE;
238 if (UNIT_TEST_CASE.name == name) return UNIT_TEST_CASE; 243 if (UNIT_TEST_CASE.name == name) return UNIT_TEST_CASE;
239 if (UNIT_TEST_GROUP.name == name) return UNIT_TEST_GROUP; 244 if (UNIT_TEST_GROUP.name == name) return UNIT_TEST_GROUP;
240 if (UNKNOWN.name == name) return UNKNOWN; 245 if (UNKNOWN.name == name) return UNKNOWN;
241 throw new ArgumentError('Unknown ElementKind: $name'); 246 throw new ArgumentError('Unknown ElementKind: $name');
242 } 247 }
243 248
244 static ElementKind valueOfEngine(engine.ElementKind kind) { 249 static ElementKind valueOfEngine(engine.ElementKind kind) {
(...skipping 14 matching lines...) Expand all
259 } 264 }
260 if (kind == engine.ElementKind.FUNCTION_TYPE_ALIAS) { 265 if (kind == engine.ElementKind.FUNCTION_TYPE_ALIAS) {
261 return FUNCTION_TYPE_ALIAS; 266 return FUNCTION_TYPE_ALIAS;
262 } 267 }
263 if (kind == engine.ElementKind.GETTER) { 268 if (kind == engine.ElementKind.GETTER) {
264 return GETTER; 269 return GETTER;
265 } 270 }
266 if (kind == engine.ElementKind.LIBRARY) { 271 if (kind == engine.ElementKind.LIBRARY) {
267 return LIBRARY; 272 return LIBRARY;
268 } 273 }
274 if (kind == engine.ElementKind.LOCAL_VARIABLE) {
275 return LOCAL_VARIABLE;
276 }
269 if (kind == engine.ElementKind.METHOD) { 277 if (kind == engine.ElementKind.METHOD) {
270 return METHOD; 278 return METHOD;
271 } 279 }
272 if (kind == engine.ElementKind.SETTER) { 280 if (kind == engine.ElementKind.SETTER) {
273 return SETTER; 281 return SETTER;
274 } 282 }
275 if (kind == engine.ElementKind.TOP_LEVEL_VARIABLE) { 283 if (kind == engine.ElementKind.TOP_LEVEL_VARIABLE) {
276 return TOP_LEVEL_VARIABLE; 284 return TOP_LEVEL_VARIABLE;
277 } 285 }
278 return UNKNOWN; 286 return UNKNOWN;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 START_COLUMN: startColumn 336 START_COLUMN: startColumn
329 }; 337 };
330 } 338 }
331 339
332 @override 340 @override
333 String toString() { 341 String toString() {
334 return 'Location(file=$file; offset=$offset; length=$length; ' 342 return 'Location(file=$file; offset=$offset; length=$length; '
335 'startLine=$startLine; startColumn=$startColumn)'; 343 'startLine=$startLine; startColumn=$startColumn)';
336 } 344 }
337 } 345 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computer/computer_occurrences.dart ('k') | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698