Extension type. Code folding.

Change-Id: I33ee2cf63a275c7c2d8f41c4033a0ee4d2641e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323944
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-09-01 20:47:23 +00:00 committed by Commit Queue
parent 49f5312fed
commit 53cd950e7a
2 changed files with 30 additions and 0 deletions

View file

@ -297,6 +297,17 @@ class _DartUnitFoldingComputerVisitor extends RecursiveAstVisitor<void> {
super.visitExtensionDeclaration(node);
}
@override
void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) {
_computer._addRegionForAnnotations(node.metadata);
_computer._addRegion(
node.leftBracket.end,
node.rightBracket.offset,
FoldingKind.CLASS_BODY,
);
super.visitExtensionTypeDeclaration(node);
}
@override
void visitFieldDeclaration(FieldDeclaration node) {
_computer._addRegionForAnnotations(node.metadata);

View file

@ -361,6 +361,25 @@ final a = new Text(/*[0*/
});
}
Future<void> test_extensionType() async {
var content = '''
// Content before
extension type E(int it) {/*[0*/
void m/*[1*/() {
}/*1]*/
/*0]*/}
// Content after
''';
await _computeRegions(content);
expectRegions({
0: FoldingKind.CLASS_BODY,
1: FoldingKind.FUNCTION_BODY,
});
}
Future<void> test_file_header() async {
var content = """
// Copyright some year by some people/*[0*/