diff --git a/src/EditorFeatures/Core/ContentTypeNames.cs b/src/EditorFeatures/Core/ContentTypeNames.cs
index 072d9018d2aeacbd0d76809605e9122fe4be5375..b980877273cb37d6352ad9e6bbc4d58845877a8a 100644
--- a/src/EditorFeatures/Core/ContentTypeNames.cs
+++ b/src/EditorFeatures/Core/ContentTypeNames.cs
@@ -10,5 +10,7 @@ internal static class ContentTypeNames
public const string VisualBasicContentType = "Basic";
public const string VisualBasicSignatureHelpContentType = "Basic Signature Help";
public const string XamlContentType = "XAML";
+ public const string JavaScriptContentTypeName = "JavaScript";
+ public const string TypeScriptContentTypeName = "TypeScript";
}
}
diff --git a/src/EditorFeatures/Core/EditorFeatures.csproj b/src/EditorFeatures/Core/EditorFeatures.csproj
index 04b86651a4c44ffb591df573e06270e9bc9951f9..f0b3db7194bc36a87c2af8c6d7348202692cc208 100644
--- a/src/EditorFeatures/Core/EditorFeatures.csproj
+++ b/src/EditorFeatures/Core/EditorFeatures.csproj
@@ -109,6 +109,8 @@
+
+
diff --git a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs
index 43ca3a34f9b61f1f384db67425e8d448a407ab69..a908e385adf98425d62365898e44d04ed918b3fd 100644
--- a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs
+++ b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionCommandHandler.cs
@@ -27,15 +27,21 @@ internal class GoToDefinitionCommandHandler :
public CommandState GetCommandState(GoToDefinitionCommandArgs args, Func nextHandler)
{
- return CommandState.Available;
+ return args.SubjectBuffer.GetFeatureOnOffOption(GoToDefinitionOptions.Enabled)
+ ? CommandState.Available
+ : CommandState.Unavailable;
}
public void ExecuteCommand(GoToDefinitionCommandArgs args, Action nextHandler)
{
- var caretPos = args.TextView.GetCaretPoint(args.SubjectBuffer);
- if (caretPos.HasValue && TryExecuteCommand(args.SubjectBuffer.CurrentSnapshot, caretPos.Value))
+ var subjectBuffer = args.SubjectBuffer;
+ if (subjectBuffer.GetFeatureOnOffOption(GoToDefinitionOptions.Enabled))
{
- return;
+ var caretPos = args.TextView.GetCaretPoint(subjectBuffer);
+ if (caretPos.HasValue && TryExecuteCommand(subjectBuffer.CurrentSnapshot, caretPos.Value))
+ {
+ return;
+ }
}
nextHandler();
diff --git a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionOptions.cs b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionOptions.cs
new file mode 100644
index 0000000000000000000000000000000000000000..6c884f8ca085b328d48d5458fdd5568d0711cf2b
--- /dev/null
+++ b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionOptions.cs
@@ -0,0 +1,12 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Microsoft.CodeAnalysis.Options;
+
+namespace Microsoft.CodeAnalysis.Editor
+{
+ internal static class GoToDefinitionOptions
+ {
+ public static readonly PerLanguageOption Enabled = new PerLanguageOption(
+ nameof(GoToDefinitionOptions), nameof(Enabled), defaultValue: true);
+ }
+}
diff --git a/src/EditorFeatures/Core/GoToDefinition/IGoToDefinitionService.cs b/src/EditorFeatures/Core/GoToDefinition/IGoToDefinitionService.cs
index a8fda42a08a4bc91a70090b29748be94d005f949..2afa5b41f2f73e2ac31ca6aa0fba9cea699917a4 100644
--- a/src/EditorFeatures/Core/GoToDefinition/IGoToDefinitionService.cs
+++ b/src/EditorFeatures/Core/GoToDefinition/IGoToDefinitionService.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Navigation;
+using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.Editor
{
diff --git a/src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs b/src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs
index 29f937a1e35d2532c76ccc959336f4b3608eb3c3..06be7cb45a28f1be8f89ff79e96c8b732ba94a6c 100644
--- a/src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs
+++ b/src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs
@@ -34,21 +34,27 @@ internal partial class GoToImplementationCommandHandler : ICommandHandler nextHandler)
{
- // Because this is expensive to compute, we just always say yes
- return CommandState.Available;
+ // Because this is expensive to compute, we just always say yes as long as the language allows it.
+ return args.SubjectBuffer.GetFeatureOnOffOption(GoToImplementationOptions.Enabled)
+ ? CommandState.Available
+ : CommandState.Unavailable;
}
public void ExecuteCommand(GoToImplementationCommandArgs args, Action nextHandler)
{
- var caret = args.TextView.GetCaretPoint(args.SubjectBuffer);
+ var subjectBuffer = args.SubjectBuffer;
- if (caret.HasValue)
+ if (subjectBuffer.GetFeatureOnOffOption(GoToImplementationOptions.Enabled))
{
- var document = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
- if (document != null)
+ var caret = args.TextView.GetCaretPoint(subjectBuffer);
+ if (caret.HasValue)
{
- ExecuteCommand(document, caret.Value);
- return;
+ var document = subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
+ if (document != null)
+ {
+ ExecuteCommand(document, caret.Value);
+ return;
+ }
}
}
diff --git a/src/EditorFeatures/Core/GoToImplementation/GoToImplementationOptions.cs b/src/EditorFeatures/Core/GoToImplementation/GoToImplementationOptions.cs
new file mode 100644
index 0000000000000000000000000000000000000000..1a23fa2fc012e447943b9e95662d92ad8b80273e
--- /dev/null
+++ b/src/EditorFeatures/Core/GoToImplementation/GoToImplementationOptions.cs
@@ -0,0 +1,12 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Microsoft.CodeAnalysis.Options;
+
+namespace Microsoft.CodeAnalysis.Editor.GoToImplementation
+{
+ internal static class GoToImplementationOptions
+ {
+ public static readonly PerLanguageOption Enabled = new PerLanguageOption(
+ nameof(GoToImplementationOptions), nameof(Enabled), defaultValue: true);
+ }
+}
\ No newline at end of file
diff --git a/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs b/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs
index 7efe5916a92e46b4bdaeb0448d0206d59e529e2d..c95e484ece43d7455072005ec5efe254047b7a61 100644
--- a/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs
+++ b/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs
@@ -36,7 +36,10 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Suggestions
[Export(typeof(ISuggestedActionsSourceProvider))]
[Export(typeof(SuggestedActionsSourceProvider))]
- [VisualStudio.Utilities.ContentType(ContentTypeNames.RoslynContentType)]
+ [VisualStudio.Utilities.ContentType(ContentTypeNames.CSharpContentType)]
+ [VisualStudio.Utilities.ContentType(ContentTypeNames.VisualBasicContentType)]
+ [VisualStudio.Utilities.ContentType(ContentTypeNames.JavaScriptContentTypeName)]
+ [VisualStudio.Utilities.ContentType(ContentTypeNames.TypeScriptContentTypeName)]
[VisualStudio.Utilities.ContentType(ContentTypeNames.XamlContentType)]
[VisualStudio.Utilities.Name("Roslyn Code Fix")]
[VisualStudio.Utilities.Order]