Skip to content

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

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

Add opt-in block-end code mining#4226
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 over the default document partitioning, which keeps org.eclipse.ui.workbench.texteditor free of any dependency on JDT or a language model: braces inside comments and strings are skipped whenever a partitioner is installed, and otherwise the whole document is treated as code. A block is annotated once it spans at least a configurable number of lines (default 20), which is the only knob; an earlier "or contains a nested block" rule was dropped because it fired on very short blocks and cluttered the editor.

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.

Covered by unit tests for the brace matching (including partitioned documents where braces sit in comments and strings), a preference page test for the group and the enablement dependency, and an editor test that asserts the mining is actually rendered at the closing brace and disappears again when the preference is turned off.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Test Results

   858 files  +    5     858 suites  +5   58m 31s ⏱️ + 10m 40s
 8 189 tests +   28   7 946 ✅ +   28  243 💤 ± 0  0 ❌ ±0 
20 469 runs  +1 237  19 815 ✅ +1 217  654 💤 +20  0 ❌ ±0 

Results for commit 8a4d2f4. ± Comparison against base commit 5ddc27d.

♻️ This comment has been updated with latest results.

Add a language-agnostic code mining that echoes a block's opening line at
its closing brace, making it easier to see which block a closing brace
belongs to. The echoed text is prefixed with "// " so it reads like the
closing brace comment people write by hand.

Braces are matched purely structurally, so braces inside comments and
strings are ignored when the document has a partitioner for the default
partitioning; otherwise the whole document is treated as code. There is
no dependency on JDT or any language model.

To avoid clutter the mining is only shown for blocks spanning at least a
configurable number of lines (default 20). The feature is registered by
default but disabled via preferences and can be enabled together with
the minimum block size on the Text Editors preference page. The code
mining settings there now live in their own group, which also takes the
existing problem annotation settings off the crowded flat option list.
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant