package jetbrains.mps.kotlin.typesystem;

/*Generated by MPS */

import jetbrains.mps.lang.typesystem.runtime.AbstractNonTypesystemRule_Runtime;
import jetbrains.mps.lang.typesystem.runtime.NonTypesystemRule_Runtime;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.typesystem.inference.TypeCheckingContext;
import jetbrains.mps.lang.typesystem.runtime.IsApplicableStatus;
import jetbrains.mps.kotlin.behavior.IDeconstructingDeclarations__BehaviorDescriptor;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.errors.messageTargets.MessageTarget;
import jetbrains.mps.errors.messageTargets.NodeMessageTarget;
import jetbrains.mps.errors.IErrorReporter;
import jetbrains.mps.errors.BaseQuickFixProvider;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import org.jetbrains.mps.openapi.language.SReferenceLink;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import org.jetbrains.mps.openapi.language.SInterfaceConcept;

public class check_IDeconstructingDeclarations_SuperfluousRef_NonTypesystemRule extends AbstractNonTypesystemRule_Runtime implements NonTypesystemRule_Runtime {
  public check_IDeconstructingDeclarations_SuperfluousRef_NonTypesystemRule() {
  }
  public void applyRule(final SNode iDeconstructingDeclarations, final TypeCheckingContext typeCheckingContext, IsApplicableStatus status) {
    if (!((boolean) IDeconstructingDeclarations__BehaviorDescriptor.isDeconstructed_id4FOkRjXxnrt.invoke(iDeconstructingDeclarations))) {
      for (SNode var : ListSequence.fromList(SLinkOperations.getChildren(iDeconstructingDeclarations, LINKS.variables$EO9Z))) {
        if ((SLinkOperations.getTarget(var, LINKS.deconstructingOperator$ZV8Z) != null)) {
          {
            final MessageTarget errorTarget = new NodeMessageTarget();
            IErrorReporter _reporter_2309309498 = typeCheckingContext.reportWarning(var, "superfluous underlying function", "r:aff09eac-afd3-4057-bdd8-e02a572d1436(jetbrains.mps.kotlin.typesystem)", "5401033615058909146", null, errorTarget);
            {
              BaseQuickFixProvider intentionProvider = new BaseQuickFixProvider("jetbrains.mps.kotlin.typesystem.FunctionCall_FixReference_QuickFix", "5401033615058913452", false);
              intentionProvider.putArgument("call", var);
              intentionProvider.putArgument("newTarget", null);
              intentionProvider.putArgument("targetLink", LINKS.deconstructingOperator$ZV8Z);
              _reporter_2309309498.addIntentionProvider(intentionProvider);
            }
          }
        }
      }
    }
  }
  public SAbstractConcept getApplicableConcept() {
    return CONCEPTS.IDeconstructingDeclarations$Ed;
  }
  public IsApplicableStatus isApplicableAndPattern(SNode argument) {
    return new IsApplicableStatus(argument.getConcept().isSubConceptOf(getApplicableConcept()), null);
  }
  public boolean overrides() {
    return false;
  }

  private static final class LINKS {
    /*package*/ static final SReferenceLink deconstructingOperator$ZV8Z = MetaAdapterFactory.getReferenceLink(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x4af45374fd841d58L, 0x4af45374fd846ecaL, "deconstructingOperator");
    /*package*/ static final SContainmentLink variables$EO9Z = MetaAdapterFactory.getContainmentLink(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x5aee73f62d23451L, 0x4af45374fd847a71L, "variables");
  }

  private static final class CONCEPTS {
    /*package*/ static final SInterfaceConcept IDeconstructingDeclarations$Ed = MetaAdapterFactory.getInterfaceConcept(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x5aee73f62d23451L, "jetbrains.mps.kotlin.structure.IDeconstructingDeclarations");
  }
}
