Exemple #1
0
        public override void doActionUsing(CSsemi.CSemiExp semi)
        {
            UsingElem usingelem        = new UsingElem();
            Elem      elem             = new Elem();
            bool      existingfunction = false;
            string    classname        = semi[0];
            string    functionname     = semi[1];
            string    type             = semi[2];
            string    typename         = semi[3];

            for (int i = 0; i < repo_.analyzedata.Count; i++)
            {
                elem = repo_.analyzedata[i];
                if ((elem.type == "struct" || elem.type == "enum" || elem.type == "class" || elem.type == "interface") &&
                    type == elem.name)
                {
                    for (int j = 0; j < repo_.usingdata.Count; j++)
                    {
                        usingelem = repo_.usingdata[j];
                        if (functionname == usingelem.containingfunction)
                        {
                            existingfunction = true;
                            TypeDetails typeDetails = new TypeDetails();
                            usingelem.parent             = classname;
                            usingelem.containingfunction = functionname;
                            typeDetails.type             = type;
                            typeDetails.usedtypename     = typename;
                            usingelem.typeslist.Add(typeDetails);
                            int index = repo_.usingdata.IndexOf(usingelem);
                            repo_.usingdata.Remove(usingelem);
                            repo_.usingdata.Insert(index, usingelem);
                        }
                    }

                    if (!existingfunction)
                    {
                        TypeDetails typeDetails = new TypeDetails();
                        usingelem                    = new UsingElem();
                        usingelem.parent             = classname;
                        usingelem.containingfunction = functionname;
                        typeDetails.type             = type;
                        typeDetails.usedtypename     = typename;
                        usingelem.typeslist.Add(typeDetails);
                        repo_.usingdata.Add(usingelem);
                    }
                }
            }
        }
        /// <summary>
        /// stores the semi into the using element
        /// </summary>
        /// <param name="semi">the semi to be stored</param>
        public override void doActionUsing(CSsemi.CSemiExp semi)
        {
            UsingElem usingelem = new UsingElem();
            Elem elem = new Elem();
            bool existingfunction = false;
            string classname = semi[0];
            string functionname = semi[1];
            string type = semi[2];
            string typename = semi[3];

            for (int i = 0; i < repo_.analyzedata.Count; i++)
            {
                elem = repo_.analyzedata[i];
                if ((elem.type == "struct" || elem.type == "enum" || elem.type == "class" || elem.type == "interface") && type == elem.name)
                {
                    for (int j = 0; j < repo_.usingdata.Count; j++)
                    {
                        usingelem = repo_.usingdata[j];
                        if (functionname == usingelem.containingfunction)
                        {
                            existingfunction = true;
                            TypeDetails typeDetails = new TypeDetails();
                            usingelem.parent = classname;
                            usingelem.containingfunction = functionname;
                            typeDetails.type = type;
                            typeDetails.usedtypename = typename;
                            usingelem.typeslist.Add(typeDetails);
                            int index = repo_.usingdata.IndexOf(usingelem);
                            repo_.usingdata.Remove(usingelem);
                            repo_.usingdata.Insert(index, usingelem);
                        }
                    }
                    if (!existingfunction)
                    {
                        TypeDetails typeDetails = new TypeDetails();
                        usingelem = new UsingElem();
                        usingelem.parent = classname;
                        usingelem.containingfunction = functionname;
                        typeDetails.type = type;
                        typeDetails.usedtypename = typename;
                        usingelem.typeslist.Add(typeDetails);
                        repo_.usingdata.Add(usingelem);
                    }
                    createPackageAnalysisList("Using", semi, i);
                }
            }
        }