public static void ReplaceIdentifier([CanBeNull] this IFSharpIdentifier fsIdentifier, string name) { // todo: replace the composite identifier node with a single token where possible if (!(fsIdentifier?.FirstChild is FSharpIdentifierToken token)) { return; } name = Lexhelp.Keywords.QuoteIdentifierIfNeeded(name); using (WriteLockCookie.Create(fsIdentifier.IsPhysical())) LowLevelModificationUtil.ReplaceChildRange(token, token, new FSharpIdentifierToken(name)); }
public static void ReplaceIdentifier([CanBeNull] this IFSharpIdentifier fsIdentifier, string name) { var token = fsIdentifier?.IdentifierToken; if (token == null) { return; } name = NamingManager.GetNamingLanguageService(fsIdentifier.Language).MangleNameIfNecessary(name); using (WriteLockCookie.Create(fsIdentifier.IsPhysical())) LowLevelModificationUtil.ReplaceChildRange(token, token, new FSharpIdentifierToken(name)); }
public static TreeTextRange GetNameRange([CanBeNull] this IFSharpIdentifier identifier) { if (identifier == null) { return(TreeTextRange.InvalidRange); } if (identifier is IActivePatternId activePatternId) { return(activePatternId.GetCasesRange()); } var nameRange = identifier.GetTreeTextRange(); var identifierToken = identifier.IdentifierToken; if (identifierToken == null) { return(nameRange); } return(FSharpNamesUtil.IsEscapedWithBackticks(identifierToken.GetText()) ? nameRange.TrimLeft(2).TrimRight(2) : nameRange); }
public static TreeTextRange GetNameRange([CanBeNull] this IFSharpIdentifier identifier) { return(identifier?.GetTreeTextRange() ?? TreeTextRange.InvalidRange); }
public static IFSharpReferenceOwner GetByIdentifier([CanBeNull] IFSharpIdentifier identifier) => ReferenceExprNavigator.GetByIdentifier(identifier) ?? (IFSharpReferenceOwner)ReferenceNameNavigator.GetByIdentifier(identifier) ?? TypeExtensionDeclarationNavigator.GetByIdentifier(identifier);
public static TreeTextRange GetNameIdentifierRange([CanBeNull] this IFSharpIdentifier identifier) => identifier?.GetTreeTextRange() ?? TreeTextRange.InvalidRange;