Groovy
  1. Groovy
  2. GROOVY-5017

[PATCH] SimpleTemplateEngine line number is off by one

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.3, 1.9-beta-4
    • Component/s: None
    • Labels:
      None
    • Flags:
      Patch

      Description

      Line number reported from scripts compiled by SimpleTemplateEngine is off by one because it generates an extra new line that's not found in the original source file. Patch attached.

      1. DIFF
        0.7 kB
        Kohsuke Kawaguchi

        Activity

        Kohsuke Kawaguchi created issue -
        Hide
        Roshan Dawrani added a comment -

        Thanks for the patch. A slight improvement suggested below.

        If we currently have script generated as a), with the patch it looks like b)

        a)

        -- script source --
        /* Generated by SimpleTemplateEngine */
        out.print("""Hello \"$firstname\",
        Nice to meet you in """); print city ;
        out.print("""""");
        
        -- script end --
        

        b)

        -- script source --
        /* Generated by SimpleTemplateEngine */out.print("""Hello \"$firstname\",
        Nice to meet you in """); print city ;
        out.print("""""");
        
        -- script end --
        

        With slightld modified patch, it looks like c)

                 private void startScript(StringWriter sw) {
        -            sw.write("/* Generated by SimpleTemplateEngine */\n");
                     sw.write("out.print(\"\"\"");
                 }
         
                 private void endScript(StringWriter sw) {
        -            sw.write("\"\"\");\n");
        +            sw.write("\"\"\");\n\n/* Generated by SimpleTemplateEngine */");
                 }
        

        Suggested new output that preserves the line numbers of the original script, but reads slightly better

        -- script source --
        out.print("""Hello \"$firstname\",
        Nice to meet you in """); print city ;
        out.print("""""");
        
        /* Generated by SimpleTemplateEngine */
        -- script end --
        
        Show
        Roshan Dawrani added a comment - Thanks for the patch. A slight improvement suggested below. If we currently have script generated as a), with the patch it looks like b) a) -- script source -- /* Generated by SimpleTemplateEngine */ out.print("""Hello \"$firstname\", Nice to meet you in """); print city ; out.print(""""""); -- script end -- b) -- script source -- /* Generated by SimpleTemplateEngine */out.print("""Hello \"$firstname\", Nice to meet you in """); print city ; out.print(""""""); -- script end -- With slightld modified patch, it looks like c) private void startScript(StringWriter sw) { - sw.write( "/* Generated by SimpleTemplateEngine */\n" ); sw.write( "out.print(\" \ "\" "); } private void endScript(StringWriter sw) { - sw.write( "\" \ "\" );\n"); + sw.write( "\" \ "\" );\n\n/* Generated by SimpleTemplateEngine */"); } Suggested new output that preserves the line numbers of the original script, but reads slightly better -- script source -- out.print("""Hello \"$firstname\", Nice to meet you in """); print city ; out.print(""""""); /* Generated by SimpleTemplateEngine */ -- script end --
        Hide
        Kohsuke Kawaguchi added a comment -

        I don't have any objection at all (in fact as far as I'm concerned, I couldn't care less about this "generated by" comment.)

        Show
        Kohsuke Kawaguchi added a comment - I don't have any objection at all (in fact as far as I'm concerned, I couldn't care less about this "generated by" comment.)
        Hide
        Roshan Dawrani added a comment -

        Good. There shouldn't probably be, but will just wait for a little bit to see if other devs see any potential impact.

        Show
        Roshan Dawrani added a comment - Good. There shouldn't probably be, but will just wait for a little bit to see if other devs see any potential impact.
        Hide
        Jochen Theodorou added a comment -

        looks like a good idea to me

        Show
        Jochen Theodorou added a comment - looks like a good idea to me
        Hide
        Guillaume Delcroix added a comment -

        Good idea too here!

        Show
        Guillaume Delcroix added a comment - Good idea too here!
        Roshan Dawrani made changes -
        Field Original Value New Value
        Assignee Roshan Dawrani [ roshandawrani ]
        Roshan Dawrani made changes -
        Fix Version/s 1.8.3 [ 17657 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.9-beta-4 [ 17656 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733943 ] Default workflow, editable Closed status [ 12745752 ]
        Mark Thomas made changes -
        Flags Patch [ 10430 ]
        Patch Submitted Yes [ 10763 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971481 ] Default workflow, editable Closed status [ 12979300 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        15h 33m 1 Roshan Dawrani 14/Sep/11 13:47
        Resolved Resolved Closed Closed
        29d 11h 41m 1 Paul King 14/Oct/11 01:28

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Kohsuke Kawaguchi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development