-
Notifications
You must be signed in to change notification settings - Fork 13
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
[#23] Refresh open editors when compile_commands.json changes #24
[#23] Refresh open editors when compile_commands.json changes #24
Conversation
They mentioned in the commit message of llvm/llvm-project@9899319 :
I'am not sure, but it seems that the compile_commands.json file has to be in the subdirectory /build relative to the source code file e.g. src/build/compile_commands.json |
I think this comment just means that the auto refresh only checks the compile_commands.json in the build directory, meaning the toplevel directory. AFAIK you can put compile_commands.json files anywhere in the sub hierarchy but they are not covered by this mechanism. |
|
I just did. It doesn't seem to make a difference at all if the json file is at the toplevel or under toplevel/build. Btw I just tested using org.eclipse.lsp4e 0.15.0 instead of org.eclipse.lsp4e 0.16.0 and with the 0.15.0 version it seems to work without the delay of 5 seconds. However with 0.15.0 I get an exception
|
interesting, I'am working with the LSP4E sources in in my workspace. I'll try it |
Do you set schedule the UIJob immediately: UIJob.create("Refresh Editors", monitor -> {
int rangeOffset = textViewer.getTopIndexStartOffset();
int rangeLength = textViewer.getBottomIndexEndOffset() - rangeOffset;
editor.getSite().getPage().reuseEditor((IReusableEditor) editor, editor.getEditorInput());
textViewer.revealRange(rangeOffset, rangeLength);
}).schedule(); |
@ddscharfe Please rebase your PR to let the CI build run |
8f82abb
to
6f48f62
Compare
I did the folowing with the LSP4E build form sources:
With a 5 sec schedule delay it works. After re-build of the project an a newly created compile_commands.json the editor gets refreshed after 5 sec |
Yes. |
...lipse.cdt.lsp.editor.ui/src/org/eclipse/cdt/lsp/editor/ui/clangd/CompileCommandsMonitor.java
Outdated
Show resolved
Hide resolved
...lipse.cdt.lsp.editor.ui/src/org/eclipse/cdt/lsp/editor/ui/clangd/CompileCommandsMonitor.java
Show resolved
Hide resolved
6f48f62
to
32d1d75
Compare
...lipse.cdt.lsp.editor.ui/src/org/eclipse/cdt/lsp/editor/ui/clangd/CompileCommandsMonitor.java
Show resolved
Hide resolved
32d1d75
to
b3b9bea
Compare
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.
LGTM. Could you provide test for this feature?
I could add a few integration tests, this would probably make sense. I'd also like to have unit tests, for which using dependency injection and mocking would be helpful. Would you mind using google guice in this project and mockito for the tests? |
Mockito is fine. I'am not sure about google guice, since it should be a CDT feature in the future. We should ask @jonahgraham regarding this. |
I asked this question to @jonahgraham a few years ago: https://www.eclipse.org/lists/cdt-dev/msg31411.html |
Yepp, we do this in our projects as well. |
Update open editors when compile_commands.json file of the project of the edited file is added/removed/changed.
This makes use of clangd hot-reload, see https://reviews.llvm.org/D92663.
I thought it should be possible to notify clangd via didChangeWatchedFiles, however clangd receives the command but doesn't seem to update the compilation data base.