Exemple #1
0
        //============================================================
        // <T>在方法节点的子节点中连接上方法的返回值节点
        //
        // @param node 返回值节点的父节点,即隶属于的方法节点
        // @param indextable 类型全名的索引表
        //============================================================
        private void ReturnNodeMaker(FXmlNode node, FClassesIndexTable indextable)
        {
            FXmlNode nodeRetrun = new FXmlNode("Return");

            if (this.ReturnType != "" && this.ReturnType != "void")
            {
                string strType = this.ReturnType;
                nodeRetrun.Set("type", this.ReturnType);
                FFileNode type = new FFileNode(this.ReturnType, GetUsing(_strLine));
                this.ReturnType = indextable.LookInMap(type, this.ReturnType);
                if (strType != this.ReturnType)
                {
                    nodeRetrun.Set("return_type", this.ReturnType);
                }
            }
            if (this.AnnotateReturn.Trim() != "")
            {
                nodeRetrun.Set("description", this.AnnotateReturn);
            }
            if (this.ReturnType.Trim() != "" && this.ReturnType.Trim() != "void")
            {
                node.Push(nodeRetrun);
            }
            FXmlNode resource = new FXmlNode("Source");

            resource.Text = MethodCode;
            node.Push(resource);
        }
Exemple #2
0
        //============================================================
        // <T>生成XML节点,并附加到父节点上。</T>
        //
        // @param nodeParent 属性节点的父节点
        // @param indextable 类型全名索引表
        // @param swPrint 用于打印警告的StreamWriter对象
        // @param file 警告所处在的文件
        // @param relative 被选取的文件夹的路径
        //============================================================
        public void XMLMaker(FXmlNode nodeParent, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
        {
            if (!IsProAnnoFine())
            {
                PrintAnnoWarning(swPrint, file, relative);
            }
            FXmlNode nodeProperty = new FXmlNode("Property");

            nodeProperty.Set("name", this.PropertyName);
            nodeProperty.Set("type", this.PropertyType);
            FFileNode type     = new FFileNode(this.PropertyType, GetUsing(_strLine));
            string    fulltype = indextable.LookInMap(type, this.PropertyType);

            if (fulltype != this.PropertyType)
            {
                nodeProperty.Set("full_name", fulltype);
            }
            if (this.AnnotateLable != "")
            {
                nodeProperty.Set("label", AnnotateLable);
            }
            if (this.AnnotateDescription != "")
            {
                nodeProperty.Set("description", AnnotateDescription);
            }
            nodeProperty.Set("access_level", AccessLevel);
            FXmlNode code = new FXmlNode("Source");

            code.Text = this.PropertyCode;
            nodeProperty.Push(code);
            nodeParent.Push(nodeProperty);
        }
Exemple #3
0
        //============================================================
        // <T>在字段节点的子节点中连接上方法的返回值节点
        //
        // @param nodeParent 返回值节点的父节点,即隶属于的方法节点
        // @param indextable 类型全名的索引表
        // @param swPrint 用于打印警告的StreamWriter对象
        // @param file 警告所处在的文件
        // @param relative 被选取的文件夹的路径
        //============================================================
        public void XMLMaker(FXmlNode nodeParent, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
        {
            if (!IsFieldAnnoFine())
            {
                PrintAnnoWarning(swPrint, file, relative);
            }
            FXmlNode nodeField = new FXmlNode("Field");

            nodeField.Set("name", this.FieldName);
            nodeField.Set("full_name", this.FullName);
            nodeField.Set("access_level", this.AccessLevel);
            nodeField.Set("type", this.Type);
            FFileNode type     = new FFileNode(this.Type, GetUsing(_strLines));
            string    fulltype = indextable.LookInMap(type, this.Type);

            if (Type != this.Type)
            {
                nodeField.Set("return_type", fulltype);
            }
            if (Description != "")
            {
                nodeField.Set("description", Description);
            }
            nodeParent.Push(nodeField);
        }
Exemple #4
0
        //============================================================
        // <T>解析文件。</T>
        //
        // @parame fileinfo 要解析的文件
        // @param index 解析对象
        //============================================================
        public void ParserFile(FileInfo file, string outputPath, FClassesIndexTable indextable, StreamWriter swPrint, string relative)
        {
            FStrings lines = GetLines(file.DirectoryName + "\\" + file.Name);

            for (int n = 0; n < lines.Count; n++)
            {
                //string line = ConvertToUTF8 ( lines[n].ToString() );
                if (IsSpace(lines[n].ToString()))
                {
                    FCsSpace space = new FCsSpace();
                    space.FillValue(lines, n, space.GetPairNum(lines, n));
                    string path = outputPath + "\\" + space.SpaceName.Trim();
                    space.ParserSpace(lines, n, path, indextable, swPrint, file, relative);
                }
            }
        }
Exemple #5
0
        //============================================================
        // <T>解析方法。</T>
        //
        // @parame strline 需要解析的字符串集合。
        // @param index 当前索引行的行号
        // @param swPrint 用于打印警告的StreamWriter对象
        // @param file 警告所处在的文件
        // @param relative 被选取的文件夹的路径
        //============================================================
        public void ParserMethod(FStrings strLine, int index, FXmlNode nodeClass, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
        {
            int    eindex    = strLine[index].Trim().IndexOf("(");
            int    end       = strLine[index].Trim().IndexOf(")");
            string methodStr = strLine[index].Trim().Substring(eindex + 1, end - eindex - 1);

            methodStr = ScanComma(methodStr);
            string[] strParams = methodStr.Split(new string[] { "$," }, StringSplitOptions.None);
            if ((strParams.Length == 1) && strParams[0] == "")
            {
                FXmlNode xmlmethod = new FXmlNode("Method");
                xmlmethod.Set("name", this.MethodName);
                xmlmethod.Set("full_name", this.FullMethodName);
                if (this.AnnotateLabel != "")
                {
                    xmlmethod.Set("label", this.AnnotateLabel);
                }
                if (this.AnnotateDescription != "")
                {
                    xmlmethod.Set("description", this.AnnotateDescription);
                }
                ReturnNodeMaker(xmlmethod, indextable);
                nodeClass.Push(xmlmethod);
                return;
            }
            if (strParams.Length != 0 && strParams[0] != "")
            {
                FXmlNode method = XMLMaker(nodeClass, swPrint, file, relative);
                for (int n = 0; n < strParams.Length; n++)
                {
                    FCsParameter param    = new FCsParameter();
                    FStrings     strAnnos = GetAnnotate(strLine, index);
                    param.FillValue(strLine, strAnnos, _beginIndex);
                    param.ParserParam(strParams[n], strAnnos, indextable);
                    param.XMLMaker(method, swPrint, file, relative);
                    if (param.ParameterName != "")
                    {
                        this.Parameter.Add(param);
                    }
                }
                ReturnNodeMaker(method, indextable);
            }
        }
Exemple #6
0
 //============================================================
 // <T>将属于参数的字符串对象传给参数对象后,解析参数。</T>
 //
 // @param param 属于参数的字符串。
 // @param stranno属于参数的注释内容
 // @param swPrint 用于打印警告的StreamWriter对象
 // @param file 警告所处在的文件
 // @param relative 被选取的文件夹的路径
 //============================================================
 public void ParserParam(string param, FStrings stranno, FClassesIndexTable indextable)
 {
     param = param.Trim();
     //int index=param.LastIndexOf(' ');
     //char[] c = param.ToArray<char>();
     string[] str = param.Trim().Split(new char[] { ' ' });
     if (str.Length > 1)
     {
         string paramtype = string.Empty, paramname = string.Empty;
         for (int n = 0; n < str.Length - 1; n++)
         {
             paramtype += str[n].ToString() + " ";
         }
         paramname           = str[str.Length - 1].ToString();
         this._parameterType = paramtype.Trim();
         FFileNode type = new FFileNode(_parameterType, GetUsing(_strLine));
         this._fulltype      = indextable.LookInMap(type, this._parameterType);
         this._parameterName = paramname.Trim();
     }
 }
Exemple #7
0
        //============================================================
        // <T>获取命名空间。</T>
        // @parame strline 需要获取的字符串集合。
        // @param index 当前索引
        // @return 获取的命名空间对象
        //============================================================
        public void ParserSpace(FStrings strLine, int index, string path, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
        {
            int start, end = CheckParaAnnotate(strLine, index, out start);

            for (index++; index < strLine.Count; index++)
            {
                if (IsInInterregional(index, start, end))
                {
                    continue;
                }
                if (IsClass(strLine[index]))
                {
                    int      endIndex = GetPairNum(strLine, index);
                    FCsClass aclass   = new FCsClass( );
                    aclass.FillValue(strLine, index, endIndex);
                    aclass.ParserClass(strLine, this, index, path, indextable, swPrint, file, relative);
                    this.Class.Add(aclass);
                }
            }
        }
Exemple #8
0
        //============================================================
        // <T>生成节点时,将此对象生成的节点连接到上层节点上</T>
        //
        // @param node 需要连接的父节点。
        // @param swPrint 用于打印警告的StreamWriter对象
        // @param file 警告所处在的文件
        // @param relative 被选取的文件夹的路径
        // @return 本对象生成的节点。
        //============================================================
        public FXmlNode XMLMaker(FXmlNode node, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
        {
            if (!IsClassAnnoFine())
            {
                PrintAnnoWarning(swPrint, file, relative);
            }
            FXmlNode classNode = new FXmlNode("Class");

            classNode.Set("name", this.ClassName);
            if (this.AccessLevel != "")
            {
                classNode.Set("access_level", this.AccessLevel);
            }
            if (this.Annotates != null && Annotates.Count > 0)
            {
                ParserClassAnnotate();
                if (Label.Trim() != "")
                {
                    classNode.Set("label", Label.Trim());
                }
                if (Description.Trim() != "")
                {
                    classNode.Set("description", Description.Trim());
                }
            }
            if (this.ParentsName != string.Empty)
            {
                FFileNode type = new FFileNode(this.ParentsName.Trim(), GetUsing(_strLine));
                this.ParentsName = indextable.LookInMap(type, this._parentName.Trim());
                classNode.Set("parent_class", ParentsName.Trim());
            }
            FXmlNode classCode = new FXmlNode("Source");

            classCode.Text = ClassCode;
            classNode.Push(classCode);
            node.Push(classNode);
            return(classNode);
        }
Exemple #9
0
        //============================================================
        //<T>将类所继承的接口作为子节点连接到类的节点下面</T>
        // @param interface 接口的字符串组
        // @param nodeClass 要连接的父节点,也就是类的节点
        //============================================================
        public void MakeInterfaceNode(FArray <string> interfaces, FXmlNode nodeClass, FClassesIndexTable indextable)
        {
            if (interfaces == null || interfaces.Length < 1)
            {
                return;
            }
            FXmlNode nodeInterface = new FXmlNode("Inherts");

            foreach (string str in interfaces)
            {
                FXmlNode  inhert    = new FXmlNode("Inhert");
                string    inhertstr = str.Trim();
                FFileNode type      = new FFileNode(inhertstr, GetUsing(_strLine));
                inhertstr = indextable.LookInMap(type, inhertstr);
                inhert.Set("name", inhertstr.Trim());
                nodeInterface.Push(inhert);
            }
            nodeClass.Push(nodeInterface);
        }
Exemple #10
0
        //============================================================
        // <T>获取类。</T>
        // @parame strline 需要获取的字符串集合。
        // @param index 当前索引
        // @return 获取的类对象
        //============================================================
        public void ParserClass(FStrings strLine, FCsSpace space, int index, string path, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
        {
            FXmlDocument doc        = new FXmlDocument();
            FXmlNode     config     = doc.Root;
            FXmlNode     nodeSpace  = space.XMLMaker(config);
            FXmlNode     xmlClass   = XMLMaker(nodeSpace, indextable, swPrint, file, relative);
            FXmlNode     fields     = new FXmlNode("Fields");
            FXmlNode     properties = new FXmlNode("Properties");
            FXmlNode     methods    = new FXmlNode("Methods");

            MakeInterfaceNode(this.Interface, xmlClass, indextable);
            xmlClass.Push(fields);
            xmlClass.Push(properties);
            xmlClass.Push(methods);
            int start, end = CheckParaAnnotate(strLine, index, out start);

            for (int n = _startIndex; n < _endIndex; n++)
            {
                if (IsInInterregional(n, start, end))
                {
                    continue;
                }
                if (IsField(strLine[n]))
                {
                    FCsField field = new FCsField(strLine, n);
                    field.Parser(fields, indextable, swPrint, file, relative);
                }
                if (IsProperty(strLine[n]))
                {
                    FCsProperty property = new FCsProperty(strLine, n, GetPairNum(strLine, n));
                    property.ParserPorperty(properties, indextable, swPrint, file, relative);
                }
                if (IsMethod(strLine[n]))
                {
                    int       endIndex = GetPairNum(strLine, n);
                    FCsMethod method   = new FCsMethod();
                    method.FillValue(strLine, n, endIndex);
                    method.ParserMethod(strLine, n, methods, indextable, swPrint, file, relative);
                    this.Method.Add(method);
                }
                if (FCsSpace.IsClass(strLine[n + 1]))
                {
                    SaveSXMLFile(path, doc);
                    FillValue(strLine, n + 1, GetPairNum(strLine, n + 1));
                    ParserClass(strLine, space, n + 1, path, indextable, swPrint, file, relative);
                }
            }
            SaveSXMLFile(path, doc);
        }
Exemple #11
0
 //============================================================
 // <T>解析属性。</T>
 //
 // @param nodeParent 属性节点的父节点
 // @param indextable 类型全名索引表
 // @param swPrint 用于打印警告的StreamWriter对象
 // @param file 警告所处在的文件
 // @param relative 被选取的文件夹的路径
 //============================================================
 public void ParserPorperty(FXmlNode nodeParent, FClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative)
 {
     XMLMaker(nodeParent, indextable, swPrint, file, relative);
 }