Feature suggestion: Dead Code Removal.

Monkey Archive Forums/Monkey Discussion/Feature suggestion: Dead Code Removal.

Steve Ancell(Posted 2014) [#1]
Would it be possible to have "Dead Code Removal" in a future update, or would that be asking for too much. Don't want to sound like I'm extracting the urine or anything. ;)


dragon(Posted 2014) [#2]
it is build in...

if you have a function foo():

Function foo:Void()
bar()
End

and you never use foo() somewhere
this function is never checked and converted
so if you call bar() inside foo() - and bar() does not exist, you do not get a error...


to ENABLE dead code checking, use:
#REFLECTION_FILTER="*"
Import reflection


ziggy(Posted 2014) [#3]
You can also disable dead code removal for current file only by adding this instead (it compiles faster):
import reflection
#REFLECTION_FILTER+="${MODPATH}"



Steve Ancell(Posted 2014) [#4]
What I actually meant is a method of actually removing unused code from the source, suck as a "DCR" button add-on in the edit menu within the IDE.

[edit]I'm not sure if that extra button would be a Monkey-X or JungleIDE feature though[/edit]


Steve Ancell(Posted 2014) [#5]
Also thanks dragon and ziggy for that bit of info, I never knew about that built-in reflection filter thing.


ziggy(Posted 2014) [#6]
I'm not sure if that extra button would be a Monkey-X or JungleIDE feature though
I think trans could be easily modified to output what AST nodes are being excluded from final compilation. Then, any IDE could get this information and "gray" or "shadow" or whatever this areas of code in the editors, so the coder knows for sure if any of the source code being edited is never checked for errors. So, for me, the answer would be that it should be "calculated" by trans to grant accuracy, and used by IDEs to provide user interaction with this information


Samah(Posted 2014) [#7]
@ziggy: Then, any IDE could get this information and "gray" or "shadow" or whatever this areas of code in the editors...

That sounds like a Jungle IDE feature request to me, ziggy. :)


Arjailer(Posted 2014) [#8]
This would be great. With the way I code (constantly refactoring and refining) I always end up with a pile of unused code.

I even wrote a Blitz3D unused code removal plug-in for the old Protean IDE :-)