Exemplo n.º 1
0
  public SNode convertField(PsiField x, SNode parentConcept) {
    SNode field;
    if (isStatic(x)
        || SConceptOperations.isSubConceptOf(
            parentConcept, "jetbrains.mps.baseLanguage.structure.Interface")) {
      field =
          SConceptOperations.createNewNode(
              "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration", null);
    } else {
      field =
          SConceptOperations.createNewNode(
              "jetbrains.mps.baseLanguage.structure.FieldDeclaration", null);
      SPropertyOperations.set(
          SNodeOperations.cast(field, "jetbrains.mps.baseLanguage.structure.FieldDeclaration"),
          "isVolatile",
          "" + (x.hasModifierProperty(PsiModifier.VOLATILE)));
      SPropertyOperations.set(
          SNodeOperations.cast(field, "jetbrains.mps.baseLanguage.structure.FieldDeclaration"),
          "isTransient",
          "" + (x.hasModifierProperty(PsiModifier.TRANSIENT)));
    }

    SPropertyOperations.set(field, "name", x.getName());
    SLinkOperations.setTarget(
        SNodeOperations.cast(field, "jetbrains.mps.baseLanguage.structure.ClassifierMember"),
        "visibility",
        getVisibility(x),
        true);
    SPropertyOperations.set(field, "isFinal", "" + (isFinal(x)));
    SLinkOperations.setTarget(field, "type", convertType(x.getType()), true);
    addAnnotations(x, field);

    return field;
  }
Exemplo n.º 2
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");
   }
 }
Exemplo n.º 3
0
 public List<?> createParameterObjects(
     SNode node, IScope scope, IOperationContext operationContext, EditorContext editorContext) {
   List<SNode> res = ListSequence.fromList(new LinkedList<SNode>());
   ListSequence.fromList(res)
       .addElement(
           SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.regexp.structure.NegativeLookAheadRegexp"));
   ListSequence.fromList(res)
       .addElement(
           SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.regexp.structure.NegativeLookBehindRegexp"));
   ListSequence.fromList(res)
       .addElement(
           SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.regexp.structure.PositiveLookAheadRegexp"));
   ListSequence.fromList(res)
       .addElement(
           SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.regexp.structure.PositiveLookBehindRegexp"));
   ListSequence.fromList(res)
       .addElement(
           SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.regexp.structure.MatchParensRegexp"));
   return res;
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   EditorCell selectedCell = editorContext.getSelectedCell();
   if (!(selectedCell.isReferenceCell())) {
     return;
   }
   SNode contextNode =
       SNodeOperations.cast(
           selectedCell.getSNode(), "jetbrains.mps.lang.core.structure.BaseConcept");
   if (contextNode == null) {
     return;
   }
   String role = selectedCell.getRole();
   if (SNodeOperations.isInstanceOf(
       contextNode, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation")) {
     SNode attributedNode =
         SNodeOperations.cast(
             SNodeOperations.getParent(contextNode),
             "jetbrains.mps.lang.core.structure.BaseConcept");
     assert attributedNode != null;
     AttributeOperations.setAttribute(
         attributedNode,
         new IAttributeDescriptor.LinkAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
             role),
         null);
     return;
   }
   if (AttributeOperations.getAttribute(
           contextNode,
           new IAttributeDescriptor.LinkAttribute(
               SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
               role))
       != null) {
     AttributeOperations.setAttribute(
         contextNode,
         new IAttributeDescriptor.LinkAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
             role),
         null);
   } else {
     SNode referenceAntiquotation =
         SNodeFactoryOperations.setNewAttribute(
             contextNode,
             new IAttributeDescriptor.LinkAttribute(
                 SConceptOperations.findConceptDeclaration(
                     "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
                 role),
             "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation");
     if (selectedCell.isSingleNodeCell()) {
       SPropertyOperations.set(
           referenceAntiquotation,
           "label",
           SPropertyOperations.getString(
               SNodeOperations.getConceptDeclaration(contextNode), "name"));
     }
   }
 }
Exemplo n.º 5
0
 public static List<SubstituteAction>
     nodeSubstituteActionsBuilder_ActionsFactory_SNodeOperation_1201875763403(
         final IOperationContext operationContext,
         final NodeSubstituteActionsFactoryContext _context) {
   List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
   ListSequence.fromList(result)
       .addSequence(
           ListSequence.fromList(
               ChildSubstituteActionsHelper.createDefaultSubstituteActions(
                   SConceptOperations.findConceptDeclaration(
                       "jetbrains.mps.lang.typesystem.structure.Node_TypeOperation"),
                   _context.getParentNode(),
                   _context.getCurrentTargetNode(),
                   _context.getChildSetter(),
                   operationContext)));
   ListSequence.fromList(result)
       .addSequence(
           ListSequence.fromList(
               ChildSubstituteActionsHelper.createDefaultSubstituteActions(
                   SConceptOperations.findConceptDeclaration(
                       "jetbrains.mps.lang.typesystem.structure.Node_InferTypeOperation"),
                   _context.getParentNode(),
                   _context.getCurrentTargetNode(),
                   _context.getChildSetter(),
                   operationContext)));
   return result;
 }
 public static Scope virtual_getProjectStructureScope_3734116213129936182(
     SNode thisNode, final SNode kind) {
   if (SConceptOperations.isSubConceptOf(
           kind, "jetbrains.mps.build.mps.structure.BuildMps_AbstractModule")
       || SConceptOperations.isSubConceptOf(
           kind, "jetbrains.mps.build.mps.structure.BuildMps_IdeaPlugin")
       || SConceptOperations.isSubConceptOf(
           kind, "jetbrains.mps.build.mps.structure.BuildMps_Group")) {
     return new CompositeScope(
         Sequence.fromIterable(
                 BuildProject_Behavior.call_getVisibleProjects_1224588814561807665(
                     BuildPlugin_Behavior.call_getProject_1224588814561866657(thisNode), false))
             .select(
                 new ISelector<SNode, DescendantsScope>() {
                   public DescendantsScope select(SNode it) {
                     return DescendantsScope.forNamedElements(
                         it,
                         SLinkOperations.findLinkDeclaration(
                             "jetbrains.mps.build.structure.BuildProject", "parts"),
                         kind);
                   }
                 })
             .concat(
                 Sequence.fromIterable(
                     Sequence.<DescendantsScope>singleton(
                         DescendantsScope.forNamedElements(
                             BuildPlugin_Behavior.call_getProject_1224588814561866657(thisNode),
                             SLinkOperations.findLinkDeclaration(
                                 "jetbrains.mps.build.structure.BuildProject", "parts"),
                             kind))))
             .toGenericArray(DescendantsScope.class));
   }
   return null;
 }
 private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) {
   return SNodeOperations.getConceptDeclaration(node)
           == SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.closures.structure.ClosureLiteral")
       || SNodeOperations.getConceptDeclaration(node)
           == SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.closures.structure.UnrestrictedClosureLiteral");
 }
Exemplo n.º 8
0
 public static SNode getBinaryOperationType(SNode leftType, SNode rightType, boolean mayBeString) {
   List<SNode> leastCommonSupertypes =
       SubtypingUtil.leastCommonSuperTypes(Arrays.asList(leftType, rightType), null);
   if (mayBeString) {
     SModel javaLangJavaStubModelDescriptor =
         SModelRepository.getInstance()
             .getModelDescriptor(SModelReference.fromString("java.lang@java_stub"));
     assert javaLangJavaStubModelDescriptor != null;
     SModel javaLang = javaLangJavaStubModelDescriptor.getSModel();
     SNode stringClass = SModelOperations.getRootByName(javaLang, "String");
     if (SNodeOperations.isInstanceOf(
                 leftType, "jetbrains.mps.baseLanguage.structure.ClassifierType")
             && SLinkOperations.getTarget(
                     (SNodeOperations.cast(
                         leftType, "jetbrains.mps.baseLanguage.structure.ClassifierType")),
                     "classifier",
                     false)
                 == stringClass
         || SNodeOperations.isInstanceOf(
                 rightType, "jetbrains.mps.baseLanguage.structure.ClassifierType")
             && SLinkOperations.getTarget(
                     (SNodeOperations.cast(
                         rightType, "jetbrains.mps.baseLanguage.structure.ClassifierType")),
                     "classifier",
                     false)
                 == stringClass) {
       SNode classifierType =
           SConceptOperations.createNewNode(
               "jetbrains.mps.baseLanguage.structure.ClassifierType", null);
       SLinkOperations.setTarget(
           classifierType,
           "classifier",
           SNodeOperations.cast(stringClass, "jetbrains.mps.baseLanguage.structure.Classifier"),
           false);
       return classifierType;
     }
   }
   if (leastCommonSupertypes.isEmpty()) {
     SNode runtimeErrorType =
         SConceptOperations.createNewNode(
             "jetbrains.mps.lang.typesystem.structure.RuntimeErrorType", null);
     SPropertyOperations.set(runtimeErrorType, "errorText", "incompatible types");
     return runtimeErrorType;
   }
   SNode type = leastCommonSupertypes.iterator().next();
   {
     IMatchingPattern pattern_j6k1pf_e0c =
         HUtil.createMatchingPatternByConceptFQName(
             "jetbrains.mps.baseLanguage.structure.PrimitiveType");
     SNode coercedNode_j6k1pf_e0c =
         TypeChecker.getInstance().getRuntimeSupport().coerce_(type, pattern_j6k1pf_e0c);
     if (coercedNode_j6k1pf_e0c != null) {
       return coercedNode_j6k1pf_e0c;
     } else {
       return type;
     }
   }
 }
 public SNode createNewMethod() {
   if (isStatic) {
     return SConceptOperations.createNewNode(
         "jetbrains.mps.baseLanguage.structure.StaticMethodDeclaration", null);
   } else {
     return SConceptOperations.createNewNode(
         "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration", null);
   }
 }
Exemplo n.º 10
0
  public static List<SubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_TypeClause_1185801400389(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.lang.typesystem.structure.NormalTypeClause");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
        SNode wrappedConcept =
            SConceptOperations.findConceptDeclaration(
                "jetbrains.mps.baseLanguage.structure.Expression");
        IChildNodeSetter setter =
            new AbstractChildNodeSetter() {
              private SNode wrapNode(
                  SNode nodeToWrap, SModel model, @Nullable EditorContext editorContext) {
                SNode normalTypeClause =
                    SNodeFactoryOperations.createNewNode(
                        model, "jetbrains.mps.lang.typesystem.structure.NormalTypeClause", null);
                SLinkOperations.setTarget(normalTypeClause, "normalType", nodeToWrap, true);
                return normalTypeClause;
              }

              public boolean returnSmallPart(SNode nodeToWrap) {
                return false;
              }

              @Override
              public SNode doExecute(
                  SNode pn, SNode oc, SNode nc, IScope sc, @Nullable EditorContext editorContext) {
                SNode wrappedNode = wrapNode(nc, nc.getModel(), editorContext);
                _context
                    .getChildSetter()
                    .execute(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedNode,
                        operationContext.getScope(),
                        editorContext);
                return (returnSmallPart(nc) ? nc : wrappedNode);
              }
            };
        ListSequence.fromList(result)
            .addSequence(
                ListSequence.fromList(
                    ModelActions.createChildNodeSubstituteActions(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedConcept,
                        setter,
                        operationContext)));
      }
    }
    return result;
  }
Exemplo n.º 11
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_LValue_9034131902188086416(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.VariableNameDeclaration");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode name =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.VariableNameDeclaration", null);
                    SPropertyOperations.set(name, "name", pattern);
                    return name;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    SNode name =
                        VariableNameDeclaration_Behavior.testName_9034131902194480300(
                            _context.getCurrentTargetNode(), pattern);
                    if ((name != null)) {
                      return false;
                    }
                    return REGEXP_x583g4_a0a2a2a0a0a0a2a0a1a6.matcher(pattern).matches();
                  }

                  public String getMatchingText(String pattern) {
                    return pattern;
                  }

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
Exemplo n.º 12
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_IGeneralizedWordUnit_3263637656457821343(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.bash.structure.SimpleWord");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode newNode =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.SimpleWord", null);
                    SPropertyOperations.set(newNode, "word", pattern);
                    return newNode;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    if (strictly) {
                      return REGEXP_x583g4_a0a0a0a2a0a0a0a2a0a1a3.matcher(pattern).matches();
                    } else {
                      return REGEXP_x583g4_a0a0a0a0c0a0a0a0c0a0b0d.matcher(pattern).matches();
                    }
                  }

                  public String getMatchingText(String pattern) {
                    return pattern;
                  }

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
Exemplo n.º 13
0
  public static List<SubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_CExpression_6585869519574739818(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.nanoc.structure.CExpression");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode result =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.nanoc.structure.IntConst", null);
                    SPropertyOperations.set(result, "value", pattern);
                    return result;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    if (strictly) {
                      return REGEXP_x583g4_a0a0a0a2a0a0a0a2a0a1a2.matcher(pattern).matches();
                    } else {
                      return REGEXP_x583g4_a0a0a0a0c0a0a0a0c0a0b0c.matcher(pattern).matches();
                    }
                  }

                  public String getMatchingText(String pattern) {
                    return pattern;
                  }

                  public String getVisibleMatchingText(String pattern) {
                    return getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
Exemplo n.º 14
0
 private SNode getVisibility(PsiModifierListOwner x) {
   if (x.hasModifierProperty(PsiModifier.PUBLIC)) {
     return SConceptOperations.createNewNode(
         "jetbrains.mps.baseLanguage.structure.PublicVisibility", null);
   } else if (x.hasModifierProperty(PsiModifier.PROTECTED)) {
     return SConceptOperations.createNewNode(
         "jetbrains.mps.baseLanguage.structure.ProtectedVisibility", null);
   } else if (x.hasModifierProperty(PsiModifier.PRIVATE)) {
     return SConceptOperations.createNewNode(
         "jetbrains.mps.baseLanguage.structure.PrivateVisibility", null);
   } else {
     return null;
   }
 }
Exemplo n.º 15
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_LinePart_1237218108602(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mpslite.structure.ConstantLinePart");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode constant =
                        SNodeFactoryOperations.createNewNode(
                            model, "jetbrains.mpslite.structure.ConstantLinePart", null);
                    SPropertyOperations.set(constant, "text", pattern);
                    return constant;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    return REGEXP_x583g4_a0a0a2a0a0a0a2a0a1a0.matcher(pattern).matches();
                  }

                  public String getMatchingText(String pattern) {
                    return pattern;
                  }

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
    public void execute(final SNode node, final EditorContext editorContext) {
      SNode statement =
          SConceptOperations.createNewNode(
              "org.jetbrains.mps.samples.IfAndUnless.structure.MyIfStatement", null);
      SLinkOperations.setTarget(
          statement, "condition", SLinkOperations.getTarget(node, "condition", true), true);
      SNode ifBody =
          SConceptOperations.createNewNode(
              "org.jetbrains.mps.samples.IfAndUnless.structure.TrueFlow", null);
      ListSequence.fromList(SLinkOperations.getTargets(ifBody, "statement", true))
          .addSequence(
              ListSequence.fromList(
                  SLinkOperations.getTargets(
                      SLinkOperations.getTarget(node, "ifTrue", true), "statement", true)));
      SLinkOperations.setTarget(statement, "body", ifBody, true);

      SLinkOperations.setTarget(
          statement,
          "alternative",
          SConceptOperations.createNewNode(
              "org.jetbrains.mps.samples.IfAndUnless.structure.FalseFlow", null),
          true);
      if (SNodeOperations.isInstanceOf(
          SLinkOperations.getTarget(node, "ifFalseStatement", true),
          "jetbrains.mps.baseLanguage.structure.BlockStatement")) {
        ListSequence.fromList(
                SLinkOperations.getTargets(
                    SLinkOperations.getTarget(statement, "alternative", true), "statement", true))
            .addSequence(
                ListSequence.fromList(
                    SLinkOperations.getTargets(
                        SLinkOperations.getTarget(
                            SNodeOperations.cast(
                                SLinkOperations.getTarget(node, "ifFalseStatement", true),
                                "jetbrains.mps.baseLanguage.structure.BlockStatement"),
                            "statements",
                            true),
                        "statement",
                        true)));
      } else {
        ListSequence.fromList(
                SLinkOperations.getTargets(
                    SLinkOperations.getTarget(statement, "alternative", true), "statement", true))
            .addElement(SLinkOperations.getTarget(node, "ifFalseStatement", true));
      }
      SNodeOperations.replaceWithAnother(node, statement);
      editorContext.select(SLinkOperations.getTarget(statement, "condition", true));
    }
Exemplo n.º 17
0
  public static List<SubstituteAction> sideTransform_ActionsFactory_VarRef_6585869519574772785(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    ListSequence.fromList(result)
        .addElement(
            new AbstractSideTransformHintSubstituteAction(
                SConceptOperations.findConceptDeclaration(
                    "jetbrains.mps.nanoc.structure.CAssignmentExpression"),
                _context.getSourceNode()) {
              public SNode doSubstitute(
                  @Nullable final EditorContext editorContext, String pattern) {
                SNode result =
                    SNodeOperations.replaceWithAnother(
                        _context.getSourceNode(),
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.nanoc.structure.CAssignmentExpression", null));
                return SLinkOperations.setTarget(
                    result, "variable", _context.getSourceNode(), true);
              }

              public String getMatchingText(String pattern) {
                return "=";
              }

              public String getVisibleMatchingText(String pattern) {
                return getMatchingText(pattern);
              }
            });
    return result;
  }
Exemplo n.º 18
0
 public boolean canWrap(@NotNull SNode node) {
   if (eq_kl7j79_a0a0b2(
       SNodeOperations.getConceptDeclaration(node),
       SConceptOperations.findConceptDeclaration(
           "jetbrains.mps.baseLanguage.structure.ClassConcept"))) {
     if (SPropertyOperations.getBoolean(
         SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.ClassConcept"),
         "abstractClass")) {
       return false;
     }
     SNode ancestor =
         SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.Classifier");
     if (!(BehaviorReflection.invokeVirtual(
         Boolean.TYPE, ancestor, "virtual_checkLoops_3980490811621705344", new Object[] {}))) {
       return false;
     }
     while (ancestor != null
         && SNodeOperations.isInstanceOf(
             ancestor, "jetbrains.mps.baseLanguage.structure.ClassConcept")
         && !(BehaviorReflection.invokeVirtual(
                 String.class, ancestor, "virtual_getFqName_1213877404258", new Object[] {})
             .equals(TestCase.class.getCanonicalName()))) {
       ancestor =
           check_kl7j79_a0a0d0a0b2(
               SLinkOperations.getTarget(
                   SNodeOperations.cast(
                       ancestor, "jetbrains.mps.baseLanguage.structure.ClassConcept"),
                   "superclass",
                   true));
     }
     return ancestor != null;
   }
   return false;
 }
 public List<?> createParameterObjects(
     SNode node, IScope scope, IOperationContext operationContext, EditorContext editorContext) {
   // hack before actions are refactored
   List<INodeSubstituteAction> actions =
       ModelActions.createChildSubstituteActions(
           SNodeOperations.getParent(node),
           node,
           SConceptOperations.findConceptDeclaration(
               "jetbrains.mps.baseLanguage.structure.BinaryOperation"),
           new AbstractChildNodeSetter() {
             protected SNode doExecute(
                 SNode parentNode, SNode oldChild, SNode newChild, IScope scope) {
               SNode sourceNode = (SNode) oldChild;
               SNode result = (SNode) newChild;
               SNodeOperations.replaceWithAnother(sourceNode, result);
               SLinkOperations.setTarget(
                   result,
                   "leftExpression",
                   SLinkOperations.getTarget(sourceNode, "lValue", true),
                   true);
               SLinkOperations.setTarget(
                   result,
                   "rightExpression",
                   SLinkOperations.getTarget(sourceNode, "rValue", true),
                   true);
               return result;
             }
           },
           operationContext);
   return actions;
 }
 public InstanceMethodDeclarationScope(SNode classifierNode, Iterable<SNode> extendedClassifiers) {
   super(
       SConceptOperations.findConceptDeclaration(
           "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"),
       classifierNode,
       extendedClassifiers);
 }
Exemplo n.º 21
0
  public static List<INodeSubstituteAction> sideTransform_ActionsFactory_Attribute_1225239967737(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode concept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.sampleXML.structure.Attribute");
      ListSequence.fromList(result)
          .addElement(
              new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) {
                public SNode doSubstitute(String pattern) {
                  //  add next attribute
                  SNode nextAttr =
                      SConceptOperations.createNewNode(
                          "jetbrains.mps.sampleXML.structure.Attribute", null);
                  SPropertyOperations.set(
                      nextAttr, "name", ((pattern == null ? null : pattern.trim())));
                  SNodeOperations.insertNextSiblingChild(_context.getSourceNode(), nextAttr);
                  return nextAttr;
                }

                public String getMatchingText(String pattern) {
                  return pattern;
                }

                public String getVisibleMatchingText(String pattern) {
                  return this.getMatchingText(pattern);
                }
              });
    }
    return result;
  }
 private static void attachReference_id2wBFdLy8qmn(@NotNull SNode __thisNode__, SNode reference) {
   assert IReferenceAttachable_BehaviorDescriptor.canAttachReference_id2wBFdLy7HtS.invoke(
       __thisNode__, reference);
   SLinkOperations.setTarget(
       __thisNode__,
       MetaAdapterFactory.getContainmentLink(
           0x8585453e6bfb4d80L,
           0x98deb16074f1d86cL,
           0x73a7cdcfbbbf8aadL,
           0x73a7cdcfbbbf8c41L,
           "warningRef"),
       SConceptOperations.createNewNode(
           SNodeOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0x8585453e6bfb4d80L,
                   0x98deb16074f1d86cL,
                   0x6abc06f5f4af0d67L,
                   "jetbrains.mps.lang.test.structure.UnknownRuleReference"))));
   SLinkOperations.setTarget(
       SLinkOperations.getTarget(
           __thisNode__,
           MetaAdapterFactory.getContainmentLink(
               0x8585453e6bfb4d80L,
               0x98deb16074f1d86cL,
               0x73a7cdcfbbbf8aadL,
               0x73a7cdcfbbbf8c41L,
               "warningRef")),
       MetaAdapterFactory.getReferenceLink(
           0x8585453e6bfb4d80L,
           0x98deb16074f1d86cL,
           0x6abc06f5f4afab9dL,
           0x73a7cdcfba51f755L,
           "declaration"),
       reference);
 }
Exemplo n.º 23
0
 public static boolean baseMappingRule_Condition_1566704013439143567(
     final IOperationContext operationContext, final BaseMappingRuleContext _context) {
   if (!(SNodeOperations.getConceptDeclaration(SNodeOperations.getParent(_context.getNode()))
       == SConceptOperations.findConceptDeclaration(
           "jetbrains.mps.baseLanguage.structure.StatementList"))) {
     return false;
   }
   SNode methodLike =
       SNodeOperations.getAncestor(
           SNodeOperations.getParent(_context.getNode()),
           "jetbrains.mps.baseLanguage.structure.IMethodLike",
           false,
           false);
   if (!(BehaviorReflection.invokeVirtual(
           (Class<SNode>) ((Class) Object.class),
           methodLike,
           "virtual_getLastStatement_1239354409446",
           new Object[] {})
       == _context.getNode())) {
     return false;
   }
   if (!(LastStatementUtil.canMakeReturnStatement(_context.getNode()))) {
     return false;
   }
   return true;
 }
Exemplo n.º 24
0
 public static boolean baseMappingRule_Condition_1201386765715(
     final IOperationContext operationContext, final BaseMappingRuleContext _context) {
   return SConceptOperations.isExactly(
       SNodeOperations.getConceptDeclaration(
           SLinkOperations.getTarget(_context.getNode(), "operation", true)),
       "jetbrains.mps.baseLanguage.structure.PropertyReference");
 }
 public List<SNode> getSubOrSuperTypes(
     SNode type, TypeCheckingContext typeCheckingContext, IsApplicableStatus status) {
   List<SNode> supertypes = ListSequence.fromList(new ArrayList<SNode>());
   SNode elementConcept =
       SLinkOperations.getTarget(
           type,
           MetaAdapterFactory.getReferenceLink(
               0x7866978ea0f04cc7L,
               0x81bc4d213d9375e1L,
               0x10aae26be32L,
               0x10aae27c421L,
               "elementConcept"));
   if (elementConcept != null) {
     List<SNode> superConcepts = SConceptOperations.getDirectSuperConcepts(elementConcept, false);
     for (SNode superConcept : ListSequence.fromList(superConcepts)) {
       ListSequence.fromList(supertypes)
           .addElement(_quotation_createNode_f6ipu3_a0a0a1a2a1(superConcept));
     }
     // ==========
     ListSequence.fromList(supertypes).addElement(_quotation_createNode_f6ipu3_a0a3a2a1());
   }
   ListSequence.fromList(supertypes)
       .addElement(_quotation_createNode_f6ipu3_a0a3a1(elementConcept));
   ListSequence.fromList(supertypes).addElement(_quotation_createNode_f6ipu3_a0a4a1());
   return supertypes;
 }
Exemplo n.º 26
0
  public static List<SubstituteAction> sideTransform_ActionsFactory_VarDecl_6585869519574765725(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    ListSequence.fromList(result)
        .addElement(
            new AbstractSideTransformHintSubstituteAction(
                SConceptOperations.findConceptDeclaration(
                    "jetbrains.mps.nanoc.structure.CExpression"),
                _context.getSourceNode()) {
              public SNode doSubstitute(
                  @Nullable final EditorContext editorContext, String pattern) {
                return SNodeFactoryOperations.setNewChild(
                    _context.getSourceNode(),
                    "initializer",
                    "jetbrains.mps.nanoc.structure.CExpression");
              }

              public String getMatchingText(String pattern) {
                return "=";
              }

              public String getVisibleMatchingText(String pattern) {
                return getMatchingText(pattern);
              }
            });
    return result;
  }
  public static Scope virtual_getLayoutScope_1224588814561807654(SNode thisNode, SNode kind) {
    if (SConceptOperations.isSubConceptOf(
            kind, "jetbrains.mps.build.mps.structure.BuildMps_AbstractModule")
        || SConceptOperations.isSubConceptOf(
            kind, "jetbrains.mps.build.mps.structure.BuildMps_Group")
        || SConceptOperations.isSubConceptOf(
            kind, "jetbrains.mps.build.mps.structure.BuildMps_IdeaPlugin")) {
      return DescendantsScope.forNamedElements(
          BuildPlugin_Behavior.call_getProject_1224588814561866657(thisNode),
          SLinkOperations.findLinkDeclaration(
              "jetbrains.mps.build.structure.BuildProject", "parts"),
          kind);
    }

    return null;
  }
Exemplo n.º 28
0
  public SNode resolveClass(PsiClassType t) {
    PsiClass cls = t.resolve();

    // TODO q: handle this case? create dynamic reference?
    if (cls == null) {
      return null;
    }

    System.out.println("Class resolved: " + cls.getQualifiedName());

    PsiElement e = cls;
    do {
      e = e.getParent();
      if (!(e instanceof PsiClass) && !(e instanceof PsiJavaFile)) {
        return null;
      }
    } while (!(e instanceof PsiJavaFile));

    PsiJavaFile file = (PsiJavaFile) e;
    String packageName = file.getPackageName();
    SModelReference modelRef = SModelReference.fromString(packageName);

    SNode clsType =
        SConceptOperations.createNewNode(
            "jetbrains.mps.baseLanguage.structure.ClassifierType", null);
    clsType.setReference(
        "classifier", new DynamicReference("classifier", clsType, modelRef, t.getClassName()));

    System.out.println("Class type: " + t.getClassName());

    return clsType;
  }
Exemplo n.º 29
0
 public List<?> createParameterObjects(
     SNode node, IScope scope, IOperationContext operationContext, EditorContext editorContext) {
   return ListSequence.fromList(
           SConceptOperations.getAllSubConcepts(
               SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.lang.generator.structure.NodeMacro"),
               SNodeOperations.getModel(node),
               scope))
       .where(
           new IWhereFilter<SNode>() {
             public boolean accept(SNode it) {
               return !(SPropertyOperations.getBoolean(it, "abstract"));
             }
           })
       .toListSequence();
 }
Exemplo n.º 30
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_IGeneralizedWordUnit_3147078024758607987(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode concept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.ArithmeticExpansion");
      ListSequence.fromList(result)
          .addElement(
              new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) {
                public SNode doSubstitute(String pattern) {
                  SNode newNode =
                      SNodeFactoryOperations.createNewNode(
                          "jetbrains.mps.bash.structure.ArithmeticExpansion", null);
                  SNodeOperations.insertNextSiblingChild(_context.getSourceNode(), newNode);
                  return newNode;
                }

                public String getMatchingText(String pattern) {
                  return "$((";
                }

                public String getVisibleMatchingText(String pattern) {
                  return this.getMatchingText(pattern);
                }
              });
    }
    return result;
  }