NArrange.VisualBasic.VBParser.ParseType C# (CSharp) Method

ParseType() private method

Parses a type definition.
private ParseType ( CodeAccess access, TypeModifiers typeAttributes, TypeElementType elementType ) : TypeElement
access CodeAccess The access.
typeAttributes TypeModifiers The type attributes.
elementType TypeElementType Type of the element.
return NArrange.Core.CodeElements.TypeElement
        private TypeElement ParseType(
			CodeAccess access, TypeModifiers typeAttributes, TypeElementType elementType)
        {
            TypeElement typeElement = new TypeElement();

            EatWhiteSpace();
            string className = CaptureWord();
            typeElement.Name = className;
            typeElement.Access = access;
            typeElement.Type = elementType;
            typeElement.TypeModifiers = typeAttributes;

            if (elementType == TypeElementType.Enum)
            {
                EatLineContinuation();

                if (NextChar == VBKeyword.As[0])
                {
                    EatWord(VBKeyword.As);
                    string interfaceName = CaptureTypeName();
                    InterfaceReference interfaceReference =
                        new InterfaceReference(interfaceName, InterfaceReferenceType.None);
                    typeElement.AddInterface(interfaceReference);
                }

                string enumText = ParseBlock(VBKeyword.Enumeration);

                // TODO: Parse enum values as fields
                typeElement.BodyText = enumText;
            }
            else
            {
                EatWhiteSpace();
                bool isGeneric = TryReadChar(VBSymbol.BeginParameterList);
                if (isGeneric)
                {
                    EatWord(VBKeyword.Of, "Expected Of");

                    this.ParseTypeParameters(typeElement);
                }

                EatWhiteSpace();

                //
                // Parse child elements
                //
                List<ICodeElement> childElements = ParseElements(typeElement);
                foreach (ICodeElement childElement in childElements)
                {
                    typeElement.AddChild(childElement);
                }

                EatWhiteSpace();
                string elementTypeString = EnumUtilities.ToString(elementType);
                EatWord(elementTypeString, "Expected End " + elementTypeString);
            }

            return typeElement;
        }