Add annotations to folding regions
Bug: https://github.com/dart-lang/sdk/issues/33033
Change-Id: Ie1917e3bd29b5cc2b6ecbed1238818e4e49f822a
Reviewed-on: https://dart-review.googlesource.com/54580
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 cf76107..7cdee41 100644
--- a/pkg/analysis_server/lib/src/computer/computer_folding.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_folding.dart
@@ -65,6 +65,15 @@
}
@override
+ Object visitAnnotation(Annotation node) {
+ _addRegion(
+ node.arguments.leftParenthesis.end,
+ node.arguments.rightParenthesis.offset,
+ FoldingKind.TOP_LEVEL_DECLARATION);
+ return super.visitAnnotation(node);
+ }
+
+ @override
Object visitComment(Comment node) {
final FoldingKind kind = node.isDocumentation
? FoldingKind.DOCUMENTATION_COMMENT
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 171926b..2b1d228 100644
--- a/pkg/analysis_server/test/src/computer/folding_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
@@ -144,6 +144,21 @@
_compareRegions(regions, content);
}
+ test_annotations() async {
+ String content = """
+@myMultilineAnnotation(/*1:INC*/
+ "this",
+ "is a test"
+/*1:INC:TOP_LEVEL_DECLARATION*/)
+main() {/*2:INC*/
+ print("Hello, world!");
+/*2:INC:TOP_LEVEL_DECLARATION*/}
+""";
+
+ final regions = await _computeRegions(content);
+ _compareRegions(regions, content);
+ }
+
/// Compares provided folding regions with expected
/// regions extracted from the comments in the provided content.
void _compareRegions(List<FoldingRegion> regions, String content) {