[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Refactorings you are missing

The bugzilla list looks a lot like nobody cares for C anymore.

e.g. wishlist/thoughts applicable to C (not just C++)
* Change if-elseif-elseif--else to switch-case
* Change for-loop to while-loop, while-loop to for-loop, while to do-while
* Specify/Add/Remove module prefix to function(s)/vairable(s) (only externs, only statics, extern and statics)
* Change function from extern to static and static to extern (incl moving the prototype from .h to .c and from .c to .h)
* Change variable from extern to static and static to extern
* Move function(s)/variable(s) to other or new module
* Sort structure members by size/alignment (optimize for padding)
* Change scope of variables


    static int i = 0;            void foo(void)
    void foo(void)               {
    {                                static int i = 0;
        i++;                         i++;
    }                            }

* Sort variables/prototypes into sections (e.g. variables declared anywhere within a file into a section at the top of the file)

static int i;                   /* Types */
void foo(void)                  typedef struct {
{                                   int a;
   i++;                         } mystruct;
}
                                /* Variables */
static void baz(int);           static int i;
void bar(void)                  static int j;
{                               mystruct my_baz;
    baz(20);
}                               /* Prototypes */
                                static void baz(int);
static int j;
typedef struct {                void foo(void)
    int a;                      {
} mystruct;                        i++;
mystruct my_baz;                }
static void baz(int k)
{                               void bar(void)
   my_baz.a = i * k;            {
}                                   baz(20);
                                }

                                static void baz(int k)
                                {
                                   my_baz.a = i * k;
                                }


* Change function/variable signatures to AUTOSAR compiler abstraction and memory mapping
(see http://www.autosar.org/download/R4.1/AUTOSAR_SWS_MemoryMapping.pdf and
http://www.autosar.org/download/R4.1/AUTOSAR_SWS_CompilerAbstraction.pdf for backgroud and spec)


void MOD_Mainfunction(uint32 a, uint8* p, const uint8* cp, uint8* const pc);
   vs.
FUNC(void, MOD_CODE) MOD_Mainfunction( VAR(uint32, AUTOMATIC) a,
                                       P2VAR(uint8, AUTOMATIC) p,
                                       P2CONSTVAR(uint8, AUTOMATIC) cp,
                                       CONST2PVAR(uint8, AUTOMATIC) pc) )




Am 10.05.2013 21:12, schrieb Nathan Ridge:
As a full-time Eclipse CDT user, I have many suggestions on this front.

In addition to the refactorings that were already mentioned, I think
it would be nice to see the following:

  - "Create method" as a quick fix when a method is unresolved
  - "Create function" as a quick fix when a function is unresolved
  - "Create class/struct" as a quick fix when a type is unresolved
  - "Inline variable" as the complement of "extract variable"
  - "Extract method" and "inline method" (analogous to "extract variable" and "inline variable")
  - Replace "auto" with the type it stands for
  - Replace a conventional for loop with a range-based for loop (need to detect where this is possible)

Also, here's a user interface improvement to the rename refactoring
that recent versions of ReSharper do for C#: rather than forcing
the user to invoke a rename refactoring, they detect when the user
changed an identifier via regular typing, and suggest to perform
the corresponding rename refactoring. I think it would be awesome
if CDT could do this.

Regards,
Nate 		 	   		
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev