IEnumerable <ICompletionItem> CreateEventCompletion(XamlCompletionContext context, ITypeDefinition td) { IMethod invoker = td.GetMethods(method => method.Name == "Invoke").FirstOrDefault(); if (invoker != null && context.ActiveElement != null) { var item = context.ActiveElement; var resolver = new XamlAstResolver(compilation, context.ParseInformation); var mrr = resolver.ResolveAttribute(context.Attribute) as MemberResolveResult; IEvent evt; if (mrr == null || (evt = mrr.Member as IEvent) == null) { return(EmptyList <ICompletionItem> .Instance); } int offset = XmlEditor.XmlParser.GetActiveElementStartIndex(context.Editor.Document.Text, context.Editor.Caret.Offset); if (offset == -1) { return(Enumerable.Empty <ICompletionItem>()); } var loc = context.Editor.Document.GetLocation(offset); string name = context.ActiveElement.GetAttributeValue("Name"); if (string.IsNullOrEmpty(name)) { name = context.ActiveElement.GetAttributeValue(XamlConst.XamlNamespace, "Name"); } return(FindMatchingEventHandlers(context, evt, (string.IsNullOrEmpty(name) ? item.Name : name))); } return(EmptyList <ICompletionItem> .Instance); }
void FindReferencesInFile(SymbolSearchArgs searchArguments, ISymbol entity, FileName fileName, Action <SearchedFile> callback, CancellationToken cancellationToken) { ITextSource textSource = searchArguments.ParseableFileContentFinder.Create(fileName); if (textSource == null) { return; } int offset = textSource.IndexOf(entity.Name, 0, textSource.TextLength, StringComparison.Ordinal); if (offset < 0) { return; } var parseInfo = SD.ParserService.Parse(fileName, textSource) as XamlFullParseInformation; if (parseInfo == null) { return; } ReadOnlyDocument document = null; IHighlighter highlighter = null; List <SearchResultMatch> results = new List <SearchResultMatch>(); XamlAstResolver resolver = new XamlAstResolver(compilation, parseInfo); do { if (document == null) { document = new ReadOnlyDocument(textSource, fileName); highlighter = SD.EditorControlService.CreateHighlighter(document); highlighter.BeginHighlighting(); } var result = resolver.ResolveAtLocation(document.GetLocation(offset + entity.Name.Length / 2 + 1), cancellationToken); int length = entity.Name.Length; if ((result is TypeResolveResult && ((TypeResolveResult)result).Type.Equals(entity)) || (result is MemberResolveResult && ((MemberResolveResult)result).Member.Equals(entity))) { var region = new DomRegion(fileName, document.GetLocation(offset), document.GetLocation(offset + length)); var builder = SearchResultsPad.CreateInlineBuilder(region.Begin, region.End, document, highlighter); results.Add(new SearchResultMatch(fileName, document.GetLocation(offset), document.GetLocation(offset + length), offset, length, builder, highlighter.DefaultTextColor)); } offset = textSource.IndexOf(entity.Name, offset + length, textSource.TextLength - offset - length, StringComparison.OrdinalIgnoreCase); } while (offset > 0); if (highlighter != null) { highlighter.Dispose(); } if (results.Count > 0) { callback(new SearchedFile(fileName, results)); } }
bool DoAttributeCompletion(XamlCompletionContext context, XamlCompletionItemList completionList) { XamlAstResolver resolver = new XamlAstResolver(compilation, context.ParseInformation); ITextEditor editor = context.Editor; var mrr = resolver.ResolveAttribute(context.Attribute) as MemberResolveResult; if (mrr != null && mrr.Type.Kind != TypeKind.Unknown) { completionList.Items.AddRange(generator.MemberCompletion(context, mrr.Type, string.Empty)); editor.ShowInsightWindow(generator.MemberInsight(mrr)); editor.ShowCompletionWindow(completionList); switch (mrr.Type.FullName) { case "System.Windows.PropertyPath": string start = editor.GetWordBeforeCaretExtended(); int index = start.LastIndexOfAny(PropertyPathTokenizer.ControlChars); if (index + 1 < start.Length) { start = start.Substring(index + 1); } else { start = ""; } completionList.PreselectionLength = start.Length; break; case "System.Windows.Media.FontFamily": string text = context.ValueStartOffset > -1 ? context.RawAttributeValue.Substring(0, Math.Min(context.ValueStartOffset, context.RawAttributeValue.Length)) : ""; int lastComma = text.LastIndexOf(','); completionList.PreselectionLength = lastComma == -1 ? context.ValueStartOffset : context.ValueStartOffset - lastComma - 1; break; } } return(completionList.Items.Any()); }
bool DoAttributeCompletion(XamlCompletionContext context, XamlCompletionItemList completionList) { XamlAstResolver resolver = new XamlAstResolver(compilation, context.ParseInformation); ITextEditor editor = context.Editor; var mrr = resolver.ResolveAttribute(context.Attribute) as MemberResolveResult; if (mrr != null && mrr.Type.Kind != TypeKind.Unknown) { completionList.Items.AddRange(generator.MemberCompletion(context, mrr.Type, string.Empty)); editor.ShowInsightWindow(generator.MemberInsight(mrr)); editor.ShowCompletionWindow(completionList); switch (mrr.Type.FullName) { case "System.Windows.PropertyPath": string start = editor.GetWordBeforeCaretExtended(); int index = start.LastIndexOfAny(PropertyPathTokenizer.ControlChars); if (index + 1 < start.Length) { start = start.Substring(index + 1); } else { start = ""; } completionList.PreselectionLength = start.Length; break; case "System.Windows.Media.FontFamily": string text = context.ValueStartOffset > -1 ? context.RawAttributeValue.Substring(0, Math.Min(context.ValueStartOffset, context.RawAttributeValue.Length)) : ""; int lastComma = text.LastIndexOf(','); completionList.PreselectionLength = lastComma == -1 ? context.ValueStartOffset : context.ValueStartOffset - lastComma - 1; break; } } return completionList.Items.Any(); }
IEnumerable<ICompletionItem> CreateEventCompletion(XamlCompletionContext context, ITypeDefinition td) { IMethod invoker = td.GetMethods(method => method.Name == "Invoke").FirstOrDefault(); if (invoker != null && context.ActiveElement != null) { var item = context.ActiveElement; var resolver = new XamlAstResolver(compilation, context.ParseInformation); var mrr = resolver.ResolveAttribute(context.Attribute) as MemberResolveResult; IEvent evt; if (mrr == null || (evt = mrr.Member as IEvent) == null) return EmptyList<ICompletionItem>.Instance; int offset = XmlEditor.XmlParser.GetActiveElementStartIndex(context.Editor.Document.Text, context.Editor.Caret.Offset); if (offset == -1) return Enumerable.Empty<ICompletionItem>(); var loc = context.Editor.Document.GetLocation(offset); string name = context.ActiveElement.GetAttributeValue("Name"); if (string.IsNullOrEmpty(name)) name = context.ActiveElement.GetAttributeValue(XamlConst.XamlNamespace, "Name"); return FindMatchingEventHandlers(context, evt, (string.IsNullOrEmpty(name) ? item.Name : name)); } return EmptyList<ICompletionItem>.Instance; }
public XamlCompletionItemList CreateListForContext(XamlCompletionContext context) { XamlCompletionItemList list = new XamlCompletionItemList(context); ITextEditor editor = context.Editor; compilation = SD.ParserService.GetCompilationForFile(editor.FileName); XamlAstResolver resolver = new XamlAstResolver(compilation, context.ParseInformation); switch (context.Description) { case XamlContextDescription.None: if (context.Forced) { list.Items.AddRange(standardElements); list.Items.AddRange(CreateElementList(context, false)); AddClosingTagCompletion(context, list, resolver); } break; case XamlContextDescription.AtTag: if ((editor.Caret.Offset > 0 && editor.Document.GetCharAt(editor.Caret.Offset - 1) == '.') || context.PressedKey == '.') { list.Items.AddRange(CreateAttributeList(context, false)); } else { list.Items.AddRange(standardElements); list.Items.AddRange(CreateElementList(context, false)); AddClosingTagCompletion(context, list, resolver); } break; case XamlContextDescription.InTag: string word = editor.GetWordBeforeCaretExtended(); if (context.PressedKey == '.' || word.Contains(".")) { int pos = word.IndexOf(':'); string element = word.Substring(pos + 1, word.Length - pos - 1); string className = word; int propertyStart = element.IndexOf('.'); if (propertyStart != -1) { element = element.Substring(0, propertyStart).TrimEnd('.'); className = className.Substring(0, propertyStart + pos + 1).TrimEnd('.'); } int caretOffset = editor.Caret.Offset; int offset = editor.Document.LastIndexOf(className, caretOffset - word.Length, word.Length, StringComparison.OrdinalIgnoreCase); TextLocation loc = editor.Document.GetLocation(offset); XamlFullParseInformation info = context.ParseInformation; XamlResolver nameResolver = new XamlResolver(compilation); TypeResolveResult trr = nameResolver.ResolveExpression(className, context) as TypeResolveResult; ITypeDefinition typeClass = trr != null ? trr.Type.GetDefinition() : null; if (typeClass != null && typeClass.HasAttached(true, true)) list.Items.AddRange(GetListOfAttached(context, typeClass, true, true)); } else { list.Items.AddRange(CreateAttributeList(context, true)); list.Items.AddRange(standardAttributes); } break; case XamlContextDescription.InAttributeValue: new XamlCodeCompletionBinding().CtrlSpace(editor); break; } list.SortItems(); return list; }
void AddClosingTagCompletion(XamlContext context, DefaultCompletionItemList list, XamlAstResolver resolver) { if (context.ParentElement != null && !context.InRoot) { ResolveResult rr = resolver.ResolveElement(context.ParentElement); TypeResolveResult trr = rr as TypeResolveResult; MemberResolveResult mrr = rr as MemberResolveResult; if (trr != null) { if (trr.IsError) return; list.Items.Add(new XamlCompletionItem("/" + context.ParentElement.Name, trr.Type.GetDefinition())); } else if (mrr != null) { if (mrr.IsError) return; list.Items.Add(new XamlCompletionItem("/" + context.ParentElement.Name, mrr.Member)); } } }
/// <summary> /// Returns the list of allow XAML2009 completion items. /// </summary> public static IEnumerable<string> GetAllowedItems(XamlCompletionContext context) { string xamlPrefix = context.XamlNamespacePrefix; string xKey = string.IsNullOrEmpty(xamlPrefix) ? "" : xamlPrefix + ":"; var compilation = SD.ParserService.GetCompilationForFile(context.Editor.FileName); var resolver = new XamlAstResolver(compilation, context.ParseInformation); // TODO : add support for x:Key as attribute element (XAML 2009 only) switch (context.Description) { case XamlContextDescription.AtTag: if (context.ParentElement != null && string.Equals(context.ParentElement.Name, xKey + "Members", StringComparison.OrdinalIgnoreCase)) { yield return xKey + "Member"; yield return xKey + "Property"; } else if (context.ParentElement == context.RootElement && context.RootElement.Attributes.Any(attr => string.Equals(attr.Name, xKey + "Class", StringComparison.OrdinalIgnoreCase))) { yield return xKey + "Code"; yield return xKey + "Members"; } else { if (context.ParentElement != null && string.Equals(context.ParentElement.Name, xKey + "Code", StringComparison.OrdinalIgnoreCase)) yield break; yield return xKey + "Array"; yield return xKey + "Boolean"; yield return xKey + "Byte"; yield return xKey + "Char"; yield return xKey + "Decimal"; yield return xKey + "Dictionary"; yield return xKey + "Double"; yield return xKey + "Int16"; yield return xKey + "Int32"; yield return xKey + "Int64"; yield return xKey + "List"; yield return xKey + "Object"; yield return xKey + "Reference"; yield return xKey + "Single"; yield return xKey + "String"; yield return xKey + "TimeSpan"; yield return xKey + "Uri"; if (context.RootElement.Attributes.Any(attr => string.Equals(attr.Name, xKey + "Class", StringComparison.OrdinalIgnoreCase))) yield return xKey + "Members"; } break; case XamlContextDescription.InTag: yield return xKey + "Uid"; if (context.InRoot) { yield return xKey + "Class"; yield return xKey + "ClassModifier"; yield return xKey + "Subclass"; yield return xKey + "Name"; } else { var resourceDictionaryType = compilation.FindType(typeof(ResourceDictionary)); if (context.ActiveElement != null && string.Equals(context.ActiveElement.Name, xKey + "Array", StringComparison.OrdinalIgnoreCase)) { yield return "Type"; } else if (context.ActiveElement != null && string.Equals(context.ActiveElement.Name, xKey + "Member", StringComparison.OrdinalIgnoreCase)) { yield return "Name"; } else if (context.ActiveElement != null && string.Equals(context.ActiveElement.Name, xKey + "Property", StringComparison.OrdinalIgnoreCase)) { yield return "Name"; yield return "Type"; } else if (context.RootElement.Attributes.Any(attr => string.Equals(attr.Name, xKey + "Class", StringComparison.OrdinalIgnoreCase))) { yield return xKey + "FieldModifier"; yield return xKey + "Name"; } else { yield return xKey + "Name"; } if (context.ParentElement != null) { var rr = resolver.ResolveElement(context.ParentElement); if (rr != null) { if (rr.Type.Equals(resourceDictionaryType)) { yield return xKey + "Key"; yield return xKey + "Shared"; } else if (rr.Type.TypeParameterCount > 0) { yield return xKey + "TypeArguments"; } } } } break; } yield break; }
void FindReferencesInFile(SymbolSearchArgs searchArguments, ISymbol entity, FileName fileName, Action<SearchedFile> callback, CancellationToken cancellationToken) { ITextSource textSource = searchArguments.ParseableFileContentFinder.Create(fileName); if (textSource == null) return; int offset = textSource.IndexOf(entity.Name, 0, textSource.TextLength, StringComparison.Ordinal); if (offset < 0) return; var parseInfo = SD.ParserService.Parse(fileName, textSource) as XamlFullParseInformation; if (parseInfo == null) return; ReadOnlyDocument document = null; IHighlighter highlighter = null; List<SearchResultMatch> results = new List<SearchResultMatch>(); XamlAstResolver resolver = new XamlAstResolver(compilation, parseInfo); do { if (document == null) { document = new ReadOnlyDocument(textSource, fileName); highlighter = SD.EditorControlService.CreateHighlighter(document); highlighter.BeginHighlighting(); } var result = resolver.ResolveAtLocation(document.GetLocation(offset + entity.Name.Length / 2 + 1), cancellationToken); int length = entity.Name.Length; if ((result is TypeResolveResult && ((TypeResolveResult)result).Type.Equals(entity)) || (result is MemberResolveResult && ((MemberResolveResult)result).Member.Equals(entity))) { var region = new DomRegion(fileName, document.GetLocation(offset), document.GetLocation(offset + length)); var builder = SearchResultsPad.CreateInlineBuilder(region.Begin, region.End, document, highlighter); results.Add(new SearchResultMatch(fileName, document.GetLocation(offset), document.GetLocation(offset + length), offset, length, builder, highlighter.DefaultTextColor)); } offset = textSource.IndexOf(entity.Name, offset + length, textSource.TextLength - offset - length, StringComparison.OrdinalIgnoreCase); } while (offset > 0); if (highlighter != null) { highlighter.Dispose(); } if (results.Count > 0) callback(new SearchedFile(fileName, results)); }
void RenameReferencesInFile(SymbolRenameArgs args, FileName fileName, Action<PatchedFile> callback, Action<Error> errorCallback, bool isNameValid, CancellationToken cancellationToken) { ITextSource textSource = args.ParseableFileContentFinder.Create(fileName); if (textSource == null) return; int offset = textSource.IndexOf(entity.Name, 0, textSource.TextLength, StringComparison.Ordinal); if (offset < 0) return; var parseInfo = SD.ParserService.Parse(fileName, textSource) as XamlFullParseInformation; if (parseInfo == null) return; ReadOnlyDocument document = null; IHighlighter highlighter = null; List<RenameResultMatch> results = new List<RenameResultMatch>(); XamlAstResolver resolver = new XamlAstResolver(compilation, parseInfo); string newCode = args.NewName; do { if (document == null) { document = new ReadOnlyDocument(textSource, fileName); highlighter = SD.EditorControlService.CreateHighlighter(document); highlighter.BeginHighlighting(); } var result = resolver.ResolveAtLocation(document.GetLocation(offset + entity.Name.Length / 2 + 1), cancellationToken); int length = entity.Name.Length; if ((result is TypeResolveResult && ((TypeResolveResult)result).Type.Equals(entity)) || (result is MemberResolveResult && ((MemberResolveResult)result).Member.Equals(entity))) { var region = new DomRegion(fileName, document.GetLocation(offset), document.GetLocation(offset + length)); var builder = SearchResultsPad.CreateInlineBuilder(region.Begin, region.End, document, highlighter); results.Add(new RenameResultMatch(fileName, document.GetLocation(offset), document.GetLocation(offset + length), offset, length, newCode, builder, highlighter.DefaultTextColor)); } offset = textSource.IndexOf(entity.Name, offset + length, textSource.TextLength - offset - length, StringComparison.OrdinalIgnoreCase); } while (offset > 0); if (highlighter != null) { highlighter.Dispose(); } if (results.Count > 0) { if (!isNameValid) { errorCallback(new Error(ErrorType.Error, string.Format("The name '{0}' is not valid in the current context!", args.NewName), new DomRegion(fileName, results[0].StartLocation))); return; } IDocument changedDocument = new TextDocument(document); var oldVersion = changedDocument.Version; foreach (var result in results.OrderByDescending(m => m.StartOffset)) { changedDocument.Replace(result.StartOffset, result.Length, result.NewCode); } callback(new PatchedFile(fileName, results, oldVersion, changedDocument.Version)); } }
public XamlCompletionItemList CreateListForContext(XamlCompletionContext context) { XamlCompletionItemList list = new XamlCompletionItemList(context); ITextEditor editor = context.Editor; compilation = SD.ParserService.GetCompilationForFile(editor.FileName); XamlAstResolver resolver = new XamlAstResolver(compilation, context.ParseInformation); switch (context.Description) { case XamlContextDescription.None: if (context.Forced) { list.Items.AddRange(standardElements); list.Items.AddRange(CreateElementList(context, false)); AddClosingTagCompletion(context, list, resolver); } break; case XamlContextDescription.AtTag: if ((editor.Caret.Offset > 0 && editor.Document.GetCharAt(editor.Caret.Offset - 1) == '.') || context.PressedKey == '.') { list.Items.AddRange(CreateAttributeList(context, false)); } else { list.Items.AddRange(standardElements); list.Items.AddRange(CreateElementList(context, false)); AddClosingTagCompletion(context, list, resolver); } break; case XamlContextDescription.InTag: string word = editor.GetWordBeforeCaretExtended(); if (context.PressedKey == '.' || word.Contains(".")) { int pos = word.IndexOf(':'); string element = word.Substring(pos + 1, word.Length - pos - 1); string className = word; int propertyStart = element.IndexOf('.'); if (propertyStart != -1) { element = element.Substring(0, propertyStart).TrimEnd('.'); className = className.Substring(0, propertyStart + pos + 1).TrimEnd('.'); } int caretOffset = editor.Caret.Offset; int offset = editor.Document.LastIndexOf(className, caretOffset - word.Length, word.Length, StringComparison.OrdinalIgnoreCase); TextLocation loc = editor.Document.GetLocation(offset); XamlFullParseInformation info = context.ParseInformation; XamlResolver nameResolver = new XamlResolver(compilation); TypeResolveResult trr = nameResolver.ResolveExpression(className, context) as TypeResolveResult; ITypeDefinition typeClass = trr != null?trr.Type.GetDefinition() : null; if (typeClass != null && typeClass.HasAttached(true, true)) { list.Items.AddRange(GetListOfAttached(context, typeClass, true, true)); } } else { list.Items.AddRange(CreateAttributeList(context, true)); list.Items.AddRange(standardAttributes); } break; case XamlContextDescription.InAttributeValue: new XamlCodeCompletionBinding().CtrlSpace(editor); break; } list.SortItems(); return(list); }
void AddClosingTagCompletion(XamlContext context, DefaultCompletionItemList list, XamlAstResolver resolver) { if (context.ParentElement != null && !context.InRoot) { ResolveResult rr = resolver.ResolveElement(context.ParentElement); TypeResolveResult trr = rr as TypeResolveResult; MemberResolveResult mrr = rr as MemberResolveResult; if (trr != null) { if (trr.IsError) { return; } list.Items.Add(new XamlCompletionItem("/" + context.ParentElement.Name, trr.Type.GetDefinition())); } else if (mrr != null) { if (mrr.IsError) { return; } list.Items.Add(new XamlCompletionItem("/" + context.ParentElement.Name, mrr.Member)); } } }
void RenameReferencesInFile(SymbolRenameArgs args, FileName fileName, Action <PatchedFile> callback, Action <Error> errorCallback, bool isNameValid, CancellationToken cancellationToken) { ITextSource textSource = args.ParseableFileContentFinder.Create(fileName); if (textSource == null) { return; } int offset = textSource.IndexOf(entity.Name, 0, textSource.TextLength, StringComparison.Ordinal); if (offset < 0) { return; } var parseInfo = SD.ParserService.Parse(fileName, textSource) as XamlFullParseInformation; if (parseInfo == null) { return; } ReadOnlyDocument document = null; IHighlighter highlighter = null; List <RenameResultMatch> results = new List <RenameResultMatch>(); XamlAstResolver resolver = new XamlAstResolver(compilation, parseInfo); string newCode = args.NewName; do { if (document == null) { document = new ReadOnlyDocument(textSource, fileName); highlighter = SD.EditorControlService.CreateHighlighter(document); highlighter.BeginHighlighting(); } var result = resolver.ResolveAtLocation(document.GetLocation(offset + entity.Name.Length / 2 + 1), cancellationToken); int length = entity.Name.Length; if ((result is TypeResolveResult && ((TypeResolveResult)result).Type.Equals(entity)) || (result is MemberResolveResult && ((MemberResolveResult)result).Member.Equals(entity))) { var region = new DomRegion(fileName, document.GetLocation(offset), document.GetLocation(offset + length)); var builder = SearchResultsPad.CreateInlineBuilder(region.Begin, region.End, document, highlighter); results.Add(new RenameResultMatch(fileName, document.GetLocation(offset), document.GetLocation(offset + length), offset, length, newCode, builder, highlighter.DefaultTextColor)); } offset = textSource.IndexOf(entity.Name, offset + length, textSource.TextLength - offset - length, StringComparison.OrdinalIgnoreCase); } while (offset > 0); if (highlighter != null) { highlighter.Dispose(); } if (results.Count > 0) { if (!isNameValid) { errorCallback(new Error(ErrorType.Error, string.Format("The name '{0}' is not valid in the current context!", args.NewName), new DomRegion(fileName, results[0].StartLocation))); return; } IDocument changedDocument = new TextDocument(document); var oldVersion = changedDocument.Version; foreach (var result in results.OrderByDescending(m => m.StartOffset)) { changedDocument.Replace(result.StartOffset, result.Length, result.NewCode); } callback(new PatchedFile(fileName, results, oldVersion, changedDocument.Version)); } }
/// <summary> /// Returns the list of allow XAML2009 completion items. /// </summary> public static IEnumerable <string> GetAllowedItems(XamlCompletionContext context) { string xamlPrefix = context.XamlNamespacePrefix; string xKey = string.IsNullOrEmpty(xamlPrefix) ? "" : xamlPrefix + ":"; var compilation = SD.ParserService.GetCompilationForFile(context.Editor.FileName); var resolver = new XamlAstResolver(compilation, context.ParseInformation); // TODO : add support for x:Key as attribute element (XAML 2009 only) switch (context.Description) { case XamlContextDescription.AtTag: if (context.ParentElement != null && string.Equals(context.ParentElement.Name, xKey + "Members", StringComparison.OrdinalIgnoreCase)) { yield return(xKey + "Member"); yield return(xKey + "Property"); } else if (context.ParentElement == context.RootElement && context.RootElement.Attributes.Any(attr => string.Equals(attr.Name, xKey + "Class", StringComparison.OrdinalIgnoreCase))) { yield return(xKey + "Code"); yield return(xKey + "Members"); } else { if (context.ParentElement != null && string.Equals(context.ParentElement.Name, xKey + "Code", StringComparison.OrdinalIgnoreCase)) { yield break; } yield return(xKey + "Array"); yield return(xKey + "Boolean"); yield return(xKey + "Byte"); yield return(xKey + "Char"); yield return(xKey + "Decimal"); yield return(xKey + "Dictionary"); yield return(xKey + "Double"); yield return(xKey + "Int16"); yield return(xKey + "Int32"); yield return(xKey + "Int64"); yield return(xKey + "List"); yield return(xKey + "Object"); yield return(xKey + "Reference"); yield return(xKey + "Single"); yield return(xKey + "String"); yield return(xKey + "TimeSpan"); yield return(xKey + "Uri"); if (context.RootElement.Attributes.Any(attr => string.Equals(attr.Name, xKey + "Class", StringComparison.OrdinalIgnoreCase))) { yield return(xKey + "Members"); } } break; case XamlContextDescription.InTag: yield return(xKey + "Uid"); if (context.InRoot) { yield return(xKey + "Class"); yield return(xKey + "ClassModifier"); yield return(xKey + "Subclass"); yield return(xKey + "Name"); } else { var resourceDictionaryType = compilation.FindType(typeof(ResourceDictionary)); if (context.ActiveElement != null && string.Equals(context.ActiveElement.Name, xKey + "Array", StringComparison.OrdinalIgnoreCase)) { yield return("Type"); } else if (context.ActiveElement != null && string.Equals(context.ActiveElement.Name, xKey + "Member", StringComparison.OrdinalIgnoreCase)) { yield return("Name"); } else if (context.ActiveElement != null && string.Equals(context.ActiveElement.Name, xKey + "Property", StringComparison.OrdinalIgnoreCase)) { yield return("Name"); yield return("Type"); } else if (context.RootElement.Attributes.Any(attr => string.Equals(attr.Name, xKey + "Class", StringComparison.OrdinalIgnoreCase))) { yield return(xKey + "FieldModifier"); yield return(xKey + "Name"); } else { yield return(xKey + "Name"); } if (context.ParentElement != null) { var rr = resolver.ResolveElement(context.ParentElement); if (rr != null) { if (rr.Type.Equals(resourceDictionaryType)) { yield return(xKey + "Key"); yield return(xKey + "Shared"); } else if (rr.Type.TypeParameterCount > 0) { yield return(xKey + "TypeArguments"); } } } } break; } yield break; }