From 548b7e7820829d66f9bb7002f743fd676f0dace2 Mon Sep 17 00:00:00 2001 From: Nick Tan Date: Sun, 6 Aug 2023 10:26:54 -0700 Subject: [PATCH] fixed #555 --- .../util/param/TestNGMethodParameterVisitor.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/testng-eclipse-plugin/src/main/org/testng/eclipse/util/param/TestNGMethodParameterVisitor.java b/testng-eclipse-plugin/src/main/org/testng/eclipse/util/param/TestNGMethodParameterVisitor.java index 4b9738bd..be2f8847 100644 --- a/testng-eclipse-plugin/src/main/org/testng/eclipse/util/param/TestNGMethodParameterVisitor.java +++ b/testng-eclipse-plugin/src/main/org/testng/eclipse/util/param/TestNGMethodParameterVisitor.java @@ -15,6 +15,7 @@ import org.eclipse.jdt.core.dom.MemberValuePair; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.NormalAnnotation; +import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.SingleMemberAnnotation; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.StringLiteral; @@ -148,9 +149,15 @@ protected void record(MethodDeclaration method, StringLiteral value){ protected void record(MethodDeclaration method, ArrayInitializer values) { List literals = values.expressions(); List paramNames = new ArrayList(literals.size()); - for(int i= 0; i < literals.size(); i++) { - StringLiteral str = (StringLiteral) literals.get(i); - paramNames.add(str.getLiteralValue()); + for(Object expr : literals) { + if (expr instanceof StringLiteral) { + StringLiteral str = (StringLiteral) expr; + paramNames.add(str.getLiteralValue()); + } else if (expr instanceof SimpleName) { + SimpleName sn = (SimpleName) expr; + paramNames.add(sn.getIdentifier()); + } + } record(method, paramNames);