static string GetText(ResolveResult result, string expression, out bool debuggerCanShowValue) { debuggerCanShowValue = false; if (result == null) { // when pressing control, show the expression even when it could not be resolved return((Control.ModifierKeys == Keys.Control) ? "" : null); } if (result is MixedResolveResult) { return(GetText(((MixedResolveResult)result).PrimaryResult, expression, out debuggerCanShowValue)); } else if (result is DelegateCallResolveResult) { return(GetText(((DelegateCallResolveResult)result).Target, expression, out debuggerCanShowValue)); } IAmbience ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.UseFullyQualifiedMemberNames; if (result is MemberResolveResult) { return(GetMemberText(ambience, ((MemberResolveResult)result).ResolvedMember, expression, out debuggerCanShowValue)); } else if (result is LocalResolveResult) { LocalResolveResult rr = (LocalResolveResult)result; ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedTypeNames | ConversionFlags.ShowReturnType | ConversionFlags.ShowDefinitionKeyWord; StringBuilder b = new StringBuilder(); if (rr.IsParameter) { b.Append(StringParser.Parse("${res:MainWindow.Editor.Tooltip.Parameter} ")); } else { b.Append(StringParser.Parse("${res:MainWindow.Editor.Tooltip.LocalVar} ")); } b.Append(ambience.Convert(rr.Field)); if (currentDebugger != null) { string currentValue = currentDebugger.GetValueAsString(rr.VariableName); if (currentValue != null) { debuggerCanShowValue = true; b.Append(" = "); if (currentValue.Length > 256) { currentValue = currentValue.Substring(0, 256) + "..."; } b.Append(currentValue); } } return(b.ToString()); } else if (result is NamespaceResolveResult) { return(StringParser.Parse("${res:MainWindow.Editor.Tooltip.Namespace} ") + ((NamespaceResolveResult)result).Name); } else if (result is TypeResolveResult) { IClass c = ((TypeResolveResult)result).ResolvedClass; if (c != null) { return(GetMemberText(ambience, c, expression, out debuggerCanShowValue)); } else { return(ambience.Convert(result.ResolvedType)); } } else if (result is MethodGroupResolveResult) { MethodGroupResolveResult mrr = result as MethodGroupResolveResult; IMethod m = mrr.GetMethodIfSingleOverload(); IMethod m2 = mrr.GetMethodWithEmptyParameterList(); if (m != null) { return(GetMemberText(ambience, m, expression, out debuggerCanShowValue)); } else if (ambience is VBNetAmbience && m2 != null) { return(GetMemberText(ambience, m2, expression, out debuggerCanShowValue)); } else { return(StringParser.Parse("${res:MainWindow.Editor.Tooltip.UnresolvedOverload} ") + ambience.Convert(mrr.ContainingType) + "." + mrr.Name); } } else { if (Control.ModifierKeys == Keys.Control) { if (result.ResolvedType != null) { return("expression of type " + ambience.Convert(result.ResolvedType)); } else { return("ResolveResult without ResolvedType"); } } else { return(null); } } }
static string GetText(ResolveResult result, string expression, out bool debuggerCanShowValue) { debuggerCanShowValue = false; if (result == null) { // when pressing control, show the expression even when it could not be resolved return((Control.ModifierKeys == Keys.Control) ? "" : null); } if (result is MixedResolveResult) { return(GetText(((MixedResolveResult)result).PrimaryResult, expression, out debuggerCanShowValue)); } IAmbience ambience = AmbienceService.CurrentAmbience; ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.ShowAccessibility; if (result is MemberResolveResult) { return(GetMemberText(ambience, ((MemberResolveResult)result).ResolvedMember, expression, out debuggerCanShowValue)); } else if (result is LocalResolveResult) { LocalResolveResult rr = (LocalResolveResult)result; ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedNames | ConversionFlags.ShowReturnType | ConversionFlags.QualifiedNamesOnlyForReturnTypes; StringBuilder b = new StringBuilder(); if (rr.IsParameter) { b.Append("parameter "); } else { b.Append("local variable "); } b.Append(ambience.Convert(rr.Field)); if (currentDebugger != null) { string currentValue = currentDebugger.GetValueAsString(rr.Field.Name); if (currentValue != null) { debuggerCanShowValue = true; b.Append(" = "); b.Append(currentValue); } } return(b.ToString()); } else if (result is NamespaceResolveResult) { return("namespace " + ((NamespaceResolveResult)result).Name); } else if (result is TypeResolveResult) { IClass c = ((TypeResolveResult)result).ResolvedClass; if (c != null) { return(GetMemberText(ambience, c, expression, out debuggerCanShowValue)); } else { return(ambience.Convert(result.ResolvedType)); } } else if (result is MethodResolveResult) { MethodResolveResult mrr = result as MethodResolveResult; IMethod m = mrr.GetMethodIfSingleOverload(); if (m != null) { return(GetMemberText(ambience, m, expression, out debuggerCanShowValue)); } else { return("Overload of " + ambience.Convert(mrr.ContainingType) + "." + mrr.Name); } } else { if (Control.ModifierKeys == Keys.Control) { if (result.ResolvedType != null) { return("expression of type " + ambience.Convert(result.ResolvedType)); } else { return("ResolveResult without ResolvedType"); } } else { return(null); } } }