Exemplo n.º 1
0
 void AllResults(ISearchResultCallback searchResultCallback, WorkerResult newResult, IReadOnlyList <DeclaredSymbolInfo> allTypes, CancellationToken token)
 {
     // Search Types
     newResult.filteredSymbols = new List <DeclaredSymbolInfo> ();
     foreach (var type in allTypes)
     {
         if (token.IsCancellationRequested)
         {
             newResult.filteredSymbols = null;
             return;
         }
         SearchResult curResult = newResult.CheckType(type);
         if (curResult != null)
         {
             newResult.filteredSymbols.Add(type);
             searchResultCallback.ReportResult(curResult);
         }
     }
 }
        void AllResults(ISearchResultCallback searchResultCallback, WorkerResult lastResult, WorkerResult newResult, IEnumerable <DeclaredSymbolInfo> completeTypeList, CancellationToken token)
        {
            // Search Types
            newResult.filteredSymbols = new List <DeclaredSymbolInfo> ();
            bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith(lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredSymbols != null;
            var  allTypes             = startsWithLastFilter ? lastResult.filteredSymbols : completeTypeList;

            foreach (var type in allTypes)
            {
                if (token.IsCancellationRequested)
                {
                    newResult.filteredSymbols = null;
                    return;
                }
                SearchResult curResult = newResult.CheckType(type);
                if (curResult != null)
                {
                    newResult.filteredSymbols.Add(type);
                    searchResultCallback.ReportResult(curResult);
                }
            }
        }
        void AllResults(WorkerResult lastResult, WorkerResult newResult, CancellationToken token)
        {
            if (newResult.isGotoFilePattern)
            {
                return;
            }
            uint x = 0;

            // Search Types
            if (newResult.IncludeTypes && (newResult.Tag == null || typeTags.Any(t => t == newResult.Tag)))
            {
                newResult.filteredTypes = new List <ITypeDefinition> ();
                bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith(lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredTypes != null;
                var  allTypes             = startsWithLastFilter ? lastResult.filteredTypes : types;
                foreach (var type in allTypes)
                {
                    if (unchecked (x++) % 100 == 0 && token.IsCancellationRequested)
                    {
                        return;
                    }

                    if (newResult.Tag != null)
                    {
                        if (newResult.Tag == "c" && type.Kind != TypeKind.Class)
                        {
                            continue;
                        }
                        if (newResult.Tag == "s" && type.Kind != TypeKind.Struct)
                        {
                            continue;
                        }
                        if (newResult.Tag == "i" && type.Kind != TypeKind.Interface)
                        {
                            continue;
                        }
                        if (newResult.Tag == "e" && type.Kind != TypeKind.Enum)
                        {
                            continue;
                        }
                        if (newResult.Tag == "d" && type.Kind != TypeKind.Delegate)
                        {
                            continue;
                        }
                    }
                    SearchResult curResult = newResult.CheckType(type);
                    if (curResult != null)
                    {
                        newResult.filteredTypes.Add(type);
                        newResult.results.AddResult(curResult);
                    }
                }
            }

            // Search members
            if (newResult.IncludeMembers && (newResult.Tag == null || memberTags.Any(t => t == newResult.Tag)))
            {
                newResult.filteredMembers = new List <Tuple <ITypeDefinition, IUnresolvedMember> > ();
                bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith(lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredMembers != null;
                if (startsWithLastFilter)
                {
                    foreach (var t in lastResult.filteredMembers)
                    {
                        if (unchecked (x++) % 100 == 0 && token.IsCancellationRequested)
                        {
                            return;
                        }
                        var member = t.Item2;
                        if (newResult.Tag != null)
                        {
                            if (newResult.Tag == "m" && member.EntityType != EntityType.Method)
                            {
                                continue;
                            }
                            if (newResult.Tag == "p" && member.EntityType != EntityType.Property)
                            {
                                continue;
                            }
                            if (newResult.Tag == "f" && member.EntityType != EntityType.Field)
                            {
                                continue;
                            }
                            if (newResult.Tag == "evt" && member.EntityType != EntityType.Event)
                            {
                                continue;
                            }
                        }
                        SearchResult curResult = newResult.CheckMember(t.Item1, member);
                        if (curResult != null)
                        {
                            newResult.filteredMembers.Add(t);
                            newResult.results.AddResult(curResult);
                        }
                    }
                }
                else
                {
                    Func <IUnresolvedMember, bool> mPred = member => {
                        if (newResult.Tag != null)
                        {
                            if (newResult.Tag == "m" && member.EntityType != EntityType.Method)
                            {
                                return(false);
                            }
                            if (newResult.Tag == "p" && member.EntityType != EntityType.Property)
                            {
                                return(false);
                            }
                            if (newResult.Tag == "f" && member.EntityType != EntityType.Field)
                            {
                                return(false);
                            }
                            if (newResult.Tag == "evt" && member.EntityType != EntityType.Event)
                            {
                                return(false);
                            }
                        }
                        return(newResult.IsMatchingMember(member));
                    };

                    getMembersTimer.BeginTiming();
                    try {
                        foreach (var type in types)
                        {
                            if (type.Kind == TypeKind.Delegate)
                            {
                                continue;
                            }
                            foreach (var p in type.Parts)
                            {
                                foreach (var member in p.Members.Where(mPred))
                                {
                                    if (unchecked (x++) % 100 == 0 && token.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    SearchResult curResult = newResult.CheckMember(type, member);
                                    if (curResult != null)
                                    {
                                        newResult.filteredMembers.Add(Tuple.Create(type, member));
                                        newResult.results.AddResult(curResult);
                                    }
                                }
                            }
                        }
                    } finally {
                        getMembersTimer.EndTiming();
                    }
                }
            }
        }
Exemplo n.º 4
0
        IEnumerable <SearchResult> AllResults(BackgroundWorker worker, WorkerResult lastResult, WorkerResult newResult)
        {
            // Search files
            if (newResult.IncludeFiles)
            {
                newResult.filteredFiles = new List <ProjectFile> ();
                bool startsWithLastFilter          = lastResult.pattern != null && newResult.pattern.StartsWith(lastResult.pattern) && lastResult.filteredFiles != null;
                IEnumerable <ProjectFile> allFiles = startsWithLastFilter ? lastResult.filteredFiles : files;
                foreach (ProjectFile file in allFiles)
                {
                    if (worker.CancellationPending)
                    {
                        yield break;
                    }
                    SearchResult curResult = newResult.CheckFile(file);
                    if (curResult != null)
                    {
                        newResult.filteredFiles.Add(file);
                        yield return(curResult);
                    }
                }
            }
            if (newResult.isGotoFilePattern)
            {
                yield break;
            }

            // Search Types
            if (newResult.IncludeTypes)
            {
                newResult.filteredTypes = new List <IType> ();
                lock (types) {
                    bool         startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith(lastResult.pattern) && lastResult.filteredTypes != null;
                    List <IType> allTypes             = startsWithLastFilter ? lastResult.filteredTypes : types;
                    foreach (IType type in allTypes)
                    {
                        if (worker.CancellationPending)
                        {
                            yield break;
                        }
                        SearchResult curResult = newResult.CheckType(type);
                        if (curResult != null)
                        {
                            newResult.filteredTypes.Add(type);
                            yield return(curResult);
                        }
                    }
                }
            }

            // Search members
            if (newResult.IncludeMembers)
            {
                newResult.filteredMembers = new List <IMember> ();
                lock (members) {
                    bool           startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith(lastResult.pattern) && lastResult.filteredMembers != null;
                    List <IMember> allMembers           = startsWithLastFilter ? lastResult.filteredMembers : members;
                    foreach (IMember member in allMembers)
                    {
                        if (worker.CancellationPending)
                        {
                            yield break;
                        }
                        SearchResult curResult = newResult.CheckMember(member);
                        if (curResult != null)
                        {
                            newResult.filteredMembers.Add(member);
                            yield return(curResult);
                        }
                    }
                }
            }
        }
		void AllResults (ISearchResultCallback searchResultCallback, WorkerResult lastResult, WorkerResult newResult, IReadOnlyList<DeclaredSymbolInfo> completeTypeList, CancellationToken token)
		{
			// Search Types
			newResult.filteredSymbols = new List<DeclaredSymbolInfo> ();
			bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith (lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredSymbols != null;
			var allTypes = startsWithLastFilter ? lastResult.filteredSymbols : completeTypeList;
			foreach (var type in allTypes) {
				if (token.IsCancellationRequested) {
					newResult.filteredSymbols = null;
					return;
				}
				SearchResult curResult = newResult.CheckType (type);
				if (curResult != null) {
					newResult.filteredSymbols.Add (type);
					searchResultCallback.ReportResult (curResult);
				}
			}
		}
        void AllResults(ISearchResultCallback searchResultCallback, WorkerResult lastResult, WorkerResult newResult, IReadOnlyList <DeclaredSymbolInfo> completeTypeList, CancellationToken token)
        {
            if (newResult.isGotoFilePattern)
            {
                return;
            }
            uint x = 0;

            // Search Types
            newResult.filteredSymbols = new List <DeclaredSymbolInfo> ();
            bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith(lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredSymbols != null;
            var  allTypes             = startsWithLastFilter ? lastResult.filteredSymbols : completeTypeList;

            foreach (var type in allTypes)
            {
                if (unchecked (x++) % 100 == 0 && token.IsCancellationRequested)
                {
                    newResult.filteredSymbols = null;
                    return;
                }

                if (type.Kind == DeclaredSymbolInfoKind.Constructor ||
                    type.Kind == DeclaredSymbolInfoKind.Module ||
                    type.Kind == DeclaredSymbolInfoKind.Indexer)
                {
                    continue;
                }

                if (newResult.Tag != null)
                {
                    if ((newResult.Tag == "type" || newResult.Tag == "t") && type.Kind != DeclaredSymbolInfoKind.Class && type.Kind != DeclaredSymbolInfoKind.Struct && type.Kind != DeclaredSymbolInfoKind.Interface && type.Kind != DeclaredSymbolInfoKind.Enum && type.Kind != DeclaredSymbolInfoKind.Delegate)
                    {
                        continue;
                    }

                    if (newResult.Tag == "class" && type.Kind != DeclaredSymbolInfoKind.Class)
                    {
                        continue;
                    }
                    if (newResult.Tag == "struct" && type.Kind != DeclaredSymbolInfoKind.Struct)
                    {
                        continue;
                    }
                    if (newResult.Tag == "interface" && type.Kind != DeclaredSymbolInfoKind.Interface)
                    {
                        continue;
                    }
                    if (newResult.Tag == "enum" && type.Kind != DeclaredSymbolInfoKind.Enum)
                    {
                        continue;
                    }
                    if (newResult.Tag == "delegate" && type.Kind != DeclaredSymbolInfoKind.Delegate)
                    {
                        continue;
                    }

                    if ((newResult.Tag == "member" || newResult.Tag == "m") && type.Kind != DeclaredSymbolInfoKind.Method && type.Kind != DeclaredSymbolInfoKind.Property && type.Kind != DeclaredSymbolInfoKind.Field && type.Kind != DeclaredSymbolInfoKind.Event)
                    {
                        continue;
                    }
                    if (newResult.Tag == "method" && type.Kind != DeclaredSymbolInfoKind.Method)
                    {
                        continue;
                    }
                    if (newResult.Tag == "property" && type.Kind != DeclaredSymbolInfoKind.Property)
                    {
                        continue;
                    }
                    if (newResult.Tag == "field" && type.Kind != DeclaredSymbolInfoKind.Field)
                    {
                        continue;
                    }
                    if (newResult.Tag == "event" && type.Kind != DeclaredSymbolInfoKind.Event)
                    {
                        continue;
                    }
                }
                SearchResult curResult = newResult.CheckType(type);
                if (curResult != null)
                {
                    newResult.filteredSymbols.Add(type);
                    newResult.results.AddResult(curResult);
                    searchResultCallback.ReportResult(curResult);
                }
            }
        }
		void AllResults (WorkerResult lastResult, WorkerResult newResult, CancellationToken token)
		{
			if (newResult.isGotoFilePattern)
				return;
			uint x = 0;
			// Search Types
			if (newResult.IncludeTypes && (newResult.Tag == null || typeTags.Any (t => t == newResult.Tag))) {
				newResult.filteredTypes = new List<ITypeDefinition> ();
				bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith (lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredTypes != null;
				var allTypes = startsWithLastFilter ? lastResult.filteredTypes : types;
				foreach (var type in allTypes) {
					if (unchecked(x++) % 100 == 0 && token.IsCancellationRequested)
						return;

					if (newResult.Tag != null) {
						if (newResult.Tag == "c" && type.Kind != TypeKind.Class)
							continue;
						if (newResult.Tag == "s" && type.Kind != TypeKind.Struct)
							continue;
						if (newResult.Tag == "i" && type.Kind != TypeKind.Interface)
							continue;
						if (newResult.Tag == "e" && type.Kind != TypeKind.Enum)
							continue;
						if (newResult.Tag == "d" && type.Kind != TypeKind.Delegate)
							continue;
					}
					SearchResult curResult = newResult.CheckType (type);
					if (curResult != null) {
						newResult.filteredTypes.Add (type);
						newResult.results.AddResult (curResult);
					}
				}
			}
			
			// Search members
			if (newResult.IncludeMembers && (newResult.Tag == null || memberTags.Any (t => t == newResult.Tag))) {
				newResult.filteredMembers = new List<Tuple<ITypeDefinition, IUnresolvedMember>> ();
				bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith (lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredMembers != null;
				if (startsWithLastFilter) {
					foreach (var t in lastResult.filteredMembers) {
						if (unchecked(x++) % 100 == 0 && token.IsCancellationRequested)
							return;
						var member = t.Item2;
						if (newResult.Tag != null) {
							if (newResult.Tag == "m" && member.EntityType != EntityType.Method)
								continue;
							if (newResult.Tag == "p" && member.EntityType != EntityType.Property)
								continue;
							if (newResult.Tag == "f" && member.EntityType != EntityType.Field)
								continue;
							if (newResult.Tag == "evt" && member.EntityType != EntityType.Event)
								continue;
						}
						SearchResult curResult = newResult.CheckMember (t.Item1, member);
						if (curResult != null) {
							newResult.filteredMembers.Add (t);
							newResult.results.AddResult (curResult);
						}
					}
				} else {
					Func<IUnresolvedMember, bool> mPred = member => {
						if (newResult.Tag != null) {
							if (newResult.Tag == "m" && member.EntityType != EntityType.Method)
								return false;
							if (newResult.Tag == "p" && member.EntityType != EntityType.Property)
								return false;
							if (newResult.Tag == "f" && member.EntityType != EntityType.Field)
								return false;
							if (newResult.Tag == "evt" && member.EntityType != EntityType.Event)
								return false;
						}
						return newResult.IsMatchingMember (member);
					};

					getMembersTimer.BeginTiming ();
					try {
						foreach (var type in types) {
							if (type.Kind == TypeKind.Delegate)
								continue;
							foreach (var p in type.Parts) {
								foreach (var member in p.Members.Where (mPred)) {
									if (unchecked(x++) % 100 == 0 && token.IsCancellationRequested)
										return;
									SearchResult curResult = newResult.CheckMember (type, member);
									if (curResult != null) {
										newResult.filteredMembers.Add (Tuple.Create (type, member));
										newResult.results.AddResult (curResult);
									}
								}
							}
						}
					} finally {
						getMembersTimer.EndTiming ();
					}
				}
			}
		}
		void AllResults (ISearchResultCallback searchResultCallback, WorkerResult lastResult, WorkerResult newResult, IReadOnlyList<DeclaredSymbolInfo> completeTypeList, CancellationToken token)
		{
			if (newResult.isGotoFilePattern)
				return;
			uint x = 0;
			// Search Types
			newResult.filteredSymbols = new List<DeclaredSymbolInfo> ();
			bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith (lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredSymbols != null;
			var allTypes = startsWithLastFilter ? lastResult.filteredSymbols : completeTypeList;
			foreach (var type in allTypes) {
				if (unchecked(x++) % 100 == 0 && token.IsCancellationRequested) {
					newResult.filteredSymbols = null;
					return;
				}

				if (type.Kind == DeclaredSymbolInfoKind.Constructor ||
				    type.Kind == DeclaredSymbolInfoKind.Module ||
				    type.Kind == DeclaredSymbolInfoKind.Indexer)
					continue;
				
				if (newResult.Tag != null) {
					if ((newResult.Tag == "type" || newResult.Tag == "t") && type.Kind != DeclaredSymbolInfoKind.Class && type.Kind != DeclaredSymbolInfoKind.Struct && type.Kind != DeclaredSymbolInfoKind.Interface && type.Kind != DeclaredSymbolInfoKind.Enum && type.Kind != DeclaredSymbolInfoKind.Delegate)
					    continue;
					
					if (newResult.Tag == "class" && type.Kind != DeclaredSymbolInfoKind.Class)
						continue;
				    if (newResult.Tag == "struct" && type.Kind != DeclaredSymbolInfoKind.Struct)
						continue;
				    if (newResult.Tag == "interface" && type.Kind != DeclaredSymbolInfoKind.Interface)
						continue;
				    if (newResult.Tag == "enum" && type.Kind != DeclaredSymbolInfoKind.Enum)
						continue;
				    if (newResult.Tag == "delegate" && type.Kind != DeclaredSymbolInfoKind.Delegate)
						continue;

					if ((newResult.Tag == "member" || newResult.Tag == "m") && type.Kind != DeclaredSymbolInfoKind.Method && type.Kind != DeclaredSymbolInfoKind.Property && type.Kind != DeclaredSymbolInfoKind.Field && type.Kind != DeclaredSymbolInfoKind.Event)
					    continue;
					if (newResult.Tag == "method" && type.Kind != DeclaredSymbolInfoKind.Method)
						continue;
					if (newResult.Tag == "property" && type.Kind != DeclaredSymbolInfoKind.Property)
						continue;
					if (newResult.Tag == "field" && type.Kind != DeclaredSymbolInfoKind.Field)
						continue;
					if (newResult.Tag == "event" && type.Kind != DeclaredSymbolInfoKind.Event)
						continue;
					
				}
				SearchResult curResult = newResult.CheckType (type);
				if (curResult != null) {
					newResult.filteredSymbols.Add (type);
					newResult.results.AddResult (curResult);
					searchResultCallback.ReportResult (curResult);
				}
			}
		}
        IEnumerable <SearchResult> AllResults(BackgroundWorker worker, WorkerResult lastResult, WorkerResult newResult)
        {
            string toMatch = newResult.pattern;
            int    i       = toMatch.IndexOf(':');

            if (i != -1)
            {
                toMatch = toMatch.Substring(0, i);
            }

            // Search files
            if (newResult.IncludeFiles)
            {
                newResult.filteredFiles = new List <ProjectFile> ();
                bool startsWithLastFilter          = lastResult.pattern != null && toMatch.StartsWith(lastResult.pattern) && lastResult.filteredFiles != null;
                IEnumerable <ProjectFile> allFiles = startsWithLastFilter ? lastResult.filteredFiles : files;
                foreach (ProjectFile file in allFiles)
                {
                    if (worker.CancellationPending)
                    {
                        yield break;
                    }
                    SearchResult curResult = newResult.CheckFile(file, toMatch);
                    if (curResult != null)
                    {
                        newResult.filteredFiles.Add(file);
                        yield return(curResult);
                    }
                }
            }

            // Search Types
            if (newResult.IncludeTypes)
            {
                newResult.filteredTypes = new List <IType> ();
                bool         startsWithLastFilter = lastResult.pattern != null && toMatch.StartsWith(lastResult.pattern) && lastResult.filteredTypes != null;
                List <IType> allTypes             = startsWithLastFilter ? lastResult.filteredTypes : types;
                foreach (IType type in allTypes)
                {
                    if (worker.CancellationPending)
                    {
                        yield break;
                    }
                    SearchResult curResult = newResult.CheckType(type, toMatch);
                    if (curResult != null)
                    {
                        newResult.filteredTypes.Add(type);
                        yield return(curResult);
                    }
                }
            }

            // Search members
            if (newResult.IncludeMembers)
            {
                newResult.filteredMembers = new List <IMember> ();
                bool           startsWithLastFilter = lastResult.pattern != null && toMatch.StartsWith(lastResult.pattern) && lastResult.filteredMembers != null;
                List <IMember> allMembers           = startsWithLastFilter ? lastResult.filteredMembers : members;
                foreach (IMember member in allMembers)
                {
                    if (worker.CancellationPending)
                    {
                        yield break;
                    }
                    SearchResult curResult = newResult.CheckMember(member, toMatch);
                    if (curResult != null)
                    {
                        newResult.filteredMembers.Add(member);
                        yield return(curResult);
                    }
                }
            }
        }