Copilot commented on code in PR #397:
URL: https://github.com/apache/commons-jexl/pull/397#discussion_r2768801269
##########
src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java:
##########
@@ -1184,6 +1171,10 @@ private String escapeString(final CharSequence str) {
return StringParser.escapeString(str, (char) 0);
}
Review Comment:
The isIgnorable method lacks JavaDoc documentation. Consider adding
documentation that explains which characters are considered ignorable (newline,
carriage return, tab, form feed) and that these characters are ignored within
template expressions but NOT between the expression prefix ($, #) and the
opening brace. This would help future maintainers understand this important
parsing behavior.
```suggestion
/**
* Determines whether the given character is considered ignorable
whitespace in
* template expressions.
* <p>
* The characters newline ({@code '\n'}), carriage return ({@code
'\r'}), tab
* ({@code '\t'}) and form feed ({@code '\f'}) are treated as ignorable
within
* template expressions and are skipped by the parser. These characters
are
* <em>not</em> ignored between the expression prefix ({@code '$'} or
* {@code '#'}) and the opening brace {@code '{'}; in that position they
* influence parsing instead of being discarded.
* </p>
*
* @param c the character to test
* @return {@code true} if the character is ignorable, {@code false}
otherwise
*/
```
##########
src/main/java/org/apache/commons/jexl3/JxltEngine.java:
##########
@@ -310,6 +310,20 @@ public interface Template {
* @return the prepared version of the template
*/
Template prepare(JexlContext context);
+
+ /**
+ * Prepares this template by expanding any contained deferred
TemplateExpression with optional arguments.
+ * <p>This binds arguments to template parameters for immediate
expressions when the template also
+ * uses deferred/nested expressions.</p>
+ *
+ * @param context the context to prepare against
+ * @param args the arguments to bind (optional)
+ * @return the prepared version of the template
+ * @since 3.6.2
+ */
+ default Template prepare(JexlContext context, Object... args) {
+ throw new UnsupportedOperationException("No default
implementation");
Review Comment:
The default implementation throws UnsupportedOperationException with a
generic message. Consider providing a more descriptive error message that
indicates this is a default implementation that should be overridden, such as
"This template implementation does not support prepare with arguments. Override
this method to provide support."
```suggestion
throw new UnsupportedOperationException(
"This template implementation does not support prepare
with arguments. "
+ "Override this method to provide support.");
```
--
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]