1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2016-03-02 19:54:02 -08:00
parent 70fe8493fc
commit 86dabd3d00

View file

@ -31,10 +31,7 @@ import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.text.CTextTools;
public class ContentAssistPreference { public class ContentAssistPreference {
// /** Preference key for content assist auto activation (unused) */ // /** Preference key for content assist auto activation (unused) */
// public final static String AUTOACTIVATION= "content_assist_autoactivation"; // public final static String AUTOACTIVATION= "content_assist_autoactivation";
/** Preference key for content assist auto activation delay */ /** Preference key for content assist auto activation delay */
@ -55,6 +52,8 @@ public class ContentAssistPreference {
public final static String AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$ public final static String AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$
/** Preference key for content assist to insert the common prefix */ /** Preference key for content assist to insert the common prefix */
public final static String PREFIX_COMPLETION= "content_assist_prefix_completion"; //$NON-NLS-1$ public final static String PREFIX_COMPLETION= "content_assist_prefix_completion"; //$NON-NLS-1$
/** Preference key for content assist to guess function arguments. */
public final static String GUESS_ARGUMENTS= "content_assist_guess_arguments"; //$NON-NLS-1$
/** Preference key for C/CPP content assist auto activation triggers */ /** Preference key for C/CPP content assist auto activation triggers */
public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot"; //$NON-NLS-1$ public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot"; //$NON-NLS-1$
@ -69,7 +68,7 @@ public class ContentAssistPreference {
// public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$ // public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$
/** Preference key for alphabetic ordering of proposals */ /** Preference key for alphabetic ordering of proposals */
public final static String ORDER_PROPOSALS= "content_assist_order_proposals"; //$NON-NLS-1$ public final static String ORDER_PROPOSALS= "content_assist_order_proposals"; //$NON-NLS-1$
// /** Preference key for case sensitivity of propsals */ // /** Preference key for case sensitivity of proposals */
// public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity"; // public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
// /** Preference key for adding includes on code assist (unused) */ // /** Preference key for adding includes on code assist (unused) */
// public final static String ADD_INCLUDE= "content_assist_add_import"; //$NON-NLS-1$ // public final static String ADD_INCLUDE= "content_assist_add_import"; //$NON-NLS-1$
@ -136,7 +135,7 @@ public class ContentAssistPreference {
boolean dotTriggersAutoReplace = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW); boolean dotTriggersAutoReplace = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
// quick and dirty, since we only have one thing to replace // Quick and dirty, since we only have one thing to replace
// if other replacement auto-activate triggers are added, // if other replacement auto-activate triggers are added,
// triggers will have to be cleared and characters that share // triggers will have to be cleared and characters that share
// such as "." will have to be ||ed together. // such as "." will have to be ||ed together.
@ -149,25 +148,20 @@ public class ContentAssistPreference {
triggers = "."; //$NON-NLS-1$ triggers = "."; //$NON-NLS-1$
ccp.setReplacementAutoActivationCharacters(triggers); ccp.setReplacementAutoActivationCharacters(triggers);
} }
/** /**
* Configure the given content assistant from the given store. * Configure the given content assistant from the given store.
*/ */
public static void configure(ContentAssistant assistant, IPreferenceStore store) { public static void configure(ContentAssistant assistant, IPreferenceStore store) {
CTextTools textTools= CUIPlugin.getDefault().getTextTools(); CTextTools textTools= CUIPlugin.getDefault().getTextTools();
IColorManager manager= textTools.getColorManager(); IColorManager manager= textTools.getColorManager();
boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT); boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW); boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON); boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
boolean enabledReplaceDotWithArrow boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
boolean enabled boolean enabled = (enabledDot || enabledArrow || enabledDoubleColon || enabledReplaceDotWithArrow);
= (enabledDot || enabledArrow || enabledDoubleColon
|| enabledReplaceDotWithArrow);
assistant.enableAutoActivation(enabled); assistant.enableAutoActivation(enabled);
int delay= store.getInt(AUTOACTIVATION_DELAY); int delay= store.getInt(AUTOACTIVATION_DELAY);
@ -196,16 +190,15 @@ public class ContentAssistPreference {
configureCProcessor(assistant, store); configureCProcessor(assistant, store);
} }
private static void changeCProcessor(ContentAssistant assistant, IPreferenceStore store, String key) { private static void changeCProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
CContentAssistProcessor ccp= getCProcessor(assistant); CContentAssistProcessor ccp= getCProcessor(assistant);
if (ccp == null) if (ccp == null)
return; return;
if ( (AUTOACTIVATION_TRIGGERS_DOT.equals(key)) if ((AUTOACTIVATION_TRIGGERS_DOT.equals(key))
|| (AUTOACTIVATION_TRIGGERS_ARROW.equals(key)) || (AUTOACTIVATION_TRIGGERS_ARROW.equals(key))
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key)) || (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key))
|| (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))){ || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))){
configureActivationCharacters(store, ccp); configureActivationCharacters(store, ccp);
} }
// else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) { // else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
@ -230,20 +223,18 @@ public class ContentAssistPreference {
* change event and the given preference store. * change event and the given preference store.
*/ */
public static void changeConfiguration(ContentAssistant assistant, IPreferenceStore store, PropertyChangeEvent event) { public static void changeConfiguration(ContentAssistant assistant, IPreferenceStore store, PropertyChangeEvent event) {
String p= event.getProperty(); String p= event.getProperty();
if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p)) if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
|| (AUTOACTIVATION_TRIGGERS_ARROW.equals(p)) || (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p)) || (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p))
|| (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(p))){ || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(p))){
boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT); boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW); boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON); boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW); boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ) || (enabledReplaceDotWithArrow )); boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ) || (enabledReplaceDotWithArrow ));
assistant.enableAutoActivation(enabled); assistant.enableAutoActivation(enabled);
} else if (AUTOACTIVATION_DELAY.equals(p)) { } else if (AUTOACTIVATION_DELAY.equals(p)) {
int delay= store.getInt(AUTOACTIVATION_DELAY); int delay= store.getInt(AUTOACTIVATION_DELAY);
assistant.setAutoActivationDelay(delay); assistant.setAutoActivationDelay(delay);
@ -275,20 +266,17 @@ public class ContentAssistPreference {
private static ContentAssistPreference instance = null; private static ContentAssistPreference instance = null;
private final IPropertyChangeListener propertyListener = new IPropertyChangeListener() { private final IPropertyChangeListener propertyListener = new IPropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent event) { public void propertyChange(PropertyChangeEvent event) {
String prop = event.getProperty(); String prop = event.getProperty();
if (prop.equals(ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES)) { if (prop.equals(ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES)) {
updateOnPreferences(); updateOnPreferences();
} }
} }
}; };
private ContentAssistPreference() { private ContentAssistPreference() {
getPreferences().addPropertyChangeListener( getPreferences().addPropertyChangeListener(propertyListener);
propertyListener);
updateOnPreferences(); updateOnPreferences();
} }
@ -313,9 +301,6 @@ public class ContentAssistPreference {
getPreferences().removePropertyChangeListener(propertyListener); getPreferences().removePropertyChangeListener(propertyListener);
} }
/**
* @noreference This method is not intended to be referenced by clients.
*/
public static synchronized void shutdown() { public static synchronized void shutdown() {
if (instance != null) { if (instance != null) {
instance.shutdownInternal(); instance.shutdownInternal();