1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 314813 - [mark occurrences] Add preference option for overloaded operators

This commit is contained in:
Anton Leherbauer 2010-10-28 13:16:15 +00:00
parent e137bca742
commit c83b49a790
6 changed files with 37 additions and 13 deletions

View file

@ -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();

View file

@ -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 <code>true</code>.
* @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();

View file

@ -79,6 +79,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock
ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
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);
}

View file

@ -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;

View file

@ -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

View file

@ -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 <code>true</code>.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
@ -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 <code>true</code>.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @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.
* <p>
@ -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