8000 The C/C++ Editor OR C/C++ Editor (LSP) won't be used for opening a *.hpp file · Issue #26 · eclipse-cdt/cdt-lsp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

The C/C++ Editor OR C/C++ Editor (LSP) won't be used for opening a *.hpp file #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghentschke opened this issue Mar 6, 2023 · 2 comments
Assignees
Milestone

Comments

@ghentschke
Copy link
Contributor
ghentschke commented Mar 6, 2023

When opening a *.hpp file, the C/C++ Editor (LSP) won't be used, because content types are missing in the org.eclipse.ui.editors extension point. The org.eclipse.tm4e.language_pack plug-in defines content types for C/C++ files as well ("lng.cpp" and "lng.c")

The content types "lng.cpp" and "lng.c" are associated to the ExtensionBasedTextEditor only.

Unfortunately is the extension type returned for a *.hpp file by org.eclipse.core.internal.resources.ContentDescriptionManager.getDescriptionFor(File, ResourceInfo, boolean) "lng.cpp" and NOT "org.eclipse.cdt.core.cxxHeader".

Because the "lng.cpp" extension type is only associated to the ExtensionBasedTextEditor, the editor registry only returns this editor for the "lng.cpp" content type.

This results in the need to associate the "lng.cpp" and "lng.c" to the C/C++ Editor and C/C++ Editor (LSP). By doing this, we are able to override the default editor in CEditorAssociationOverride for a *.hpp file with either the C/C++ Editor or C/C++ Editor (LSP)

ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Mar 6, 2023
The org.eclipse.tm4e.language_pack plug-in adds content types for C/C++
files. These content types needs to be considered during filtering
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Mar 6, 2023
The org.eclipse.tm4e.language_pack plug-in adds content types for C/C++
files. These content types needs to be considered during filtering
@ghentschke ghentschke changed the title The C/C++ Editor (LSP) won't be used for opening a *.hpp file The C/C++ Editor OR C/C++ Editor (LSP) won't be used for opening a *.hpp file Mar 6, 2023
@jonahgraham
Copy link
Member

Unfortunately is the extension type returned for a *.hpp file by org.eclipse.core.internal.resources.ContentDescriptionManager.getDescriptionFor(File, ResourceInfo, boolean) "lng.cpp" and NOT "org.eclipse.cdt.core.cxxHeader".

The reason for this was not obvious to me until I got right into the code. I has understood that priority of the content type decided which content type to use when multiple ones existed. But actually priority is only used if the "depth" of the definition is the same. For .hpp files, the depth is deeper in CDT than in TM4E:

CDT:

  • org.eclipse.cdt.core.cxxHeader
  • org.eclipse.cdt.core.cxxSource
  • org.eclipse.cdt.core.cSource
  • org.eclipse.core.runtime.text

TM4E:

  • org.eclipse.tm4e.language_pack.lng.cpp
  • org.eclipse.tm4e.language_pack.basetype
  • org.eclipse.core.runtime.text

For C headers, C source and C++ source the depth is the same as TM4E, so the priority wins out to resolve the conflict.

The content types "lng.cpp" and "lng.c" are associated to the ExtensionBasedTextEditor only.

So this is kind of true, for the places that use the first result of content type they get it wrong. For those that consider all content types the file could be things go a bit better.

I wonder if the best solution is to make CDT's .hpp less deep. Not sure of the effect of that, and it would be affected negatively if TM4E removed the basetype from their depth.

Therefore I propose one of these two solutions to get a better result overall in the case of hpp files:

ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Mar 7, 2023
The org.eclipse.tm4e.language_pack plug-in adds content types for C/C++
files. These content types needs to be considered during filtering
This is a fix for eclipse-tm4e/tm4e#499
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Mar 7, 2023
The org.eclipse.tm4e.language_pack plug-in adds content types for C/C++
files. These content types needs to be considered during filtering
This is a fix for eclipse-tm4e/tm4e#499
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Mar 7, 2023
The org.eclipse.tm4e.language_pack plug-in adds content types for C/C++
files. These content types needs to be considered during filtering
This is a fix for eclipse-tm4e/tm4e#499
8000
ghentschke added a commit that referenced this issue Mar 8, 2023
The org.eclipse.tm4e.language_pack plug-in adds content types for C/C++
files. These content types needs to be considered during filtering
This is a fix for eclipse-tm4e/tm4e#499
@ghentschke
Copy link
Contributor Author

I'll close this issue when either eclipse-cdt/cdt#310 or eclipse-tm4e/tm4e#500 has been merged.

@ghentschke ghentschke reopened this Mar 8, 2023
@ghentschke ghentschke self-assigned this May 15, 2023
@jonahgraham jonahgraham added this to the 1.0.0 milestone Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0