Exemple #1
0
            public TextSpan?GetConflictEditSpan(
                InlineRenameLocation location,
                string triggerText,
                string replacementText,
                CancellationToken cancellationToken
                )
            {
                var position = triggerText.LastIndexOf(replacementText, StringComparison.Ordinal);

                if (_isRenamingAttributePrefix)
                {
                    // We're only renaming the attribute prefix part.  We want to adjust the span of
                    // the reference we've found to only update the prefix portion.
                    var index = triggerText.LastIndexOf(
                        replacementText + AttributeSuffix,
                        StringComparison.Ordinal
                        );
                    position = index >= 0 ? index : position;
                }

                if (position < 0)
                {
                    return(null);
                }

                return(new TextSpan(location.TextSpan.Start + position, replacementText.Length));
            }
Exemple #2
0
            /// <summary>
            /// Given a span of text, we need to return the subspan that is editable and
            /// contains the current replacementText.
            ///
            /// These cases are currently handled:
            ///     - Escaped identifiers                          [goo] => goo
            ///     - Type suffixes in VB                          goo$ => goo
            ///     - Qualified names from complexification        A.goo => goo
            ///     - Optional Attribute suffixes                  XAttribute => X
            ///         Careful here:                              XAttribute => XAttribute if renamesymbol is XAttributeAttribute
            ///     - Compiler-generated EventHandler suffix       XEventHandler => X
            ///     - Compiler-generated get_ and set_ prefixes    get_X => X
            /// </summary>
            public TextSpan GetReferenceEditSpan(
                InlineRenameLocation location,
                string triggerText,
                CancellationToken cancellationToken
                )
            {
                var searchName = this.RenameSymbol.Name;

                if (_isRenamingAttributePrefix)
                {
                    // We're only renaming the attribute prefix part.  We want to adjust the span of
                    // the reference we've found to only update the prefix portion.
                    searchName = GetWithoutAttributeSuffix(this.RenameSymbol.Name);
                }

                var index = triggerText.LastIndexOf(searchName, StringComparison.Ordinal);

                if (index < 0)
                {
                    // Couldn't even find the search text at this reference location.  This might happen
                    // if the user used things like unicode escapes.  IN that case, we'll have to rename
                    // the entire identifier.
                    return(location.TextSpan);
                }

                return(new TextSpan(location.TextSpan.Start + index, searchName.Length));
            }
 public TextSpan GetReferenceEditSpan(
     InlineRenameLocation location,
     string triggerText,
     CancellationToken cancellationToken
     )
 {
     return(location.TextSpan);
 }
 public TextSpan?GetConflictEditSpan(
     InlineRenameLocation location,
     string triggerText,
     string replacementText,
     CancellationToken cancellationToken
     )
 {
     return(location.TextSpan);
 }
Exemple #5
0
 public TextSpan GetReferenceEditSpan(
     InlineRenameLocation location,
     string triggerText,
     CancellationToken cancellationToken
     )
 {
     return(_info.GetReferenceEditSpan(
                new FSharpInlineRenameLocation(location.Document, location.TextSpan),
                cancellationToken
                ));
 }
 public TextSpan GetReferenceEditSpan(
     InlineRenameLocation location,
     string triggerText,
     CancellationToken cancellationToken
     )
 {
     return(_info.GetReferenceEditSpan(
                new VSTypeScriptInlineRenameLocationWrapper(
                    new InlineRenameLocation(location.Document, location.TextSpan)
                    ),
                cancellationToken
                ));
 }
Exemple #7
0
 public TextSpan?GetConflictEditSpan(
     InlineRenameLocation location,
     string triggerText,
     string replacementText,
     CancellationToken cancellationToken
     )
 {
     return(_info.GetConflictEditSpan(
                new FSharpInlineRenameLocation(location.Document, location.TextSpan),
                replacementText,
                cancellationToken
                ));
 }
Exemple #8
0
 public TextSpan?GetConflictEditSpan(InlineRenameLocation location, string replacementText, CancellationToken cancellationToken) => null;
Exemple #9
0
 public TextSpan GetReferenceEditSpan(InlineRenameLocation location, CancellationToken cancellationToken)
 {
     return(default(TextSpan));
 }
            public TextSpan? GetConflictEditSpan(InlineRenameLocation location, string replacementText, CancellationToken cancellationToken)
            {
                var spanText = GetSpanText(location.Document, location.TextSpan, cancellationToken);
                var position = spanText.LastIndexOf(replacementText, StringComparison.Ordinal);

                if (_isRenamingAttributePrefix)
                {
                    // We're only renaming the attribute prefix part.  We want to adjust the span of 
                    // the reference we've found to only update the prefix portion.
                    var index = spanText.LastIndexOf(replacementText + AttributeSuffix, StringComparison.Ordinal);
                    position = index >= 0 ? index : position;
                }

                if (position < 0)
                {
                    return null;
                }

                return new TextSpan(location.TextSpan.Start + position, replacementText.Length);
            }
Exemple #11
0
 public TextSpan GetReferenceEditSpan(InlineRenameLocation location, CancellationToken cancellationToken) => default;
Exemple #12
0
 TextSpan IInlineRenameInfo.GetReferenceEditSpan(InlineRenameLocation location, string triggerText, CancellationToken cancellationToken)
 => GetReferenceEditSpan(new FSharpInlineRenameLocation(location.Document, location.TextSpan), cancellationToken);
            /// <summary>
            /// Given a span of text, we need to return the subspan that is editable and
            /// contains the current replacementText.
            /// 
            /// These cases are currently handled:
            ///     - Escaped identifiers                          [foo] => foo
            ///     - Type suffixes in VB                          foo$ => foo
            ///     - Qualified names from complexification        A.foo => foo
            ///     - Optional Attribute suffixes                  XAttribute => X
            ///         Careful here:                              XAttribute => XAttribute if renamesymbol is XAttributeAttribute
            ///     - Compiler-generated EventHandler suffix       XEventHandler => X
            ///     - Compiler-generated get_ and set_ prefixes    get_X => X
            /// </summary>
            public TextSpan GetReferenceEditSpan(InlineRenameLocation location, CancellationToken cancellationToken)
            {
                var searchName = this.RenameSymbol.Name;
                if (_isRenamingAttributePrefix)
                {
                    // We're only renaming the attribute prefix part.  We want to adjust the span of 
                    // the reference we've found to only update the prefix portion.
                    searchName = GetWithoutAttributeSuffix(this.RenameSymbol.Name);
                }

                var spanText = GetSpanText(location.Document, location.TextSpan, cancellationToken);
                var index = spanText.LastIndexOf(searchName, StringComparison.Ordinal);

                if (index < 0)
                {
                    // Couldn't even find the search text at this reference location.  This might happen
                    // if the user used things like unicode escapes.  IN that case, we'll have to rename
                    // the entire identifier.
                    return location.TextSpan;
                }

                return new TextSpan(location.TextSpan.Start + index, searchName.Length);
            }
 public TextSpan? GetConflictEditSpan(InlineRenameLocation location, string replacementText, CancellationToken cancellationToken) { return null; }
Exemple #15
0
 TextSpan?IInlineRenameInfo.GetConflictEditSpan(InlineRenameLocation location, string triggerText, string replacementText, CancellationToken cancellationToken)
 => GetConflictEditSpan(new FSharpInlineRenameLocation(location.Document, location.TextSpan), replacementText, cancellationToken);
 public TextSpan GetReferenceEditSpan(InlineRenameLocation location, CancellationToken cancellationToken) { return default(TextSpan); }
Exemple #17
0
 TextSpan?IInlineRenameInfo.GetConflictEditSpan(InlineRenameLocation location, string triggerText, string replacementText, CancellationToken cancellationToken)
 => GetConflictEditSpan(new VSTypeScriptInlineRenameLocationWrapper(
                            new InlineRenameLocation(location.Document, location.TextSpan)), replacementText, cancellationToken);
Exemple #18
0
 TextSpan IInlineRenameInfo.GetReferenceEditSpan(InlineRenameLocation location, string triggerText, CancellationToken cancellationToken)
 => GetReferenceEditSpan(new VSTypeScriptInlineRenameLocationWrapper(
                             new InlineRenameLocation(location.Document, location.TextSpan)), cancellationToken);
 public VSTypeScriptInlineRenameLocationWrapper(InlineRenameLocation underlyingObject) =>
Exemple #20
0
 public TextSpan?GetConflictEditSpan(InlineRenameLocation location, string replacementText, CancellationToken cancellationToken)
 {
     return(_info.GetConflictEditSpan(new VSTypeScriptInlineRenameLocationWrapper(
                                          new InlineRenameLocation(location.Document, location.TextSpan)), replacementText, cancellationToken));
 }