NPE fix for annotations with no arguments

Change-Id: I93254aeef708157566a3adf942ebc84902e3c02c
Reviewed-on: https://dart-review.googlesource.com/54680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
diff --git a/pkg/analysis_server/lib/src/computer/computer_folding.dart b/pkg/analysis_server/lib/src/computer/computer_folding.dart
index 7cdee41..bea49f1 100644
--- a/pkg/analysis_server/lib/src/computer/computer_folding.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_folding.dart
@@ -3,7 +3,6 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/syntactic_entity.dart';
 import 'package:analyzer/dart/ast/visitor.dart';
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -66,10 +65,14 @@
 
   @override
   Object visitAnnotation(Annotation node) {
-    _addRegion(
-        node.arguments.leftParenthesis.end,
-        node.arguments.rightParenthesis.offset,
-        FoldingKind.TOP_LEVEL_DECLARATION);
+    if (node.arguments != null &&
+        node.arguments.leftParenthesis != null &&
+        node.arguments.rightParenthesis != null) {
+      _addRegion(
+          node.arguments.leftParenthesis.end,
+          node.arguments.rightParenthesis.offset,
+          FoldingKind.TOP_LEVEL_DECLARATION);
+    }
     return super.visitAnnotation(node);
   }
 
diff --git a/pkg/analysis_server/test/src/computer/folding_computer_test.dart b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
index 2b1d228..72a26a7 100644
--- a/pkg/analysis_server/test/src/computer/folding_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
@@ -150,6 +150,8 @@
   "this",
   "is a test"
 /*1:INC:TOP_LEVEL_DECLARATION*/)
+@another()
+@andAnother
 main() {/*2:INC*/
   print("Hello, world!");
 /*2:INC:TOP_LEVEL_DECLARATION*/}