From c83b49a7907db641d8c3935efb3c663bcf876144 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Thu, 28 Oct 2010 13:16:15 +0000 Subject: [PATCH] Bug 314813 - [mark occurrences] Add preference option for overloaded operators --- .../cdt/ui/tests/text/MarkOccurrenceTest.java | 5 +---- .../cdt/internal/ui/editor/CEditor.java | 18 ++++++++++++------ .../MarkOccurrencesConfigurationBlock.java | 11 +++++++++-- .../ui/preferences/PreferencesMessages.java | 1 + .../preferences/PreferencesMessages.properties | 1 + .../eclipse/cdt/ui/PreferenceConstants.java | 14 +++++++++++++- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java index d0ecec1a98b..66ab69c0dcf 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java @@ -124,10 +124,7 @@ public class MarkOccurrenceTest extends BaseUITestCase { assertNotNull(fgWriteHighlightRGB); final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true); - // TLETODO temporary fix for bug 314635 - store.setValue(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX - + SemanticHighlightings.OVERLOADED_OPERATOR - + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX, true); + store.setValue(PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, true); fEditor= openCEditor(new Path("/" + PROJECT + "/src/occurrences.cpp")); assertNotNull(fEditor); fTextWidget= fEditor.getViewer().getTextWidget(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index e515c86b56f..072de8bee09 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -1479,6 +1479,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC ((CSourceViewer) getSourceViewer()).setPreferenceStore(store); fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES); + fMarkOverloadedOperatorOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES); fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES); } @@ -1691,6 +1692,10 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC fStickyOccurrenceAnnotations= newBooleanValue; return; } + if (PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES.equals(property)) { + fMarkOverloadedOperatorOccurrences= newBooleanValue; + return; + } if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event) || (isEnableScalablilityMode() && PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT.equals(property))) { @@ -2782,6 +2787,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC * @since 5.0 */ private boolean fStickyOccurrenceAnnotations; + /** + * Tells whether to mark overloaded operator occurrences in this editor. + * Only valid if {@link #fMarkOccurrenceAnnotations} is true. + * @since 5.3 + */ + private boolean fMarkOverloadedOperatorOccurrences; /** * The selection used when forcing occurrence marking * through code. @@ -3360,12 +3371,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC if (binding != null) { OccurrencesFinder occurrencesFinder= new OccurrencesFinder(); if (occurrencesFinder.initialize(astRoot, name) == null) { - // TLETODO temporary fix for bug 314635 - boolean overloadedOperatorsEnabled = getPreferenceStore().getBoolean( - PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX - + SemanticHighlightings.OVERLOADED_OPERATOR - + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX); - if (!overloadedOperatorsEnabled) { + if (!fMarkOverloadedOperatorOccurrences) { occurrencesFinder.setOptions(OccurrencesFinder.OPTION_EXCLUDE_IMPLICIT_REFERENCES); } locations= occurrencesFinder.getOccurrences(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java index c5d4251723e..8069cb54867 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java @@ -79,6 +79,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock ArrayList overlayKeys= new ArrayList(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES)); OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; @@ -122,8 +123,14 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock addFiller(composite); + label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markOverloadOccurrences; + Button slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, 0); + createDependency(master, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, slave); + + addFiller(composite); + label= PreferencesMessages.MarkOccurrencesConfigurationBlock_stickyOccurrences; - Button slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); + slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); createDependency(master, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave); return composite; @@ -171,7 +178,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock private static void indent(Control control) { GridData gridData= new GridData(); - gridData.horizontalIndent= 20; + gridData.horizontalIndent= 10; control.setLayoutData(gridData); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java index c99f011a446..9e8c92ea07d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java @@ -393,6 +393,7 @@ public final class PreferencesMessages extends NLS { public static String MarkOccurrencesConfigurationBlock_link; public static String MarkOccurrencesConfigurationBlock_link_tooltip; public static String MarkOccurrencesConfigurationBlock_markOccurrences; + public static String MarkOccurrencesConfigurationBlock_markOverloadOccurrences; public static String MarkOccurrencesConfigurationBlock_stickyOccurrences; public static String ScalabilityPreferencePage_description; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index 05c4983a1d2..8c56c66fb38 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -454,6 +454,7 @@ MarkOccurrencesConfigurationBlock_link= The appearance can be configured on the MarkOccurrencesConfigurationBlock_link_tooltip=Show the annotations preferences MarkOccurrencesConfigurationBlock_markOccurrences= Mark &occurrences of the selected element in the current file. +MarkOccurrencesConfigurationBlock_markOverloadOccurrences= Mark o&verloaded operators MarkOccurrencesConfigurationBlock_stickyOccurrences= &Keep marks when the selection changes #Scalability Preferences diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index 4e239a23408..4051ccf89f1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -1350,9 +1350,9 @@ public class PreferenceConstants { */ public static final String EDITOR_MARK_OCCURRENCES= "markOccurrences"; //$NON-NLS-1$ - /** * A named preference that controls whether occurrences are sticky in the editor. + * Only valid if {@link #EDITOR_MARK_OCCURRENCES} is true. *

* Value is of type Boolean. *

@@ -1361,6 +1361,17 @@ public class PreferenceConstants { */ public static final String EDITOR_STICKY_OCCURRENCES= "stickyOccurrences"; //$NON-NLS-1$ + /** + * A named preference that controls whether occurrences of overloaded operators are marked in the editor. + * Only valid if {@link #EDITOR_MARK_OCCURRENCES} is true. + *

+ * Value is of type Boolean. + *

+ * + * @since 5.3 + */ + public static final String EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES= "markOverloadedOperatorsOccurrences"; //$NON-NLS-1$ + /** * A named preference that controls whether all scalability mode options should be turned on. *

@@ -1661,6 +1672,7 @@ public class PreferenceConstants { // mark occurrences store.setDefault(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true); + store.setDefault(PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, false); store.setDefault(PreferenceConstants.EDITOR_STICKY_OCCURRENCES, true); // Scalability