|
|
@ -25,17 +25,18 @@ |
|
|
|
// THE SOFTWARE.
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.IO; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using ICSharpCode.Decompiler.CSharp.OutputVisitor; |
|
|
|
using ICSharpCode.NRefactory.TypeSystem; |
|
|
|
using ICSharpCode.Decompiler.TypeSystem; |
|
|
|
|
|
|
|
using ICSharpCode.NRefactory.CSharp; |
|
|
|
|
|
|
|
using ICSharpCode.NRefactory.PatternMatching; |
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.NRefactory.CSharp |
|
|
|
namespace ICSharpCode.Decompiler.CSharp.Syntax |
|
|
|
{ |
|
|
|
{ |
|
|
|
public abstract class AstNode : AbstractAnnotatable, ICSharpCode.NRefactory.TypeSystem.IFreezable, PatternMatching.INode, ICloneable |
|
|
|
public abstract class AstNode : AbstractAnnotatable, IFreezable, INode, ICloneable |
|
|
|
{ |
|
|
|
{ |
|
|
|
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class
|
|
|
|
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class
|
|
|
|
internal static readonly Role<AstNode> RootRole = new Role<AstNode> ("Root"); |
|
|
|
internal static readonly Role<AstNode> RootRole = new Role<AstNode> ("Root"); |
|
|
@ -72,7 +73,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
return visitor.VisitNullNode(this, data); |
|
|
|
return visitor.VisitNullNode(this, data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) |
|
|
|
protected internal override bool DoMatch (AstNode other, NRefactory.PatternMatching.Match match) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return other == null || other.IsNull; |
|
|
|
return other == null || other.IsNull; |
|
|
|
} |
|
|
|
} |
|
|
@ -80,16 +81,16 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region PatternPlaceholder
|
|
|
|
#region PatternPlaceholder
|
|
|
|
public static implicit operator AstNode (PatternMatching.Pattern pattern) |
|
|
|
public static implicit operator AstNode (NRefactory.PatternMatching.Pattern pattern) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return pattern != null ? new PatternPlaceholder (pattern) : null; |
|
|
|
return pattern != null ? new PatternPlaceholder (pattern) : null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sealed class PatternPlaceholder : AstNode, PatternMatching.INode |
|
|
|
sealed class PatternPlaceholder : AstNode, INode |
|
|
|
{ |
|
|
|
{ |
|
|
|
readonly PatternMatching.Pattern child; |
|
|
|
readonly NRefactory.PatternMatching.Pattern child; |
|
|
|
|
|
|
|
|
|
|
|
public PatternPlaceholder (PatternMatching.Pattern child) |
|
|
|
public PatternPlaceholder (NRefactory.PatternMatching.Pattern child) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.child = child; |
|
|
|
this.child = child; |
|
|
|
} |
|
|
|
} |
|
|
@ -113,12 +114,12 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
return visitor.VisitPatternPlaceholder (this, child, data); |
|
|
|
return visitor.VisitPatternPlaceholder (this, child, data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) |
|
|
|
protected internal override bool DoMatch (AstNode other, NRefactory.PatternMatching.Match match) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return child.DoMatch (other, match); |
|
|
|
return child.DoMatch (other, match); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) |
|
|
|
bool NRefactory.PatternMatching.INode.DoMatchCollection (Role role, NRefactory.PatternMatching.INode pos, NRefactory.PatternMatching.Match match, NRefactory.PatternMatching.BacktrackingInfo backtrackingInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return child.DoMatchCollection (role, pos, match, backtrackingInfo); |
|
|
|
return child.DoMatchCollection (role, pos, match, backtrackingInfo); |
|
|
|
} |
|
|
|
} |
|
|
@ -206,11 +207,11 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
/// The file name of the region is set based on the parent SyntaxTree's file name.
|
|
|
|
/// The file name of the region is set based on the parent SyntaxTree's file name.
|
|
|
|
/// If this node is not connected to a whole compilation, the file name will be null.
|
|
|
|
/// If this node is not connected to a whole compilation, the file name will be null.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public ICSharpCode.NRefactory.TypeSystem.DomRegion GetRegion() |
|
|
|
public DomRegion GetRegion() |
|
|
|
{ |
|
|
|
{ |
|
|
|
var syntaxTree = (this.Ancestors.LastOrDefault() ?? this) as SyntaxTree; |
|
|
|
var syntaxTree = (this.Ancestors.LastOrDefault() ?? this) as SyntaxTree; |
|
|
|
string fileName = (syntaxTree != null ? syntaxTree.FileName : null); |
|
|
|
string fileName = (syntaxTree != null ? syntaxTree.FileName : null); |
|
|
|
return new ICSharpCode.NRefactory.TypeSystem.DomRegion(fileName, this.StartLocation, this.EndLocation); |
|
|
|
return new DomRegion(fileName, this.StartLocation, this.EndLocation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public AstNode Parent { |
|
|
|
public AstNode Parent { |
|
|
@ -649,29 +650,29 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
#region Pattern Matching
|
|
|
|
#region Pattern Matching
|
|
|
|
protected static bool MatchString (string pattern, string text) |
|
|
|
protected static bool MatchString (string pattern, string text) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return PatternMatching.Pattern.MatchString(pattern, text); |
|
|
|
return NRefactory.PatternMatching.Pattern.MatchString(pattern, text); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected internal abstract bool DoMatch (AstNode other, PatternMatching.Match match); |
|
|
|
protected internal abstract bool DoMatch (AstNode other, NRefactory.PatternMatching.Match match); |
|
|
|
|
|
|
|
|
|
|
|
bool PatternMatching.INode.DoMatch (PatternMatching.INode other, PatternMatching.Match match) |
|
|
|
bool NRefactory.PatternMatching.INode.DoMatch (NRefactory.PatternMatching.INode other, NRefactory.PatternMatching.Match match) |
|
|
|
{ |
|
|
|
{ |
|
|
|
AstNode o = other as AstNode; |
|
|
|
AstNode o = other as AstNode; |
|
|
|
// try matching if other is null, or if other is an AstNode
|
|
|
|
// try matching if other is null, or if other is an AstNode
|
|
|
|
return (other == null || o != null) && DoMatch (o, match); |
|
|
|
return (other == null || o != null) && DoMatch (o, match); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) |
|
|
|
bool NRefactory.PatternMatching.INode.DoMatchCollection (Role role, NRefactory.PatternMatching.INode pos, NRefactory.PatternMatching.Match match, NRefactory.PatternMatching.BacktrackingInfo backtrackingInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
AstNode o = pos as AstNode; |
|
|
|
AstNode o = pos as AstNode; |
|
|
|
return (pos == null || o != null) && DoMatch (o, match); |
|
|
|
return (pos == null || o != null) && DoMatch (o, match); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PatternMatching.INode PatternMatching.INode.NextSibling { |
|
|
|
NRefactory.PatternMatching.INode NRefactory.PatternMatching.INode.NextSibling { |
|
|
|
get { return nextSibling; } |
|
|
|
get { return nextSibling; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PatternMatching.INode PatternMatching.INode.FirstChild { |
|
|
|
NRefactory.PatternMatching.INode NRefactory.PatternMatching.INode.FirstChild { |
|
|
|
get { return firstChild; } |
|
|
|
get { return firstChild; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|