Example #1
0
 public static Collection<String> getUsedLanguageNamespaces(
     SModel model, boolean isTemplateModel) {
   if (isTemplateModel) {
     return getUsedLanguageNamespacesInTemplateModel(model);
   }
   if (SModelStereotype.isGeneratorModel(model)) {
     TemplateModelScanner templateModelScanner = new TemplateModelScanner(model);
     templateModelScanner.scan();
     Set<String> namespaces = new HashSet<String>(templateModelScanner.getQueryLanguages());
     for (SModuleReference ref :
         ((jetbrains.mps.smodel.SModelInternal) model).engagedOnGenerationLanguages()) {
       namespaces.add(ref.getModuleName());
     }
     return namespaces;
   }
   Set<String> namespaces = new HashSet<String>();
   for (SModuleReference ref :
       ((jetbrains.mps.smodel.SModelInternal) model).engagedOnGenerationLanguages()) {
     namespaces.add(ref.getModuleName());
   }
   for (SNode root : model.getRootNodes()) {
     namespaces.add(NameUtil.namespaceFromConceptFQName(root.getConcept().getId()));
     for (SNode child : jetbrains.mps.util.SNodeOperations.getDescendants(root, null)) {
       namespaces.add(NameUtil.namespaceFromConceptFQName(child.getConcept().getId()));
     }
   }
   // empty behavior model should have it's behavior aspect descriptor generated
   if (model.getModule() instanceof Language && LanguageAspect.BEHAVIOR.is(model)) {
     namespaces.add(BootstrapLanguages.BEHAVIOR.getModuleName());
   }
   return namespaces;
 }
Example #2
0
  @Override
  public List<String> getWarnings() {
    List<String> warnings = new ArrayList<String>(super.getWarnings());
    Set<String> usedLanguages = new HashSet<String>();
    for (SModel model : myModule.getOwnTemplateModels()) {
      if (SModelStereotype.isGeneratorModel(model)) {
        usedLanguages.addAll(ModelContentUtil.getUsedLanguageNamespacesInTemplateModel(model));
      }
    }
    Set<String> extendedLanguages = new HashSet<String>();
    Language sourceLanguage = myModule.getSourceLanguage();
    usedLanguages.remove(sourceLanguage.getModuleName());

    Set<Language> ext = new LinkedHashSet<Language>();
    sourceLanguage.getDependenciesManager().collectAllExtendedLanguages(ext);

    for (Language language : ext) {
      extendedLanguages.add(language.getModuleName());
    }

    for (String lang : usedLanguages) {
      Language language = ModuleRepositoryFacade.getInstance().getModule(lang, Language.class);
      if (language == null) continue;

      if (!extendedLanguages.contains(lang) && !language.getRuntimeModulesReferences().isEmpty()) {
        warnings.add(sourceLanguage + " should extend " + lang);
      }
    }
    return warnings;
  }
  private boolean checkResolvedTarget(AbstractTemplateGenerator generator, SNode outputTargetNode) {
    Status status =
        generator
            .getReferentRoleValidator(myOutputSourceNode, myReferenceRole)
            .validate(outputTargetNode);
    if (status != null) {
      generator
          .getLogger()
          .error(
              myOutputSourceNode.getReference(),
              status.getMessage(getClass().getSimpleName()),
              getErrorDescriptions());
      return false;
    }

    SModel referentNodeModel = outputTargetNode.getModel();
    if (referentNodeModel != null && referentNodeModel != myOutputSourceNode.getModel()) {
      if (SModelStereotype.isGeneratorModel(referentNodeModel)) {
        // references to template nodes are not acceptable
        String msg = "bad reference, cannot refer to a generator model: %s for role '%s' in %s";
        generator
            .getLogger()
            .error(
                myOutputSourceNode.getReference(),
                String.format(
                    msg,
                    SNodeUtil.getDebugText(outputTargetNode),
                    myReferenceRole,
                    SNodeUtil.getDebugText(myOutputSourceNode)),
                getErrorDescriptions());
        return false;
      }
      if (referentNodeModel.getModule() instanceof TransientModelsModule) {
        // references to transient nodes in a model outside one being generated are not acceptable
        String msg =
            "bad reference, cannot refer to an external transient model: %s  for role '%s' in %s";
        generator
            .getLogger()
            .error(
                myOutputSourceNode.getReference(),
                String.format(
                    msg,
                    SNodeUtil.getDebugText(outputTargetNode),
                    myReferenceRole,
                    SNodeUtil.getDebugText(myOutputSourceNode)),
                getErrorDescriptions());
        return false;
      }
    }
    return true;
  }
 public static boolean static_canBeARoot(SModel model, final IOperationContext operationContext) {
   return LanguageAspect.EDITOR.is(model) || SModelStereotype.isGeneratorModel(model);
 }
Example #5
0
 public static boolean call_isInTemplates_1213877396627(SNode thisNode) {
   return SModelStereotype.isGeneratorModel(SNodeOperations.getModel(thisNode));
 }
 private static boolean staticCanBeARoot(SModel model, final IOperationContext operationContext) {
   return SModuleOperations.isAspect(model, "editor") || SModelStereotype.isGeneratorModel(model);
 }