SNode sourceNode = ...; // get the source node SNode targetNode = ...; // get the target node SModelDescriptor modelDescriptor = ...; // get the model descriptor SLanguage language = ...; // get the language SModel model = modelDescriptor.getModels().iterator().next(); // get the model LinkDeclaration declaration = language.getLinkRegistry().getDeclaration("myLink"); // get the link declaration SLink link = SLinkOperations.createLink(sourceNode, declaration, targetNode, model);
SLink link = ...; // get the link to delete SModelDescriptor modelDescriptor = ...; // get the model descriptor SModel model = modelDescriptor.getModels().iterator().next(); // get the model SLinkOperations.deleteLink(link, model);
SNode sourceNode = ...; // get the source node SModelDescriptor modelDescriptor = ...; // get the model descriptor SModel model = modelDescriptor.getModels().iterator().next(); // get the model SLanguage language = ...; // get the language LinkDeclaration declaration = language.getLinkRegistry().getDeclaration("myLink"); // get the link declaration ListIn summary, the `jetbrains.mps.lang.smodel.generator.smodeladapter` package library provides the `SLinkOperations` class, which is used for working with links in a JetBrains MPS SModel. The code examples demonstrate the creation, deletion, and finding of links in an SModel.links = SLinkOperations.findLinks(sourceNode, declaration, model);