public override string ExplicitLabel(IFuzzyOption item) { if (item is NamespaceOption namespaceOption) { return(namespaceOption.value.DisplayName()); } else if (item is TypeOption typeOption) { return(typeOption.value.DisplayName()); } else if (item is MemberOption memberOption) { var member = memberOption.value; if (member.isInvocable) { return($"{member.info.DisplayName(action, expectingBoolean)} ({member.methodBase.DisplayParameterString()})"); } else { return(member.info.DisplayName(action, expectingBoolean)); } } throw new NotSupportedException(); }
public FuzzyOptionNode(IFuzzyOption option) { Ensure.That(nameof(option)).IsNotNull(option); this.option = option; children = new List <FuzzyOptionNode>(); labelText = option.label; }
public FuzzyOptionNode(IFuzzyOption option, string label) { Ensure.That(nameof(option)).IsNotNull(option); this.option = option; children = new List <FuzzyOptionNode>(); labelText = label ?? string.Empty; }
public override string SearchResultLabel(IFuzzyOption item, string query) { if (item is MemberOption memberOption) { return(memberOption.SearchResultLabel(query, action, expectingBoolean)); } return(base.SearchResultLabel(item, query)); }
public override IEnumerable <IFuzzyOption> Children(IFuzzyOption parent, bool ordered) { if (parent is NamespaceOption namespaceOption) { var @namespace = namespaceOption.value; if ([email protected]) { var childNamespaces = Enumerable.Empty <Namespace>(); if (namespacesInNamespace.TryGetValue(@namespace, out var foundNamespaces)) { childNamespaces = foundNamespaces; } if (ordered) { childNamespaces = childNamespaces.OrderBy(ns => ns.DisplayName(false)); } foreach (var childNamespace in childNamespaces) { yield return(new NamespaceOption(childNamespace, FuzzyOptionMode.Branch)); } } var childTypes = Enumerable.Empty <Type>(); if (typesInNamespace.TryGetValue(@namespace, out var foundTypes)) { childTypes = foundTypes; } if (ordered) { childTypes = childTypes.OrderBy(t => t.DisplayName()); } foreach (var type in childTypes) { yield return(new TypeOption(type, FuzzyOptionMode.Leaf)); } } else if (parent.value == enumsGroup) { var childTypes = enumTypes.AsEnumerable(); if (ordered) { childTypes = childTypes.OrderBy(t => t.DisplayName()); } foreach (var type in childTypes) { yield return(new TypeOption(type, FuzzyOptionMode.Leaf)); } } }
public override IEnumerable <IFuzzyOption> Children(IFuzzyOption parent, bool ordered) { if (parent is AssetFolderOption folderOption) { return(Children(folderOption.value)); } else { return(Enumerable.Empty <IFuzzyOption>()); } }
public override IEnumerable <IFuzzyOption> Children(IFuzzyOption parent, bool ordered) { foreach (var extension in extensions) { var children = (extension is FuzzyOptionTree fot) ? fot.Children(parent, ordered) : extension.Children(parent); foreach (var extensionChild in children) { yield return(extensionChild); } } }
public override string SearchResultLabel(IFuzzyOption item, string query) { foreach (var extension in extensions) { try { var label = extension.SearchResultLabel(item, query); if (label != null) { return(label); } } catch (NotSupportedException) {} } return(base.SearchResultLabel(item, query)); }
public virtual IEnumerable <IFuzzyOption> SearchableChildren(IFuzzyOption parent) { if (parent is FuzzyWindow.FavoritesRoot) { foreach (var favorite in favorites.Where(CanFavorite)) { yield return(favorite); } } else { foreach (var child in Children(parent, false)) { yield return(child); foreach (var grandchild in SearchableChildren(child)) { yield return(grandchild); } } } }
public override IEnumerable <IFuzzyOption> Children(IFuzzyOption parent, bool ordered) { if (parent is NamespaceOption namespaceOption) { var @namespace = namespaceOption.value; if ([email protected]) { var childNamespaces = namespaces.Where(ns => ns.Parent == @namespace); if (ordered) { childNamespaces = childNamespaces.OrderBy(ns => ns.DisplayName(false)); } foreach (var childNamespace in childNamespaces) { yield return(new NamespaceOption(childNamespace, FuzzyOptionMode.Branch)); yield return(new NamespaceOption(childNamespace, FuzzyOptionMode.Leaf)); } } } }
public virtual bool UseExplicitLabel(IFuzzyOption parent, IFuzzyOption item) { return(false); }
public virtual string SearchResultLabel(IFuzzyOption item, string query) { return(item.SearchResultLabel(query)); }
public virtual IEnumerable <ISearchResult <IFuzzyOption> > SearchResults(string query, IFuzzyOption parent, CancellationToken cancellation) { var options = parent == null?SearchableRoot() : SearchableChildren(parent); return(options.OrderableSearchFilter(query, x => x.haystack, cancellation)); }
public virtual IEnumerable <IFuzzyOption> OrderedSearchResults(string query, IFuzzyOption parent, CancellationToken cancellation) { return(SearchResults(query, parent, cancellation).OrderByRelevance()); }
public override IEnumerable <ISearchResult <IFuzzyOption> > SearchResults(string query, IFuzzyOption parent, CancellationToken cancellation) { foreach (var baseSearchResult in base.SearchResults(query, parent, cancellation)) { yield return(baseSearchResult); } foreach (var extension in extensions) { if (extension.searchable) { foreach (var extensionSearchResult in extension.SearchResults(query, parent, cancellation)) { yield return(extensionSearchResult); } } } }
public virtual IEnumerable <IFuzzyOption> Children(IFuzzyOption parent, bool ordered) => Enumerable.Empty <IFuzzyOption>();
public override IEnumerable <ISearchResult <IFuzzyOption> > SearchResults(string query, IFuzzyOption parent, CancellationToken cancellation) { return(looseAssemblyNames.Select(x => new LooseAssemblyNameOption(x)).OrderableSearchFilter(query, x => x.haystack, cancellation)); }
public override IEnumerable <IFuzzyOption> Children(IFuzzyOption parent, bool ordered) { return(Enumerable.Empty <IFuzzyOption>()); }
public override IEnumerable <IFuzzyOption> OrderedSearchResults(string query, IFuzzyOption parent, CancellationToken cancellation) { // Exclude duplicate inherited members, like the high amount of "Destroy()" or "enabled", // if their declaring type is also available for search. foreach (var memberOption in codebase.members .Cancellable(cancellation) .Select(m => new MemberOption(m)) .UnorderedSearchFilter(query, m => m.Haystack(action, expectingBoolean)) .Where(m => !m.value.isPseudoInherited || !codebase.types.Contains(m.value.info.DeclaringOrExtendedType())) .OrderBy(m => LudiqCore.Configuration.groupInheritedMembers && m.value.isPseudoInherited) .ThenByDescending(m => SearchUtility.Relevance(query, m.Haystack(action, expectingBoolean)))) { yield return(memberOption); } foreach (var typeOption in codebase.types .Select(t => new TypeOption(t, FuzzyOptionMode.Branch)) .Where(t => !t.value.IsEnum) .OrderedSearchFilter(query, t => t.haystack, cancellation)) { yield return(typeOption); } }
public override IEnumerable <ISearchResult <IFuzzyOption> > SearchResults(string query, IFuzzyOption parent, CancellationToken cancellation) { var children = parent != null ? SearchableChildren(parent) : namespaces.Select(x => (IFuzzyOption) new NamespaceOption(x, FuzzyOptionMode.Branch)); return(children.OrderableSearchFilter(query, x => x.haystack, cancellation)); }
public virtual string ExplicitLabel(IFuzzyOption item) { throw new NotSupportedException(); }
public virtual bool CanFavorite(IFuzzyOption item) { throw new NotSupportedException(); }
public override bool CanFavorite(IFuzzyOption item) { return(item is MemberOption); }
public IEnumerable <IFuzzyOption> Children(IFuzzyOption parent) { return(Children(parent, true)); }
public override IEnumerable <IFuzzyOption> Children(IFuzzyOption parent, bool ordered) { if (parent is NamespaceOption namespaceOption) { var @namespace = namespaceOption.value; if ([email protected]) { var childNamespaces = codebase.members .Select(m => m.targetType) .Distinct() .Where(t => !t.IsEnum) .Select(t => t.Namespace()) .Distinct() .Where(ns => ns.Parent == @namespace); if (ordered) { childNamespaces = childNamespaces.OrderBy(ns => ns.DisplayName(false)); } foreach (var childNamespace in childNamespaces) { yield return(new NamespaceOption(childNamespace, FuzzyOptionMode.Branch)); } } var childTypes = codebase.members .Select(m => m.targetType) .Where(t => !t.IsEnum) .Distinct() .Where(t => t.Namespace() == @namespace); if (ordered) { childTypes = childTypes.OrderBy(t => t.DisplayName()); } foreach (var type in childTypes) { yield return(new TypeOption(type, FuzzyOptionMode.Branch)); } } else if (parent is TypeOption typeOption) { var childMembers = codebase.members.Where(m => m.targetType == typeOption.value); if (ordered) { childMembers = childMembers .OrderBy(m => LudiqCore.Configuration.groupInheritedMembers && m.isPseudoInherited) .ThenBy(m => m.info.DisplayName()); } foreach (var member in childMembers) { yield return(new MemberOption(member)); } } else if (parent is MemberOption) { yield break; } else { throw new NotSupportedException(); } }