CodeRush Tip – Quick Navigation – Build your own Search

As we saw in our previous post, Quick Navigation has many filter options available to for you to fine tune your search, and it will even remember these choices between usages.

What’s less well know about CodeRush, is that many of the commands support the passing of parameters.

In the case of the QuickNav command, 4 parameters are accepted (TypeFilter, MemberFilter, AccessFilter and LocationFilter)
Each of these parameters have several different values which may be passed.

At this point I think it’s worth paying homage to AlexS and a forum post now nearly 3 years old, but no less valid for it.

To quote some of his post…
-------------------------------------------------------------
TypeFilter -- defines default type filter for the Quick Navigation.
Use the following values to setup default type filter: Classes, Interfaces, Structs, Enums, Delegates, AllTypes.
Use "and" keyword to combine filters together like this: Classes and Structs

MemberFilter -- defines default member filter for the Quick Navigation.
Use the following values to setup default member filter: Methods, Properties, Events, Fields, LocalsAndParams, AllMembers.
Use "and" keyword to combine filters together like this: Methods and Properties.

AccessFilter -- defines default access filter for the Quick Navigation.
Use the following values to setup default access filter: Private, Protected, Internal, ProtectedInternal, Public, AllVisibilities.
Use "and" keyword to combine filters together like this: Private and Protected.

LocationFilter -- defines default location filter for the Quick Navigation.
Use the following values to setup default location filter: AllFiles, CurrentSolution, CurrentProject, CurrentNamespace, CurrentFile.
You can not use "and" keyword here to combine filters together.
-------------------------------------------------------------
Note: These parameters should be comma separated, in order, leaving blanks for unset parameters.

So by creating a new shortcut and passing the right parameters, we can start to create our very own sub features.

For example, I like to use this facility to setup:

  • Ctrl+T –> Find Types in Solution
  • Ctrl+M –> Find Members in File

To create the 2 features mentioned above, use the following bindings and parameters:

Find Types in Solution
Bind to : Suggest Ctrl+T
Command: QuickNav
Params: AllTypes, , AllVisibilities, CurrentSolution

Find Members in File
Bind to : Suggest Ctrl+M
Command: QuickNav
Params: , AllMembers, AllVisibilities, CurrentFile

It should be noted that these shortcuts will set the options, open Quick Navigation and perform the search. You are entirely free to use the resultant screen as is, or tweak the options further and really narrow your search.

  • If you use these shortcuts again, they will restore the options to the assigned settings.
  • Use of the raw Quick Navigation function (Ctrl+Shift+Q) will remember whatever set of options were last configured.

Happy searching

no comments
No Comments

Please login or register to post comments.