/*public IEnumerable<ChainedNavigationItemData> GetNextChainedScopes( GotoContext gotoContext, IdentifierMatcher matcher, INavigationScope containingScope, CheckForInterrupt checkCancelled) { var solution = containingScope.GetSolution(); var cache = this.GetCache(containingScope, solution, gotoContext); return ChainedScopesUtil.GetNextCodeModelScope(matcher, containingScope, checkCancelled, cache, true); } */ public IEnumerable<MatchingInfo> FindMatchingInfos( IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func<bool> checkCancelled) { var primaryMembersData = this.GetPrimaryMembers(scope.GetSolution()); var fileMembersMap = new NTriplesFileMembersMap(); var result = new Collection<MatchingInfo>(); foreach (var data in primaryMembersData) { var quickSearchTexts = this.GetQuickSearchTexts(data.Element); var matchedText = quickSearchTexts.FirstOrDefault(tuple => matcher.Matches(tuple.A)); if (matchedText == null) { continue; } fileMembersMap.Add(matchedText.A, data); var matchingIndicies = matchedText.B ? matcher.MatchingIndicies(matchedText.A) : EmptyArray<IdentifierMatch>.Instance; result.Add( new MatchingInfo( matchedText.A, matcher.Filter == "*" ? EmptyList<IdentifierMatch>.InstanceList : matchingIndicies, matchedText.B)); } gotoContext.PutData(NTriplesFileMembersMap.NTriplesFileMembersMapKey, fileMembersMap); return result; }
public IEnumerable<MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func<bool> checkForInterrupt) { var indices = matcher.MatchingIndicies(matcher.Filter); var matchingInfo = new MatchingInfo(matcher.Filter, indices); yield return matchingInfo; }
public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher) { // not sure why we have to explicitly do this if (matcher.Filter.Length == 0) return false; // oops: this means feature only works with open sln return scope is SolutionNavigationScope; }
public IEnumerable<IOccurence> GetOccurencesByMatchingInfo(MatchingInfo navigationInfo, INavigationScope scope, GotoContext gotoContext, Func<bool> checkForInterrupt) { // send this off to the server to be processed foreach (string s in yt.GetCompletionOptionsFor(navigationInfo.Identifier)) { yield return new YouTrackIssueOccurence {IssueId = navigationInfo.Identifier, IssueDescription = s}; } }
/// <summary> /// Finds matched items and returns a corresponing list of matchingInfos. /// Controller (or some other entity that will use this provider) recieves these items, scores them, sorts /// and than invoke GetOccurences for the top scored of them. /// </summary> /// <param name="matcher">matcher to use</param><param name="scope">defines a scope to search in</param><param name="gotoContext"/><param name="checkForInterrupt"/> /// <returns/> public IEnumerable<MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func<bool> checkForInterrupt) { var occurrences = new List<ItemOccurence>(); var databases = new List<DatabaseUri>(); foreach (var project in VisualStudio.Projects.ProjectManager.Projects) { if (project.Site != null) { databases.Add(new DatabaseUri(project.Site, DatabaseName.Master)); } } using (var fibers = this.myTaskHost.CreateBarrier(this.myLifetime, checkForInterrupt, false, false)) { foreach (var databaseUri in databases) { var busy = true; var db = databaseUri; ExecuteCompleted completed = delegate(string response, ExecuteResult executeResult) { if (!DataService.HandleExecute(response, executeResult, true)) { busy = false; return; } var r = response.ToXElement(); if (r == null) { busy = false; return; } foreach (var element in r.Elements()) { occurrences.Add(new ItemOccurence(ItemHeader.Parse(db, element))); } busy = false; }; databaseUri.Site.DataService.ExecuteAsync("Search.Search", completed, matcher.Filter, string.Empty, string.Empty, string.Empty, string.Empty, 0); AppHost.DoEvents(ref busy); } } gotoContext.PutData(SitecoreItemOccurrences, occurrences); var matchingInfo = new MatchingInfo(matcher.Filter, EmptyList<IdentifierMatch>.InstanceList); return new[] { matchingInfo }; }
/// <summary> /// Determines whether the specified scope is applicable. /// </summary> /// <param name="scope">The scope.</param> /// <param name="gotoContext">The goto context.</param> /// <param name="matcher">The matcher.</param> /// <returns><c>true</c> if the specified scope is applicable; otherwise, <c>false</c>.</returns> public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher) { if (string.IsNullOrEmpty(matcher.Filter)) { return false; } if (matcher.Filter.Length < 3) { return false; } if (scope is ProjectModelNavigationScope) { return true; } if (scope is SolutionNavigationScope) { return true; } return VisualStudio.Projects.ProjectManager.Projects.Any(); }
/// <summar>Gets occurences by given matchingInfo </summar><param name="navigationInfo"/><param name="scope"/><param name="gotoContext"/><param name="checkForInterrupt"/> /// <returns/> public IEnumerable<IOccurence> GetOccurencesByMatchingInfo(MatchingInfo navigationInfo, INavigationScope scope, GotoContext gotoContext, Func<bool> checkForInterrupt) { var occurrences = gotoContext.GetData(SitecoreItemOccurrences); return occurrences ?? EmptyList<ItemOccurence>.InstanceList; }
public IEnumerable<IOccurence> GetOccurencesByMatchingInfo( MatchingInfo navigationInfo, INavigationScope scope, GotoContext gotoContext, Func<bool> checkForInterrupt) { var fileMembersMap = gotoContext.GetData(NTriplesFileMembersMap.NTriplesFileMembersMapKey); if (fileMembersMap == null) { yield break; } var membersData = fileMembersMap[navigationInfo.Identifier]; foreach (var clrFileMemberData in membersData) { var occurence = this.CreateOccurence(clrFileMemberData); if (occurence != null) { yield return occurence; } } }
public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher) { return true; }
public IEnumerable<IOccurence> GetOccurencesByMatchingInfo( MatchingInfo navigationInfo, INavigationScope scope, GotoContext gotoContext, Func<bool> checkCancelled) { var fileMembersMap = gotoContext.GetData(NTriplesFileMembersMap.NTriplesFileMembersMapKey); if (fileMembersMap == null) { yield break; } var membersData = fileMembersMap[navigationInfo.Identifier]; foreach (var clrFileMemberData in membersData) { var occurence = this.CreateOccurence(clrFileMemberData); if (occurence != null) { yield return occurence; } } /* ISolution solution = scope.GetSolution(); var cache = this.GetCache(scope, solution, gotoContext); var namespaceNavigationScope = scope as NamespaceNavigationScope; if (namespaceNavigationScope != null) { INamespace namespaceScope = namespaceNavigationScope.DeclaredElement as INamespace; if (namespaceScope != null) { return (IEnumerable<IOccurence>)EmptyList<IOccurence>.InstanceList; } //return Enumerable.Select<IClrDeclaredElement, IOccurence>(Enumerable.Where<IClrDeclaredElement>(Enumerable.Where<IClrDeclaredElement>(ChainedScopesUtil.GetAllSubElements(namespaceScope, cache, true), (Func<IClrDeclaredElement, bool>)(element => element.ShortName == navigationInfo.Identifier)), new Func<IClrDeclaredElement, bool>(this.IsDeclaredElementVisible)), (Func<IClrDeclaredElement, IOccurence>)(x => (IOccurence)new ChainedCodeModelOccurence((IDeclaredElement)x, navigationInfo, OccurencePresentationOptions.DefaultOptions))); } if (!(scope is SolutionNavigationScope)) { return (IEnumerable<IOccurence>)EmptyList<IOccurence>.InstanceList; } List<IClrDeclaredElement> list1 = new List<IClrDeclaredElement>(); foreach (ITypeMember typeMember in cache.GetSourceMembers(navigationInfo.Identifier)) { if (!typeMember.IsSynthetic() && !(typeMember is IAccessor)) { list1.Add((IClrDeclaredElement)typeMember); } } List<IClrDeclaredElement> list2 = new List<IClrDeclaredElement>(); if (scope.ExtendedSearchFlag == LibrariesFlag.SolutionAndLibraries) { foreach (ITypeMember typeMember in cache.GetCompiledMembers(navigationInfo.Identifier)) { list2.Add((IClrDeclaredElement)typeMember); } } IClrDeclaredElement[] elementsByShortName = cache.GetElementsByShortName(navigationInfo.Identifier); return Enumerable.Select<IClrDeclaredElement, IOccurence>( Enumerable.Where<IClrDeclaredElement>( Enumerable.Concat<IClrDeclaredElement>( CollectionUtil.Concat<IClrDeclaredElement>( (IEnumerable<IClrDeclaredElement>)list1, elementsByShortName), (IEnumerable<IClrDeclaredElement>)list2), new Func<IClrDeclaredElement, bool>(this.IsDeclaredElementVisible)), (Func<IClrDeclaredElement, IOccurence>) (x => (IOccurence)new DeclaredElementOccurence((IDeclaredElement)x, OccurenceType.Occurence)));*/ }
public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher) { if (!(scope is SolutionNavigationScope)) { return scope is NamespaceNavigationScope; } return true; }