Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,23 @@
// See the LICENSE file in the project root for more information.

using System;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.Tagging;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Workspaces;
using Microsoft.VisualStudio.Text.Tagging;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;

internal abstract class VSTypeScriptAsynchronousTaggerProvider<TTag> : AsynchronousViewTaggerProvider<TTag>
where TTag : ITag
{
[Obsolete("Use constructor that takes ITextBufferVisibilityTracker. Use `[Import(AllowDefault = true)] ITextBufferVisibilityTracker? visibilityTracker`")]
protected VSTypeScriptAsynchronousTaggerProvider(
IThreadingContext threadingContext,
IAsynchronousOperationListenerProvider asyncListenerProvider,
VSTypeScriptGlobalOptions globalOptions)
: this(
threadingContext,
globalOptions,
visibilityTracker: null,
asyncListenerProvider)
{
}

[Obsolete("Use constructor that takes a single TaggerHost")]
protected VSTypeScriptAsynchronousTaggerProvider(
IThreadingContext threadingContext,
VSTypeScriptGlobalOptions globalOptions,
ITextBufferVisibilityTracker? visibilityTracker,
IAsynchronousOperationListenerProvider asyncListenerProvider)
: base(new TaggerHost(threadingContext, globalOptions.Service, visibilityTracker, asyncListenerProvider), FeatureAttribute.Classification)
[Obsolete("Use constructor that takes VSTypeScriptTaggerHost")]
protected VSTypeScriptAsynchronousTaggerProvider(TaggerHost taggerHost)
: base(taggerHost, FeatureAttribute.Classification)
{
}

protected VSTypeScriptAsynchronousTaggerProvider(TaggerHost taggerHost)
: base(taggerHost, FeatureAttribute.Classification)
protected VSTypeScriptAsynchronousTaggerProvider(VSTypeScriptTaggerHost taggerHost)
: base(taggerHost.UnderlyingObject, FeatureAttribute.Classification)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.Composition;
using Microsoft.CodeAnalysis.Editor.Tagging;
using Microsoft.CodeAnalysis.Host.Mef;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;

[Export(typeof(VSTypeScriptTaggerHost)), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class VSTypeScriptTaggerHost(TaggerHost underlyingObject)
{
internal TaggerHost UnderlyingObject { get; } = underlyingObject;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.Threading.Tasks;
using Microsoft.CodeAnalysis.Shared.TestHooks;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;

internal static class TaskExtensions
{
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
public static Task CompletesAsyncOperation(this Task task, VSTypeScriptAsyncToken asyncToken)
#pragma warning restore VSTHRD200
=> task.CompletesAsyncOperation(asyncToken.UnderlyingObject);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 Microsoft.CodeAnalysis.Shared.TestHooks;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;

internal sealed class VSTypeScriptAsyncToken(IAsyncToken underlyingObject) : IDisposable
{
internal IAsyncToken UnderlyingObject
=> underlyingObject;

public void Dispose()
=> UnderlyingObject.Dispose();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.Shared.TestHooks;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;

internal readonly struct VSTypeScriptAsynchronousOperationListener(IAsynchronousOperationListener underlyingObject)
{
public VSTypeScriptAsyncToken BeginAsyncOperation(string name, object? tag = null, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
=> new(underlyingObject.BeginAsyncOperation(name, tag, filePath, lineNumber));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.Composition;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.TestHooks;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;

[Shared]
[Export(typeof(VSTypeScriptAsynchronousOperationListenerProvider))]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class VSTypeScriptAsynchronousOperationListenerProvider(
IAsynchronousOperationListenerProvider provider)
{
public VSTypeScriptAsynchronousOperationListener GetListener(string featureName)
=> new(provider.GetListener(featureName));
Comment on lines +19 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the underlying provider, this means multiple calls for the same featureName will return different instances. Since it's stateless though I presume that's fine...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, should be fine. Usually this is called in a ctor and then the listener is used in the type.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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 Microsoft.CodeAnalysis.Shared.TestHooks;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;

internal static class VSTypeScriptFeatureAttribute
{
public const string RenameTracking = FeatureAttribute.RenameTracking;
public const string Snippets = FeatureAttribute.Snippets;
public const string Workspace = FeatureAttribute.Workspace;
public const string SolutionCrawlerLegacy = FeatureAttribute.SolutionCrawlerLegacy;
}
Loading