Construct ClassIndex based on the CompilationInfo, to correctly reflect the available modules/classes. - #9543
Construct ClassIndex based on the CompilationInfo, to correctly reflect the available modules/classes.#9543lahodaj wants to merge 2 commits into
Conversation
…ct the available modules/classes.
|
I am trying the changes in this PR on my project and it does work sometimes, but mostly it is broken. When I am lucky, I see Code Completion for JUnit:
But when I dismiss the code completion, type something like
Also the JUnit code completion doesn't appear on first invocation. Only on subsequent request. FYI: There are possibly related compilation issues in
Is CC & co. in my project working for you properly? |
| * only valid after toPhase(ELEMENTS_RESOLVED) | ||
| * @return | ||
| */ | ||
| public ClassIndex getClassIndex() { |
There was a problem hiding this comment.
Maybe add an assert to avoid calling this when the status isn't in the right phase?
There was a problem hiding this comment.
There's an assert in CompilationInfoImpl.
This problem is present in Apache NetBeans 30 as well - e.g. it is not a regression caused by this PR:
It is again the package not visible because module does not read it. Clearly javac in NetBeans doesn't get it right. Isn't there a way to turn this error into a warning for my project? |
|
I made some progress in improving the state for the index search. For the support for the provided dependency, given the shenanigans with unpacking the dependencies into the compile-target directory, that's particularly tricky to support. |





Looking at Jaroslav's report:
https://lists.apache.org/thread/f5st2t0wspbdmjt6v5ojobzqpl7cjk9n
There's a general problem with
ClassIndex- it is based onClasspathInfoonly, and only on boot, compile and source path. This means theClassIndexdoes not see things on the module path, and module classpath(*).ComputeImportshas a hack to workaround this, but code completion does not.I think it is time to bite the bullet, at least partially, and try to fix this more conceptually.
The proposal herein is that we'll take
ClassIndexfromCompilationInfos, notClasspathInfos, wherever possible, and that thisClassIndexwill be configured based on the actual modules in the compilation.(*) I am not quite certain we need module classpath (basically, classpath, but when modules are enabled). I think it would make more sense to only have classpath, but lets not dive into that too deep in this PR.
^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
LLMs, Commit messages and PR description:
git log) that all commits have a valid name and email address for you in the Author field.Assisted-by: MODEL_NAME MODEL_VERSIONline appended to the commit message.Assisted-byline from above)If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)