-
Notifications
You must be signed in to change notification settings - Fork 769
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
[READY] Automatically load a compilation database if found #680
Conversation
@r4nt I remember you wanting to see this implemented in ycmd. Curious what your thoughts are; check out both this PR and the other implementation (linked in PR description). |
Gave a light review pass. I'm leaning towards this approach as well now that I've seen both. The other approach is a default extra conf file, but the we load it by default and the user would be unwise to change that file directly... at that point we might as well just have this default logic hard-coded into ycmd, because it effectively is. As usual, thanks for the PR! :) Review status: 0 of 6 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed. cpp/ycm/ClangCompleter/CompilationDatabase.h, line 57 at r1 (raw file):
I'm pretty sure you can just make this return an Let's avoid returning raw pointers if possible. ycmd/completers/cpp/flags.py, line 96 at r1 (raw file):
Empty line before comment block? ycmd/completers/cpp/flags.py, line 232 at r1 (raw file):
Let's expand ycmd/completers/cpp/flags.py, line 235 at r1 (raw file):
Maybe cut down on some of these obvious comments now that this isn't in a user-facing file. :) Comments from Reviewable |
Current coverage is 92.69% (diff: 97.47%)@@ master #680 diff @@
==========================================
Files 79 79
Lines 5166 5258 +92
Methods 295 297 +2
Messages 0 0
Branches 139 139
==========================================
+ Hits 4742 4874 +132
+ Misses 368 329 -39
+ Partials 56 55 -1
|
Review status: 0 of 6 files reviewed at latest revision, 4 unresolved discussions. cpp/ycm/ClangCompleter/CompilationDatabase.h, line 57 at r1 (raw file): Previously, Valloric (Val Markovic) wrote…
Old habit. Trying to avoid a string copy ( ycmd/completers/cpp/flags.py, line 96 at r1 (raw file): Previously, Valloric (Val Markovic) wrote…
Done. ycmd/completers/cpp/flags.py, line 232 at r1 (raw file): Previously, Valloric (Val Markovic) wrote…
Done. ycmd/completers/cpp/flags.py, line 235 at r1 (raw file): Previously, Valloric (Val Markovic) wrote…
Yep, for this revision i literally copy/pasted the whole code block :) Comments from Reviewable |
Review status: 0 of 6 files reviewed at latest revision, 5 unresolved discussions, some commit checks failed. ycmd/completers/cpp/clang_completer.py, line 37 at r3 (raw file):
why the parenthesis here? Comments from Reviewable |
645cd44
to
8854ab4
Compare
Review status: 0 of 6 files reviewed at latest revision, 5 unresolved discussions. ycmd/completers/cpp/clang_completer.py, line 37 at r3 (raw file): Previously, vheon (Andrea Cedraro) wrote…
I think because i changed this then changed it back. Fixed. Comments from Reviewable |
b0fe88a
to
bf093d3
Compare
Tests are passing, we're happy with this approach, there's some draft documentation. I think this is READY for a proper review cycle. |
Yep, agree that built-in is probably better. Very happy to see projects that use the compilation db work just out of the box. Thanks so much for this. |
Interesting. Thanks! We were chatting about this last night. Our plan is go out something simple live then improve the heuristics based on feedback and/or inspiration. We considered more caches and some path manipulations for header files (the latter being the key goal). Do you have experience with longest common suffix? Do you know that it works well? E.g. does it work for clang code base? If so, that could be our first feedback/inspiration point. :) |
Nice stuff! Some minor inline comments, otherwise great. Review status: 0 of 8 files reviewed at latest revision, 4 unresolved discussions. ycmd/completers/cpp/flags.py, line 97 at r4 (raw file):
Since this is python, I'd like to see docs stating what the type of key and value are. ycmd/completers/cpp/flags.py, line 104 at r4 (raw file):
Same as above; I'd like to see docs stating what the type of key and value are. God, I hate dynamic languages... ycmd/tests/clang/init.py, line 104 at r4 (raw file):
"Project" seems to be used here to imply a Comments from Reviewable |
2023330
to
b868dd2
Compare
Thanks for the review! Review status: 0 of 8 files reviewed at latest revision, 5 unresolved discussions. ycmd/completers/cpp/flags.py, line 97 at r4 (raw file): Previously, Valloric (Val Markovic) wrote…
Done. ycmd/completers/cpp/flags.py, line 104 at r4 (raw file): Previously, Valloric (Val Markovic) wrote…
Done. ycmd/tests/clang/init.py, line 104 at r4 (raw file): Previously, Valloric (Val Markovic) wrote…
Done. ClangProject seems ok. Comments from Reviewable |
Reviewed 2 of 6 files at r1, 1 of 3 files at r2, 1 of 5 files at r4, 1 of 5 files at r5. ycmd/completers/cpp/clang_completer.py, line 388 at r4 (raw file):
can't we write this as ycmd/completers/cpp/flags.py, line 104 at r5 (raw file):
Just a nitpick but is "The" right here? ycmd/completers/cpp/flags.py, line 198 at r5 (raw file):
We call this function in two places and in both places we do this check. Couldn't we ycmd/completers/cpp/flags.py, line 205 at r5 (raw file):
I think is more Pythonic to write it as Comments from Reviewable |
Reviewed 3 of 6 files at r1, 3 of 3 files at r2, 2 of 2 files at r3, 5 of 5 files at r4, 4 of 5 files at r5. cpp/ycm/ClangCompleter/CompilationDatabase.h, line 58 at r2 (raw file):
Isn't the open bracket supposed to be on the first line according to our coding style? ycmd/completers/cpp/clang_completer.py, line 402 at r2 (raw file):
This ycmd/completers/cpp/clang_completer.py, line 391 at r4 (raw file):
Last ycmd/completers/cpp/clang_completer.py, line 397 at r5 (raw file):
It's not obvious why try:
extra_conf = extra_conf_store.ModuleFileForSourceFile( filename )
except UnknownExtraConf as error:
return ...
try:
flags = self._FlagsForRequest( request_data ) or []
except NoExtraConfDetected:
return ...
database = self._flags.compilation_database_dir_map.get(
os.path.dirname( filename ) )
if database:
return ... flags ...
return ... flags ... This way, it is clear that ycmd/completers/cpp/flags.py, line 186 at r2 (raw file):
I think this function should also clear the ycmd/completers/cpp/flags.py, line 191 at r2 (raw file):
Parentheses are not required. ycmd/completers/cpp/flags.py, line 248 at r5 (raw file):
One dot can be removed. ycmd/tests/clang/init.py, line 133 at r4 (raw file):
We use ycmd/tests/clang/flags_test.py, line 513 at r2 (raw file):
Typo: ycmd/tests/clang/flags_test.py, line 513 at r4 (raw file):
This test is not directly related to compilation databases so I would not prefix its name with Comments from Reviewable |
91fcd73
to
b036b21
Compare
Review status: 3 of 8 files reviewed at latest revision, 17 unresolved discussions. cpp/ycm/ClangCompleter/CompilationDatabase.h, line 58 at r2 (raw file): Previously, micbou wrote…
it is indeed. ycmd/completers/cpp/clang_completer.py, line 402 at r2 (raw file): Previously, micbou wrote…
Done. Removed by refactor of exceptions. ycmd/completers/cpp/clang_completer.py, line 388 at r4 (raw file): Previously, vheon (Andrea Cedraro) wrote…
yeah, i just hate dynamic languages. None behaves strangely. ycmd/completers/cpp/clang_completer.py, line 391 at r4 (raw file): Previously, micbou wrote…
Done. ycmd/completers/cpp/clang_completer.py, line 397 at r5 (raw file): Previously, micbou wrote…
I've changed the control flow here to make it more obvious and added a few comments. ycmd/completers/cpp/flags.py, line 186 at r2 (raw file): Previously, micbou wrote…
Done. ycmd/completers/cpp/flags.py, line 191 at r2 (raw file): Previously, micbou wrote…
Done. ycmd/completers/cpp/flags.py, line 104 at r5 (raw file): Previously, vheon (Andrea Cedraro) wrote…
Done. ycmd/completers/cpp/flags.py, line 198 at r5 (raw file): Previously, vheon (Andrea Cedraro) wrote…
Yeah, I have it this way in another change. It is better to have ycmd/completers/cpp/flags.py, line 205 at r5 (raw file): Previously, vheon (Andrea Cedraro) wrote…
grr. done :) ycmd/completers/cpp/flags.py, line 248 at r5 (raw file): Previously, micbou wrote…
Done. Comments from Reviewable |
Review status: 3 of 8 files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. ycmd/completers/cpp/flags.py, line 97 at r4 (raw file): Previously, puremourning (Ben Jackson) wrote…
Maybe use "key" instead of "LHS" and "value" instead of "RHS"? Seems more obvious. ycmd/completers/cpp/flags.py, line 104 at r4 (raw file): Previously, puremourning (Ben Jackson) wrote…
Same as above. RHS is a needless abbreviation, just use "value". Comments from Reviewable |
Reviewed 2 of 6 files at r1, 1 of 5 files at r5, 5 of 5 files at r6. Comments from Reviewable |
b036b21
to
f0f7a0e
Compare
Review status: 7 of 8 files reviewed at latest revision, 9 unresolved discussions. ycmd/tests/clang/init.py, line 133 at r4 (raw file): Previously, micbou wrote…
Done. ycmd/tests/clang/flags_test.py, line 513 at r2 (raw file): Previously, micbou wrote…
Done. ycmd/tests/clang/flags_test.py, line 513 at r4 (raw file): Previously, micbou wrote…
Done. Comments from Reviewable |
f0f7a0e
to
e1a3743
Compare
Review status: 6 of 8 files reviewed at latest revision, 6 unresolved discussions. ycmd/completers/cpp/flags.py, line 97 at r4 (raw file): Previously, Valloric (Val Markovic) wrote…
Done Comments from Reviewable |
Review status: 6 of 8 files reviewed at latest revision, 6 unresolved discussions. ycmd/completers/cpp/flags.py, line 104 at r4 (raw file): Previously, Valloric (Val Markovic) wrote…
Done. Comments from Reviewable |
Reviewed 2 of 2 files at r7. ycmd/tests/clang/debug_info_test.py, line 98 at r5 (raw file):
Oh nice! Comments from Reviewable |
I tested it on our code base and, to my surprise, it worked great. I only needed to copy the Reviewed 5 of 5 files at r6, 2 of 2 files at r7. Comments from Reviewable |
e1a3743
to
128b508
Compare
I've rebased and just tweaked a few comments which were wrong or contained typos. Is this ready to merge now? I was thinking we could merge this, merge my documentation updates to YCM and update ycmd submodule. This would release python 3.6 support, a few bug fixes and this change. Major release! :) Review status: 7 of 8 files reviewed at latest revision, 4 unresolved discussions. Comments from Reviewable |
Merge it! :) |
@homu r=micbou |
📌 Commit 128b508 has been approved by |
[READY] Automatically load a compilation database if found Alternative implementation to : #679 See #679 for explanation and rationale. Fixes: #489 Fixes: ycm-core/YouCompleteMe#2310 (sort of) Fixes: #26 Fixes: ycm-core/YouCompleteMe#1981 Fixes: ycm-core/YouCompleteMe#1623 (sort of) Fixes: ycm-core/YouCompleteMe#1622 Partly implements: ycm-core/YouCompleteMe#927 Fixes: ycm-core/YouCompleteMe#664 Fixes: ycm-core/YouCompleteMe#487 Fixes (discussion on): ycm-core/YouCompleteMe#174 This implementation is almost identical to the default-extra-conf version, except: - the code lives in `flags.py` - it re-uses `INCLUDE_FLAGS` from `flags.py` - it provides the directory of the compilation database in the `clang_completer` debug info instead of the name of the default extra conf module. On reflection, I think I might prefer this implementation. For now, the tests are identical to the other PR (you can now see why I added that set of tests!) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/680) <!-- Reviewable:end -->
☀️ Test successful - status |
[READY] Update readme for compilation database support # PR Prelude Thank you for working on YCM! :) **Please complete these steps and check these boxes (by putting an `x` inside the brackets) _before_ filing your PR:** - [X] I have read and understood YCM's [CONTRIBUTING][cont] document. - [X] I have read and understood YCM's [CODE_OF_CONDUCT][code] document. - [X] I have included tests for the changes in my PR. If not, I have included a rationale for why I haven't. > only changes docs - [X] **I understand my PR may be closed if it becomes obvious I didn't actually perform all of these steps.** # Why this change is necessary and useful This change: - updates the c-family completer documentation to describe the built in support for compilation databases added in ycm-core/ycmd#680 - explains more about why ycmd needs compiler flags, and how to go about providing them - recommends using a compilation database (as that seems to be the fashion) - standardises formatting for `NOTE` (it was inconsistent before) - states that the preferred installation method is `install.py` (rather than the full installation instructions) - update the vim doc - update the ycmd submodule ### ycmd update release note - ycm-core/ycmd#678 - Bump Boost version to 1.63.0 - ycm-core/ycmd#686 - Update JediHTTP for Python 3.6 support - ycm-core/ycmd#684 - Fix JavaScript identifier regex - ycm-core/ycmd#680 - Automatically load a compilation database if found [cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md [code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2495) <!-- Reviewable:end -->
[READY] Add an option to make relative paths in flags from extra conf absolute Since PR #680, all the infrastructure is here to convert any relative paths in the list of flags from the `.ycm_extra_conf.py` file to absolute ones. We just need to use the `_MakeRelativePathsInFlagsAbsolute` function. This PR adds a new optional key `working_directory` to the dictionary returned by the `FlagsForFile` function in the `.ycm_extra_conf.py` file. This option allows specifying the working directory i.e. the directory for which the paths in the list of flags are relative to. Update YCM's own `.ycm_extra_conf.py` file to reflect this change. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/795) <!-- Reviewable:end -->
Alternative implementation to : #679
See #679 for explanation and rationale.
Fixes: #489
Fixes: ycm-core/YouCompleteMe#2310 (sort of)
Fixes: #26
Fixes: ycm-core/YouCompleteMe#1981
Fixes: ycm-core/YouCompleteMe#1623 (sort of)
Fixes: ycm-core/YouCompleteMe#1622
Partly implements: ycm-core/YouCompleteMe#927
Fixes: ycm-core/YouCompleteMe#664
Fixes: ycm-core/YouCompleteMe#487
Fixes (discussion on): ycm-core/YouCompleteMe#174
This implementation is almost identical to the default-extra-conf version, except:
flags.py
INCLUDE_FLAGS
fromflags.py
clang_completer
debug info instead of the name of the default extra conf module.On reflection, I think I might prefer this implementation.
For now, the tests are identical to the other PR (you can now see why I added that set of tests!)
This change is