Ejemplo n.º 1
0
        public void ParseInterface()
        {
            FClass fclass = new FClass();
            int    last   = parseLine.ToString().IndexOf("{");
            int    start  = parseLine.ToString().IndexOf("interface");

            fclass.CName        = parseLine.ToString().Substring(start + 10, last - start - 10).Trim();
            fclass.CIsInterface = true;
            fclass.CId          = inputSource.ElementID;
            parseLine.Remove(0, last + 1);
            int index = fclass.IndexOf(inputSource.ListOfNamespaces, statusOfNamespace[statusOfNamespace.Count - 1], fclass);//kontrollon klasa a eshte ne listen e namspacave e rujtun ma heret dhe e mer indexin e asaj klase

            //[para se me e fut kalsen po vesim a eziston edhe nese po po ja marrim indexin poziten e klases edhe qka po parsojm po vendosim ne ate klase
            if (index == -1)
            {
                inputSource.ListOfNamespaces[statusOfNamespace[statusOfNamespace.Count - 1]].NClasses.Add(fclass);
                statusOfClass.Add(inputSource.ListOfNamespaces[statusOfNamespace[statusOfNamespace.Count - 1]].NClasses.Count - 1);
                inputSource.ElementID++;
            }
            else
            {
                statusOfClass.Add(index);
            }
            ParseInterface pI = new ParseInterface(this);

            pI.ProcessInterfaceLine();
        }
Ejemplo n.º 2
0
        public void ParseStruct()
        {
            FClass fclass = new FClass();

            lastIndex  = parseLine.ToString().IndexOf("{");
            fclass.CId = inputSource.ElementID;

            if (statusOfClass.Count > 0)
            {
                fclass.ParentClass.Add(inputSource.ListOfNamespaces[statusOfNamespace[statusOfNamespace.Count - 1]].NClasses[statusOfClass[statusOfClass.Count - 1]].CName);
            }
            fclass.CName = parseLine.ToString().Substring(startIndex + 7, lastIndex - (startIndex + 7)).Trim();

            if ((parseLine.ToString().IndexOf("abstract") > -1) && (parseLine.ToString().IndexOf("abstract") < lastIndex))
            {
                fclass.CIsAbstract = true;
            }
            fclass.CIsInterface = false;
            fclass.CIsEnum      = false;
            fclass.CIsStruct    = true;

            fclass.CStub      = false;
            fclass.CBelongsTo = inputSource.ListOfNamespaces[statusOfNamespace[statusOfNamespace.Count - 1]].NId;

            parseLine.Remove(0, lastIndex + 1);
            inputSource.ElementID++;
            inputSource.ListOfNamespaces[statusOfNamespace[statusOfNamespace.Count - 1]].NClasses.Add(fclass);
            statusOfClass.Add(inputSource.ListOfNamespaces[statusOfNamespace[statusOfNamespace.Count - 1]].NClasses.Count - 1);
        }
Ejemplo n.º 3
0
        public void ParseClass()
        {
            FClass fclass = new FClass();

            lastIndex  = parseLine.ToString().IndexOf("{");
            fclass.CId = inputSource.ElementID;

            if (statusOfClass.Count > 0)
            {
                fclass.ParentClass.Add(inputSource.ListOfNamespaces[statusOfNamepsace[statusOfNamepsace.Count - 1]].NClasses[statusOfClass[statusOfClass.Count - 1]].CName);
            }

            int           inherit = parseLine.ToString().IndexOf(":");
            List <string> name    = new List <string>();

            if ((inherit > -1) && (inherit < lastIndex))
            {
                string[] parent = parseLine.ToString().Substring(inherit + 1, lastIndex - (inherit + 1)).Split(',');
                if (parent.Length > 0)
                {
                    for (int i = 0; i < parent.Length; i++)
                    {
                        fclass.ParentClass.Add(parent[i].Trim());
                    }
                }
                fclass.CName = parseLine.ToString().Substring(startIndex + 5, inherit - (startIndex + 5)).Trim();
            }
            else
            {
                fclass.CName = parseLine.ToString().Substring(startIndex + 5, lastIndex - (startIndex + 5)).Trim();
            }

            if ((parseLine.ToString().IndexOf("abstarct") > -1) && (parseLine.ToString().IndexOf("abstract") < lastIndex))
            {
                fclass.CIsAbstract = true;
            }
            fclass.CIsInterface = false;
            fclass.CIsEnum      = false;
            fclass.CIsStruct    = false;

            fclass.CStub = false;

            fclass.CBelongsTo = inputSource.ListOfNamespaces[statusOfNamepsace[statusOfNamepsace.Count - 1]].NId;


            int index = fclass.IndexOf(inputSource.ListOfNamespaces, statusOfNamepsace[statusOfNamepsace.Count - 1], fclass);

            if (index == -1)
            {
                inputSource.ListOfNamespaces[statusOfNamepsace[statusOfNamepsace.Count - 1]].NClasses.Add(fclass);
                statusOfClass.Add(inputSource.ListOfNamespaces[statusOfNamepsace[statusOfNamepsace.Count - 1]].NClasses.Count - 1);
                inputSource.ElementID++;
            }
            else
            {
                statusOfClass.Add(index);
            }
            parseLine.Remove(0, lastIndex + 1);
        }
Ejemplo n.º 4
0
 public int IndexOf(List <FNamespace> listOfNamespace, int indexOfNamespace, FClass fClass)
 {
     for (int i = 0; i < listOfNamespace[indexOfNamespace].NClasses.Count; i++)
     {
         if (listOfNamespace[indexOfNamespace].NClasses[i].cName == fClass.cName)
         {
             return(i);
         }
     }
     return(-1);
 }
Ejemplo n.º 5
0
        public int FindMethod(string s)
        {
            FClass fClass = new FClass();

            for (int i = 0; i < fClass.CMethods.Count; i++)
            {
                if (s.CompareTo(fClass.CMethods[i].MName) == 0)
                {
                    return(parser.inputSource.ListOfNamespaces[parser.statusOfNamepsace[parser.statusOfNamepsace.Count - 1]].NClasses[parser.statusOfClass[parser.statusOfClass.Count - 1]].CMethods[i].MId);
                }
            }
            return(0);
        }
Ejemplo n.º 6
0
        public void ParseClass()
        {
            FClass fclass = new FClass();

            lastIndex  = parseLine.ToString().IndexOf("{");
            fclass.CId = inputSource.ElementID;

            // Due to a bug (or limitation) a class can not be assigned to a namespace, if it's not the first class declaration in .cs file.
            // This can cause an ArgumentOutOfRangeException. To prevent this we create an "Empty Namespace".
            var nameSpace    = _defaultNamespace;
            int nameSpaceIdx = 0;

            if (statusOfNamespace.Count > 0)
            {
                nameSpaceIdx = statusOfNamespace[statusOfNamespace.Count - 1];
                nameSpace    = inputSource.ListOfNamespaces[nameSpaceIdx];
            }
            else
            {
                inputSource.ListOfNamespaces.Add(_defaultNamespace);
                statusOfNamespace.Add(0);
            }

            if (statusOfClass.Count > 0)
            {
                fclass.ParentClass.Add(nameSpace.NClasses[statusOfClass[statusOfClass.Count - 1]].CName);
            }

            int           inherit = parseLine.ToString().IndexOf(":");
            List <string> name    = new List <string>();

            if ((inherit > -1) && (inherit < lastIndex))
            {
                string[] parent = parseLine.ToString().Substring(inherit + 1, lastIndex - (inherit + 1)).Split(',');
                if (parent.Length > 0)
                {
                    for (int i = 0; i < parent.Length; i++)
                    {
                        fclass.ParentClass.Add(parent[i].Trim());
                    }
                }
                fclass.CName = parseLine.ToString().Substring(startIndex + 5, inherit - (startIndex + 5)).Trim();
            }
            else
            {
                fclass.CName = parseLine.ToString().Substring(startIndex + 5, lastIndex - (startIndex + 5)).Trim();
            }

            if ((parseLine.ToString().IndexOf("abstract") > -1) && (parseLine.ToString().IndexOf("abstract") < lastIndex))
            {
                fclass.CIsAbstract = true;
            }
            fclass.CIsInterface = false;
            fclass.CIsEnum      = false;
            fclass.CIsStruct    = false;
            fclass.CStub        = false;
            fclass.CBelongsTo   = nameSpace.NId;

            int index = fclass.IndexOf(inputSource.ListOfNamespaces, nameSpaceIdx, fclass);

            if (index == -1)
            {
                nameSpace.NClasses.Add(fclass);
                statusOfClass.Add(nameSpace.NClasses.Count - 1);
                inputSource.ElementID++;
            }
            else
            {
                statusOfClass.Add(index);
            }
            parseLine.Remove(0, lastIndex + 1);
        }