mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[xtext] Fixed endless recursion and missing writer.flush() in Serializer,
renamed FormatterRequest.formatUndenfinedTokensOnly => formatUndefinedHiddenRegionsOnly Signed-off-by: Miro Spönemann <miro.spoenemann@itemis.de>
This commit is contained in:
parent
8ee759d365
commit
e05160a685
2 changed files with 10 additions and 9 deletions
|
@ -32,7 +32,7 @@ import com.google.common.collect.Maps;
|
|||
* <li>{@link #preferences Preferences} with keys from e.g. {@link FormatterPreferenceKeys}.</li>
|
||||
* <li>{@link #regions} that describe how to restrict the text regions for which {@link ITextReplacement replacements} are produced.</li>
|
||||
* <li>An option to {@link #allowIdentityEdits()} which will disable automated suppression of text replacements that do not cause changes.</li>
|
||||
* <li>A setting for green-field formatting ({@link #formatUndenfinedTokensOnly}): only format regions that have no whitespace information yet.</li>
|
||||
* <li>A setting for green-field formatting ({@link #formatUndefinedHiddenRegionsOnly}): only format regions that have no whitespace information yet.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ITextReplacement> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue