// Copyright 2000-2019 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 com.intellij.openapi.editor.impl;

import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorGutter;
import com.intellij.openapi.editor.LineNumberConverter;
import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
import gnu.trove.TIntFunction;
import org.jetbrains.annotations.NotNull;

/**
 * Adapter that should help in migration from {@link EditorGutterComponentEx#setLineNumberConvertor(TIntFunction)} and
 * {@link EditorGutterComponentEx#setLineNumberConvertor(TIntFunction, TIntFunction)} to
 * {@link EditorGutter#setLineNumberConverter(LineNumberConverter)} and
 * {@link EditorGutter#setLineNumberConverter(LineNumberConverter, LineNumberConverter)}
 */
@SuppressWarnings("deprecation")
public class LineNumberConverterAdapter implements LineNumberConverter {
  private final TIntFunction myFunction;

  public LineNumberConverterAdapter(@NotNull TIntFunction function) {
    myFunction = function;
  }

  @Override
  public Integer convert(@NotNull Editor editor, int lineNumber) {
    int result = myFunction.execute(lineNumber - 1);
    return result < 0 ? null : result + 1;
  }

  @Override
  public Integer getMaxLineNumber(@NotNull Editor editor) {
    for (int i = editor.getDocument().getLineCount(); i > 0; i--) {
      int number = myFunction.execute(i - 1);
      if (number >= 0) {
        return number + 1;
      }
    }
    return 0;
  }
}

@@ -329,71 +329,8 @@
 er;%0A
-import com.intellij.openapi.editor.ex.EditorGutterComponentEx;%0A
 impo
@@ -418,35 +418,19 @@
 ter 
-that should help in
+for
  migrati
 on f
@@ -429,98 +429,46 @@
 rati
-o
 n
+g
  from 
-%7B@link EditorGutterComponentEx#setLineNumberConvertor(TIntFunction)%7D and
+obsolete removed API
 %0A * %7B@
-link
+code
  Edi
@@ -527,22 +527,28 @@
 tion
-, TIntFunction
+ lineNumberConvertor
 )%7D t
@@ -718,41 +718,8 @@
  */%0A
-@SuppressWarnings(%22deprecation%22)%0A
 publ

fix javadoc refs