/*
 * Copyright 2000-2013 JetBrains s.r.o.
 * Copyright 2014-2015 AS3Boyan
 * Copyright 2014-2014 Elias Ku
 *
 * 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.intellij.plugins.haxe.model.fixer;

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;

abstract public class HaxeFixer implements IntentionAction, Runnable {
  private String text;

  public HaxeFixer(String text) {
    this.text = text;
  }

  @Nls
  @NotNull
  @Override
  public String getText() {
    return this.text;
  }

  @Nls
  @NotNull
  @Override
  public String getFamilyName() {
    return "semantic";
  }

  @Override
  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    return true;
  }

  @Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    run();
  }

  @Override
  public boolean startInWriteAction() {
    return true;
  }

  abstract public void run();
}
/*
 * Copyright 2000-2013 JetBrains s.r.o.
 * Copyright 2014-2015 AS3Boyan
 * Copyright 2014-2014 Elias Ku
 * Copyright 2019 Eric Bishton
 *
 * 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.intellij.plugins.haxe.model.fixer;

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;

abstract public class HaxeFixer implements IntentionAction, Runnable {
  @FunctionalInterface
  public interface IntentionCallback {
    void run();
  }

  private static class CallbackFixer extends HaxeFixer {
    final private IntentionCallback callback;
    CallbackFixer(@NotNull String text, @NotNull IntentionCallback cb) {
      super(text);
      this.callback = cb;
    }
    @Override
    public void run() {
      callback.run();
    }
  }

  private String text;

  public HaxeFixer(String text) {
    this.text = text;
  }

  public static HaxeFixer create(@NotNull String text, @NotNull IntentionCallback cb) {
    return new CallbackFixer(text, cb);
  }

  @Nls
  @NotNull
  @Override
  public String getText() {
    return this.text;
  }

  @Nls
  @NotNull
  @Override
  public String getFamilyName() {
    return "semantic";
  }

  @Override
  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    return true;
  }

  @Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    run();
  }

  @Override
  public boolean startInWriteAction() {
    return true;
  }

  abstract public void run();
}
Add a fixer that uses a functional interface.