One thing that is missing from the PB IDE is refactoring tools. Refactoring changes your source code to a more readable form without changing its output. Managing a large project is tedious if you have to do all refactoring by hand, when it could be automated. I know the upcoming IDE automation feature will probably help us write our own refactoring tools, but here are some ideas anyway! I don't know how many people would find this functionality useful, but I've noticed on my current project (300k source code at the moment) that refactoring takes ages. Anyway, I think these refactoring tools in particular could be helpful:
Code: Select all
Append/prepend a string to all procedures in selection/file/project
Append/prepend a string to all structures in selection/file/project
Append/prepend a string to all global/local variables in selection/file/project
etc.
Renames all items (procedures, structures, variables, parameters etc). by appending or prepending a given string for all items found inside a selection, currently selected file or the whole project.
Code: Select all
Rename procedure and all references to that procedure in selection/file/project
Rename structure (or structure field) and all references to that structure (or structure field) in selection/file/project
Rename parameter in a procedure and all references to that parameter
etc.
Renames the selected item (procedure, structure, variable etc.) and automatically renames all references pointing to that item (procedure calls, structure references and so on). Finding and renaming the items using regular expressions would be good also.
Code: Select all
Remove unreferenced procedures in selection/file/project
Remove unreferenced structures (or structure fields) in selection/file/project
etc.
Removes dead code by removing items (procedures, structures, variables etc.) that are not used inside the current selection, current file or the whole project. This includes uncalled procedures, unused structures and so on. I think this has been requested before, and implemented too as an external tool. Native support would be nice though.
Code: Select all
Declare all procedures in selection/file/project
Declare all variables in selection/file/project, respecting scope
Goes through the code and creates declarations for all found procedures or variables. I believe this too has been requested before. I know of a couple of tools that do this, but again, native support would be nice.
Code: Select all
Move all procedure declarations to top
Move all variable declarations to top (of procedure)
The first function moves all procedure declarations found inside the current selection, current file or the whole project to the top of the selection, or places them in a separate window or clipboard where it could be placed at a user-defined location after running the tool. The second one moves all variable declarations found inside procedures to the beginning of that procedure. An option to group variable declarations onto a single line might be helpful to clear clutter.
Code: Select all
Move all procedures that match a given regular expression (or simply all procedures) into a given file
Move all structures that match a given regular expression into a given file
Move all prototypes/structures/interfaces/macros into a given file
etc.
Moves all items (procedures, structures, interfaces) inside a selection or file (and optionally whose names match a given regular expression) into a specified file. This way code dealing with a specific part of your program could be more easily separated into its own file.
Sorts all found procedures inside selection or file (with given options, i.e. ascending/descending etc.) Might be tricky as there can be code in-between the procedures. Maybe separate procedures into groups before sorting when there is more than whitespace (i.e. code or comments) between them.
Unroll loop unrolls loops that can be unrolled. Maybe have an option for unroll strength (i.e. how many iterations to unroll a loop). Loop refactoring could automatically refactor While (Expression that evaluates to true at compile time) : Wend to Repeat : Forever or remove While (Expression that evaluates to false at compile time) : Wend loops and everything inside.
Refactors if-constructs by removing code inside branches that evaluate to false at compile time. Remove if-constructs around a code block when they evaluate to true at compile time. Folding if-constructs inside if-constructs to their parent if possible would be great (by turning If X : If Z into If X And Z). Possibly rather tricky to implement.
Perform all constant folding that can be done at compile-time (i.e. replace all expressions like 4+5*2 directly with their results, if one can be calculated during the compiling process). I know this is done at compile-time but for readability I would like to be able to perform it myself.
Those are the ones I can think of, are there any more you can come up with? I know some of these are rather overkill and some could be solved by implementing regular expression search & replace or by writing a small tool, but I know all of these would have helped me in my current project.