@Override public void apply(final IHiddenRegionFormatter it) { final ITypedPreferenceValues preferences = it.getRequest().getPreferences(); final Boolean newLine = preferences.<Boolean>getPreference(this); final Boolean preserve = preferences.<Boolean>getPreference(XbaseFormatterPreferenceKeys.preserveNewLines); int _xifexpression = (int) 0; if ((newLine).booleanValue()) { _xifexpression = 1; } else { _xifexpression = 0; } final int min = _xifexpression; int _xifexpression_1 = (int) 0; if (((preserve).booleanValue() || (newLine).booleanValue())) { _xifexpression_1 = 1; } else { _xifexpression_1 = 0; } final int max = _xifexpression_1; it.setNewLines(min, min, max); it.setSpace(" "); }
protected List<ITextReplacement> format2(final XtextResource resource, final ITextRegion selection, final ITypedPreferenceValues preferences) { final FormatterRequest request = this.formatterRequestProvider.get(); request.setAllowIdentityEdits(false); request.setFormatUndefinedHiddenRegionsOnly(false); if ((selection != null)) { request.setRegions(Collections.<ITextRegion>unmodifiableList(CollectionLiterals.<ITextRegion>newArrayList(selection))); } if ((preferences != null)) { request.setPreferences(preferences); } final ITextRegionAccess regionAccess = this.regionBuilder.forNodeModel(resource).create(); request.setTextRegionAccess(regionAccess); final IFormatter2 formatter2 = this.formatter2Provider.get(); final List<ITextReplacement> replacements = formatter2.format(request); return replacements; }
@Override public void apply(final IHiddenRegionFormatter it) { final ITypedPreferenceValues preferences = it.getRequest().getPreferences(); final Integer blankline = preferences.<Integer>getPreference(this); final Integer preserve = preferences.<Integer>getPreference(XbaseFormatterPreferenceKeys.preserveBlankLines); final int min = ((blankline).intValue() + 1); final int max = Math.max(((preserve).intValue() + 1), min); it.setNewLines(min, min, max); }
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; }
/** * @see #preferences */ public FormatterRequest setPreferences(ITypedPreferenceValues preferenceValues) { this.preferences = preferenceValues; return this; }
/** * @see #preferences */ public ITypedPreferenceValues getPreferences() { if (preferences == null) preferences = new MapBasedPreferenceValues(Maps.<String, String> newLinkedHashMap()); return preferences; }
public ITypedPreferenceValues getPreferences() { return getFormatter().getPreferences(); }
/** * @return the preferences from the {@link FormatterRequest} */ public ITypedPreferenceValues getPreferences() { return request.getPreferences(); }