Ejemplo n.º 1
0
 public override SymInfo[] GetNamesAsInObject()
 {
     List<SymInfo> syms = new List<SymInfo>();
     if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
         return syms.ToArray();
     MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance);
     foreach (MemberInfo mi in mis)
         if (!mi.Name.Contains("$"))
             switch (mi.MemberType)
             {
                 case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName)
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                         syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Field:
                     {
                         if (!(mi as FieldInfo).IsSpecialName)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                             if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                             si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                             syms.Add(si2);
                         }
                         //syms.Add(new SymInfo(mi.Name,SymbolKind.Field,mi.Name)); break;
                     }
                     break;
                 case MemberTypes.Property:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                         si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                         syms.Add(si2);
                         //syms.Add(new SymInfo(mi.Name,SymbolKind.Property,mi.Name));
                     }
                     break;
                 case MemberTypes.Event:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                         si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                         syms.Add(si2);
                         //syms.Add(new SymInfo(mi.Name,SymbolKind.Event,mi.Name));
                     }
                     break;
             }
     return syms.ToArray();
 }
Ejemplo n.º 2
0
        public override SymInfo[] GetNames()
        {
            List<SymInfo> syms = new List<SymInfo>();
            if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
                return syms.ToArray();
            MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy);
            if (ctn.IsInterface)
            {
                List<MemberInfo> mems = new List<MemberInfo>();
                mems.AddRange(mis);
                mems.AddRange(typeof(object).GetMembers());
                Type[] types = ctn.GetInterfaces();
                foreach (Type t in types)
                    mems.AddRange(t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy));
                mis = mems.ToArray();
            }
            if (si.kind != SymbolKind.Type)
            {
                foreach (MemberInfo mi in mis)
                    if (!mi.Name.Contains("$"))
                        switch (mi.MemberType)
                        {
                            case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                    si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                                    syms.Add(si2);
                                }
                                break;
                            case MemberTypes.Field:
                                {
                                    if (!(mi as FieldInfo).IsSpecialName)
                                    {
                                        SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                                        if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                                        si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                                        syms.Add(si2);
                                    }
                                    //syms.Add(new SymInfo(mi.Name,SymbolKind.Field,mi.Name)); break;
                                }
                                break;
                            case MemberTypes.Property:
                                {
                                    PropertyInfo pi = mi as PropertyInfo;
                                    MethodInfo acc_mi = pi.GetGetMethod(true);
                                    if (acc_mi != null && !acc_mi.IsStatic)
                                    {
                                        SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                                        si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                                        syms.Add(si2);
                                    }
                                    //syms.Add(new SymInfo(mi.Name,SymbolKind.Property,mi.Name));
                                }
                                break;
                            case MemberTypes.Event:
                                {
                                    MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                                    if (acc_mi.IsPublic && !acc_mi.IsStatic)
                                    {
                                        SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                                        si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                                        syms.Add(si2);
                                    }
                                    //syms.Add(new SymInfo(mi.Name,SymbolKind.Event,mi.Name));
                                }
                                break;
                        }
            }
            else
                foreach (MemberInfo mi in mis)
                    switch (mi.MemberType)
                    {
                        case MemberTypes.Method: if (!((mi as MethodInfo).IsSpecialName) && (mi as MethodInfo).IsStatic)
                            {
                                SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                                syms.Add(si2);
                            }
                            break;
                        case MemberTypes.Field:
                            {
                                if ((mi as FieldInfo).IsStatic && !(mi as FieldInfo).IsSpecialName)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                                    if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                                    si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                                    syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Property:
                            {
                                PropertyInfo pi = mi as PropertyInfo;
                                MethodInfo acc_mi = pi.GetGetMethod(true);
                                if (acc_mi != null && acc_mi.IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                                    si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                                    syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Event:
                            {
                                MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                                if (acc_mi.IsPublic && acc_mi.IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                                    si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                                    syms.Add(si2);
                                }
                                //syms.Add(new SymInfo(mi.Name,SymbolKind.Event,mi.Name));
                            }
                            break;
                    }

            return syms.ToArray();
        }
Ejemplo n.º 3
0
        public SymInfo[] GetStaticNames()
        {
            List<SymInfo> syms = new List<SymInfo>();
            if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
                return syms.ToArray();
            MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy);

            if (ctn.IsInterface)
            {
                return syms.ToArray();
            }
            foreach (MemberInfo mi in mis)
                if (!mi.Name.Contains("$"))
                    switch (mi.MemberType)
                    {
                        case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName && (mi as MethodInfo).IsStatic)
                            {
                                SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                CompiledMethodScope member = new CompiledMethodScope(si2, mi as MethodInfo, this);
                                si2 = member.si;
                                if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                    syms.Add(si2);
                            }
                            break;
                        case MemberTypes.Field:
                            {
                                if (!(mi as FieldInfo).IsSpecialName && (mi as FieldInfo).IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                                    if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                                    si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                                    if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                        syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Constructor:
                            {
                                SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                                CompiledConstructorScope member = new CompiledConstructorScope(si2, mi as ConstructorInfo, this);
                                si2 = member.si;
                                if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                    syms.Add(si2);
                            }
                            break;
                        case MemberTypes.Property:
                            {
                                PropertyInfo pi = mi as PropertyInfo;
                                if (pi.GetGetMethod(true) != null && pi.GetGetMethod(true).IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                                    si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                                    if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                        syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.Event:
                            {
                                MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                                if (acc_mi != null && acc_mi.IsStatic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                                    si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                                    syms.Add(si2);
                                    if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                        syms.Add(si2);
                                }
                            }
                            break;
                        case MemberTypes.NestedType:
                            {
                                if ((mi as Type).IsNestedPublic)
                                {
                                    SymInfo si2 = new SymInfo(null, SymbolKind.Type, null);
                                    CompiledScope member = TypeTable.get_compiled_type(si2, mi as Type);
                                    si2 = member.si;
                                    syms.Add(si2);
                                }
                            }
                            break;
                    }
            return syms.ToArray();
        }
Ejemplo n.º 4
0
 public override SymInfo[] GetNamesAsInObject(ExpressionVisitor ev)
 {
     List<SymInfo> syms = new List<SymInfo>();
     if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
         return syms.ToArray();
     MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
     List<MemberInfo> members = new List<MemberInfo>();
     members.AddRange(mis);
     IEnumerable<MemberInfo> en = PascalABCCompiler.NetHelper.NetHelper.GetExtensionMethods(ctn);
     members.AddRange(en);
     mis = members.ToArray();
     if (ctn.IsInterface)
     {
         List<MemberInfo> mems = new List<MemberInfo>();
         mems.AddRange(mis);
         mems.AddRange(typeof(object).GetMembers(BindingFlags.Public | BindingFlags.Instance));
         Type[] types = ctn.GetInterfaces();
         foreach (Type t in types)
             mems.AddRange(t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy));
         mis = mems.ToArray();
     }
     foreach (MemberInfo mi in mis)
         if (!mi.Name.Contains("$"))
             switch (mi.MemberType)
             {
                 case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName)
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         si2 = new CompiledMethodScope(si2, mi as MethodInfo, this).si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Field:
                     {
                         if (!(mi as FieldInfo).IsSpecialName)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                             if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                             si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.Property:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                         si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Event:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                         si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
             }
     if (implemented_interfaces != null && false)
     {
         foreach (TypeScope ts in implemented_interfaces)
             syms.AddRange(ts.GetNamesAsInObject(ev));
     }
     return syms.ToArray();
 }
Ejemplo n.º 5
0
 public override SymInfo[] GetNames(ExpressionVisitor ev, PascalABCCompiler.Parsers.KeywordKind keyword, bool called_in_base)
 {
     List<SymInfo> syms = new List<SymInfo>();
     if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities)
         return syms.ToArray();
     MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy);
     List<MemberInfo> constrs = new List<MemberInfo>();
     //constrs.AddRange(ctn.GetNestedTypes(BindingFlags.Public));
     //if (ctn != typeof(object))
     ConstructorInfo[] cis = ctn.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     foreach (ConstructorInfo ci in cis)
         if (!called_in_base)
             constrs.Add(ci);
         else if (ci.GetParameters().Length > 0)
             constrs.Add(ci);
     constrs.AddRange(mis);
     //constrs.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetExtensionMethods(ctn));
     mis = constrs.ToArray();
     if (ctn.IsInterface)
     {
         return syms.ToArray();
     }
     foreach (MemberInfo mi in mis)
         if (!mi.Name.Contains("$"))
             switch (mi.MemberType)
             {
                 case MemberTypes.Method: if (!(mi as MethodInfo).IsSpecialName && (mi as MethodInfo).IsStatic)
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         CompiledMethodScope member = new CompiledMethodScope(si2, mi as MethodInfo, this);
                         si2 = member.si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Field:
                     {
                         if (!(mi as FieldInfo).IsSpecialName && (mi as FieldInfo).IsStatic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Field, null);
                             if ((mi as FieldInfo).IsLiteral) si2.kind = SymbolKind.Constant;
                             si2 = new CompiledFieldScope(si2, mi as FieldInfo, this).si;
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.Constructor:
                     {
                         SymInfo si2 = new SymInfo(null, SymbolKind.Method, null);
                         CompiledConstructorScope member = new CompiledConstructorScope(si2, mi as ConstructorInfo, this);
                         si2 = member.si;
                         if (si2.acc_mod == access_modifer.protected_modifer)
                         {
                             if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                 syms.Add(si2);
                         }
                         else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                             syms.Add(si2);
                     }
                     break;
                 case MemberTypes.Property:
                     {
                         PropertyInfo pi = mi as PropertyInfo;
                         if (pi.GetGetMethod(true) != null && pi.GetGetMethod(true).IsStatic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Property, null);
                             si2 = new CompiledPropertyScope(si2, mi as PropertyInfo, this).si;
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.Event:
                     {
                         MethodInfo acc_mi = (mi as EventInfo).GetAddMethod(true);
                         if (acc_mi != null && acc_mi.IsStatic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Event, null);
                             si2 = new CompiledEventScope(si2, mi as EventInfo, this).si;
                             syms.Add(si2);
                             if (si2.acc_mod == access_modifer.protected_modifer)
                             {
                                 if (ev.CheckForBaseAccess(ev.entry_scope, this))
                                     syms.Add(si2);
                             }
                             else if (si2.acc_mod != access_modifer.private_modifer && si2.acc_mod != access_modifer.internal_modifer)
                                 syms.Add(si2);
                         }
                     }
                     break;
                 case MemberTypes.NestedType:
                     {
                         if ((mi as Type).IsNestedPublic)
                         {
                             SymInfo si2 = new SymInfo(null, SymbolKind.Type, null);
                             CompiledScope member = TypeTable.get_compiled_type(si2, mi as Type);
                             si2 = member.si;
                             syms.Add(si2);
                         }
                     }
                     break;
             }
     return syms.ToArray();
 }