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

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

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

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

@ -99,8 +99,8 @@ namespace ICSharpCode.NRefactory.CSharp
if (role != null) if (role != null)
this.flags |= role.TokenIndex << AstNodeFlagsUsedBits; 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)]; return TokenRole.Tokens [(int)(this.flags >> AstNodeFlagsUsedBits)];
} }
@ -125,11 +125,6 @@ namespace ICSharpCode.NRefactory.CSharp
CSharpTokenNode o = other as CSharpTokenNode; CSharpTokenNode o = other as CSharpTokenNode;
return o != null && !o.IsNull && !(o is CSharpModifierToken); 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
&& this.BaseType.DoMatch(o.BaseType, match) && this.BaseType.DoMatch(o.BaseType, match)
&& this.ArraySpecifiers.DoMatch(o.ArraySpecifiers, match); && this.ArraySpecifiers.DoMatch(o.ArraySpecifiers, match);
} }
public override string ToString() public override string ToString(CSharpFormattingOptions formattingOptions)
{ {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.Append(this.BaseType.ToString()); b.Append(this.BaseType.ToString());
@ -210,8 +210,8 @@ namespace ICSharpCode.NRefactory.CSharp
ArraySpecifier o = other as ArraySpecifier; ArraySpecifier o = other as ArraySpecifier;
return o != null && this.Dimensions == o.Dimensions; return o != null && this.Dimensions == o.Dimensions;
} }
public override string ToString() public override string ToString(CSharpFormattingOptions formattingOptions)
{ {
return "[" + new string(',', this.Dimensions - 1) + "]"; return "[" + new string(',', this.Dimensions - 1) + "]";
} }

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

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

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

@ -118,13 +118,7 @@ namespace ICSharpCode.NRefactory.CSharp
{ {
return (Expression)base.Clone(); 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) public Expression ReplaceWith(Func<Expression, Expression> replaceFunction)
{ {
if (replaceFunction == null) if (replaceFunction == null)

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

@ -74,13 +74,12 @@ namespace ICSharpCode.NRefactory.CSharp
Attribute o = other as Attribute; Attribute o = other as Attribute;
return o != null && this.Type.DoMatch (o.Type, match) && this.Arguments.DoMatch (o.Arguments, match); 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) if (IsNull)
return "Null"; return "Null";
else return base.ToString(formattingOptions);
return GetText();
} }
} }
} }

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

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

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

@ -119,24 +119,7 @@ namespace ICSharpCode.NRefactory.CSharp
&& MatchString(this.MemberName, o.MemberName) && this.Target.DoMatch(o.Target, match) && MatchString(this.MemberName, o.MemberName) && this.Target.DoMatch(o.Target, match)
&& this.TypeArguments.DoMatch(o.TypeArguments, 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) public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider = null)
{ {
if (interningProvider == null) if (interningProvider == null)

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

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

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

@ -147,17 +147,6 @@ namespace ICSharpCode.NRefactory.CSharp
return o != null && MatchString(this.Identifier, o.Identifier) && this.TypeArguments.DoMatch(o.TypeArguments, match); 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) public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider = null)
{ {
if (interningProvider == null) if (interningProvider == null)

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

@ -122,11 +122,5 @@ namespace ICSharpCode.NRefactory.CSharp
public override NodeType NodeType { public override NodeType NodeType {
get { return NodeType.Statement; } 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
{ {
return visitor.VisitVariableInitializer (this, data); 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) protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{ {
VariableInitializer o = other as VariableInitializer; VariableInitializer o = other as VariableInitializer;

Loading…
Cancel
Save