Thrift
  1. Thrift
  2. THRIFT-481

indentation of ruby classes is off by a few

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 0.1
    • Fix Version/s: 0.9
    • Component/s: Ruby - Compiler
    • Labels:
      None

      Description

      For some reason it looks like the generator indents more than it outdents in some strange way, leading to the end of the file being indented several columns

        Activity

        Hide
        Kevin Clark added a comment -

        So, it used to do this because the indentation variable is global, and multiple files are generated concurrently. Mark and I had decided it wasn't a big enough deal to fix.

        Show
        Kevin Clark added a comment - So, it used to do this because the indentation variable is global, and multiple files are generated concurrently. Mark and I had decided it wasn't a big enough deal to fix.
        Hide
        Bryan Duxbury added a comment -

        Can you clarify what you mean by multiple files are being generated concurrently? I would have thought that we'd generate all of the types file, then all of the constants file, then all of the services, etc. Is this not the case?

        Show
        Bryan Duxbury added a comment - Can you clarify what you mean by multiple files are being generated concurrently? I would have thought that we'd generate all of the types file, then all of the constants file, then all of the services, etc. Is this not the case?
        Hide
        Kevin Clark added a comment -

        That's not the case. The generator does it bits at a time. See void t_rb_generator::init_generator().

        Show
        Kevin Clark added a comment - That's not the case. The generator does it bits at a time. See void t_rb_generator::init_generator().
        Hide
        Bryan Duxbury added a comment -

        Hm. Maybe I will have an intern refactor the code generation stuff like this over the summer

        Show
        Bryan Duxbury added a comment - Hm. Maybe I will have an intern refactor the code generation stuff like this over the summer
        Hide
        Ilya Maykov added a comment -

        Here is a candidate patch. The approach is really simple: create a subclass of std::ofstream that contains the indent level and has the methods: indent(), indent_up(), indent_down(). Then change the types of the 3 open files (f_types_, f_constants_, f_service_) to the new class and refactor all code to call the indent methods.

        Also does a bit of whitespace formatting (break up some long lines, combine some short lines) and adds a missing indent when generating docstring comments.

        Show
        Ilya Maykov added a comment - Here is a candidate patch. The approach is really simple: create a subclass of std::ofstream that contains the indent level and has the methods: indent(), indent_up(), indent_down(). Then change the types of the 3 open files (f_types_, f_constants_, f_service_) to the new class and refactor all code to call the indent methods. Also does a bit of whitespace formatting (break up some long lines, combine some short lines) and adds a missing indent when generating docstring comments.
        Hide
        Jake Farrell added a comment -

        looks good, Ilya please commit

        Show
        Jake Farrell added a comment - looks good, Ilya please commit
        Hide
        Ilya Maykov added a comment -

        Fixed in revision 1295423.

        Show
        Ilya Maykov added a comment - Fixed in revision 1295423.
        Hide
        Hudson added a comment -

        Integrated in Thrift #418 (See https://builds.apache.org/job/Thrift/418/)
        THRIFT-481: indentation of ruby classes is off by a few
        Compiler: Ruby
        Patch: Ilya Maykov

        Fixed indentation of gen-rb files by wrapping each file
        output stream in a class that keeps track of the indent
        level instead of using the global indent. (Revision 1295423)

        Result = FAILURE
        ilyam : http://svn.apache.org/viewvc/?view=rev&rev=1295423
        Files :

        • /thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
        Show
        Hudson added a comment - Integrated in Thrift #418 (See https://builds.apache.org/job/Thrift/418/ ) THRIFT-481 : indentation of ruby classes is off by a few Compiler: Ruby Patch: Ilya Maykov Fixed indentation of gen-rb files by wrapping each file output stream in a class that keeps track of the indent level instead of using the global indent. (Revision 1295423) Result = FAILURE ilyam : http://svn.apache.org/viewvc/?view=rev&rev=1295423 Files : /thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc

          People

          • Assignee:
            Ilya Maykov
            Reporter:
            Bryan Duxbury
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development