Java Code Examples for org.eclipse.xtext.formatting2.IFormattableDocument#format()
The following examples show how to use
org.eclipse.xtext.formatting2.IFormattableDocument#format() .
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: BeeLangTestLanguageFormatter.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected void _format(final Unit unit, @Extension final IFormattableDocument document) { EList<SimpleTypeRef> _implements = unit.getImplements(); for (final SimpleTypeRef simpleTypeRef : _implements) { document.<SimpleTypeRef>format(simpleTypeRef); } EList<ProvidedCapability> _providedCapabilities = unit.getProvidedCapabilities(); for (final ProvidedCapability providedCapability : _providedCapabilities) { document.<ProvidedCapability>format(providedCapability); } EList<AliasedRequiredCapability> _requiredCapabilities = unit.getRequiredCapabilities(); for (final AliasedRequiredCapability aliasedRequiredCapability : _requiredCapabilities) { document.<AliasedRequiredCapability>format(aliasedRequiredCapability); } EList<RequiredCapability> _metaRequiredCapabilities = unit.getMetaRequiredCapabilities(); for (final RequiredCapability requiredCapability : _metaRequiredCapabilities) { document.<RequiredCapability>format(requiredCapability); } EList<Function> _functions = unit.getFunctions(); for (final Function function : _functions) { document.<Function>format(function); } }
Example 2
Source File: SARLFormatter.java From sarl with Apache License 2.0 | 6 votes |
@Override protected void _format(XForLoopExpression expr, IFormattableDocument document) { final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(expr); document.append(regionFor.keyword(this.keywords.getForKeyword()), ONE_SPACE); final JvmFormalParameter declaredParam = expr.getDeclaredParam(); document.prepend(declaredParam, NO_SPACE); document.append(declaredParam, ONE_SPACE); document.format(declaredParam); final XExpression forExpression = expr.getForExpression(); document.prepend(forExpression, ONE_SPACE); document.append(forExpression, NO_SPACE); document.format(forExpression); final XExpression eachExpression = expr.getEachExpression(); if (eachExpression != null) { formatBody(eachExpression, true, document); } else { document.prepend(regionFor.keyword(this.keywords.getSemicolonKeyword()), NO_SPACE); } }
Example 3
Source File: SARLFormatter.java From sarl with Apache License 2.0 | 6 votes |
@Override protected void _format(XtendField field, IFormattableDocument document) { formatAnnotations(field, document, XbaseFormatterPreferenceKeys.newLineAfterFieldAnnotations); formatModifiers(field, document); final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(field); final ISemanticRegion columnKw = regionFor.keyword(this.keywords.getColonKeyword()); document.prepend(columnKw, ONE_SPACE); document.append(columnKw, ONE_SPACE); final ISemanticRegion equalKw = regionFor.keyword(this.keywords.getEqualsSignKeyword()); document.prepend(equalKw, ONE_SPACE); document.append(equalKw, ONE_SPACE); final ISemanticRegion semicolumn = regionFor.keyword(this.keywords.getSemicolonKeyword()); document.prepend(semicolumn, NO_SPACE); final JvmTypeReference type = field.getType(); document.format(type); final XExpression initialValue = field.getInitialValue(); document.format(initialValue); }
Example 4
Source File: XbaseFormatter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
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()); }
Example 5
Source File: BeeLangTestLanguageFormatter.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void _format(final Model model, @Extension final IFormattableDocument document) { EList<Unit> _units = model.getUnits(); for (final Unit unit : _units) { document.<Unit>format(unit); } EList<Function> _functions = model.getFunctions(); for (final Function function : _functions) { document.<Function>format(function); } }
Example 6
Source File: XtendFormatter.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void formatAnnotations(final XtendAnnotationTarget target, @Extension final IFormattableDocument document, final Procedure1<? super IHiddenRegionFormatter> configKey) { boolean _isEmpty = target.getAnnotations().isEmpty(); if (_isEmpty) { return; } EList<XAnnotation> _annotations = target.getAnnotations(); for (final XAnnotation a : _annotations) { { document.<XAnnotation>format(a); document.<XAnnotation>append(a, configKey); } } }
Example 7
Source File: DomainmodelFormatter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void _format(final Property property, @Extension final IFormattableDocument document) { final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> { it.noSpace(); }; document.surround(this.textRegionExtensions.regionFor(property).keyword(":"), _function); document.<JvmTypeReference>format(property.getType()); }
Example 8
Source File: XtypeFormatter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void _format(final XImportSection section, @Extension final IFormattableDocument format) { EList<XImportDeclaration> _importDeclarations = section.getImportDeclarations(); for (final XImportDeclaration imp : _importDeclarations) { { format.<XImportDeclaration>format(imp); XImportDeclaration _last = IterableExtensions.<XImportDeclaration>last(section.getImportDeclarations()); boolean _notEquals = (!Objects.equal(imp, _last)); if (_notEquals) { format.<XImportDeclaration>append(imp, XbaseFormatterPreferenceKeys.blankLinesBetweenImports); } else { format.<XImportDeclaration>append(imp, XbaseFormatterPreferenceKeys.blankLinesAfterImports); } } } }
Example 9
Source File: XtypeFormatter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
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 10
Source File: SARLFormatter.java From sarl with Apache License 2.0 | 5 votes |
@Override protected void _format(XVariableDeclaration expr, IFormattableDocument document) { final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(expr); document.append(regionFor.keyword(this.keywords.getExtensionExtensionKeyword()), ONE_SPACE); document.append(regionFor.keyword(this.keywords.getValKeyword()), ONE_SPACE); document.append(regionFor.keyword(this.keywords.getWriteableVarKeyword()), ONE_SPACE); document.surround(regionFor.keyword(this.keywords.getColonKeyword()), ONE_SPACE); document.surround(regionFor.keyword(this.keywords.getEqualsSignKeyword()), ONE_SPACE); document.format(expr.getType()); document.format(expr.getRight()); }
Example 11
Source File: XbaseFormatter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
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 12
Source File: SARLFormatter.java From sarl with Apache License 2.0 | 5 votes |
/** Format the given SARL event. * * @param event the SARL component. * @param document the document. */ protected void _format(SarlEvent event, IFormattableDocument document) { formatAnnotations(event, document, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations); formatModifiers(event, document); final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(event); document.append(regionFor.keyword(this.keywords.getEventKeyword()), ONE_SPACE); document.surround(regionFor.keyword(this.keywords.getExtendsKeyword()), ONE_SPACE); document.format(event.getExtends()); formatBody(event, document); }
Example 13
Source File: XbaseFormatter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
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 14
Source File: XbaseFormatter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void _format(final JvmGenericArrayTypeReference array, @Extension final IFormattableDocument document) { List<ISemanticRegion> _ruleCallsTo = this.textRegionExtensions.regionFor(array).ruleCallsTo(this.grammar.getArrayBracketsRule()); for (final ISemanticRegion region : _ruleCallsTo) { ArrayBracketsFormattingReplacer _arrayBracketsFormattingReplacer = new ArrayBracketsFormattingReplacer(region); document.addReplacer(_arrayBracketsFormattingReplacer); } document.<JvmTypeReference>format(array.getComponentType()); }
Example 15
Source File: PureXbaseFormatter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@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); } }
Example 16
Source File: NoJdtTestLanguageFormatter.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected void _format(final Model model, @Extension final IFormattableDocument document) { EList<Greeting> _greetings = model.getGreetings(); for (final Greeting greeting : _greetings) { document.<Greeting>format(greeting); } }
Example 17
Source File: PureXbaseFormatter.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected void _format(final Model model, @Extension final IFormattableDocument document) { document.<XImportSection>format(model.getImportSection()); document.<XBlockExpression>format(model.getBlock()); }
Example 18
Source File: XbaseFormatter.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
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)); }
Example 19
Source File: TestLanguageFormatter.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected void _format(final Model model, @Extension final IFormattableDocument document) { EList<AbstractElement> _elements = model.getElements(); for (final AbstractElement type : _elements) { document.<AbstractElement>format(type); } }
Example 20
Source File: FileAwareTestLanguageFormatter.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected void _format(final Element element, @Extension final IFormattableDocument document) { EList<Element> _contents = element.getContents(); for (final Element _element : _contents) { document.<Element>format(_element); } }