Skip to content

Commit

Permalink
Use libdparse to check for named arg
Browse files Browse the repository at this point in the history
Remove custom named arg parser
  • Loading branch information
danielzuncke authored and WebFreak001 committed Oct 26, 2023
1 parent 9f37710 commit 2ea6c43
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/dfmt/ast_info.d
Original file line number Diff line number Diff line change
Expand Up @@ -461,31 +461,22 @@ final class FormatVisitor : ASTVisitor
return;
}

/+
Items are function arguments: f(<item>, <item>);
Iterate them and check if they are named arguments: tok!":" belongs to a
named argument if it is preceeded by one tok!"identifier" (+ any number
of comments):
+/
foreach (item; functionCall.arguments.namedArgumentList.items)
{
// Set to true after first tok!"identifier".
auto foundIdentifier = false;
// Do nothing if not a named argument.
if (item.name == tok!"")
{
continue;
}

// Find first colon if named argument.
foreach (t; item.tokens)
{
if (t.type == tok!"identifier" && !foundIdentifier)
{
foundIdentifier = true;
continue;
}

if (t.type == tok!":" && foundIdentifier)
if (t.type == tok!":")
{
astInformation.namedArgumentColonLocations ~= t.index;
break;
}

break;
}
}

Expand Down

0 comments on commit 2ea6c43

Please sign in to comment.