private void setDefaultSuperType(Stereotype subType) { StructPart anyRec = (StructPart) BindingUtil.findPart( NameUtile.getAsName(MofConversion.EGLX_lang_package), NameUtile.getAsName("AnyRecord")); BindingUtil.setDefaultSupertype(recordBinding, subType, anyRec); }
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; }
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()}); } } } } }
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()); }
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; }
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(); }