예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
 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);
예제 #6
0
 public static TreeTextRange GetNameIdentifierRange([CanBeNull] this IFSharpIdentifier identifier) =>
 identifier?.GetTreeTextRange() ?? TreeTextRange.InvalidRange;