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;
}

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 2 times, most recently 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

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ± 0     867 suites  ±0   44m 27s ⏱️ - 6m 32s
 8 555 tests + 7   8 315 ✅ + 7  240 💤 ±0  0 ❌ ±0 
21 537 runs  +21  20 864 ✅ +21  673 💤 ±0  0 ❌ ±0 

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.
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testGetHeightDoesNotReturnZero
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testTwoLineCodeMiningHeightMatchesTextWidgetLineHeight
org.eclipse.jface.text.tests.codemining.CodeMiningLineHeaderAnnotationTest ‑ testFailedPlaceholderResolveRequestsRedraw
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.CodeMiningLineHeaderAnnotationTest ‑ testUnresolvedPlaceholderShowsLastResolved
org.eclipse.jface.text.tests.codemining.CodeMiningTest ‑ testLineHeaderCodeMiningPlaceholder

♻️ This comment has been updated with latest results.

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

@flori-schwa
flori-schwa force-pushed the fschwabe/codemining-placeholders branch 4 times, most recently from 26f3acd to e80a3e9 Compare November 6, 2026 14:12
@fedejeanne

Copy link
Copy Markdown
Member

Thanks for the update, the separate getPlaceholderLabel() method works well: getLabel() keeps its meaning, the click mapping and the "last resolved vs. placeholder" decision are now correct, and all my earlier points are addressed except the two below.

1. Test helper cleanup (the open thread on PlaceholderLineHeaderCodeMining)

PlaceholderLineHeaderCodeMining still has three constructors but only one is used. UnresolvedPlaceholderMining and ResolvablePlaceholderMining in CodeMiningLineHeaderAnnotationTest duplicate it. The patch below makes PlaceholderLineHeaderCodeMining concrete with a single constructor that takes the placeholder label, and reuses it everywhere.

2. Javadoc caveats for implementors of IPlaceholderCodeMining: the placeholder only prevents jumping if it has the same number of lines as the resolved label, and a null/empty resolved label makes the lines disappear again. Also included in the patch.

I applied the patch on top of e80a3e927c and ran CodeMiningLineHeaderAnnotationTest (11 tests) and CodeMiningTest (20 tests) with Tycho. It compiles and all tests pass.

Patch (apply with git apply)
diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/IPlaceholderCodeMining.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/IPlaceholderCodeMining.java
index 3ac92cfd2f..64664cb4c0 100644
--- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/IPlaceholderCodeMining.java
+++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/IPlaceholderCodeMining.java
@@ -36,6 +36,10 @@ import org.eclipse.jface.text.ITextViewer;
  * <li>If resolution fails or is cancelled, the label should remain {@code null}. The mining is then
  * treated as resolved with an error, see {@link ICodeMining#getLabel()}.</li>
  * </ul>
+ * <p>
+ * To actually prevent editor jumping, the placeholder should have the same number of lines as the
+ * resolved label. If the mining resolves to a {@code null} or empty label, the placeholder
+ * disappears and the lines it occupied are removed again.
  *
  * @see ICodeMining
  * @since 3.32
diff --git a/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningLineHeaderAnnotationTest.java b/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningLineHeaderAnnotationTest.java
index bb846d0cb1..23c8306ae1 100644
--- a/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningLineHeaderAnnotationTest.java
+++ b/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningLineHeaderAnnotationTest.java
@@ -47,12 +47,9 @@ import org.eclipse.jface.internal.text.codemining.CodeMiningLineHeaderAnnotation
 
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.Position;
 import org.eclipse.jface.text.codemining.ICodeMining;
-import org.eclipse.jface.text.codemining.ICodeMiningProvider;
-import org.eclipse.jface.text.codemining.IPlaceholderCodeMining;
 import org.eclipse.jface.text.codemining.LineHeaderCodeMining;
 import org.eclipse.jface.text.source.AnnotationModel;
 import org.eclipse.jface.text.source.AnnotationPainter;
@@ -297,7 +294,7 @@ public class CodeMiningLineHeaderAnnotationTest {
 
 		String placeholder= "Placeholder";
 
-		ICodeMining mining= new ResolvablePlaceholderMining(0, document, null, placeholder) {
+		ICodeMining mining= new PlaceholderLineHeaderCodeMining(0, document, null, placeholder) {
 
 			@Override
 			public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) {
@@ -343,7 +340,7 @@ public class CodeMiningLineHeaderAnnotationTest {
 
 		String placeholder= "Placeholder";
 
-		ICodeMining mining= new ResolvablePlaceholderMining(0, document, null, placeholder) {
+		ICodeMining mining= new PlaceholderLineHeaderCodeMining(0, document, null, placeholder) {
 			@Override
 			protected CompletableFuture<Void> doResolve(ITextViewer viewer, IProgressMonitor monitor) {
 				resolveRequested.set(true);
@@ -387,7 +384,7 @@ public class CodeMiningLineHeaderAnnotationTest {
 			}
 		};
 
-		ICodeMining unresolvedPlaceholder= new ResolvablePlaceholderMining(0, document, null, "Placeholder") {
+		ICodeMining unresolvedPlaceholder= new PlaceholderLineHeaderCodeMining(0, document, null, "Placeholder") {
 			@Override
 			public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) {
 				drawnMining.compareAndSet(null, this);
@@ -412,7 +409,12 @@ public class CodeMiningLineHeaderAnnotationTest {
 	}
 
 	private LineHeaderCodeMining unresolvedPlaceholder(String label) throws BadLocationException {
-		return new UnresolvedPlaceholderMining(0, document, null, label);
+		return new PlaceholderLineHeaderCodeMining(0, document, null, label) {
+			@Override
+			public boolean isResolved() {
+				return false;
+			}
+		};
 	}
 
 	private LineHeaderCodeMining codeMining(String label) throws BadLocationException {
@@ -432,41 +434,4 @@ public class CodeMiningLineHeaderAnnotationTest {
 		return new Font(textWidget.getDisplay(), "Consolas", height, SWT.NORMAL); //$NON-NLS-1$
 	}
 
-	private static class UnresolvedPlaceholderMining extends LineHeaderCodeMining implements IPlaceholderCodeMining {
-
-		private final String placeholderLabel;
-
-		public UnresolvedPlaceholderMining(int beforeLineNumber, IDocument document, ICodeMiningProvider provider, String label) throws BadLocationException {
-			super(beforeLineNumber, document, provider);
-			this.placeholderLabel= label;
-		}
-
-		@Override
-		public boolean isResolved() {
-			return false;
-		}
-
-		@Override
-		public String getPlaceholderLabel() {
-			return placeholderLabel;
-		}
-
-	}
-
-	private static class ResolvablePlaceholderMining extends LineHeaderCodeMining implements IPlaceholderCodeMining {
-
-		private final String placeholderLabel;
-
-		public ResolvablePlaceholderMining(int beforeLineNumber, IDocument document, ICodeMiningProvider provider, String placeholder) throws BadLocationException {
-			super(beforeLineNumber, document, provider);
-			this.placeholderLabel= placeholder;
-		}
-
-		@Override
-		public String getPlaceholderLabel() {
-			return placeholderLabel;
-		}
-
-	}
-
 }
diff --git a/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java b/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java
index 93d47efdf3..2dfe7730fe 100644
--- a/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java
+++ b/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java
@@ -891,12 +891,7 @@ public class CodeMiningTest {
 					@Override
 					public CompletableFuture<List<? extends ICodeMining>> provideCodeMinings(ITextViewer viewer, IProgressMonitor monitor) {
 						try {
-							ICodeMining mining= new PlaceholderLineHeaderCodeMining(0, viewer.getDocument(), this) {
-
-								@Override
-								public String getPlaceholderLabel() {
-									return placeholderText;
-								}
+							ICodeMining mining= new PlaceholderLineHeaderCodeMining(0, viewer.getDocument(), this, placeholderText) {
 
 								@Override
 								protected CompletableFuture<Void> doResolve(ITextViewer theViewer, IProgressMonitor theMonitor) {
diff --git a/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/PlaceholderLineHeaderCodeMining.java b/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/PlaceholderLineHeaderCodeMining.java
index 7f7e3024fa..28673ca5db 100644
--- a/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/PlaceholderLineHeaderCodeMining.java
+++ b/tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/PlaceholderLineHeaderCodeMining.java
@@ -10,29 +10,27 @@
  *******************************************************************************/
 package org.eclipse.jface.text.tests.codemining;
 
-import java.util.function.Consumer;
-
-import org.eclipse.swt.events.MouseEvent;
-
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
 import org.eclipse.jface.text.codemining.ICodeMiningProvider;
 import org.eclipse.jface.text.codemining.IPlaceholderCodeMining;
 import org.eclipse.jface.text.codemining.LineHeaderCodeMining;
 
-public abstract class PlaceholderLineHeaderCodeMining extends LineHeaderCodeMining implements IPlaceholderCodeMining {
+/**
+ * {@link LineHeaderCodeMining} with a fixed placeholder label for tests.
+ */
+public class PlaceholderLineHeaderCodeMining extends LineHeaderCodeMining implements IPlaceholderCodeMining {
 
-	public PlaceholderLineHeaderCodeMining(int beforeLineNumber, IDocument document, ICodeMiningProvider provider, Consumer<MouseEvent> action) throws BadLocationException {
-		super(beforeLineNumber, document, provider, action);
-	}
+	private final String placeholderLabel;
 
-	public PlaceholderLineHeaderCodeMining(int beforeLineNumber, IDocument document, ICodeMiningProvider provider) throws BadLocationException {
+	public PlaceholderLineHeaderCodeMining(int beforeLineNumber, IDocument document, ICodeMiningProvider provider, String placeholderLabel) throws BadLocationException {
 		super(beforeLineNumber, document, provider);
+		this.placeholderLabel= placeholderLabel;
 	}
 
-	public PlaceholderLineHeaderCodeMining(Position position, ICodeMiningProvider provider, Consumer<MouseEvent> action) throws BadLocationException {
-		super(position, provider, action);
+	@Override
+	public String getPlaceholderLabel() {
+		return placeholderLabel;
 	}
 
 }

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

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 fedejeanne left a comment

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.

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

@flori-schwa
flori-schwa force-pushed the fschwabe/codemining-placeholders branch from 05bffd8 to 1353228 Compare November 18, 2026 10:46

@fedejeanne fedejeanne left a comment

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.

All fixes applied ✔️

The failing test is unrelated:

I will merge once development for M1 is open (beginning of December).

@tobiasmelcher

Copy link
Copy Markdown
Contributor

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 IPlaceholderCodeMining interface, so the new code paths are never used for it. I found no regressions: rendering, resolving and clicking on code minings all behave as before. From that point of view the change is backward compatible for existing providers.

getPlaceholderLabel() is called on the UI thread, several times per paint

getPlaceholderLabel() is called synchronously on the UI thread, inside painting and line-height calculation, and more than once per paint. With one line-header placeholder mining that is still resolving, I counted these calls in a single repaint:

Call site Calls
getHeight → hasAtLeastOneDrawableMining → isDrawableMining 1
getHeight → getMultilineHeight 1
chooseMiningToDraw → getResolveState 1
chooseMiningToDraw → isDrawableMining 1
LineHeaderCodeMining.draw → getLabelOrPlaceholder() 1
AbstractCodeMining.draw → getLabelOrPlaceholder() (single-line labels only) 1
Total 6 (5 for a multi-line placeholder)

An implementation that does real work in getPlaceholderLabel() therefore blocks the UI directly. In my test a getter taking 100 ms blocked a single repaint for about 600 ms. This happens again on every repaint (scrolling, typing, resizing) until resolve() finishes, and it grows with the number of visible placeholder minings. It shows up as a frozen UI rather than flicker, and the framework can't interrupt a synchronous call on the display thread.

I'd suggest two changes:

  1. Document the threading contract in the Javadoc of IPlaceholderCodeMining.getPlaceholderLabel(). It is called on the UI thread during painting and layout. It must be cheap and must not block. It should return a precomputed value that stays the same while the mining is unresolved. Any expensive work belongs where the mining is created (e.g. in ICodeMiningProvider.provideCodeMinings, which is asynchronous) or in resolve().
  2. Call getPlaceholderLabel() only once per paint. The framework should read the placeholder once and reuse that value for the height calculation, for choosing what to draw, and for drawing. Reading it once per mining (for example when the annotation is updated, with AbstractCodeMining keeping the value) would be even better, since repaints would then never call client code for it.

@fedejeanne

Copy link
Copy Markdown
Member

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 PlaceholderLineHeaderCodeMining does today. Something like this should do:

* @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.

@tobiasmelcher

Copy link
Copy Markdown
Contributor

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.

@fedejeanne

Copy link
Copy Markdown
Member

@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 @apiNote since it needs other changes which are outside of the scope of this PR) but also to give subclasses of AbstractCodeMining a good starting point by using a pre-computed value. Repaints would only read a field and never run client code.

I tried that in vi-eclipse/fedejeanne/codemining-placeholders (currently vi-eclipse@748e424).

I did not add a cache in update() though since that one runs off the UI thread, so reading the placeholder there would change the thread contract. "Once per paint" is also hard to define, because getHeight() and draw() are separate calls. A cache in update() would be a second source of truth next to the field, which needs to be kept up-to-date (difficult).

Also, classes that implement IPlaceholderCodeMining directly (without extending AbstractCodeMining) are not cached. For them only the documented contract applies.

Do you think this would be a good compromise?

@flori-schwa
flori-schwa force-pushed the fschwabe/codemining-placeholders branch from 1353228 to 5e379b7 Compare November 27, 2026 08:34
@flori-schwa

flori-schwa commented Nov 27, 2026 •

Copy link
Copy Markdown
Author

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" getPlaceholderLabel() Method, whose value does not change on repeated calls and caching the placeholder labels in the annotation (next to fMinings).

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
@flori-schwa
flori-schwa force-pushed the fschwabe/codemining-placeholders branch from 5e379b7 to 7a24e7a Compare November 27, 2026 09:03
@tobiasmelcher

Copy link
Copy Markdown
Contributor

Also, classes that implement IPlaceholderCodeMining directly (without extending AbstractCodeMining) are not cached. For them only the documented contract applies.

Do you think this would be a good compromise?

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.

@flori-schwa

Copy link
Copy Markdown
Author

Also, classes that implement IPlaceholderCodeMining directly (without extending AbstractCodeMining) are not cached. For them only the documented contract applies.
Do you think this would be a good compromise?

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.
If we go with the latter, then the new interface might not be needed and could be replaced by a new default method in ICodeMining.

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

4 participants