void AddContentsFromClassAndMembers(ExpressionContext context, CSharpTextEditorCompletion.CompletionDataCollector col)
        {
            IMethod method = callingMember as IMethod;

            if (method != null && method.Parameters != null)
            {
                AddParameterList(col, method.Parameters);
            }
            IProperty property = callingMember as IProperty;

            if (property != null && property.Parameters != null)
            {
                AddParameterList(col, property.Parameters);
            }
            if (CallingType == null)
            {
                return;
            }

            AddContentsFromOuterClass(CallingType, context, col);
            IType callingType = CallingType is InstantiatedType ? ((InstantiatedType)CallingType).UninstantiatedType : CallingType;

            //bool isInStatic = CallingMember != null ? CallingMember.IsStatic : false;

            if (CallingMember == null || !CallingMember.IsStatic)
            {
                foreach (TypeParameter parameter in callingType.TypeParameters)
                {
                    col.Add(parameter.Name, "md-literal");
                }
            }

            if (context != ExpressionContext.TypeDeclaration && CallingMember != null)
            {
                bool includeProtected = DomType.IncludeProtected(dom, CallingType, CallingMember.DeclaringType);
                foreach (IType type in dom.GetInheritanceTree(CallingType))
                {
                    foreach (IMember member in type.Members)
                    {
                        if (!(member is IType) && CallingMember.IsStatic && !(member.IsStatic || member.IsConst))
                        {
                            continue;
                        }
                        if (member.IsAccessibleFrom(dom, CallingType, CallingMember, includeProtected))
                        {
                            if (context.FilterEntry(member))
                            {
                                continue;
                            }
                            col.Add(member);
                        }
                    }
                }
            }
        }
        static void AddParameterList(CSharpTextEditorCompletion.CompletionDataCollector col, IEnumerable <IParameter> parameters)
        {
            foreach (IParameter p in parameters)
            {
                col.Add(p);
//				completionList.Add (p.Name, "md-literal");
            }
        }
 void AddContentsFromOuterClass(IType outer, ExpressionContext context, CSharpTextEditorCompletion.CompletionDataCollector col)
 {
     if (outer == null)
     {
         return;
     }
     foreach (IMember member in outer.Members)
     {
         if (member is IType || member.IsStatic || member.IsConst)
         {
             col.Add(member);
         }
     }
     AddContentsFromOuterClass(outer.DeclaringType, context, col);
 }
        public CSharpTextEditorCompletion.CompletionDataCollector AddAccessibleCodeCompletionData(ExpressionContext context, CSharpTextEditorCompletion.CompletionDataCollector col)
        {
            if (context != ExpressionContext.Global && context != ExpressionContext.TypeName)
            {
                AddContentsFromClassAndMembers(context, col);

                if (lookupTableVisitor != null && lookupTableVisitor.Variables != null)
                {
//					int callingMemberline = CallingMember != null ? CallingMember.Location.Line : 0;
                    // local variables could be outside members (LINQ initializers)
                    foreach (KeyValuePair <string, List <LocalLookupVariable> > pair in lookupTableVisitor.Variables)
                    {
                        if (pair.Value != null && pair.Value.Count > 0)
                        {
                            foreach (LocalLookupVariable v in pair.Value)
                            {
                                DomLocation varStartPos = new DomLocation(lookupVariableLine + v.StartPos.Line, v.StartPos.Column - 1);
                                DomLocation varEndPos   = new DomLocation(lookupVariableLine + v.EndPos.Line, v.EndPos.Column - 1);
                                if (varStartPos > this.resolvePosition || (!v.EndPos.IsEmpty && varEndPos < this.resolvePosition))
                                {
                                    continue;
                                }
                                col.Add(new LocalVariable(CallingMember, pair.Key, ConvertTypeReference(v.TypeRef), DomRegion.Empty));
                            }
                        }
                    }
                }

                if (CallingMember is IProperty)
                {
                    IProperty property = (IProperty)callingMember;
                    if (property.HasSet && editor != null && property.SetRegion.Contains(resolvePosition.Line, editor.CursorColumn))
                    {
                        col.Add("value");
                    }
                }

                if (CallingMember is IEvent)
                {
                    col.Add("value");
                }
            }

            List <string> namespaceList = new List <string> ();

            namespaceList.Add("");

            List <string> namespaceDeclList = new List <string> ();

            namespaceDeclList.Add("");
            if (unit != null)
            {
                foreach (IUsing u in unit.Usings)
                {
                    foreach (string alias in u.Aliases.Keys)
                    {
                        col.Add(alias);
                    }
                    if (u.Namespaces == null)
                    {
                        continue;
                    }
                    bool isNamespaceDecl = u.IsFromNamespace && u.Region.Contains(this.resolvePosition);
                    if (u.IsFromNamespace && !isNamespaceDecl)
                    {
                        continue;
                    }
                    foreach (string ns in u.Namespaces)
                    {
                        namespaceList.Add(ns);
                        if (isNamespaceDecl)
                        {
                            namespaceDeclList.Add(ns);
                        }
                    }
                }

                foreach (object o in dom.GetNamespaceContents(namespaceList, true, true))
                {
                    if (context.FilterEntry(o))
                    {
                        continue;
                    }
                    if (o is Namespace)
                    {
                        Namespace ns   = o as Namespace;
                        bool      skip = true;
                        foreach (string str in namespaceDeclList)
                        {
                            if (dom.NamespaceExists(str.Length > 0 ? str + "." + ns.Name : ns.Name))
                            {
                                skip = false;
                                break;
                            }
                        }
                        if (skip)
                        {
                            continue;
                        }
                    }

                    //IMember member = o as IMember;
                    //if (member != null && completionList.Find (member.Name) != null)
                    //	continue;
                    if (context == ExpressionContext.Attribute)
                    {
                        IType t = o as IType;
                        if (t != null && !t.IsBaseType(attributeType))
                        {
                            continue;
                        }
                    }
                    CompletionData data = col.Add(o);
                    if (data != null && context == ExpressionContext.Attribute && data.CompletionText != null && data.CompletionText.EndsWith("Attribute"))
                    {
                        string newText = data.CompletionText.Substring(0, data.CompletionText.Length - "Attribute".Length);
                        data.SetText(newText);
                    }
                }
                CodeTemplateService.AddCompletionDataForMime("text/x-csharp", col.CompletionList);
            }
            return(col);
        }