This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new dcdb5fdaee minor refactor: formatting
dcdb5fdaee is described below

commit dcdb5fdaeed44e5f42a3f673317cbf596fce0a9b
Author: Paul King <[email protected]>
AuthorDate: Sat Apr 16 08:44:19 2022 +1000

    minor refactor: formatting
---
 .../groovy/text/StreamingTemplateEngine.java       | 71 +++++++++++-----------
 1 file changed, 34 insertions(+), 37 deletions(-)

diff --git 
a/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
 
b/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
index 219f5e5b46..8f5a210aed 100644
--- 
a/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
+++ 
b/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
@@ -85,7 +85,7 @@ import java.util.concurrent.atomic.AtomicInteger;
  *
  * print template.make(binding)
  * </pre>
- *
+ * <p>
  * This example uses a mix of the JSP style and GString style
  * placeholders but you can typically use just one style if you wish. Running
  * this example will produce this output:
@@ -171,7 +171,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
 
     /**
      * Creates a template instance using the template source from the provided 
Reader.
-     *
+     * <p>
      * The template can be applied repeatedly on different bindings to produce 
custom output.
      *
      * <strong>Technical detail</strong><br />
@@ -186,7 +186,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
      *      //code generated by parsing the template data
      *   }
      * </pre>
-     *
+     * <p>
      * We then curry in the parentClass and stringSectionList arguments so 
that the StreamingTemplate
      * instance returned from 'createTemplate' internally contains a template 
closure on the form:
      *
@@ -195,7 +195,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
      *      //code generated by parsing the template data
      *   }
      * </pre>
-     *
+     * <p>
      * Calling {@code template.make(binding)}, curries in the 'binding' 
argument:
      *
      * <pre>
@@ -204,7 +204,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
      *     return (Writable) template;
      *   }
      * </pre>
-     *
+     * <p>
      * This only leaves the 'out' argument unbound. The only method on the 
{@link groovy.lang.Writable writable} interface is
      * {@link groovy.lang.Writable#writeTo writeTo(Writer out)} so groovy 
rules about casting a closure to a one-method-interface
      * apply and the above works. I.e. we return the now one argument closure 
as the Writable
@@ -219,7 +219,6 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
 
     /**
      * The class used to implement the Template interface for the 
StreamingTemplateEngine
-     *
      */
     private static class StreamingTemplate implements Template {
         /**
@@ -308,7 +307,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
          * <pre>
          * Alice why is a $bird like a writing desk
          * </pre>
-         *
+         * <p>
          * Would produce a string section "Alice why is a " followed by
          * a dollar identifier expression followed by another string
          * section " like a writing desk".
@@ -333,11 +332,11 @@ public class StreamingTemplateEngine extends 
TemplateEngine {
         /**
          * Called to handle the ending of a string section.
          *
-         * @param sections The list of string sections. The current section 
gets added to this section.
-         * @param currentSection The current string section.
+         * @param sections            The list of string sections. The current 
section gets added to this section.
+         * @param currentSection      The current string section.
          * @param templateExpressions Template expressions
-         * @param lastSourcePosition The last read position in the source 
template stream.
-         * @param targetPosition The last written to position in the target 
script stream.
+         * @param lastSourcePosition  The last read position in the source 
template stream.
+         * @param targetPosition      The last written to position in the 
target script stream.
          */
         private void finishStringSection(List<StringSection> sections, 
StringSection currentSection,
                                          StringBuilder templateExpressions,
@@ -387,13 +386,13 @@ public class StreamingTemplateEngine extends 
TemplateEngine {
         }
 
         private String getErrorContext(int actualLine) throws IOException {
-            int minLine = Math.max(0, actualLine -1);
+            int minLine = Math.max(0, actualLine - 1);
             int maxLine = Math.min(getLinesInSource(), actualLine + 1);
 
             LineNumberReader r = new LineNumberReader(new 
StringReader(templateSource.toString()));
             int lineNr;
             StringBuilder result = new StringBuilder();
-            while ((lineNr = r.getLineNumber()+1) <= maxLine) {
+            while ((lineNr = r.getLineNumber() + 1) <= maxLine) {
                 String line = r.readLine();
                 if (lineNr < minLine) continue;
 
@@ -431,7 +430,8 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
          * <pre>
          * { out -> out << "${"test"} of expr and "; test = 1 ; out << 
"${test} script."}.asWritable()
          * </pre>
-         * @param source A reader into the template source data
+         *
+         * @param source       A reader into the template source data
          * @param parentLoader A class loader we use
          * @throws CompilationFailedException
          * @throws ClassNotFoundException
@@ -561,8 +561,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
                 int d = read(source, sourcePosition, lookAhead);
                 c = read(source, sourcePosition, lookAhead);
                 clear(lookAhead);
-                if ((d == '$' && c == '{') ||
-                    (d == '<' && c == '%')) {
+                if ((d == '$' && c == '{') || (d == '<' && c == '%')) {
                     source.reset();
                     currentSection.data.append('\\');
                     return;
@@ -627,7 +626,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
          * <pre>
          * Alice why is a $bird like a writing desk
          * </pre>
-         *
+         * <p>
          * which would produce the following template data:
          *
          * <pre>
@@ -635,26 +634,24 @@ public class StreamingTemplateEngine extends 
TemplateEngine {
          * out << bird;
          * out << " like a writing desk";
          * </pre>
-         *
+         * <p>
          * This method is given the 'b' in 'bird' in argument c, checks if it 
is a valid
          * java identifier start (we assume groovy did not mangle the java
          * identifier rules). If so it proceeds to parse characters from the 
input
          * until it encounters a non-java-identifier character. At that point
          *
-         * @param c The first letter of the potential identifier, 'b' in the 
above example
-         * @param reader The reader reading from the template source
-         * @param target The target groovy script source we write to
+         * @param c              The first letter of the potential identifier, 
'b' in the above example
+         * @param reader         The reader reading from the template source
+         * @param target         The target groovy script source we write to
          * @param sourcePosition The reader position in the source stream
          * @param targetPosition The writer position in the target stream
          * @return true if a valid dollar preceded identifier was found, false 
otherwise. More
-         *         specifically, returns true if the first character after the 
dollar sign is
-         *         a valid java identifier. Note that the dollar curly syntax 
is handled by
-         *         another method.
-         *
+         * specifically, returns true if the first character after the dollar 
sign is a valid
+         * java identifier. Note that the dollar curly syntax is handled by 
another method.
          * @throws IOException
          * @throws FinishedReadingException If we encountered the end of the 
source stream.
          */
-        private int parseDollarIdentifier(int c ,
+        private int parseDollarIdentifier(int c,
                                           final Reader reader,
                                           final StringBuilder target,
                                           final Position sourcePosition,
@@ -682,7 +679,7 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
          * <pre>
          * Alice why is a ${bird} like a writing desk
          * </pre>
-         *
+         * <p>
          * which would produce the following template data:
          *
          * <pre>
@@ -690,14 +687,14 @@ public class StreamingTemplateEngine extends 
TemplateEngine {
          * out << """${bird}""";
          * out << " like a writing desk";
          * </pre>
-         *
+         * <p>
          * This method is given the 'b' in 'bird' in argument c, checks if it 
is a valid
          * java identifier start (we assume groovy did not mangle the java
          * identifier rules). If so it proceeds to parse characters from the 
input
          * until it encounters a non-java-identifier character. At that point
          *
-         * @param reader The reader reading from the template source
-         * @param target The target groovy script source we write to
+         * @param reader         The reader reading from the template source
+         * @param target         The target groovy script source we write to
          * @param sourcePosition The reader position in the source stream
          * @param targetPosition The writer position in the target stream
          * @throws IOException
@@ -723,10 +720,10 @@ public class StreamingTemplateEngine extends 
TemplateEngine {
          * append ';' then write the section as a statement
          */
         private void parseSection(final int pendingC,
-                final Reader reader,
-                final StringBuilder target,
-                final Position sourcePosition,
-                final Position targetPosition) throws IOException, 
FinishedReadingException {
+                                  final Reader reader,
+                                  final StringBuilder target,
+                                  final Position sourcePosition,
+                                  final Position targetPosition) throws 
IOException, FinishedReadingException {
             //the below is a quirk, we do this so that every 
non-string-section is prefixed by
             //the same number of characters (the others have "out<<\"\"\"${"), 
this allows us to
             //figure out the exception row and column later on
@@ -754,9 +751,9 @@ public class StreamingTemplateEngine extends TemplateEngine 
{
          * Parse a &lt;%= .... %&gt; expression
          */
         private void parseExpression(final Reader reader,
-                final StringBuilder target,
-                final Position sourcePosition,
-                final Position targetPosition) throws IOException, 
FinishedReadingException {
+                                     final StringBuilder target,
+                                     final Position sourcePosition,
+                                     final Position targetPosition) throws 
IOException, FinishedReadingException {
             append(target, targetPosition, "out<<\"\"\"${");
 
             readAndAppend(reader, target, sourcePosition, targetPosition);

Reply via email to