in ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Util/FSharpNamesUtil.cs [30:70]
public static string RemoveBackticks([NotNull] this string name) =>
IsEscapedWithBackticks(name)
? name.Substring(EscapedNameStartIndex, name.Length - EscapedNameAffixLength)
: name;
[NotNull]
public static IEnumerable<string> GetPossibleSourceNames([NotNull] IDeclaredElement element)
{
var name = element.ShortName;
var names = new HashSet<string> {name, ConvertValLogicalNameToDisplayNameCore(name)};
if (element is IFSharpDeclaredElement fsDeclaredElement)
names.Add(fsDeclaredElement.SourceName);
if (element is IConstructor { ContainingType: { } typeElement })
GetPossibleSourceNames(typeElement, names);
if (element is ITypeElement type)
GetPossibleSourceNames(type, names);
if (element is IAttributesOwner attrOwner)
{
if (GetFirstArgStringValue(attrOwner, CompilationSourceNameAttrTypeName) is { } sourceName)
names.Add(sourceName);
if (GetFirstArgStringValue(attrOwner, CustomOperationAttrTypeName) is { } customOpName)
names.Add(customOpName);
if (GetFirstArgValue(attrOwner, CompilationMappingAttrTypeName) is { } flagValue)
{
if ((SourceConstructFlags) flagValue == SourceConstructFlags.UnionCase && element is IMethod &&
name.StartsWith("New", StringComparison.Ordinal))
names.Add(name.Substring(3));
}
}
if (element is ICompiledElement and IMethod method)
names.Add(TryRemoveCompiledAccessorPrefix(method.ShortName));
return names;
}