Browse Source

Fix end location of PrimitiveExpression

pull/923/head
Siegfried Pammer 8 years ago
parent
commit
9871984991
  1. 7
      ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs
  2. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs

7
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs

@ -103,13 +103,14 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -103,13 +103,14 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public override void WritePrimitiveValue(object value, string literalValue = null)
{
Expression node = nodes.Peek().LastOrDefault() as Expression;
var startLocation = locationProvider.Location;
base.WritePrimitiveValue(value, literalValue);
if (node is PrimitiveExpression) {
((PrimitiveExpression)node).SetStartLocation(locationProvider.Location);
((PrimitiveExpression)node).SetLocation(startLocation, locationProvider.Location);
}
if (node is NullReferenceExpression) {
((NullReferenceExpression)node).SetStartLocation(locationProvider.Location);
((NullReferenceExpression)node).SetStartLocation(startLocation);
}
base.WritePrimitiveValue(value, literalValue);
}
public override void WritePrimitiveType(string type)

6
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs

@ -43,11 +43,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -43,11 +43,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
internal void SetStartLocation(TextLocation value)
internal void SetLocation(TextLocation startLocation, TextLocation endLocation)
{
ThrowIfFrozen();
this.startLocation = value;
this.endLocation = null;
this.startLocation = startLocation;
this.endLocation = endLocation;
}
string literalValue;

Loading…
Cancel
Save