当前位置: 首页>>代码示例>>C#>>正文


C# TextChange类代码示例

本文整理汇总了C#中TextChange的典型用法代码示例。如果您正苦于以下问题:C# TextChange类的具体用法?C# TextChange怎么用?C# TextChange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextChange类属于命名空间,在下文中一共展示了TextChange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryGetDocumentWithFullyQualifiedTypeName

        private bool TryGetDocumentWithFullyQualifiedTypeName(Document document, out TextSpan updatedTextSpan, out Document documentWithFullyQualifiedTypeName)
        {
            documentWithFullyQualifiedTypeName = null;
            updatedTextSpan = default(TextSpan);

            var surfaceBufferFieldSpan = new VsTextSpan[1];
            if (snippetExpansionClient.ExpansionSession.GetFieldSpan(_fieldName, surfaceBufferFieldSpan) != VSConstants.S_OK)
            {
                return false;
            }

            SnapshotSpan subjectBufferFieldSpan;
            if (!snippetExpansionClient.TryGetSubjectBufferSpan(surfaceBufferFieldSpan[0], out subjectBufferFieldSpan))
            {
                return false;
            }

            var originalTextSpan = new TextSpan(subjectBufferFieldSpan.Start, subjectBufferFieldSpan.Length);
            updatedTextSpan = new TextSpan(subjectBufferFieldSpan.Start, _fullyQualifiedName.Length);

            var textChange = new TextChange(originalTextSpan, _fullyQualifiedName);
            var newText = document.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None).WithChanges(textChange);

            documentWithFullyQualifiedTypeName = document.WithText(newText);
            return true;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:26,代码来源:AbstractSnippetFunctionSimpleTypeName.cs

示例2: OwnsChange

 public virtual bool OwnsChange(Span target, TextChange change)
 {
     var end = target.Start.AbsoluteIndex + target.Length;
     var changeOldEnd = change.OldPosition + change.OldLength;
     return change.OldPosition >= target.Start.AbsoluteIndex &&
            (changeOldEnd < end || (changeOldEnd == end && AcceptedCharacters != AcceptedCharacters.None));
 }
开发者ID:cjqian,项目名称:Razor,代码行数:7,代码来源:SpanEditHandler.cs

示例3: GetTransformedDocumentAsync

        private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
            var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

            TextChange textChange = new TextChange(new TextSpan(diagnostic.Location.SourceSpan.Start, 1), string.Empty);
            return document.WithText(text.WithChanges(textChange));
        }
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1626CodeFixProvider.cs

示例4: RaiseChangeCompleted

 public void RaiseChangeCompleted(TextChange change)
 {
     var e = ChangeCompleted;
     if (e != null)
     {
         e(this, change);
     }
 }
开发者ID:rride,项目名称:VsVim,代码行数:8,代码来源:MockTextChangeTracker.cs

示例5: GetTransformedDocumentAsync

        private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken token)
        {
            var newLine = document.Project.Solution.Workspace.Options.GetOption(FormattingOptions.NewLine, LanguageNames.CSharp);

            var sourceText = await document.GetTextAsync(token).ConfigureAwait(false);
            var textChange = new TextChange(diagnostic.Location.SourceSpan, newLine);

            return document.WithText(sourceText.WithChanges(textChange));
        }
开发者ID:endjin,项目名称:StyleCopAnalyzers,代码行数:9,代码来源:SA1507CodeFixProvider.cs

示例6: parameter

#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
        public static CompletionChange Create(
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
            TextChange textChange,
            int? newPosition = null,
            bool includesCommitCharacter = false)
        {
            return new CompletionChange(textChange, newPosition, includesCommitCharacter);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:CompletionChange.cs

示例7: CompletionChange

        private CompletionChange(TextChange textChange, int? newPosition, bool includesCommitCharacter)
        {
            TextChange = textChange;
#pragma warning disable CS0618 // Type or member is obsolete
            TextChanges = ImmutableArray.Create(textChange);
#pragma warning restore CS0618 // Type or member is obsolete
            NewPosition = newPosition;
            IncludesCommitCharacter = includesCommitCharacter;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:CompletionChange.cs

示例8: TestIsDelete

        public void TestIsDelete()
        {
            // Arrange
            var oldBuffer = new Mock<ITextBuffer>().Object;
            var newBuffer = new Mock<ITextBuffer>().Object;
            var change = new TextChange(0, 1, oldBuffer, 0, newBuffer);

            // Assert
            Assert.True(change.IsDelete);
        }
开发者ID:cjqian,项目名称:Razor,代码行数:10,代码来源:TextChangeTest.cs

示例9: Bug18241

 public void Bug18241()
 {
     var tree = SyntaxFactory.ParseSyntaxTree(" class C { void M() { await X() on ");
     SourceText text = tree.GetText();
     TextSpan span = new TextSpan(text.Length, 0);
     TextChange change = new TextChange(span, "/*comment*/");
     SourceText newText = text.WithChanges(change);
     // This line caused an assertion and then crashed in the parser.
     var newTree = tree.WithChangedText(newText);
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:10,代码来源:BindingAwaitTests.cs

示例10: TestDeleteCreatesTheRightSizeChange

        public void TestDeleteCreatesTheRightSizeChange()
        {
            // Arrange
            var oldBuffer = new Mock<ITextBuffer>().Object;
            var newBuffer = new Mock<ITextBuffer>().Object;
            var change = new TextChange(0, 1, oldBuffer, 0, newBuffer);

            // Assert
            Assert.Equal(0, change.NewText.Length);
            Assert.Equal(1, change.OldText.Length);
        }
开发者ID:cjqian,项目名称:Razor,代码行数:11,代码来源:TextChangeTest.cs

示例11: CanAcceptChange

 protected override PartialParseResult CanAcceptChange(Span target, TextChange normalizedChange)
 {
     if (((AutoCompleteAtEndOfSpan && IsAtEndOfSpan(target, normalizedChange)) || IsAtEndOfFirstLine(target, normalizedChange)) &&
         normalizedChange.IsInsert &&
         ParserHelpers.IsNewLine(normalizedChange.NewText) &&
         AutoCompleteString != null)
     {
         return PartialParseResult.Rejected | PartialParseResult.AutoCompleteBlock;
     }
     return PartialParseResult.Rejected;
 }
开发者ID:x-strong,项目名称:Razor,代码行数:11,代码来源:AutoCompleteEditHandler.cs

示例12: CanAcceptChange

        protected override PartialParseResult CanAcceptChange(Span target, TextChange normalizedChange)
        {
            if (AcceptedCharacters == AcceptedCharacters.Any)
            {
                return PartialParseResult.Rejected;
            }

            // In some editors intellisense insertions are handled as "dotless commits".  If an intellisense selection is confirmed
            // via something like '.' a dotless commit will append a '.' and then insert the remaining intellisense selection prior
            // to the appended '.'.  This 'if' statement attempts to accept the intermediate steps of a dotless commit via
            // intellisense.  It will accept two cases:
            //     1. '@foo.' -> '@foobaz.'.
            //     2. '@foobaz..' -> '@foobaz.bar.'. Includes Sub-cases '@foobaz()..' -> '@foobaz().bar.' etc.
            // The key distinction being the double '.' in the second case.
            if (IsDotlessCommitInsertion(target, normalizedChange))
            {
                return HandleDotlessCommitInsertion(target);
            }

            if (IsAcceptableReplace(target, normalizedChange))
            {
                return HandleReplacement(target, normalizedChange);
            }
            var changeRelativePosition = normalizedChange.OldPosition - target.Start.AbsoluteIndex;

            // Get the edit context
            char? lastChar = null;
            if (changeRelativePosition > 0 && target.Content.Length > 0)
            {
                lastChar = target.Content[changeRelativePosition - 1];
            }

            // Don't support 0->1 length edits
            if (lastChar == null)
            {
                return PartialParseResult.Rejected;
            }

            // Accepts cases when insertions are made at the end of a span or '.' is inserted within a span.
            if (IsAcceptableInsertion(target, normalizedChange))
            {
                // Handle the insertion
                return HandleInsertion(target, lastChar.Value, normalizedChange);
            }

            if (IsAcceptableDeletion(target, normalizedChange))
            {
                return HandleDeletion(target, lastChar.Value, normalizedChange);
            }

            return PartialParseResult.Rejected;
        }
开发者ID:cjqian,项目名称:Razor,代码行数:52,代码来源:ImplicitExpressionEditHandler.cs

示例13: Create

 private void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _factory = new MockRepository(MockBehavior.Loose);
     _operations = _factory.Create<ICommonOperations>(MockBehavior.Strict);
     _vimTextBuffer = _factory.Create<IVimTextBuffer>(MockBehavior.Strict);
     _vimTextBuffer.SetupProperty(x => x.LastEditPoint);
     _trackerRaw = new TextChangeTracker(_vimTextBuffer.Object, _textView, _operations.Object);
     _trackerRaw.TrackCurrentChange = true;
     _tracker = _trackerRaw;
     _tracker.ChangeCompleted += (sender, args) => { _lastChange = args.TextChange; };
 }
开发者ID:Kazark,项目名称:VsVim,代码行数:13,代码来源:TextChangeTrackerTest.cs

示例14: ConstructorInitializesProperties

        public void ConstructorInitializesProperties()
        {
            // Act
            var oldBuffer = new Mock<ITextBuffer>().Object;
            var newBuffer = new Mock<ITextBuffer>().Object;
            var change = new TextChange(42, 24, oldBuffer, 1337, newBuffer);

            // Assert
            Assert.Equal(42, change.OldPosition);
            Assert.Equal(24, change.OldLength);
            Assert.Equal(1337, change.NewLength);
            Assert.Same(newBuffer, change.NewBuffer);
            Assert.Same(oldBuffer, change.OldBuffer);
        }
开发者ID:cjqian,项目名称:Razor,代码行数:14,代码来源:TextChangeTest.cs

示例15: ApplyChange

        public virtual EditResult ApplyChange(Span target, TextChange change, bool force)
        {
            var result = PartialParseResult.Accepted;
            var normalized = change.Normalize();
            if (!force)
            {
                result = CanAcceptChange(target, normalized);
            }

            // If the change is accepted then apply the change
            if ((result & PartialParseResult.Accepted) == PartialParseResult.Accepted)
            {
                return new EditResult(result, UpdateSpan(target, normalized));
            }
            return new EditResult(result, new SpanBuilder(target));
        }
开发者ID:cjqian,项目名称:Razor,代码行数:16,代码来源:SpanEditHandler.cs


注:本文中的TextChange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。