CLion 2019.3 EAP: C++20’s Concepts, Go to Header/Source, and .lldbinit

Hi,

A new CLion 2019.3 EAP (build 193.5096.27) is now available! Get it from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). A patch-update for anyone using the previous EAP build will be available shortly.

DOWNLOAD CLION 2019.3 EAP

Key highlights:

Support for C++20’s Concepts in CLion

Concepts are one of the biggest and most important features coming in the C++20 standard. We’ve been collaborating with Saar Raz, the author of the Concepts support in Clang, and have merged his Clang branch into our custom Clangd-based language engine in CLion, and implemented a few things on top:

  • Parsing and custom highlighting
  • Code inspections, like Unused Concept
  • Code completion
    • Completions on template type parameters that are constrained
    • Completion for types constrained by std::is_base_of<MyBase, T> and std::is_same<Other, T>
  • Refactorings and navigation actions for Concepts
    • Rename
    • Go to Definition
    • Find Usages

Concepts completion

To learn more about CLion’s support for C++20’s Concepts, please see our dedicated blog post.

Action to switch between header/source files

To switch between header/source files, CLion has offered Go to Related Symbol. This IntelliJ platform action is smart as it tries to find related symbols across the whole project, but it may also cause some issues and inaccuracies when used for switching between header/source use case:

  • It tries to locate the cursor in the newly opened file on a related class/function definition, which is often inconvenient.
  • It tries to find the best option and just goes there without asking the user to select from the available options (this often causes issues for cases with one header plus many source files, or a .h/.inl/.cpp triple).
  • Because it tries to be so smart, it might be heavy in terms of performance (as it looks through all the project symbols).
  • Several heuristics exist which could be quicker and superior in many situations when switching between header/source. None of them is used by this general Go to Related Symbol action.

To address these issues, we’re introducing a new "Go to Header/Source" action:
Go to Header/Source

As you can see, it either opens a file in the editor right away or shows the popup with various options. This action uses a few heuristics for the search:

  1. The most recent switched file is always at the top of the list.
  2. Next goes the file with the matching name from the same directory, if any (for example, myfile.h / myfile.cpp).
  3. Then, a definition/declaration-based search is performed in the background (which looks for files with definitions with matching declarations in the current file, and vice versa), and new items are added to the popup.
  4. Note that the search is currently limited to direct includers/includees so as to avoid interference from the same symbols from different targets.
  5. If no single destination is found within 500 ms, CLion shows an interactive popup where new items are added and you can select where you want to navigate to.

There’s one last thing worth mentioning. We understand that CLion users mostly use Go to Related Symbol as a Go to Header/Source action and might be accustomed to this shortcut. From now on, if you invoke Go to Related Symbol via the keyboard shortcut in a C/C++ file, and the non-default shortcut is not yet set for Go to Header/Source, CLion will ask you – only once per installation – if you’d like to remap the current shortcut from Go to Related Symbol to Go to Header/Source:
Remap the shortcut

LLDB: read .lldbinit from the project root

We’ve recently added an ability to read .gdbinit from the project root. It’s now time to enable it for .lldbinit as well.

You may find this useful to tune the LLDB debugger behavior via passing some commands and options in a .lldbinit file. Note that to enable this behavior, you have to explicitly allow it in your home .lldbinit file. Please see this for the exact commands.

Full release notes are here.

DOWNLOAD CLION 2019.3 EAP

Your CLion Team
JetBrains
The Drive to Develop

This entry was posted in Announcement, Early Access Preview and tagged , , , , , . Bookmark the permalink.

28 Responses to CLion 2019.3 EAP: C++20’s Concepts, Go to Header/Source, and .lldbinit

  1. Adam Papousek says:

    I have briefly tried the Go to Header/Source action (which I was missing greatly btw) and what seems to happen quite often is that I invoke it and get a list of just the one file I want requiring me press Enter.

    For example I am in a file “Foo.cpp” invoke the action and I get a “Go to Header/Source” titled window with just “Foo.h”. I would expect CLion to just switch to “Foo.h”.

    • Anastasia Kazakova says:

      Yes, we’ve seen such behaviour. For now, the algorithm still has to check there are no other options. So from the good side, you can instantly navigate to the option found already by pressing Enter, from the other side, you are not navigated automatically as CLion still searches the other options. We are now thinking about a solution to such cases.

      • Taw says:

        I also am in the same situation, I hate the dropdown list, which appears almost every time (perhaps my project is wrong, I think that we have multiple headers for one source file), but it’s still annoying. For example I have ctr+tab is my shortcut for this and then I have to press Enter located at the other side of the keyboard.

        • Anastasia Kazakova says:

          Is there also only one option in the list for you?

          • Taw says:

            No, mostly there are multiple options but I rarely want to select from the list the desired header. If I have multiple headers, I would like to go to the one with the same name (if exists) as the src file.
            If I want to go to that specific function from the header, I go to that function and press “go to declaration”.

          • Anastasia Kazakova says:

            The header with the same name is placed on top, as the most relevant. However, we can’t simply jump to it instantly, as there might be others, also relevant headers to navigate to. Go to Related Symbols behaved like that (jump instantly) and was not always correct, so we had complaints from our users.

  2. Renat says:

    I use eap all the time and I am constantly experiencing various crashes. I report all crashes to you. Are you checking them?

  3. Taw says:

    You guys removed the brackets between file names and files paths for Navigate-File (I opened IDEA-223210 for this, because I think it was a mistake, the brackets were great) but you kept them for Navigate to header/source. Why this inconsistency?

  4. Taw says:

    A question please: The “Go to header/source” feature is very nice, is there any situation in which “Go to Related Symbol” works better?
    Thanks :)

    • Anastasia Kazakova says:

      Go to Related Symbol is a more general platform action, which also tries to locate the cursor in the newly opened file on a related class/function definition. In case, you just need to navigate between header/source, you’d better use a new action.

      • Taw says:

        Sorry I am not understanding this very clear: so if I have 3 headers associated to a src file, when I put the cursor in a function and press “go to related symbol”, it should navigate to the corresponding header which contain that function declaration? Because it does not.

        Also “Go to Related Symbol” works better in some situations, first it searches the include file with the same name, but “Go to header/source” does not. I opened CPP-17982 for this.

        • Anastasia Kazakova says:

          If you are switching between header/source, there might be several options. Go to Related symbol just select one (which might be incorrect in C++), while Go to Header/Source shows the list with the option sorted as I’ve described in the blog post. This is the major difference I guess.

          We’ll follow-up on the particular problem in YouTrack.

          • Taw says:

            I see a lot of bugs related to this feature not working ok.
            I recently opened CPP-18031, which is a blocker for me, so I will continue using “go to symbol”, it’s not perfect, but it works a lot better in some situations.

          • Anastasia Kazakova says:

            Could you please handle the question in the ticket regarding the inclusion mechanism you use there?

  5. Maxim Yanchenko says:

    Just tried to use “Go to header/source” – it always shows “No related files” even though the related file is right here in the same directory.
    E.g. a makefile project with compile_commands.json, file names Application.H and Application.C, normal “Go to related” works perfectly fine.

  6. Roman Popov says:

    I’ve been using new EAP for couple of days now, and my experience with new “switch header/source” had been great so far. Thanks!

    But unfortunately its not a silver bullet, you will need to solve other navigation actions too. Another thing I suffer from is navigate from “forward declaration” to “full declaration(definition)”. In a project I have to work with forward declarations are heavily misused : they are everywhere.
    And I know for sure it can be solved with some heuristics too, because when I navigate in Sublime Text using a simple text search and my brain I often can find definition faster than Clion using 32 brains of my multicore CPU!
    So, IMO, navigate to definition should work the same way : Pop Up Window with heuristic results.

Leave a Reply

Your email address will not be published. Required fields are marked *