Browse Source

Fixed for context completion.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
7befa599aa
  1. 6
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  2. 23
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

6
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs

@ -426,6 +426,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -426,6 +426,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
var contextList = new CompletionDataWrapper (this);
var identifierStart = GetExpressionAtCursor ();
if (identifierStart != null && identifierStart.Item2 is TypeParameterDeclaration)
return null;
@ -1957,7 +1958,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -1957,7 +1958,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
}
if (expr == null) {
var forStmt = tmpUnit.GetNodeAt<ForStatement> (location.Line, location.Column - 3);
var block = tmpUnit.GetNodeAt<BlockStatement> (location);
var node = block != null ? block.Statements.LastOrDefault () : null;
var forStmt = node != null ? node.PrevSibling as ForStatement : null;
if (forStmt != null && forStmt.EmbeddedStatement.IsNull) {
expr = forStmt;
var id = new IdentifierExpression ("stub");

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

@ -1632,6 +1632,29 @@ class A @@ -1632,6 +1632,29 @@ class A
});
}
/// <summary>
/// Bug 2788 - Locals do not show up inside the 'for' statement context
/// </summary>
[Test()]
public void TestBug2788 ()
{
CombinedProviderTest (
@"
class A
{
public void Test()
{
var foo = new byte[100];
$for (int i = 0; i < f$
}
}
", provider => {
Assert.IsNotNull (provider.Find ("foo"), "'foo' not found.");
Assert.IsNotNull (provider.Find ("i"), "'i' not found.");
});
}
[Test()]
public void TestNewInConstructor ()
{

Loading…
Cancel
Save