Browse Source

[Completion] Fixed parameter completion for static methods.

newNRvisualizers
mike 14 years ago
parent
commit
7a03092fac
  1. 9
      ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs
  2. 4
      ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
  3. 34
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ParameterCompletionTests.cs

9
ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs

@ -113,18 +113,17 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -113,18 +113,17 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
IEnumerable<IMethod> CollectMethods(AstNode resolvedNode, MethodGroupResolveResult resolveResult)
{
// var lookup = new MemberLookup (ctx.CurrentTypeDefinition, Compilation.MainAssembly);
var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
bool onlyStatic = false;
if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic) {
if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic || resolveResult.TargetResult is TypeResolveResult) {
onlyStatic = true;
}
foreach (var method in resolveResult.Methods) {
if (method.IsConstructor) {
continue;
}
// if (!lookup.IsAccessible (member, true))
// continue;
if (!lookup.IsAccessible (method, true))
continue;
if (onlyStatic && !method.IsStatic) {
continue;
}

4
ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj

@ -390,8 +390,8 @@ @@ -390,8 +390,8 @@
<MonoDevelop>
<Properties>
<Policies>
<TextStylePolicy TabWidth="4" EolMarker="Unix" inheritsSet="Mono" inheritsScope="text/plain" scope="text/plain" />
<TextStylePolicy FileWidth="120" TabWidth="4" EolMarker="Unix" inheritsSet="Mono" inheritsScope="text/plain" scope="text/x-csharp" />
<TextStylePolicy TabsToSpaces="False" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
<TextStylePolicy FileWidth="120" TabsToSpaces="False" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
<CSharpFormattingPolicy IndentSwitchBody="True" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
<TextStylePolicy inheritsSet="null" scope="text/x-jay" />
</Policies>

34
ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ParameterCompletionTests.cs

@ -941,5 +941,39 @@ class TestClass @@ -941,5 +941,39 @@ class TestClass
");
Assert.IsTrue (provider == null || provider.Count == 0);
}
/// <summary>
/// Bug 4927 - [New Resolver] Autocomplete shows non-static methods when using class name
/// </summary>
[Test()]
public void TestBug4927 ()
{
IParameterDataProvider provider = CreateProvider (
@"
public class A
{
// static method
public static void Method(string someParameter, object anotherParameter)
{
}
// instance method
public void Method()
{
}
}
public class B
{
public static void Main()
{
$A.Method($
}
}
");
Assert.IsNotNull (provider, "provider was not created.");
Assert.AreEqual (1, provider.Count);
}
}
}
Loading…
Cancel
Save