Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: pkg/analysis_server/lib/src/computer/computer_hover.dart

Issue 2704933002: Guard against NPE caused by invalid code (issue 28829) (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/computer/computer_hover.dart
diff --git a/pkg/analysis_server/lib/src/computer/computer_hover.dart b/pkg/analysis_server/lib/src/computer/computer_hover.dart
index 5648d886fc9379776e43c7d72a088c14fc077a9e..f718bc2a9730da4ef23ee4bef7bbe2175547e36b 100644
--- a/pkg/analysis_server/lib/src/computer/computer_hover.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_hover.dart
@@ -114,6 +114,11 @@ class DartUnitHoverComputer {
if (element is ParameterElement) {
element = element.enclosingElement;
}
+ if (element == null) {
+ // This can happen when the code is invalid, such as having a field formal
+ // parameter for a field that does not exist.
+ return null;
+ }
// The documentation of the element itself.
if (element.documentationComment != null) {
return removeDartDocDelimiters(element.documentationComment);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698