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

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

Issue 492243002: Introduce convenience methods into generated analysis server classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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:analysis_server/src/protocol2.dart'; 8 import 'package:analysis_server/src/protocol2.dart';
9 import 'package:analyzer/src/generated/element.dart' as engine; 9 import 'package:analyzer/src/generated/element.dart' as engine;
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 Element(this.kind, this.name, this.location, this.isPrivate, 71 Element(this.kind, this.name, this.location, this.isPrivate,
72 this.isDeprecated, {this.parameters, this.returnType, this.isAbstract: fal se, 72 this.isDeprecated, {this.parameters, this.returnType, this.isAbstract: fal se,
73 this.isConst: false, this.isFinal: false, this.isStatic: false}); 73 this.isConst: false, this.isFinal: false, this.isStatic: false});
74 74
75 factory Element.fromEngine(engine.Element element) { 75 factory Element.fromEngine(engine.Element element) {
76 String name = element.displayName; 76 String name = element.displayName;
77 String elementParameters = _getParametersString(element); 77 String elementParameters = _getParametersString(element);
78 String elementReturnType = _getReturnTypeString(element); 78 String elementReturnType = _getReturnTypeString(element);
79 return new Element( 79 return new Element(
80 elementKindFromEngine(element.kind), 80 new ElementKind.fromEngine(element.kind),
81 name, 81 name,
82 new Location.fromElement(element), 82 new Location.fromElement(element),
83 element.isPrivate, 83 element.isPrivate,
84 element.isDeprecated, 84 element.isDeprecated,
85 parameters: elementParameters, 85 parameters: elementParameters,
86 returnType: elementReturnType, 86 returnType: elementReturnType,
87 isAbstract: _isAbstract(element), 87 isAbstract: _isAbstract(element),
88 isConst: _isConst(element), 88 isConst: _isConst(element),
89 isFinal: _isFinal(element), 89 isFinal: _isFinal(element),
90 isStatic: _isStatic(element)); 90 isStatic: _isStatic(element));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return element.isStatic; 218 return element.isStatic;
219 } 219 }
220 if (element is engine.PropertyInducingElement) { 220 if (element is engine.PropertyInducingElement) {
221 return element.isStatic; 221 return element.isStatic;
222 } 222 }
223 return false; 223 return false;
224 } 224 }
225 } 225 }
226 226
227 227
228 ElementKind elementKindFromEngine(engine.ElementKind kind) {
229 if (kind == engine.ElementKind.CLASS) {
230 return ElementKind.CLASS;
231 }
232 if (kind == engine.ElementKind.COMPILATION_UNIT) {
233 return ElementKind.COMPILATION_UNIT;
234 }
235 if (kind == engine.ElementKind.CONSTRUCTOR) {
236 return ElementKind.CONSTRUCTOR;
237 }
238 if (kind == engine.ElementKind.FIELD) {
239 return ElementKind.FIELD;
240 }
241 if (kind == engine.ElementKind.FUNCTION) {
242 return ElementKind.FUNCTION;
243 }
244 if (kind == engine.ElementKind.FUNCTION_TYPE_ALIAS) {
245 return ElementKind.FUNCTION_TYPE_ALIAS;
246 }
247 if (kind == engine.ElementKind.GETTER) {
248 return ElementKind.GETTER;
249 }
250 if (kind == engine.ElementKind.LIBRARY) {
251 return ElementKind.LIBRARY;
252 }
253 if (kind == engine.ElementKind.LOCAL_VARIABLE) {
254 return ElementKind.LOCAL_VARIABLE;
255 }
256 if (kind == engine.ElementKind.METHOD) {
257 return ElementKind.METHOD;
258 }
259 if (kind == engine.ElementKind.PARAMETER) {
260 return ElementKind.PARAMETER;
261 }
262 if (kind == engine.ElementKind.SETTER) {
263 return ElementKind.SETTER;
264 }
265 if (kind == engine.ElementKind.TOP_LEVEL_VARIABLE) {
266 return ElementKind.TOP_LEVEL_VARIABLE;
267 }
268 if (kind == engine.ElementKind.TYPE_PARAMETER) {
269 return ElementKind.TYPE_PARAMETER;
270 }
271 return ElementKind.UNKNOWN;
272 }
273
274
275 /** 228 /**
276 * Information about a location. 229 * Information about a location.
277 */ 230 */
278 class Location { 231 class Location {
279 final String file; 232 final String file;
280 final int offset; 233 final int offset;
281 final int length; 234 final int length;
282 final int startLine; 235 final int startLine;
283 final int startColumn; 236 final int startColumn;
284 237
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 START_COLUMN: startColumn 297 START_COLUMN: startColumn
345 }; 298 };
346 } 299 }
347 300
348 @override 301 @override
349 String toString() { 302 String toString() {
350 return 'Location(file=$file; offset=$offset; length=$length; ' 303 return 'Location(file=$file; offset=$offset; length=$length; '
351 'startLine=$startLine; startColumn=$startColumn)'; 304 'startLine=$startLine; startColumn=$startColumn)';
352 } 305 }
353 } 306 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/computer/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698