Permalink
Browse files

Fixed some unit tests.

  • Loading branch information...
1 parent a81096d commit 6d4a8250842fd44c554789da473dea290817e42d @mkrueger mkrueger committed Oct 24, 2011
@@ -161,7 +161,7 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
return null;
var methodGroup = invocationResult.Item1 as MethodGroupResolveResult;
if (methodGroup != null)
- return CreateParameterCompletion (methodGroup, invocationResult.Item2, invoke.Item2, 0);
+ return CreateParameterCompletion (methodGroup, invocationResult.Item2, invoke.Item2, 0, controlSpace);
return null;
case ',':
int cpos2;
@@ -183,7 +183,7 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
// check propose name, for context <variable name> <ctrl+space> (but only in control space context)
IType isAsType = null;
var isAsExpression = GetExpressionAt (offset);
- if (controlSpace && isAsExpression != null && isAsExpression.Item2 is VariableDeclarationStatement) {
+ if (controlSpace && isAsExpression != null && isAsExpression.Item2 is VariableDeclarationStatement && token != "new") {
var parent = isAsExpression.Item2 as VariableDeclarationStatement;
int offset1 = document.GetOffset (parent.Type.StartLocation);
int offset2 = document.GetOffset (parent.Type.EndLocation);
@@ -217,7 +217,6 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
AutoCompleteEmptyMatch = false;
return proposeNameList.Result;
}
-
// int tokenIndex = offset;
// string token = GetPreviousToken (ref tokenIndex, false);
// if (result.ExpressionContext == ExpressionContext.ObjectInitializer) {
@@ -252,7 +251,7 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
return null;
methodGroup = invocationResult.Item1 as MethodGroupResolveResult;
if (methodGroup != null)
- return CreateParameterCompletion (methodGroup, invocationResult.Item2, invoke.Item2, currentParameter);
+ return CreateParameterCompletion (methodGroup, invocationResult.Item2, invoke.Item2, currentParameter, controlSpace);
return null;
case "=":
case "==":
@@ -918,7 +917,7 @@ IEnumerable<ICompletionData> CreateTypeCompletionData (IType hintType)
DefaultCompletionString = GetShortType (hintType, GetState ());
wrapper.AddType (hintType, DefaultCompletionString);
}
- AddTypesAndNamespaces (wrapper, state, pred);
+ AddTypesAndNamespaces (wrapper, state, pred, m => false);
AddKeywords (wrapper, primitiveTypesKeywords.Where (k => k != "void"));
AutoCompleteEmptyMatch = true;
return wrapper.Result;
@@ -946,7 +945,6 @@ IEnumerable<ICompletionData> GetOverrideCompletionData (ITypeDefinition type, st
return null; // don't add override completion for static members
}
}
-
foreach (var baseType in type.GetAllBaseTypeDefinitions (ctx)) {
AddVirtuals (alreadyInserted, wrapper, type, modifiers, baseType, declarationBegin);
addedVirtuals = true;
@@ -963,7 +961,6 @@ void AddVirtuals (Dictionary<string, bool> alreadyInserted, CompletionDataWrappe
foreach (var m in curType.Methods.Where (m => !m.IsConstructor && !m.IsDestructor).Cast<IMember> ().Concat (curType.Properties.Cast<IMember> ())) {
if (m.IsSynthetic || curType.Kind != TypeKind.Interface && !(m.IsVirtual || m.IsOverride || m.IsAbstract))
continue;
-
// filter out the "Finalize" methods, because finalizers should be done with destructors.
if (m is IMethod && m.Name == "Finalize")
continue;
@@ -972,7 +969,6 @@ void AddVirtuals (Dictionary<string, bool> alreadyInserted, CompletionDataWrappe
string text = m.ReflectionName; //TODO:correct ?
// check if the member is already implemented
bool foundMember = type.Members.Any (cm => cm.ReflectionName /*amb.GetString (ctx, cm, OutputFlags.ClassBrowserEntries)*/ == text);
-
if (!foundMember && !alreadyInserted.ContainsKey (text)) {
alreadyInserted [text] = true;
data.CompletionCategory = col.GetCompletionCategory (curType);
@@ -1172,7 +1168,7 @@ public ITypeDefinition GetTypeFromContext (ITypeDefinition type)
return result;
}
- IEnumerable<ICompletionData> CreateParameterCompletion (MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, int parameter)
+ IEnumerable<ICompletionData> CreateParameterCompletion (MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, int parameter, bool controlSpace)
{
var result = new CompletionDataWrapper (this);
var addedEnums = new HashSet<string> ();
@@ -1197,10 +1193,12 @@ IEnumerable<ICompletionData> CreateParameterCompletion (MethodGroupResolveResult
}
}
- if (addedEnums.Count + addedDelegates.Count == 0)
- return Enumerable.Empty<ICompletionData> ();
- AutoCompleteEmptyMatch = false;
- AutoSelect = false;
+ if (!controlSpace) {
+ if (addedEnums.Count + addedDelegates.Count == 0)
+ return Enumerable.Empty<ICompletionData> ();
+ AutoCompleteEmptyMatch = false;
+ AutoSelect = false;
+ }
AddContextCompletion (result, state, invocation);
// resolver.AddAccessibleCodeCompletionData (ExpressionContext.MethodBody, cdc);
@@ -1290,7 +1288,7 @@ IEnumerable<ICompletionData> CreateCompletionData (TextLocation location, Resolv
// Console.WriteLine ("type:" + type +"/"+type.GetType ());
// Console.WriteLine ("IS PROT ALLOWED:" + isProtectedAllowed);
// Console.WriteLine (resolveResult);
-// Console.WriteLine (currentMember.IsStatic);
+// Console.WriteLine (currentMember != null ? currentMember.IsStatic : "currentMember == null");
foreach (var member in type.GetMembers (ctx)) {
if (!lookup.IsAccessible (member, isProtectedAllowed)) {
// Console.WriteLine ("skip access: " + member.FullName);
@@ -3085,7 +3085,11 @@ public void Foo ()
");
Assert.IsNotNull (provider, "provider not found.");
Assert.IsNull (provider.Find ("Foo"), "method 'Foo' found.");
- provider = CreateCtrlSpaceProvider (
+ }
+
+ public void TestBug669285B ()
+ {
+ var provider = CreateCtrlSpaceProvider (
@"static class Ext
{
public static void Foo<T> (this T[] t)
@@ -3322,7 +3326,7 @@ public static void Main (string[] args)
}
}
}");
- Assert.IsNotNull (provider.Find ("Foo1"), "method 'Foo1' not found.");
+ Assert.IsNotNull (provider.Find ("Foo2"), "method 'Foo2' not found.");
}
/// <summary>

0 comments on commit 6d4a825

Please sign in to comment.