Browse Source

Fixed completion test case.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
850776fabc
  1. 11
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs
  2. 19
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

11
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs

@ -98,7 +98,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -98,7 +98,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
return currentType;
}
bool IsInsideType (IUnresolvedTypeDefinition currentType, TextLocation location)
bool IsInsideType (IUnresolvedEntity currentType, TextLocation location)
{
int startOffset = document.GetOffset (currentType.Region.Begin);
int endOffset = document.GetOffset (location);
@ -175,6 +175,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -175,6 +175,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (!IsInsideType (currentType, location))
currentType = null;
}
this.currentMember = null;
if (this.currentType != null) {
foreach (var member in currentType.Members) {
@ -182,6 +183,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -182,6 +183,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
currentMember = member;
}
}
// location is beyond last reported end region, now we need to check, if the end region changed
// NOTE: Enums are a special case, there the "last" field needs to be treated as current member
if (currentMember != null && currentMember.Region.End < location && currentType.Kind != TypeKind.Enum) {
if (!IsInsideType (currentMember, location))
currentMember = null;
}
var stack = GetBracketStack (GetMemberTextToCaret ().Item1);
if (stack.Count == 0)
currentMember = null;

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

@ -4035,7 +4035,24 @@ public class TestMe @@ -4035,7 +4035,24 @@ public class TestMe
});
}
[Test()]
public void TestMethodNameContext ()
{
CompletionDataList provider = CreateProvider (
@"using System;
namespace Test
{
class Program
{
void SomeMethod ()
{
}
$public void T$
}
}");
Assert.IsTrue (provider == null || provider.Count == 0, "provider should be empty.");
}
}
}

Loading…
Cancel
Save