ArrayList CtrlSpaceForAttributeName(string fileContent, XamlExpressionContext context) { if (context.ElementPath.Elements.Count == 0) { return(null); } QualifiedName lastElement = context.ElementPath.Elements[context.ElementPath.Elements.Count - 1]; XamlCompilationUnit cu = parseInfo.BestCompilationUnit as XamlCompilationUnit; if (cu == null) { return(null); } IReturnType rt = cu.CreateType(lastElement.Namespace, lastElement.Name); if (rt == null) { return(null); } ArrayList list = new ArrayList(); foreach (IProperty p in rt.GetProperties()) { if (p.IsPublic && p.CanSet) { list.Add(p); } } return(list); }
public ArrayList CtrlSpace(int caretLineNumber, int caretColumn, ParseInformation parseInfo, string fileContent, ExpressionContext expressionContext) { this.parseInfo = parseInfo; this.caretLineNumber = caretLineNumber; this.caretColumn = caretColumn; this.callingClass = parseInfo.BestCompilationUnit.GetInnermostClass(caretLineNumber, caretColumn); this.context = expressionContext as XamlExpressionContext; if (context == null) { return(null); } if (context.AttributeName == null) { return(CtrlSpaceForElement(fileContent)); } else if (context.InAttributeValue) { return(CtrlSpaceForAttributeValue(fileContent, context)); } else { return(CtrlSpaceForAttributeName(fileContent, context)); } }
public ResolveResult Resolve(ExpressionResult expressionResult, ParseInformation parseInfo, string fileContent) { this.resolveExpression = expressionResult.Expression; this.parseInfo = parseInfo; this.caretLineNumber = expressionResult.Region.BeginLine; this.caretColumn = expressionResult.Region.BeginColumn; this.callingClass = parseInfo.BestCompilationUnit.GetInnermostClass(caretLineNumber, caretColumn); this.context = expressionResult.Context as XamlExpressionContext; if (context == null) { return(null); } try { using (XmlTextReader r = new XmlTextReader(new StringReader(fileContent))) { r.WhitespaceHandling = WhitespaceHandling.Significant; // move reader to correct position while (r.Read() && !IsReaderAtTarget(r)) { } if (string.IsNullOrEmpty(context.AttributeName)) { return(ResolveElementName(r)); } else if (context.InAttributeValue) { MemberResolveResult mrr = ResolveAttribute(r, context.AttributeName); if (mrr != null) { return(ResolveAttributeValue(mrr.ResolvedMember, resolveExpression)); } } else { // in attribute name return(ResolveAttribute(r, resolveExpression)); } } return(null); } catch (XmlException) { return(null); } }
ArrayList CtrlSpaceForAttributeValue(string fileContent, XamlExpressionContext context) { ArrayList attributes = CtrlSpaceForAttributeName(fileContent, context); if (attributes != null) { foreach (IProperty p in attributes.OfType <IProperty>()) { if (p.Name == context.AttributeName && p.ReturnType != null) { IClass c = p.ReturnType.GetUnderlyingClass(); if (c != null && c.ClassType == ClassType.Enum) { return(EnumCompletion(c)); } } } } return(null); }