Ejemplo n.º 1
0
 private static void assignDependencies(
     final Statement stm,
     final String keyword,
     final ISyntacticElement elt,
     final Set<Diagnostic> errors) {
   // COMPATIBILITY with the definition of environment
   // if ( !SymbolProto.nonTypeStatements.contains(keyword) ) {
   if (!DescriptionFactory.isStatementProto(keyword)) {
     Set<String> s = varDependenciesOf(stm);
     if (s != null && !s.isEmpty()) {
       elt.setFacet(DEPENDS_ON, new StringListExpressionDescription(s));
     }
     // 25/01/14: this test is cancelled for the moment, as the facet type is now defined earlier
     // when dealing
     // with type var_name;
     // if ( !(stm instanceof S_Var) ) {
     // IExpressionDescription type = elt.getExpressionAt(TYPE);
     // if ( type != null ) {
     // if ( type.toString().equals(keyword) ) {
     // addWarning("Duplicate declaration of type", stm, errors);
     // } else {
     // addWarning("Conflicting declaration of type (" + type + " and " + keyword +
     // "), only the last one will be considered", stm, errors);
     // }
     // }
     // }
   }
 }
Ejemplo n.º 2
0
 private static final Set<String> varDependenciesOf(final Statement s) {
   Set<String> list = new HashSet();
   for (Facet facet : EGaml.getFacetsOf(s)) {
     Expression expr = facet.getExpr();
     if (expr != null) {
       if (expr instanceof VariableRef) {
         list.add(EGaml.getKey.caseVariableRef((VariableRef) expr));
       } else {
         for (TreeIterator<EObject> tree = expr.eAllContents(); tree.hasNext(); ) {
           EObject obj = tree.next();
           if (obj instanceof VariableRef) {
             list.add(EGaml.getKey.caseVariableRef((VariableRef) obj));
           }
         }
       }
     }
   }
   if (list.isEmpty()) {
     return null;
   }
   return list;
 }