private ITypeElement HighlightUndefinedType(IXmlTag tag, string attributeName) { IXmlAttribute attribute = tag.GetAttribute(attributeName); if ((attribute == null) || (attribute.XmlName != attributeName) || (attribute.UnquotedValue == null)) { return null; } string fullQualifiedTypeName = attribute.UnquotedValue; Logger.LogMessage("Type is {0}", fullQualifiedTypeName); Parser parser = new Parser(); IParserError error; parser.Parse(fullQualifiedTypeName, out error); if (error != ParserError.None) { AddHighlighting(attribute, new TypeHighlighting(string.Format("Error in type: {0}", error.Message))); } ITypeElement typeElement = PsiUtils.GetTypeElement(tag, m_Process.Solution, fullQualifiedTypeName); if ((typeElement == null) || (typeElement.Module == null)) { AddHighlighting(attribute, new TypeHighlighting(string.Format("Type '{0}' could not be resolved", fullQualifiedTypeName))); } else { // TODO: put TypeNameParser into Parser and refactor this TypeNameParser typeNameParser = new TypeNameParser(fullQualifiedTypeName, m_Assembly, m_Namespace); string assemblyName = typeNameParser.AssemblyName; if (typeElement.Module.Name != "mscorlib") { BuildSettingsManager buildSettingsManager = BuildSettingsManager.GetInstance(typeElement.GetProjectFiles()[0].GetProject()); if (buildSettingsManager != null) { IAssemblyFile outputAssemblyFile = buildSettingsManager.GetOutputAssemblyFile(); if ((outputAssemblyFile != null) && (outputAssemblyFile.Name != assemblyName)) { AddHighlighting(attribute, new TypeHighlighting(string.Format("Assembly name '{0}' should be '{1}'", assemblyName, outputAssemblyFile.Name))); } } } } return typeElement; }
private static ITypeElement GetPropertyType(IXmlTag node, ITypeElement typeElement) { if (typeElement == null) { return null; } IXmlAttribute attribute = node.GetAttribute("name"); if ((attribute != null) && (attribute.Value != null)) { string propertyName = attribute.UnquotedValue; IProperty property = PsiUtils.GetProperty(typeElement, propertyName); if (property != null) { IDeclaredType declaredType = property.Type as IDeclaredType; if (declaredType != null) { return declaredType.GetTypeElement(); } } } return null; }