/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jetbrains.python.refactoring.changeSignature;

import com.intellij.refactoring.changeSignature.ParameterInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * User : ktisha
 */

public class PyParameterInfo implements ParameterInfo {

  private final int myOldIndex;
  private String myName = "";
  private String myOldName = "";
  private String myDefaultValue = null;
  private boolean myDefaultInSignature = false;

  public PyParameterInfo(int index) {
    myOldIndex = index;
  }

  public PyParameterInfo(int oldIndex, String name, @Nullable String defaultValue, boolean defaultInSignature) {
    myOldIndex = oldIndex;
    myName = name;
    myOldName = name;
    myDefaultValue = defaultValue;
    myDefaultInSignature = defaultInSignature;
  }

  @NotNull
  @Override
  public String getName() {
    return myName;
  }

  @NotNull
  public String getOldName() {
    return myOldName;
  }

  @Override
  public int getOldIndex() {
    return myOldIndex;
  }

  @Nullable
  @Override
  public String getDefaultValue() {
    return myDefaultValue;
  }

  @Override
  public void setName(String name) {
    myName = name;
  }

  public void setDefaultValue(String defaultValue) {
    myDefaultValue = defaultValue;
  }

  @Override
  public String getTypeText() {
    return "";
  }

  @Override
  public boolean isUseAnySingleVariable() {
    return false;
  }

  @Override
  public void setUseAnySingleVariable(boolean b) {
    throw new UnsupportedOperationException();
  }

  public boolean getDefaultInSignature() {
    return myDefaultInSignature;
  }

  public void setDefaultInSignature(boolean defaultInSignature) {
    myDefaultInSignature = defaultInSignature;
  }

  public boolean isRenamed() {
    return !myOldName.equals(myName);
  }
}

@@ -653,16 +653,66 @@
 ature;%0A%0A
+import com.intellij.openapi.util.text.StringUtil;%0A
 import c
@@ -852,16 +852,43 @@
 lable;%0A%0A
+import java.util.Objects;%0A%0A
 /**%0A * U
@@ -2481,11 +2481,470 @@
 me);%0A  %7D
+%0A%0A  @Override%0A  public String toString() %7B%0A    final String defaultValueType = myDefaultInSignature ? %22signature%22 : %22call%22;%0A    return %22PyParameterInfo(%22 +%0A           (isNew() ? %22%3Cnew%3E%22 : %22oldIndex: %22 + myOldIndex) + %22, %22 +%0A           %22name: %22 + (isRenamed() ? myOldName + %22 -%3E %22 + myName : myName) + %22, %22 +%0A           %22default: %22 + (StringUtil.isEmpty(myDefaultValue) ? %22%3Cempty%3E%22 : %22'%22 + myDefaultValue + %22' (%22 + defaultValueType + %22)%22) +%0A           %22)%22;%0A  %7D
 %0A%7D%0A

Implement toString() for PyParameterInfo to ease debugging