Beispiel #1
0
        //============================================================
        // <T>将方法对象对象解析成XML文档,并解析出代码在编译器外的警告或者错误。</T>
        //
        // @param nodeClass 需要附加到的类的节点
        // @param swPrint StringWriter对象用来输出警告或者错误。
        // @param file 当前解析的文件
        // @param relativePath 被选择解析的文件夹路径
        //============================================================
        public FXmlNode XMLMaker(FXmlNode nodeClass, StreamWriter swPrint, FileInfo file, string relativePath)
        {
            int index = -1;

            if (!IsMethodAnnoFine())
            {
                PrintWarning(swPrint, file, relativePath);
            }
            if (!IsReturnfine())
            {
                PrintError(swPrint, file, relativePath);
            }
            if (!IsSwitchFine(out index))
            {
                PrintDefaultError(swPrint, file, relativePath, index);
            }
            if (!IsforFine(out index))
            {
                PrintForError(swPrint, file, relativePath, index);
            }
            if (!IsIfFine(out index))
            {
                PrintIfError(swPrint, file, relativePath, index);
            }
            FXmlNode nodeMethod = new FXmlNode("Method");

            nodeMethod.Set("name", MethodName);
            nodeMethod.Set("full_name", FullMethodName);
            if (AnnotateLable != "")
            {
                nodeMethod.Set("label", AnnotateLable);
            }
            if (AnnotateDescription != "")
            {
                nodeMethod.Set("description", AnnotateDescription);
            }
            nodeClass.Push(nodeMethod);
            return(nodeMethod);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        //============================================================
        // <T>解析方法段代码。</T>
        //
        // @param nodeParent 需要附加到的父节点
        // @param swPrint StringWriter对象用来输出警告或者错误。
        // @param file 当前解析的文件
        // @param relativePath 被选择解析的文件夹路径
        //============================================================
        public void ParserMethod(FXmlNode nodeParent, StreamWriter swPrint, FileInfo file, string relativePath)
        {
            string   methodLine  = _strLines[_beginIndex].ToString().Trim();
            int      paraStart   = methodLine.IndexOf('(') + 1;
            int      paraEnd     = methodLine.IndexOf(')');
            string   paramstring = methodLine.Substring(paraStart, paraEnd - paraStart).Trim();
            FXmlNode nodeMethod  = XMLMaker(nodeParent, swPrint, file, relativePath);

            if (paramstring != "")
            {
                string[] pa = paramstring.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int n = 0; n < pa.Length; n++)
                {
                    FCppParameter parameter = new FCppParameter(GetAnnotate(_strLines, _beginIndex), pa[n].Trim(), _beginIndex);
                    parameter.ParserParameter(nodeMethod, swPrint, file, relativePath);
                }
                MethodReturnNode(nodeMethod);
            }
            FXmlNode methodCode = new FXmlNode("Source");

            methodCode.Text = MethodCode;
            nodeMethod.Push(methodCode);
        }