public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
   try {
     for (SModel model :
         Sequence.fromIterable(
             ((MPSProject) MapSequence.fromMap(_params).get("mpsProject")).getProjectModels())) {
       if (!(model instanceof RefactorableSModelDescriptor)) {
         continue;
       }
       if (SModelStereotype.isStubModelStereotype(SModelStereotype.getStereotype(model))) {
         continue;
       }
       UpdateRefactoringVersions_Action.this.updateModelVersion(
           (RefactorableSModelDescriptor) model, _params);
     }
     for (SModel model :
         Sequence.fromIterable(
             ((MPSProject) MapSequence.fromMap(_params).get("mpsProject")).getProjectModels())) {
       if (!(model instanceof EditableSModelDescriptor)) {
         continue;
       }
       if (SModelStereotype.isStubModelStereotype(SModelStereotype.getStereotype(model))) {
         continue;
       }
       UpdateRefactoringVersions_Action.this.updateImportVersions(
           (EditableSModelDescriptor) model, _params);
     }
     SModelRepository.getInstance().saveAll();
   } catch (Throwable t) {
     LOG.error("User's action execute method failed. Action:" + "UpdateRefactoringVersions", t);
   }
 }
 @Override
 protected boolean acceptModel(SModel model) {
   if (SModelStereotype.isStubModelStereotype(SModelStereotype.getStereotype(model))) {
     return false;
   }
   return acceptModule(model.getModule());
 }
 private static boolean renderingCondition_1x071y_a01a(
     SNode node, EditorContext editorContext, IScope scope) {
   return SNodeOperations.getAncestor(
               node, "jetbrains.mps.baseLanguage.structure.AnonymousClass", false, false)
           == null
       && !(SModelStereotype.isStubModelStereotype(
           SNodeOperations.getModel(node).getStereotype()));
 }
  public void stopListening() {
    if (!SModelStereotype.isStubModelStereotype(myModel.getStereotype())) {
      ModelGenerationStatusManager.getInstance().removeGenerationStatusListener(myStatusListener);
    }

    myModel.removeModelListener(mySimpleModelListener);
    SModelEventsDispatcher.getInstance().unregisterListener(myEventsListener);
  }
  public void startListening() {
    visitNode(myTreeNode);

    SModelEventsDispatcher.getInstance().registerListener(myEventsListener);
    myModel.addModelListener(mySimpleModelListener);

    if (!SModelStereotype.isStubModelStereotype(myModel.getStereotype())) {
      ModelGenerationStatusManager.getInstance().addGenerationStatusListener(myStatusListener);
    }
  }
 /*package*/ static Object getCompileTimeConstantValue_idi1LP2xI(
     @NotNull SNode __thisNode__, SModule module) {
   SNode classifier =
       SLinkOperations.getTarget(
           __thisNode__,
           MetaAdapterFactory.getReferenceLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf940c80846L,
               0x10a75869f9bL,
               "classifier"));
   if ((classifier != null)
       && SModelStereotype.isStubModelStereotype(
           SModelStereotype.getStereotype(
               SNodeOperations.getModel(classifier).getReference().getModelName()))) {
     return Expression__BehaviorDescriptor.eval_idhEwJgmp.invoke(__thisNode__, module);
   } else {
     return ((boolean)
             Expression__BehaviorDescriptor.isCompileTimeConstant_idi1LOPRp.invoke(
                 SLinkOperations.getTarget(
                     SLinkOperations.getTarget(
                         __thisNode__,
                         MetaAdapterFactory.getReferenceLink(
                             0xf3061a5392264cc5L,
                             0xa443f952ceaf5816L,
                             0xf8c77f1e98L,
                             0xf8cc6bf960L,
                             "variableDeclaration")),
                     MetaAdapterFactory.getContainmentLink(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0xf8c37a7f6eL,
                         0xf8c37f506eL,
                         "initializer")))
         ? Expression__BehaviorDescriptor.getCompileTimeConstantValue_idi1LP2xI.invoke(
             SLinkOperations.getTarget(
                 SLinkOperations.getTarget(
                     __thisNode__,
                     MetaAdapterFactory.getReferenceLink(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0xf8c77f1e98L,
                         0xf8cc6bf960L,
                         "variableDeclaration")),
                 MetaAdapterFactory.getContainmentLink(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0xf8c37a7f6eL,
                     0xf8c37f506eL,
                     "initializer")),
             module)
         : null);
   }
 }
  public static Object virtual_getCompileTimeConstantValue_1238860310638(
      SNode thisNode, IModule module) {
    if (SNodeOperations.isInstanceOf(
        SLinkOperations.getTarget(thisNode, "variableDeclaration", false),
        "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration")) {
      // todo
      SNode declaration =
          SNodeOperations.cast(
              SLinkOperations.getTarget(thisNode, "variableDeclaration", false),
              "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration");
      SNode classifier =
          SNodeOperations.as(
              SNodeOperations.getParent(declaration),
              "jetbrains.mps.baseLanguage.structure.Classifier");
      if ((classifier != null)
          && SModelStereotype.isStubModelStereotype(
              SNodeOperations.getModel(classifier).getSModelReference().getStereotype())) {
        return Expression_Behavior.call_eval_1213877519769(thisNode, module);
      } else {
        return (BehaviorReflection.invokeVirtual(
                Boolean.TYPE,
                SLinkOperations.getTarget(declaration, "initializer", true),
                "virtual_isCompileTimeConstant_1238860258777",
                new Object[] {})
            ? BehaviorReflection.invokeVirtual(
                Object.class,
                SLinkOperations.getTarget(declaration, "initializer", true),
                "virtual_getCompileTimeConstantValue_1238860310638",
                new Object[] {module})
            : null);
      }
    }

    return BehaviorReflection.invokeSuper(
        Object.class,
        thisNode,
        "jetbrains.mps.baseLanguage.structure.Expression",
        "virtual_getCompileTimeConstantValue_1238860310638",
        new Object[] {module});
  }
 private static boolean _StyleParameter_QueryFunction_fao2ea_a0a0(
     EditorContext editorContext, SNode node) {
   return !(SModelStereotype.isStubModelStereotype(
       SNodeOperations.getModelStereotype(
           jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations.getModel(node))));
 }
  private void update(SNode method, SNode baseMethod) {
    if (SModelStereotype.isStubModelStereotype(
        SNodeOperations.getModel(baseMethod).getStereotype())) {
      setVariableNames(method, MapSequence.fromMap(new HashMap<String, Integer>()));
    }
    if (myRemoveAttributes) {
      for (SNode child : SNodeOperations.getChildren(method)) {
        removeAttributes(child);
      }
    }
    boolean isInterfaceMethod =
        SNodeOperations.isInstanceOf(
                SNodeOperations.getParent(baseMethod),
                "jetbrains.mps.baseLanguage.structure.Interface")
            || SPropertyOperations.getBoolean(baseMethod, "isAbstract");
    if (myInsertOverride && !(isInterfaceMethod)) {
      boolean isNeedAddAnnotation = true;
      for (SNode annotation : SLinkOperations.getTargets(method, "annotation", true)) {
        if (SLinkOperations.getTarget(annotation, "annotation", false)
            == SNodeOperations.getNode(
                "f:java_stub#6354ebe7-c22a-4a0f-ac54-50b52ab9b065#java.lang(JDK/java.lang@java_stub)",
                "~Override")) {
          isNeedAddAnnotation = false;
          break;
        }
      }
      if (isNeedAddAnnotation) {
        ListSequence.fromList(SLinkOperations.getTargets(method, "annotation", true))
            .addElement(_quotation_createNode_tfz3o4_a0a0a2a3a8());
      }
    }

    Iterable<SNode> paramList =
        ListSequence.fromList(SLinkOperations.getTargets(method, "parameter", true))
            .select(
                new ISelector<SNode, SNode>() {
                  public SNode select(SNode it) {
                    return _quotation_createNode_tfz3o4_a0a0a0a5a8(it);
                  }
                });
    SNode defaultExpr;
    if (isInterfaceMethod) {
      defaultExpr =
          BehaviorReflection.invokeVirtual(
              (Class<SNode>) ((Class) Object.class),
              SLinkOperations.getTarget(baseMethod, "returnType", true),
              "virtual_createDefaultTypeExpression_3359611512358152580",
              new Object[] {});
    } else {
      defaultExpr =
          _quotation_createNode_tfz3o4_a0a0a7a8(
              baseMethod, Sequence.fromIterable(paramList).toListSequence());
    }

    if (SNodeOperations.isInstanceOf(
        SLinkOperations.getTarget(method, "returnType", true),
        "jetbrains.mps.baseLanguage.structure.VoidType")) {
      if (!(isInterfaceMethod)) {
        ListSequence.fromList(
                SLinkOperations.getTargets(
                    SLinkOperations.getTarget(method, "body", true), "statement", true))
            .addElement(_quotation_createNode_tfz3o4_a0a0a0a9a8(defaultExpr));
      }
    } else {
      ListSequence.fromList(
              SLinkOperations.getTargets(
                  SLinkOperations.getTarget(method, "body", true), "statement", true))
          .addElement(getReturnStatement(defaultExpr));
    }
  }
Beispiel #10
0
  @Override
  public void doUpdate(AnActionEvent event) {
    removeAll();

    SModel modelDescriptor = event.getData(MPSDataKeys.CONTEXT_MODEL);
    if (modelDescriptor == null) {
      setEnabledState(event.getPresentation(), false);
      return;
    }

    if (!(modelDescriptor instanceof EditableSModel)
        || (((EditableSModel) modelDescriptor).isReadOnly())) {
      event.getPresentation().setEnabled(false);
      event.getPresentation().setVisible(false);
      return;
    }

    IScope scope = event.getData(MPSDataKeys.SCOPE);
    IOperationContext context = event.getData(MPSDataKeys.OPERATION_CONTEXT);

    boolean isStubModel =
        SModelStereotype.isStubModelStereotype(SModelStereotype.getStereotype(modelDescriptor));
    if (scope == null || context == null || isStubModel) {
      setEnabledState(event.getPresentation(), false);
      return;
    }

    boolean inEditor = event.getData(MPSDataKeys.LOGICAL_VIEW_SELECTION_SIZE) == null;

    if (!inEditor) {
      Integer selectedItemsCount = event.getData(MPSDataKeys.LOGICAL_VIEW_SELECTION_SIZE);
      boolean singleItemSelected = selectedItemsCount != null && selectedItemsCount == 1;

      if (!singleItemSelected) {
        setEnabledState(event.getPresentation(), false);
        return;
      }

      TreeNode treeNode = event.getData(MPSDataKeys.LOGICAL_VIEW_NODE);

      if (!(treeNode instanceof PackageNode)) {
        myPackage = null;
      } else {
        final PackageNode node = (PackageNode) treeNode;
        myPackage = node.getPackage();
      }
    } else {
      SNode node = event.getData(MPSDataKeys.NODE);
      myPackage = null;
      if (node != null) {
        SNode root = node.getContainingRoot();
        myPackage =
            SNodeAccessUtil.getProperty(root, SNodeUtil.property_BaseConcept_virtualPackage);
      }
    }

    setEnabledState(event.getPresentation(), true);

    List<Language> modelLanguages = SModelOperations.getLanguages(modelDescriptor, scope);

    LanguageAspect aspect = Language.getModelAspect(modelDescriptor);
    if (aspect != null) {
      SModuleReference ref = aspect.getMainLanguage();
      Language lang = scope.getLanguage(ref);
      if (lang != null) {
        modelLanguages.remove(lang);

        for (SNode conceptDeclaration : lang.getConceptDeclarations()) {
          if (ModelConstraintsManager.canBeRoot(
              context, NameUtil.nodeFQName(conceptDeclaration), modelDescriptor)) {
            add(
                new NewRootNodeAction(
                    new jetbrains.mps.smodel.SNodePointer(conceptDeclaration), modelDescriptor));
          }
        }

        addSeparator();
      }
    }

    Collections.sort(modelLanguages, new ToStringComparator());

    List<Language> languagesWithRoots = new ArrayList<Language>();
    for (final Language language : modelLanguages) {
      for (SNode conceptDeclaration : language.getConceptDeclarations()) {
        if (ModelConstraintsManager.canBeRoot(
            context, NameUtil.nodeFQName(conceptDeclaration), modelDescriptor)) {
          languagesWithRoots.add(language);
          break;
        }
      }
    }

    boolean plain = myPlain || (languagesWithRoots.size() == 1 && aspect == null);

    for (final Language language : languagesWithRoots) {
      String name = language.getModuleName();
      Icon icon = IconManager.getIconForNamespace(language.getModuleName());
      BaseGroup langRootsGroup;

      if (!plain) {
        langRootsGroup = new BaseGroup(NameUtil.compactNamespace(name), name, icon);
        langRootsGroup.setPopup(true);
      } else {
        langRootsGroup = this;
      }

      for (SNode conceptDeclaration : language.getConceptDeclarations()) {
        if (ModelConstraintsManager.getInstance()
            .canBeRoot(context, NameUtil.nodeFQName(conceptDeclaration), modelDescriptor)) {
          langRootsGroup.add(
              new NewRootNodeAction(
                  new jetbrains.mps.smodel.SNodePointer(conceptDeclaration), modelDescriptor));
        }
      }
      if (!plain) {
        this.add(langRootsGroup);
      } else {
        this.addSeparator();
      }
    }

    if (getChildrenCount() == 0) {
      add(
          ActionManager.getInstance()
              .getAction(
                  "jetbrains.mps.ide.editor.actions.AddLanguageImport_Action" /* FIXME AddLanguageImport_Action.class.getName()*/));
    }
  }
Beispiel #11
0
 public static boolean shouldReportError(SNode node) {
   if (SModelUtil_new.getMetaLevel(node) != 0) return false;
   if (SModelStereotype.isStubModelStereotype(node.getModel().getStereotype())) return false;
   return true;
 }
Beispiel #12
0
 public static Iterable<SNode> getRootsToIterate(SModel model) {
   if (SModelStereotype.isStubModelStereotype(
       jetbrains.mps.util.SNodeOperations.getModelStereotype(model)))
     return new EmptyIterable<SNode>();
   return new ConditionalIterable<SNode>(model.getRootNodes(), new MyCondition());
 }