Browse Source

Replaced GetText() with ToString (). (GetText is still in the API but

will get removed)
pull/32/merge
Mike Krüger 13 years ago
parent
commit
106bfc49db
  1. 16
      ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
  2. 2
      ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs
  3. 9
      ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs
  4. 8
      ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs
  5. 4
      ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs
  6. 8
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs
  7. 7
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs
  8. 6
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs
  9. 19
      ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs
  10. 4
      ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs
  11. 11
      ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs
  12. 6
      ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs
  13. 10
      ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs

16
ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs

@ -877,14 +877,19 @@ namespace ICSharpCode.NRefactory.CSharp @@ -877,14 +877,19 @@ namespace ICSharpCode.NRefactory.CSharp
node = next;
}
}
[Obsolete("Use ToString(options).")]
public string GetText (CSharpFormattingOptions formattingOptions = null)
{
return ToString(formattingOptions);
}
/// <summary>
/// Gets the node as formatted C# output.
/// </summary>
/// <param name='formattingOptions'>
/// Formatting options.
/// </param>
public virtual string GetText (CSharpFormattingOptions formattingOptions = null)
public virtual string ToString (CSharpFormattingOptions formattingOptions)
{
if (IsNull)
return "";
@ -892,7 +897,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -892,7 +897,12 @@ namespace ICSharpCode.NRefactory.CSharp
AcceptVisitor (new CSharpOutputVisitor (w, formattingOptions ?? FormattingOptionsFactory.CreateMono ()));
return w.ToString ();
}
public sealed override string ToString()
{
return ToString(null);
}
/// <summary>
/// Returns true, if the given coordinates (line, column) are in the node.
/// </summary>

2
ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override string GetText (CSharpFormattingOptions formattingOptions = null)
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return GetModifierName (Modifier);
}

9
ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs

@ -99,8 +99,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -99,8 +99,8 @@ namespace ICSharpCode.NRefactory.CSharp
if (role != null)
this.flags |= role.TokenIndex << AstNodeFlagsUsedBits;
}
public override string GetText (CSharpFormattingOptions formattingOptions = null)
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return TokenRole.Tokens [(int)(this.flags >> AstNodeFlagsUsedBits)];
}
@ -125,11 +125,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -125,11 +125,6 @@ namespace ICSharpCode.NRefactory.CSharp
CSharpTokenNode o = other as CSharpTokenNode;
return o != null && !o.IsNull && !(o is CSharpModifierToken);
}
public override string ToString ()
{
return string.Format ("[CSharpTokenNode: StartLocation={0}, EndLocation={1}, Role={2}]", StartLocation, EndLocation, Role);
}
}
}

8
ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs

@ -96,8 +96,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -96,8 +96,8 @@ namespace ICSharpCode.NRefactory.CSharp
&& this.BaseType.DoMatch(o.BaseType, match)
&& this.ArraySpecifiers.DoMatch(o.ArraySpecifiers, match);
}
public override string ToString()
public override string ToString(CSharpFormattingOptions formattingOptions)
{
StringBuilder b = new StringBuilder();
b.Append(this.BaseType.ToString());
@ -210,8 +210,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -210,8 +210,8 @@ namespace ICSharpCode.NRefactory.CSharp
ArraySpecifier o = other as ArraySpecifier;
return o != null && this.Dimensions == o.Dimensions;
}
public override string ToString()
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return "[" + new string(',', this.Dimensions - 1) + "]";
}

4
ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs

@ -78,8 +78,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -78,8 +78,8 @@ namespace ICSharpCode.NRefactory.CSharp
var o = other as ErrorNode;
return o != null;
}
public override string ToString ()
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return "[ErrorNode]";
}

8
ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs

@ -118,13 +118,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -118,13 +118,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
return (Expression)base.Clone();
}
// Make debugging easier by giving Expressions a ToString() implementation
public override string ToString()
{
return DebugToString();
}
public Expression ReplaceWith(Func<Expression, Expression> replaceFunction)
{
if (replaceFunction == null)

7
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs

@ -74,13 +74,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -74,13 +74,12 @@ namespace ICSharpCode.NRefactory.CSharp
Attribute o = other as Attribute;
return o != null && this.Type.DoMatch (o.Type, match) && this.Arguments.DoMatch (o.Arguments, match);
}
public override string ToString ()
public override string ToString(CSharpFormattingOptions formattingOptions)
{
if (IsNull)
return "Null";
else
return GetText();
return base.ToString(formattingOptions);
}
}
}

6
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs

@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override string GetText(CSharpFormattingOptions formattingOptions)
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return "\n";
}
@ -104,7 +104,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -104,7 +104,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override string GetText(CSharpFormattingOptions formattingOptions)
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return "\r\n";
}
@ -132,7 +132,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -132,7 +132,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override string GetText(CSharpFormattingOptions formattingOptions)
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return "\r";
}

19
ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs

@ -119,24 +119,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -119,24 +119,7 @@ namespace ICSharpCode.NRefactory.CSharp
&& MatchString(this.MemberName, o.MemberName) && this.Target.DoMatch(o.Target, match)
&& this.TypeArguments.DoMatch(o.TypeArguments, match);
}
public override string ToString()
{
StringBuilder b = new StringBuilder();
b.Append(this.Target);
if (IsDoubleColon)
b.Append("::");
else
b.Append('.');
b.Append(this.MemberName);
if (this.TypeArguments.Any()) {
b.Append('<');
b.Append(string.Join(", ", this.TypeArguments));
b.Append('>');
}
return b.ToString();
}
public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider = null)
{
if (interningProvider == null)

4
ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs

@ -97,8 +97,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -97,8 +97,8 @@ namespace ICSharpCode.NRefactory.CSharp
PrimitiveType o = other as PrimitiveType;
return o != null && MatchString(this.Keyword, o.Keyword);
}
public override string ToString()
public override string ToString(CSharpFormattingOptions formattingOptions)
{
return Keyword;
}

11
ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs

@ -147,17 +147,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -147,17 +147,6 @@ namespace ICSharpCode.NRefactory.CSharp
return o != null && MatchString(this.Identifier, o.Identifier) && this.TypeArguments.DoMatch(o.TypeArguments, match);
}
public override string ToString()
{
StringBuilder b = new StringBuilder(this.Identifier);
if (this.TypeArguments.Any()) {
b.Append('<');
b.Append(string.Join(", ", this.TypeArguments));
b.Append('>');
}
return b.ToString();
}
public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider = null)
{
if (interningProvider == null)

6
ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs

@ -122,11 +122,5 @@ namespace ICSharpCode.NRefactory.CSharp @@ -122,11 +122,5 @@ namespace ICSharpCode.NRefactory.CSharp
public override NodeType NodeType {
get { return NodeType.Statement; }
}
// Make debugging easier by giving Statements a ToString() implementation
public override string ToString()
{
return DebugToString();
}
}
}

10
ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs

@ -163,15 +163,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -163,15 +163,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitVariableInitializer (this, data);
}
public override string ToString()
{
if (this.Initializer.IsNull)
return "[VariableInitializer " + this.Name + "]";
else
return "[VariableInitializer " + this.Name + " = " + this.Initializer.ToString() + "]";
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
VariableInitializer o = other as VariableInitializer;

Loading…
Cancel
Save