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

Moved two previously hidden preferences to CCorePreferenceConstants.java and made them public.

This commit is contained in:
Sergey Prigogin 2009-11-11 20:34:00 +00:00
parent de4fdf198f
commit 717dfc08a6
5 changed files with 46 additions and 21 deletions

View file

@ -150,14 +150,6 @@ public class PDOMManager implements IWritableIndexManager, IListener {
ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID
};
/**
* Boolean preference controlling whether paths to non-workspace files are stored in canonical
* form or not.
*/
// TODO(sprigogin): Move to CPreferencesConstants and add UI support.
public static final String PREFERENCES_CONSTANT_PATH_CANONICALIZATION =
CCorePlugin.PLUGIN_ID + ".path_canonicalization"; //$NON-NLS-1$
/**
* Protects fIndexerJob, fCurrentTask and fTaskQueue.
*/
@ -283,7 +275,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
prop.equals(CCorePreferenceConstants.TODO_TASK_PRIORITIES) ||
prop.equals(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE)) {
reindexAll();
} else if (prop.equals(PREFERENCES_CONSTANT_PATH_CANONICALIZATION)) {
} else if (prop.equals(CCorePreferenceConstants.FILE_PATH_CANONICALIZATION)) {
updatePathCanonicalizationStrategy();
reindexAll();
}
@ -302,7 +294,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
private void updatePathCanonicalizationStrategy() {
IPreferencesService prefs = Platform.getPreferencesService();
boolean canonicalize = prefs.getBoolean(CCorePlugin.PLUGIN_ID, PREFERENCES_CONSTANT_PATH_CANONICALIZATION, true, null);
boolean canonicalize = prefs.getBoolean(CCorePlugin.PLUGIN_ID, CCorePreferenceConstants.FILE_PATH_CANONICALIZATION, true, null);
PathCanonicalizationStrategy.setPathCanonicalization(canonicalize);
}

View file

@ -120,7 +120,14 @@ public class CCorePreferenceConstants {
* Default absolute maximum size of the index-db in megabytes.
*/
public static final String DEFAULT_MAX_INDEX_DB_CACHE_SIZE_MB = "64"; //$NON-NLS-1$
/**
* Boolean preference controlling whether paths of non-workspace files are stored in index in canonical
* form or not. Canonicalization is performed by calling {@link java.io.File#getCanonicalPath()}.
* @since 5.2
*/
public static final String FILE_PATH_CANONICALIZATION = CCorePlugin.PLUGIN_ID + ".path_canonicalization"; //$NON-NLS-1$
/**
* Workspace-wide language mappings.
*/

View file

@ -518,7 +518,18 @@ public class DefaultCodeFormatterConstants {
public static final String FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_access_specifier_compare_to_type_header"; //$NON-NLS-1$
/**
* <pre>
* FORMATTER / Option to indent body declarations compare to access specifiers (visibility labels)
* FORMATTER / Number of extra spaces in front of 'public:', 'protected:', 'private:' access specifiers.
* Enables fractional indent of access specifiers. Does not affect indentation of body declarations.
* - option id: "org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces"
* - possible values: "&lt;n&gt;", where n is zero or a positive integer
* - default: "0"
* </pre>
* @since 5.2
*/
public static final String FORMATTER_INDENT_ACCESS_SPECIFIER_EXTRA_SPACES = CCorePlugin.PLUGIN_ID + ".formatter.indent_access_specifier_extra_spaces"; //$NON-NLS-1$
/**
* <pre>
* FORMATTER / Option to indent body declarations relative to access specifiers (visibility labels)
* - option id: "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier"
* - possible values: { TRUE, FALSE }
* - default: TRUE

View file

@ -7,7 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Sergey Prigogin, Google
* Sergey Prigogin (Google)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core;
@ -59,7 +59,8 @@ public class CCorePreferenceInitializer extends AbstractPreferenceInitializer {
defaultPreferences.putBoolean(CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true);
defaultPreferences.putBoolean(CCorePlugin.PREF_USE_STRUCTURAL_PARSE_MODE, false);
defaultPreferences.putBoolean(CCorePreferenceConstants.FILE_PATH_CANONICALIZATION, true);
// indexer defaults
IndexerPreferences.initializeDefaultPreferences(defaultPreferences);
}

View file

@ -12,9 +12,13 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@ -75,6 +79,8 @@ public final class CIndenter {
final boolean prefHasTemplates;
final String prefTabChar;
private final IPreferencesService preferenceService;
private final IScopeContext[] preferenceContexts;
private final ICProject fProject;
/**
@ -84,12 +90,22 @@ public final class CIndenter {
* @return the value of the preference
*/
private String getCoreFormatterOption(String key) {
if (fProject == null)
return CCorePlugin.getOption(key);
return fProject.getOption(key, true);
return getCoreFormatterOption(key, null);
}
private String getCoreFormatterOption(String key, String defaultValue) {
return preferenceService.getString(CCorePlugin.PLUGIN_ID, key, defaultValue, preferenceContexts);
}
private int getCoreFormatterOption(String key, int defaultValue) {
return preferenceService.getInt(CCorePlugin.PLUGIN_ID, key, defaultValue, preferenceContexts);
}
CorePrefs(ICProject project) {
preferenceService = Platform.getPreferencesService();
preferenceContexts = project != null ?
new IScopeContext[] { new ProjectScope(project.getProject()), new InstanceScope(), new DefaultScope() } :
new IScopeContext[] { new InstanceScope(), new DefaultScope() };
fProject= project;
prefUseTabs= prefUseTabs();
prefTabSize= prefTabSize();
@ -345,9 +361,7 @@ public final class CIndenter {
}
private int prefAccessSpecifierExtraSpaces() {
// Hidden option that enables fractional indent of access specifiers.
IPreferencesService prefs = Platform.getPreferencesService();
return prefs.getInt(CCorePlugin.PLUGIN_ID, CCorePlugin.PLUGIN_ID + ".formatter.indent_access_specifier_extra_spaces", 0, null); //$NON-NLS-1$
return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_EXTRA_SPACES, 0);
}
private int prefNamespaceBodyIndent() {