Skip to content

Add opt-in block-end code mining - #4226

Open
vogella wants to merge 2 commits into
eclipse-platform:masterfrom
vogella:lv/block-end-codemining
Open

vogella wants to merge 2 commits into
eclipse-platform:masterfrom
vogella:lv/block-end-codemining

Conversation

@vogella

@vogella vogella commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Adds a best-effort, language-independent code mining that echoes a block's opening line at its closing brace, so an isolated } tells you which block it terminates.
The echoed text is prefixed with // so it reads like the closing brace comment people write by hand.

Braces are matched purely structurally, which keeps org.eclipse.ui.workbench.texteditor free of any dependency on JDT or a language model.
Braces in comments and string literals are skipped where the document has a partitioning that marks code as the default content type, including empty boundary partitions in comment-only documents.
A partitioning that uses content types of its own, as TextMate does for every text file, cannot say where the code is and is ignored. In that fallback, braces inside comments or literals can produce incorrect matches.
A block is annotated once it spans at least a configurable number of lines, 20 by default.
Nothing in the platform recomputes minings on a document change (JDT ships its own reconciler for that), so the provider follows the document itself and refreshes shortly after typing stops, scanning a copy of the document in the background.
Edits immediately cancel the current request, including a completed scan still waiting for other providers, so obsolete snapshot positions are not published by the combined code-mining refresh.

The feature is off by default behind a new checkbox on the Text Editors preference page.
Since that page is already crowded, the new setting and the existing problem annotation code mining settings now share a "Code Minings" group instead of adding two more rows to the flat option list.

@github-actions

github-actions Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ±  0     867 suites  ±0   1h 4m 53s ⏱️ + 12m 11s
 8 685 tests + 62   8 445 ✅ + 62  240 💤 ±0  0 ❌ ±0 
21 924 runs  +186  21 251 ✅ +186  673 💤 ±0  0 ❌ ±0 

Results for commit 94de360. ± Comparison against base commit ecc4c34.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the lv/block-end-codemining branch from f1dd834 to 8a4d2f4 Compare August 14, 2026 10:23
@vogella vogella changed the title WIP - Add opt-in block-end code mining Add opt-in block-end code mining Aug 14, 2026
@vogella
vogella force-pushed the lv/block-end-codemining branch from 8a4d2f4 to d0316e0 Compare August 24, 2026 02:53
@vogella vogella added plan Planned bugs/enhancements for a release and removed Planned for 4.42 labels Aug 31, 2026
@vogella
vogella force-pushed the lv/block-end-codemining branch from d0316e0 to 0434738 Compare September 9, 2026 14:43
@vogella
vogella marked this pull request as ready for review September 9, 2026 14:44
@vogella

vogella commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author
pr4226-preferences pr4226-code-minings

@vogella
vogella force-pushed the lv/block-end-codemining branch 2 times, most recently from b2b9730 to 096ec8a Compare October 7, 2026 05:56
@vogella
vogella force-pushed the lv/block-end-codemining branch 2 times, most recently from 069d8ff to 181196e Compare October 8, 2026 12:19
@vogella

vogella commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author
pr4226-code-minings-cropped pr4226-preferences

Works also for non Java l like JS

pr4226-code-minings-js-cropped

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

Asynchronous completion can render off the SWT thread, and Allman-style blocks can derive labels from comments.

2 open findings
What changed in this PR

Adds opt-in, language-agnostic block-end code minings to text editors.

Changes:

  • Implements asynchronous structural brace matching and refresh handling.
  • Adds grouped code-mining preferences with a configurable minimum block size.
  • Adds unit and UI coverage for matching, preferences, and rendering.
File Description
WorkbenchTextEditorTestSuite.java Registers structural matching tests.
BlockEndCodeMiningTest.java Tests block detection and partition handling.
TextEditorDefaultsPreferencePageTest.java Tests preference defaults and controls.
EditorsTestSuite.java Registers preference and rendering tests.
BlockEndCodeMiningRenderingTest.java Tests live editor rendering and refreshes.
BlockEndCodeMiningProvider.java Implements block scanning and refresh behavior.
BlockEndCodeMining.java Defines the rendered line-end mining.
BlockEndCodeMiningPreferenceConstants.java Defines preference keys and defaults.
org.eclipse.ui.workbench.texteditor/​plugin.xml Registers the provider.
org.eclipse.ui.workbench.texteditor/​plugin.properties Adds the provider label.
AbstractDecoratedTextEditorPreferenceConstants.java Initializes preference defaults.
TextEditorMessages.properties Adds preference-page messages.
TextEditorMessages.java Exposes the new messages.
TextEditorDefaultsPreferencePage.java Adds grouped code-mining controls.
org.eclipse.ui.editors/​plugin.xml Registers preference-search keywords.
org.eclipse.ui.editors/​plugin.properties Defines block-end search terms.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vogella
vogella force-pushed the lv/block-end-codemining branch from 181196e to 969cdff Compare October 9, 2026 05:22
@vogella
vogella requested a balanced review from Copilot October 9, 2026 06:03

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

Closing-line heuristics can suppress valid minings or attach misleading labels when trailing strings or inline blocks are present.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

@vogella
vogella force-pushed the lv/block-end-codemining branch 2 times, most recently from f1b7117 to 397d765 Compare October 16, 2026 07:19
@vogella
vogella force-pushed the lv/block-end-codemining branch from 397d765 to 91f8efa Compare November 10, 2026 19:37
@vogella
vogella force-pushed the lv/block-end-codemining branch from 91f8efa to b638aa0 Compare November 30, 2026 12:38
@eclipse-platform-bot

Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF
bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From b1d6537577f133548bff79d54c4f4811e10042e1 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Mon, 30 Nov 2026 12:44:24 +0000
Subject: [PATCH] Version bump(s) for 4.43 stream


diff --git a/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF
index b23ca3fa7b..f20b751069 100644
--- a/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true
-Bundle-Version: 3.23.0.qualifier
+Bundle-Version: 3.23.100.qualifier
 Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: %providerName
diff --git a/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
index 002a49ef57..8db5f86526 100644
--- a/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor; singleton:=true
-Bundle-Version: 3.20.300.qualifier
+Bundle-Version: 3.20.400.qualifier
 Bundle-Activator: org.eclipse.ui.internal.texteditor.TextEditorPlugin
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: %providerName
-- 
2.56.1

Further information are available in Common Build Issues - Missing version increments.

@vogella
vogella force-pushed the lv/block-end-codemining branch from d859b5a to 271dcb5 Compare November 30, 2026 16:18
Echo a block's opening line at its closing brace, prefixed with " // ", so an
isolated } tells which block it terminates. Braces are matched structurally,
skipping comments and literals where a partitioning marks code as the default
content type, and the provider refreshes itself after typing pauses, scanning a
document copy in the background. Off by default, enabled on the Text Editors
preference page in a new "Code Minings" group.

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@vogella
vogella force-pushed the lv/block-end-codemining branch from 271dcb5 to 94de360 Compare December 3, 2026 16:24
@vogella

vogella commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author
preferences editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan Planned bugs/enhancements for a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants