FlatRedBall.Glue.Parsing.ParsedMethod.FillArgumentList C# (CSharp) Method

FillArgumentList() private method

private FillArgumentList ( ParsedMethod parsedMethod, List currentBlock, int lineIndex, bool requireTypes ) : void
parsedMethod ParsedMethod
currentBlock List
lineIndex int
requireTypes bool
return void
        internal void FillArgumentList(ParsedMethod parsedMethod, List<string> currentBlock, int lineIndex, bool requireTypes)
        {
            int wordIndex = 0;
            int  parenthesisDeep = 0;
            bool hasFoundClosedParenthesis = false;

            ParsedField argumentToAddTo = null;

            while (!hasFoundClosedParenthesis)
            {
                string line = currentBlock[lineIndex];

                wordIndex = 0;

                string currentType = null;

                while (true)
                {
                    string word = ParsedClass.GetWord(line, ref wordIndex);

                    if (word == "(")
                    {
                        if (argumentToAddTo != null)
                        {
                            argumentToAddTo.Name += word;
                        }

                        parenthesisDeep++;
                    }
                    else if (word == ")")
                    {
                        parenthesisDeep--;


                        if (parenthesisDeep == 0)
                        {
                            hasFoundClosedParenthesis = true;
                            break;
                        }
                        else if (argumentToAddTo != null)
                        {
                            argumentToAddTo.Name += word;
                        }

                        
                    }
                    else if (word == "")
                    {
                        lineIndex++;
                        break;
                    }
                    else if (parenthesisDeep == 0)
                    {
                        continue;
                    }
                    else if (word == ",")
                    {
                        argumentToAddTo = null;
                        continue;
                    }
                    else if (currentType == null && requireTypes)
                    {
                        currentType = word;
                    }
                    else
                    {
                        ParsedField parsedField = new ParsedField(Scope.Public, currentType, word);
                        currentType = null;

                        parsedMethod.ArgumentList.Add(parsedField);

                        argumentToAddTo = parsedField;
                    }

                }
            }
        }
    }

Usage Example

コード例 #1
0
        private void CreateParsedMethod(int startIndex, int endIndex, bool trimContents)
        {
            // For now we'll assume that all properties are on
            // the same line.  Eventually we may want to combine
            // all lines before the opening bracket


            // todo: add attributes:
            CurrentAttributes.Clear();


            #region Get header information

            int lineIndexForHeader = 0;

            string headerLine = mCurrentBlock[lineIndexForHeader].Trim();

            int numberOfParens = mCurrentBlock[lineIndexForHeader].CountOf('(') - mCurrentBlock[lineIndexForHeader].CountOf(')');


            while (numberOfParens > 0)
            {
                lineIndexForHeader++;
                headerLine += " " + mCurrentBlock[lineIndexForHeader].Trim();

                numberOfParens += mCurrentBlock[lineIndexForHeader].CountOf('(') - mCurrentBlock[lineIndexForHeader].CountOf(')');
            }

            ParsedMethod parsedMethod = new ParsedMethod();

            parsedMethod.FillHeaderInformation(headerLine);

            #endregion

            parsedMethod.StartIndex = startIndex;
            parsedMethod.EndIndex   = endIndex;

            parsedMethod.FillArgumentList(parsedMethod, mCurrentBlock, 0, true);

            // Fill generic restrictions after getting all arguments
            parsedMethod.FillGenericRestrictions(headerLine);

            parsedMethod.FillBaseCall(mCurrentBlock);

            StringBuilder methodContents = new StringBuilder();

            bool hasGetter;
            bool hasSetter;

            bool hasAutomaticGetter;
            bool hasAutomaticSetter;

            FillGettersAndSetters(methodContents, methodContents, false, trimContents, out hasGetter, out hasSetter, out hasAutomaticGetter, out hasAutomaticSetter);

            parsedMethod.MethodContents = methodContents.ToString();
            parsedMethod.StoreOffOldName();

            mParsedMethods.Add(parsedMethod);
        }
All Usage Examples Of FlatRedBall.Glue.Parsing.ParsedMethod::FillArgumentList