Browse Source

Improved get/set keyword handling.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
37798b0eba
  1. 7
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  2. 15
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/KeywordTests.cs

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

@ -432,7 +432,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (identifierStart == null && !string.IsNullOrEmpty (token) && !(IsInsideComment (tokenIndex) || IsInsideString (tokenIndex))) { if (identifierStart == null && !string.IsNullOrEmpty (token) && !(IsInsideComment (tokenIndex) || IsInsideString (tokenIndex))) {
char last = token [token.Length - 1]; char last = token [token.Length - 1];
if (char.IsLetterOrDigit (last) || last == '_' || token == ">") { if (char.IsLetterOrDigit (last) || last == '_' || token == ">") {
return controlSpace ? DefaultControlSpaceItems () : null; return HandleKeywordCompletion (tokenIndex, token);
//return controlSpace ? DefaultControlSpaceItems () : null;
} }
} }
if (identifierStart == null) if (identifierStart == null)
@ -935,6 +937,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
case "internal": case "internal":
case "sealed": case "sealed":
case "static": case "static":
var accessorContext = HandleAccessorContext ();
if (accessorContext != null)
return accessorContext;
wrapper = new CompletionDataWrapper (this); wrapper = new CompletionDataWrapper (this);
var state = GetState (); var state = GetState ();
AddTypesAndNamespaces (wrapper, state, null, null, m => false); AddTypesAndNamespaces (wrapper, state, null, null, m => false);

15
ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/KeywordTests.cs

@ -129,6 +129,21 @@ class Test
}); });
} }
[Test()]
public void GetSetKeywordTestAfterModifier ()
{
CodeCompletionBugTests.CombinedProviderTest (
@"class Test
{
public int MyProperty {
internal $g$
}
", provider => {
Assert.IsNotNull (provider.Find ("get"), "keyword 'get' not found.");
Assert.IsNotNull (provider.Find ("set"), "keyword 'set' not found.");
});
}
[Test()] [Test()]
public void AddRemoveKeywordTest () public void AddRemoveKeywordTest ()
{ {

Loading…
Cancel
Save