コード例 #1
0
            public static SourceText From(
                ITextBufferCloneService?textBufferCloneService,
                ITextSnapshot editorSnapshot
                )
            {
                if (editorSnapshot == null)
                {
                    throw new ArgumentNullException(nameof(editorSnapshot));
                }

                if (!s_textSnapshotMap.TryGetValue(editorSnapshot, out var snapshot))
                {
                    // Explicitly obtain the TextBufferContainer before calling GetValue to avoid reentrancy in
                    // ConditionalWeakTable. https://github.com/dotnet/roslyn/issues/28256
                    var container = TextBufferContainer.From(editorSnapshot.TextBuffer);

                    // Avoid capturing `textBufferCloneServiceOpt` on the fast path
                    var tempTextBufferCloneService = textBufferCloneService;
                    snapshot = s_textSnapshotMap.GetValue(
                        editorSnapshot,
                        s => new SnapshotSourceText(tempTextBufferCloneService, s, container)
                        );
                }

                return(snapshot);
            }
コード例 #2
0
            private SnapshotSourceText(ITextSnapshot editorSnapshot)
            {
                Contract.ThrowIfNull(editorSnapshot);

                this.EditorSnapshot = editorSnapshot;
                _containerOpt       = TextBufferContainer.From(editorSnapshot.TextBuffer);
                _reiteratedVersion  = editorSnapshot.Version.ReiteratedVersionNumber;
            }
コード例 #3
0
            private SnapshotSourceText(ITextSnapshot editorSnapshot, Encoding encodingOpt)
            {
                Contract.ThrowIfNull(editorSnapshot);

                this.RoslynSnapshot = TextBufferMapper.ToRoslyn(editorSnapshot);
                _containerOpt       = TextBufferContainer.From(editorSnapshot.TextBuffer);
                _reiteratedVersion  = editorSnapshot.Version.ReiteratedVersionNumber;
                _encodingOpt        = encodingOpt;
            }
コード例 #4
0
 private SnapshotSourceText(ITextBufferCloneService textBufferCloneServiceOpt, ITextSnapshot editorSnapshot) :
     this(textBufferCloneServiceOpt, editorSnapshot, TextBufferContainer.From(editorSnapshot.TextBuffer))
 {
 }
コード例 #5
0
 public static SourceTextContainer AsTextContainer(this ITextBuffer buffer) =>
 TextBufferContainer.From(buffer);
コード例 #6
0
ファイル: Extensions.cs プロジェクト: fjsnogueira/roslyn-1
 public static SourceTextContainer AsTextContainer(this ITextBuffer buffer)
 {
     return(TextBufferContainer.From(buffer));
 }
コード例 #7
0
 private SnapshotSourceText(ITextSnapshot editorSnapshot) :
     this(editorSnapshot, TextBufferContainer.From(editorSnapshot.TextBuffer))
 {
 }