提交 0afe42d8 编写于 作者: A Ankita Khera

Formatting fixes

上级 2c1643a2
using System.Windows;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows;
using System.Windows.Controls;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
namespace Microsoft.CodeAnalysis.Editor.InlineParamNameHints
namespace Microsoft.CodeAnalysis.Editor.InlineParameterNameHints
{
/// <summary>
/// This is the tag which implements the IntraTextAdornmentTag and is meant to
/// create the UIElements that get shown in the editor
/// </summary>
class InlineParamNameHintsTag : IntraTextAdornmentTag
internal class InlineParamNameHintsTag : IntraTextAdornmentTag
{
public readonly string TagName;
......@@ -18,7 +22,7 @@ class InlineParamNameHintsTag : IntraTextAdornmentTag
/// </summary>
/// <param name="text">The name of the parameter associated with the argument</param>
public InlineParamNameHintsTag(string text)
: base(CreateElement(text), null, (PositionAffinity?)PositionAffinity.Successor)
: base(CreateElement(text), removalCallback: null, (PositionAffinity?)PositionAffinity.Successor)
{
TagName = text;
if (TagName.Length != 0)
......@@ -46,5 +50,4 @@ private static UIElement CreateElement(string text)
return block;
}
}
}
using System;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis.ExtractMethod;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
namespace Microsoft.CodeAnalysis.Editor.InlineParamNameHints
namespace Microsoft.CodeAnalysis.Editor.InlineParameterNameHints
{
/// <summary>
/// The purpose of this tagger is to convert the InlineParamNameHintsDataTags to
/// the InlineParamNameHintsTag, which actually creates the UIElement. It reacts to
/// tags changing and updates the adornments accordingly.
/// </summary>
class InlineParamNameHintsTagger : ITagger<IntraTextAdornmentTag>
class InlineParamNameHintsTagger : ITagger<IntraTextAdornmentTag>, IDisposable
{
private readonly ITagAggregator<InlineParamNameHintDataTag> _tagAggregator;
private readonly ITextBuffer _buffer;
public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
public InlineParamNameHintsTagger(ITextBuffer buffer, ITagAggregator<InlineParamNameHintDataTag> tagAggregator)
{
......@@ -29,18 +35,20 @@ private void _tagAggregator_TagsChanged(object sender, TagsChangedEventArgs e)
var spans = e.Span.GetSpans(_buffer);
foreach (var span in spans)
{
TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(span.Snapshot, 0, span.Snapshot.Length)));
TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span));//new SnapshotSpan(span.Snapshot, 0, span.Snapshot.Length)));
}
}
public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
public IEnumerable<ITagSpan<IntraTextAdornmentTag>> GetTags(NormalizedSnapshotSpanCollection spans)
{
var tagsList = new List<TagSpan<IntraTextAdornmentTag>>();
var tagsList = new List<ITagSpan<IntraTextAdornmentTag>>();
var dataTags = _tagAggregator.GetTags(spans);
foreach(var tag in dataTags)
{
if (spans.Count <= 0)
{
return tagsList;
}
var dataTagSpans = tag.Span.GetSpans(spans[0].Snapshot);
var textTag = tag.Tag;
if (dataTagSpans.Count > 0)
......@@ -48,10 +56,14 @@ public IEnumerable<ITagSpan<IntraTextAdornmentTag>> GetTags(NormalizedSnapshotSp
var dataTagSpan = dataTagSpans[0];
var adornmentSpan = new SnapshotSpan(dataTagSpan.Start, 0);
tagsList.Add(new TagSpan<IntraTextAdornmentTag>(adornmentSpan, new InlineParamNameHintsTag(textTag.TagName)));
}
}
return tagsList.AsEnumerable();
return tagsList;
}
public void Dispose()
{
_tagAggregator.Dispose();
}
}
}
using System.ComponentModel.Composition;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.CodeAnalysis.Editor.InlineParamNameHints
namespace Microsoft.CodeAnalysis.Editor.InlineParameterNameHints
{
/// <summary>
/// The provider that is used as a middleman to create the tagger so that the data tag
......@@ -16,7 +20,7 @@ namespace Microsoft.CodeAnalysis.Editor.InlineParamNameHints
[Name(nameof(InlineParamNameHintsTaggerProvider))]
class InlineParamNameHintsTaggerProvider : ITaggerProvider
{
private IBufferTagAggregatorFactoryService _bufferTagAggregatorFactoryService;
private readonly IBufferTagAggregatorFactoryService _bufferTagAggregatorFactoryService;
[ImportingConstructor]
public InlineParamNameHintsTaggerProvider(IBufferTagAggregatorFactoryService bufferTagAggregatorFactoryService)
{
......
using Microsoft.VisualStudio.Text.Tagging;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.CodeAnalysis.Editor.InlineParamNameHints
using Microsoft.VisualStudio.Text.Tagging;
namespace Microsoft.CodeAnalysis.Editor.InlineParameterNameHints
{
/// <summary>
/// The simple tag that only holds information regarding the associated parameter name
......@@ -9,6 +13,7 @@ namespace Microsoft.CodeAnalysis.Editor.InlineParamNameHints
class InlineParamNameHintDataTag : ITag
{
public readonly string TagName;
public InlineParamNameHintDataTag(string name)
{
TagName = name;
......
using System.ComponentModel.Composition;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Tagging;
......@@ -13,7 +17,7 @@
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.CodeAnalysis.Editor.InlineParamNameHints
namespace Microsoft.CodeAnalysis.Editor.InlineParameterNameHints
{
/// <summary>
/// The TaggerProvider that calls upon the service in order to locate the spans and names
......
......@@ -3,7 +3,7 @@
' See the LICENSE file in the project root for more information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.Editor.InlineParamNameHints
Imports Microsoft.CodeAnalysis.Editor.InlineParameterNameHints
Imports Microsoft.CodeAnalysis.Editor.Shared.Extensions
Imports Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports Microsoft.CodeAnalysis.Editor.Tagging
......@@ -11,7 +11,7 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Shared.TestHooks
Imports Microsoft.VisualStudio.Text
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InlineParamNameHints
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InlineParameterNameHints
<[UseExportProvider]>
Public MustInherit Class AbstractInlineParamNameHintsTests
......@@ -57,9 +57,6 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InlineParamNameHints
AssertEx.Equal(expectedTags, producedTags)
End Using
End Function
End Class
End Namespace
......@@ -2,7 +2,7 @@
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InlineParamNameHints
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InlineParameterNameHints
Public Class CSharpInlineParamNameHintsTests
Inherits AbstractInlineParamNameHintsTests
......
using System;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
......@@ -9,7 +14,6 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.InlineParameterNameHints;
using Microsoft.CodeAnalysis.Text;
#nullable enable
namespace Microsoft.CodeAnalysis.CSharp.InlineParameterNameHints
{
......
......@@ -6,6 +6,7 @@
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;
#nullable enable
namespace Microsoft.CodeAnalysis.CSharp.Extensions
{
......@@ -41,7 +42,7 @@ public static RefKind GetRefKind(this ArgumentSyntax argument)
/// is true, the last parameter will be returned if it is params parameter and the index of
/// the specified argument is greater than the number of parameters.
/// </summary>
public static IParameterSymbol DetermineParameter(
public static IParameterSymbol? DetermineParameter(
this ArgumentSyntax argument,
SemanticModel semanticModel,
bool allowParams = false,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册