From 2ea6c43a66fa866dba8fedff4f3802b4a50cd57a Mon Sep 17 00:00:00 2001 From: Daniel Zuncke Date: Thu, 26 Oct 2023 16:21:03 +0200 Subject: [PATCH] Use libdparse to check for named arg Remove custom named arg parser --- src/dfmt/ast_info.d | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/dfmt/ast_info.d b/src/dfmt/ast_info.d index a7b74be..34a8ede 100644 --- a/src/dfmt/ast_info.d +++ b/src/dfmt/ast_info.d @@ -461,31 +461,22 @@ final class FormatVisitor : ASTVisitor return; } - /+ - Items are function arguments: f(, ); - 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; } }