Browse Source

Add visitor pattern to IType.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
19dc183e19
  1. 32
      ICSharpCode.NRefactory.Tests/TypeSystem/CecilLoaderTests.cs
  2. 6
      ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs
  3. 2
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  4. 28
      ICSharpCode.NRefactory/TypeSystem/ArrayType.cs
  5. 15
      ICSharpCode.NRefactory/TypeSystem/ByReferenceType.cs
  6. 33
      ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
  7. 25
      ICSharpCode.NRefactory/TypeSystem/ConstructedType.cs
  8. 25
      ICSharpCode.NRefactory/TypeSystem/IType.cs
  9. 4
      ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs
  10. 7
      ICSharpCode.NRefactory/TypeSystem/ITypeReference.cs
  11. 14
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs
  12. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractTypeReference.cs
  13. 37
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs
  14. 5
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeParameter.cs
  15. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/TypeWithElementType.cs
  16. 15
      ICSharpCode.NRefactory/TypeSystem/PointerType.cs
  17. 71
      ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs
  18. 48
      ICSharpCode.NRefactory/TypeSystem/TypeVisitor.cs

32
ICSharpCode.NRefactory.Tests/TypeSystem/CecilLoaderTests.cs

@ -19,5 +19,37 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -19,5 +19,37 @@ namespace ICSharpCode.NRefactory.TypeSystem
CecilLoader loader = new CecilLoader() { IncludeInternalMembers = true };
testCasePC = loader.LoadAssemblyFile(typeof(TestCase.SimplePublicClass).Assembly.Location);
}
[Test]
public void InheritanceTest()
{
ITypeResolveContext ctx = Mscorlib;
ITypeDefinition c = Mscorlib.GetClass(typeof(SystemException));
ITypeDefinition c2 = Mscorlib.GetClass(typeof(Exception));
Assert.IsNotNull(c, "c is null");
Assert.IsNotNull(c2, "c2 is null");
//Assert.AreEqual(3, c.BaseTypes.Count); // Inherited interfaces are not reported by Cecil
// which matches the behaviour of our C#/VB parsers
Assert.AreEqual("System.Exception", c.BaseTypes[0].Resolve(ctx).FullName);
Assert.AreSame(c2, c.BaseTypes[0]);
/*
List<ITypeDefinition> subClasses = new List<ITypeDefinition>();
foreach (IClass subClass in c.ClassInheritanceTree) {
subClasses.Add(subClass);
}
Assert.AreEqual(5, subClasses.Count, "ClassInheritanceTree length");
Assert.AreEqual("System.SystemException", subClasses[0].FullyQualifiedName);
Assert.AreEqual("System.Exception", subClasses[1].FullyQualifiedName);
if (subClasses[2].FullyQualifiedName == "System.Object") {
Assert.AreEqual("System.Object", subClasses[2].FullyQualifiedName);
Assert.AreEqual("System.Runtime.Serialization.ISerializable", subClasses[3].FullyQualifiedName);
Assert.AreEqual("System.Runtime.InteropServices._Exception", subClasses[4].FullyQualifiedName);
} else {
Assert.AreEqual("System.Runtime.Serialization.ISerializable", subClasses[2].FullyQualifiedName);
Assert.AreEqual("System.Runtime.InteropServices._Exception", subClasses[3].FullyQualifiedName);
Assert.AreEqual("System.Object", subClasses[4].FullyQualifiedName);
}*/
}
}
}

6
ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
[Test]
public void SimplePublicClassTest()
{
ITypeDefinition c = testCasePC.GetClass(typeof(SimplePublicClass).FullName, 0, StringComparer.Ordinal);
ITypeDefinition c = testCasePC.GetClass(typeof(SimplePublicClass));
Assert.AreEqual(typeof(SimplePublicClass).Name, c.Name);
Assert.AreEqual(typeof(SimplePublicClass).FullName, c.FullName);
Assert.AreEqual(typeof(SimplePublicClass).Namespace, c.Namespace);
@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
[Test]
public void SimplePublicClassMethodTest()
{
ITypeDefinition c = testCasePC.GetClass(typeof(SimplePublicClass).FullName, 0, StringComparer.Ordinal);
ITypeDefinition c = testCasePC.GetClass(typeof(SimplePublicClass));
Assert.AreEqual(2, c.Methods.Count);
IMethod method = c.Methods.Single(m => m.Name == "Method");
@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
[Ignore]
public void DynamicTypeInGenerics()
{
ITypeDefinition testClass = testCasePC.GetClass(typeof(DynamicTest).FullName, 0, StringComparer.Ordinal);
ITypeDefinition testClass = testCasePC.GetClass(typeof(DynamicTest));
/*CSharpAmbience a = new CSharpAmbience();
a.ConversionFlags = ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterList;
Assert.AreEqual("List<dynamic> DynamicGenerics1(Action<object, dynamic[], object>)", a.Convert(testClass.Methods.Single(me => me.Name == "DynamicGenerics1")));

2
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -192,8 +192,10 @@ @@ -192,8 +192,10 @@
<Compile Include="TypeSystem\ITypeParameter.cs" />
<Compile Include="TypeSystem\ITypeReference.cs" />
<Compile Include="TypeSystem\ITypeResolveContext.cs" />
<Compile Include="TypeSystem\TypeVisitor.cs" />
<Compile Include="TypeSystem\IVariable.cs" />
<Compile Include="TypeSystem\PointerType.cs" />
<Compile Include="TypeSystem\ReflectionHelper.cs" />
<Compile Include="TypeSystem\SharedTypes.cs" />
<Compile Include="CSharp\Parser\mcs\cs-parser.cs" />
<Compile Include="CSharp\Parser\mcs\expression.cs" />

28
ICSharpCode.NRefactory/TypeSystem/ArrayType.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.TypeSystem
@ -47,6 +48,33 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -47,6 +48,33 @@ namespace ICSharpCode.NRefactory.TypeSystem
ArrayType a = other as ArrayType;
return a != null && elementType.Equals(a.elementType) && a.dimensions == dimensions;
}
public override IEnumerable<IType> GetBaseTypes(ITypeResolveContext context)
{
List<IType> baseTypes = new List<IType>();
IType t = context.GetClass(typeof(Array));
if (t != null)
baseTypes.Add(t);
t = context.GetClass(typeof(List<>));
if (t != null)
baseTypes.Add(t);
return baseTypes;
}
public override IType AcceptVisitor(TypeVisitor visitor)
{
return visitor.VisitArrayType(this);
}
public override IType VisitChildren(TypeVisitor visitor)
{
IType elementType = GetElementType();
IType e = elementType.AcceptVisitor(visitor);
if (e == elementType)
return this;
else
return new ArrayType(e, dimensions);
}
}
public class ArrayTypeReference : AbstractTypeReference

15
ICSharpCode.NRefactory/TypeSystem/ByReferenceType.cs

@ -30,6 +30,21 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -30,6 +30,21 @@ namespace ICSharpCode.NRefactory.TypeSystem
ByReferenceType a = other as ByReferenceType;
return a != null && elementType.Equals(a.elementType);
}
public override IType AcceptVisitor(TypeVisitor visitor)
{
return visitor.VisitByReferenceType(this);
}
public override IType VisitChildren(TypeVisitor visitor)
{
IType elementType = GetElementType();
IType e = elementType.AcceptVisitor(visitor);
if (e == elementType)
return this;
else
return new ByReferenceType(e);
}
}
public class ByReferenceTypeReference : AbstractTypeReference

33
ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs

@ -230,7 +230,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -230,7 +230,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
ITypeReference typeRef = GetSimpleType(nameparts[0]);
for (int i = 1; i < nameparts.Length; i++) {
int partTypeParameterCount;
string namepart = SplitTypeParameterCountFromReflectionName(nameparts[i], out partTypeParameterCount);
string namepart = ReflectionHelper.SplitTypeParameterCountFromReflectionName(nameparts[i], out partTypeParameterCount);
typeRef = new NestedTypeReference(typeRef, namepart, partTypeParameterCount);
}
return typeRef;
@ -249,7 +249,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -249,7 +249,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
ITypeReference GetSimpleType(string reflectionName)
{
int typeParameterCount;
string name = SplitTypeParameterCountFromReflectionName(reflectionName, out typeParameterCount);
string name = ReflectionHelper.SplitTypeParameterCountFromReflectionName(reflectionName, out typeParameterCount);
var earlyBindContext = this.EarlyBindContext;
if (earlyBindContext != null) {
IType c = earlyBindContext.GetClass(name, typeParameterCount, StringComparer.Ordinal);
@ -259,31 +259,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -259,31 +259,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
return new GetClassTypeReference(name, typeParameterCount);
}
static string SplitTypeParameterCountFromReflectionName(string reflectionName)
{
int pos = reflectionName.LastIndexOf('`');
if (pos < 0) {
return reflectionName;
} else {
return reflectionName.Substring(0, pos);
}
}
static string SplitTypeParameterCountFromReflectionName(string reflectionName, out int typeParameterCount)
{
int pos = reflectionName.LastIndexOf('`');
if (pos < 0) {
typeParameterCount = 0;
return reflectionName;
} else {
string typeCount = reflectionName.Substring(pos + 1);
if (int.TryParse(typeCount, out typeParameterCount))
return reflectionName.Substring(0, pos);
else
return reflectionName;
}
}
static bool HasDynamicAttribute(ICustomAttributeProvider attributeProvider, int typeIndex)
{
if (attributeProvider == null || !attributeProvider.HasCustomAttributes)
@ -358,7 +333,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -358,7 +333,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
TypeDefinition typeDefinition;
public CecilTypeDefinition(IProjectContent pc, TypeDefinition typeDefinition)
: base(pc, typeDefinition.Namespace, SplitTypeParameterCountFromReflectionName(typeDefinition.Name))
: base(pc, typeDefinition.Namespace, ReflectionHelper.SplitTypeParameterCountFromReflectionName(typeDefinition.Name))
{
this.typeDefinition = typeDefinition;
}
@ -423,7 +398,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -423,7 +398,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
name = name.Substring(pos + 1);
if (name.Length == 0 || name[0] == '<')
continue;
name = SplitTypeParameterCountFromReflectionName(name);
name = ReflectionHelper.SplitTypeParameterCountFromReflectionName(name);
InnerClasses.Add(new CecilTypeDefinition(this, name, nestedType));
}
}

25
ICSharpCode.NRefactory/TypeSystem/ConstructedType.cs

@ -116,7 +116,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -116,7 +116,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
return this;
}
public IType GetBaseType(ITypeResolveContext context)
public IEnumerable<IType> GetBaseTypes(ITypeResolveContext context)
{
throw new NotImplementedException();
}
@ -176,6 +176,29 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -176,6 +176,29 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
return hashCode;
}
public IType AcceptVisitor(TypeVisitor visitor)
{
return visitor.VisitConstructedType(this);
}
public IType VisitChildren(TypeVisitor visitor)
{
IType g = genericType.AcceptVisitor(visitor);
ITypeDefinition def = g as ITypeDefinition;
if (def == null)
return g;
IType[] ta = new IType[typeArguments.Length];
bool isSame = g == this;
for (int i = 0; i < typeArguments.Length; i++) {
ta[i] = typeArguments[i].AcceptVisitor(visitor);
isSame &= ta[i] == typeArguments[i];
}
if (isSame)
return this;
else
return new ConstructedType(def, ta);
}
}
/// <summary>

25
ICSharpCode.NRefactory/TypeSystem/IType.cs

@ -44,6 +44,17 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -44,6 +44,17 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets the number of type parameters.
/// </summary>
int TypeParameterCount { get; }
/// <summary>
/// Calls ITypeVisitor.Visit for this type.
/// </summary>
IType AcceptVisitor(TypeVisitor visitor);
/// <summary>
/// Calls ITypeVisitor.Visit for all children of this type, and reconstructs this type with the children based
/// by the return values of the visit calls.
/// </summary>
IType VisitChildren(TypeVisitor visitor);
}
[ContractClassFor(typeof(IType))]
@ -107,5 +118,19 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -107,5 +118,19 @@ namespace ICSharpCode.NRefactory.TypeSystem
{
return false;
}
IType IType.AcceptVisitor(TypeVisitor visitor)
{
Contract.Requires(visitor != null);
Contract.Ensures(Contract.Result<IType>() != null);
return this;
}
IType IType.VisitChildren(TypeVisitor visitor)
{
Contract.Requires(visitor != null);
Contract.Ensures(Contract.Result<IType>() != null);
return this;
}
}
}

4
ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs

@ -37,6 +37,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -37,6 +37,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
IList<IProperty> Properties { get; }
IList<IMethod> Methods { get; }
IList<IEvent> Events { get; }
/// <summary>
/// Gets all members declared in this class. This is the union of Fields,Properties,Methods and Events.
/// </summary>
IEnumerable<IMember> Members { get; }
}

7
ICSharpCode.NRefactory/TypeSystem/ITypeReference.cs

@ -16,9 +16,9 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -16,9 +16,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
IType Resolve(ITypeResolveContext context);
/// <summary>
/// Gets the base type. May return null.
/// Gets the direct base types.
/// </summary>
IType GetBaseType(ITypeResolveContext context);
IEnumerable<IType> GetBaseTypes(ITypeResolveContext context);
/// <summary>
/// Gets inner classes (including inherited inner classes).
@ -56,9 +56,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -56,9 +56,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
return null;
}
IType ITypeReference.GetBaseType(ITypeResolveContext context)
IEnumerable<IType> ITypeReference.GetBaseTypes(ITypeResolveContext context)
{
Contract.Requires(context != null);
Contract.Ensures(Contract.Result<IEnumerable<IType>>() != null);
return null;
}

14
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs

@ -61,9 +61,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -61,9 +61,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return this;
}
public IType GetBaseType(ITypeResolveContext context)
public virtual IEnumerable<IType> GetBaseTypes(ITypeResolveContext context)
{
return null;
return EmptyList<IType>.Instance;
}
public virtual IList<IType> GetNestedTypes(ITypeResolveContext context)
@ -103,5 +103,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -103,5 +103,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
return this.DotNetName;
}
public virtual IType AcceptVisitor(TypeVisitor visitor)
{
return visitor.VisitOtherType(this);
}
public virtual IType VisitChildren(TypeVisitor visitor)
{
return this;
}
}
}

4
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractTypeReference.cs

@ -10,9 +10,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -10,9 +10,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
public abstract IType Resolve(ITypeResolveContext context);
public virtual IType GetBaseType(ITypeResolveContext context)
public virtual IEnumerable<IType> GetBaseTypes(ITypeResolveContext context)
{
return Resolve(context).GetBaseType(context);
return Resolve(context).GetBaseTypes(context);
}
public virtual IList<IType> GetNestedTypes(ITypeResolveContext context)

37
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeDefinition.cs

@ -300,9 +300,32 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -300,9 +300,32 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return projectContent; }
}
public IType GetBaseType(ITypeResolveContext context)
public IEnumerable<IType> GetBaseTypes(ITypeResolveContext context)
{
throw new NotImplementedException();
if (baseTypes == null || baseTypes.Count == 0) {
if (this.FullName == "System.Object")
return EmptyList<IType>.Instance;
switch (classType) {
case ClassType.Enum:
return GetPrimitiveBaseType(typeof(Enum), context);
case ClassType.Struct:
return GetPrimitiveBaseType(typeof(ValueType), context);
case ClassType.Delegate:
return GetPrimitiveBaseType(typeof(Delegate), context);
default:
return GetPrimitiveBaseType(typeof(object), context);
}
}
return baseTypes.Select(t => t.Resolve(context)).Where(t => t != SharedTypes.UnknownType);
}
static IEnumerable<IType> GetPrimitiveBaseType(Type type, ITypeResolveContext context)
{
IType t = context.GetClass(type);
if (t != null)
return new [] { t };
else
return EmptyList<IType>.Instance;
}
public virtual ITypeDefinition GetCompoundClass()
@ -414,5 +437,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -414,5 +437,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
flags[FlagAddDefaultConstructorIfRequired] = value;
}
}
public IType AcceptVisitor(TypeVisitor visitor)
{
return visitor.VisitTypeDefinition(this);
}
public IType VisitChildren(TypeVisitor visitor)
{
return this;
}
}
}

5
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultTypeParameter.cs

@ -163,5 +163,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -163,5 +163,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public virtual ITypeParameter UnboundTypeParameter {
get { return null; }
}
public override IType AcceptVisitor(TypeVisitor visitor)
{
return visitor.VisitTypeParameter(this);
}
}
}

4
ICSharpCode.NRefactory/TypeSystem/Implementation/TypeWithElementType.cs

@ -38,5 +38,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -38,5 +38,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
return elementType;
}
// Force concrete implementations to override VisitChildren - the base implementation
// in AbstractType assumes there are no children, but we know there is (at least) 1.
public abstract override IType VisitChildren(TypeVisitor visitor);
}
}

15
ICSharpCode.NRefactory/TypeSystem/PointerType.cs

@ -32,6 +32,21 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -32,6 +32,21 @@ namespace ICSharpCode.NRefactory.TypeSystem
PointerType a = other as PointerType;
return a != null && elementType.Equals(a.elementType);
}
public override IType AcceptVisitor(TypeVisitor visitor)
{
return visitor.VisitPointerType(this);
}
public override IType VisitChildren(TypeVisitor visitor)
{
IType elementType = GetElementType();
IType e = elementType.AcceptVisitor(visitor);
if (e == elementType)
return this;
else
return new PointerType(e);
}
}
public class PointerTypeReference : AbstractTypeReference

71
ICSharpCode.NRefactory/TypeSystem/ReflectionHelper.cs

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.NRefactory.TypeSystem
{
/// <summary>
/// Static helper methods for reflection names.
/// </summary>
public static class ReflectionHelper
{
/// <summary>
/// Retrieves a class.
/// </summary>
/// <returns>Returns the class; or null if it is not found.</returns>
public static ITypeDefinition GetClass(this ITypeResolveContext context, Type type)
{
if (type.DeclaringType != null) {
ITypeDefinition declaringType = GetClass(context, type.DeclaringType);
if (declaringType != null) {
int typeParameterCount;
string name = SplitTypeParameterCountFromReflectionName(type.Name, out typeParameterCount);
foreach (ITypeDefinition innerClass in declaringType.InnerClasses) {
if (innerClass.Name == name && innerClass.TypeParameterCount == typeParameterCount) {
return innerClass;
}
}
}
return null;
} else {
int typeParameterCount;
string name = SplitTypeParameterCountFromReflectionName(type.FullName, out typeParameterCount);
return context.GetClass(name, typeParameterCount, StringComparer.Ordinal);
}
}
/// <summary>
/// Removes the ` with type parameter count from the reflection name.
/// </summary>
/// <remarks>Do not use this method with the full name of inner classes.</remarks>
public static string SplitTypeParameterCountFromReflectionName(string reflectionName)
{
int pos = reflectionName.LastIndexOf('`');
if (pos < 0) {
return reflectionName;
} else {
return reflectionName.Substring(0, pos);
}
}
/// <summary>
/// Removes the ` with type parameter count from the reflection name.
/// </summary>
/// <remarks>Do not use this method with the full name of inner classes.</remarks>
public static string SplitTypeParameterCountFromReflectionName(string reflectionName, out int typeParameterCount)
{
int pos = reflectionName.LastIndexOf('`');
if (pos < 0) {
typeParameterCount = 0;
return reflectionName;
} else {
string typeCount = reflectionName.Substring(pos + 1);
if (int.TryParse(typeCount, out typeParameterCount))
return reflectionName.Substring(0, pos);
else
return reflectionName;
}
}
}
}

48
ICSharpCode.NRefactory/TypeSystem/TypeVisitor.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.NRefactory.TypeSystem
{
/// <summary>
/// Description of ITypeVisitor.
/// </summary>
public abstract class TypeVisitor
{
public virtual IType VisitTypeDefinition(ITypeDefinition type)
{
return type.VisitChildren(this);
}
public virtual IType VisitTypeParameter(ITypeParameter type)
{
return type.VisitChildren(this);
}
public virtual IType VisitConstructedType(ConstructedType type)
{
return type.VisitChildren(this);
}
public virtual IType VisitArrayType(ArrayType type)
{
return type.VisitChildren(this);
}
public virtual IType VisitPointerType(PointerType type)
{
return type.VisitChildren(this);
}
public virtual IType VisitByReferenceType(ByReferenceType type)
{
return type.VisitChildren(this);
}
public virtual IType VisitOtherType(IType type)
{
return type.VisitChildren(this);
}
}
}
Loading…
Cancel
Save