Java 类org.eclipse.xtext.preferences.ITypedPreferenceValues 实例源码

项目:xtext-extras    文件:NewLineOrPreserveKey.java   
@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(" ");
}
项目:xtext-core    文件:FormattingService.java   
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;
}
项目:xtext-extras    文件:BlankLineKey.java   
@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);
}
项目:xtext-core    文件:FormatterTestRequest.java   
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;
}
项目:xtext-core    文件:FormatterRequest.java   
/**
 * @see #preferences
 */
public FormatterRequest setPreferences(ITypedPreferenceValues preferenceValues) {
    this.preferences = preferenceValues;
    return this;
}
项目:xtext-core    文件:FormatterRequest.java   
/**
 * @see #preferences
 */
public ITypedPreferenceValues getPreferences() {
    if (preferences == null)
        preferences = new MapBasedPreferenceValues(Maps.<String, String> newLinkedHashMap());
    return preferences;
}
项目:xtext-core    文件:FormattableDocument.java   
public ITypedPreferenceValues getPreferences() {
    return getFormatter().getPreferences();
}
项目:xtext-core    文件:AbstractFormatter2.java   
/**
 * @return the preferences from the {@link FormatterRequest}
 */
public ITypedPreferenceValues getPreferences() {
    return request.getPreferences();
}