/*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<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 IEnumerable <IOccurence> GetOccurencesByMatchingInfo( [NotNull] MatchingInfo navigationInfo, [NotNull] INavigationScope scope, [NotNull] GotoContext gotoContext, [NotNull] Func <bool> checkForInterrupt) { var occurrences = gotoContext.GetData(GoToWordOccurrences); return(occurrences ?? EmptyList <IOccurence> .InstanceList); }
public IEnumerable <Pair <IOccurrence, MatchingInfo> > GetMatchingOccurrences( IIdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func <bool> checkForInterrupt) { ApplicableGeneratorsCache applicableGeneratorsCache = gotoContext.GetData(GotoGeneratorController.ApplicableGeneratorsCacheKey); Debug.Assert(applicableGeneratorsCache != null, "applicableGeneratorsCache != null"); foreach (IGenerator generator in applicableGeneratorsCache.GetApplicableGenerators()) { string name = generator.Name; string typeName = generator.GetType().Name; bool matches = matcher.Matches(name) || matcher.Matches(typeName); if (matches) { yield return(Pair.Of( (IOccurrence) new GeneratorOccurrence(generator), new MatchingInfo(matcher, typeName) )); } } }
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 <IOccurrence> GetOccurrencesByMatchingInfo( MatchingInfo navigationInfo, INavigationScope scope, GotoContext gotoContext, Func <bool> checkForInterrupt) { yield break; }
public IEnumerable <MatchingInfo> FindMatchingInfos( IIdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func <bool> checkForInterrupt) { yield break; }
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}; } }
public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher) { if (!(scope is SolutionNavigationScope)) { return(scope is NamespaceNavigationScope); } return(true); }
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); }
[NotNull] public IEnumerable <MatchingInfo> FindMatchingInfos( [NotNull] IdentifierMatcher matcher, [NotNull] INavigationScope scope, [NotNull] GotoContext gotoContext, [NotNull] CheckForInterrupt checkCanceled) { var solution = scope.GetSolution(); if (solution == null) { return(EmptyList <MatchingInfo> .InstanceList); } var navigationScope = scope as FileMemberNavigationScope; if (navigationScope != null) { var sourceFile = navigationScope.GetPrimarySourceFile(); var consumer = new List <IOccurence>(); SearchInFile(matcher.Filter, sourceFile, consumer, checkCanceled); foreach (var occurence in consumer) { //return new MatchingInfo(matcher.Filter, EmptyList<IdentifierMatch>.InstanceList); } } var filterText = matcher.Filter; var occurrences = new List <IOccurence>(); myShellLocks.AssertReadAccessAllowed(); //if (scope.ExtendedSearchFlag == LibrariesFlag.SolutionOnly) //{ // FindByWords(filterText, solution, occurrences, gotoContext, checkCanceled); //} //else //{ // FindTextual(filterText, solution, occurrences, checkCanceled); //} if (occurrences.Count > 0) { gotoContext.PutData(GoToWordOccurrences, occurrences); return(new[] { new MatchingInfo(filterText, EmptyList <IdentifierMatch> .InstanceList) }); } return(EmptyList <MatchingInfo> .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); } } }
/// <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 virtual bool IsApplicable(INavigationScope scope, GotoContext gotoContext) { return(true); }
public IEnumerable <MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, CheckForInterrupt checkCancelled, GotoContext gotoContext) { var fileMemberScope = scope as FileMemberNavigationScope; if (fileMemberScope == null) { return(EmptyList <MatchingInfo> .InstanceList); } var primaryMembersData = GetPrimaryMembers(fileMemberScope); var primarySourceFile = fileMemberScope.GetPrimarySourceFile(); ICollection <ClrFileMemberData> secondaryMembersData = new Collection <ClrFileMemberData>(); if (scope.ExtendedSearchFlag == LibrariesFlag.SolutionAndLibraries) { var secondaryFilesGetter = fileMemberScope.GetSecondaryFilesGetter(); secondaryMembersData = GetSecondaryMembers(primarySourceFile, secondaryFilesGetter); } var clrFileMembersMap = new ClrFileMembersMap(); var result = new Collection <MatchingInfo>(); foreach (var data in primaryMembersData.Concat(secondaryMembersData)) { var quickSearchTexts = GetQuickSearchTexts(data.Element); var matchedText = quickSearchTexts.FirstOrDefault(tuple => matcher.Matches(tuple.A)); if (matchedText == null) { continue; } clrFileMembersMap.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(ClrFileMembersMap.ClrFileMembersMapKey, clrFileMembersMap); return(result); }
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; } } }
[NotNull] public IEnumerable <ChainedNavigationItemData> GetNextChainedScopes( [NotNull] GotoContext gotoContext, [NotNull] IdentifierMatcher matcher, [NotNull] INavigationScope containingScope, [NotNull] CheckForInterrupt checkForInterrupt) { return(EmptyList <ChainedNavigationItemData> .InstanceList); }
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; }
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) { return(true); }
public IEnumerable <MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func <bool> checkForInterrupt) { var fileMemberScope = scope as FileMemberNavigationScope; if (fileMemberScope == null) { return(EmptyList <MatchingInfo> .InstanceList); } var primaryMembersData = GetPrimaryMembers(fileMemberScope); var psiFileMembersMap = new PsiFileMembersMap(); var result = new Collection <MatchingInfo>(); foreach (var data in primaryMembersData) { var quickSearchTexts = GetQuickSearchTexts(data.Element); var matchedText = quickSearchTexts.FirstOrDefault(tuple => matcher.Matches(tuple.A)); if (matchedText == null) { continue; } psiFileMembersMap.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(PsiFileMembersMap.PsiFileMembersMapKey, psiFileMembersMap); return(result); }
/// <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 }; }
public bool IsApplicable( [NotNull] INavigationScope scope, [NotNull] GotoContext gotoContext, [NotNull] IdentifierMatcher matcher) { return(true); }
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 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 }); } }
public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher) { return true; }