eranif / codelite

A multi purpose IDE specialized in C/C++/Rust/Python/PHP and Node.js. Written in C++
https://codelite.org
GNU General Public License v2.0
2.13k stars 456 forks source link

[Feature Request]: Hide namespaces in outline view #3271

Closed buergi closed 10 months ago

buergi commented 12 months ago

Describe your idea in details

It would be very helpful, if there would be an option to hide all namespaces and potentially also class names in the outline view. As in most C++ files all definitions are in the same namespace, this only clutters the view and requires the side panel to be resized to a large width only to be able to see the actual names of the definitions.

So instead of

my::namespace::MyClass::methodnameA()
my::namespace::MyClass::methodnameB()
my::namespace::MyClass::methodnameC()

i'd love to have an option to only display

methodnameA()
methodnameB()
methodnameC()

just as it is displayed in the corresponding header file. Although this might of course cause duplicate lines, in most cases the names should be unique.

Another option would be to display namespace and class name as a kind of separator in the list, every time the prefix changes from one line to the other, something like

-- my::namespace::MyClass
methodnameA()
methodnameB()
methodnameC()
-- my::namespace::MyOtherClass
methodnameD()
methodnameE()
eranif commented 11 months ago

Which version and which Language Server is enabled for you? Using clangd, it does not display the namespace as part of symbol scope. See attached image: 1

buergi commented 11 months ago

An nice, that is more or less exactly how I expected it to look. I'm using clangd 16.0.5 from msys

C:\tools\msys64\clang64\bin\clangd.exe
  -limit-results=250
  -header-insertion-decorators=0
  --compile-commands-dir=$(WorkspacePath)

as the integrated clangd does not run for me. When I enable the checkbox under Plugins > Language Server > Settings > Internal clangd > Enabled and hit ok, then re-enter the dialog the checkbox is unchecked again. In the task manager I can see that no clangd is running. The command is the same as above, except for the different path and when I run the command directly in a console, it runs fine.

"C:\Program Files\CodeLite\clangd.exe"
  -limit-results=250
  -header-insertion-decorators=0
  --compile-commands-dir=$(WorkspacePath)
eranif commented 11 months ago

Which version are you using? recent versions of CodeLite no longer ships the clangd.exe, instead we auto detect clangd.exe from MSYS2

buergi commented 11 months ago

I use the latest release 17.0.0, I just uninstalled CodeLite, completely removed the program folder and reinstalled it. I cannot confirm that it does not ship clangd.exe as it was still installed.

eranif commented 11 months ago

"Recent" is 17.7 not 17.0

buergi commented 11 months ago

Ah, sorry, still used the stable release, however, I retried on 17.7 and it still comes with clangd.exe.

I also noticed I can confirm that in the situation as in your screenshot the namespace prefix is not displayed. I tried on 17.7 with clangd from msys but I guess it was already the case in 17.0. However this holds only in the case when the namespace prefix is not contained in the corresponding line of code as well. For example in the following situation the implementation of the constructor contains the full namespace, which is then also displayed in the outline view, the send method only specifies the class prefix and is therefore also displayed without namespace in the outline view. grafik

I'd still prefer the representation in the outline view as it is generated for typical header files, where all prefixes are displayed as separate lines grafik as it is the most compact view without containing redundant information between subsequent lines. Although it doesn't uniquely show

This would be very trivially to implemented by string comparison of subsequent lines. It is probably not very elegant relying on string operations here rather than using a proper API. I don't know if the clangd API allows querying the full object namespaces directly independently how they are written in code. But this would allow to iterate through these input lines

a::b::c::Foo::foo()
a::b::c::Foo::bar()
a::b::c::Foo::Cup::blub()
a::b::Bar::fob()
a::b::Bar::bof()
operator<<()

And show them either like this

-- a::b::c::Foo
foo()
bar()
-- a::b::c::Foo::Cup
blub()
-- a::b::Bar
fob()
bof()
-- ::
operator<<()

Or probably better like this

. a
  . b
    . c
      ⬡ Foo
      foo()
      bar()
        ⬡ Cup
        blub()
    ⬡ Bar
      fob()
      bof()
operator<<()
eranif commented 11 months ago

You are correct, I spoken too soon. We now deliver the clangd from the MSYS environment (in previous versions, we delivered clangd from the native Windows installer)