ycm-core / ycmd

A code-completion & code-comprehension server
https://ycm-core.github.io/ycmd/
GNU General Public License v3.0
1.69k stars 764 forks source link

Java: Fix gradle project root detection #1749

Closed puremourning closed 2 weeks ago

puremourning commented 1 month ago

Typical "modern" layout from gradle init:

If you open app/src/java/.../Foo.java, we incorrectly pick app/ as the project root because we find first build.gradle then keep looking only for that file. Instead we should keep looking for any gradle file.

Now, when searching for the project root, we continue to search the varioius file names, but we tag each file name with the "kind" and keep searching for other files of the same kind rather than just the same name.

Meanwhile, we prefer finding the gradle/maven project. The reason for this is that jdt.ls spams .project files all over the codebase which makes any project you've previously opened look like an eclipse project. This is fine if the project root was previously correctly determined and/or the projects properly imported, but means that we never self-correct. So prefer finding the non-native project types so that we pick the correct root in most cases.


This change is Reviewable

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.94%. Comparing base (5de7052) to head (779a711). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1749 +/- ## ========================================== + Coverage 95.92% 95.94% +0.02% ========================================== Files 84 84 Lines 8462 8464 +2 Branches 163 163 ========================================== + Hits 8117 8121 +4 + Misses 295 293 -2 Partials 50 50 ```
mergify[bot] commented 2 weeks ago

Thanks for sending a PR!

mergify[bot] commented 2 weeks ago

Thanks for sending a PR!