Working with CMake project - ReSharper always makes clean analysis, when the CMake cache is regenerated

Hello, 

 

I'm trying to use the ReSharper with CMake in Visual Studio 2017.

Our codebase is pretty huge (contains a lot of and large 3rd party libs) and the ReSharper's analysis takes a long time (maybe 30-60 minutes). I kinda get this, it does a lot of complicated things, so that's fine (at least in the latest version, restarting the Visual Studio now does not cause a new complete analysis).

But now I have the following problem - every time the CMake cache is regenerated, the whole analysis starts from the very beginning again.. this disables the whole ReSharper and even control-click stops working.

Even more, the analysis happens not only when the CMake cache is cleaned and generated, it happens every single time a CMakeLists.txt is touched.

My current case - when I add a new source file, the CMake cache is regenerated  (to "catch" the new file) and this causes a completely new/clean ReSharper analysis, which does not seem normal to me. This would mean hours and hours of waiting for the analysis to finish just because of added/removed single source file.

Could you, please, advice?

 

Thanks in advance!

Best Regards, 

Kiril

 

P.S. Even more, while ReSharper is analyzing, I can't even comment-out a line with ReSharper's key shortcut.. it just shows "ReSharper is thinking... (Esc to cancel)". Why would the analysis beak literally everything, related to the ReSharper?

P.P.S. Sometimes, when I open VS, the ReSharper does not load its cache/symbols/etc. It says it's OK, there's a green 'check' at the bottom, but it actually does not work at all (like it's uninstalled, but it still shadows VS's equivalent features). Restarting VS (several times) 'fixes' the issue.

7 comments
Comment actions Permalink

Hello,

This is not intended behavior, please let us help understand better what's happening. With CMake projects, ReSharper should start reindexing only when include paths or compilation command lines change as the result of touching CMakeLists.txt.

Could you please do the following:

1) Run Visual Studio with the /ReSharper.Internal command line argument.
2) Go to ReSharper->Options->Logging, click on "Create file" in the Logger Configurations->Hive line, and paste the following configuration (with the path to the log file changed to your liking):

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="file" class="JetBrains.Util.Logging.FileLogEventListener" pattern="%d{HH:mm:ss.fff} |%l| %-30c{1}| %M%n">
<arg>c:\tmp\resharper-{date}.log</arg>
</appender>
<logger name="JetBrains.Platform.VisualStudio.SinceVs15.ProjectModel.OpenFolderFileContextTracker" level="TRACE">
<appender-ref>file</appender-ref>
</logger>
</configuration>

3) Reproduce the reindexing after CMakeLists.txt gets touched.

4) Attach the resulting log to https://youtrack.jetbrains.com/issue/RSCPP-19506.

I should be able to tell what exactly causes the reindexing based on that log.

To answer the reindexing question - most of R# actions require an abstract syntax tree to operate upon. To build an AST for a header file, you need to find a .cpp file which includes that header file. To do that you need to "compile" them one by one until you find a source file which includes the header. That's mostly why some actions might be not available during indexing. For source files e.g. "Comment line" should work as soon as the AST is ready (which might take longer than usual during indexing because included headers have not been parsed yet). Anyway, we hoped that with CMake projects reindexing would trigger relatively rarely.

Thanks!

0
Comment actions Permalink

Hi again, 

Thanks for you response!

 

I executed the steps above. I edited a CMakeLists.txt (from a subdir, not the even the general one) just by adding a new empty line and saving it.That triggered regenerating CMake cache and also a completely new ReSharper analysis.

Before the end of the analysis, I deleted the empty line and saved the CMakeLists.txt again. The CMake cache was regenerated again, but ReShaprer didn't seem to restart its own analysis. After the analysis finished, I restarted VS.

 

Thanks a lot! I hope the attached file is helpful.

Kiril

0
Comment actions Permalink

Hello, 

I have one more question. We use a lot of 3rd party libs (located in a subdirectory of our main project directory). VS' intellisense analyzes them for about a minute or two, while the ReSharper analyzes them for about 2 hours (literally).

Is there something we can do about this? Maybe move the 3rd party libs outside of our main project dir (I guess this will not help)? Or somehow ignore them in ReSharper? I added them inside Code Inspection -> Settings -> Elements to skip and now the ReSharper does not show warnings/errors in them, but it still analyzes them, which takes huge amount of time. 

Or, maybe, is this analysis parallel? If not, can we turn on parallel analysis?

 

Thanks a lot!

Kiril

0
Comment actions Permalink

Sure, you can exclude files from the indexing process, but the correct settings page is "Third-Party Code". You need to add a file masks to the list of file masks in the "Skipped code" section (see https://www.jetbrains.com/help/resharper/2017.1/Reference_Options_Code_Editing_Third_Party_Code.html for details).

Sorry it's so confusing at the moment, we aim to consolidate all the options that allow to exclude files from indexing/analyzing in the next release.

Thanks!

0
Comment actions Permalink

That's some great news, thanks!

But if I add all 3rd party libs there, will I still be able to find their declarations/definitions? I mean, will VS/R# still be able to lead me to their locations/includes/declarations/definitions/etc. via 'ctrl+click' for example? Or this will force R# to totally ignore these files? How is this supposed to behave?

EDIT: Sorry, I wrote this post before reading the link from the post above. I'd still ask you something - what if we add all the 3rd party libs in Skipped Code, as you suggest, will it still be able at least to find the declarations in the headers (in the include path)? It looks like we need some option, that's in-between "Skipped code" and "Library code", doh!

Sorry for the question, I didn't test it, I'm first asking because I'd like to skip a potential completely new analysis of the whole codebase. 

If it still does some lightweight analysis, that allows the things above, that would be great! If not, could you give some other advice what I could do? 

Thanks a lot!

Kiril

0
Comment actions Permalink

It's supposed to exclude only indexing roots (normally .cpp files), so if a .cpp file that is indexed includes some header files, their contents will be indexed regardless of third-party settings (since this is necessary for correct parsing). So in practice you should be able to just add the directories with third-party libs to "Skipped code", and if you include a header from this library, ReSharper will be able to navigate to it.

Of course, some features won't work (e.g. auto-import completion for non-indexed libraries), but it's probably the only way to use R++ if you have so much code. Let me know if you have other problems with configuration of the indexing process.

0
Comment actions Permalink

Thank you very much for your assistance and for complete and explanatory answers!

 

To the original point: I'll write here again, once 2017.1.2 is available and when I try the fix.

0

Please sign in to leave a comment.