Browse Source

Add consistency check that mutates the AST and checks if pattern matching finds the difference.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
33c882d4a3
  1. 2
      ICSharpCode.NRefactory.CSharp/Ast/SyntaxTree.cs
  2. 1
      ICSharpCode.NRefactory.ConsistencyCheck/CSharpFile.cs
  3. 1
      ICSharpCode.NRefactory.ConsistencyCheck/ICSharpCode.NRefactory.ConsistencyCheck.csproj
  4. 1
      ICSharpCode.NRefactory.ConsistencyCheck/Program.cs

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

@ -132,7 +132,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -132,7 +132,7 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SyntaxTree o = other as SyntaxTree;
return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match);
return o != null && this.Members.DoMatch(o.Members, match);
}
public override void AcceptVisitor (IAstVisitor visitor)

1
ICSharpCode.NRefactory.ConsistencyCheck/CSharpFile.cs

@ -50,6 +50,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck @@ -50,6 +50,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck
// Keep the original text around; we might use it for a refactoring later
this.OriginalText = File.ReadAllText(fileName);
this.SyntaxTree = p.Parse(this.OriginalText, fileName);
this.SyntaxTree.Freeze(); // the various tests shouldn't modify the AST shared by all tests
if (p.HasErrors) {
Console.WriteLine("Error parsing " + fileName + ":");

1
ICSharpCode.NRefactory.ConsistencyCheck/ICSharpCode.NRefactory.ConsistencyCheck.csproj

@ -74,6 +74,7 @@ @@ -74,6 +74,7 @@
<Compile Include="CSharpFile.cs" />
<Compile Include="CSharpProject.cs" />
<Compile Include="FindReferencesConsistencyCheck.cs" />
<Compile Include="PatternMatchingTest.cs" />
<Compile Include="TypeSystemTests.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

1
ICSharpCode.NRefactory.ConsistencyCheck/Program.cs

@ -66,6 +66,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck @@ -66,6 +66,7 @@ namespace ICSharpCode.NRefactory.ConsistencyCheck
RunTestOnAllFiles("Resolver test (no parsed file)", ResolverTest.RunTestWithoutUnresolvedFile);
RunTestOnAllFiles("Resolver test (randomized order)", RandomizedOrderResolverTest.RunTest);
new FindReferencesConsistencyCheck(solution).Run();
RunTestOnAllFiles("Pattern Matching test", PatternMatchingTest.RunTest);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);

Loading…
Cancel
Save