Browse Source

VB code completion: fix bug that caused code completion to omit local variables when typing near the end of a block.

http://community.sharpdevelop.net/forums/t/16643.aspx
The VB parser was using the end of the last statement as the EndLocation for the block. This made local variables
declared in that block unavailable when typing another statement at the end of the block.
We now use the location of the 'End' or 'Next' token instead.
pull/39/merge
Daniel Grunwald 13 years ago
parent
commit
a457ec6278
  1. 16
      src/AddIns/BackendBindings/VBNetBinding/Test/CodeCompletionTests.cs
  2. 652
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  3. 4
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

16
src/AddIns/BackendBindings/VBNetBinding/Test/CodeCompletionTests.cs

@ -119,5 +119,21 @@ End Module"; @@ -119,5 +119,21 @@ End Module";
TestCtrlSpace(text, true, list => Assert.IsFalse(list.Items.Any(i => i.Text == "InnerException")));
}
[Test]
public void TestLocalVariablesAvailableAtEndOfForLoop()
{
string text = @"Module Test
Public Sub f()
Dim cheeses = { ""cheddar"", ""brie"", ""edam"" }
For Each cheese As String In cheeses
Dim gouda = ""is tasty""
|
Next
End Sub
End Module";
TestKeyPress(text, 'g', CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion, list => Assert.IsTrue(list.Items.Any(i => i.Text == "gouda")));
}
}
}

652
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

4
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -3014,7 +3014,9 @@ Block<out Statement stmt> @@ -3014,7 +3014,9 @@ Block<out Statement stmt>
}
(.
stmt = blockStmt;
if (t != null) blockStmt.EndLocation = t.EndLocation;
// Use start of 'End'/'Next' keyword, not the end of the previous statement
// this is necessary to have local variables available for code completion (CodeCompletionTests.TestLocalVariablesAvailableAtEndOfForLoop)
if (la != null) blockStmt.EndLocation = la.Location;
BlockEnd();
.)
.

Loading…
Cancel
Save