Browse Source

OutputVisitor: allow writing constructor declarations without writing their parent type declaration.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
84a5ace4aa
  1. 7
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs
  2. 9
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/DestructorDeclaration.cs
  3. 8
      ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

7
ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs

@ -33,6 +33,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,6 +33,13 @@ namespace ICSharpCode.NRefactory.CSharp
{
public static readonly Role<ConstructorInitializer> InitializerRole = new Role<ConstructorInitializer>("Initializer", ConstructorInitializer.Null);
/// <summary>
/// Gets/Sets the name of the class containing the constructor.
/// This property can be used to inform the output visitor about the class name when writing a constructor declaration
/// without writing the complete type declaration. It is ignored when the constructor has a type declaration as parent.
/// </summary>
public string Name { get; set; }
public CSharpTokenNode LParToken {
get { return GetChildByRole (Roles.LPar); }
}

9
ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/DestructorDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// DestructorDeclaration.cs
//
// Author:
@ -34,6 +34,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -34,6 +34,13 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (TildeRole); }
}
/// <summary>
/// Gets/Sets the name of the class containing the destructor.
/// This property can be used to inform the output visitor about the class name when writing a destructor declaration
/// without writing the complete type declaration. It is ignored when the destructor has a type declaration as parent.
/// </summary>
public string Name { get; set; }
public CSharpTokenNode LParToken {
get { return GetChildByRole (Roles.LPar); }
}

8
ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -1626,9 +1626,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1626,9 +1626,7 @@ namespace ICSharpCode.NRefactory.CSharp
WriteAttributes(constructorDeclaration.Attributes);
WriteModifiers(constructorDeclaration.ModifierTokens);
TypeDeclaration type = constructorDeclaration.Parent as TypeDeclaration;
if (type != null) {
WriteIdentifier(type.Name);
}
WriteIdentifier(type != null ? type.Name : constructorDeclaration.Name);
Space(policy.BeforeConstructorDeclarationParentheses);
WriteCommaSeparatedListInParenthesis(constructorDeclaration.Parameters, policy.WithinMethodDeclarationParentheses);
if (!constructorDeclaration.Initializer.IsNull) {
@ -1661,9 +1659,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1661,9 +1659,7 @@ namespace ICSharpCode.NRefactory.CSharp
WriteModifiers(destructorDeclaration.ModifierTokens);
WriteToken("~", DestructorDeclaration.TildeRole);
TypeDeclaration type = destructorDeclaration.Parent as TypeDeclaration;
if (type != null) {
WriteIdentifier(type.Name);
}
WriteIdentifier(type != null ? type.Name : destructorDeclaration.Name);
Space(policy.BeforeConstructorDeclarationParentheses);
LPar();
RPar();

Loading…
Cancel
Save