Пример #1
0
 public static void addVariablePattern(EditorContext context) {
   EditorCell contextCell = context.getSelectedCell();
   SNode node = contextCell.getSNode();
   SNode linkDeclaration =
       SNodeOperations.cast(
           contextCell.getLinkDeclaration(),
           "jetbrains.mps.lang.structure.structure.LinkDeclaration");
   SNode genuineLinkDeclaration = SModelUtil.getGenuineLinkDeclaration(linkDeclaration);
   if (linkDeclaration != null
       && SPropertyOperations.hasValue(
           genuineLinkDeclaration, "metaClass", "reference", "reference")) {
     String role = SPropertyOperations.getString(genuineLinkDeclaration, "role");
     AttributeOperations.createAndSetAttrbiute(
         node,
         new IAttributeDescriptor.LinkAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration"),
             role),
         "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration");
   } else {
     AttributeOperations.createAndSetAttrbiute(
         node,
         new IAttributeDescriptor.NodeAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.pattern.structure.Pattern")),
         "jetbrains.mps.lang.pattern.structure.PatternVariableDeclaration");
   }
 }
Пример #2
0
 public static boolean isPatternApplicable(EditorContext context) {
   EditorCell contextCell = context.getSelectedCell();
   if (contextCell == null) {
     return false;
   }
   INodeAdapter node = BaseAdapter.fromNode(contextCell.getSNode());
   if (node == null) {
     return false;
   }
   return node.findParent(PatternExpression.class) != null;
 }
 public boolean isApplicableToNode(final SNode node, final EditorContext editorContext) {
   final EditorCell editorCell = editorContext.getSelectedCell();
   if (editorCell == null) {
     return false;
   }
   if (editorCell.getLinkDeclaration()
       != SLinkOperations.findLinkDeclaration(
           "jetbrains.mps.lang.generator.structure.Weaving_MappingRule", "ruleConsequence")) {
     return false;
   }
   return SLinkOperations.getTarget(node, "ruleConsequence", true) == null
       || SConceptOperations.isExactly(
           SNodeOperations.getConceptDeclaration(
               SLinkOperations.getTarget(node, "ruleConsequence", true)),
           "jetbrains.mps.lang.generator.structure.RuleConsequence");
 }
 public void execute_internal(EditorContext editorContext, SNode node) {
   EditorCell current = editorContext.getSelectedCell();
   EditorCell toSelect = current.getPrevLeaf(CellConditions.SELECTABLE);
   SPropertyOperations.set(node, "caseInsensitive", "" + false);
   editorContext.getNodeEditorComponent().changeSelection(toSelect);
 }