Beispiel #1
0
        void HandleTextReplacing(object sender, Core.Text.TextChangeEventArgs e)
        {
            var handler = TextChanged;

            if (handler != null)
            {
                lock (replaceLock) {
                    var oldText      = CurrentText;
                    var changes      = new Microsoft.CodeAnalysis.Text.TextChange[e.TextChanges.Count];
                    var changeRanges = new TextChangeRange[e.TextChanges.Count];
                    for (int i = 0; i < e.TextChanges.Count; ++i)
                    {
                        var c    = e.TextChanges[i];
                        var span = new TextSpan(c.Offset, c.RemovalLength);
                        changes[i]      = new Microsoft.CodeAnalysis.Text.TextChange(span, c.InsertedText.Text);
                        changeRanges[i] = new TextChangeRange(span, c.InsertionLength);
                    }
                    var newText = oldText.WithChanges(changes);
                    currentText = newText;
                    try {
                        handler(this, new Microsoft.CodeAnalysis.Text.TextChangeEventArgs(oldText, newText, changeRanges));
                    } catch (ArgumentException ae) {
                        LoggingService.LogWarning(ae.Message + " re opening " + editor.FileName + " as roslyn source text.");
                        workspace.InformDocumentClose(Id, editor.FileName);
                        Dispose();                          // 100% ensure that this object is disposed
                        if (workspace.GetDocument(Id) != null)
                        {
                            TypeSystemService.InformDocumentOpen(Id, editor);
                        }
                    } catch (Exception ex) {
                        LoggingService.LogError("Error while text replacing", ex);
                    }
                }
            }
        }
        void HandleTextReplacing(object sender, Core.Text.TextChangeEventArgs e)
        {
            var handler = TextChanged;

            if (handler != null)
            {
                lock (replaceLock) {
                    var oldText      = CurrentText;
                    var changes      = new Microsoft.CodeAnalysis.Text.TextChange[e.TextChanges.Count];
                    var changeRanges = new TextChangeRange[e.TextChanges.Count];
                    for (int i = 0; i < e.TextChanges.Count; ++i)
                    {
                        var c    = e.TextChanges[i];
                        var span = new TextSpan(c.Offset, c.RemovalLength);
                        changes[i]      = new Microsoft.CodeAnalysis.Text.TextChange(span, c.InsertedText.Text);
                        changeRanges[i] = new TextChangeRange(span, c.InsertionLength);
                    }
                    var newText = oldText.WithChanges(changes);
                    currentText = newText;
                    try {
                        handler(this, new Microsoft.CodeAnalysis.Text.TextChangeEventArgs(oldText, newText, changeRanges));
                    } catch (Exception ex) {
                        LoggingService.LogError("Error while text replacing", ex);
                    }
                }
            }
        }
        void HandleTextReplacing(object sender, Core.Text.TextChangeEventArgs e)
        {
            var handler = TextChanged;

            if (handler != null)
            {
                var oldText = CurrentText;
                var newText = oldText.Replace(e.Offset, e.RemovalLength, e.InsertedText.Text);
                handler(this, new Microsoft.CodeAnalysis.Text.TextChangeEventArgs(oldText, newText, new TextChangeRange(TextSpan.FromBounds(e.Offset, e.Offset + e.RemovalLength), e.InsertionLength)));
            }
        }
        void HandleTextReplacing(object sender, Core.Text.TextChangeEventArgs e)
        {
            var handler = TextChanged;

            if (handler != null)
            {
                var oldText = CurrentText;
                var newText = oldText.Replace(e.Offset, e.RemovalLength, e.InsertedText.Text);
                currentText = newText;
                try {
                    handler(this, new Microsoft.CodeAnalysis.Text.TextChangeEventArgs(oldText, newText, new TextChangeRange(TextSpan.FromBounds(e.Offset, e.Offset + e.RemovalLength), e.InsertionLength)));
                } catch (Exception ex) {
                    LoggingService.LogError("Error while text replacing", ex);
                }
            }
        }
        async void Handle_TextChanged(object sender, Core.Text.TextChangeEventArgs e)
        {
            var ln = Document.OffsetToLineNumber(e.Offset);

            if (ln >= stateCache.Count)
            {
                return;
            }
            var line      = Document.GetLineByOffset(e.Offset);
            var lastState = GetState(line);

            var high = new Highlighter(this, lastState);
            await high.GetColoredSegments(Document, line.Offset, line.LengthIncludingDelimiter);

            OnHighlightingStateChanged(new LineEventArgs(line));
            stateCache.RemoveRange(ln - 1, stateCache.Count - ln + 1);
        }
        async void Handle_TextChanged(object sender, Core.Text.TextChangeEventArgs e)
        {
            for (int i = 0; i < e.TextChanges.Count; ++i)
            {
                var change = e.TextChanges[i];
                var ln     = Document.OffsetToLineNumber(change.NewOffset);
                if (ln >= stateCache.Count)
                {
                    continue;
                }
                var line      = Document.GetLineByOffset(change.NewOffset);
                var lastState = await GetStateAsync(line);

                var high = new Highlighter(this, lastState);
                await high.GetColoredSegments(Document, line.Offset, line.LengthIncludingDelimiter);

                OnHighlightingStateChanged(new LineEventArgs(line));
                stateCache.RemoveRange(ln - 1, stateCache.Count - ln + 1);
            }
        }
 void Document_TextChanged(object sender, Core.Text.TextChangeEventArgs e)
 {
     currentText = null;
 }
 void Editor_TextChanged(object sender, Core.Text.TextChangeEventArgs e)
 {
 }