| 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.hover; | 5 library computer.hover; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' show HoverInformation; | 7 import 'package:analysis_server/src/protocol.dart' show HoverInformation; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 hover.containingClassDescription = containingClass.toString(); | 104 hover.containingClassDescription = containingClass.toString(); |
| 105 } | 105 } |
| 106 // containing library | 106 // containing library |
| 107 LibraryElement library = element.library; | 107 LibraryElement library = element.library; |
| 108 if (library != null) { | 108 if (library != null) { |
| 109 hover.containingLibraryName = library.name; | 109 hover.containingLibraryName = library.name; |
| 110 hover.containingLibraryPath = library.source.fullName; | 110 hover.containingLibraryPath = library.source.fullName; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 // documentation | 113 // documentation |
| 114 String dartDoc = element.computeDocumentationComment(); | 114 hover.dartdoc = _computeDocumentation(element); |
| 115 dartDoc = _removeDartDocDelimiters(dartDoc); | |
| 116 hover.dartdoc = dartDoc; | |
| 117 } | 115 } |
| 118 // parameter | 116 // parameter |
| 119 hover.parameter = _safeToString(expression.bestParameterElement); | 117 hover.parameter = _safeToString(expression.bestParameterElement); |
| 120 // types | 118 // types |
| 121 hover.staticType = _safeToString(expression.staticType); | 119 hover.staticType = _safeToString(expression.staticType); |
| 122 hover.propagatedType = _safeToString(expression.propagatedType); | 120 hover.propagatedType = _safeToString(expression.propagatedType); |
| 123 // done | 121 // done |
| 124 return hover; | 122 return hover; |
| 125 } | 123 } |
| 126 // not an expression | 124 // not an expression |
| 127 return null; | 125 return null; |
| 128 } | 126 } |
| 129 | 127 |
| 128 String _computeDocumentation(Element element) { |
| 129 if (element is ParameterElement) { |
| 130 element = element.enclosingElement; |
| 131 } |
| 132 String dartDoc = element.computeDocumentationComment(); |
| 133 return _removeDartDocDelimiters(dartDoc); |
| 134 } |
| 135 |
| 130 static _safeToString(obj) => obj != null ? obj.toString() : null; | 136 static _safeToString(obj) => obj != null ? obj.toString() : null; |
| 131 } | 137 } |
| OLD | NEW |