<commit_before>﻿using System;
using System.Collections.Immutable;
using System.Windows;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.FindReferences;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;

namespace Microsoft.VisualStudio.LanguageServices.Implementation
{
    internal partial class StreamingFindReferencesPresenter
    {
        private class ReferenceEntry
        {
            private readonly StreamingFindReferencesPresenter _presenter;

            private readonly RoslynDefinitionBucket _definitionBucket;
            private readonly SourceReferenceItem _sourceReferenceItem;

            private readonly object _boxedProjectGuid;
            private readonly SourceText _sourceText;
            private readonly ImmutableArray<TaggedText> _taggedParts;

            public ReferenceEntry(
                StreamingFindReferencesPresenter presenter,
                RoslynDefinitionBucket definitionBucket,
                SourceReferenceItem sourceReferenceItem,
                Guid projectGuid,
                SourceText sourceText,
                ImmutableArray<TaggedText> taggedParts)
            {
                _presenter = presenter;

                _definitionBucket = definitionBucket;
                _sourceReferenceItem = sourceReferenceItem;

                _boxedProjectGuid = projectGuid;
                _sourceText = sourceText;
                _taggedParts = taggedParts;
            }

            public bool TryGetValue(string keyName, out object content)
            {
                content = GetValue(keyName);
                return content != null;
            }

            private DocumentLocation Location => _sourceReferenceItem.Location;
            private Document Document => Location.Document;
            private TextSpan SourceSpan => Location.SourceSpan;

            private object GetValue(string keyName)
            {
                switch (keyName)
                {
                case StandardTableKeyNames.DocumentName:
                    return Document.FilePath;
                case StandardTableKeyNames.Line:
                    return _sourceText.Lines.GetLinePosition(SourceSpan.Start).Line;
                case StandardTableKeyNames.Column:
                    return _sourceText.Lines.GetLinePosition(SourceSpan.Start).Character;
                case StandardTableKeyNames.ProjectName:
                    return Location.Document.Project.Name;
                case StandardTableKeyNames.ProjectGuid:
                    return _boxedProjectGuid;

                case StandardTableKeyNames.Text:
                    return _sourceText.Lines.GetLineFromPosition(SourceSpan.Start).ToString().Trim();

                case StandardTableKeyNames.FullText:
                    // When we support classified lines, change this to:
                    // return GetEllisionBufferAroundReference();
                    return _sourceText.Lines.GetLineFromPosition(SourceSpan.Start).ToString().Trim();

                case StandardTableKeyNames2.TextInlines:
                    return _taggedParts.ToTextBlock(_presenter._typeMap).Inlines;

                //case StandardTableKeyNames2.DefinitionIcon:
                //    return  _displayGlyph ? (object)_item.Glyph.GetImageMoniker() : null;

                case StandardTableKeyNames2.Definition:
                    return _definitionBucket;
                }

                return null;
            }

            internal bool TryCreateToolTip(string columnName, out object toolTip)
            {
                toolTip = GetEllisionBufferAroundReference();
                return true;
            }

            private FrameworkElement GetEllisionBufferAroundReference()
            {
                var snapshotSpan = GetSnapshotSpanAroundReference();
                var content = new ElisionBufferDeferredContent(<commit_msg>Remove commented out code.<commit_after>﻿using System;
using System.Collections.Immutable;
using System.Windows;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.FindReferences;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;

namespace Microsoft.VisualStudio.LanguageServices.Implementation
{
    internal partial class StreamingFindReferencesPresenter
    {
        private class ReferenceEntry
        {
            private readonly StreamingFindReferencesPresenter _presenter;

            private readonly RoslynDefinitionBucket _definitionBucket;
            private readonly SourceReferenceItem _sourceReferenceItem;

            private readonly object _boxedProjectGuid;
            private readonly SourceText _sourceText;
            private readonly ImmutableArray<TaggedText> _taggedParts;

            public ReferenceEntry(
                StreamingFindReferencesPresenter presenter,
                RoslynDefinitionBucket definitionBucket,
                SourceReferenceItem sourceReferenceItem,
                Guid projectGuid,
                SourceText sourceText,
                ImmutableArray<TaggedText> taggedParts)
            {
                _presenter = presenter;

                _definitionBucket = definitionBucket;
                _sourceReferenceItem = sourceReferenceItem;

                _boxedProjectGuid = projectGuid;
                _sourceText = sourceText;
                _taggedParts = taggedParts;
            }

            public bool TryGetValue(string keyName, out object content)
            {
                content = GetValue(keyName);
                return content != null;
            }

            private DocumentLocation Location => _sourceReferenceItem.Location;
            private Document Document => Location.Document;
            private TextSpan SourceSpan => Location.SourceSpan;

            private object GetValue(string keyName)
            {
                switch (keyName)
                {
                case StandardTableKeyNames.DocumentName:
                    return Document.FilePath;
                case StandardTableKeyNames.Line:
                    return _sourceText.Lines.GetLinePosition(SourceSpan.Start).Line;
                case StandardTableKeyNames.Column:
                    return _sourceText.Lines.GetLinePosition(SourceSpan.Start).Character;
                case StandardTableKeyNames.ProjectName:
                    return Location.Document.Project.Name;
                case StandardTableKeyNames.ProjectGuid:
                    return _boxedProjectGuid;

                case StandardTableKeyNames.Text:
                    return _sourceText.Lines.GetLineFromPosition(SourceSpan.Start).ToString().Trim();

                case StandardTableKeyNames.FullText:
                    // When we support classified lines, change this to:
                    // return GetEllisionBufferAroundReference();
                    return _sourceText.Lines.GetLineFromPosition(SourceSpan.Start).ToString().Trim();

                case StandardTableKeyNames2.TextInlines:
                    return _taggedParts.ToTextBlock(_presenter._typeMap).Inlines;

                case StandardTableKeyNames2.Definition:
                    return _definitionBucket;
                }

                return null;
            }

            internal bool TryCreateToolTip(string columnName, out object toolTip)
            {
                toolTip = GetEllisionBufferAroundReference();
                return true;
            }

            private FrameworkElement GetEllisionBufferAroundReference()
            {
                var snapshotSpan = GetSnapshotSpanAroundReference();
                var content = new ElisionBufferDeferredContent(
{'fraction_non_alphanumeric': 0.053683196918632645, 'fraction_numerical': 0.000601829561868079, 'mean_word_length': 2.081973293768546, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6894363', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1704, 'n_words': 376}