Ejemplo n.º 1
0
 private static void convertBlock(
     final Statement stm, final ISyntacticElement elt, final Set<Diagnostic> errors) {
   Block block = stm.getBlock();
   if (block != null) {
     Expression function = block.getFunction();
     if (function != null) {
       // If it is a function (and not a regular block), we add it as a facet
       addFacet(elt, FUNCTION, convExpr(function, errors), errors);
     } else {
       convStatements(elt, EGaml.getStatementsOf(block), errors);
     }
   }
 }
Ejemplo n.º 2
0
 private static void convElse(
     final S_If stm, final ISyntacticElement elt, final Set<Diagnostic> errors) {
   EObject elseBlock = stm.getElse();
   if (elseBlock != null) {
     ISyntacticElement elseElt =
         SyntacticFactory.create(ELSE, elseBlock, EGaml.hasChildren(elseBlock));
     if (elseBlock instanceof Statement) {
       elseElt.addChild(convStatement(elt, (Statement) elseBlock, errors));
     } else {
       convStatements(elseElt, EGaml.getStatementsOf((Block) elseBlock), errors);
     }
     elt.addChild(elseElt);
   }
 }
Ejemplo n.º 3
0
  public static SyntacticModelElement buildSyntacticContents(
      final EObject root, final Set<Diagnostic> errors) {
    if (!(root instanceof Model)) {
      return null;
    }
    ModelImpl m = (ModelImpl) root;
    Object[] imps;
    if (m.eIsSet(GamlPackage.MODEL__IMPORTS)) {
      List<Import> imports = m.getImports();
      imps = new Object[imports.size()];
      for (int i = 0; i < imps.length; i++) {
        URI uri = URI.createURI(imports.get(i).getImportURI(), false);
        imps[i] = uri;
      }
    } else {
      imps = null;
    }

    SyntacticModelElement model =
        (SyntacticModelElement) SyntacticFactory.create(MODEL, m, EGaml.hasChildren(m), imps);
    model.setFacet(NAME, convertToLabel(null, m.getName()));
    convStatements(model, EGaml.getStatementsOf(m), errors);
    return model;
  }