public IType GetArrayType(IReturnType elementType, MonoDevelop.Projects.Dom.Output.Ambience ambience) { // Create a fake class which sublcasses System.Array and implements IList<T> DomType t = new DomType(ambience.GetString(elementType, MonoDevelop.Projects.Dom.Output.OutputFlags.UseFullName) + "[]"); // set the compilation unit of the array type to that of the element type - it's required for jumping to the declaration of the type. IType eType = GetType(elementType); if (eType != null) { t.CompilationUnit = eType.CompilationUnit; } t.Resolved = true; t.BaseType = new DomReturnType("System.Array"); t.ClassType = ClassType.Class; t.Modifiers = Modifiers.Public; t.SourceProjectDom = this; DomProperty indexer = new DomProperty(); indexer.Name = "Item"; indexer.SetterModifier = indexer.GetterModifier = Modifiers.Public; indexer.PropertyModifier |= PropertyModifier.IsIndexer; indexer.Add(new DomParameter(indexer, "index", DomReturnType.Int32)); indexer.ReturnType = elementType; t.Add(indexer); DomReturnType listType = new DomReturnType("System.Collections.Generic.IList", false, new IReturnType [] { elementType }); t.AddInterfaceImplementation(listType); return(t); }
public override object VisitIndexerDeclaration (ICSharpCode.NRefactory.Ast.IndexerDeclaration indexerDeclaration, object data) { DomProperty indexer = new DomProperty (); indexer.Name = "this"; indexer.Documentation = RetrieveDocumentation (indexerDeclaration.StartLocation.Line); indexer.PropertyModifier |= PropertyModifier.IsIndexer; indexer.Location = ConvertLocation (indexerDeclaration.StartLocation); indexer.BodyRegion = ConvertRegion (indexerDeclaration.EndLocation, indexerDeclaration.BodyEnd); indexer.GetterModifier = indexer.SetterModifier = ConvertModifiers (indexerDeclaration.Modifier); indexer.ReturnType = ConvertReturnType (indexerDeclaration.TypeReference); indexer.Add (ConvertParameterList (indexer, indexerDeclaration.Parameters)); AddAttributes (indexer, indexerDeclaration.Attributes); AddExplicitInterfaces (indexer, indexerDeclaration.InterfaceImplementations); if (indexerDeclaration.HasGetRegion) { indexer.PropertyModifier |= PropertyModifier.HasGet; if (indexerDeclaration.GetRegion.Modifier != ICSharpCode.NRefactory.Ast.Modifiers.None) indexer.GetterModifier = ConvertModifiers (indexerDeclaration.GetRegion.Modifier); indexer.GetRegion = ConvertRegion (indexerDeclaration.GetRegion.StartLocation, indexerDeclaration.GetRegion.EndLocation); } if (indexerDeclaration.HasSetRegion) { indexer.PropertyModifier |= PropertyModifier.HasSet; if (indexerDeclaration.SetRegion.Modifier != ICSharpCode.NRefactory.Ast.Modifiers.None) indexer.SetterModifier = ConvertModifiers (indexerDeclaration.SetRegion.Modifier); indexer.SetRegion = ConvertRegion (indexerDeclaration.SetRegion.StartLocation, indexerDeclaration.SetRegion.EndLocation); } indexer.DeclaringType = typeStack.Peek (); typeStack.Peek ().Add (indexer); return null; }
public static DomProperty ReadProperty(BinaryReader reader, INameDecoder nameTable) { DomProperty result = new DomProperty(); // ReadMemeberInformation (changed for storing getter & setter modifiers) result.Name = ReadString(reader, nameTable); result.Documentation = ReadString(reader, nameTable); result.GetterModifier = (Modifiers)reader.ReadUInt32(); result.SetterModifier = (Modifiers)reader.ReadUInt32(); result.Location = ReadLocation(reader, nameTable); uint count = ReadUInt(reader, 1000); while (count-- > 0) { result.Add(ReadAttribute(reader, nameTable)); } // End uint explicitInterfaces = ReadUInt(reader, 500); while (explicitInterfaces-- > 0) { result.AddExplicitInterface(ReadReturnType(reader, nameTable)); } uint arguments = ReadUInt(reader, 5000); while (arguments-- > 0) { result.Add(ReadParameter(reader, nameTable)); } result.BodyRegion = ReadRegion(reader, nameTable); result.ReturnType = ReadReturnType(reader, nameTable); result.PropertyModifier = (PropertyModifier)reader.ReadInt32(); result.GetRegion = ReadRegion(reader, nameTable); result.SetRegion = ReadRegion(reader, nameTable); return(result); }
public IType GetArrayType (IReturnType elementType, MonoDevelop.Projects.Dom.Output.Ambience ambience) { // Create a fake class which sublcasses System.Array and implements IList<T> DomType t = new DomType (ambience.GetString (elementType, MonoDevelop.Projects.Dom.Output.OutputFlags.UseFullName) + "[]"); // set the compilation unit of the array type to that of the element type - it's required for jumping to the declaration of the type. IType eType = GetType (elementType); if (eType != null) t.CompilationUnit = eType.CompilationUnit; t.Resolved = true; t.BaseType = new DomReturnType ("System.Array"); t.ClassType = ClassType.Class; t.Modifiers = Modifiers.Public; t.SourceProjectDom = this; DomProperty indexer = new DomProperty (); indexer.Name = "Item"; indexer.SetterModifier = indexer.GetterModifier = Modifiers.Public; indexer.PropertyModifier |= PropertyModifier.IsIndexer; indexer.Add (new DomParameter(indexer, "index", DomReturnType.Int32)); indexer.ReturnType = elementType; t.Add (indexer); DomReturnType listType = new DomReturnType ("System.Collections.Generic.IList", false, new IReturnType [] { elementType }); t.AddInterfaceImplementation (listType); return t; }
public static DomProperty ReadProperty (BinaryReader reader, INameDecoder nameTable, IDomObjectTable objectTable) { DomProperty result = new DomProperty (); // ReadMemeberInformation (changed for storing getter & setter modifiers) result.Name = ReadString (reader, nameTable); result.Documentation = ReadString (reader, nameTable); result.GetterModifier = (Modifiers)reader.ReadUInt32(); result.SetterModifier = (Modifiers)reader.ReadUInt32(); result.Location = ReadLocation (reader, nameTable); uint count = ReadUInt (reader, 1000); while (count-- > 0) result.Add (ReadAttribute (reader, nameTable, objectTable)); // End uint explicitInterfaces = ReadUInt (reader, 500); while (explicitInterfaces-- > 0) { result.AddExplicitInterface (ReadReturnType (reader, nameTable, objectTable)); } uint arguments = ReadUInt (reader, 5000); while (arguments-- > 0) { result.Add (ReadParameter (reader, nameTable, objectTable)); } result.BodyRegion = ReadRegion (reader, nameTable); result.ReturnType = ReadReturnType (reader, nameTable, objectTable); result.PropertyModifier = (PropertyModifier)reader.ReadInt32 (); result.GetRegion = ReadRegion (reader, nameTable); result.SetRegion = ReadRegion (reader, nameTable); return result; }