diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index dcecc63840..41cc072f6f 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -498,7 +498,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return contextList.Result; } - Console.WriteLine ("blub"); return DefaultControlSpaceItems (); } if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) { @@ -611,7 +610,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (cu == null) return null; var member = cu.GetNodeAt (location); - Print (cu); if (member != null && member.NameToken.EndLocation < location) return DefaultControlSpaceItems (); return null; @@ -1780,20 +1778,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return Tuple.Create (CSharpParsedFile, (AstNode)target, Unit); } } - - if (currentMember == null && currentType == null) { + if (currentMember == null && currentType == null) return null; - } - baseUnit = ParseStub ("a()"); + baseUnit = ParseStub ("a()"); + var curNode = baseUnit.GetNodeAt (location); // Hack for handle object initializer continuation expressions - if (baseUnit.GetNodeAt (location) is AttributedNode || baseUnit.GetNodeAt (location) == null) { + if (curNode is AttributedNode || baseUnit.GetNodeAt (location) == null) { baseUnit = ParseStub ("a()};"); } var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; var mref = baseUnit.GetNodeAt (location); - Print (baseUnit); if (mref == null) { var invoke = baseUnit.GetNodeAt (location); if (invoke != null) @@ -1805,13 +1801,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion mref.Parent.ReplaceWith (expr); } else { Expression tref = baseUnit.GetNodeAt (location); - var memberType = tref != null ? ((TypeReferenceExpression)tref).Type as MemberType : null; + MemberType memberType = tref != null ? ((TypeReferenceExpression)tref).Type as MemberType : null; if (memberType == null) { memberType = baseUnit.GetNodeAt (location); if (memberType != null) { tref = baseUnit.GetNodeAt (location); - if (tref == null) - return null; + if (tref == null) { + tref = new TypeReferenceExpression (memberType.Clone ()); + memberType.Parent.AddChild (tref, AstNode.Roles.Expression); + } } if (tref is ObjectCreateExpression) { expr = new TypeReferenceExpression (memberType.Target.Clone ()); diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs index 078b63d069..c492da0eec 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs @@ -4008,5 +4008,20 @@ public class TestMe Assert.IsNotNull (provider.Find ("classParameter"), "'classParameter' not found."); Assert.IsNotNull (provider.Find ("parameter"), "'parameter' not found."); } + + [Test()] + public void TestParameterTypeNameContext () + { + CombinedProviderTest ( +@"class Program +{ + public Program ($System.$) + { + } +}", provider => { + Assert.IsNotNull (provider.Find ("Object"), "'Object' not found."); + }); + } + } }