예제 #1
0
 @Override
 public String visit(ILet e) throws IVisitor.VisitorException {
   // Simplify does not have let
   // We can create a new temp variable (or function of any quantified parameters)
   // and then use that.
   for (IBinding b : e.bindings()) {
     String r = b.expr().accept(this);
     ISort s = typemap.get(b.expr());
     // FIXME - don't use toString - also need to map to a unique new temporary
     r = (s.isBool() ? "(IFF " : "(EQ ") + b.parameter().accept(this) + " " + r + " )";
     conjuncts.add(r);
   }
   return e.expr().accept(this);
   // throw new VisitorException("Use of let is not yet implemented in the Simplify
   // adapter",e.pos()); // FIXME - let in Simplify
 }
예제 #2
0
 @Override
 public IAttribute setDefault(String defaultValue) {
   IBinding parent = attachedBinding;
   if (parent != null) {
     parent.getSemaphore().lock();
   }
   try {
     if (parent != null) {
       parent.validateMutability();
     }
     return this; // default value cannot be setfor this implementation of IAttribute; simple
                  // ignore it
   } finally {
     if (parent != null) {
       parent.getSemaphore().unlock();
     }
   }
 }
예제 #3
0
 @Override
 public String visit(IBinding e) throws IVisitor.VisitorException {
   //			StringBuilder sb = new StringBuilder();
   //			sb.append(e.parameter().accept(this));
   //			return sb.toString();
   throw new VisitorException(
       "Use of bindings is not yet implemented in the Simplify adapter",
       e.pos()); // FIXME - let in Simplify
 }
예제 #4
0
  /**
   * Creates a list mapper that corresponding to the facilities of the specified type.
   *
   * <p>The mapper is chosen according to the following priorities:
   *
   * <ul>
   *   <li>annotated field
   *   <li>via genmodel label field - requires additional generation of information
   *   <li>by field name: label, name, fullName
   *   <li>by field type: String
   *   <li>{@link #toString()}
   * </ul>
   *
   * @param binding the binding to map
   * @param ec the class to create the mapper for
   * @return the mapper
   */
  public static IClassIdentiferMapper createClassIdentiferMapper(IBinding binding, EClass ec) {
    EStructuralFeature feature;

    /*
     * Any constant string is used first of all...
     *
     * TODO: Problem: if text is specified, icon and other arguments are ignored!
     */
    final String constantText = binding.getArgument(Constants.ARG_TEXT, String.class, null);
    if (constantText != null)
      return new IClassIdentiferMapper() {
        @Override
        public Object map(Object value) {
          return constantText;
        }

        @Override
        public IObservableValue getObservableValue(
            IObservableValue value, EditingDomain editingDomain) {
          return value;
        }
      };

    // Via Annotation
    final String featureNames = binding.getArgument(Constants.ARG_FEATURE_NAME, String.class, null);
    if (featureNames != null) {
      // Pattern.compile("(\\p{L}+)")
      final StringTokenizer st = new StringTokenizer(featureNames, ".");
      EClassifier c = ec;
      final List<EStructuralFeature> sfs = new ArrayList<EStructuralFeature>();
      while (st.hasMoreTokens()) {
        final String name = st.nextToken();
        binding.assertTrue(c instanceof EClass, "Intermidiate features must be references");
        final EClass eClass = (EClass) c;
        feature = eClass.getEStructuralFeature(name);
        binding.assertTrue(
            feature != null,
            "Unknown feature: '"
                + eClass.getName()
                + "."
                + name
                + "' in argument "
                + Constants.ARG_FEATURE_NAME
                + " ("
                + featureNames
                + ")");

        sfs.add(feature);
        c = feature.getEType();
      }

      switch (sfs.size()) {
        case 0:
          LogUtils.error(
              binding,
              "Feature names '" + featureNames + "' does not exist. Ignored.",
              binding.getCreationPoint());
          break;
        case 1:
          return new SingleFeatureMapper(sfs.get(0));
        default:
          return new MultipleFeatureMapper(sfs.toArray(new EStructuralFeature[sfs.size()]));
      }
    }

    // By Field Name
    feature = ec.getEStructuralFeature("label");
    if (feature != null) return new SingleFeatureMapper(feature);
    feature = ec.getEStructuralFeature("name");
    if (feature != null) return new SingleFeatureMapper(feature);
    feature = ec.getEStructuralFeature("fullName");
    if (feature != null) return new SingleFeatureMapper(feature);

    // By Field Type
    for (final EAttribute a : ec.getEAllAttributes()) {
      if (a.getEType() == EcorePackage.Literals.ESTRING) return new SingleFeatureMapper(a);
    }

    // Fall back on toString()....
    return DEFAULT_MAPPER;
  }
 public boolean isEqualTo(IBinding binding) {
   if (binding.isRecovered() && binding.getKind() == IBinding.VARIABLE) {
     return this.getKey().equals(binding.getKey());
   }
   return false;
 }