Inheritance: MonoDevelop.Ide.Gui.Content.CompletionTextEditorExtension
Exemplo n.º 1
0
 void AddContentsFromOuterClass(IType outer, ExpressionContext context, FSharpTextEditorCompletion.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);
 }
Exemplo n.º 2
0
 static void AddParameterList(FSharpTextEditorCompletion.CompletionDataCollector col, IEnumerable<IParameter> parameters)
 {
     foreach (IParameter p in parameters) {
         col.Add (p);
     //				completionList.Add (p.Name, "md-literal");
     }
 }
Exemplo n.º 3
0
        void AddContentsFromClassAndMembers(ExpressionContext context, FSharpTextEditorCompletion.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.DeclaringType, 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);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public FSharpTextEditorCompletion.CompletionDataCollector AddAccessibleCodeCompletionData(ExpressionContext context, FSharpTextEditorCompletion.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) {
                                if (new DomLocation (callingMemberline + v.StartPos.Line - 2, v.StartPos.Column) <= this.resolvePosition && (v.EndPos.IsEmpty || new DomLocation (callingMemberline + v.EndPos.Line - 2, v.EndPos.Column) >= this.resolvePosition)) {
                                    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;
                    }
                    ICompletionData 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;
        }