WIP - Add opt-in block-end code mining - #4226
Draft
vogella wants to merge 1 commit into
Draft
Conversation
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 over the default document partitioning, so braces inside comments and strings are ignored when a partitioner is available; 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 when a block spans at least a configurable number of lines (default 20) or contains a nested block. 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.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.texteditorfree 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. To avoid clutter a block is only annotated when it spans at least a configurable number of lines (default 20) or contains a nested block, and the feature is off by default behind a new checkbox on the Text Editors preference page.Still marked WIP: the rendering has not been verified in a running IDE yet, and the default threshold of 20 lines is a guess that deserves a second opinion.