@ -59,20 +59,33 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -59,20 +59,33 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
bool hasConstructableContraint = false ;
bool hasConstructableConstraint = false ;
bool hasReferenceTypeConstraint = false ;
bool hasValueTypeConstraint = false ;
/// <summary>
/// Gets if the type parameter has the 'new' constraint.
/// Gets/Sets if the type parameter has the 'new() ' constraint.
/// </summary>
public bool HasConstructableContraint {
get {
return hasConstructableContraint ;
}
set {
hasConstructableContraint = value ;
}
public bool HasConstructableConstraint {
get { return hasConstructableConstraint ; }
set { hasConstructableConstraint = value ; }
}
/// <summary>
/// Gets/Sets if the type parameter has the 'class' constraint.
/// </summary>
public bool HasReferenceTypeConstraint {
get { return hasReferenceTypeConstraint ; }
set { hasReferenceTypeConstraint = value ; }
}
/// <summary>
/// Gets/Sets if the type parameter has the 'struct' constraint.
/// </summary>
public bool HasValueTypeConstraint {
get { return hasValueTypeConstraint ; }
set { hasValueTypeConstraint = value ; }
}
public DefaultTypeParameter ( IMethod method , string name , int index )
{
@ -110,7 +123,9 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -110,7 +123,9 @@ namespace ICSharpCode.SharpDevelop.Dom
if ( tp = = null ) return false ;
if ( tp . index ! = index ) return false ;
if ( tp . name ! = name ) return false ;
if ( tp . hasConstructableContraint ! = hasConstructableContraint ) return false ;
if ( tp . hasConstructableConstraint ! = hasConstructableConstraint ) return false ;
if ( tp . hasReferenceTypeConstraint ! = hasReferenceTypeConstraint ) return false ;
if ( tp . hasValueTypeConstraint ! = hasValueTypeConstraint ) return false ;
if ( tp . method ! = method ) {
if ( tp . method = = null | | method = = null ) return false ;
if ( tp . method . FullyQualifiedName = = method . FullyQualifiedName ) return false ;
@ -129,5 +144,24 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -129,5 +144,24 @@ namespace ICSharpCode.SharpDevelop.Dom
{
return String . Format ( "[{0}: {1}]" , GetType ( ) . Name , name ) ;
}
public static DefaultClass GetDummyClassForTypeParameter ( ITypeParameter p )
{
DefaultClass c = new DefaultClass ( p . Class . CompilationUnit , p . Name ) ;
if ( p . Method ! = null ) {
c . Region = new DomRegion ( p . Method . Region . BeginLine , p . Method . Region . BeginColumn ) ;
} else {
c . Region = new DomRegion ( p . Class . Region . BeginLine , p . Class . Region . BeginColumn ) ;
}
c . Modifiers = ModifierEnum . Public ;
if ( p . HasValueTypeConstraint ) {
c . ClassType = ClassType . Struct ;
} else if ( p . HasConstructableConstraint ) {
c . ClassType = ClassType . Class ;
} else {
c . ClassType = ClassType . Interface ;
}
return c ;
}
}
}