| 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/plugin/protocol/protocol.dart' | 7 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 8 show HoverInformation; | 8 show HoverInformation; |
| 9 import 'package:analysis_server/src/computer/computer_overrides.dart'; | 9 import 'package:analysis_server/src/computer/computer_overrides.dart'; |
| 10 import 'package:analysis_server/src/utilities/documentation.dart'; | 10 import 'package:analysis_server/src/utilities/documentation.dart'; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 return null; | 107 return null; |
| 108 } | 108 } |
| 109 | 109 |
| 110 String _computeDocumentation(Element element) { | 110 String _computeDocumentation(Element element) { |
| 111 if (element is FieldFormalParameterElement) { | 111 if (element is FieldFormalParameterElement) { |
| 112 element = (element as FieldFormalParameterElement).field; | 112 element = (element as FieldFormalParameterElement).field; |
| 113 } | 113 } |
| 114 if (element is ParameterElement) { | 114 if (element is ParameterElement) { |
| 115 element = element.enclosingElement; | 115 element = element.enclosingElement; |
| 116 } | 116 } |
| 117 if (element == null) { |
| 118 // This can happen when the code is invalid, such as having a field formal |
| 119 // parameter for a field that does not exist. |
| 120 return null; |
| 121 } |
| 117 // The documentation of the element itself. | 122 // The documentation of the element itself. |
| 118 if (element.documentationComment != null) { | 123 if (element.documentationComment != null) { |
| 119 return removeDartDocDelimiters(element.documentationComment); | 124 return removeDartDocDelimiters(element.documentationComment); |
| 120 } | 125 } |
| 121 // Look for documentation comments of overridden members. | 126 // Look for documentation comments of overridden members. |
| 122 OverriddenElements overridden = findOverriddenElements(element); | 127 OverriddenElements overridden = findOverriddenElements(element); |
| 123 for (Element superElement in [] | 128 for (Element superElement in [] |
| 124 ..addAll(overridden.superElements) | 129 ..addAll(overridden.superElements) |
| 125 ..addAll(overridden.interfaceElements)) { | 130 ..addAll(overridden.interfaceElements)) { |
| 126 String rawDoc = superElement.documentationComment; | 131 String rawDoc = superElement.documentationComment; |
| 127 if (rawDoc != null) { | 132 if (rawDoc != null) { |
| 128 Element interfaceClass = superElement.enclosingElement; | 133 Element interfaceClass = superElement.enclosingElement; |
| 129 return removeDartDocDelimiters(rawDoc) + | 134 return removeDartDocDelimiters(rawDoc) + |
| 130 '\n\nCopied from `${interfaceClass.displayName}`.'; | 135 '\n\nCopied from `${interfaceClass.displayName}`.'; |
| 131 } | 136 } |
| 132 } | 137 } |
| 133 return null; | 138 return null; |
| 134 } | 139 } |
| 135 | 140 |
| 136 static _safeToString(obj) => obj?.toString(); | 141 static _safeToString(obj) => obj?.toString(); |
| 137 } | 142 } |
| OLD | NEW |