-
Notifications
You must be signed in to change notification settings - Fork 11
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
[#227] Refactor ClangdConfigurationManager #229
Conversation
- Allows vendors to overwrite default behavior fixes eclipse-cdt#227
Still some unit test issues. |
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.
From #227 (comment) :
So, this should also be a default setup (or at least to be achievable without writing your own plugin) with CDT LSP.
I would say "default setup" request is questionable, but "achievable without writing your own plugin" sounds reasonable. Does this PR satisfy the mentioned need?
@@ -48,14 +51,15 @@ public void start(BundleContext context) throws Exception { | |||
workspaceTracker.open(); | |||
workspace = workspaceTracker.getService(); | |||
compileCommandsMonitor = new CompileCommandsMonitor(workspace).start(); | |||
cProjectChangeMonitor = new CProjectChangeMonitor().start(); | |||
cProjectChangeMonitor = Optional.ofNullable(PlatformUI.getWorkbench().getService(CProjectChangeMonitor.class)) |
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.
component may have methods annotated with
@Activate
and @Deactivate
, so we can avoid this code
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.
Thanks for the hint. I'll check that.
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.
Please take a look at my last commit
@@ -61,6 +61,24 @@ public static IProject createCProject(String projectName) throws CoreException { | |||
return project; | |||
} | |||
|
|||
// static IProject createEmptyCMakeProject(String projectName) { |
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.
Do we need this code or not? If not, let's remove it
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.
No, can be removed
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.
Done
* Gesa Hentschke (Bachmann electronic GmbH) - initial implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.cdt.lsp.clangd; |
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.
Usually the component is a part of implementation, and not a part of [potential] API, it should be placed to internal
package
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.
I've to rework this part as I stumped about this https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#:~:text=A%20bundle%20containing,components%20being%20activated.
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.
Please take a look at my last commit
* with a service.ranking property > 0 to implement custom behavior | ||
* and to replace the {@link ClangdConfigurationManager} | ||
*/ | ||
public interface ClangdCProjectDescriptionListener { |
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.
this interface needs more work, it has 3 methods with tightly-coupled implementation and all of them are open for public invocation. Ideally there should be only one.
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.
Should be fixed with my last commit
- Fix unit tests fixes eclipse-cdt#227
- Support cmake projects as well fixes eclipse-cdt#227
- Add org.eclipse.cdt.cmake.core to target definition fixes eclipse-cdt#227
Yes. They have to implement either I put the default implementations in the |
Yes, I understand the idea of the fix. My point is that class with Also, I had an impression that the original request was to have something like preference-controlled strategy rather than API to override. But let's wait for a feedback. |
- Fix bundle activator/Service Component Runtime (SCR) problem: The Bundle Activator's start method must not rely upon SCR having activated any of the bundle's components. However, the components can rely upon the Bundle Activator's start method having been called. That is, there is a happens-before relationship between the Bundle Activator's start method being run and the components being activated. fixes eclipse-cdt#227
* @param project managed C/C++ project | ||
* @param newCProjectDescription new CProject description | ||
* @param macroResolver helper to resolve macros in the CWD path of the builder | ||
*/ | ||
public void setCompilationDatabasePath(IProject project, ICProjectDescription newCProjectDescription, |
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.
I think, since this is no longer part of ClangdCProjectDescriptionListener
interface, it's enough to make this method protected.
* Enabler for {@link setCompilationDatabasePath}. Can be overriden for customization. | ||
* @param project | ||
* @return true if the database path should be written to .clangd file in the project root. | ||
*/ | ||
public boolean enableSetCompilationDatabasePath(IProject project) { |
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.
I think, since this is no longer part of ClangdCProjectDescriptionListener
interface, it's enough to make this method protected.
I'm not sure how such a preference for our case could look like. Disabling the creation of I've implemented a working prototype and it works as expected. Thank you @ghentschke. |
- make methods protected since they aren't part of the interface anymore. fixes eclipse-cdt#227
fixes #227