Repository navigation
CodeMinings: Add support for rendering placeholder while resolving #3723 - #4508
flori-schwa wants to merge 1 commit into
Conversation
0113326 to
05782b5
Compare
Test Results 867 files ± 0 867 suites ±0 44m 27s ⏱️ - 6m 32s Results for commit 1353228. ± Comparison against base commit b5dd338. This pull request removes 2 and adds 9 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
🟡 Changes recommended
Incorrect click-target mapping, a null-label painting race, and a nondeterministic test remain unresolved.
3 open issues
What changed in this PR
Adds opt-in code-mining placeholders to reduce editor content shifting while labels resolve asynchronously, addressing #3723.
Changes:
- Introduces
IPlaceholderCodeMiningto distinguish placeholder labels from resolved labels. - Updates header, inline, and footer rendering to support placeholders without caching them as resolved results.
- Adds placeholder rendering, height, and redraw tests.
| File | Description |
|---|---|
| tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/PlaceholderLineHeaderCodeMining.java | Adds a reusable placeholder-enabled test mining. |
| tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java | Tests placeholder-to-resolved label rendering. |
| tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningLineHeaderAnnotationTest.java | Tests placeholder height and resolution-triggered redraws. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/IPlaceholderCodeMining.java | Defines the public placeholder contract. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java | Adds a helper to identify unresolved placeholders. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java | Supports placeholder drawing and separates resolved-cache handling. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineContentAnnotation.java | Supports inline placeholders and resolution-triggered redraws. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningDocumentFooterAnnotation.java | Updates footer height checks and resolved-cache handling. |
Review effort: Balanced
26f3acd to
e80a3e9
Compare
|
Thanks for the update, the separate 1. Test helper cleanup (the open thread on
2. Javadoc caveats for implementors of I applied the patch on top of Patch (apply with
|
e80a3e9 to
05bffd8
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Placeholder rendering can reserve a height inconsistent with the displayed mining and fail to redraw after resolution errors or cancellation, causing overlap or lingering blank space.
2 open issues
3 resolved since last review
Review effort: Balanced
fedejeanne
left a comment
There was a problem hiding this comment.
Thank you for addressing my comments, Florian, everything good on my side ✔️
I let Copilot review again and it found 2 things:
- I proposed a patch for you to (review and) apply for the 1st finding
- I marked the 2nd finding as settled since we already discussed it.
After the 1st finding is resolved, I will approve this PR and it can be merged in the upcoming release (we need to wait until master is open for development again). This should happen beginning of December (see the release plan).
05bffd8 to
1353228
Compare
fedejeanne
left a comment
There was a problem hiding this comment.
All fixes applied ✔️
The failing test is unrelated:
I will merge once development for M1 is open (beginning of December).
|
Thanks for working on this! A placeholder that reserves the space while a mining is still resolving is a nice improvement against the editor content jumping around. Compatibility with existing code mining implementations I tested the change with the code prediction feature in the ABAP Development Tools (ADT), which is built on the code mining API. That implementation doesn't implement the new
An implementation that does real work in I'd suggest two changes:
|
|
Thank you for the feedback, Tobias! I agree on changing the JavaDoc, It's valuable advice and it never hurts to help the consumers with that. w.r.t. caching the results: one could also leave that to the consumer and give a hint on the JavaDoc so that the consumer makes sure that the placeholder is cached, just like * @apiNote This method is called in the UI thread, possibly several times.
* Implementations must not block the calling thread and may
* cache the result to avoid repeated computation. |
|
Thanks, Federico. I’m fine with leaving caching to the implementation as you suggest, so please go ahead with the Javadoc update. This isn’t a blocker from my side. My personal preference would still be to minimize calls in the framework, ideally reading the placeholder once per repaint. Over the years, I’ve seen extensions do unexpected things, so I tend to favor making the framework as resilient as possible to expensive implementations. Calling it once wouldn’t prevent a slow getter from blocking the UI, but it would avoid multiplying that cost. That’s my preference, though, and I’m happy to proceed with your approach. |
|
@tobiasmelcher one way to go (probably not exactly what you had in mind, but hopefully close enough) would be to not only document the details in the JavaDoc (btw I removed I tried that in I did not add a cache in Also, classes that implement Do you think this would be a good compromise? |
1353228 to
5e379b7
Compare
|
Thanks for the feedback @fedejeanne and @tobiasmelcher I added the javadoc note but I am also currently trying out a way of computing the placeholder label only once. The API contract would require implementors to implement an "effectively final" I have some other ideas of how ensure the mining state is only read once per call using a sealed type hierarchy, but that would require more object allocations, which we should probably avoid. Maybe I can revisit that idea, once value objects are out of preview. |
…lipse-platform#3723 Codemining implementations can now opt-in to rendering placeholder text to prevent editor jumping. The IPlaceholderCodeMining interface must be implemented and getPlaceholderLabel() should return a non-empty string. If no label is set and there is no last resolved mining, the placeholder text will be shown while the resolve() Future is still running. Fixes eclipse-platform#3723
5e379b7 to
7a24e7a
Compare
Thanks a lot @fedejeanne, that's more than I asked for. Yes, I think this is a good compromise. With the stored value in AbstractCodeMining, a repaint only reads a field for almost all real-world minings, so a once-per-paint cache isn't needed anymore. Your reasons for not caching in update() make sense to me. |
Then we'd also need to either document get/setPlaceholderLabel in AbstractCodeMining and require users to implement the IPlaceholdeCodeMining interface or let AbstractCodeMining implement it directly. |

Codemining implementations can now opt-in to rendering placeholder text
to prevent editor jumping. The IPlaceholderCodeMining interface must be
implemented and getPlaceholderLabel() should return a non-empty string.
If no label is set and there is no last resolved mining, the placeholder
text will be shown while the resolve() Future is still running.
Fixes #3723
Example Usage:
In
JavaImplementationCodeMining(JDT):IPlaceholderCodeMininginterface:getPlaceholderLabel()Method:Here is a screen recording where I added a placeholder to the "Java References" and "Java Implementations" Code minings. I also added a random delay in the resolve method to simulate work.
Placeholders.mp4