package jetbrains.mps.baseLanguage.javadoc.migration;

/*Generated by MPS */

import jetbrains.mps.lang.migration.runtime.base.MigrationScriptBase;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.mps.openapi.module.SModule;
import org.jetbrains.mps.openapi.model.SModel;
import jetbrains.mps.internal.collections.runtime.Sequence;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations;
import jetbrains.mps.lang.migration.runtime.base.Problem;
import org.jetbrains.mps.openapi.module.SearchScope;
import jetbrains.mps.lang.smodel.query.runtime.CommandUtil;
import jetbrains.mps.project.EditableFilteringScope;
import jetbrains.mps.lang.smodel.query.runtime.QueryExecutionContext;
import java.util.List;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import java.util.ArrayList;
import jetbrains.mps.internal.collections.runtime.CollectionSequence;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.baseLanguage.closures.runtime._FunctionTypes;
import jetbrains.mps.lang.migration.runtime.base.DeprecatedConceptMemberNotMigratedProblem;
import jetbrains.mps.lang.migration.runtime.base.MigrationScriptReference;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SConcept;
import org.jetbrains.mps.openapi.language.SContainmentLink;

public class MoveDocTagsIntoTagsChildCollection extends MigrationScriptBase {
  private final String description = "MoveDocTagsIntoTagsChildCollection";
  public String getCaption() {
    return description;
  }
  @Override
  public boolean isRerunnable() {
    return true;
  }
  public SNode execute(final SModule m) {
    doExecute(m);
    return null;
  }
  public void doExecute(final SModule m) {
    Iterable<SModel> models = m.getModels();
    Sequence.fromIterable(models).ofType(SModel.class).translate((model) -> SModelOperations.nodes(model, CONCEPTS.ClassifierDocComment$mh)).visitAll((it) -> JavaDocConverter.convertClassifierTags(it));
    Sequence.fromIterable(models).ofType(SModel.class).translate((model) -> SModelOperations.nodes(model, CONCEPTS.MethodDocComment$HI)).visitAll((it) -> JavaDocConverter.convertMethodTags(it));
    Sequence.fromIterable(models).ofType(SModel.class).translate((model) -> SModelOperations.nodes(model, CONCEPTS.FieldDocComment$wl)).visitAll((it) -> JavaDocConverter.convertFieldTags(it));
    Sequence.fromIterable(models).ofType(SModel.class).translate((model) -> SModelOperations.nodes(model, CONCEPTS.BaseDocComment$bU)).visitAll((it) -> JavaDocConverter.convertTags(it));
  }
  @Override
  public Iterable<Problem> check(SModule m) {
    {
      SearchScope scope_i7tkk0_a0f = CommandUtil.createScope(m);
      final SearchScope scope_i7tkk0_a0f_0 = new EditableFilteringScope(scope_i7tkk0_a0f);
      QueryExecutionContext context = () -> scope_i7tkk0_a0f_0;
      List<Problem> result = ListSequence.fromList(new ArrayList<Problem>());
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.ClassifierDocComment$mh, false)).where((it) -> ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.param$Wb3e)).isNotEmpty()).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.param$Wb3e);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.MethodDocComment$HI, false)).where((it) -> ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.param$LRA1)).isNotEmpty()).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.param$LRA1);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.MethodDocComment$HI, false)).where((it) -> ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.throwsTag$gRkU)).isNotEmpty()).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.throwsTag$gRkU);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.MethodDocComment$HI, false)).where((it) -> (SLinkOperations.getTarget(it, LINKS.return$h3ZK) != null)).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.return$h3ZK);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.BaseDocComment$bU, false)).where((it) -> (SLinkOperations.getTarget(it, LINKS.deprecated$M8kQ) != null)).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.deprecated$M8kQ);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.BaseDocComment$bU, false)).where((it) -> ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.author$lgjQ)).isNotEmpty()).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.author$lgjQ);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.BaseDocComment$bU, false)).where((it) -> ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.since$M6dH)).isNotEmpty()).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.since$M6dH);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.BaseDocComment$bU, false)).where((it) -> ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.version$M6sI)).isNotEmpty()).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.version$M6sI);
        }
      }));
      ListSequence.fromList(result).addSequence(CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.selectScope(null, context), CONCEPTS.BaseDocComment$bU, false)).where((it) -> ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.see$H9Bg)).isNotEmpty()).select(new _FunctionTypes._return_P1_E0<Problem, SNode>() {
        public Problem invoke(SNode it) {
          return DeprecatedConceptMemberNotMigratedProblem.deprecatedContainmentLink(it, LINKS.see$H9Bg);
        }
      }));
      return result;
    }
  }
  public MigrationScriptReference getReference() {
    return new MigrationScriptReference(MetaAdapterFactory.getLanguage(0xf280165065d5424eL, 0xbb1b463a8781b786L, "jetbrains.mps.baseLanguage.javadoc"), 1);
  }

  private static final class CONCEPTS {
    /*package*/ static final SConcept ClassifierDocComment$mh = MetaAdapterFactory.getConcept(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x1cb65d9fe66a764cL, "jetbrains.mps.baseLanguage.javadoc.structure.ClassifierDocComment");
    /*package*/ static final SConcept MethodDocComment$HI = MetaAdapterFactory.getConcept(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7faeeb34L, "jetbrains.mps.baseLanguage.javadoc.structure.MethodDocComment");
    /*package*/ static final SConcept FieldDocComment$wl = MetaAdapterFactory.getConcept(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x5ed0d79d7dc44bf2L, "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment");
    /*package*/ static final SConcept BaseDocComment$bU = MetaAdapterFactory.getConcept(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7fae70d3L, "jetbrains.mps.baseLanguage.javadoc.structure.BaseDocComment");
  }

  private static final class LINKS {
    /*package*/ static final SContainmentLink param$Wb3e = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x1cb65d9fe66a764cL, 0x1cb65d9fe66a764eL, "param");
    /*package*/ static final SContainmentLink param$LRA1 = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7faeeb34L, 0x757ba20a4c90eaf9L, "param");
    /*package*/ static final SContainmentLink throwsTag$gRkU = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7faeeb34L, 0x514c0f687050918cL, "throwsTag");
    /*package*/ static final SContainmentLink return$h3ZK = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7faeeb34L, 0x514c0f6870509198L, "return");
    /*package*/ static final SContainmentLink deprecated$M8kQ = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7fae70d3L, 0x757ba20a4c87f96bL, "deprecated");
    /*package*/ static final SContainmentLink author$lgjQ = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7fae70d3L, 0x4a3c146b7faeeb32L, "author");
    /*package*/ static final SContainmentLink since$M6dH = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7fae70d3L, 0x757ba20a4c87f962L, "since");
    /*package*/ static final SContainmentLink version$M6sI = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7fae70d3L, 0x757ba20a4c87f963L, "version");
    /*package*/ static final SContainmentLink see$H9Bg = MetaAdapterFactory.getContainmentLink(0xf280165065d5424eL, 0xbb1b463a8781b786L, 0x4a3c146b7fae70d3L, 0x1ec532ec252df7ddL, "see");
  }
}
