mbien commented on code in PR #53:
URL: https://github.com/apache/netbeans-jackpot30/pull/53#discussion_r4347616502
##########
cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java:
##########
@@ -1018,6 +1018,42 @@ public void testPatchApply() throws Exception {
"--filter-patch", getWorkDirPath() + "/patch.diff");
}
+ public void testPatchWarningsMultiLineMatch() throws Exception {
+ String golden =
+ "package test;\n" +
+ "public class Test {\n" +
Review Comment:
lets use code blocks for new code (i think project is on 21 by now)
LLMs must be usually explicitly told what style to generate code with,
otherwise they copy the same style of the file. (which in this case we don't
want)
##########
cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java:
##########
@@ -659,7 +660,17 @@ public FilteringWorker(PatchDescription patch, Worker
delegate) {
@Override
public Collection<? extends ErrorDescription>
createErrors(HintContext ctx) {
Collection<? extends ErrorDescription> errors =
delegate.createErrors(ctx);
- return errors != null ? errors.stream().filter(ed ->
patch.included(ed)).collect(Collectors.toList()) : null;
+ if (errors == null) return null;
+ //ErrorDescriptionFactory never produces a multi-line span:
forTree clamps the
+ //end of the description to the end of its first line, forName
uses the (short)
+ //name span. A match that starts on a line the patch did not
add but ends on a
+ //line it did add would therefore be filtered out when judged
by the description's
+ //range. Use the span of the tree the hint matched instead;
fall back to the
+ //description's own range if the tree positions cannot be
determined.
+ Tree tree = ctx.getPath().getLeaf();
+ int start = (int)
ctx.getInfo().getTrees().getSourcePositions().getStartPosition(ctx.getInfo().getCompilationUnit(),
tree);
+ int end = (int)
ctx.getInfo().getTrees().getSourcePositions().getEndPosition(ctx.getInfo().getCompilationUnit(),
tree);
Review Comment:
nitpick: temp variable to shorten the chain.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists