Permalink
Browse files

Fixed unit test.

  • Loading branch information...
1 parent 98ad3ba commit 5d614c052d6d3b0f8b9cb599257817347ddc39f9 @mkrueger mkrueger committed Oct 24, 2011
Showing with 25 additions and 3 deletions.
  1. +25 −3 ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
View
28 ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
@@ -267,7 +267,7 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
if (resolveResult == null)
return null;
- if (resolveResult.Item1.Type.IsEnum ()) {
+ if (resolveResult.Item1.Type.Kind == TypeKind.Enum) {
var wrapper = new CompletionDataWrapper (this);
AddContextCompletion (wrapper, resolveResult.Item2, expressionOrVariableDeclaration.Item2);
AddEnumMembers (wrapper, resolveResult.Item1.Type, resolveResult.Item2);
@@ -604,8 +604,8 @@ IEnumerable<ICompletionData> HandleKeywordCompletion (int wordStart, string word
var wrapper = new CompletionDataWrapper (this);
AddTypesAndNamespaces (wrapper, GetState (), t => false);
return wrapper.Result;
-// case "case":
-// return CreateCaseCompletionData (location, result);
+ case "case":
+ return CreateCaseCompletionData (location);
// case ",":
// case ":":
// if (result.ExpressionContext == ExpressionContext.InheritableType) {
@@ -1377,6 +1377,28 @@ void AddExtensionMethods (CompletionDataWrapper result, Conversions conv, List<I
}
}
}
+ IEnumerable<ICompletionData> CreateCaseCompletionData (TextLocation location)
+ {
+ var unit = ParseStub ("a: break;");
+ if (unit == null)
+ return null;
+ var s = unit.GetNodeAt<SwitchStatement> (location);
+ if (s == null)
+ return null;
+
+ var offset = document.GetOffset (s.Expression.StartLocation);
+ var expr = GetExpressionAt (offset);
+ if (expr == null)
+ return null;
+
+ var resolveResult = ResolveExpression (expr.Item1, expr.Item2, expr.Item3);
+ if (resolveResult == null || resolveResult.Item1.Type.Kind != TypeKind.Enum)
+ return null;
+ var wrapper = new CompletionDataWrapper (this);
+ AddEnumMembers (wrapper, resolveResult.Item1.Type, resolveResult.Item2);
+ AutoCompleteEmptyMatch = false;
+ return wrapper.Result;
+ }
#region Parsing methods

0 comments on commit 5d614c0

Please sign in to comment.