Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: icsharpcode/NRefactory
base: 99de4e1221
...
head fork: icsharpcode/NRefactory
compare: 40b8ce58d2
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
33 ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
@@ -48,7 +48,7 @@ public class CSharpCompletionEngine : CSharpCompletionEngineBase
public string EolMarker { get; set; }
public string IndentString { get; set; }
-#endregion
+ #endregion
#region Result properties
public bool AutoCompleteEmptyMatch;
@@ -2014,34 +2014,47 @@ string AddDelegateHandlers(CompletionDataWrapper completionList, IType delegateT
"delegate",
"Creates anonymous delegate.",
"delegate {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString
- );
+ );
}
var sb = new StringBuilder("(");
var sbWithoutTypes = new StringBuilder("(");
+ var state = GetState();
+ var builder = new TypeSystemAstBuilder(state);
+
for (int k = 0; k < delegateMethod.Parameters.Count; k++) {
if (k > 0) {
sb.Append(", ");
sbWithoutTypes.Append(", ");
}
- var parameterType = delegateMethod.Parameters [k].Type;
- sb.Append(GetShortType(parameterType, GetState()));
- sb.Append(" ");
- sb.Append(delegateMethod.Parameters [k].Name);
+ var convertedParameter = builder.ConvertParameter (delegateMethod.Parameters [k]);
+ if (convertedParameter.ParameterModifier == ParameterModifier.Params)
+ convertedParameter.ParameterModifier = ParameterModifier.None;
+ sb.Append(convertedParameter.GetText (FormattingPolicy));
sbWithoutTypes.Append(delegateMethod.Parameters [k].Name);
}
+
sb.Append(")");
sbWithoutTypes.Append(")");
completionList.AddCustom(
"delegate" + sb,
"Creates anonymous delegate.",
"delegate" + sb + " {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString
- );
- if (!completionList.Result.Any(data => data.DisplayText == sbWithoutTypes.ToString())) {
+ );
+
+ if (!completionList.Result.Any(data => data.DisplayText == sb.ToString())) {
+ completionList.AddCustom(
+ sb.ToString(),
+ "Creates typed lambda expression.",
+ sb + " => |" + (addSemicolon ? ";" : "")
+ );
+ }
+
+ if (!delegateMethod.Parameters.Any (p => p.IsOut || p.IsRef) && !completionList.Result.Any(data => data.DisplayText == sbWithoutTypes.ToString())) {
completionList.AddCustom(
sbWithoutTypes.ToString(),
"Creates lambda expression.",
sbWithoutTypes + " => |" + (addSemicolon ? ";" : "")
- );
+ );
}
/* TODO:Make factory method out of it.
// It's needed to temporarly disable inserting auto matching bracket because the anonymous delegates are selectable with '('
@@ -2055,7 +2068,7 @@ string AddDelegateHandlers(CompletionDataWrapper completionList, IType delegateT
}*/
return sb.ToString();
}
-
+
bool IsAccessibleFrom(IEntity member, ITypeDefinition calledType, IMember currentMember, bool includeProtected)
{
if (currentMember == null) {
View
11 ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/RedundantThisIssue.cs
@@ -45,11 +45,20 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
IssueMarker = IssueMarker.GrayOut)]
public class RedundantThisIssue : ICodeIssueProvider
{
+ bool ignoreConstructors = true;
+
/// <summary>
/// Specifies whether to ignore redundant 'this' in constructors.
/// "this.Name = name;"
/// </summary>
- public bool IgnoreConstructors = true;
+ public bool IgnoreConstructors {
+ get {
+ return ignoreConstructors;
+ }
+ set {
+ ignoreConstructors = value;
+ }
+ }
public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
{
View
24 ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/DelegateContextTests.cs
@@ -97,6 +97,30 @@ void TestFoo()
Assert.IsNotNull(provider.Find("(arg1, arg2)"));
});
}
+
+
+ [Test()]
+ public void TestRefOutParams()
+ {
+ CodeCompletionBugTests.CombinedProviderTest(
+ @"using System;
+public delegate void FooBar (out int foo, ref int bar, params object[] additional);
+
+public class Test
+{
+ FooBar foo;
+
+ void TestFoo()
+ {
+ $foo = d$
+ }
+}
+", provider => {
+ Assert.IsFalse(provider.AutoSelect);
+ Assert.IsNotNull(provider.Find("(out int foo, ref int bar, object[] additional)"));
+ Assert.IsNull(provider.Find("(foo, bar, additional)"));
+ });
+ }
}
}

No commit comments for this range

Something went wrong with that request. Please try again.