|
|
@ -886,7 +886,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
string parameterDefinition = AddDelegateHandlers( |
|
|
|
string parameterDefinition = AddDelegateHandlers( |
|
|
|
wrapper, |
|
|
|
wrapper, |
|
|
|
delegateType, |
|
|
|
delegateType, |
|
|
|
optDelegateName: GuessEventHandlerMethodName(curTokenIndex) |
|
|
|
optDelegateName: GuessEventHandlerMethodName(curTokenIndex, (currentType == null) ? null : currentType.Name) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2584,10 +2584,49 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public string GuessEventHandlerMethodName(int tokenIndex) |
|
|
|
public string GuessEventHandlerMethodName(int tokenIndex, string surroundingTypeName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
var names = new List<string>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string eventName = GetPreviousToken(ref tokenIndex, false); |
|
|
|
string result = GetPreviousToken(ref tokenIndex, false); |
|
|
|
string result = GetPreviousToken(ref tokenIndex, false); |
|
|
|
return "Handle" + result; |
|
|
|
if (result != ".") { |
|
|
|
|
|
|
|
if (surroundingTypeName == null) { |
|
|
|
|
|
|
|
eventName = "Handle" + eventName; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
names.Add(surroundingTypeName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
while (result == ".") { |
|
|
|
|
|
|
|
result = GetPreviousToken(ref tokenIndex, false); |
|
|
|
|
|
|
|
if (result == "this") { |
|
|
|
|
|
|
|
if (names.Count == 0) { |
|
|
|
|
|
|
|
if (surroundingTypeName == null) { |
|
|
|
|
|
|
|
eventName = "Handle" + eventName; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
names.Add(surroundingTypeName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (result != null) { |
|
|
|
|
|
|
|
string trimmedName = result.Trim(); |
|
|
|
|
|
|
|
if (trimmedName.Length == 0) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
names.Insert(0, trimmedName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result = GetPreviousToken(ref tokenIndex, false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(eventName)) { |
|
|
|
|
|
|
|
names.Add(eventName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result = String.Join("_", names.ToArray()); |
|
|
|
|
|
|
|
foreach (char ch in result) { |
|
|
|
|
|
|
|
if (!char.IsLetterOrDigit(ch) && ch != '_') { |
|
|
|
|
|
|
|
result = ""; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool MatchDelegate(IType delegateType, IMethod method) |
|
|
|
bool MatchDelegate(IType delegateType, IMethod method) |
|
|
|