Skip to content

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

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

vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:lv/block-end-codemining

Conversation

@vogella

@vogella vogella commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Adds a language-agnostic 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; 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.
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.

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

   864 files  ±  0     864 suites  ±0   45m 51s ⏱️ - 2m 22s
 8 444 tests + 40   8 202 ✅ + 40  242 💤 ±0  0 ❌ ±0 
21 201 runs  +120  20 524 ✅ +120  677 💤 ±0  0 ❌ ±0 

Results for commit 969cdff. ± Comparison against base commit 0cf5104.

♻️ 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.

Echo a block's opening line at its closing brace, prefixed with " // ", so an
isolated } tells which block it terminates.

Braces are matched structurally, without a parser, so there is no 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; 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. Only blocks
spanning at least a configurable number of lines are annotated, 20 by default.
A closing brace that already carries a comment is left alone.

Nothing in the platform recomputes minings on a document change, JDT brings 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.

The feature is off by default and enabled on the Text Editors preference page,
where the code mining settings now share a group with the existing problem
annotation ones, placed after the sticky scrolling settings.

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@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

Comment on lines +262 to +264
// The echo would read as a label of the block that opens after the brace, as in "} else {".
if (afterBrace.endsWith("{")) { //$NON-NLS-1$
return;
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.

2 participants