Example #1
0
 private boolean checkHasSubtype() {
   boolean subtypeValid;
   if (externalType.hasSubType()) {
     subtypeValid = externalTypeBinding.getStereotype() != null;
   } else {
     problemRequestor.acceptProblem(
         externalType.getName(),
         IProblemRequestor.PART_DEFINITION_REQUIRES_TYPE_CLAUSE,
         new String[] {externalType.getName().getCanonicalName()});
     subtypeValid = false;
   }
   return subtypeValid;
 }
Example #2
0
  @Override
  public boolean visit(ExternalType externalType) {
    this.externalType = externalType;
    EGLNameValidator.validate(
        externalType.getName(), EGLNameValidator.HANDLER, problemRequestor, compilerOptions);
    new AnnotationValidator(problemRequestor, compilerOptions)
        .validateAnnotationTarget(externalType);

    if (checkHasSubtype()) {
      checkExtendedTypes(externalTypeBinding.getStereotype().getEClass());
      checkCycles();
    }
    return true;
  }
Example #3
0
 private void checkCycles() {
   for (Name name : externalType.getExtendedTypes()) {
     Type type = name.resolveType();
     if (type instanceof org.eclipse.edt.mof.egl.ExternalType
         && checkCycles(
             (org.eclipse.edt.mof.egl.ExternalType) type,
             new HashSet<org.eclipse.edt.mof.egl.ExternalType>())) {
       problemRequestor.acceptProblem(
           name,
           IProblemRequestor.RECURSIVE_LOOP_IN_EXTENDS,
           new String[] {externalTypeBinding.getCaseSensitiveName(), name.toString()});
     }
   }
 }
Example #4
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;
  }
Example #5
0
  private void checkParameters(List parameters) {

    Stereotype subtype = externalTypeBinding.getStereotype();
    if (subtype != null) {
      // do not validate the parms for NativeType
      EClass clazz = subtype.getEClass();
      if (clazz != null
          && NameUtile.equals(
              clazz.getName(), NameUtile.getAsName(IEGLConstants.PROPERTY_NATIVETYPE))
          && NameUtile.equals(clazz.getPackageName(), NameUtile.getAsName("eglx.lang"))) {
        return;
      }
    }

    for (Iterator iter = parameters.iterator(); iter.hasNext(); ) {
      FunctionParameter parm = (FunctionParameter) iter.next();
      if (parm.isParmConst()) {
        problemRequestor.acceptProblem(
            parm,
            IProblemRequestor.EXTERNALTYPE_PARM_CANNOT_BE_CONST,
            new String[] {parm.getName().getCanonicalName()});
      }
    }
  }