/*
 * Copyright 2003-2016 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 jetbrains.mps.smodel.runtime;

import jetbrains.mps.smodel.IOperationContext;
import jetbrains.mps.util.annotation.ToRemove;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import org.jetbrains.mps.openapi.language.SProperty;
import org.jetbrains.mps.openapi.language.SReferenceLink;
import org.jetbrains.mps.openapi.model.SModel;
import org.jetbrains.mps.openapi.model.SNode;

public interface ConstraintsDescriptor {

  SAbstractConcept getConcept();

  boolean canBeChild(@NotNull ConstraintContext_CanBeChild context, @Nullable CheckingNodeContext checkingNodeContext);

  boolean canBeRoot(@NotNull ConstraintContext_CanBeRoot context, @Nullable CheckingNodeContext checkingNodeContext);

  boolean canBeParent(@NotNull ConstraintContext_CanBeParent context, @Nullable CheckingNodeContext checkingNodeContext);

  boolean canBeAncestor(@NotNull ConstraintContext_CanBeAncestor context, @Nullable CheckingNodeContext checkingNodeContext);

  /**
   *
   * @deprecated use {@link #canBeChild(ConstraintContext_CanBeChild, CheckingNodeContext)} instead
   */
  @Deprecated
  @ToRemove(version = 3.5)
  boolean canBeChild(@Nullable SNode node, SNode parentNode, @Deprecated SNode link, @Deprecated SNode childConcept, IOperationContext operationContext,
      @Nullable CheckingNodeContext checkingNodeContext);

  /**
   *
   * @deprecated use {@link #canBeRoot(ConstraintContext_CanBeRoot, CheckingNodeContext)} instead
   */
  @Deprecated
  @ToRemove(version = 3.5)
  boolean canBeRoot(@NotNull SModel model, IOperationContext operationContext, @Nullable CheckingNodeContext checkingNodeContext);

  /**
   *
   * @deprecated use {@link #canBeParent(ConstraintContext_CanBeParent, CheckingNodeContext)} instead
   */
  @Deprecated
  @ToRemove(version = 3.5)
  boolean canBeParent(SNode node, @Nullable SNode childNode, @Deprecated SNode childConcept, @Deprecated SNode link, IOperationContext operationContext,
      @Nullable CheckingNodeContext checkingNodeContext);

  /**
   *
   * @deprecated use {@link #canBeAncestor(ConstraintContext_CanBeAncestor, CheckingNodeContext)} instead
   */
  @Deprecated
  @ToRemove(version = 3.5)
  boolean canBeAncestor(SNode node, @Nullable SNode childNode, @Deprecated SNode childConcept, SNode parentNode, @Deprecated SNode link,
      IOperationContext operationContext, @Nullable CheckingNodeContext checkingNodeContext);

  PropertyConstraintsDescriptor getProperty(SProperty property);

  ReferenceConstraintsDescriptor getReference(SReferenceLink referenceLink);

  @Nullable
  ReferenceScopeProvider getDefaultScopeProvider();

  @Nullable
    // by convention inheritance for this methods not works
  IconResource getInstanceIcon(SNode node);

  // FIXME why default_CONCRETE_concept is SAbstractConcept? Need to check generated code and make sure it's SConcept at generation time
  SAbstractConcept getDefaultConcreteConcept();

  // todo: remove/move this methods
  // by convention inheritance for this methods not works
  // null if icon not alternative
  @Deprecated
  @ToRemove(version = 3.4)
  @Nullable
  String getAlternativeIcon(SNode node);
}
