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; }
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()}); } } } } }
@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; }
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()}); } } }