Ejemplo n.º 1
0
 static void TryAddExtension(LanguageProperties language, Action <IMethodOrProperty> methodFound, IMethodOrProperty ext, IReturnType resolvedType)
 {
     // now add the extension method if it fits the type
     if (MemberLookupHelper.IsApplicable(resolvedType, ext.Parameters[0].ReturnType, ext as IMethod))
     {
         IMethod method = ext as IMethod;
         if (method != null && method.TypeParameters.Count > 0)
         {
             IReturnType[] typeArguments = new IReturnType[method.TypeParameters.Count];
             MemberLookupHelper.InferTypeArgument(method.Parameters[0].ReturnType, resolvedType, typeArguments);
             for (int i = 0; i < typeArguments.Length; i++)
             {
                 if (typeArguments[i] != null)
                 {
                     ext            = (IMethod)ext.CreateSpecializedMember();
                     ext.ReturnType = ConstructedReturnType.TranslateType(ext.ReturnType, typeArguments, true);
                     for (int j = 0; j < ext.Parameters.Count; ++j)
                     {
                         ext.Parameters[j].ReturnType = ConstructedReturnType.TranslateType(ext.Parameters[j].ReturnType, typeArguments, true);
                     }
                     break;
                 }
             }
         }
         methodFound(ext);
     }
 }
Ejemplo n.º 2
0
        public static void AddContentsFromCalling(List <ICompletionEntry> result, IClass callingClass, IMember callingMember)
        {
            IMethodOrProperty methodOrProperty = callingMember as IMethodOrProperty;

            if (methodOrProperty != null)
            {
                foreach (IParameter p in methodOrProperty.Parameters)
                {
                    result.Add(new DefaultField.ParameterField(p.ReturnType, p.Name, methodOrProperty.Region, callingClass));
                }
                if (callingMember is IMethod)
                {
                    AddTypeParametersForCtrlSpace(result, ((IMethod)callingMember).TypeParameters);
                }
            }

            bool inStatic = false;

            if (callingMember != null)
            {
                inStatic = callingMember.IsStatic;
            }

            if (callingClass != null)
            {
                AddTypeParametersForCtrlSpace(result, callingClass.TypeParameters);


                List <ICompletionEntry> members = new List <ICompletionEntry>();
                IReturnType             t       = callingClass.DefaultReturnType;
                var language = callingClass.ProjectContent.Language;
                foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(t, callingClass, language, true))
                {
                    if ((!inStatic || m.IsStatic) && language.ShowMember(m, m.IsStatic))
                    {
                        result.Add(m);
                    }
                }
                members.Clear();
                IClass c = callingClass.DeclaringType;
                while (c != null)
                {
                    t = c.DefaultReturnType;
                    foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(t, c, language, true))
                    {
                        if (language.ShowMember(m, true))
                        {
                            result.Add(m);
                        }
                    }
                    c = c.DeclaringType;
                }
            }
        }
Ejemplo n.º 3
0
        public override bool IsReferenceTo(IEntity entity)
        {
            IClass c = entity as IClass;

            if (c != null)
            {
                IMethod m = resolvedMember as IMethod;
                return(m != null && m.IsConstructor &&
                       m.DeclaringType.FullyQualifiedName == c.FullyQualifiedName &&
                       m.DeclaringType.TypeParameters.Count == c.TypeParameters.Count);
            }
            else
            {
                return(MemberLookupHelper.IsSimilarMember(resolvedMember, entity as IMember));
            }
        }
Ejemplo n.º 4
0
        public override List <ICompletionEntry> GetCompletionData(IProjectContent projectContent)
        {
            if (this.ResolvedType == null)
            {
                return(null);
            }
            List <ICompletionEntry> res = new List <ICompletionEntry>();

            foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(this.ResolvedType, this.CallingClass, projectContent.Language, true))
            {
                if (projectContent.Language.ShowMember(m, false))
                {
                    res.Add(m);
                }
            }

            if (this.CallingClass != null)
            {
                AddExtensions(projectContent.Language, res.Add, this.CallingClass, this.ResolvedType);
            }

            return(res);
        }
Ejemplo n.º 5
0
        protected List <ICompletionEntry> GetCompletionData(LanguageProperties language, bool showStatic)
        {
            if (resolvedType == null)
            {
                return(null);
            }
            List <ICompletionEntry> res = new List <ICompletionEntry>();

            foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(resolvedType, callingClass, language))
            {
                if (language.ShowMember(m, showStatic))
                {
                    res.Add(m);
                }
            }

            if (!showStatic && callingClass != null)
            {
                AddExtensions(language, res.Add, callingClass, resolvedType, this.showAllNamespacesContentsInCC);
            }

            return(res);
        }
Ejemplo n.º 6
0
        public static bool ImplementsAbstractClass(this IClass targetClass, IClass abstractClass)
        {
            var requiredAbstractMembers = MemberLookupHelper.GetAccessibleMembers(abstractClass.DefaultReturnType, targetClass, LanguageProperties.CSharp, true).Where(m => m.IsAbstract);

            return(!requiredAbstractMembers.Any(missingMember => !targetClass.HasMember(missingMember)));
        }
Ejemplo n.º 7
0
 public override bool IsReferenceTo(IEntity entity)
 {
     return(MemberLookupHelper.IsSimilarMember(GetMethodIfSingleOverload(), entity as IMember));
 }