void WriteMemberDeclarationName(IMember member, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); if ((ConversionFlags & ConversionFlags.ShowDeclaringType) == ConversionFlags.ShowDeclaringType) { ConvertType(member.DeclaringType, formatter, formattingPolicy); formatter.WriteToken("."); } switch (member.EntityType) { case EntityType.Indexer: formatter.WriteKeyword("this"); break; case EntityType.Constructor: formatter.WriteIdentifier(member.DeclaringType.Name); break; case EntityType.Destructor: formatter.WriteToken("~"); formatter.WriteIdentifier(member.DeclaringType.Name); break; case EntityType.Operator: switch (member.Name) { case "op_Implicit": formatter.WriteKeyword("implicit"); formatter.Space(); formatter.WriteKeyword("operator"); formatter.Space(); ConvertType(member.ReturnType, formatter, formattingPolicy); break; case "op_Explicit": formatter.WriteKeyword("explicit"); formatter.Space(); formatter.WriteKeyword("operator"); formatter.Space(); ConvertType(member.ReturnType, formatter, formattingPolicy); break; default: formatter.WriteKeyword("operator"); formatter.Space(); var operatorType = OperatorDeclaration.GetOperatorType(member.Name); if (operatorType.HasValue) { formatter.WriteToken(OperatorDeclaration.GetToken(operatorType.Value)); } else { formatter.WriteIdentifier(member.Name); } break; } break; default: formatter.WriteIdentifier(member.Name); break; } if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList && member.EntityType == EntityType.Method) { var outputVisitor = new CSharpOutputVisitor(formatter, formattingPolicy); outputVisitor.WriteTypeParameters(astBuilder.ConvertEntity(member).GetChildrenByRole(Roles.TypeParameter)); } }
void WriteMemberDeclarationName(IMember member, TokenWriter writer, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); EntityDeclaration node = astBuilder.ConvertEntity(member); if ((ConversionFlags & ConversionFlags.ShowDeclaringType) == ConversionFlags.ShowDeclaringType && member.DeclaringType != null) { ConvertType(member.DeclaringType, writer, formattingPolicy); writer.WriteTokenOperator(Roles.Dot, "."); } switch (member.SymbolKind) { case SymbolKind.Indexer: writer.WriteKeyword(Roles.Identifier, "this"); break; case SymbolKind.Constructor: WriteQualifiedName(member.DeclaringType.Name, writer, formattingPolicy); break; case SymbolKind.Destructor: writer.WriteTokenOperator(DestructorDeclaration.TildeRole, "~"); WriteQualifiedName(member.DeclaringType.Name, writer, formattingPolicy); break; case SymbolKind.Operator: switch (member.Name) { case "op_Implicit": writer.WriteKeyword(OperatorDeclaration.ImplicitRole, "implicit"); writer.Space(); writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); ConvertType(member.ReturnType, writer, formattingPolicy); break; case "op_Explicit": writer.WriteKeyword(OperatorDeclaration.ExplicitRole, "explicit"); writer.Space(); writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); ConvertType(member.ReturnType, writer, formattingPolicy); break; default: writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); var operatorType = OperatorDeclaration.GetOperatorType(member.Name); if (operatorType.HasValue) { writer.WriteToken(OperatorDeclaration.GetRole(operatorType.Value), OperatorDeclaration.GetToken(operatorType.Value), BoxedTextColor.Text); } else { writer.WriteIdentifier(node.NameToken, BoxedTextColor.Text); } break; } break; default: writer.WriteIdentifier(Identifier.Create(member.Name), BoxedTextColor.Text); break; } if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList && member.SymbolKind == SymbolKind.Method) { var outputVisitor = new CSharpOutputVisitor(writer, formattingPolicy); outputVisitor.WriteTypeParameters(node.GetChildrenByRole(Roles.TypeParameter), CodeBracesRangeFlags.AngleBrackets); } }