Ejemplo n.º 1
0
 private void setDefaultSuperType(Stereotype subType) {
   StructPart anyRec =
       (StructPart)
           BindingUtil.findPart(
               NameUtile.getAsName(MofConversion.EGLX_lang_package),
               NameUtile.getAsName("AnyRecord"));
   BindingUtil.setDefaultSupertype(recordBinding, subType, anyRec);
 }
Ejemplo n.º 2
0
  private boolean isMofClass(org.eclipse.edt.mof.egl.ExternalType et) {

    if (BindingUtil.getAnnotationWithSimpleName(et, "ClassType") != null) {
      return true;
    }
    if (BindingUtil.getAnnotationWithSimpleName(et, "MofClass") != null) {
      return true;
    }

    return false;
  }
Ejemplo n.º 3
0
 private void checkExtendedTypes(EClass expectedSubtype) {
   for (Iterator iter = externalType.getExtendedTypes().iterator(); iter.hasNext(); ) {
     Name nameAST = (Name) iter.next();
     Type extendedType = nameAST.resolveType();
     if (extendedType != null && !BindingUtil.isEClassProxy(extendedType)) {
       if (!(extendedType instanceof org.eclipse.edt.mof.egl.ExternalType)) {
         problemRequestor.acceptProblem(
             nameAST,
             IProblemRequestor.EXTERNALTYPE_MUST_EXTEND_EXTERNALTYPE,
             new String[] {extendedType.getTypeSignature()});
       } else {
         // Super type must have the same subtype.
         Stereotype superSubtype =
             ((org.eclipse.edt.mof.egl.ExternalType) extendedType).getStereotype();
         if (superSubtype == null
             || (!expectedSubtype.equals(superSubtype.getEClass())
                 && !isMofClass((org.eclipse.edt.mof.egl.ExternalType) extendedType))) {
           problemRequestor.acceptProblem(
               nameAST,
               IProblemRequestor.EXTERNAL_TYPE_SUPER_SUBTYPE_MISMATCH,
               new String[] {extendedType.getTypeSignature()});
         }
       }
     }
   }
 }
Ejemplo n.º 4
0
  public void validate(
      Node errorNode,
      Node target,
      Element targetElement,
      Map<String, Object> allAnnotationsAndFields,
      IProblemRequestor problemRequestor,
      ICompilerOptions compilerOptions) {
    Type type = null;
    if (targetElement instanceof Type) {
      type = (Type) targetElement;
    } else if (targetElement instanceof TypedElement) {
      type = ((TypedElement) targetElement).getType();
    }

    if (type == null) {
      return;
    }

    // Numerics cannot have decimals.
    if (type instanceof FixedPrecisionType) {
      if (((FixedPrecisionType) type).getDecimals() > 0) {
        problemRequestor.acceptProblem(
            errorNode,
            RUIResourceKeys.PROPERTY_INVALID_FOR_DECIMALS,
            IMarker.SEVERITY_ERROR,
            new String[] {IEGLConstants.PROPERTY_TIMEFORMAT},
            RUIResourceKeys.getResourceBundleForKeys());
      }
      return;
    }

    if (type instanceof ParameterizedType) {
      type = ((ParameterizedType) type).getParameterizableType();
    }

    // string, time, and numerics are valid. everything else is invalid.
    if (TypeUtils.Type_STRING.equals(type)
        || TypeUtils.Type_TIME.equals(type)
        || TypeUtils.isNumericType(type)) {
      return;
    }

    problemRequestor.acceptProblem(
        errorNode,
        RUIResourceKeys.PROPERTY_INVALID_FOR_TYPE,
        IMarker.SEVERITY_ERROR,
        new String[] {
          IEGLConstants.PROPERTY_TIMEFORMAT, BindingUtil.getShortTypeString(type, false)
        },
        RUIResourceKeys.getResourceBundleForKeys());
  }
Ejemplo n.º 5
0
  private boolean checkCycles(
      org.eclipse.edt.mof.egl.ExternalType externalType,
      Set<org.eclipse.edt.mof.egl.ExternalType> seen) {
    // Sometimes the binding won't be resolved yet.
    externalType = (org.eclipse.edt.mof.egl.ExternalType) BindingUtil.realize(externalType);

    if (seen.contains(externalType)) {
      return false;
    }

    if (externalTypeBinding.equals(externalType)) {
      return true;
    }

    seen.add(externalType);
    for (StructPart superType : externalType.getSuperTypes()) {
      if (superType instanceof org.eclipse.edt.mof.egl.ExternalType) {
        if (checkCycles((org.eclipse.edt.mof.egl.ExternalType) superType, seen)) {
          return true;
        }
      }
    }
    return false;
  }
Ejemplo n.º 6
0
 private String getName(Member dataBinding) {
   StringBuffer sbName = new StringBuffer(dataBinding.getCaseSensitiveName());
   sbName.append(" : "); // $NON-NLS-1$
   sbName.append(BindingUtil.getShortTypeString(dataBinding.getType(), true));
   return sbName.toString();
 }