private void HighlightUndefinedMappedProperty(IXmlTag xmlTag, string propertyName, IElement nameAttribute, IElement typeAttribute, ITypeElement typeElement, AccessMethod access, string attributeName) { IAccessor propertyGetter = null; IAccessor propertySetter = null; IField field = null; string className = (typeElement == null) ? UndefinedType : typeElement.ShortName; if ((access.Method == AccessMethod.AccessMethodProperty) || (access.Method == AccessMethod.AccessMethodNosetter)) { propertyGetter = PsiUtils.GetPropertyGetter(typeElement, propertyName); HighlightPropertyGetter(propertyName, propertyGetter, nameAttribute, className); } if (access.Method == AccessMethod.AccessMethodProperty) { propertySetter = PsiUtils.GetPropertySetter(typeElement, propertyName); HighlightPropertySetter(propertyName, propertySetter, nameAttribute, className); } if ((access.Method == AccessMethod.AccessMethodField) || (access.Method == AccessMethod.AccessMethodNosetter)) { field = PsiUtils.GetField(typeElement, propertyName, access); HighlightField(access, propertyName, nameAttribute, className, field); } ITypeElement propertyClass = HighlightUndefinedType(xmlTag, attributeName); if ((typeAttribute != null) && (propertyClass != null)) { if (propertyGetter != null) { IDeclaredType getterType = propertyGetter.ReturnType as IDeclaredType; if ((getterType != null) && (!propertyClass.IsDescendantOf(getterType.GetTypeElement()))) { AddHighlighting(typeAttribute, new TypeHighlighting(string.Format("Class name '{0}' should be '{1}' or a descendant for property getter", propertyClass.ShortName, getterType.GetTypeElement().ShortName))); } } if (propertySetter != null) { IDeclaredType setterType = propertySetter.Parameters[0] as IDeclaredType; if ((setterType != null) && (!propertyClass.IsDescendantOf(setterType.GetTypeElement()))) { AddHighlighting(typeAttribute, new TypeHighlighting(string.Format("Class name '{0}' should be '{1}' or a descendant for property setter", propertyClass.ShortName, setterType.GetTypeElement().ShortName))); } } if (field != null) { IDeclaredType fieldType = field.Type as IDeclaredType; if ((fieldType != null) && (!propertyClass.IsDescendantOf(fieldType.GetTypeElement()))) { AddHighlighting(typeAttribute, new TypeHighlighting(string.Format("Class name '{0}' should be '{1}' or a descendant for field '{2}'", propertyClass.ShortName, fieldType.GetTypeElement().ShortName, field.ShortName))); } } } }
private void HighlightField(AccessMethod access, string propertyName, IElement nameAttribute, string className, IField field) { if (field == null) { AddHighlighting(nameAttribute, new PropertyHighlighting(string.Format("Field '{0}' not found in class '{1}'", access.Name(propertyName), className))); } }
private AccessMethod HighlightUndefinedAccessAttribute(IElement accessAttribute, string accessMethod) { Logger.LogMessage("HighlightUndefinedAccessAttribute {0}/{1}", accessAttribute, accessMethod); if (string.IsNullOrEmpty(accessMethod)) { Logger.LogMessage(" default: {0}", m_DefaultAccess); return new AccessMethod(m_DefaultAccess); } AccessMethod access = new AccessMethod(accessMethod); if ((access.Unknown) && (accessAttribute != null)) { AddHighlighting(accessAttribute, new AccessHighlighting(string.Format("Access method '{0}' unknown", accessMethod))); } return access; }