-
Notifications
You must be signed in to change notification settings - Fork 768
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
Java: Fix gradle project root detection #1749
Java: Fix gradle project root detection #1749
Conversation
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.
Reviewable status: 0 of 2 LGTMs obtained
ycmd/completers/java/java_completer.py
line 45 at r1 (raw file):
PATH_TO_JAVA = None PROJECT_FILE_TAILS = {
making this a dictionary makes the sequence undefined. Either revert to list or use OrderedDict.
71e4d78
to
219baa5
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.
Reviewable status: 0 of 2 LGTMs obtained
ycmd/completers/java/java_completer.py
line 45 at r1 (raw file):
Previously, puremourning (Ben Jackson) wrote…
making this a dictionary makes the sequence undefined. Either revert to list or use OrderedDict.
done
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.
Added a test using bare grade init project
Reviewable status: 0 of 2 LGTMs obtained
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.
Reviewed 26 of 26 files at r2, all commit messages.
Reviewable status: 0 of 2 LGTMs obtained (waiting on @puremourning)
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.
Reviewed 26 of 26 files at r2, all commit messages.
Reviewable status: 0 of 2 LGTMs obtained (waiting on @puremourning)
ycmd/completers/java/java_completer.py
line 45 at r1 (raw file):
Previously, puremourning (Ben Jackson) wrote…
done
Iteration order of regular dictionaries is defined to be the same as insertion order, since... python 3.7. We only support python 3.8 and newer and even python 3.8 is nearing EOL.
https://mail.python.org/pipermail/python-dev/2017-December/151283.html
A list of tuples is an odd data type, when dict works. If you think we should be more explicit about ordering, then there's still OrderedDict
.
219baa5
to
779a711
Compare
Typical "modern" layout from `gradle init`: - settings.gradle - app/build.gradle - ... If you open app/src/java/.../Foo.java, we incorrectly pick app/ as the project root. 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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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 |
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.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @puremourning)
Thanks for sending a PR! |
1 similar comment
Thanks for sending a PR! |
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