| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // variable, if synthetic accessor | 88 // variable, if synthetic accessor |
| 89 if (element is PropertyAccessorElement) { | 89 if (element is PropertyAccessorElement) { |
| 90 PropertyAccessorElement accessor = element; | 90 PropertyAccessorElement accessor = element; |
| 91 if (accessor.isSynthetic) { | 91 if (accessor.isSynthetic) { |
| 92 element = accessor.variable; | 92 element = accessor.variable; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 // description | 95 // description |
| 96 hover.elementDescription = element.toString(); | 96 hover.elementDescription = element.toString(); |
| 97 hover.elementKind = element.kind.displayName; | 97 hover.elementKind = element.kind.displayName; |
| 98 // library | 98 // containing class |
| 99 ClassElement containingClass = |
| 100 element.getAncestor((e) => e is ClassElement); |
| 101 if (containingClass != null) { |
| 102 hover.containingClassDescription = containingClass.toString(); |
| 103 } |
| 104 // containing library |
| 99 LibraryElement library = element.library; | 105 LibraryElement library = element.library; |
| 100 if (library != null) { | 106 if (library != null) { |
| 101 hover.containingLibraryName = library.name; | 107 hover.containingLibraryName = library.name; |
| 102 hover.containingLibraryPath = library.source.fullName; | 108 hover.containingLibraryPath = library.source.fullName; |
| 103 } | 109 } |
| 104 // documentation | 110 // documentation |
| 105 String dartDoc = element.computeDocumentationComment(); | 111 String dartDoc = element.computeDocumentationComment(); |
| 106 dartDoc = _removeDartDocDelimiters(dartDoc); | 112 dartDoc = _removeDartDocDelimiters(dartDoc); |
| 107 hover.dartdoc = dartDoc; | 113 hover.dartdoc = dartDoc; |
| 108 } | 114 } |
| 109 // parameter | 115 // parameter |
| 110 hover.parameter = _safeToString(expression.bestParameterElement); | 116 hover.parameter = _safeToString(expression.bestParameterElement); |
| 111 // types | 117 // types |
| 112 hover.staticType = _safeToString(expression.staticType); | 118 hover.staticType = _safeToString(expression.staticType); |
| 113 hover.propagatedType = _safeToString(expression.propagatedType); | 119 hover.propagatedType = _safeToString(expression.propagatedType); |
| 114 // done | 120 // done |
| 115 return hover; | 121 return hover; |
| 116 } | 122 } |
| 117 // not an expression | 123 // not an expression |
| 118 return null; | 124 return null; |
| 119 } | 125 } |
| 120 | 126 |
| 121 static _safeToString(obj) => obj != null ? obj.toString() : null; | 127 static _safeToString(obj) => obj != null ? obj.toString() : null; |
| 122 } | 128 } |
| OLD | NEW |