Exemplo n.º 1
0
 @Override
 public boolean isApplicable(AnActionEvent event, final Map<String, Object> _params) {
   SAbstractConcept concept = event.getData(MPSCommonDataKeys.NODE).getConcept();
   LanguageRuntime languageRuntime =
       LanguageRegistry.getInstance(event.getData(MPSCommonDataKeys.MPS_PROJECT))
           .getLanguage(concept.getLanguage());
   DocumentationAspectDescriptor docDescriptor =
       languageRuntime.getAspect(DocumentationAspectDescriptor.class);
   return docDescriptor != null;
 }
Exemplo n.º 2
0
 @Override
 public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
   SAbstractConcept concept = event.getData(MPSCommonDataKeys.NODE).getConcept();
   LanguageRuntime languageRuntime =
       LanguageRegistry.getInstance(event.getData(MPSCommonDataKeys.MPS_PROJECT))
           .getLanguage(concept.getLanguage());
   DocumentationAspectDescriptor docDescriptor =
       languageRuntime.getAspect(DocumentationAspectDescriptor.class);
   String docText = docDescriptor.getConceptDocumentation(concept);
   if (docText != null) {
     JOptionPane.showMessageDialog(null, docText);
   }
 }
Exemplo n.º 3
0
 public IFacet lookup(IFacet.Name fn) {
   LanguageRegistry langReg = LanguageRegistry.getInstance();
   if (langReg != null) {
     LanguageRuntime lr = langReg.getLanguage(fn.getNamespace());
     if (lr != null) {
       IFacetManifest fm = lr.getFacetProvider().getDescriptor(null).getManifest();
       IFacet fct = fm.lookup(fn);
       if (fct != null) {
         return fct;
       }
     }
   }
   // fallback to the "old" mechanism
   LOG.debug("facet not found, loading using deprecated mechanism " + fn);
   return MapSequence.fromMap(facetMap).get(fn);
 }
Exemplo n.º 4
0
 public void apply() {
   if (myNodesToApply.isEmpty()) {
     return;
   }
   SNode first = myNodesToApply.iterator().next();
   SModel model = first.getModel();
   if (model == null) {
     LOG.warning(
         "Checking node which is not attached to the model: "
             + first.getPresentation()
             + " "
             + first.getNodeId());
     return;
   }
   // XXX could I demand here that model has to be attached to a repository, so that I can use one
   // to obtain LanguageRegistry?
   for (SLanguage language : SModelOperations.getAllLanguageImports(model)) {
     LanguageRuntime languageRuntime = LanguageRegistry.getInstance().getLanguage(language);
     if (languageRuntime == null) {
       continue;
     }
     DataFlowAspectDescriptor aspect = languageRuntime.getAspect(DataFlowAspectDescriptor.class);
     if (aspect == null) {
       continue;
     }
     for (DataFlowConstructor rule : aspect.getConstructors(myAnalyzerId)) {
       myRules.add(rule);
     }
   }
   Set<SNode> descendants = new LinkedHashSet<SNode>();
   for (SNode myNodeToApply : myNodesToApply) {
     descendants.addAll(
         SNodeOperations.getNodeDescendants(
             myNodeToApply, null, false, new SAbstractConcept[] {}));
   }
   for (SNode descendant : descendants) {
     getRules(descendant).forEach(rule -> rule.performActions(myProgram, descendant));
   }
 }