public void init() {
   IntentionsManager.getInstance().registerIntentionFactory(new ConvertToNodeBuilder_Intention());
   IntentionsManager.getInstance().registerIntentionFactory(new CreateAntiquotation_Intention());
   IntentionsManager.getInstance()
       .registerIntentionFactory(new CreateListAntiquotation_Intention());
   IntentionsManager.getInstance()
       .registerIntentionFactory(new CreatePropertyAntiquotation_Intention());
   IntentionsManager.getInstance()
       .registerIntentionFactory(new CreateReferenceAntiquotation_Intention());
 }
Beispiel #2
0
  public void doUpdate(AnActionEvent event) {
    try {
      SurroundWithIntentions_ActionGroup.this.removeAll();

      IntentionsManager.QueryDescriptor query = new IntentionsManager.QueryDescriptor();
      query.setIntentionClass(SurroundWithIntention.class);
      query.setInstantiate(true);
      query.setCurrentNodeOnly(true);

      List<Tuples._2<Intention, SNode>> groupItems =
          ListSequence.fromList(new ArrayList<Tuples._2<Intention, SNode>>());
      SNode node = event.getData(MPSDataKeys.NODE);
      final EditorContext context = event.getData(MPSDataKeys.EDITOR_CONTEXT);

      Collection<Pair<Intention, SNode>> intentions =
          IntentionsManager.getInstance().getAvailableIntentions(query, node, context);
      for (Pair<Intention, SNode> pair : Sequence.fromIterable(intentions)) {
        ListSequence.fromList(groupItems)
            .addElement(MultiTuple.<Intention, SNode>from(pair.getFirst(), pair.getSecond()));
      }
      if (ListSequence.fromList(groupItems).isEmpty()) {
        return;
      }

      ListSequence.fromList(groupItems)
          .sort(
              new Comparator<Tuples._2<Intention, SNode>>() {
                public int compare(Tuples._2<Intention, SNode> a, Tuples._2<Intention, SNode> b) {
                  return a._0()
                      .getDescription(a._1(), context)
                      .compareTo(b._0().getDescription(b._1(), context));
                }
              },
              true)
          .visitAll(
              new IVisitor<Tuples._2<Intention, SNode>>() {
                public void visit(Tuples._2<Intention, SNode> it) {
                  SurroundWithIntentions_ActionGroup.this.addParameterizedAction(
                      new SurroundIntentionAction_Action((SurroundWithIntention) it._0(), it._1()),
                      PluginId.getId("jetbrains.mps.lang.intentions"),
                      (SurroundWithIntention) it._0(),
                      it._1());
                }
              });
    } catch (Throwable t) {
      LOG.error("User group error", t);
    }
    for (Pair<ActionPlace, Condition<BaseAction>> p : this.myPlaces) {
      this.addPlace(p.first, p.second);
    }
  }
 public void init() {
   IntentionsManager.getInstance().registerIntentionFactory(new InlineConstant_Intention());
   IntentionsManager.getInstance().registerIntentionFactory(new IntroduceConstant_Intention());
   IntentionsManager.getInstance().registerIntentionFactory(new SafeRemoveConstant_Intention());
 }
 public void init() {
   IntentionsManager.getInstance().registerIntentionFactory(new RemoveExclamationMark_Intention());
   IntentionsManager.getInstance().registerIntentionFactory(new SwitchDefault_Intention());
   IntentionsManager.getInstance()
       .registerIntentionFactory(new replace_whereBlock_with_closure_Intention());
 }