Features I miss in C++ ReSharper

  1. Prefer namespace alias over full namespace
    Consider following code

    #include "foo.h"

    namespace ss = spacename01::spacename02;

    int main()
    {
    spacename01::spacename02::foo f;
    ss::foo f1;
    return 0;
    }

    I would like to see ReSharper suggesting to use ss:: instead of spacename01::spacename02:: on "f" declaration
  2. in case of pointers or references declared in header file and definition header include suggest to switch to forward declarations, remove the include and move it to translation unit (if any)
  3. figure out how to make life easier when the header is cluttered with forward declaration. suggest to create separate include with forward declarations like it is done in boost?
  4. add a possibility to define "third party code" by location, for example "d:\Development\ThirdParties". detect includes in translation units from this location, suggest to move to precompiled header if employed.
  5. Add feature which is similar to CLang's Modernize (nowadays clang-tidy) http://clang.llvm.org/extra/clang-tidy/index.html (see modernize-* cli parameter), allow applying it on whole solution
  6. Allow removing all unnecessary includes from the whole project/solution
  7. Detect the case when the header is not selfcontained - consider following scenario, you have precompiled header, it has string header included, then you create new class and you declare a member of type std::string in its header, it will compile and the ReSharper will not complain because of the inclusion of the string header in precompiled header. it is wrong, since once you include the class header from outside of this project it will fail to compile in case the later does not have the string included somewhere.
4 comments

Hello,
Thanks for the ideas! Some comments:
1. I filed https://youtrack.jetbrains.com/issue/RSCPP-17140 for this feature. Please note that R++ has 'Introduce namespace alias' refactoring, which allows you to create a new alias and use it everywhere where possible in the current file.
5. We already have some of these features implemented, e.g. use override/nuillptr (with bulk versions), make_shared/make_unique, use auto. We'll continue adding more analyses.
6. Removing unnecessary includes is at the moment a risky operation - it does not guarantee that the project will compile, only that this header won't contain unresolved symbols when used in a particular source file which was used when performing the analysis. If the project does not follow include-what-you-use rule everywhere, removing unnecessary included in the entire project is likely to break compilation.
7. Parsing the header twice (once as it is compiled, and the other in self-contained mode) is costly, but we've been considering adding a global option to always use self-contained mode.
Thanks and let us know if you have any other suggestions!

0

*thumbs up*

as for item 5, I saw only "redundant qualifiers" are available as bulk operation but not for "auto" for example, did I overlook it?

6.1) sometimes thing have to be broken first, for being rebuilt the right way

6.2) I dont know what technology you are using to parse the code but if you are CLang based then you have the build database and the google's opensource which can be used with aforementioned database to remove unnecessary includes. see here https://github.com/include-what-you-use/include-what-you-use

 

0

I believe 'Add override specifier' and 'Replace expression with nullptr' are bulk fixes too at the moment. We'll be adding new bulk fixes based on requests.

We'll think about what's the best approach to run 'Remove unnecessary includes' over the entire project. We're using our own parser and code model, and the approach we use is similar to the one include-what-you-use uses.

Thanks!

0

Please sign in to leave a comment.