// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.formatter;

import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;

/**
 * @author Max Medvedev
 */
public class FormattingContext {
  private final CommonCodeStyleSettings mySettings;
  private final GroovyCodeStyleSettings myGroovySettings;
  private final AlignmentProvider myAlignmentProvider;

  private final boolean myForbidWrapping;
  private final boolean myForbidNewLineInSpacing;

  public FormattingContext(@NotNull CommonCodeStyleSettings settings,
                           @NotNull AlignmentProvider provider,
                           @NotNull GroovyCodeStyleSettings groovySettings,
                           boolean forbidWrapping,
                           boolean forbidNewLineInSpacing) {
    mySettings = settings;
    myAlignmentProvider = provider;
    myGroovySettings = groovySettings;
    this.myForbidWrapping = forbidWrapping;
    this.myForbidNewLineInSpacing = forbidNewLineInSpacing;
  }

  public CommonCodeStyleSettings getSettings() {
    return mySettings;
  }

  public AlignmentProvider getAlignmentProvider() {
    return myAlignmentProvider;
  }

  public GroovyCodeStyleSettings getGroovySettings() {
    return myGroovySettings;
  }

  public FormattingContext createContext(boolean forbidWrapping, boolean forbidNewLineInSpacing) {
    return new FormattingContext(
      mySettings,
      myAlignmentProvider,
      myGroovySettings,
      myForbidWrapping || forbidWrapping,
      myForbidNewLineInSpacing || forbidNewLineInSpacing
    );
  }

  public boolean isForbidWrapping() {
    return myForbidWrapping;
  }

  public boolean isForbidNewLineInSpacing() {
    return myForbidNewLineInSpacing;
  }
}

@@ -1205,32 +1205,369 @@
 InSpacing;%0A  %7D%0A%0A
+  public FormattingContext(@NotNull CommonCodeStyleSettings settings,%0A                           @NotNull AlignmentProvider provider,%0A                           @NotNull GroovyCodeStyleSettings groovySettings,%0A                           boolean forbidWrapping) %7B%0A    this(settings, provider, groovySettings, forbidWrapping, false);%0A  %7D%0A%0A
   public CommonC

Add constructor for API compatibility