Exemplo n.º 1
0
        IEnumerable <IMethod> CollectMethods(AstNode resolvedNode, MethodGroupResolveResult resolveResult)
        {
            var  lookup     = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
            bool onlyStatic = false;

            if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic || resolveResult.TargetResult is TypeResolveResult)
            {
                onlyStatic = true;
            }
            foreach (var method in resolveResult.Methods)
            {
                if (method.IsConstructor)
                {
                    continue;
                }
                if (!lookup.IsAccessible(method, true))
                {
                    continue;
                }
                if (onlyStatic && !method.IsStatic)
                {
                    continue;
                }
                yield return(method);
            }

            foreach (var extMethods in resolveResult.GetEligibleExtensionMethods(true))
            {
                foreach (var method in extMethods)
                {
                    yield return(method);
                }
            }
        }
        IEnumerable <IMethod> CollectMethods(AstNode resolvedNode, MethodGroupResolveResult resolveResult)
        {
            var  lookup     = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
            bool onlyStatic = false;

            if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic || resolveResult.TargetResult is TypeResolveResult)
            {
                onlyStatic = true;
            }
            var methods = new List <IMethod>();

            foreach (var method in resolveResult.Methods)
            {
                if (method.IsConstructor)
                {
                    continue;
                }
                if (!lookup.IsAccessible(method, true))
                {
                    continue;
                }
                if (onlyStatic && !method.IsStatic)
                {
                    continue;
                }
                if (method.IsShadowing)
                {
                    for (int j = 0; j < methods.Count; j++)
                    {
                        if (ParameterListComparer.Instance.Equals(methods[j].Parameters, method.Parameters))
                        {
                            methods.RemoveAt(j);
                            j--;
                        }
                    }
                }
                methods.Add(method);
            }
            foreach (var m in methods)
            {
                yield return(m);
            }
            foreach (var extMethods in resolveResult.GetEligibleExtensionMethods(true))
            {
                foreach (var method in extMethods)
                {
                    if (methods.Contains(method))
                    {
                        continue;
                    }
                    yield return(new ReducedExtensionMethod(method));
                }
            }
        }
		IEnumerable<ICompletionData> CreateParameterCompletion(MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, SyntaxTree unit, int parameter, bool controlSpace)
		{
			var result = new CompletionDataWrapper(this);
			var addedEnums = new HashSet<string>();
			var addedDelegates = new HashSet<string>();
			
			foreach (var method in resolveResult.Methods) {
				CreateParameterForInvocation(result, method, state, parameter, addedEnums, addedDelegates);
			}
			foreach (var methods in resolveResult.GetEligibleExtensionMethods (true)) {
				foreach (var method in methods) {
					if (resolveResult.Methods.Contains (method))
						continue;
					CreateParameterForInvocation(result, new ReducedExtensionMethod (method), state, parameter, addedEnums, addedDelegates);
				}
			}
			
			foreach (var method in resolveResult.Methods) {
				if (parameter < method.Parameters.Count && method.Parameters [parameter].Type.Kind == TypeKind.Delegate) {
					AutoSelect = false;
					AutoCompleteEmptyMatch = false;
				}
				foreach (var p in method.Parameters) {
					result.AddNamedParameterVariable(p);
				}
			}
			
			if (!controlSpace) {
				if (addedEnums.Count + addedDelegates.Count == 0) {
					return Enumerable.Empty<ICompletionData>();
				}
				AutoCompleteEmptyMatch = false;
				AutoSelect = false;
			}
			AddContextCompletion(result, state, invocation);
			
			//			resolver.AddAccessibleCodeCompletionData (ExpressionContext.MethodBody, cdc);
			//			if (addedDelegates.Count > 0) {
			//				foreach (var data in result.Result) {
			//					if (data is MemberCompletionData) 
			//						((MemberCompletionData)data).IsDelegateExpected = true;
			//				}
			//			}
			return result.Result;
		}
		IEnumerable<IMethod> CollectMethods(AstNode resolvedNode, MethodGroupResolveResult resolveResult)
		{
			var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
			bool onlyStatic = false;
			if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic || resolveResult.TargetResult is TypeResolveResult) {
				onlyStatic = true;
			}
			var methods = new List<IMethod>();
			foreach (var method in resolveResult.Methods) {
				if (method.IsConstructor) {
					continue;
				}
				if (!lookup.IsAccessible (method, true))
					continue;
				if (onlyStatic && !method.IsStatic) {
					continue;
				}
				if (method.IsShadowing) {
					for (int j = 0; j < methods.Count; j++) {
						if (ParameterListComparer.Instance.Equals(methods[j].Parameters, method.Parameters)) {
							methods.RemoveAt (j);
							j--;
						}
					}
				}
				methods.Add (method);
			}
			foreach (var m in methods) {
				yield return m;
			}
			foreach (var extMethods in resolveResult.GetEligibleExtensionMethods (true)) {
				foreach (var method in extMethods) {
					if (methods.Contains (method))
						continue;
					yield return new ReducedExtensionMethod (method);
				}
			}
		}