@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; }
@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); } }
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)); } }