Browse Source

Corrected locations for parset expressions/statments/type members.

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
450be5a945
  1. 9
      ICSharpCode.NRefactory/CSharp/Ast/CSharpTokenNode.cs
  2. 13
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs
  3. 11
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Comment.cs
  4. 35
      ICSharpCode.NRefactory/CSharp/Ast/IRelocationable.cs
  5. 10
      ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs
  6. 9
      ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs
  7. 1062
      ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  8. 3
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

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

@ -27,7 +27,7 @@ using System; @@ -27,7 +27,7 @@ using System;
namespace ICSharpCode.NRefactory.CSharp
{
public class CSharpTokenNode : AstNode
public class CSharpTokenNode : AstNode, IRelocationable
{
public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode ();
class NullCSharpTokenNode : CSharpTokenNode
@ -80,6 +80,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -80,6 +80,13 @@ namespace ICSharpCode.NRefactory.CSharp
this.tokenLength = tokenLength;
}
#region IRelocationable implementation
void IRelocationable.SetStartLocation (AstLocation startLocation)
{
this.startLocation = startLocation;
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCSharpTokenNode (this, data);

13
ICSharpCode.NRefactory/CSharp/Ast/Expressions/EmptyExpression.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Type&lt;[EMPTY]&gt;
/// </summary>
public class EmptyExpression : Expression
public class EmptyExpression : Expression, IRelocationable
{
AstLocation location;
@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.CSharp
return location;
}
}
public override AstLocation EndLocation {
get {
return location;
@ -54,7 +54,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,7 +54,14 @@ namespace ICSharpCode.NRefactory.CSharp
{
this.location = location;
}
#region IRelocationable implementation
void IRelocationable.SetStartLocation (AstLocation startLocation)
{
this.location = startLocation;
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitEmptyExpression (this, data);

11
ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Comment.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -32,7 +32,7 @@ namespace ICSharpCode.NRefactory.CSharp
Documentation
}
public class Comment : AstNode
public class Comment : AstNode, IRelocationable
{
public override NodeType NodeType {
get {
@ -81,6 +81,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -81,6 +81,15 @@ namespace ICSharpCode.NRefactory.CSharp
this.startLocation = startLocation;
this.endLocation = endLocation;
}
#region IRelocationable implementation
void IRelocationable.SetStartLocation (AstLocation startLocation)
{
int lineDelta = startLocation.Line - this.startLocation.Line;
endLocation = new AstLocation (endLocation.Line + lineDelta, lineDelta != 0 ? endLocation.Column : endLocation.Column + startLocation.Column - this.startLocation.Column);
this.startLocation = startLocation;
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{

35
ICSharpCode.NRefactory/CSharp/Ast/IRelocationable.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
//
// IRelocationable.cs
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace ICSharpCode.NRefactory.CSharp
{
public interface IRelocationable
{
void SetStartLocation (AstLocation startLocation);
}
}

10
ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs

@ -28,7 +28,7 @@ using System; @@ -28,7 +28,7 @@ using System;
namespace ICSharpCode.NRefactory.CSharp
{
public class Identifier : AstNode
public class Identifier : AstNode, IRelocationable
{
public static readonly new Identifier Null = new NullIdentifier ();
class NullIdentifier : Identifier
@ -79,7 +79,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -79,7 +79,15 @@ namespace ICSharpCode.NRefactory.CSharp
get {
return startLocation;
}
}
#region IRelocationable implementation
void IRelocationable.SetStartLocation (AstLocation startLocation)
{
this.startLocation = startLocation;
}
#endregion
public override AstLocation EndLocation {
get {

9
ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs

@ -29,7 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -29,7 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// ;
/// </summary>
public class EmptyStatement : Statement
public class EmptyStatement : Statement, IRelocationable
{
public AstLocation Location {
get;
@ -48,6 +48,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,6 +48,13 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
#region IRelocationable implementation
void IRelocationable.SetStartLocation (AstLocation startLocation)
{
this.Location = startLocation;
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitEmptyStatement (this, data);

1062
ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs

File diff suppressed because it is too large Load Diff

3
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</ProjectGuid>
@ -355,6 +355,7 @@ @@ -355,6 +355,7 @@
<Compile Include="CSharp\Formatter\CSharpFormattingOptions.cs" />
<Compile Include="CSharp\Ast\Expressions\AnonymousTypeCreateExpression.cs" />
<Compile Include="CSharp\Ast\Expressions\UndocumentedExpression.cs" />
<Compile Include="CSharp\Ast\IRelocationable.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="CSharp\" />

Loading…
Cancel
Save