public String getJavaStubSource(IEObjectDescription description) {
    if (!isJvmDeclaredType(description)) {
      return null;
    }
    QualifiedName qualifiedName = description.getQualifiedName();

    StringBuilder classSignatureBuilder = new StringBuilder();
    if (qualifiedName.getSegments().size() > 1) {
      String string = qualifiedName.toString();
      classSignatureBuilder.append("package " + string.substring(0, string.lastIndexOf('.')) + ";");
      classSignatureBuilder.append("\n");
    }
    classSignatureBuilder.append("public ");
    if (description.getEClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
      if (description.getUserData(JvmTypesResourceDescriptionStrategy.IS_INTERFACE) != null) {
        classSignatureBuilder.append("interface ");
      } else {
        classSignatureBuilder.append("class ");
      }
    } else if (description.getEClass() == TypesPackage.Literals.JVM_ENUMERATION_TYPE) {
      classSignatureBuilder.append("enum ");
    } else if (description.getEClass() == TypesPackage.Literals.JVM_ANNOTATION_TYPE) {
      classSignatureBuilder.append("@interface ");
    }
    classSignatureBuilder.append(qualifiedName.getLastSegment());
    String typeParameters =
        description.getUserData(JvmTypesResourceDescriptionStrategy.TYPE_PARAMETERS);
    if (typeParameters != null) {
      classSignatureBuilder.append(typeParameters);
    }
    classSignatureBuilder.append("{}");
    return classSignatureBuilder.toString();
  }
 public boolean reject(IEObjectDescription element) {
   return element.getEClass() == TerminologyPackage.Literals.ENTRY
       || element.getEClass() == TerminologyPackage.Literals.SUBJECT
       || element.getEClass() == TerminologyPackage.Literals.TERMINOLOGY
       || element.getEClass() == TerminologyPackage.Literals.PRODUCT
       || element.getEClass() == TerminologyPackage.Literals.GR
       || element.getEClass() == TerminologyPackage.Literals.LANGUAGE
       || element.getEClass() == TerminologyPackage.Literals.CUSTOMER;
 }
 protected boolean isJvmDeclaredType(IEObjectDescription description) {
   EClass eClass = description.getEClass();
   return (eClass == TypesPackage.Literals.JVM_GENERIC_TYPE
           || eClass == TypesPackage.Literals.JVM_ENUMERATION_TYPE
           || eClass == TypesPackage.Literals.JVM_ANNOTATION_TYPE)
       && description.getUserData(IS_NESTED_TYPE) == null;
 }
Пример #4
0
 protected boolean isAcceptedByPP(IEObjectDescription od) {
   switch (od.getEClass().getClassifierID()) {
     case PPPackage.HOST_CLASS_DEFINITION:
     case PPPackage.DEFINITION:
     case PPPackage.DEFINITION_ARGUMENT:
     case PPPackage.VARIABLE_EXPRESSION:
     case PPPackage.NODE_DEFINITION:
       return true;
   }
   return false;
 }
Пример #5
0
    protected boolean isClassAccepted(IEObjectDescription od, Collection<EClass> acceptedClasses) {
      EClass eclass = od.getEClass();
      EPackage epackage = eclass.getEPackage();
      // user supplied filter
      if (acceptedClasses != null
          && acceptedClasses.size() != 0
          && !acceptedClasses.contains(eclass)) return false;

      if (epackage == PPPackage.eINSTANCE) return isAcceptedByPP(od);
      if (epackage == PPTPPackage.eINSTANCE) return isAcceptedByPPTP(od);
      return false;
    }
Пример #6
0
  protected void cacheMetaParameters(EObject scopeDetermeningObject) {
    // System.err.println("Computing meta cache");
    metaCache = Maps.newHashMap();
    Resource scopeDetermeningResource = scopeDetermeningObject.eResource();

    IResourceDescriptions descriptionIndex =
        indexProvider.getResourceDescriptions(scopeDetermeningResource);
    IResourceDescription descr =
        descriptionIndex.getResourceDescription(scopeDetermeningResource.getURI());
    if (descr == null) return; // give up - some sort of clean build
    EClass wantedType = PPTPPackage.Literals.TYPE_ARGUMENT;
    for (IContainer visibleContainer : manager.getVisibleContainers(descr, descriptionIndex)) {
      for (IEObjectDescription objDesc : visibleContainer.getExportedObjects()) {
        QualifiedName q = objDesc.getQualifiedName();
        if ("Type".equals(q.getFirstSegment())) {
          if (wantedType == objDesc.getEClass() || wantedType.isSuperTypeOf(objDesc.getEClass()))
            metaCache.put(q.getLastSegment(), objDesc);
        }
      }
    }
  }
Пример #7
0
    protected boolean isAcceptedByPPTP(IEObjectDescription od) {
      // Contributions from .pptp files are not meaningful to open
      String path = od.getEObjectURI().path();
      if (path != null && path.endsWith(".pptp")) return false;

      // all other are ok (i.e. typically from .rb)
      // Only included those that are meaningful for user to open
      switch (od.getEClass().getClassifierID()) {
        case PPTPPackage.TYPE:
        case PPTPPackage.FUNCTION:
        case PPTPPackage.PARAMETER:
        case PPTPPackage.PROPERTY:
        case PPTPPackage.META_TYPE:
        case PPTPPackage.META_VARIABLE:
          return true;
      }
      return false;
    }
Пример #8
0
 protected void expect(Iterator<IEObjectDescription> i, String name, EClass eClass) {
   IEObjectDescription desc = i.next();
   assertEquals(name, converter.toString(desc.getQualifiedName()));
   assertEquals(eClass, desc.getEClass());
 }
 @Override
 public String image(IEObjectDescription description) {
   return description.getEClass().getName() + ".gif";
 }