-
Notifications
You must be signed in to change notification settings - Fork 12
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
[#242] Make ClangdConfigurationFileManager configurable #286
[#242] Make ClangdConfigurationFileManager configurable #286
Conversation
We discussed this already: promoting [OSGi component] implementation to API won't do us any good. We already have public interface. |
I know. It was a wish from @travkin79 to subclass the |
I'd have to check the suggested interface to answer this, but I'm not in office for some time. Maybe you could check that using my requirements from the following, @ghentschke? I quickly looked at the interface and I don't see how I could achieve the following without needing to copy code from the original service implementation. My goal is just to switch off the creation of |
You could register your service manually in the start method of your Activator, something like this: public void start(BundleContext bundleContext) throws Exception {
// ...
ClangdCProjectDescriptionListener originalService = bundleContext.getService(bundleContext.getServiceReference(ClangdCProjectDescriptionListener.class));
ClangdCProjectDescriptionListener decoratedService = ...; // your own service implementation which can use originalService
Hashtable<String, Object> properties = new Hashtable<>();
properties.put("service.ranking", 10000);
context.registerService(ClangdCProjectDescriptionListener.class.getName(), decoratedService, properties);
} @ruspl-afed is this the right way to do this with OSGi? Another way might be to use the |
I checked the code. Sorry that it took so long.
Hello @ghentschke, @ddscharfe, and @ruspl-afed, technically, I think, I could implement the interface What I need, is basically exactly the behavior implemented in @Override
public boolean enableSetCompilationDatabasePath(IProject project) {
// do not create a .clangd file for certain set of projects
return !CustomProjectSelector.isSpecialProject(project)
&& super.enableSetCompilationDatabasePath(project);
} When implementing the interface I think, we need another solution here to make this customization less painful. Maybe we need an additional interface & (replaceable) OSGi service that can be used to decide whether to create a Maybe you have other, better ideas? Maybe some of these options mentioned by @ruspl-afed?
|
@travkin79 have you tried my suggested solution? This way you should be able to implement the interface, do the checks and delegate to the default implementation without copying any implementation. |
Hi @ddscharfe,
|
Hi @travkin79, My idea was: your service implements
I agree, it feels a little hacky. I don't know enough about OSGi services, maybe @ruspl-afed can help. The basic use case however seems legit to me: Register a service with a higher priority, but delegate to the "default" service. |
Hi @ddscharfe, Your assumption is that for my set of "special" projects I don't have to handle the events in I think that assumption is wrong. I think, I have to handle the event exactly like the |
AFAIU |
Hi @ddscharfe, |
Hi @ddscharfe,
I also did some experiments with naming the original service (similar to other dependency injection mechanisms) and trying to reference it from my custom service, but the injection did not happen. The reference stayed being |
That's unfortunate, but now as you mention it, it kinda makes sense that the default If we cannot solve it the way I thought, having another service that can be used to decide whether to create a .clangd file or not, as you proposed, makes sense to me. Or maybe the additional service could provide the detection of the compile_commands.json path (e.g. in your special project case "../compile_commands.json). This would allow more customization. |
Thanks @ddscharfe, Actually, we don't need a custom detection of the The last option, enabling / disabling detection of the So, I would prefer option 1, an additional service that checks for a given project if a |
I'll modify this PR in a way that it provides a service for a custom implementation for |
since its needed by some vendors to overwrite certain methods it should be made available. part of eclipse-cdt#276
6ea2982
to
0e3e89b
Compare
7297c86
to
aceeab9
Compare
@travkin79 I think the last commit should be what you need. @ruspl-afed could you please review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a certain set of projects, I want to avoid the creation of .clangd files.
change looks sufficient to cover the initial request
Thank you, @ghentschke. That works for me. |
since its needed by some vendors to overwrite certain methods it should be made available.
part of #276