Skip to content

Commit

Permalink
. t determine line numbers via java-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsEckart authored and isidore committed Jan 22, 2024
1 parent da0d8f0 commit 97f5c78
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.approvaltests;

import com.github.javaparser.Range;
import com.spun.util.FormattedException;
import com.spun.util.ObjectUtils;
import com.spun.util.StringUtils;
Expand Down Expand Up @@ -85,7 +86,7 @@ void testLineNumbers()
getLink(Query.first(Approvals.class.getMethods(),
m -> m.getName().equals("verifyAll") && m.getParameterTypes()[0].equals(Object[].class)));
}
private String showParameters(Method m)
public static String showParameters(Method m)
{
return StringUtils.join(Query.select(m.getParameters(), p -> String.format("%s", p.getType().getSimpleName())),
",");
Expand All @@ -94,9 +95,9 @@ public static String getLink(Method m)
{
String baseUrl = "https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java";
String file = m.getDeclaringClass().getName().replace('.', '/') + ".java";
CtMethod methodX = getMethodX(m);
int start = getLineNumber(methodX);
int end = start + 3;
Range methodLines = ParsingFilesTest.getMethodLines(m);
int start = methodLines.begin.line;
int end = methodLines.end.line;
return String.format("%s/%s#L%s-L%s", baseUrl, file, start, end);
}
private static CtMethod getMethodX(Method method)
Expand Down
Loading

0 comments on commit 97f5c78

Please sign in to comment.