SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Request for Refactoring testing: Extract Method refactoring

Last post 05-12-2008 10:33 PM by siegi44. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-06-2008 7:38 PM

    • siegi44
    • Top 10 Contributor
    • Joined on 03-31-2006
    • Steyr, Austria
    • Posts 173
    • Team Members

    Request for Refactoring testing: Extract Method refactoring

    Hi,

    I have completed an "Extract Method" refactoring for C# as an add-in and now I wanted to ask you for help testing and reporting problems/bugs.

    You can download the Add-in file here (will only work for SD 3.0)

    Please report any problems you face or if you have any tips for improvement.

    Thank you! 

    Siegfried Pammer
  • 05-07-2008 7:48 PM In reply to

    Re: Request for Refactoring testing: Extract Method refactoring

    - I have to press Ctrl+Z multiple times to undo "Extract Method"

    - selected comments are deleted instead of moved to the new method

    - I think extracted methods shouldn't be public by default

    - When the whitespace at the start line is not included in the selection, the created method call is indented incorrectly

    In this code:

             static Instruction GetRealJumpTarget(Instruction instr)
            {
                if (instr == null)
                    return null;
                // use hashset to ensure the loop stops even if analysing an infinite loop
                HashSet<Instruction> hashset = new HashSet<Instruction>();
                while (instr.OpCode == OpCode.Jump && hashset.Add(instr))
                    instr = instr.JumpTarget;
                return instr;
            }

    - Extracting the loop: the created "instr" parameter should be a ref parameter because it's written to in the extracted code
    - the loop body is not indented correctly (CSharpOutputVisitor bug?)

    In this code:

    public static void Run(Function function)
    {
                // eliminate jumps to unconditional jumps
                foreach (Instruction instr in function.IntermediateCode)
                    instr.JumpTarget = GetRealJumpTarget(instr.JumpTarget);

    Try to extract the loop body. The refactoring should generate a parameter "instr", but it's missing.

    Daniel Grunwald
  • 05-08-2008 6:29 AM In reply to

    • siegi44
    • Top 10 Contributor
    • Joined on 03-31-2006
    • Steyr, Austria
    • Posts 173
    • Team Members

    Re: Request for Refactoring testing: Extract Method refactoring

     Thanks for your help...

    DanielGrunwald:

    - selected comments are deleted instead of moved to the new method

    I haven't found a way to keep them in the AST, aren't they parsed by NRefactory, if so how can I keep them? 

    DanielGrunwald:

    - I think extracted methods shouldn't be public by default

    They aren't meant to be, instead they should be private.

    DanielGrunwald:

    - When the whitespace at the start line is not included in the selection, the created method call is indented incorrectly

     Ok. Will fix this.

    DanielGrunwald:

    In this code:

             static Instruction GetRealJumpTarget(Instruction instr)
            {
                if (instr == null)
                    return null;
                // use hashset to ensure the loop stops even if analysing an infinite loop
                HashSet<Instruction> hashset = new HashSet<Instruction>();
                while (instr.OpCode == OpCode.Jump && hashset.Add(instr))
                    instr = instr.JumpTarget;
                return instr;
            }

    - Extracting the loop: the created "instr" parameter should be a ref parameter because it's written to in the extracted code
    - the loop body is not indented correctly (CSharpOutputVisitor bug?)

    In this code:

    public static void Run(Function function)
    {
                // eliminate jumps to unconditional jumps
                foreach (Instruction instr in function.IntermediateCode)
                    instr.JumpTarget = GetRealJumpTarget(instr.JumpTarget);

    Try to extract the loop body. The refactoring should generate a parameter "instr", but it's missing.

     

    Ok.

    I will fix these things.

    Thanks again. 

    Siegfried Pammer
  • 05-12-2008 10:33 PM In reply to

    • siegi44
    • Top 10 Contributor
    • Joined on 03-31-2006
    • Steyr, Austria
    • Posts 173
    • Team Members

    Re: Request for Refactoring testing: Extract Method refactoring

    OK. I fixed these problems. Thanks again.

    Daniel could you tell me where I should put my classes and how to integrate them into whole SharpDevelop Refactoring structure?

    Thanks again 

    Siegfried Pammer
Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.