Browse Source

Fixed completion bug.

newNRvisualizers
Mike Krüger 13 years ago
parent
commit
4b3bb7e8a7
  1. 6
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 34
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

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

@ -780,7 +780,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -780,7 +780,7 @@ namespace ICSharpCode.NRefactory.CSharp
newField.AddChild (variable, FixedFieldDeclaration.VariableRole);
}
}
if (location != null)
if (location != null && location.Count > 1)
newField.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon);
typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole);
@ -820,8 +820,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -820,8 +820,8 @@ namespace ICSharpCode.NRefactory.CSharp
newField.AddChild (variable, Roles.Variable);
}
}
if (location != null)
newField.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1])), Roles.Semicolon);
if (location != null && location.Count > 1)
newField.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon);
typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole);
}

34
ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

@ -5212,5 +5212,39 @@ public class TestFoo @@ -5212,5 +5212,39 @@ public class TestFoo
Assert.IsNull(provider.Find("split_char"), "'split_char' found.");
}
/// <summary>
/// Bug 4961 - Code completion for enumerations in static classes doesn't work.
/// </summary>
[Test()]
public void TestBug4961()
{
CombinedProviderTest(
@"using System;
using System.Collections.Generic;
namespace EnumerationProblem
{
public enum Options
{
GiveCompletion,
IwouldLoveIt,
}
static class Converter
{
private static Dictionary<Options, string> options = new Dictionary<Options, string> ()
{
${ Options.$
};
}
}
", provider => {
Assert.IsNotNull(provider.Find("GiveCompletion"));
Assert.IsNotNull(provider.Find("IwouldLoveIt"));
});
}
}
}

Loading…
Cancel
Save