| 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 // containing class | 98 // not local element |
| 99 ClassElement containingClass = | 99 if (element.enclosingElement is! ExecutableElement) { |
| 100 element.getAncestor((e) => e is ClassElement); | 100 // containing class |
| 101 if (containingClass != null) { | 101 ClassElement containingClass = |
| 102 hover.containingClassDescription = containingClass.toString(); | 102 element.getAncestor((e) => e is ClassElement); |
| 103 } | 103 if (containingClass != null) { |
| 104 // containing library | 104 hover.containingClassDescription = containingClass.toString(); |
| 105 LibraryElement library = element.library; | 105 } |
| 106 if (library != null) { | 106 // containing library |
| 107 hover.containingLibraryName = library.name; | 107 LibraryElement library = element.library; |
| 108 hover.containingLibraryPath = library.source.fullName; | 108 if (library != null) { |
| 109 hover.containingLibraryName = library.name; |
| 110 hover.containingLibraryPath = library.source.fullName; |
| 111 } |
| 109 } | 112 } |
| 110 // documentation | 113 // documentation |
| 111 String dartDoc = element.computeDocumentationComment(); | 114 String dartDoc = element.computeDocumentationComment(); |
| 112 dartDoc = _removeDartDocDelimiters(dartDoc); | 115 dartDoc = _removeDartDocDelimiters(dartDoc); |
| 113 hover.dartdoc = dartDoc; | 116 hover.dartdoc = dartDoc; |
| 114 } | 117 } |
| 115 // parameter | 118 // parameter |
| 116 hover.parameter = _safeToString(expression.bestParameterElement); | 119 hover.parameter = _safeToString(expression.bestParameterElement); |
| 117 // types | 120 // types |
| 118 hover.staticType = _safeToString(expression.staticType); | 121 hover.staticType = _safeToString(expression.staticType); |
| 119 hover.propagatedType = _safeToString(expression.propagatedType); | 122 hover.propagatedType = _safeToString(expression.propagatedType); |
| 120 // done | 123 // done |
| 121 return hover; | 124 return hover; |
| 122 } | 125 } |
| 123 // not an expression | 126 // not an expression |
| 124 return null; | 127 return null; |
| 125 } | 128 } |
| 126 | 129 |
| 127 static _safeToString(obj) => obj != null ? obj.toString() : null; | 130 static _safeToString(obj) => obj != null ? obj.toString() : null; |
| 128 } | 131 } |
| OLD | NEW |