コード例 #1
0
        private void BuildPropertyDeclaration(string tcLine)
        {
            // the last word in this line is the name of the property
            tcLine = ReplaceManager.GetSingledSpacedString(tcLine).Trim();

            if (tcLine.EndsWith(")"))
            {
                int nEnd = tcLine.IndexOf("(");
                this.PropertyParameterToken = this.ExtractBlock(tcLine, "(", ")");
                FieldManager fm = new FieldManager();
                this.PropertyParameterToken = "(" + fm.GetConvertedExpression(this.PropertyParameterToken) + ") ";
                this.PropertyParameterToken = this.PropertyParameterToken.Replace("Dim ", "");
                tcLine = tcLine.Substring(0, nEnd).Trim();
            }

            int npos = tcLine.LastIndexOf(" ");

            this.PropertyNameToken = tcLine.Substring(npos + 1);
            string cDefinition = tcLine.Substring(0, npos).Trim();

            cDefinition = ReplaceManager.HandleModifiers(cDefinition);

            //A property has to return a value
            cDefinition           = cDefinition.Trim();
            npos                  = cDefinition.LastIndexOf(" ");
            this.ReturnValueToken = "As " + cDefinition.Substring(npos).Trim();
            cDefinition           = cDefinition.Substring(0, npos);

            this.PropertyModifiersToken = cDefinition;
        }
コード例 #2
0
        private void UpdateModifierToken()
        {
            IEnumerator ie = this.ModifersQueue.GetEnumerator();

            while (ie.MoveNext())
            {
                this.ModifierToken += ReplaceManager.HandleModifiers(((string)ie.Current) + " ");
            }
        }
コード例 #3
0
        private void BuildMethodDeclaration(string tcLine)
        {
            //Locate the position of a colon and if we find it then break the method line and parent
            int nColon = tcLine.IndexOf(":");

            if (nColon > 0)
            {
                this.MethodParentToken = tcLine.Substring(nColon + 1);
                tcLine = tcLine.Substring(0, nColon);

                //fix the MethodParentToken first [COMMENTED FOR NOW. NOT SURE IF REQUIRED]
                //string lcParameters = this.GetParameters(this.MethodParentToken);
                //int nEndPos = this.MethodParentToken.IndexOf("(");
                //this.MethodParentToken = this.MethodParentToken.Substring(0, nEndPos) + lcParameters;
            }


            //Break the method call into two parts
            // 1. Method definition
            // 2. Parameters passed

            // Let us get the parameters
            tcLine = ReplaceManager.GetSingledSpacedString(tcLine).Trim();
            int    nOpenParen   = 0;
            int    nClosedParen = 0;
            string cParameters  = "";
            string cDefinition  = tcLine;
            int    k;

            for (int i = tcLine.Length; 0 < i; i--)
            {
                k = i - 1;
                if (tcLine[k] == ')')
                {
                    nClosedParen++;
                }

                if (tcLine[k] == '(')
                {
                    nOpenParen++;
                }

                if (nOpenParen != 0 && nClosedParen != 0)
                {
                    if (nOpenParen - nClosedParen == 0)
                    {
                        //Create the two seperate strings and exit out
                        cDefinition = tcLine.Substring(0, k);
                        cParameters = tcLine.Substring(k).Trim();
                        break;
                    }
                }
            }

            this.ParameterToken = this.GetParameters(cParameters);

            //split the definition and if the length is two then add a private modifier as default
            cDefinition = ReplaceManager.GetSingledSpacedString(cDefinition);             //safety purposes

            //Check for any modifiers in this string and if so then handle them


            string[] cTemp = cDefinition.Split(' ');
            if (cTemp.Length == 2)
            {
                //add a private modifier
                cDefinition = "private " + cDefinition;
            }


            //If we find a void in the definition part it is a Sub else a Function
            //In VB Sub do not return a value and Functions do return a value
            if (cDefinition.IndexOf("void ") >= 0)
            {
                this.MethodType = "Sub";
            }

            cDefinition = " " + cDefinition.Trim() + " ";
            cDefinition = ReplaceManager.HandleModifiers(cDefinition);

            //The last word will always be the name of the method
            cDefinition = cDefinition.Trim();
            int npos = cDefinition.LastIndexOf(" ");

            this.MethodNameToken = cDefinition.Substring(npos).Trim();
            cDefinition          = cDefinition.Substring(0, npos);

            //In this case the second last value will be the return value datatype of the method
            if (this.MethodType != "Sub")
            {
                npos = cDefinition.LastIndexOf(" ");
                if (npos >= 0)
                {
                    this.ReturnValueToken = " As " + cDefinition.Substring(npos).Trim();
                    cDefinition           = cDefinition.Substring(0, npos);
                }
            }

            //if(cDefinition.Length > 0)
            if (npos > 0)
            {
                this.MethodModifiersToken = cDefinition.Substring(0, npos) + " ";
            }
        }