Here’s my tip on how to use the IDE’s code folding feature for good rather than evil.
Create a new LiveTemplate, call it “assert” and use this XML code for the template text.
<?xml version="1.0" encoding="utf-8" ?> <codetemplate xmlns="http://schemas.borland.com/Delphi/2005/codetemplates" version="1.0.0"> <template name="assert" surround="false" invoke="auto"> <point name="condition"> </point> <description> {$REGION 'Assert'}Assert(...){$ENDREGION} </description> <author> Lachlan Gemmell </author> <code language="Delphi" context="methodbody" delimiter="|"> <![CDATA[{$REGION 'Assert'}Assert(|condition|);{$ENDREGION}]]> </code> </template> </codetemplate>
Now trigger the template whenever you write an assert statement, which we all use liberally of course 😉
You’ll get an assert statement wrapped in a single line region. Sounds pointless but trust me there is a reason.
Fill in the assert condition and message parameters then collapse the region either with the mouse or the key combination Ctrl+Shift+K,E
Your distracting full length Assert statement will be reduced to a nice unobtrusive single word “Assert”. It makes code with lots of Assert statements much easier to read but doesn’t hide their existence from you.
I also do a similar thing with SmartInspect/CodeSite logging statements.
You’ll find an extended video walkthrough including the LiveTemplate creation process here.