public AddInterface ( |
||
interfaceReference | The interface reference. | |
return | void |
/// <summary> /// Clones an attributed element. /// </summary> /// <returns>Cloned attribute element state.</returns> protected override AttributedElement DoAttributedClone() { TypeElement clone = new TypeElement(); // // Copy state // clone._typeModifiers = _typeModifiers; clone._type = _type; foreach (InterfaceReference interfaceReference in Interfaces) { InterfaceReference referenceClone = interfaceReference.Clone() as InterfaceReference; clone.AddInterface(referenceClone); } foreach (TypeParameter typeParam in TypeParameters) { TypeParameter typeParamClone = typeParam.Clone() as TypeParameter; clone.TypeParametersBase.Add(typeParamClone); } return(clone); }
/// <summary> /// Parses a type definition. /// </summary> /// <param name="access">The access.</param> /// <param name="typeAttributes">The type attributes.</param> /// <param name="elementType">Type of the element.</param> /// <returns>A type code element.</returns> 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; }
/// <summary> /// Clones an attributed element. /// </summary> /// <returns>Cloned attribute element state.</returns> protected override AttributedElement DoAttributedClone() { TypeElement clone = new TypeElement(); // // Copy state // clone._typeModifiers = _typeModifiers; clone._type = _type; foreach (InterfaceReference interfaceReference in Interfaces) { InterfaceReference referenceClone = interfaceReference.Clone() as InterfaceReference; clone.AddInterface(referenceClone); } foreach (TypeParameter typeParam in TypeParameters) { TypeParameter typeParamClone = typeParam.Clone() as TypeParameter; clone.TypeParametersBase.Add(typeParamClone); } return clone; }
/// <summary> /// Parses a type definition. /// </summary> /// <param name="access">Type accessibility.</param> /// <param name="typeAttributes">Type modifiers.</param> /// <param name="elementType">Type element type.</param> /// <returns>Type code element.</returns> 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; EatWhiteSpace(); if (elementType == TypeElementType.Enum) { EatWhiteSpace(); if (NextChar == CSharpSymbol.TypeImplements) { TryReadChar(); string interfaceName = CaptureTypeName(); InterfaceReference interfaceReference = new InterfaceReference(interfaceName, InterfaceReferenceType.None); typeElement.AddInterface(interfaceReference); } string enumText = ParseBlock(true, typeElement); // TODO: Parse enum values as fields typeElement.BodyText = enumText; } else { bool isGeneric = TryReadChar(CSharpSymbol.BeginGeneric); if (isGeneric) { string[] typeParameterNames = ParseAliasList(); foreach (string typeParameterName in typeParameterNames) { TypeParameter typeParameter = new TypeParameter(); typeParameter.Name = typeParameterName; typeElement.AddTypeParameter(typeParameter); } EatWhiteSpace(); if (!TryReadChar(CSharpSymbol.EndGeneric)) { this.OnParseError("Expected " + CSharpSymbol.EndGeneric); } } EatWhiteSpace(); bool implements = TryReadChar(CSharpSymbol.TypeImplements); if (implements) { string[] typeList = ParseAliasList(); foreach (string type in typeList) { InterfaceReference interfaceReference = new InterfaceReference(type, InterfaceReferenceType.None); typeElement.AddInterface(interfaceReference); } } EatWhiteSpace(); ParseTypeParameterConstraints(typeElement); // Associate any additional comments in the type definition with the type. ReadOnlyCollection<ICommentElement> extraComments = ParseComments(); foreach (ICommentElement comment in extraComments) { typeElement.AddHeaderComment(comment); } EatChar(CSharpSymbol.BeginBlock); EatWhiteSpace(); if (NextChar != CSharpSymbol.EndBlock) { // // Parse child elements // List<ICodeElement> childElements = ParseElements(typeElement); foreach (ICodeElement childElement in childElements) { typeElement.AddChild(childElement); } } EatChar(CSharpSymbol.EndBlock); } // // Types allow a trailing semi-colon // EatTrailingEndOfStatement(); return typeElement; }