Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
import org.eclipse.ui.internal.editors.text.TextEditorDefaultsPreferencePage.EnumeratedDomain.EnumValue;
import org.eclipse.ui.internal.editors.text.codemining.annotation.AnnotationCodeMiningPreferenceConstants;

import org.eclipse.ui.internal.texteditor.BlockEndCodeMiningPreferenceConstants;

import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AbstractTextEditor;

Expand Down Expand Up @@ -808,6 +810,9 @@ private OverlayPreferenceStore createOverlayStore() {
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AnnotationCodeMiningPreferenceConstants.SHOW_ANNOTATION_CODE_MINING_LEVEL));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AnnotationCodeMiningPreferenceConstants.SHOW_ANNOTATION_CODE_MINING_MAX));

overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, BlockEndCodeMiningPreferenceConstants.SHOW_BLOCK_END_CODE_MINING));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, BlockEndCodeMiningPreferenceConstants.BLOCK_END_CODE_MINING_MIN_LINES));

overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_STICKY_SCROLLING_ENABLED));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_STICKY_SCROLLING_MAXIMUM_COUNT));

Expand Down Expand Up @@ -1027,6 +1032,18 @@ public void widgetSelected(SelectionEvent e) {
((Combo) showCodeMiningsControls[1]).addSelectionListener(codeMiningsListener);
fMasterSlaveListeners.add(codeMiningsListener);

label= TextEditorMessages.TextEditorDefaultsPreferencePage_blockEndCodeMining;
description= TextEditorMessages.TextEditorDefaultsPreferencePage_blockEndCodeMining_description;
Preference blockEndCodeMining= new Preference(BlockEndCodeMiningPreferenceConstants.SHOW_BLOCK_END_CODE_MINING, label, description);
Button blockEndCodeMiningButton= addCheckBox(appearanceComposite, blockEndCodeMining, new BooleanDomain(), 0);

label= TextEditorMessages.TextEditorDefaultsPreferencePage_blockEndCodeMining_minLines;
description= TextEditorMessages.TextEditorDefaultsPreferencePage_blockEndCodeMining_minLines_description;
Preference blockEndCodeMiningMinLines= new Preference(BlockEndCodeMiningPreferenceConstants.BLOCK_END_CODE_MINING_MIN_LINES, label, description);
IntegerDomain blockEndCodeMiningMinLinesDomain= new IntegerDomain(1, 99999);
Control[] blockEndCodeMiningMinLinesControls= addTextField(appearanceComposite, blockEndCodeMiningMinLines, blockEndCodeMiningMinLinesDomain, 15, 20);
createDependency(blockEndCodeMiningButton, blockEndCodeMining, blockEndCodeMiningMinLinesControls);

label= TextEditorMessages.TextEditorDefaultsPreferencePage_stickyScrollingEnabled;
Preference stickyScrollingEnabled= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_STICKY_SCROLLING_ENABLED, label, null);
Button stickyScrollingEnabledButton= addCheckBox(appearanceComposite, stickyScrollingEnabled, new BooleanDomain(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ private TextEditorMessages() {
public static String TextEditorDefaultsPreferencePage_codeMinings_max_description;
public static String TextEditorDefaultsPreferencePage_codeMinings_none;
public static String TextEditorDefaultsPreferencePage_codeMinings_show;
public static String TextEditorDefaultsPreferencePage_blockEndCodeMining;
public static String TextEditorDefaultsPreferencePage_blockEndCodeMining_description;
public static String TextEditorDefaultsPreferencePage_blockEndCodeMining_minLines;
public static String TextEditorDefaultsPreferencePage_blockEndCodeMining_minLines_description;
public static String TextEditorDefaultsPreferencePage_configureWhitespaceCharacterPainterProperties;
public static String TextEditorDefaultsPreferencePage_deleteSpacesAsTabs;
public static String TextEditorDefaultsPreferencePage_enclosed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ TextEditorDefaultsPreferencePage_codeMinings_max=Maximum annotations shown:
TextEditorDefaultsPreferencePage_codeMinings_max_description=Limits the number of shown annotations to prevent performance issues
TextEditorDefaultsPreferencePage_codeMinings_none=None
TextEditorDefaultsPreferencePage_codeMinings_show=Show code minings &for problem annotations:
TextEditorDefaultsPreferencePage_blockEndCodeMining=Show &block end code minings
TextEditorDefaultsPreferencePage_blockEndCodeMining_description=Shows the opening line of a code block at its closing brace
TextEditorDefaultsPreferencePage_blockEndCodeMining_minLines=Minimum block size (lines):
TextEditorDefaultsPreferencePage_blockEndCodeMining_minLines_description=A block end code mining is only shown when the block spans at least this many lines or contains a nested block
TextEditorDefaultsPreferencePage_configureWhitespaceCharacterPainterProperties=Configure visibility of whitespace characters in different regions of a line of text:
TextEditorDefaultsPreferencePage_deleteSpacesAsTabs=Remove &multiple spaces on backspace/delete
TextEditorDefaultsPreferencePage_enclosed=Enclosed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.eclipse.ui.internal.editors.text.EditorsPlugin;
import org.eclipse.ui.internal.editors.text.EditorsPluginPreferenceInitializer;
import org.eclipse.ui.internal.texteditor.BlockEndCodeMiningPreferenceConstants;

import org.eclipse.ui.texteditor.spelling.SpellingService;

Expand Down Expand Up @@ -883,6 +884,9 @@ public static void initializeDefaultValues(IPreferenceStore store) {
store.setDefault(EDITOR_STICKY_SCROLLING_ENABLED, false);
store.setDefault(EDITOR_STICKY_SCROLLING_MAXIMUM_COUNT, 4);

store.setDefault(BlockEndCodeMiningPreferenceConstants.SHOW_BLOCK_END_CODE_MINING, false);
store.setDefault(BlockEndCodeMiningPreferenceConstants.BLOCK_END_CODE_MINING_MIN_LINES, BlockEndCodeMiningPreferenceConstants.DEFAULT_MIN_LINES);

MarkerAnnotationPreferences.initializeDefaultValues(store);

EditorsPluginPreferenceInitializer.setThemeBasedPreferences(store, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,4 @@ blockSelectionModeFont.description= The block selection mode font is used by tex
MinimapView.name=Minimap

CodeMining.show.ZWSP=Show ZWSP (Zero-Width Space)
CodeMining.blockEnd=Show block end code minings
5 changes: 5 additions & 0 deletions bundles/org.eclipse.ui.workbench.texteditor/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,11 @@
id="org.eclipse.test.codemining.zswpProvider"
label="%CodeMining.show.ZWSP">
</codeMiningProvider>
<codeMiningProvider
class="org.eclipse.ui.internal.texteditor.codemining.BlockEndCodeMiningProvider"
id="org.eclipse.ui.workbench.texteditor.codemining.blockEndProvider"
label="%CodeMining.blockEnd">
</codeMiningProvider>
</extension>

<extension
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2026 Eclipse Platform contributors.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.ui.internal.texteditor;

/**
* Preference keys for the block-end code mining that is contributed by
* {@code org.eclipse.ui.internal.texteditor.codemining.BlockEndCodeMiningProvider}.
* <p>
* The keys are shared between the provider (which reads them) and the
* {@code org.eclipse.ui.editors} preference page and default initializer (which
* expose and write them). They therefore live in this package which is a friend
* of {@code org.eclipse.ui.editors}.
* </p>
*/
public final class BlockEndCodeMiningPreferenceConstants {

/**
* Boolean preference that controls whether a code mining echoing a block's
* opening line is shown at its closing brace. The default value is
* <code>false</code>.
*/
public static final String SHOW_BLOCK_END_CODE_MINING= "showBlockEndCodeMining"; //$NON-NLS-1$

/**
* Integer preference for the minimum number of lines a block must span before a
* block-end code mining is shown for it. Blocks that contain a nested block are
* annotated regardless of this value.
*/
public static final String BLOCK_END_CODE_MINING_MIN_LINES= "blockEndCodeMiningMinLines"; //$NON-NLS-1$

/**
* Default value for {@link #BLOCK_END_CODE_MINING_MIN_LINES}.
*/
public static final int DEFAULT_MIN_LINES= 20;

private BlockEndCodeMiningPreferenceConstants() {
// Prevent instantiation
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2026 Eclipse Platform contributors.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.ui.internal.texteditor.codemining;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.codemining.ICodeMiningProvider;
import org.eclipse.jface.text.codemining.LineEndCodeMining;

/**
* A code mining drawn at the end of a block's closing brace line that echoes the
* text of the block's opening line.
*
* @see BlockEndCodeMiningProvider
*/
class BlockEndCodeMining extends LineEndCodeMining {

private final String label;

BlockEndCodeMining(IDocument document, int line, String label, ICodeMiningProvider provider) throws BadLocationException {
super(document, line, provider);
this.label= label;
}

@Override
public boolean isResolved() {
return true;
}

@Override
public String getLabel() {
return label;
}
}
Loading
Loading