use of org.eclipse.xtext.preferences.IPreferenceValues in project n4js by eclipse.
the class N4JSPreferenceAccess method getPreference.
/**
* @param resource
* the current resource, this will be used to calculate the preference store to access (e.g. if there are
* project specific preferences configured).
* @param compilerID
* the compiler id
* @param compilerProperty
* the compiler property to ask for
* @param defaultDescriptor
* the descriptor containing the default values to be used as fall back if there isn't a value in the
* preference store
* @return the preference value found in the preference store or any other values provider or the default value out
* of the default descriptor
*/
public String getPreference(Resource resource, String compilerID, CompilerProperties compilerProperty, CompilerDescriptor defaultDescriptor) {
IPreferenceValues preferences = valuesProvider.getPreferenceValues(resource);
PreferenceKey key = new PreferenceKey(compilerProperty.getKey(compilerID), String.valueOf(compilerProperty.getValueInCompilerDescriptor(defaultDescriptor, compilerID)));
return preferences.getPreference(key);
}
use of org.eclipse.xtext.preferences.IPreferenceValues in project xtext-core by eclipse.
the class FormatterPreferenceValuesProvider method getPreferenceValues.
@Override
public IPreferenceValues getPreferenceValues(final Resource resource) {
final IPreferenceValues preferenceValues = internalGetRawPreferenceValues(resource);
final String indent = whitespaceInfo.getIndentationInformation(resource.getURI()).getIndentString();
final String lineSep = whitespaceInfo.getLineSeparatorInformation(resource.getURI()).getLineSeparator();
return new IPreferenceValues() {
@Override
public String getPreference(PreferenceKey key) {
if (key == FormatterPreferenceKeys.indentation) {
return indent;
}
if (key == FormatterPreferenceKeys.lineSeparator) {
return lineSep;
}
return preferenceValues.getPreference(key);
}
};
}
Aggregations