Handle folding for function expression invocations

Change-Id: Id93004c1ea218b1768d649a2a806ce58a9d7f0a5
Reviewed-on: https://dart-review.googlesource.com/59061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
This commit is contained in:
Danny Tuppeny 2018-06-07 14:42:42 +00:00 committed by commit-bot@chromium.org
parent 5616ec9d6d
commit 111b621828
2 changed files with 29 additions and 0 deletions

View file

@ -157,6 +157,13 @@ class _DartUnitFoldingComputerVisitor extends RecursiveAstVisitor<Object> {
return super.visitFunctionDeclaration(node);
}
@override
Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
_computer._addRegion(node.argumentList.leftParenthesis.end,
node.argumentList.rightParenthesis.offset, FoldingKind.INVOCATION);
return super.visitFunctionExpressionInvocation(node);
}
@override
visitImportDirective(ImportDirective node) {
_computer._recordDirective(node);

View file

@ -116,6 +116,28 @@ main() {/*1:INC*/
/*2:INC:INVOCATION*/);
/*1:INC:FUNCTION_BODY*/}
// Content after
""";
final regions = await _computeRegions(content);
_compareRegions(regions, content);
}
test_function_expression_invocation() async {
String content = """
// Content before
getFunc() => (String a, String b) {/*1:INC*/
print(a);
/*1:INC:FUNCTION_BODY*/};
main2() {/*2:INC*/
getFunc()(/*3:INC*/
"one",
"two"
/*3:INC:INVOCATION*/);
/*2:INC:FUNCTION_BODY*/}
// Content after
""";