private static boolean doesNotDefineAttributes(final String keyword) {
   SymbolProto p = DescriptionFactory.getProto(keyword, null);
   if (p == null) {
     return true;
   }
   int kind = p.getKind();
   return !STATEMENTS_WITH_ATTRIBUTES.contains(kind);
 }
Example #2
0
 /**
  * Return a list of nature ids based on the natures that have been configured for this project.
  *
  * @return list of configured nature ids.
  * @param project
  */
 public static List getRegisteredRuntimeIDs(IProject project) {
   List result = null;
   String natureID = null;
   if (project != null && project.isAccessible()) {
     Iterator it = EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.iterator();
     while (it.hasNext()) {
       natureID = (String) it.next();
       try {
         if (project.hasNature(natureID)) {
           if (result == null) result = new ArrayList(2);
           result.add(natureID);
         }
       } catch (CoreException e) {
       }
     }
   }
   return result == null ? Collections.EMPTY_LIST : result;
 }
  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;
  }
 private static String convertAssignment(
     final S_Assignment stm,
     String keyword,
     final ISyntacticElement elt,
     final Expression expr,
     final Set<Diagnostic> errors) {
   IExpressionDescription value = convExpr(stm.getValue(), errors);
   if (keyword.endsWith("<-") || keyword.equals(SET)) {
     // Translation of "container[index] <- value" to
     // "put item: value in: container at: index"
     // 20/1/14: Translation of container[index] +<- value" to
     // "add item: value in: container at: index"
     if (expr instanceof Access && expr.getOp().equals("[")) {
       String kw = keyword.equals("+<-") ? ADD : PUT;
       String to = keyword.equals("+<-") ? TO : IN;
       elt.setKeyword(kw);
       addFacet(elt, ITEM, value, errors);
       addFacet(elt, to, convExpr(expr.getLeft(), errors), errors);
       List<Expression> args = EGaml.getExprsOf(((Access) expr).getArgs());
       if (args.size() == 0) {
         // Add facet all: true when no index is provided
         addFacet(elt, ALL, ConstantExpressionDescription.create(true), errors);
       } else {
         if (args.size() == 1) { // Integer index
           addFacet(elt, AT, convExpr(args.get(0), errors), errors);
         } else { // Point index
           IExpressionDescription p =
               new OperatorExpressionDescription(
                   POINT, convExpr(args.get(0), errors), convExpr(args.get(1), errors));
           addFacet(elt, AT, p, errors);
         }
       }
       keyword = kw;
     } else {
       // Translation of "var <- value" to "set var value: value"
       elt.setKeyword(SET);
       addFacet(elt, VALUE, value, errors);
       keyword = SET;
     }
   } else if (keyword.startsWith("<<") || keyword.equals("<+")) {
     // Translation of "container <+ item" or "container << item" to "add item: item to: container"
     // 08/01/14: Addition of the "<<+" (add all)
     elt.setKeyword(ADD);
     addFacet(elt, TO, convExpr(expr, errors), errors);
     addFacet(elt, ITEM, value, errors);
     if (keyword.equals("<<+")) {
       addFacet(elt, ALL, ConstantExpressionDescription.create(true), errors);
     }
     keyword = ADD;
   } else if (keyword.startsWith(">>") || keyword.equals(">-")) {
     // Translation of "container >> item" or "container >- item" to
     // "remove item: item from: container"
     // 08/01/14: Addition of the ">>-" keyword (remove all)
     elt.setKeyword(REMOVE);
     // 20/01/14: Addition of the access [] to remove from the index
     if (expr instanceof Access
         && expr.getOp().equals("[")
         && EGaml.getExprsOf(((Access) expr).getArgs()).size() == 0) {
       addFacet(elt, FROM, convExpr(expr.getLeft(), errors), errors);
       addFacet(elt, INDEX, value, errors);
     } else {
       addFacet(elt, FROM, convExpr(expr, errors), errors);
       addFacet(elt, ITEM, value, errors);
     }
     if (keyword.equals(">>-")) {
       addFacet(elt, ALL, ConstantExpressionDescription.create(true), errors);
     }
     keyword = REMOVE;
   } else if (keyword.equals(EQUATION_OP)) {
     // conversion of left member (either a var or a function)
     IExpressionDescription left = null;
     if (expr instanceof VariableRef) {
       left = new OperatorExpressionDescription(ZERO, convExpr(expr, errors));
     } else {
       left = convExpr(expr, errors);
     }
     addFacet(elt, EQUATION_LEFT, left, errors);
     // Translation of right member
     addFacet(elt, EQUATION_RIGHT, value, errors);
   }
   return keyword;
 }