Java Code Examples for org.eclipse.xtext.formatting2.IHiddenRegionFormatter#oneSpace()

The following examples show how to use org.eclipse.xtext.formatting2.IHiddenRegionFormatter#oneSpace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewLineKey.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void apply(IHiddenRegionFormatter formatter) {
	Boolean newLine = formatter.getRequest().getPreferences().getPreference(this);
	if (newLine.booleanValue()) {
		formatter.setNewLines(1);
	} else {
		formatter.oneSpace();
	}
}
 
Example 2
Source File: XbaseFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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());
}
 
Example 3
Source File: XbaseFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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());
}
 
Example 4
Source File: XbaseFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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());
}
 
Example 5
Source File: XbaseFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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());
}
 
Example 6
Source File: XbaseFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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());
}
 
Example 7
Source File: XtypeFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 8
Source File: XtypeFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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);
    }
  }
}
 
Example 9
Source File: XtendFormatter.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void _format(final XtendAnnotationType annotationType, @Extension final IFormattableDocument format) {
  this.formatAnnotations(annotationType, format, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
  this.formatModifiers(annotationType, format);
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  format.append(this.textRegionExtensions.regionFor(annotationType).keyword("annotation"), _function);
  this.formatBody(annotationType, format);
}
 
Example 10
Source File: XtendFormatter.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void _format(final XVariableDeclaration expr, @Extension final IFormattableDocument format) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  format.append(this.textRegionExtensions.regionFor(expr).keyword("extension"), _function);
  super._format(expr, format);
}
 
Example 11
Source File: XtendFormatter.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void _format(final JvmFormalParameter expr, @Extension final IFormattableDocument format) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.oneSpace();
  };
  format.append(this.textRegionExtensions.regionFor(expr).keyword("extension"), _function);
  super._format(expr, format);
}
 
Example 12
Source File: XtendFormatter.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Always put existing modifiers into this fixed order
 */
protected void formatModifiers(final XtendMember member, @Extension final IFormattableDocument document) {
  final Consumer<ISemanticRegion> _function = (ISemanticRegion it) -> {
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
      it_1.oneSpace();
    };
    document.append(it, _function_1);
  };
  this.textRegionExtensions.regionFor(member).ruleCallsTo(this._xtendGrammarAccess.getCommonModifierRule(), this._xtendGrammarAccess.getMethodModifierRule(), this._xtendGrammarAccess.getFieldModifierRule()).forEach(_function);
}
 
Example 13
Source File: XbaseFormatter.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
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));
}