Examples of EClass


Examples of org.eclipse.emf.ecore.EClass

   * @param model
   */
  private void handleEObject(IdentifyState state, EObject obj) {

    // this is a unique instance of this class type
    EClass cls = obj.eClass();
    state.uniqueClasses.uniqueInstance(cls);
    state.allInstancesCount++;
   
    // keep track of inference rule usage
    if (obj instanceof GeneratedElement) {
      String r = ((GeneratedElement) obj).getGeneratedRule();
      if (r != null) {
        state.inferenceRules.addRule(r);
      }
    }
   
    // keep track of how many supertype references are actually used
    Set<EClass> usedSupertypeReferences = new HashSet<EClass>();
   
    // get all attribute instances
    for (EAttribute attr : cls.getEAllAttributes()) {
      // is it set?
      if (obj.eIsSet(attr)) {
        Object value = obj.eGet(attr);
       
        // is it default?
        if (value != null && !value.equals(attr.getDefaultValue())) {
          // put the value
          state.uniqueAttributes.attributeValue(cls, attr, value);
         
          // keep track of direct container
          usedSupertypeReferences.add(attr.getEContainingClass());
          // and all supertypes
          for (EClass supertype : attr.getEContainingClass().getEAllSuperTypes()) {
            usedSupertypeReferences.add(supertype);
          }
         
        }
      }
    }
   
    // get all EStructuralFeatures
    for (EStructuralFeature ft : cls.getEAllStructuralFeatures()) {
      // is it set?
      if (obj.eIsSet(ft)) {
        // register an instance
        state.featureCount.featureInstance(cls, ft);

View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

    if (!cls.isAbstract())
      return cls;
   
    for (EClass c : ContainmentTestCase.getAllClasses().keySet()) {
      if (cls.isSuperTypeOf(c)) {
        EClass r = findConcreteTypeFor(c);
        if (r != null)
          return r;
      }
    }
   
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

   */
  public void testAllEdgeTypes() throws Exception {
   
    for (EClass typ2 : EdgeTypes.getEdgeTypes()) {
      // make concrete
      EClass typ = findConcreteTypeFor(typ2);
     
      // find the factory for it
      EFactory factory = ContainmentTestCase.getAllClasses().get(typ);
      assertNotNull("Could not find factory for '" + typ.getName() + "'", factory);
     
      // instantiate the object
      EObject obj = factory.create(typ);
     
      // the 'from' and to' should be null, so we need to remove this phantom edge
      assertTrue("We should remove type " + typ.getName() + ": " + obj,
          RemovePhantomEdgesAction.shouldRemove(obj));
    }
   
  }
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

  public void testNonEdgeType() throws Exception {
   
    // for every element type that _isn't_ in the EdgeTypes
    for (EClass typ2 : ContainmentTestCase.getAllClasses().keySet()) {
      // make concrete
      EClass typ = findConcreteTypeFor(typ2);
     
      // make sure it's not a subclass of a known edge
      boolean isEdge = false;
      for (EClass edge : EdgeTypes.getEdgeTypes()) {
        if (edge.isSuperTypeOf(typ))
          isEdge = true;
      }
      if (isEdge) continue;
     
      // find the factory for it
      EFactory factory = ContainmentTestCase.getAllClasses().get(typ);
      assertNotNull("Could not find factory for '" + typ.getName() + "'", factory);
     
      // instantiate the object
      EObject obj = factory.create(typ);
     
      // we should not remove this non-edge object
      assertFalse("Asking to remove non-edge object '" + typ.getName() + "' was unexpectedly successful", RemovePhantomEdgesAction.shouldRemove(obj));
    }
   
  }
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

    for (EMFClass source : root.getClasses()) {
     
      for (EReference ref : source.getTargetClass().getEReferences()) {
       
        // get the destination type
        EClass refDest = ref.getEReferenceType();
        // find the corresponding EMFClass
        EMFClass refDestEMF = getEMFClassFor(root, refDest);
       
        // create a new EMFReference
        EMFReference newRef = factory.createEMFReference();
        newRef.setName(ref.getName());
        newRef.setLowerBound(ref.getLowerBound());
        newRef.setUpperBound(ref.getUpperBound());
        newRef.setContainment(ref.isContainment());
        if (refDestEMF != null) {
          newRef.setType(refDestEMF);
        } else {
          // is there an external class?
          EMFExternalClass refExternalClass = getEMFExternalClassFor(root, refDest);
          if (refExternalClass == null) {
            // we need to create one
            refExternalClass = factory.createEMFExternalClass();
            refExternalClass.setName(refDest.getName());
            EPackage pkg = refDest.getEPackage();
            if (pkg != null) {
              refExternalClass.setTargetClass(refDest);
              refExternalClass.setPackageName(pkg.getName());
              refExternalClass.setPackageURI(pkg.getNsURI());
              refExternalClass.setPackagePrefix(pkg.getNsPrefix());
            }
            root.getExternalClasses().add(refExternalClass);
          }
          newRef.setType(refExternalClass);
        }
        newRef.setTypeName(refDest.getName());
       
        // add tagline
        EMFLoaderHelper helper = new EMFLoaderHelper() {
          @Override
          public List<ITagHandler> getSemanticTagHandlers() {
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

     
      // now find unused features
      TreeIterator<EObject> it = root.eAllContents();
      while (it.hasNext()) {
        EObject e = it.next();
        EClass cls = e.eClass();
        // check all attributes
        for (EAttribute attr : cls.getEAllAttributes()) {
          // is it non-default?
          if (e.eGet(attr) != attr.getDefaultValue()) {
            // yes; remove it from the unused features (if it exists)
            EClass container = attr.getEContainingClass();
            unusedSuperClassFeaturesMap.get(cls).remove(container);
          }
        }
       
        // check all references
        for (EReference ref : cls.getEAllReferences()) {
          if (ref.isMany()) {
            // is it empty?
            if (!((List<?>) e.eGet(ref)).isEmpty()) {
              // no; remove it from the unused features (if it exists)
              EClass container = ref.getEContainingClass();
              unusedSuperClassFeaturesMap.get(cls).remove(container);
            }
          } else {
            // is it null?
            if (e.eGet(ref) != null) {
              // no; remove it from the unused features (if it exists)
              EClass container = ref.getEContainingClass();
              unusedSuperClassFeaturesMap.get(cls).remove(container);
            }
          }
        }
      }
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

        unused.write("</a>");
        if (u.isInterface() && u.getEReferences().isEmpty() && u.getEAttributes().isEmpty()) {
          unused.write(" (empty interface)");
        }
        // do any of this classes supertypes use the reference?
        EClass usedBy = subTypeUses(map, cls, u);
        if (usedBy != null) {
          unused.write(" (used by <a href=\"#");
          unused.write(usedBy.getName());
          unused.write("\">");
          unused.write(usedBy.getName());
          unused.write("</a>)");
        }
        unused.write("</li>");
      }
      unused.write("</ul>");
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

   */
  public void loadEMFClasses(EPackage pkg, ModeldocFactory factory, ModelDocumentation root) {
    for (EClassifier classifier : pkg.getEClassifiers()) {
      if (classifier instanceof EClass) {
       
        EClass cls = (EClass) classifier;
       
        EMFClass c = factory.createEMFClass();
        c.setTargetClass(cls);
        c.setName(cls.getName());
        c.setAbstract(cls.isAbstract());
        c.setInterface(cls.isInterface());

        // add tagline
        {
          JavadocTagElement e = getTaglineForEMFElement(factory, cls);
          if (e != null) {
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

public class Test extends TestCase {

  public void testNewModel() throws Exception {
   
    // get the EClass from IAML
    EClass page = VisualPackage.eINSTANCE.getFrame();
   
    EMFClass c = ModeldocFactory.eINSTANCE.createEMFClass();
    c.setTargetClass(page);

    {
View Full Code Here

Examples of org.eclipse.emf.ecore.EClass

      testParentNameElementsPackage(sub);
    }
   
    for (EClassifier cls : pkg.getEClassifiers()) {
      if (cls instanceof EClass) {
        EClass c = (EClass) cls;
        // ignore abstract classes
        if (!c.isAbstract() && !c.isInterface()) {
          // check each PARENT_NAME_TYPES
          for (EClass typ : PARENT_NAME_TYPES) {
            if (typ.isSuperTypeOf(c)) {
              // it should be in PARENT_NAME_ELEMENTS
              assertParentNameElementsContains(c);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.