| OLD | NEW |
| 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/protocol.dart'; | 7 import 'package:analysis_server/src/protocol_server.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/utilities_dart.dart' as engine; | 9 import 'package:analyzer/src/generated/utilities_dart.dart' as engine; |
| 10 | 10 |
| 11 | 11 |
| 12 Element elementFromEngine(engine.Element element) { | 12 Element elementFromEngine(engine.Element element) { |
| 13 String name = element.displayName; | 13 String name = element.displayName; |
| 14 String elementParameters = _getParametersString(element); | 14 String elementParameters = _getParametersString(element); |
| 15 String elementReturnType = _getReturnTypeString(element); | 15 String elementReturnType = _getReturnTypeString(element); |
| 16 return new Element( | 16 return new Element( |
| 17 new ElementKind.fromEngine(element.kind), | 17 newElementKind_fromEngine(element.kind), |
| 18 name, | 18 name, |
| 19 Element.makeFlags(isPrivate: element.isPrivate, | 19 Element.makeFlags( |
| 20 isDeprecated: element.isDeprecated, | 20 isPrivate: element.isPrivate, |
| 21 isAbstract: _isAbstract(element), | 21 isDeprecated: element.isDeprecated, |
| 22 isConst: _isConst(element), | 22 isAbstract: _isAbstract(element), |
| 23 isFinal: _isFinal(element), | 23 isConst: _isConst(element), |
| 24 isStatic: _isStatic(element)), | 24 isFinal: _isFinal(element), |
| 25 location: new Location.fromElement(element), | 25 isStatic: _isStatic(element)), |
| 26 parameters: elementParameters, | 26 location: newLocation_fromElement(element), |
| 27 returnType: elementReturnType); | 27 parameters: elementParameters, |
| 28 returnType: elementReturnType); |
| 28 } | 29 } |
| 29 | 30 |
| 30 String _getParametersString(engine.Element element) { | 31 String _getParametersString(engine.Element element) { |
| 31 // TODO(scheglov) expose the corresponding feature from ExecutableElement | 32 // TODO(scheglov) expose the corresponding feature from ExecutableElement |
| 32 if (element is engine.ExecutableElement) { | 33 if (element is engine.ExecutableElement) { |
| 33 var sb = new StringBuffer(); | 34 var sb = new StringBuffer(); |
| 34 String closeOptionalString = ''; | 35 String closeOptionalString = ''; |
| 35 for (var parameter in element.parameters) { | 36 for (var parameter in element.parameters) { |
| 36 if (sb.isNotEmpty) { | 37 if (sb.isNotEmpty) { |
| 37 sb.write(', '); | 38 sb.write(', '); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 bool _isStatic(engine.Element element) { | 104 bool _isStatic(engine.Element element) { |
| 104 // TODO(scheglov) add isStatic to Element API | 105 // TODO(scheglov) add isStatic to Element API |
| 105 if (element is engine.ExecutableElement) { | 106 if (element is engine.ExecutableElement) { |
| 106 return element.isStatic; | 107 return element.isStatic; |
| 107 } | 108 } |
| 108 if (element is engine.PropertyInducingElement) { | 109 if (element is engine.PropertyInducingElement) { |
| 109 return element.isStatic; | 110 return element.isStatic; |
| 110 } | 111 } |
| 111 return false; | 112 return false; |
| 112 } | 113 } |
| OLD | NEW |