@ -225,7 +225,7 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -225,7 +225,7 @@ namespace ICSharpCode.NRefactory.CSharp
var typeArgLocation = LocationsBag . GetLocations ( c . MemberName ) ;
if ( typeArgLocation ! = null )
newType . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 0 ] ) , 1 ) , TypeDeclaration . Roles . LChevron ) ;
// AddTypeArguments (newType, typeArgLocation, c.MemberName.TypeArguments);
AddTypeParameters ( newType , typeArgLocation , c . MemberName . TypeArguments ) ;
if ( typeArgLocation ! = null )
newType . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 1 ] ) , 1 ) , TypeDeclaration . Roles . RChevron ) ;
AddConstraints ( newType , c ) ;
@ -254,7 +254,7 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -254,7 +254,7 @@ namespace ICSharpCode.NRefactory.CSharp
var typeArgLocation = LocationsBag . GetLocations ( s . MemberName ) ;
if ( typeArgLocation ! = null )
newType . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 0 ] ) , 1 ) , TypeDeclaration . Roles . LChevron ) ;
// AddTypeArguments (newType, typeArgLocation, s.MemberName.TypeArguments);
AddTypeParameters ( newType , typeArgLocation , s . MemberName . TypeArguments ) ;
if ( typeArgLocation ! = null )
newType . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 1 ] ) , 1 ) , TypeDeclaration . Roles . RChevron ) ;
AddConstraints ( newType , s ) ;
@ -283,7 +283,7 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -283,7 +283,7 @@ namespace ICSharpCode.NRefactory.CSharp
var typeArgLocation = LocationsBag . GetLocations ( i . MemberName ) ;
if ( typeArgLocation ! = null )
newType . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 0 ] ) , 1 ) , MemberReferenceExpression . Roles . LChevron ) ;
// AddTypeArguments (newType, typeArgLocation, i.MemberName.TypeArguments);
AddTypeParameters ( newType , typeArgLocation , i . MemberName . TypeArguments ) ;
if ( typeArgLocation ! = null )
newType . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 1 ] ) , 1 ) , MemberReferenceExpression . Roles . RChevron ) ;
AddConstraints ( newType , i ) ;
@ -307,12 +307,12 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -307,12 +307,12 @@ namespace ICSharpCode.NRefactory.CSharp
if ( location ! = null )
newDelegate . AddChild ( new CSharpTokenNode ( Convert ( location [ 0 ] ) , "delegate" . Length ) , TypeDeclaration . Roles . Keyword ) ;
newDelegate . AddChild ( ConvertToType ( d . ReturnType ) , AstNode . Roles . Type ) ;
newDelegate . AddChild ( new Identifier ( d . N ame, Convert ( d . MemberName . Location ) ) , AstNode . Roles . Identifier ) ;
newDelegate . AddChild ( new Identifier ( d . Basen ame, Convert ( d . MemberName . Location ) ) , AstNode . Roles . Identifier ) ;
if ( d . MemberName . TypeArguments ! = null ) {
var typeArgLocation = LocationsBag . GetLocations ( d . MemberName ) ;
if ( typeArgLocation ! = null )
newDelegate . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 0 ] ) , 1 ) , TypeDeclaration . Roles . LChevron ) ;
// AddTypeArguments (newDelegate, typeArgLocation, d.MemberName.TypeArguments);
AddTypeParameters ( newDelegate , typeArgLocation , d . MemberName . TypeArguments ) ;
if ( typeArgLocation ! = null )
newDelegate . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 1 ] ) , 1 ) , TypeDeclaration . Roles . RChevron ) ;
AddConstraints ( newDelegate , d ) ;
@ -632,7 +632,7 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -632,7 +632,7 @@ namespace ICSharpCode.NRefactory.CSharp
var typeArgLocation = LocationsBag . GetLocations ( m . MemberName ) ;
if ( typeArgLocation ! = null )
newMethod . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 0 ] ) , 1 ) , MemberReferenceExpression . Roles . LChevron ) ;
// AddTypeArguments (newMethod, typeArgLocation, m.MemberName.TypeArguments);
AddTypeParameters ( newMethod , typeArgLocation , m . MemberName . TypeArguments ) ;
if ( typeArgLocation ! = null )
newMethod . AddChild ( new CSharpTokenNode ( Convert ( typeArgLocation [ 1 ] ) , 1 ) , MemberReferenceExpression . Roles . RChevron ) ;
@ -1835,17 +1835,22 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -1835,17 +1835,22 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
void AddTypeArgument s ( AstNode parent , LocationsBag . MemberLocations location , Mono . CSharp . TypeArguments typeArguments )
void AddTypeParameter s ( AstNode parent , List < Location > location , Mono . CSharp . TypeArguments typeArguments )
{
if ( typeArguments = = null | | typeArguments . IsEmpty )
return ;
for ( int i = 0 ; i < typeArguments . Count ; i + + ) {
if ( location ! = null & & i > 0 & & i - 1 < location . Count )
parent . AddChild ( new CSharpTokenNode ( Convert ( location [ i - 1 ] ) , 1 ) , InvocationExpression . Roles . Comma ) ;
var arg = typeArguments . Args [ i ] ;
var arg = ( TypeParameterName ) typeArguments . Args [ i ] ;
if ( arg = = null )
continue ;
parent . AddChild ( ConvertToType ( arg ) , InvocationExpression . Roles . TypeArgument ) ;
TypeParameterDeclaration tp = new TypeParameterDeclaration ( ) ;
// TODO: attributes
if ( arg . Variance ! = Variance . None )
throw new NotImplementedException ( ) ; // TODO: variance
tp . AddChild ( new Identifier ( arg . Name , Convert ( arg . Location ) ) , InvocationExpression . Roles . Identifier ) ;
parent . AddChild ( tp , InvocationExpression . Roles . TypeParameter ) ;
}
}
@ -1871,11 +1876,12 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -1871,11 +1876,12 @@ namespace ICSharpCode.NRefactory.CSharp
Constraints c = d . Constraints [ i ] ;
var location = LocationsBag . GetLocations ( c ) ;
var constraint = new Constraint ( ) ;
pare nt. AddChild ( new CSharpTokenNode ( Convert ( location [ 0 ] ) , "where" . Length ) , InvocationExpression . Roles . Keyword ) ;
pare nt. AddChild ( new Identifier ( c . TypeParameter . Value , Convert ( c . TypeParameter . Location ) ) , InvocationExpression . Roles . Identifier ) ;
pare nt. AddChild ( new CSharpTokenNode ( Convert ( location [ 1 ] ) , 1 ) , Constraint . ColonRole ) ;
constrai nt. AddChild ( new CSharpTokenNode ( Convert ( location [ 0 ] ) , "where" . Length ) , InvocationExpression . Roles . Keyword ) ;
constrai nt. AddChild ( new Identifier ( c . TypeParameter . Value , Convert ( c . TypeParameter . Location ) ) , InvocationExpression . Roles . Identifier ) ;
constrai nt. AddChild ( new CSharpTokenNode ( Convert ( location [ 1 ] ) , 1 ) , Constraint . ColonRole ) ;
foreach ( var expr in c . ConstraintExpressions )
parent . AddChild ( ConvertToType ( expr ) , Constraint . BaseTypeRole ) ;
constraint . AddChild ( ConvertToType ( expr ) , Constraint . BaseTypeRole ) ;
parent . AddChild ( constraint , AstNode . Roles . Constraint ) ;
}
}