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 (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.º 3
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);
                        }
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }