Rider Disable import reordering when formatting C++

Answered

When you format the code the imports are reordered. That for Unreal Engine projects is a big problem. When you format the code, how can I disable import reordering in C++?

 
 
0
5 comments

Hi. While in the editor, press Ctrl+Alt+Shift+L (Cmd+Alt+Shift+L on Mac). This will bring up the 'Reformat File' dialog with additional options which you can turn on or off.

In your case, disable the option to "Optimize Imports".

See also: https://www.jetbrains.com/help/idea/2023.2/reformat-and-rearrange-code.html#reformat_file

-1

This is what appears:
https://i.imgur.com/emvBJdQ.png
and in the edit button, I can't check or uncheck anything C++ (it's static) and the C++ doesn't appear either
https://i.imgur.com/VudjdWv.png

And if instead of telling me the hotkeys you tell me where it is in the settings section?

A custom one doesn't work either.
https://i.imgur.com/UO2SgRs.png
To others, as I already said, C++ does not appear

I don't think it's the option. Optimizing the amounts is so that the libraries are automatically imported. It has nothing but nothing to do with sorting while formatting.

 
0

my comment is not seen in public... that's good. Well, let all your colleagues know.
https://i.imgur.com/k8IrxWA.png

By the way, it will seem silly to you just like it did to me.
When you told me this about what can be modified from there, I created another profile, "something" was recompiled and now it gives problems of the type:

   AITestSuite.Build.cs(1, 32): [CS1514] { expected
   AITestSuite.Build.cs(20, 2): [CS1513] } expected
   Microsoft.MakeFile.targets(44, 5): [MSB3073] The command "E:\UnrealEngine\Engine\Build\BatchFiles\Build.bat -Target="***Win64 Development -Project=\"D:\Epic Games \Projects UE\"***\"***.uproject\"" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.

You: "That's not possible since..."
Me: "Have you programmed Rider or Intellij?" end of discussion.
https://i.imgur.com/4eWdRxl.png

So, since you told me to press CTRL+SHIFT+ALT+L and modify it from there when I couldn't modify it, I created a new profile and it broke everything. Thank you, now I can say it openly incompetent.
Every time I hear something from you Intellij, I have no end of problems.

This is not a 1 GB student project. This is a 25GB project in real life and if you make a mistake I'm not going to give you a "0" I'm going to punish you. Now my project weighs 50 GB

Can you please tell me how to disable import reordering in C++?
I don't want any of your classmates to answer. You are going to have to be yourself, even if you ask your partner, you are going to have to give me the solution yourself.

By the way, you are already fixing this error since it was caused thanks to you:
AITestSuite.Build.cs(1, 32): [CS1514] { expected
    AITestSuite.Build.cs(20, 2): [CS1513] } expected
    Microsoft.MakeFile.targets(44, 5): [MSB3073] The command "E:\UnrealEngine\Engine\Build\BatchFiles\Build.bat -Target="***Win64 Development -Project=\"D:\Epic Games \Projects UE\"***\"***.uproject\"" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.

I'm too sick of nonsense.
Arina Efremova, I await an answer to both problems.

I will wait for both responses.

Note: I'm already seeing you coming.
Whose fault is it? You for telling me that place or me trying to do what you told me? and seeing that your solution didn't work, so I tried to create a profile without checking optimized imports. I ran that and it started doing too many things.
Keep in mind that the UE5.2.1 project occupies about 350GB. (No, that's not my project) If you don't know how Rider works with Unreal Engine I recommend that you be much more careful when answering Rider's questions.
You guided me, therefore, it is your fault.

 
0

The solution is that Rider has no solution for the default clang.
I go by parts.
Even if the sort is deactivated
https://i.imgur.com/pSzK9id.png
As was well said, it is when formatting, therefore:
If the Clang-format -> Bundle is used
https://i.imgur.com/XFb2Wo9.png
Most likely you have the SortIncludes: True from the clang.
However, if you put a custom clang they don't work as well as I commented on errors a long time ago https://youtrack.jetbrains.com/issue/RIDER-95682
and of course it has not been solved. It doesn't surprise me at all.
Therefore, as I am using the LLVM 15.0.2 Bundle (which cannot be modified) and if I put it manually in .clang-format it will not work as I mentioned in that post, we can say that no, there is no solution since the Bundle will have it SortIncludes: True.
So currently no, there is no solution.

For Arina Efremova.
Next time, instead of searching Google for the solution and having your salary depend on Google, I recommend that you use your head a little.

For Rider developers.
Pitiful spectacle about the .clang-format.

I highly recommend you copy the solution as I might delete the post for the time you wasted me. Since you only do ctrl+c/v I strongly recommend you copy it.

Now I'll have to deal with the other bug because of your mistake. Next time remember me and remember that if you give me another bad answer I will punish you. Take care of that workplace.

I give the solution to the generated problem since I don't think Ariana has the remotest idea of how to solve this.
For those of you who come with the Unreal engine, don't pay attention to Ariana's nonsense, since to solve the Error you will have to download the entire project again and recompile it (That will involve re-running the .bats and the UE solution. Not counting the time that if your project has other old libraries), therefore 24 hours lost.

1

Hello,

I am a support engineer on the Rider Team.

I'm sincerely sorry about your experience with the product and support. Indeed, the original complaint was not addressed. The feedback we received from you is very valuable and appreciated. Thank you a lot for taking your time to share it.

How to disable C++ includes reordering
Regrettably, you encountered a known problem: Make clang-format not sorting includes in such way that "generated.h" is on top. We would appreciate it if you could upvote this issue to bring additional awareness to this issue.

When you use the Clang-format bundled formatter and have no .clang-format file defined, Rider formats your code using a predefined set of rules, including the SortIncludes: true rule.

I suggest the following workaround that worked out for me:

  • Ensure the File | Setting | Editor | Code Style | C++ | General | Clang-format | Bundled is enabled;
  • Click the Write current style to .clang-format button. Then click Export;

  • Find the file generated;
  • Add a row SortIncludes: false into generated .clang-format file; (save changes via Ctrl+S)
  • To verify if that works, open sample .h file and reorder a couple of includes by yourself. Then invoke Code | Reformat And Cleanup (using default Built-in: Full Cleanup profile and choosing a file as a scope;
  • Expected result: order of includes doesn't change.

For reference, please take a look at the screencast: JetBrains Upload Service link

If there is anything else I can assist you with, please let me know.

Issue with AITestSuite.Build.cs(1, 32): [CS1514] { expected
Regrettably, I was not able to reproduce such a problem. What the keymap do you use? I would appreciate it if you could elaborate on this issue and share steps to reproduce the issue (or a screencast that you can upload here. Please tell me the upload ID in that case)

I will be waiting for your response.

Have a nice day!

 

0

Please sign in to leave a comment.