/** {@inheritDoc} Overridden for debugging purposes. */
 @Override
 protected Predicate<Method> getPredicate(EObject context, EReference reference) {
   String methodName =
       "scope_" + reference.getEContainingClass().getName() + "_" + reference.getName();
   //		System.out.println(methodName + " ctx " + context.eClass().getName());
   return PolymorphicDispatcher.Predicates.forName(methodName, 2);
 }
示例#2
0
    public static int kind(EStructuralFeature eStructuralFeature) {
      int result = 0;

      EClassifier eClassifier = eStructuralFeature.getEType();

      if (eClassifier.getInstanceClass() != null) {
        result |= HAS_INSTANCE_CLASS;
      }

      if (eStructuralFeature.isUnsettable()) {
        result |= IS_UNSETTABLE;
      }

      if (eStructuralFeature instanceof EReference) {
        EReference eReference = (EReference) eStructuralFeature;
        EReference inverseEReference = eReference.getEOpposite();
        if (eReference.isContainment()) {
          result |= IS_CONTAINMENT;
        }

        if (inverseEReference != null) {
          // This forces the feature ids to be assigned.
          //
          inverseEReference.getEContainingClass().getFeatureCount();
          result |= HAS_NAVIGABLE_INVERSE;
          if (inverseEReference.isMany()) {
            result |= HAS_MANY_INVERSE;
          }
          if (inverseEReference.isContainment()) {
            result |= IS_CONTAINER;
          }
        }

        if (eReference.isResolveProxies()) {
          result |= HAS_PROXIES;
        }

        result |= IS_EOBJECT;
      } else // if (eStructuralFeature instanceof EAttribute
      {
        if (eClassifier instanceof EEnum) {
          result |= IS_ENUM;
        } else {
          Class<?> instanceClass = eClassifier.getInstanceClass();
          if (instanceClass != null && instanceClass.isPrimitive()) {
            result |= IS_PRIMITIVE;
          }
        }
      }

      if (eStructuralFeature.isUnique()) {
        result |= IS_UNIQUE;
      }

      return result;
    }
示例#3
0
 @Override
 public IScope getScope(EObject context, EReference reference) {
   if (log.isDebugEnabled()) {
     log.debug(
         "enter getScope("
             + context
             + ", "
             + reference.getEContainingClass().getName()
             + "#"
             + reference.getName()
             + ")");
   }
   try {
     if (isFeatureCallScope(reference)) {
       if (!(context instanceof XAbstractFeatureCall)) {
         return IScope.NULLSCOPE;
       }
       return createFeatureCallScope((XAbstractFeatureCall) context, reference);
     }
     if (isConstructorCallScope(reference)) {
       return createConstructorCallScope(context, reference);
     }
     if (isTypeScope(reference)) {
       return createTypeScope(context, reference);
     }
     return super.getScope(context, reference);
   } catch (RuntimeException e) {
     log.error("error during scoping", e);
     throw e;
   } finally {
     if (log.isDebugEnabled()) {
       log.debug(
           "leave getScope("
               + context
               + ", "
               + reference.getEContainingClass().getName()
               + "#"
               + reference.getName()
               + ")");
     }
   }
 }
  /**
   * {@inheritDoc}
   *
   * @generated NOT
   * @see
   *     org.eclipse.emf.emfstore.server.model.versioning.operations.provider.CompositeOperationItemProvider#getChildren(java.lang.Object)
   */
  @SuppressWarnings("unchecked")
  @Override
  public Collection<?> getChildren(Object object) {
    if (object instanceof SemanticCompositeOperation) {
      SemanticCompositeOperation operation = (SemanticCompositeOperation) object;
      ArrayList<Object> result = new ArrayList<Object>();

      OperationsFactory factory = OperationsFactory.eINSTANCE;
      for (EStructuralFeature feature : operation.eClass().getEStructuralFeatures()) {
        if (feature instanceof EReference) {
          EReference reference = (EReference) feature;

          ModelElementGroup referenceGroup = factory.createModelElementGroup();
          String key =
              "_UI_"
                  + reference.getEContainingClass().getName()
                  + "_"
                  + reference.getName()
                  + "_feature";
          referenceGroup.setName(getString(key));
          if (reference.isMany()) {
            List<ModelElementId> value = (List<ModelElementId>) operation.eGet(reference);
            referenceGroup.getModelElements().addAll(value);
          } else {
            ModelElementId value = (ModelElementId) operation.eGet(reference);
            referenceGroup.getModelElements().add(value);
          }
          result.add(referenceGroup);
        }
      }

      OperationGroup detailsGroup = factory.createOperationGroup();
      detailsGroup.setName("Sub Operations");
      detailsGroup.getOperations().addAll(operation.getSubOperations());
      result.add(detailsGroup);

      return result;
    }
    return super.getChildren(object);
  }
  /* (non-Javadoc)
   * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
   */
  public IStatus validate(IValidationContext ctx) {
    if (DependencyChecker.newCheck) {
      return Status.OK_STATUS;
    }
    EObject eObj = ctx.getTarget();
    EMFEventType eType = ctx.getEventType();

    if (DEBUG) {
      if (eObj instanceof NamedElement) {
        NamedElement e = (NamedElement) eObj;
        System.out.println(
            "RelationshipConstraint.validate(): "
                + TngUtil.getTypeText(e)
                + ": '"
                + e.getName()
                + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
    }

    MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, 0, "", null); // $NON-NLS-1$

    // In the case of batch mode.
    if (eType == EMFEventType.NULL) {
      Collection features = new ArrayList(referencesToCheckForCircularDependency);
      features.retainAll(eObj.eClass().getEAllReferences());
      for (Iterator iter = features.iterator(); iter.hasNext(); ) {
        EReference ref = (EReference) iter.next();
        if (ref.isMany()) {
          for (Iterator iterator = ((List) eObj.eGet(ref)).iterator(); iterator.hasNext(); ) {
            Object o = iterator.next();
            IStatus status = DependencyChecker.checkCircularDependency(eObj, ref, o);
            if (!status.isOK()) {
              String msg = status.getMessage();
              if (StrUtil.isBlank(msg)) {
                msg =
                    NLS.bind(
                        ValidationResources.circularDependency_error,
                        ref.getEContainingClass().getName(),
                        ref.getName());
              }
              multiStatus.add(new ValidationStatus(IStatus.ERROR, 0, msg, eObj, ref));
            }
          }
        } else {
          Object o = eObj.eGet(ref);
          if (o != null) {
            IStatus status = DependencyChecker.checkCircularDependency(eObj, ref, o);
            if (!status.isOK()) {
              String msg = status.getMessage();
              if (StrUtil.isBlank(msg)) {
                msg =
                    NLS.bind(
                        ValidationResources.circularDependency_error,
                        ref.getEContainingClass().getName(),
                        ref.getName());
              }
              multiStatus.add(new ValidationStatus(IStatus.ERROR, 0, msg, eObj, ref));
            }
          }
        }
      }

      if (multiStatus.isOK()) {
        return ctx.createSuccessStatus();
      } else {
        return multiStatus;
      }
    }

    return ctx.createSuccessStatus();
  }
示例#6
0
 private Property getSourcePropertyEnd(EReference eReference, Association association) {
   return getPropertyByName(
       association.memberEnd, eReference.getEContainingClass().getName().toLowerCase());
 }