Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Re-enable resolver unit tests that failed due to the parser returning…

… incorrect positions.

Fixed a bug that caused array initializers to fail to resolve when the parent variable initializer was not being resolved.
  • Loading branch information...
commit b7fcc55308c1f332384790ed0a4c382add03f1ce 1 parent 25176ef
@dgrunwald dgrunwald authored
View
4 ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
@@ -444,9 +444,9 @@ public AstNode Clone ()
public abstract S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T));
#region Pattern Matching
- protected static bool MatchString (string name1, string name2)
+ protected static bool MatchString (string pattern, string text)
{
- return string.IsNullOrEmpty (name1) || name1 == name2;
+ return PatternMatching.Pattern.MatchString(pattern, text);
}
protected internal abstract bool DoMatch (AstNode other, PatternMatching.Match match);
View
2  ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs
@@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp
public class TypeParameterDeclaration : AstNode
{
public static readonly Role<AttributeSection> AttributeRole = AttributedNode.AttributeRole;
- public static readonly Role<CSharpTokenNode> VarianceRole = new Role<CSharpTokenNode>("Variance");
+ public static readonly Role<CSharpTokenNode> VarianceRole = new Role<CSharpTokenNode>("Variance", CSharpTokenNode.Null);
public override NodeType NodeType {
get { return NodeType.Unknown; }
View
4 ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
@@ -604,7 +604,8 @@ ResolveResult VisitFieldOrEventDeclaration(AttributedNode fieldOrEventDeclaratio
ResolveResult IAstVisitor<object, ResolveResult>.VisitVariableInitializer(VariableInitializer variableInitializer, object data)
{
- if (resolverEnabled) {
+ ArrayInitializerExpression aie = variableInitializer.Initializer as ArrayInitializerExpression;
+ if (resolverEnabled || aie != null) {
ResolveResult result = errorResult;
if (variableInitializer.Parent is FieldDeclaration || variableInitializer.Parent is EventDeclaration) {
if (resolver.CurrentMember != null) {
@@ -620,7 +621,6 @@ ResolveResult VisitFieldOrEventDeclaration(AttributedNode fieldOrEventDeclaratio
}
}
}
- ArrayInitializerExpression aie = variableInitializer.Initializer as ArrayInitializerExpression;
ArrayType arrayType = result.Type as ArrayType;
if (aie != null && arrayType != null) {
StoreState(aie, resolver.Clone());
View
1  ICSharpCode.NRefactory.Tests/CSharp/Resolver/ArrayCreateTests.cs
@@ -23,7 +23,6 @@
namespace ICSharpCode.NRefactory.CSharp.Resolver
{
[TestFixture]
- [Ignore("Parser produces incorrect positions")]
public class ArrayCreateTests : ResolverTestBase
{
[Test]
View
2  ICSharpCode.NRefactory.Tests/CSharp/Resolver/LambdaTests.cs
@@ -145,7 +145,7 @@ class TestClass {
Assert.AreEqual("System.Int32", lrr.Type.ReflectionName);
}
- [Test, Ignore("Fails due to parser problem")]
+ [Test]
public void LambdaInInferred2DArrayInitializer()
{
string program = @"using System;
View
2  ICSharpCode.NRefactory.Tests/CSharp/Resolver/NameLookupTests.cs
@@ -848,7 +848,7 @@ class B
Assert.AreEqual("B.x", mrr.Member.FullName);
}
- [Test, Ignore("Parser produces incorrect positions")]
+ [Test]
public void SubstituteClassAndMethodTypeParametersAtOnce()
{
string program = @"class C<X> { static void M<T>(X a, T b) { $C<T>.M<X>$(b, a); } }";
View
8 ICSharpCode.NRefactory.Tests/CSharp/Resolver/ObjectCreationTests.cs
@@ -111,7 +111,7 @@ public void DefaultCTorOverloadLookupTest()
Assert.AreEqual(0, result.Member.Parameters.Count);
}
- [Test, Ignore("Parser returns incorrect positions")]
+ [Test]
public void ChainedConstructorCall()
{
string program = @"using System;
@@ -133,13 +133,13 @@ public C()
{}
}
";
- InvocationResolveResult mrr = Resolve<InvocationResolveResult>(program.Replace("base(b)", "$base(b)$"));
+ InvocationResolveResult mrr = Resolve<CSharpInvocationResolveResult>(program.Replace("base(b)", "$base(b)$"));
Assert.AreEqual("A..ctor", mrr.Member.FullName);
- mrr = Resolve<InvocationResolveResult>(program.Replace("base(c)", "$base(c)$"));
+ mrr = Resolve<CSharpInvocationResolveResult>(program.Replace("base(c)", "$base(c)$"));
Assert.AreEqual("B..ctor", mrr.Member.FullName);
- mrr = Resolve<InvocationResolveResult>(program.Replace("this(0)", "$this(0)$"));
+ mrr = Resolve<CSharpInvocationResolveResult>(program.Replace("this(0)", "$this(0)$"));
Assert.AreEqual("C..ctor", mrr.Member.FullName);
}
View
4 ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolveAtLocationTests.cs
@@ -68,10 +68,10 @@ class A { void M() {
Assert.AreEqual("System.Int32", rr.Type.FullName);
}
- [Test, Ignore("Parser returns incorrect positions")]
+ [Test]
public void BaseCtorCall()
{
- var rr = ResolveAtLocation<InvocationResolveResult>(@"using System;
+ var rr = ResolveAtLocation<CSharpInvocationResolveResult>(@"using System;
class A { public A() : ba$se() {} }");
Assert.AreEqual("System.Object..ctor", rr.Member.FullName);
}
View
11 ICSharpCode.NRefactory/PatternMatching/Pattern.cs
@@ -28,6 +28,17 @@ namespace ICSharpCode.NRefactory.PatternMatching
/// </summary>
public abstract class Pattern : INode
{
+ /// <summary>
+ /// Gets the string that matches any string.
+ /// </summary>
+ public static readonly string AnyString = string.Empty;
+ // TODO: use something other than string.Empty so that 'no value' and 'any value' can be distinguished
+
+ public static bool MatchString(string pattern, string text)
+ {
+ return string.IsNullOrEmpty(pattern) || pattern == text;
+ }
+
internal struct PossibleMatch
{
public readonly INode NextOther; // next node after the last matched node
Please sign in to comment.
Something went wrong with that request. Please try again.