use of org.eclipse.xtext.preferences.ITypedPreferenceValues in project xtext-core by eclipse.
the class FormatterTestRequest method getOrCreateMapBasedPreferences.
public MapBasedPreferenceValues getOrCreateMapBasedPreferences() {
ITypedPreferenceValues preferences = request.getPreferences();
if (preferences instanceof MapBasedPreferenceValues)
return (MapBasedPreferenceValues) preferences;
LinkedHashMap<String, String> newMap = Maps.<String, String>newLinkedHashMap();
MapBasedPreferenceValues result = new MapBasedPreferenceValues(preferences, newMap);
request.setPreferences(result);
return result;
}
use of org.eclipse.xtext.preferences.ITypedPreferenceValues in project xtext-core by eclipse.
the class TextReplacerContext method logicalLength.
protected int logicalLength(String text) {
ITypedPreferenceValues preferences = getDocument().getRequest().getPreferences();
String indentation = preferences.getPreference(FormatterPreferenceKeys.indentation);
if (!"\t".equals(indentation))
return text.length();
@SuppressWarnings("deprecation") int tabWidth = preferences.getPreference(FormatterPreferenceKeys.indentationLength);
if (tabWidth < 0) {
tabWidth = preferences.getPreference(FormatterPreferenceKeys.tabWidth);
}
int length = 0;
for (int i = 0; i < text.length(); i++) if (text.charAt(i) == '\t')
length += tabWidth;
else
length++;
return length;
}
Aggregations