Skip to content

CodeMinings: Add support for rendering placeholder while resolving #3723 - #4508

Open
flori-schwa wants to merge 1 commit into
eclipse-platform:masterfrom
vi-eclipse:fschwabe/codemining-placeholders
Open

flori-schwa wants to merge 1 commit into
eclipse-platform:masterfrom
vi-eclipse:fschwabe/codemining-placeholders

Conversation

@flori-schwa

@flori-schwa flori-schwa commented Oct 16, 2026 •

Copy link
Copy Markdown

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):

  • implement the new IPlaceholderCodeMining interface:
-public class JavaImplementationCodeMining extends AbstractJavaElementLineHeaderCodeMining {
+public class JavaImplementationCodeMining extends AbstractJavaElementLineHeaderCodeMining implements IPlaceholderCodeMining {
  • Implement the getPlaceholderLabel() Method:
@Override
public String getPlaceholderLabel() {
  if (!showImplementationsAtLeastOne) {
    return "?? implementations"; //$NON-NLS-1$
  }
  return null;
}

@flori-schwa

Copy link
Copy Markdown
Author

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

@flori-schwa
flori-schwa force-pushed the fschwabe/codemining-placeholders branch from 0113326 to 05782b5 Compare October 16, 2026 17:36
@flori-schwa flori-schwa changed the title CodeMinings: Add support for rendering placeholders while resolving() CodeMinings: Add support for rendering placeholder while resolving #3723 Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ± 0     867 suites  ±0   49m 27s ⏱️ - 10m 41s
 8 470 tests + 5   8 228 ✅ + 5  242 💤 ±0  0 ❌ ±0 
21 288 runs  +15  20 605 ✅ +15  683 💤 ±0  0 ❌ ±0 

Results for commit 05782b5. ± Comparison against base commit 3faf11c.

This pull request removes 2 and adds 7 tests. Note that renamed tests count towards both.
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testGetHeightDoesNotReturnZero
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testTwoLineCodeMiningHeightMatchesTextWidgetLineHeight
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testGetHeightDoesNotReturnZero(boolean)[1] placeHolder: false
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testGetHeightDoesNotReturnZero(boolean)[2] placeHolder: true
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testResolvedPlaceholderDoesNotRequestRedraw
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testTwoLineCodeMiningHeightMatchesTextWidgetLineHeight(boolean)[1] placeHolder: false
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testTwoLineCodeMiningHeightMatchesTextWidgetLineHeight(boolean)[2] placeHolder: true
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testUnresolvedPlaceholderRequestsRedraw
org.eclipse.jface.text.tests.codemining.CodeMiningTest ‑ testLineHeaderCodeMiningPlaceholder

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 IPlaceholderCodeMining to 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

import org.eclipse.jface.text.codemining.IPlaceholderCodeMining;
import org.eclipse.jface.text.codemining.LineHeaderCodeMining;

public class PlaceholderLineHeaderCodeMining extends LineHeaderCodeMining implements IPlaceholderCodeMining {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Only the (int, IDocument, ICodeMiningProvider) constructor is used; drop the other two. You could also reuse the private ResolvablePlaceholderMining from CodeMiningLineHeaderAnnotationTest (moved here) instead of having two similar helper classes.

(Created by Claude)

@flori-schwa
flori-schwa force-pushed the fschwabe/codemining-placeholders branch 3 times, most recently from b5e1b6d to 26f3acd Compare November 4, 2026 12:24
…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
@flori-schwa
flori-schwa force-pushed the fschwabe/codemining-placeholders branch from 26f3acd to e80a3e9 Compare November 6, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent editor "jumping" by using placeholders for Code Minings

3 participants