|
|
|
@ -567,6 +567,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -567,6 +567,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
} else if (parameter.IsParams) { |
|
|
|
|
decl.ParameterModifier = ParameterModifier.Params; |
|
|
|
|
} |
|
|
|
|
decl.Attributes.AddRange (parameter.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.Type = ConvertType(parameter.Type); |
|
|
|
|
if (this.ShowParameterNames) { |
|
|
|
|
decl.Name = parameter.Name; |
|
|
|
@ -625,7 +626,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -625,7 +626,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
return ConvertDestructor((IMethod)entity); |
|
|
|
|
case SymbolKind.Accessor: |
|
|
|
|
IMethod accessor = (IMethod)entity; |
|
|
|
|
return ConvertAccessor(accessor, accessor.AccessorOwner != null ? accessor.AccessorOwner.Accessibility : Accessibility.None); |
|
|
|
|
return ConvertAccessor(accessor, accessor.AccessorOwner != null ? accessor.AccessorOwner.Accessibility : Accessibility.None, false); |
|
|
|
|
default: |
|
|
|
|
throw new ArgumentException("Invalid value for SymbolKind: " + entity.SymbolKind); |
|
|
|
|
} |
|
|
|
@ -679,6 +680,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -679,6 +680,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
var decl = new TypeDeclaration(); |
|
|
|
|
decl.ClassType = classType; |
|
|
|
|
decl.Modifiers = modifiers; |
|
|
|
|
decl.Attributes.AddRange (typeDefinition.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.Name = typeDefinition.Name; |
|
|
|
|
|
|
|
|
|
int outerTypeParameterCount = (typeDefinition.DeclaringTypeDefinition == null) ? 0 : typeDefinition.DeclaringTypeDefinition.TypeParameterCount; |
|
|
|
@ -691,7 +693,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -691,7 +693,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
|
|
|
|
|
if (this.ShowBaseTypes) { |
|
|
|
|
foreach (IType baseType in typeDefinition.DirectBaseTypes) { |
|
|
|
|
decl.BaseTypes.Add(ConvertType(baseType)); |
|
|
|
|
if (!baseType.IsKnownType (KnownTypeCode.Enum) && |
|
|
|
|
!baseType.IsKnownType (KnownTypeCode.Object) && |
|
|
|
|
!baseType.IsKnownType (KnownTypeCode.ValueType)) { |
|
|
|
|
decl.BaseTypes.Add (ConvertType (baseType)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -711,6 +717,10 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -711,6 +717,10 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
|
|
|
|
|
DelegateDeclaration decl = new DelegateDeclaration(); |
|
|
|
|
decl.Modifiers = modifiers & ~Modifiers.Sealed; |
|
|
|
|
decl.Attributes.AddRange (d.Attributes.Select (a => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.Attributes.AddRange (invokeMethod.ReturnTypeAttributes.Select ((a) => new AttributeSection (ConvertAttribute (a)) { |
|
|
|
|
AttributeTarget = "return" |
|
|
|
|
})); |
|
|
|
|
decl.ReturnType = ConvertType(invokeMethod.ReturnType); |
|
|
|
|
decl.Name = d.Name; |
|
|
|
|
|
|
|
|
@ -749,6 +759,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -749,6 +759,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
} |
|
|
|
|
decl.Modifiers = m; |
|
|
|
|
} |
|
|
|
|
decl.Attributes.AddRange (field.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.ReturnType = ConvertType(field.ReturnType); |
|
|
|
|
Expression initializer = null; |
|
|
|
|
if (field.IsConst && this.ShowConstantValues) |
|
|
|
@ -768,13 +779,22 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -768,13 +779,22 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Accessor ConvertAccessor(IMethod accessor, Accessibility ownerAccessibility) |
|
|
|
|
Accessor ConvertAccessor(IMethod accessor, Accessibility ownerAccessibility, bool addParamterAttribute) |
|
|
|
|
{ |
|
|
|
|
if (accessor == null) |
|
|
|
|
return Accessor.Null; |
|
|
|
|
Accessor decl = new Accessor(); |
|
|
|
|
if (this.ShowAccessibility && accessor.Accessibility != ownerAccessibility) |
|
|
|
|
decl.Modifiers = ModifierFromAccessibility(accessor.Accessibility); |
|
|
|
|
decl.Attributes.AddRange (accessor.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.Attributes.AddRange (accessor.ReturnTypeAttributes.Select ((a) => new AttributeSection (ConvertAttribute (a)) { |
|
|
|
|
AttributeTarget = "return" |
|
|
|
|
})); |
|
|
|
|
if (addParamterAttribute && accessor.Parameters.Count > 0) { |
|
|
|
|
decl.Attributes.AddRange (accessor.Parameters.Last ().Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)) { |
|
|
|
|
AttributeTarget = "param" |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
decl.Body = GenerateBodyBlock(); |
|
|
|
|
return decl; |
|
|
|
|
} |
|
|
|
@ -783,10 +803,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -783,10 +803,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
{ |
|
|
|
|
PropertyDeclaration decl = new PropertyDeclaration(); |
|
|
|
|
decl.Modifiers = GetMemberModifiers(property); |
|
|
|
|
decl.Attributes.AddRange (property.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.ReturnType = ConvertType(property.ReturnType); |
|
|
|
|
decl.Name = property.Name; |
|
|
|
|
decl.Getter = ConvertAccessor(property.Getter, property.Accessibility); |
|
|
|
|
decl.Setter = ConvertAccessor(property.Setter, property.Accessibility); |
|
|
|
|
decl.Getter = ConvertAccessor(property.Getter, property.Accessibility, false); |
|
|
|
|
decl.Setter = ConvertAccessor(property.Setter, property.Accessibility, true); |
|
|
|
|
return decl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -794,12 +815,13 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -794,12 +815,13 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
{ |
|
|
|
|
IndexerDeclaration decl = new IndexerDeclaration(); |
|
|
|
|
decl.Modifiers = GetMemberModifiers(indexer); |
|
|
|
|
decl.Attributes.AddRange (indexer.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.ReturnType = ConvertType(indexer.ReturnType); |
|
|
|
|
foreach (IParameter p in indexer.Parameters) { |
|
|
|
|
decl.Parameters.Add(ConvertParameter(p)); |
|
|
|
|
} |
|
|
|
|
decl.Getter = ConvertAccessor(indexer.Getter, indexer.Accessibility); |
|
|
|
|
decl.Setter = ConvertAccessor(indexer.Setter, indexer.Accessibility); |
|
|
|
|
decl.Getter = ConvertAccessor(indexer.Getter, indexer.Accessibility, false); |
|
|
|
|
decl.Setter = ConvertAccessor(indexer.Setter, indexer.Accessibility, true); |
|
|
|
|
return decl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -808,14 +830,16 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -808,14 +830,16 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
if (this.UseCustomEvents) { |
|
|
|
|
CustomEventDeclaration decl = new CustomEventDeclaration(); |
|
|
|
|
decl.Modifiers = GetMemberModifiers(ev); |
|
|
|
|
decl.Attributes.AddRange (ev.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.ReturnType = ConvertType(ev.ReturnType); |
|
|
|
|
decl.Name = ev.Name; |
|
|
|
|
decl.AddAccessor = ConvertAccessor(ev.AddAccessor, ev.Accessibility); |
|
|
|
|
decl.RemoveAccessor = ConvertAccessor(ev.RemoveAccessor, ev.Accessibility); |
|
|
|
|
decl.AddAccessor = ConvertAccessor(ev.AddAccessor, ev.Accessibility, true); |
|
|
|
|
decl.RemoveAccessor = ConvertAccessor(ev.RemoveAccessor, ev.Accessibility, true); |
|
|
|
|
return decl; |
|
|
|
|
} else { |
|
|
|
|
EventDeclaration decl = new EventDeclaration(); |
|
|
|
|
decl.Modifiers = GetMemberModifiers(ev); |
|
|
|
|
decl.Attributes.AddRange (ev.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.ReturnType = ConvertType(ev.ReturnType); |
|
|
|
|
decl.Variables.Add(new VariableInitializer(ev.Name)); |
|
|
|
|
return decl; |
|
|
|
@ -828,7 +852,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -828,7 +852,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
decl.Modifiers = GetMemberModifiers(method); |
|
|
|
|
if (method.IsAsync && ShowModifiers) |
|
|
|
|
decl.Modifiers |= Modifiers.Async; |
|
|
|
|
decl.Attributes.AddRange (method.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
decl.ReturnType = ConvertType(method.ReturnType); |
|
|
|
|
decl.Attributes.AddRange (method.ReturnTypeAttributes.Select ((a) => new AttributeSection (ConvertAttribute (a)) { |
|
|
|
|
AttributeTarget = "return" |
|
|
|
|
})); |
|
|
|
|
decl.Name = method.Name; |
|
|
|
|
|
|
|
|
|
if (this.ShowTypeParameters) { |
|
|
|
@ -875,6 +903,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -875,6 +903,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
{ |
|
|
|
|
ConstructorDeclaration decl = new ConstructorDeclaration(); |
|
|
|
|
decl.Modifiers = GetMemberModifiers(ctor); |
|
|
|
|
decl.Attributes.AddRange (ctor.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
if (ctor.DeclaringTypeDefinition != null) |
|
|
|
|
decl.Name = ctor.DeclaringTypeDefinition.Name; |
|
|
|
|
foreach (IParameter p in ctor.Parameters) { |
|
|
|
@ -947,6 +976,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
@@ -947,6 +976,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
|
|
|
|
|
TypeParameterDeclaration decl = new TypeParameterDeclaration(); |
|
|
|
|
decl.Variance = tp.Variance; |
|
|
|
|
decl.Name = tp.Name; |
|
|
|
|
decl.Attributes.AddRange (tp.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a)))); |
|
|
|
|
return decl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|