Permalink
Browse files

Worked on unit tests.

  • Loading branch information...
1 parent 51986c4 commit ff2a11b00a54506f146f1aa7100e907ceede235d @mkrueger mkrueger committed Nov 29, 2011
@@ -708,7 +708,7 @@ static bool IsInSwitchContext (AstNode node)
void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Predicate<IType> typePred = null, Predicate<IMember> memberPred = null)
{
- var currentMember = this.currentMember;
+ var currentMember = ctx.CurrentMember;
if (currentType != null) {
for (var ct = currentType; ct != null; ct = ct.DeclaringTypeDefinition) {
foreach (var nestedType in ct.NestedTypes) {
@@ -721,7 +721,7 @@ void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state,
}
}
if (currentMember != null) {
- foreach (var member in currentType.Resolve (ctx).GetMembers ()) {
+ foreach (var member in ctx.CurrentTypeDefinition.GetMembers ()) {
if (memberPred == null || memberPred (member))
wrapper.AddMember (member);
}
@@ -730,18 +730,15 @@ void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state,
wrapper.AddTypeParameter (p);
}
}
- Console.WriteLine ("-----");
+
for (var n = state.CurrentUsingScope; n != null; n = n.Parent) {
- Console.WriteLine ("n:" + n.Namespace.FullName);
foreach (var pair in n.UsingAliases) {
wrapper.AddNamespace (pair.Key);
}
foreach (var u in n.Usings) {
- Console.WriteLine ("u:" + u.FullName + "/" + u.Types.Count ());
foreach (var type in u.Types) {
if (typePred == null || typePred (type)) {
string name = type.Name;
- Console.WriteLine ("2" + name);
if (node is Attribute && name.EndsWith ("Attribute") && name.Length > "Attribute".Length)
name = name.Substring (0, name.Length - "Attribute".Length);
wrapper.AddType (type, name);
@@ -750,10 +747,8 @@ void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state,
}
foreach (var type in n.Namespace.Types) {
- Console.WriteLine (type.Name);
- if (typePred == null || typePred (type)) {
+ if (typePred == null || typePred (type))
wrapper.AddType (type, type.Name);
- }
}
foreach (var curNs in n.Namespace.ChildNamespaces) {
@@ -1558,6 +1553,7 @@ IEnumerable<ICompletionData> CreateCompletionData (TextLocation location, Resolv
// Console.WriteLine ("IS PROT ALLOWED:" + isProtectedAllowed);
// Console.WriteLine (resolveResult);
// Console.WriteLine (currentMember != null ? currentMember.IsStatic : "currentMember == null");
+
if (resolvedNode.Annotation<ObjectCreateExpression> () == null) { //tags the created expression as part of an object create expression.
foreach (var member in type.GetMembers ()) {
if (!lookup.IsAccessible (member, isProtectedAllowed)) {
@@ -228,10 +228,11 @@ static CompletionDataList CreateProvider (string text, bool isCtrlSpace)
rctx = rctx.WithUsingScope (parsedFile.GetUsingScope (loc).Resolve (cmp));
var curDef = parsedFile.GetInnermostTypeDefinition (loc);
if (curDef != null) {
- rctx = rctx.WithCurrentTypeDefinition (curDef.Resolve (rctx).GetDefinition ());
- var curMember = parsedFile.GetMember (loc);
+ var resolvedDef = curDef.Resolve (rctx).GetDefinition ();
+ rctx = rctx.WithCurrentTypeDefinition (resolvedDef);
+ var curMember = resolvedDef.Members.FirstOrDefault (m => m.Region.Begin <= loc && loc < m.BodyRegion.End);
if (curMember != null)
- rctx = rctx.WithCurrentMember (curMember.CreateResolved (rctx));
+ rctx = rctx.WithCurrentMember (curMember);
}
engine.ctx = rctx;
@@ -614,10 +615,11 @@ public void TestMethod ()
}
}");
Assert.IsNotNull (provider, "provider not found.");
- Assert.AreEqual (6, provider.Count);
CodeCompletionBugTests.CheckObjectMembers (provider); // 4 from System.Object
Assert.IsNotNull (provider.Find ("A"), "field 'A' not found.");
Assert.IsNotNull (provider.Find ("B"), "field 'B' not found.");
+ Assert.IsNull (provider.Find ("C"), "field 'C' found, but shouldn't.");
+ Assert.IsNull (provider.Find ("D"), "field 'D' found, but shouldn't.");
}
/// <summary>

0 comments on commit ff2a11b

Please sign in to comment.