예제 #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));
            }
예제 #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));
            }
예제 #3
0
 public TextSpan GetReferenceEditSpan(
     InlineRenameLocation location,
     string triggerText,
     CancellationToken cancellationToken
     )
 {
     return(location.TextSpan);
 }
예제 #4
0
 public TextSpan?GetConflictEditSpan(
     InlineRenameLocation location,
     string triggerText,
     string replacementText,
     CancellationToken cancellationToken
     )
 {
     return(location.TextSpan);
 }
예제 #5
0
 public TextSpan GetReferenceEditSpan(
     InlineRenameLocation location,
     string triggerText,
     CancellationToken cancellationToken
     )
 {
     return(_info.GetReferenceEditSpan(
                new FSharpInlineRenameLocation(location.Document, location.TextSpan),
                cancellationToken
                ));
 }
예제 #6
0
 public TextSpan GetReferenceEditSpan(
     InlineRenameLocation location,
     string triggerText,
     CancellationToken cancellationToken
     )
 {
     return(_info.GetReferenceEditSpan(
                new VSTypeScriptInlineRenameLocationWrapper(
                    new InlineRenameLocation(location.Document, location.TextSpan)
                    ),
                cancellationToken
                ));
 }
예제 #7
0
 public TextSpan?GetConflictEditSpan(
     InlineRenameLocation location,
     string triggerText,
     string replacementText,
     CancellationToken cancellationToken
     )
 {
     return(_info.GetConflictEditSpan(
                new FSharpInlineRenameLocation(location.Document, location.TextSpan),
                replacementText,
                cancellationToken
                ));
 }
예제 #8
0
 public TextSpan?GetConflictEditSpan(InlineRenameLocation location, string replacementText, CancellationToken cancellationToken) => null;
예제 #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);
            }
예제 #11
0
 public TextSpan GetReferenceEditSpan(InlineRenameLocation location, CancellationToken cancellationToken) => default;
예제 #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; }
예제 #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); }
예제 #17
0
 TextSpan?IInlineRenameInfo.GetConflictEditSpan(InlineRenameLocation location, string triggerText, string replacementText, CancellationToken cancellationToken)
 => GetConflictEditSpan(new VSTypeScriptInlineRenameLocationWrapper(
                            new InlineRenameLocation(location.Document, location.TextSpan)), replacementText, cancellationToken);
예제 #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) =>
예제 #20
0
 public TextSpan?GetConflictEditSpan(InlineRenameLocation location, string replacementText, CancellationToken cancellationToken)
 {
     return(_info.GetConflictEditSpan(new VSTypeScriptInlineRenameLocationWrapper(
                                          new InlineRenameLocation(location.Document, location.TextSpan)), replacementText, cancellationToken));
 }