package jetbrains.mps.tests.sraMigration.test;

/*Generated by MPS */

import jetbrains.mps.MPSLaunch;
import org.junit.jupiter.api.extension.ExtendWith;
import jetbrains.mps.baseLanguage.unitTest.runtime.EnvironmentAwareExtension;
import jetbrains.mps.testbench.EnvironmentAwareTestCase;
import org.jetbrains.mps.openapi.model.SModelReference;
import org.jetbrains.mps.openapi.model.SNodeReference;
import jetbrains.mps.project.MPSProject;
import org.junit.jupiter.api.Test;
import org.jetbrains.mps.openapi.model.SNode;
import org.junit.Assert;
import jetbrains.mps.lang.structure.util.SmartRefAttributeUtil;
import java.util.List;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import java.util.ArrayList;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.IAttributeDescriptor;
import jetbrains.mps.lang.test.matcher.NodesMatcher;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import org.junit.jupiter.api.BeforeEach;
import java.io.File;
import org.jetbrains.mps.openapi.persistence.PersistenceFacade;
import org.jetbrains.mps.openapi.model.SModel;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations;
import jetbrains.mps.util.Reference;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import jetbrains.mps.smodel.builder.SNodeBuilder;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.model.SNodeAccessUtil;
import org.jetbrains.mps.openapi.language.SConcept;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import org.jetbrains.mps.openapi.language.SReferenceLink;

@MPSLaunch
@ExtendWith(EnvironmentAwareExtension.class)
public class SmartRefAttrMigration_Test extends EnvironmentAwareTestCase {
  private static final SModelReference modelref_editor = modelref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)");
  private static final SNodeReference ref_implicitAttr = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446730");
  private static final SNodeReference ref_explicitAttr_OneCustom = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446734");
  private static final SNodeReference ref_explicitAttr_OneCustom_characteristicRef = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446735");
  private static final SNodeReference ref_explicitAttr_OneOfTwo = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446738");
  private static final SNodeReference ref_explicitAttr_OneOfTwo_characteristicRef = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446739");
  private static final SNodeReference ref_explicitAttr_OneNoReq = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446768");
  private static final SNodeReference ref_explicitAttr_OneNoReq_characteristicRef = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446769");
  private static final SNodeReference ref_explicitAttr_Specialized = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/3787933655124578220");
  private static final SNodeReference ref_explicitAttr_Specialized_characteristicRef = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/3787933655124578224");
  private static final SNodeReference ref_explicitMenu_Direct = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452446772");
  private static final SNodeReference ref_explicitMenu_Super = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/7273969254452476935");
  private static final SNodeReference ref_explicitMenu_HasVisible = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/3787933655125350636");
  private static final SNodeReference ref_explicitMenu_SCAUsage = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/44712766210641587");
  private static final SNodeReference ref_explicitMenu_SCAUsage_usage = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766210641656");
  private static final SNodeReference ref_explicitMenu_SCAUsage_Ext = ref("r:a989c2aa-03d7-4022-aa05-1be538539c8e(test.language.structure)/44712766211104382");
  private static final SNodeReference ref_explicitMenu_SCAUsage_Ext_usage = ref("r:d166d7a3-9b9c-45fc-8d55-d3ca57bcda5b(test.language.ext.editor)/44712766211104412");
  private static final SNodeReference ref_explicitCellMenu_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211611496");
  private static final SNodeReference ref_explicitCellMenu_ExplicitReferentPrimary_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211611496");
  private static final SNodeReference ref_explicitCellMenu_RefPresentation_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211671977");
  private static final SNodeReference ref_explicitCellMenu_RefPresentation_RPCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211671979");
  private static final SNodeReference ref_explicitCellMenu_RefPresentation_Custom_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211670318");
  private static final SNodeReference ref_explicitCellMenu_RefPresentation_Custom_RPCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211670320");
  private static final SNodeReference ref_explicitCellMenu_HasInEditor_RefPresentation_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211668085");
  private static final SNodeReference ref_explicitCellMenu_HasInEditor_RefPresentation_RPCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211668094");
  private static final SNodeReference ref_explicitCellMenu_HasInEditor_RefPresentation_Custom_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211671981");
  private static final SNodeReference ref_explicitCellMenu_HasInEditor_RefPresentation_Custom_RPCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211671985");
  private static final SNodeReference ref_explicitCellMenu_HasVisible_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211671991");
  private static final SNodeReference ref_explicitCellMenu_HasVisible_RefPresentation_RefCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211671999");
  private static final SNodeReference ref_explicitCellMenu_HasVisible_RefPresentation_RPCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211672001");
  private static final SNodeReference ref_explicitCellMenu_Super_RPCell = ref("r:aeb637c7-e64d-4368-92d6-31aeade23002(test.language.editor)/44712766211689888");
  private static final String PROJECT_PATH = "testbench/modules/testSmartRefAttrMigration/";
  private MPSProject project;
  @Test
  public void test_testImplicitAttr() throws Exception {
    executeUnderLock(() -> {
      SNode node_implicitAttr = resolveCD(ref_implicitAttr);

      Assert.assertTrue(SmartRefAttributeUtil.isAttributedImplicitly(node_implicitAttr));
    });
  }
  @Test
  public void test_testExplicitAttr_OneCustom() throws Exception {
    executeUnderLock(() -> {
      SNode node_explicitAttr_OneCustom = resolveCD(ref_explicitAttr_OneCustom);

      {
        List<SNode> nodesBefore = ListSequence.fromListAndArray(new ArrayList<SNode>(), new IAttributeDescriptor.NodeAttribute(CONCEPTS.SmartReferenceAttribute$B3).get(node_explicitAttr_OneCustom));
        List<SNode> nodesAfter = ListSequence.fromListAndArray(new ArrayList<SNode>(), _quotation_createNode_m5qb0v_a0a0b0c0a0a0b0(resolveLD(ref_explicitAttr_OneCustom_characteristicRef)));
        Assert.assertTrue("The nodes '" + nodesBefore + "' and '" + nodesAfter + "' do not match!", new NodesMatcher(nodesBefore, nodesAfter).diff().isEmpty());
      }
    });
  }
  @Test
  public void test_testExpicitAttr_OneOfTwo() throws Exception {
    executeUnderLock(() -> {
      SNode node_explicitAttr_OneOfTwo = resolveCD(ref_explicitAttr_OneOfTwo);

      {
        List<SNode> nodesBefore = ListSequence.fromListAndArray(new ArrayList<SNode>(), new IAttributeDescriptor.NodeAttribute(CONCEPTS.SmartReferenceAttribute$B3).get(node_explicitAttr_OneOfTwo));
        List<SNode> nodesAfter = ListSequence.fromListAndArray(new ArrayList<SNode>(), _quotation_createNode_m5qb0v_a0a0b0c0a0a0c0(resolveLD(ref_explicitAttr_OneOfTwo_characteristicRef)));
        Assert.assertTrue("The nodes '" + nodesBefore + "' and '" + nodesAfter + "' do not match!", new NodesMatcher(nodesBefore, nodesAfter).diff().isEmpty());
      }
    });
  }
  @Test
  public void test_testExpicitAttr_OneNoReq() throws Exception {
    executeUnderLock(() -> {
      SNode node_explicitAttr_OneNoReq = resolveCD(ref_explicitAttr_OneNoReq);

      {
        List<SNode> nodesBefore = ListSequence.fromListAndArray(new ArrayList<SNode>(), new IAttributeDescriptor.NodeAttribute(CONCEPTS.SmartReferenceAttribute$B3).get(node_explicitAttr_OneNoReq));
        List<SNode> nodesAfter = ListSequence.fromListAndArray(new ArrayList<SNode>(), _quotation_createNode_m5qb0v_a0a0b0c0a0a0d0(resolveLD(ref_explicitAttr_OneNoReq_characteristicRef)));
        Assert.assertTrue("The nodes '" + nodesBefore + "' and '" + nodesAfter + "' do not match!", new NodesMatcher(nodesBefore, nodesAfter).diff().isEmpty());
      }
    });
  }
  @Test
  public void test_testExpicitAttr_Specialized() throws Exception {
    executeUnderLock(() -> {
      SNode node_explicitAttr_Specialized = resolveCD(ref_explicitAttr_Specialized);

      {
        List<SNode> nodesBefore = ListSequence.fromListAndArray(new ArrayList<SNode>(), new IAttributeDescriptor.NodeAttribute(CONCEPTS.SmartReferenceAttribute$B3).get(node_explicitAttr_Specialized));
        List<SNode> nodesAfter = ListSequence.fromListAndArray(new ArrayList<SNode>(), _quotation_createNode_m5qb0v_a0a0b0c0a0a0e0(resolveLD(ref_explicitAttr_Specialized_characteristicRef)));
        Assert.assertTrue("The nodes '" + nodesBefore + "' and '" + nodesAfter + "' do not match!", new NodesMatcher(nodesBefore, nodesAfter).diff().isEmpty());
      }
    });
  }
  @Test
  public void test_testExplicitCellMenu() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_RefCell);

      SNode menuPart = SNodeOperations.as(ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$), LINKS.cellMenuPart$jjJD)).getElement(0), CONCEPTS.CellMenuPart_ReferentPrimary$uH);
      Assert.assertNotNull(menuPart);
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.matchingText$I7Ho));
      Assert.assertNull(SLinkOperations.getTarget(menuPart, LINKS.visibleMatchingText$ss9j));
    });
  }
  @Test
  public void test_testExplicitCellMenu_ExplicitReferentPrimary() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_ExplicitReferentPrimary_RefCell);

      SNode menuPart = SNodeOperations.as(ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$), LINKS.cellMenuPart$jjJD)).getElement(0), CONCEPTS.CellMenuPart_ReferentPrimary$uH);
      Assert.assertNotNull(menuPart);
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.matchingText$I7Ho));
      Assert.assertNull(SLinkOperations.getTarget(menuPart, LINKS.visibleMatchingText$ss9j));
    });
  }
  @Test
  public void test_testExplicitCellMenu_RefPresentation() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_RefPresentation_RefCell);
      SNode rpCell = resolveCMRP(ref_explicitCellMenu_RefPresentation_RPCell);

      Assert.assertNull(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$));
      Assert.assertNotNull(SLinkOperations.getTarget(rpCell, LINKS.referentPresentation$jfwN));
    });
  }
  @Test
  public void test_testExplicitCellMenu_RefPresentation_Custom() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_RefPresentation_Custom_RefCell);
      SNode rpCell = resolveCMRP(ref_explicitCellMenu_RefPresentation_Custom_RPCell);

      SNode menuPart = SNodeOperations.as(ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$), LINKS.cellMenuPart$jjJD)).getElement(0), CONCEPTS.CellMenuPart_ReferentPrimary$uH);
      Assert.assertNotNull(menuPart);
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.matchingText$I7Ho));
      Assert.assertNull(SLinkOperations.getTarget(menuPart, LINKS.visibleMatchingText$ss9j));

      Assert.assertNotNull(SLinkOperations.getTarget(rpCell, LINKS.referentPresentation$jfwN));
    });
  }
  @Test
  public void test_testExplicitCellMenu_HasVisible() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_HasVisible_RefCell);

      SNode menuPart = SNodeOperations.as(ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$), LINKS.cellMenuPart$jjJD)).getElement(0), CONCEPTS.CellMenuPart_ReferentPrimary$uH);
      Assert.assertNotNull(menuPart);
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.matchingText$I7Ho));
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.visibleMatchingText$ss9j));
    });
  }
  @Test
  public void test_testExplicitCellMenu_HasVisible_RefPresentation() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_HasVisible_RefPresentation_RefCell);
      SNode rpCell = resolveCMRP(ref_explicitCellMenu_HasVisible_RefPresentation_RPCell);

      SNode menuPart = SNodeOperations.as(ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$), LINKS.cellMenuPart$jjJD)).getElement(0), CONCEPTS.CellMenuPart_ReferentPrimary$uH);
      Assert.assertNotNull(menuPart);
      Assert.assertNull(SLinkOperations.getTarget(menuPart, LINKS.matchingText$I7Ho));
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.visibleMatchingText$ss9j));

      Assert.assertNotNull(SLinkOperations.getTarget(rpCell, LINKS.referentPresentation$jfwN));
    });
  }
  @Test
  public void test_testExplicitCellMenu_HasInEditor_RefPresentation() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_HasInEditor_RefPresentation_RefCell);
      SNode rpCell = resolveCMRP(ref_explicitCellMenu_HasInEditor_RefPresentation_RPCell);

      SNode menuPart = SNodeOperations.as(ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$), LINKS.cellMenuPart$jjJD)).getElement(0), CONCEPTS.CellMenuPart_ReferentPrimary$uH);
      Assert.assertNotNull(menuPart);
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.matchingText$I7Ho));
      Assert.assertNull(SLinkOperations.getTarget(menuPart, LINKS.visibleMatchingText$ss9j));

      Assert.assertNotNull(SLinkOperations.getTarget(rpCell, LINKS.referentPresentation$jfwN));
    });
  }
  @Test
  public void test_testExplicitCellMenu_HasInEditor_RefPresentation_Custom() throws Exception {
    executeUnderLock(() -> {

      SNode refCell = resolveCMRef(ref_explicitCellMenu_HasInEditor_RefPresentation_Custom_RefCell);
      SNode rpCell = resolveCMRP(ref_explicitCellMenu_HasInEditor_RefPresentation_Custom_RPCell);

      SNode menuPart = SNodeOperations.as(ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(refCell, LINKS.menuDescriptor$ptP$), LINKS.cellMenuPart$jjJD)).getElement(0), CONCEPTS.CellMenuPart_ReferentPrimary$uH);
      Assert.assertNotNull(menuPart);
      Assert.assertNotNull(SLinkOperations.getTarget(menuPart, LINKS.matchingText$I7Ho));
      Assert.assertNull(SLinkOperations.getTarget(menuPart, LINKS.visibleMatchingText$ss9j));

      Assert.assertNotNull(SLinkOperations.getTarget(rpCell, LINKS.referentPresentation$jfwN));
    });
  }
  @BeforeEach
  public void setUp() {
    // I don't care to close the project (a) can do it on per-test basis in BTestCase (no BeforeClass), (b) there are too many tests in this class
    // (c) PushEnvironmentRunnerBuilder is not yet capable to invoke static setEnvironment (so that we could have static project field
    // (d) this test is executed from separate process (mpsSmartRefAttrMigration.xml) and nobody gets affected with the project left open.
    project = ((MPSProject) myEnvironment.openProject(new File(PROJECT_PATH)));
  }

  private static SNodeReference ref(String str) {
    return PersistenceFacade.getInstance().createNodeReference(str);
  }

  private static SModelReference modelref(String str) {
    return PersistenceFacade.getInstance().createModelReference(str);
  }


  private SNode resolveCD(SNodeReference ref) {
    return (SNode) ref.resolve(project.getRepository());
  }

  private SNode resolveLD(SNodeReference ref) {
    return (SNode) ref.resolve(project.getRepository());
  }

  private SNode resolveSMN(SNodeReference ref) {
    return (SNode) ref.resolve(project.getRepository());
  }

  private SNode resolveCMRef(SNodeReference ref) {
    return (SNode) ref.resolve(project.getRepository());
  }

  private SNode resolveCMRP(SNodeReference ref) {
    return (SNode) ref.resolve(project.getRepository());
  }

  private SNode findGeneratedSMN(SModelReference modelRef, SNodeReference conceptRef) {
    final SNode concept = resolveCD(conceptRef);
    SModel model = modelRef.resolve(project.getRepository());
    return ListSequence.fromList(SModelOperations.roots(model, CONCEPTS.SubstituteMenu_Named$cm)).where((it) -> (new IAttributeDescriptor.NodeAttribute(CONCEPTS.GeneratedSubstituteMenuAttribute$Ya).get(it) != null) && SLinkOperations.getTarget(it, LINKS.conceptDeclaration$h3E) == concept).first();
  }

  private SNode findSMD(SModelReference modelRef, SNodeReference conceptRef) {
    final SNode concept = resolveCD(conceptRef);
    SModel model = modelRef.resolve(project.getRepository());
    return ListSequence.fromList(SModelOperations.roots(model, CONCEPTS.SubstituteMenu_Default$sV)).where((it) -> SLinkOperations.getTarget(it, LINKS.conceptDeclaration$h3E) == concept).first();
  }























  public void executeUnderLock(final Runnable runnable) {
    final Reference<Throwable> ref = new Reference<Throwable>();
    ApplicationManager.getApplication().invokeAndWait(() -> project.getModelAccess().executeCommand(() -> {
      try {
        runnable.run();
      } catch (Throwable t) {
        ref.set(t);
      }

    }), ModalityState.defaultModalityState());
    if (!(ref.isNull())) {
      throw new RuntimeException(ref.get());
    }
  }

  private static SNode _quotation_createNode_m5qb0v_a0a0b0c0a0a0b0(Object parameter_1) {
    SNode quotedNode_2 = null;
    SNode quotedNode_3 = null;
    SNodeBuilder nb = new SNodeBuilder(null, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure"), 0x7ab7b29c4d6297e8L, "SmartReferenceAttribute"));
    quotedNode_2 = nb.getResult();
    SNodeAccessUtil.setReferenceTarget(quotedNode_2, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d6297e8L, 0x7ab7b29c4d6297edL, "charactersticReference"), (SNode) parameter_1);
    SNodeBuilder nb1 = new SNodeBuilder(null, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure"), 0x7ab7b29c4d66855eL, "RefPresentationTemplate"));
    quotedNode_3 = nb1.getResult();
    nb1.setProperty(MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d66855eL, 0x3bc83bac475c4b59L, "prefix"), "custom ref [ ");
    nb1.setProperty(MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d66855eL, 0x3bc83bac475c4b5cL, "suffix"), " ]");
    quotedNode_2.addChild(MetaAdapterFactory.getContainmentLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d6297e8L, 0x7ab7b29c4d66ac37L, "refPresentationTemplate"), quotedNode_3);
    return quotedNode_2;
  }
  private static SNode _quotation_createNode_m5qb0v_a0a0b0c0a0a0c0(Object parameter_1) {
    SNode quotedNode_2 = null;
    SNodeBuilder nb = new SNodeBuilder(null, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure"), 0x7ab7b29c4d6297e8L, "SmartReferenceAttribute"));
    quotedNode_2 = nb.getResult();
    SNodeAccessUtil.setReferenceTarget(quotedNode_2, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d6297e8L, 0x7ab7b29c4d6297edL, "charactersticReference"), (SNode) parameter_1);
    return quotedNode_2;
  }
  private static SNode _quotation_createNode_m5qb0v_a0a0b0c0a0a0d0(Object parameter_1) {
    SNode quotedNode_2 = null;
    SNodeBuilder nb = new SNodeBuilder(null, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure"), 0x7ab7b29c4d6297e8L, "SmartReferenceAttribute"));
    quotedNode_2 = nb.getResult();
    SNodeAccessUtil.setReferenceTarget(quotedNode_2, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d6297e8L, 0x7ab7b29c4d6297edL, "charactersticReference"), (SNode) parameter_1);
    return quotedNode_2;
  }
  private static SNode _quotation_createNode_m5qb0v_a0a0b0c0a0a0e0(Object parameter_1) {
    SNode quotedNode_2 = null;
    SNodeBuilder nb = new SNodeBuilder(null, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure"), 0x7ab7b29c4d6297e8L, "SmartReferenceAttribute"));
    quotedNode_2 = nb.getResult();
    SNodeAccessUtil.setReferenceTarget(quotedNode_2, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d6297e8L, 0x7ab7b29c4d6297edL, "charactersticReference"), (SNode) parameter_1);
    return quotedNode_2;
  }

  private static final class CONCEPTS {
    /*package*/ static final SConcept SmartReferenceAttribute$B3 = MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x7ab7b29c4d6297e8L, "jetbrains.mps.lang.structure.structure.SmartReferenceAttribute");
    /*package*/ static final SConcept CellMenuPart_ReferentPrimary$uH = MetaAdapterFactory.getConcept(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x10f3f33baebL, "jetbrains.mps.lang.editor.structure.CellMenuPart_ReferentPrimary");
    /*package*/ static final SConcept SubstituteMenu_Named$cm = MetaAdapterFactory.getConcept(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x33e0267905fba6fdL, "jetbrains.mps.lang.editor.structure.SubstituteMenu_Named");
    /*package*/ static final SConcept GeneratedSubstituteMenuAttribute$Ya = MetaAdapterFactory.getConcept(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x1d5b104bd5525fa7L, "jetbrains.mps.lang.editor.structure.GeneratedSubstituteMenuAttribute");
    /*package*/ static final SConcept SubstituteMenu_Default$sV = MetaAdapterFactory.getConcept(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x2de9c932f4e5ab84L, "jetbrains.mps.lang.editor.structure.SubstituteMenu_Default");
  }

  private static final class LINKS {
    /*package*/ static final SContainmentLink menuDescriptor$ptP$ = MetaAdapterFactory.getContainmentLink(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0xf9eafb9a39L, 0x10f3514bb7cL, "menuDescriptor");
    /*package*/ static final SContainmentLink cellMenuPart$jjJD = MetaAdapterFactory.getContainmentLink(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x10f34f6aaacL, 0x10f34f82910L, "cellMenuPart");
    /*package*/ static final SContainmentLink matchingText$I7Ho = MetaAdapterFactory.getContainmentLink(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x10f3f33baebL, 0x6001c76613d86514L, "matchingText");
    /*package*/ static final SContainmentLink visibleMatchingText$ss9j = MetaAdapterFactory.getContainmentLink(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x10f3f33baebL, 0x5c3ee006520dfad6L, "visibleMatchingText");
    /*package*/ static final SContainmentLink referentPresentation$jfwN = MetaAdapterFactory.getContainmentLink(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x8ace515f0191e6eL, 0x6c035fefdf050085L, "referentPresentation");
    /*package*/ static final SReferenceLink conceptDeclaration$h3E = MetaAdapterFactory.getReferenceLink(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x169efbc9a9048c53L, 0x5b7b4c4d511049b4L, "conceptDeclaration");
  }
}
