You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When header and source files are in separate folders, swapping between header and source files fail in trivial situations:
.h and .cpp files with the same name but different folders will fail to swap if the contents are empty.
Similar to the above point, if there are build errors it may fail to execute the swap.
If a header only contains forward declarations and functions (no class definition), it will go to the file that contains the first class declaration.
For an example of point 3, see test-switch.tar.gz. This was tested with Qt Creator 10.0.0, which currently uses the clangd code model to handle header/source switches.
Open Foo.cpp.
Execute Switch Header/Source, it will correctly switch to Foo.h.
Execute Switch Header/Source again from Foo.h, notice how instead of switching to Foo.h it switches to Bar.h as the "source" file.
If you delete the class Bar; forward declare and change the function declaration to void foo(class Bar& bar);, executing Switch Header/Source correctly switches to Foo.cpp.
Output of clangd --version:
clangd version 16.0.2 (https://github.com/llvm/llvm-project 18ddebe1a1a9bde349441631365f0472e9693520)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu
Editor/LSP plugin: Qt Creator 10.0.0
Operating system: Arch Linux
The text was updated successfully, but these errors were encountered:
akb825
changed the title
Switch between header/source finds incorrect files in trivial cases.
Switch between header/source doesn't find correct file in trivial cases.
May 3, 2023
See #1043 for some discussion of how this feature currently works.
I think the "file index" approach discussed in this comment is a promising one and should address the case of files with the same name in different directories, regardless of their contents.
There are probably opportunities to improve the content-based heuristics as well, but the above sounds like the bigger bang for buck overall.
I agree, I think a file index and using heuristics based on that would handle situations like this much better overall. Care would need to be taken if there's multiple files with the same name, though, ideally ties would be broken based on more similar paths. (e.g. if multiple internal projects with a Foo.h and Foo.cpp pair, one heuristic could be to match the companion that has the fewest directories to a common root)
I saw that issue earlier, but it looks like their fix only resolved issues for differing case for case-insensitive filesystems.
When header and source files are in separate folders, swapping between header and source files fail in trivial situations:
For an example of point 3, see test-switch.tar.gz. This was tested with Qt Creator 10.0.0, which currently uses the clangd code model to handle header/source switches.
class Bar;
forward declare and change the function declaration tovoid foo(class Bar& bar);
, executing Switch Header/Source correctly switches to Foo.cpp.Logs
log.txt
System information
Output of
clangd --version
:clangd version 16.0.2 (https://github.com/llvm/llvm-project 18ddebe1a1a9bde349441631365f0472e9693520)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu
Editor/LSP plugin: Qt Creator 10.0.0
Operating system: Arch Linux
The text was updated successfully, but these errors were encountered: