homberghp commented on PR #8568:
URL: https://github.com/apache/netbeans/pull/8568#issuecomment-4162527529

   Indeed, the iteration order is not the problem per se, although starting at 
the top is closest to the culprit, so the iteration count is lower. That does 
not really matter, since most stack traces are short in tests, so a big-O 
analysis does not help in this case. However, the condition to accept a result 
in the loop does. If it would only accept a stack trace line when it is inside 
the test method, then that would be perfectly fine.  
   
   
https://github.com/apache/netbeans/blob/26a05a6e2386372145e4894e70347d2f69ef8b98/java/junit.ant.ui/src/org/netbeans/modules/junit/ant/ui/AntJUnitNodeOpener.java#L166-L185
   But the expression used is a compound one, with three tests:
   
   1. which tests for `testfo.equals(file)`, 
   2. not  yet at begin of array  `index != -1` and a bit hidden, both in line 
166,
   3. the boolean `methodNodeParentOfStackTraceNode`, which is in fact testing 
with `FileUtil.isParentOf(testfo.getParent(), file)` in line 181.
   
   Because of this compound condition and the order in which the stacktrace is 
iterated, it stops at the first matching line, which might be the desired file, 
or a sibling of the test file. Both terminate the loop.
   
   The compoundness (if that is a word) of the expression is the problem.
   If one needs to consider siblings, one would need multiple loops, which 
allow one to look for the test file first and, if that is not found after a 
complete iteration, then iterate to find a sibling. Again: the iteration order 
should not matter.
   
   Note that in my proposal, I only consider the fully qualified *test* method 
name in the first iteration.
   The second iteration returns the file associated with the top of the stack 
trace. If there is no such file, simply open the 
   test file object, which is never null at this point in the method 
`openCallStackFrame`. Whether or not it is a sibling is not considered.  
   
   
https://github.com/homberghp/netbeans/blob/4e9104c01b4a1971c61319af3c5ad68c4b8c0f76/java/junit.ant.ui/src/org/netbeans/modules/junit/ant/ui/AntJUnitNodeOpener.java#L161-L198
   
   Why you would want to look for a sibling is not clear to me.


-- 
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

Reply via email to