diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/formatting2/FormatterRequest.java b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/formatting2/FormatterRequest.java index 84eef179b..2c09185ea 100644 --- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/formatting2/FormatterRequest.java +++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/formatting2/FormatterRequest.java @@ -32,7 +32,7 @@ import com.google.common.collect.Maps; *
  • {@link #preferences Preferences} with keys from e.g. {@link FormatterPreferenceKeys}.
  • *
  • {@link #regions} that describe how to restrict the text regions for which {@link ITextReplacement replacements} are produced.
  • *
  • An option to {@link #allowIdentityEdits()} which will disable automated suppression of text replacements that do not cause changes.
  • - *
  • A setting for green-field formatting ({@link #formatUndenfinedTokensOnly}): only format regions that have no whitespace information yet.
  • + *
  • A setting for green-field formatting ({@link #formatUndefinedHiddenRegionsOnly}): only format regions that have no whitespace information yet.
  • * * * @author Moritz Eysholdt - Initial contribution and API @@ -145,20 +145,20 @@ public class FormatterRequest { * Enable this options if, for example, you serialize a model after applying a quick fix, refactoring or have it * edited in a graphical editor and you want to keep the whitespace-changes to a minimum. */ - private boolean formatUndenfinedTokensOnly; + private boolean formatUndefinedHiddenRegionsOnly; /** - * @see #formatUndenfinedTokensOnly + * @see #formatUndefinedHiddenRegionsOnly */ public boolean isFormatUndefinedHiddenRegionsOnly() { - return formatUndenfinedTokensOnly; + return formatUndefinedHiddenRegionsOnly; } /** - * @see #formatUndenfinedTokensOnly + * @see #formatUndefinedHiddenRegionsOnly */ - public FormatterRequest setFormatUndenfinedTokensOnly(boolean formatUndenfinedTokensOnly) { - this.formatUndenfinedTokensOnly = formatUndenfinedTokensOnly; + public FormatterRequest setFormatUndefinedHiddenRegionsOnly(boolean formatUndefinedHiddenRegionsOnly) { + this.formatUndefinedHiddenRegionsOnly = formatUndefinedHiddenRegionsOnly; return this; } diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/serializer/impl/Serializer.java b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/serializer/impl/Serializer.java index 6be5ee38c..97f642b18 100644 --- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/serializer/impl/Serializer.java +++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/serializer/impl/Serializer.java @@ -137,7 +137,7 @@ public class Serializer implements ISerializer { protected void serialize(EObject obj, Appendable appendable, SaveOptions options) throws IOException { ITextRegionAccess regionAccess = serializeToRegions(obj); FormatterRequest request = formatterRequestProvider.get(); - request.setFormatUndenfinedTokensOnly(!options.isFormatting()); + request.setFormatUndefinedHiddenRegionsOnly(!options.isFormatting()); request.setTextRegionAccess(regionAccess); IFormatter2 formatter2 = formatter2Provider.get(); List replacements = formatter2.format(request); @@ -171,7 +171,8 @@ public class Serializer implements ISerializer { @Override public void serialize(EObject obj, Writer writer, SaveOptions options) throws IOException { if (formatter2Provider != null) { - serialize(obj, writer, options); + serialize(obj, (Appendable) writer, options); + writer.flush(); } else { serialize(obj, new WriterTokenStream(writer), options); }