New CodeRush Plugin – CR_CollapseXML

Another new plugin! This one requested by a customer so they could collapse some XML (or HTML) on command.

Is there any way to have CodeRush collapse HTML or XML elements which have a ‘name’ or ‘id’ attribute?

The theory behind this is that those elements with an id or name attribute, are typically the ones that hold the high level structure. Collapsing these items will cause the structure of the HTML to be revealed.

In some ways it ‘s like CodeRush’s own Collapse to Projects functionality in solution explorer.

The user wishes to get a high level view of their HTML so that they can decide which area to drill back down into.

Now CodeRush doesn’t naturally support this functionality for HTML/XML out of the box, but you guys know me by now Smile

Yeah I wrote a plugin Smile

CollapseXML for CodeRush

CollapseXML works (despite it’s name) on both HTML and XML. It adds a new command (CollapseXML) which you can bind to any key you like.

Once installed and configured, simply place your caret within an XML or HTML file, and invoke the command using your configured key.

CodeRush will happily collapse your XML/HTML from…

HTMLExpanded

… to…

HTMLCollapsed

Availability

This plugin is available from either The Visual Studio Gallery or from GitHub

The source is available on Github

7 comment(s)
richard morris
richard morris

Nice plug-in.  

Unfortunately it doesn't work in a .dxview (DevExtreme's HTML files) files.

11 September, 2014
Rory Becker (DevExpress)
Rory Becker (DevExpress)

You are correct.

This is because CodeRush doesn't currently see .dxview files as html from a parser perspective.

I believe this is being looked at internally as we speak.

11 September, 2014
richard morris
richard morris

I have an interim build of DevXtreme (14.1.6.14237) and CodeRush (14.1.6.14254) that addressed the shortcoming that CR HTML expansions weren't working in .dxview files in the release build.

Unfortunately your plug-in doesn't work on this build :(

12 September, 2014
Rory Becker (DevExpress)
Rory Becker (DevExpress)

The builds I have don't appear to address this so far. I've pinged the team though, so I'm sure we'll have a solution soon.

12 September, 2014
Rory Becker (DevExpress)
Rory Becker (DevExpress)

Working with the builds you suggest, I was able to confirm that the plugin does work as expected with <div> tags.

However the source section of the designer seems to display some other tags without collapsible regions, which caused my plugin to be unable to collapse them.

Are all tags failing, or are some working?

15 September, 2014
richard morris
richard morris

Thanks for looking into it.

I'm using VS2010, the .dxview designer doesn't seem to do outlining like the .html designer which would probably make a difference.

I can create a bunch of divs using CodeRush' .d expansion in the .dxview give them a unique ID attribute, then hit the key combo I've associated with CollapseXML and nothing will happen.  If I close the designer and rename the .dxview into .html and open it in the .html editor it seems to work.

16 September, 2014
Rory Becker (DevExpress)
Rory Becker (DevExpress)

I have finally managed to get a copy of VS2010 installed.

I can confirm that the designer does not appear to show outline elements for any div or p tag.

These are certainly a requirement for the collapse mechanism.

I suggest you raise this as a bug/feature request against the .dxview designer.

18 September, 2014

Please login or register to post comments.