Java 类org.eclipse.xtext.formatting2.IHiddenRegionFormatter 实例源码

项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final XCollectionLiteral literal, @Extension final IFormattableDocument document) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.noSpace();
  };
  document.append(this.textRegionExtensions.regionFor(literal).keyword("#"), _function);
  ISemanticRegion _elvis = null;
  ISemanticRegion _keyword = this.textRegionExtensions.regionFor(literal).keyword("[");
  if (_keyword != null) {
    _elvis = _keyword;
  } else {
    ISemanticRegion _keyword_1 = this.textRegionExtensions.regionFor(literal).keyword("{");
    _elvis = _keyword_1;
  }
  final ISemanticRegion open = _elvis;
  ISemanticRegion _elvis_1 = null;
  ISemanticRegion _keyword_2 = this.textRegionExtensions.regionFor(literal).keyword("]");
  if (_keyword_2 != null) {
    _elvis_1 = _keyword_2;
  } else {
    ISemanticRegion _keyword_3 = this.textRegionExtensions.regionFor(literal).keyword("}");
    _elvis_1 = _keyword_3;
  }
  final ISemanticRegion close = _elvis_1;
  this.formatCommaSeparatedList(literal.getElements(), open, close, document);
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final XFeatureCall expr, @Extension final IFormattableDocument format) {
  this.formatFeatureCallTypeParameters(expr, format);
  boolean _isExplicitOperationCall = expr.isExplicitOperationCall();
  if (_isExplicitOperationCall) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final ISemanticRegion open = format.prepend(this.textRegionExtensions.regionFor(expr).keyword(this.grammar.getXFeatureCallAccess().getExplicitOperationCallLeftParenthesisKeyword_3_0_0()), _function);
    final ISemanticRegion close = this.textRegionExtensions.regionFor(expr).keyword(this.grammar.getXFeatureCallAccess().getRightParenthesisKeyword_3_2());
    this.formatFeatureCallParams(expr.getFeatureCallArguments(), open, close, format);
  } else {
    EList<XExpression> _featureCallArguments = expr.getFeatureCallArguments();
    for (final XExpression arg : _featureCallArguments) {
      this.format(arg, format);
    }
  }
}
项目: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-extras    文件:IndentOnceAutowrapFormatter.java   
@Override
public void format(final ITextSegment region, final IHiddenRegionFormatting wrapped, @Extension final IFormattableDocument document) {
  if ((!this.hasWrapped)) {
    IHiddenRegion _switchResult = null;
    boolean _matched = false;
    if (region instanceof IHiddenRegion) {
      _matched=true;
      _switchResult = ((IHiddenRegion)region);
    }
    if (!_matched) {
      if (region instanceof IHiddenRegionPart) {
        _matched=true;
        _switchResult = ((IHiddenRegionPart)region).getHiddenRegion();
      }
    }
    final IHiddenRegion hiddenRegion = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.set(hiddenRegion, this.last, _function);
    this.hasWrapped = true;
  }
}
项目:OCCI-Studio    文件:OCCIFormatter.java   
protected void _format(final AttributeState attributeState, @Extension final IFormattableDocument document) {
  final ISemanticRegion kvalue = this.textRegionExtensions.regionFor(attributeState).feature(OCCIPackage.Literals.ATTRIBUTE_STATE__VALUE);
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.setNewLines(1);
  };
  document.append(kvalue, _function);
}
项目:xtext-extras    文件:PureXbaseFormatter.java   
@Override
protected void _format(final XBlockExpression xBlockExpression, @Extension final IFormattableDocument document) {
  final Consumer<ISemanticRegion> _function = (ISemanticRegion it) -> {
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
      it_1.newLine();
    };
    document.append(it, _function_1);
  };
  this.textRegionExtensions.regionFor(xBlockExpression).keywords(this._pureXbaseGrammarAccess.getSpecialBlockExpressionAccess().getSemicolonKeyword_1_1()).forEach(_function);
  EList<XExpression> _expressions = xBlockExpression.getExpressions();
  for (final XExpression xExpression : _expressions) {
    document.<XExpression>format(xExpression);
  }
}
项目:xtext-extras    文件:NewLineKey.java   
@Override
public void apply(final IHiddenRegionFormatter it) {
  final Boolean newLine = it.getRequest().getPreferences().<Boolean>getPreference(this);
  if ((newLine).booleanValue()) {
    it.setNewLines(1);
  } else {
    it.oneSpace();
  }
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final XThrowExpression expr, @Extension final IFormattableDocument format) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  format.<XExpression>prepend(expr.getExpression(), _function);
  format.<XExpression>format(expr.getExpression());
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final XReturnExpression expr, @Extension final IFormattableDocument format) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  format.<XExpression>prepend(expr.getExpression(), _function);
  format.<XExpression>format(expr.getExpression());
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final JvmFormalParameter expr, @Extension final IFormattableDocument format) {
  JvmTypeReference _parameterType = expr.getParameterType();
  if (_parameterType!=null) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    format.<JvmTypeReference>append(_parameterType, _function);
  }
  format.<JvmTypeReference>format(expr.getParameterType());
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final XInstanceOfExpression expr, @Extension final IFormattableDocument doc) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  doc.surround(this.textRegionExtensions.regionFor(expr).keyword("instanceof"), _function);
  doc.<XExpression>format(expr.getExpression());
  doc.<JvmTypeReference>format(expr.getType());
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final XCastedExpression expr, @Extension final IFormattableDocument doc) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  doc.surround(this.textRegionExtensions.regionFor(expr).keyword("as"), _function);
  doc.<XExpression>format(expr.getTarget());
  doc.<JvmTypeReference>format(expr.getType());
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final XPostfixOperation expr, @Extension final IFormattableDocument doc) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.noSpace();
  };
  doc.prepend(this.textRegionExtensions.regionFor(expr).feature(XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE), _function);
  doc.<XExpression>format(expr.getOperand());
}
项目:xtext-extras    文件:WhitespaceKey.java   
@Override
public void apply(final IHiddenRegionFormatter it) {
  final Boolean space = it.getRequest().getPreferences().<Boolean>getPreference(this);
  String _xifexpression = null;
  if ((space).booleanValue()) {
    _xifexpression = " ";
  } else {
    _xifexpression = "";
  }
  it.setSpace(_xifexpression);
}
项目:xtext-extras    文件:XtypeFormatter.java   
protected void _format(final JvmWildcardTypeReference ref, @Extension final IFormattableDocument document) {
  boolean _isEmpty = ref.getConstraints().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(ref).keyword("?"), _function);
  }
  EList<JvmTypeConstraint> _constraints = ref.getConstraints();
  for (final JvmTypeConstraint c : _constraints) {
    document.<JvmTypeConstraint>format(c);
  }
}
项目:xtext-extras    文件:XtypeFormatter.java   
protected void _format(final JvmTypeParameter ref, @Extension final IFormattableDocument document) {
  EList<JvmTypeConstraint> _constraints = ref.getConstraints();
  for (final JvmTypeConstraint c : _constraints) {
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<JvmTypeConstraint>prepend(c, _function);
      document.<JvmTypeConstraint>format(c);
    }
  }
}
项目: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    文件:FormattableDocument.java   
@Override
public ISemanticRegion append(ISemanticRegion token, Procedure1<? super IHiddenRegionFormatter> after) {
    if (token != null) {
        IHiddenRegion gap = token.getNextHiddenRegion();
        set(gap, after);
    }
    return token;
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public <T extends EObject> T append(T owner, Procedure1<? super IHiddenRegionFormatter> after) {
    if (owner != null) {
        IEObjectRegion region = getTextRegionAccess().regionForEObject(owner);
        if (region != null) {
            IHiddenRegion gap = region.getNextHiddenRegion();
            set(gap, after);
        }
    }
    return owner;
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public <T extends EObject> T interior(T object, Procedure1<? super IHiddenRegionFormatter> init) {
    if (object != null) {
        IEObjectRegion objRegion = getTextRegionAccess().regionForEObject(object);
        if (objRegion != null) {
            IHiddenRegion previous = objRegion.getPreviousHiddenRegion();
            IHiddenRegion next = objRegion.getNextHiddenRegion();
            if (previous != null && next != null && previous != next) {
                interior(previous.getNextSemanticRegion(), next.getPreviousSemanticRegion(), init);
            }
        }
    }
    return object;
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public <T1 extends ISemanticRegion, T2 extends ISemanticRegion> //
Pair<T1, T2> interior(T1 first, T2 second, Procedure1<? super IHiddenRegionFormatter> init) {
    if (first != null && second != null) {
        set(first.getNextHiddenRegion(), second.getPreviousHiddenRegion(), init);
    }
    return Pair.of(first, second);
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public ISemanticRegion prepend(ISemanticRegion token, Procedure1<? super IHiddenRegionFormatter> before) {
    if (token != null) {
        IHiddenRegion gap = token.getPreviousHiddenRegion();
        set(gap, before);
    }
    return token;
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public <T extends EObject> T prepend(T owner, Procedure1<? super IHiddenRegionFormatter> before) {
    if (owner != null) {
        IEObjectRegion region = getTextRegionAccess().regionForEObject(owner);
        if (region != null) {
            IHiddenRegion gap = region.getPreviousHiddenRegion();
            set(gap, before);
        }
    }
    return owner;
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public Pair<IHiddenRegion, IHiddenRegion> set(IHiddenRegion first, IHiddenRegion second,
        Procedure1<? super IHiddenRegionFormatter> init) {
    if (first != null && second != null) {
        AbstractFormatter2 formatter = getFormatter();
        IHiddenRegionFormatting f1 = formatter.createHiddenRegionFormatting();
        IHiddenRegionFormatting f2 = formatter.createHiddenRegionFormatting();
        init.apply(formatter.createHiddenRegionFormatter(f1, f2));
        ITextReplacer replacer1 = formatter.createHiddenRegionReplacer(first, f1);
        ITextReplacer replacer2 = formatter.createHiddenRegionReplacer(second, f2);
        addReplacer(replacer1);
        addReplacer(replacer2);
    }
    return Pair.of(first, second);
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public IHiddenRegion set(IHiddenRegion hiddenRegion, Procedure1<? super IHiddenRegionFormatter> init) {
    if (hiddenRegion != null) {
        AbstractFormatter2 formatter = getFormatter();
        IHiddenRegionFormatting formatting = formatter.createHiddenRegionFormatting();
        init.apply(formatter.createHiddenRegionFormatter(formatting));
        ITextReplacer replacer = formatter.createHiddenRegionReplacer(hiddenRegion, formatting);
        addReplacer(replacer);
    }
    return hiddenRegion;
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public ISemanticRegion surround(ISemanticRegion token, Procedure1<? super IHiddenRegionFormatter> beforeAndAfter) {
    if (token != null) {
        IHiddenRegion previous = token.getPreviousHiddenRegion();
        IHiddenRegion next = token.getNextHiddenRegion();
        set(previous, next, beforeAndAfter);
    }
    return token;
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public <T extends EObject> T surround(T owner, Procedure1<? super IHiddenRegionFormatter> beforeAndAfter) {
    if (owner != null && !owner.eIsProxy()) {
        IEObjectRegion region = getTextRegionAccess().regionForEObject(owner);
        if (region == null)
            return owner;
        IHiddenRegion previous = region.getPreviousHiddenRegion();
        IHiddenRegion next = region.getNextHiddenRegion();
        set(previous, next, beforeAndAfter);
    }
    return owner;
}
项目:xtext-gef    文件:StatemachineFormatter.java   
protected void _format(final StatePropertyExpression expression, @Extension final IFormattableDocument document) {
  ISemanticRegionsFinder _regionFor = this.textRegionExtensions.regionFor(expression);
  ISemanticRegion _keyword = _regionFor.keyword(".");
  final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
    @Override
    public void apply(final IHiddenRegionFormatter it) {
      it.noSpace();
    }
  };
  document.surround(_keyword, _function);
}
项目:xtext-extras    文件:XbaseFormatter.java   
protected void _format(final JvmTypeConstraint constraint, @Extension final IFormattableDocument document) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  document.<JvmTypeReference>format(document.<JvmTypeReference>prepend(constraint.getTypeReference(), _function));
}
项目:xtext-core    文件:FormattableDocument.java   
@Override
public <T1 extends ISemanticRegion, T2 extends ISemanticRegion> //
Pair<T1, T2> interior(Pair<T1, T2> pair, Procedure1<? super IHiddenRegionFormatter> init) {
    return interior(pair.getKey(), pair.getValue(), init);
}
项目:xtext-core    文件:TestLanguageFormatter.java   
protected void _format(final Property property, @Extension final IFormattableDocument document) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.newLine();
  };
  document.<Property>append(property, _function);
}
项目:xtext-core    文件:FormatterSerializerIntegrationTest.java   
protected void _format(final IDList model, @Extension final IFormattableDocument document) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.setSpace("  ");
  };
  document.append(this.textRegionExtensions.regionFor(model).keyword("idlist"), _function);
}