From 23ff962beb3fd40f64cba4ddd7d4d7b0bb81a2b3 Mon Sep 17 00:00:00 2001 From: RoslynTeam Date: Fri, 30 Jan 2015 14:52:37 -0800 Subject: [PATCH] Interactive window insertion to VS Build new VSIX which contains just the interactive window Rename interactive window assemblies Include new VSIX in the list of files to be inserted Public API cleanups Move command constants into commands namespace Move operations onto IInteractiveWindowOperations interface move IContentTypeMetadata to internal class Make InteractiveContentTypeNames internal, move constants to InteractiveConstants Make RestoreHistoryEditTag internal Make CommandIds internal Make Guids internal Fix AV when opening interactive window (changeset 1407986) --- .../InteractiveCompletionCommandHandler.cs | 3 +- .../InteractiveIntelliSenseCommandHandler.cs | 3 +- .../Presentation/CompletionPresenter.cs | 3 +- ...activeCommandContentTypeLanguageService.cs | 3 +- .../BasicInteractiveEditorFeatures.vbproj | 10 +- .../Editor/Commands/ClearScreenCommand.cs | 2 +- .../Commands/CommandClassifierProvider.cs | 2 +- .../Commands/InteractiveWindowCommands.cs | 2 +- .../Editor/ContentTypeMetadata.cs | 17 +++ .../Editor/IContentTypeMetadata.cs | 27 ---- .../Editor/IInteractiveWindow.cs | 125 +--------------- .../Editor/InteractiveConstants.cs | 13 -- .../InteractiveContentTypeDefinitions.cs | 14 ++ .../Editor/InteractiveContentTypeNames.cs | 21 --- .../Editor/InteractiveWindow.cs | 134 ++++++++++++++++-- .../Editor/InteractiveWindow.csproj | 14 +- .../Editor/Output/InlineAdornmentProvider.cs | 2 +- .../Editor/Output/OutputClassifierProvider.cs | 2 +- .../PredefinedInteractiveContentTypes.cs | 11 ++ .../SmartIndent/InteractiveSmartIndenter.cs | 8 +- .../InteractiveSmartIndenterProvider.cs | 6 +- .../VisualStudio/CommandIds.cs | 2 +- src/InteractiveWindow/VisualStudio/Guids.cs | 2 +- .../VisualStudioInteractiveWindow.csproj | 11 +- .../VsInteractiveWindowCommandFilter.cs | 54 +++---- ...VsInteractiveWindowEditorFactoryService.cs | 4 +- .../source.extension.vsixmanifest | 23 +++ 27 files changed, 262 insertions(+), 256 deletions(-) create mode 100644 src/InteractiveWindow/Editor/ContentTypeMetadata.cs delete mode 100644 src/InteractiveWindow/Editor/IContentTypeMetadata.cs delete mode 100644 src/InteractiveWindow/Editor/InteractiveConstants.cs create mode 100644 src/InteractiveWindow/Editor/InteractiveContentTypeDefinitions.cs delete mode 100644 src/InteractiveWindow/Editor/InteractiveContentTypeNames.cs create mode 100644 src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs create mode 100644 src/InteractiveWindow/VisualStudio/source.extension.vsixmanifest diff --git a/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs b/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs index 8f9a8fa57be..722d2ea246f 100644 --- a/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs +++ b/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs @@ -3,11 +3,12 @@ using System.ComponentModel.Composition; using Microsoft.VisualStudio.Utilities; using Roslyn.Editor.InteractiveWindow; +using Roslyn.Editor.InteractiveWindow.Commands; namespace Microsoft.CodeAnalysis.Editor.CommandHandlers { [Export] - [ExportCommandHandler(PredefinedCommandHandlerNames.Completion, InteractiveContentTypeNames.InteractiveCommandContentType)] + [ExportCommandHandler(PredefinedCommandHandlerNames.Completion, PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] [Order(After = PredefinedCommandHandlerNames.SignatureHelp)] internal sealed class InteractiveCompletionCommandHandler : AbstractCompletionCommandHandler { diff --git a/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveIntelliSenseCommandHandler.cs b/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveIntelliSenseCommandHandler.cs index f2c329006b8..6cbfa7ce91d 100644 --- a/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveIntelliSenseCommandHandler.cs +++ b/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveIntelliSenseCommandHandler.cs @@ -2,10 +2,11 @@ using System.ComponentModel.Composition; using Roslyn.Editor.InteractiveWindow; +using Roslyn.Editor.InteractiveWindow.Commands; namespace Microsoft.CodeAnalysis.Editor.CommandHandlers { - [ExportCommandHandler(PredefinedCommandHandlerNames.IntelliSense, InteractiveContentTypeNames.InteractiveCommandContentType)] + [ExportCommandHandler(PredefinedCommandHandlerNames.IntelliSense, PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] internal sealed class InteractiveIntelliSenseCommandHandler : AbstractIntelliSenseCommandHandler { [ImportingConstructor] diff --git a/src/Interactive/EditorFeatures/Core/Implementation/Completion/Presentation/CompletionPresenter.cs b/src/Interactive/EditorFeatures/Core/Implementation/Completion/Presentation/CompletionPresenter.cs index 22d986546cf..ef918b0df88 100644 --- a/src/Interactive/EditorFeatures/Core/Implementation/Completion/Presentation/CompletionPresenter.cs +++ b/src/Interactive/EditorFeatures/Core/Implementation/Completion/Presentation/CompletionPresenter.cs @@ -8,12 +8,13 @@ using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Utilities; using Roslyn.Editor.InteractiveWindow; +using Roslyn.Editor.InteractiveWindow.Commands; namespace Microsoft.CodeAnalysis.Editor.Implementation.Completion.Presentation { [Export(typeof(IIntelliSensePresenter))] [Export(typeof(ICompletionSourceProvider))] - [ContentType(InteractiveContentTypeNames.InteractiveCommandContentType)] + [ContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] internal partial class CompletionPresenter : ForegroundThreadAffinitizedObject, IIntelliSensePresenter, ICompletionSourceProvider { private readonly ICompletionBroker _completionBroker; diff --git a/src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveCommandContentTypeLanguageService.cs b/src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveCommandContentTypeLanguageService.cs index 8fedbb69d7a..e8632854637 100644 --- a/src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveCommandContentTypeLanguageService.cs +++ b/src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveCommandContentTypeLanguageService.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis.Interactive; using Microsoft.VisualStudio.Utilities; using Roslyn.Editor.InteractiveWindow; +using Roslyn.Editor.InteractiveWindow.Commands; namespace Microsoft.CodeAnalysis.Editor.Implementation.Interactive { @@ -22,7 +23,7 @@ public InteractiveCommandContentTypeLanguageService(IContentTypeRegistryService public IContentType GetDefaultContentType() { - return _contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveCommandContentType); + return _contentTypeRegistry.GetContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName); } } } diff --git a/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj b/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj index 9b8f17ed907..2654595dd43 100644 --- a/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj +++ b/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj @@ -30,6 +30,10 @@ {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6} BasicCodeAnalysis + + {01e9bd68-0339-4a13-b42f-a3ca84d164f3} + InteractiveWindow + {3E7DEA65-317B-4F43-A25D-62F18D96CFD7} BasicScripting @@ -62,10 +66,6 @@ {8E2A252E-A140-45A6-A81A-2652996EA589} InteractiveFeatures - - {01E9BD68-0339-4A13-B42F-A3CA84D164F3} - InteractiveWindow - {18F5FBB8-7570-4412-8CC7-0A86FF13B7BA} TextEditorFeatures @@ -156,4 +156,4 @@ - + \ No newline at end of file diff --git a/src/InteractiveWindow/Editor/Commands/ClearScreenCommand.cs b/src/InteractiveWindow/Editor/Commands/ClearScreenCommand.cs index 5f233ade83e..2ec72e5a2ee 100644 --- a/src/InteractiveWindow/Editor/Commands/ClearScreenCommand.cs +++ b/src/InteractiveWindow/Editor/Commands/ClearScreenCommand.cs @@ -11,7 +11,7 @@ internal sealed class ClearScreenCommand : InteractiveWindowCommand { public override Task Execute(IInteractiveWindow window, string arguments) { - window.ClearView(); + window.Operations.ClearView(); return ExecutionResult.Succeeded; } diff --git a/src/InteractiveWindow/Editor/Commands/CommandClassifierProvider.cs b/src/InteractiveWindow/Editor/Commands/CommandClassifierProvider.cs index f0354e33bdd..e902baafbea 100644 --- a/src/InteractiveWindow/Editor/Commands/CommandClassifierProvider.cs +++ b/src/InteractiveWindow/Editor/Commands/CommandClassifierProvider.cs @@ -8,7 +8,7 @@ namespace Roslyn.Editor.InteractiveWindow.Commands { [Export(typeof(IClassifierProvider))] - [ContentType(InteractiveContentTypeNames.InteractiveCommandContentType)] + [ContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] [TextViewRole(PredefinedTextViewRoles.Document)] internal sealed class CommandClassifierProvider : IClassifierProvider { diff --git a/src/InteractiveWindow/Editor/Commands/InteractiveWindowCommands.cs b/src/InteractiveWindow/Editor/Commands/InteractiveWindowCommands.cs index 32fdad42d8a..1a7e7a053c8 100644 --- a/src/InteractiveWindow/Editor/Commands/InteractiveWindowCommands.cs +++ b/src/InteractiveWindow/Editor/Commands/InteractiveWindowCommands.cs @@ -60,7 +60,7 @@ internal Commands(IInteractiveWindow window, string prefix, IEnumerable ContentTypes { get; private set; } + + public ContentTypeMetadata(IDictionary data) + { + this.ContentTypes = (IEnumerable)data["ContentTypes"]; + } + } +} diff --git a/src/InteractiveWindow/Editor/IContentTypeMetadata.cs b/src/InteractiveWindow/Editor/IContentTypeMetadata.cs deleted file mode 100644 index e6af65fc457..00000000000 --- a/src/InteractiveWindow/Editor/IContentTypeMetadata.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.Utilities; - -namespace Roslyn.Editor.InteractiveWindow -{ - public interface IContentTypeMetadata - { - IEnumerable ContentTypes { get; } - } - - public static class ContentTypeMetadataHelpers - { - public static T OfContentType( - this IEnumerable> exports, - IContentType contentType, - IContentTypeRegistryService contentTypeRegistry) - { - return (from export in exports - from exportedContentTypeName in export.Metadata.ContentTypes - let exportedContentType = contentTypeRegistry.GetContentType(exportedContentTypeName) - where exportedContentType.IsOfType(contentType.TypeName) - select export.Value).SingleOrDefault(); - } - } -} diff --git a/src/InteractiveWindow/Editor/IInteractiveWindow.cs b/src/InteractiveWindow/Editor/IInteractiveWindow.cs index 937e06e89fa..b02b27bfc53 100644 --- a/src/InteractiveWindow/Editor/IInteractiveWindow.cs +++ b/src/InteractiveWindow/Editor/IInteractiveWindow.cs @@ -55,21 +55,6 @@ IInteractiveEvaluator Evaluator /// Returns a started task that finishes as soon as the initialization completes. Task InitializeAsync(); - /// - /// Clears the REPL window screen. - /// - void ClearView(); - - /// - /// Clears the input history. - /// - void ClearHistory(); - - /// - /// Clears the current input. - /// - void Cancel(); - /// /// Closes the underlying text view. /// @@ -103,11 +88,6 @@ IInteractiveEvaluator Evaluator /// void Submit(IEnumerable inputs); - /// - /// Resets the execution context clearing all variables. - /// - Task ResetAsync(bool initialize = true); - /// /// Aborts the current command which is executing. /// @@ -205,40 +185,6 @@ bool IsResetting get; } - /// - /// Attempts to insert a line break. Returns true if a line break is inserted, false if not. - /// - /// Will not submit the input. - /// - bool BreakLine(); - - /// - /// Handles the user pressing return/enter. - /// - /// If the caret is at the end of an input submits the current input. Otherwise if the caret is - /// in a language buffer it inserts a newline. - /// - /// If not inside of a buffer the caret well be moved to the current language buffer if possible. - /// - /// Returns true if the return was successfully processed. - /// - bool Return(); - - /// - /// Executes the current input regardless of the caret position within the input. - /// - /// If the caret is in a previously executed input then the input is pasted to the - /// end of the current input and not executed. - /// - void ExecuteInput(); - - /// - /// If the current input is a standard input this will submit the input. - /// - /// Returns true if the input was submitted, false otherwise. - /// - bool TrySubmitStandardInput(); - /// /// Appends a input into the editor buffer and history as if it has been executed. /// @@ -246,74 +192,11 @@ bool IsResetting /// void AddLogicalInput(string input); - /// - /// Advances to the next item in history. - /// - void HistoryNext(string search = null); - - /// - /// Advanced to the previous item in history. - /// - void HistoryPrevious(string search = null); - - /// - /// If no search has been performed captures the current input as - /// the search string. Then searches through history for the next - /// match against the current search string. - /// - void HistorySearchNext(); - - /// - /// If no search has been performed captures the current input as - /// the search string. Then searches through history for the previous - /// match against the current search string. - /// - void HistorySearchPrevious(); - - /// - /// Deletes the current selection or the character before the caret. - /// - /// - bool Backspace(); - - /// - /// Moves to the beginning of the line. - /// - /// When in a language buffer the caret is moved to the beginning of the - /// input region not into the prompt region. - /// - /// The caret is moved to the first non-whitespace character. - /// - /// True to extend the selection from the current caret position. - void Home(bool extendSelection); - - /// - /// Moves to the end of the line. - /// - /// True to extend the selection from the current caret position. - void End(bool extendSelection); + IInteractiveWindowOperations Operations + { + get; + } - /// - /// Selects all of the text in the buffer - /// - void SelectAll(); - /// - /// Pastes the current clipboard contents into the interactive window. - /// - /// - bool Paste(); - - /// - /// Cuts the current selection to the clipboard. - /// - void Cut(); - - /// - /// Deletes the current selection. - /// - /// Returns true if the selection was deleted - /// - bool Delete(); } } diff --git a/src/InteractiveWindow/Editor/InteractiveConstants.cs b/src/InteractiveWindow/Editor/InteractiveConstants.cs deleted file mode 100644 index d54368687cc..00000000000 --- a/src/InteractiveWindow/Editor/InteractiveConstants.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.ComponentModel.Composition; -using Microsoft.VisualStudio.Utilities; - -namespace Roslyn.Editor.InteractiveWindow -{ - public static class InteractiveConstants - { - /// - /// The additional role found in any REPL editor window. - /// - public const string InteractiveTextViewRole = "REPL"; - } -} \ No newline at end of file diff --git a/src/InteractiveWindow/Editor/InteractiveContentTypeDefinitions.cs b/src/InteractiveWindow/Editor/InteractiveContentTypeDefinitions.cs new file mode 100644 index 00000000000..f596da1569f --- /dev/null +++ b/src/InteractiveWindow/Editor/InteractiveContentTypeDefinitions.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.Composition; +using Microsoft.VisualStudio.Utilities; + +namespace Roslyn.Editor.InteractiveWindow +{ + internal static class InteractiveContentTypeDefinitions + { + [Export, Name(PredefinedInteractiveContentTypes.InteractiveContentTypeName), BaseDefinition("text"), BaseDefinition("projection")] + internal static readonly ContentTypeDefinition InteractiveContentTypeDefinition; + + [Export, Name(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName), BaseDefinition("text")] + internal static readonly ContentTypeDefinition InteractiveOutputContentTypeDefinition; + } +} \ No newline at end of file diff --git a/src/InteractiveWindow/Editor/InteractiveContentTypeNames.cs b/src/InteractiveWindow/Editor/InteractiveContentTypeNames.cs deleted file mode 100644 index 504a98c293a..00000000000 --- a/src/InteractiveWindow/Editor/InteractiveContentTypeNames.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.ComponentModel.Composition; -using Microsoft.VisualStudio.Utilities; - -namespace Roslyn.Editor.InteractiveWindow -{ - public static class InteractiveContentTypeNames - { - public const string InteractiveContentType = "Roslyn Interactive"; - public const string InteractiveOutputContentType = "Roslyn Interactive Output"; - public const string InteractiveCommandContentType = "Roslyn Interactive Command"; - - [Export, Name(InteractiveContentType), BaseDefinition("text"), BaseDefinition("projection")] - internal static readonly ContentTypeDefinition InteractiveContentTypeDefinition; - - [Export, Name(InteractiveOutputContentType), BaseDefinition("text")] - internal static readonly ContentTypeDefinition InteractiveOutputContentTypeDefinition; - - [Export, Name(InteractiveCommandContentType), BaseDefinition("code")] - internal static readonly ContentTypeDefinition InteractiveCommandContentTypeDefinition; - } -} \ No newline at end of file diff --git a/src/InteractiveWindow/Editor/InteractiveWindow.cs b/src/InteractiveWindow/Editor/InteractiveWindow.cs index 4eb114d0f00..5f09d457511 100644 --- a/src/InteractiveWindow/Editor/InteractiveWindow.cs +++ b/src/InteractiveWindow/Editor/InteractiveWindow.cs @@ -48,6 +48,7 @@ internal class InteractiveWindow : IInteractiveWindow private readonly IWpfTextView textView; private readonly IEditorOperations editorOperations; + private readonly InteractiveOperations interactiveOperations; private readonly History history; private readonly TaskScheduler uiScheduler; @@ -142,6 +143,7 @@ internal class InteractiveWindow : IInteractiveWindow this.host = host; this.Properties = new PropertyCollection(); this.history = new History(); + this.interactiveOperations = new InteractiveOperations(this); this.projectionBufferFactory = projectionBufferFactory; this.bufferFactory = bufferFactory; @@ -152,8 +154,8 @@ internal class InteractiveWindow : IInteractiveWindow this.smartIndenterService = smartIndenterService; var textContentType = contentTypeRegistry.GetContentType("text"); - var replContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveContentType); - var replOutputContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveOutputContentType); + var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); + var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); this.outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); this.stdInputBuffer = bufferFactory.CreateTextBuffer(); @@ -238,7 +240,7 @@ private ITextViewRoleSet CreateRoleSet() PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, - InteractiveConstants.InteractiveTextViewRole); + PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); } public void Close() @@ -1188,6 +1190,14 @@ public bool IsResetting } } + public IInteractiveWindowOperations Operations + { + get + { + return interactiveOperations; + } + } + public bool Delete() { historySearch = null; @@ -1634,7 +1644,7 @@ private string GetActiveCode() /// /// Sets the active code to the specified text w/o executing it. /// - private void SetActiveCode(string text, object editTag = null) + private void SetActiveCode(string text) { // TODO (tomat): this should be handled by the language intellisense provider, not here: var completionSession = this.SessionStack.TopSession; @@ -1643,7 +1653,7 @@ private void SetActiveCode(string text, object editTag = null) completionSession.Dismiss(); } - using (var edit = currentLanguageBuffer.CreateEdit(EditOptions.None, reiteratedVersionNumber: null, editTag: editTag)) + using (var edit = currentLanguageBuffer.CreateEdit(EditOptions.None, reiteratedVersionNumber: null, editTag: null)) { edit.Replace(new Span(0, currentLanguageBuffer.CurrentSnapshot.Length), text); edit.Apply(); @@ -1656,14 +1666,7 @@ private void SetActiveCode(string text, object editTag = null) /// private void SetActiveCodeToHistory(History.Entry entry) { - object editTag = null; - - if (entry.OriginalSpan.HasValue) - { - editTag = new RestoreHistoryEditTag(entry.OriginalSpan.Value); - } - - SetActiveCode(entry.Text, editTag); + SetActiveCode(entry.Text); } /// @@ -3016,5 +3019,110 @@ internal List ProjectionSpans } #endregion + + class InteractiveOperations : IInteractiveWindowOperations + { + private readonly InteractiveWindow window; + + public InteractiveOperations(InteractiveWindow window) + { + this.window = window; + } + + public bool Backspace() + { + return window.Backspace(); + } + + public bool BreakLine() + { + return window.BreakLine(); + } + + public void Cancel() + { + window.Cancel(); + } + + public void ClearHistory() + { + window.ClearHistory(); + } + + public void ClearView() + { + window.ClearView(); + } + + public void Cut() + { + window.Cut(); + } + + public bool Delete() + { + return window.Delete(); + } + + public void End(bool extendSelection) + { + window.End(extendSelection); + } + + public void ExecuteInput() + { + window.ExecuteInput(); + } + + public void HistoryNext(string search = null) + { + window.HistoryNext(search); + } + + public void HistoryPrevious(string search = null) + { + window.HistoryPrevious(search); + } + + public void HistorySearchNext() + { + window.HistorySearchNext(); + } + + public void HistorySearchPrevious() + { + window.HistorySearchPrevious(); + } + + public void Home(bool extendSelection) + { + window.Home(extendSelection); + } + + public bool Paste() + { + return window.Paste(); + } + + public Task ResetAsync(bool initialize = true) + { + return window.ResetAsync(initialize); + } + + public bool Return() + { + return window.Return(); + } + + public void SelectAll() + { + window.SelectAll(); + } + + public bool TrySubmitStandardInput() + { + return window.TrySubmitStandardInput(); + } + } } } diff --git a/src/InteractiveWindow/Editor/InteractiveWindow.csproj b/src/InteractiveWindow/Editor/InteractiveWindow.csproj index 31d14c3c1a9..22a521adfce 100644 --- a/src/InteractiveWindow/Editor/InteractiveWindow.csproj +++ b/src/InteractiveWindow/Editor/InteractiveWindow.csproj @@ -10,7 +10,7 @@ {01E9BD68-0339-4A13-B42F-A3CA84D164F3} Library Roslyn.Editor.InteractiveWindow - Roslyn.InteractiveWindow + Microsoft.VisualStudio.InteractiveWindow ..\..\..\ true @@ -97,6 +97,7 @@ + @@ -106,7 +107,7 @@ - + @@ -114,8 +115,9 @@ - - + + + @@ -132,10 +134,10 @@ + - @@ -157,4 +159,4 @@ - + \ No newline at end of file diff --git a/src/InteractiveWindow/Editor/Output/InlineAdornmentProvider.cs b/src/InteractiveWindow/Editor/Output/InlineAdornmentProvider.cs index bd06ae8caf3..154fd99f827 100644 --- a/src/InteractiveWindow/Editor/Output/InlineAdornmentProvider.cs +++ b/src/InteractiveWindow/Editor/Output/InlineAdornmentProvider.cs @@ -12,7 +12,7 @@ namespace Roslyn.Editor.InteractiveWindow { [Export(typeof(IViewTaggerProvider))] [TagType(typeof(IntraTextAdornmentTag))] - [ContentType(InteractiveContentTypeNames.InteractiveContentType)] + [ContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName)] internal sealed class InlineAdornmentProvider : IViewTaggerProvider { public ITagger CreateTagger(ITextView textView, ITextBuffer buffer) where T : ITag diff --git a/src/InteractiveWindow/Editor/Output/OutputClassifierProvider.cs b/src/InteractiveWindow/Editor/Output/OutputClassifierProvider.cs index ac7adbc2997..bc0f1ea1b59 100644 --- a/src/InteractiveWindow/Editor/Output/OutputClassifierProvider.cs +++ b/src/InteractiveWindow/Editor/Output/OutputClassifierProvider.cs @@ -15,7 +15,7 @@ namespace Roslyn.Editor.InteractiveWindow /// Classifies error text in interactive window output. /// [Export(typeof(IClassifierProvider))] - [ContentType(InteractiveContentTypeNames.InteractiveOutputContentType)] + [ContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName)] [TextViewRole(PredefinedTextViewRoles.Document)] internal sealed class OutputClassifierProvider : IClassifierProvider { diff --git a/src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs b/src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs new file mode 100644 index 00000000000..96b9aef3910 --- /dev/null +++ b/src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.Composition; +using Microsoft.VisualStudio.Utilities; + +namespace Roslyn.Editor.InteractiveWindow +{ + public static class PredefinedInteractiveContentTypes + { + public const string InteractiveContentTypeName = "Interactive Content"; + public const string InteractiveOutputContentTypeName = "Interactive Output"; + } +} \ No newline at end of file diff --git a/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenter.cs b/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenter.cs index 5a98f273f79..5db0579b699 100644 --- a/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenter.cs +++ b/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenter.cs @@ -14,7 +14,7 @@ internal sealed class InteractiveSmartIndenter : ISmartIndent private readonly ISmartIndent indenter; internal static InteractiveSmartIndenter Create( - IEnumerable> smartIndenterProviders, + IEnumerable> smartIndenterProviders, IContentType contentType, ITextView view) { @@ -55,8 +55,8 @@ public void Dispose() // If there are two providers that support the same content type, or // two providers that support different content types that do not have // inheritance relationship, we simply return the first we encounter. - private static Tuple> GetProvider( - IEnumerable> smartIndenterProviders, + private static Tuple> GetProvider( + IEnumerable> smartIndenterProviders, IContentType contentType) { // If there are two providers that both support the @@ -67,7 +67,7 @@ public void Dispose() return Tuple.Create(contentType, provider); } - Tuple> bestPair = null; + Tuple> bestPair = null; foreach (var baseType in contentType.BaseTypes) { var pair = GetProvider(smartIndenterProviders, baseType); diff --git a/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenterProvider.cs b/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenterProvider.cs index d382e4fdf06..8318d432e36 100644 --- a/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenterProvider.cs +++ b/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenterProvider.cs @@ -7,16 +7,16 @@ namespace Roslyn.Editor.InteractiveWindow { [Export(typeof(ISmartIndentProvider))] - [ContentType(InteractiveContentTypeNames.InteractiveContentType)] + [ContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName)] internal class InteractiveSmartIndenterProvider : ISmartIndentProvider { private readonly ITextEditorFactoryService editorFactory; - private readonly IEnumerable> indentProviders; + private readonly IEnumerable> indentProviders; [ImportingConstructor] public InteractiveSmartIndenterProvider( ITextEditorFactoryService editorFactory, - [ImportMany] IEnumerable> indentProviders) + [ImportMany] IEnumerable> indentProviders) { if (editorFactory == null) { diff --git a/src/InteractiveWindow/VisualStudio/CommandIds.cs b/src/InteractiveWindow/VisualStudio/CommandIds.cs index 8f11e35a740..d55f6063ef3 100644 --- a/src/InteractiveWindow/VisualStudio/CommandIds.cs +++ b/src/InteractiveWindow/VisualStudio/CommandIds.cs @@ -2,7 +2,7 @@ namespace Roslyn.VisualStudio.InteractiveWindow { - public enum CommandIds : uint + internal enum CommandIds : uint { // TODO (crwilcox): should all of these be in the editoroperations? SmartExecute = 0x103, diff --git a/src/InteractiveWindow/VisualStudio/Guids.cs b/src/InteractiveWindow/VisualStudio/Guids.cs index eb581071f34..47503961f32 100644 --- a/src/InteractiveWindow/VisualStudio/Guids.cs +++ b/src/InteractiveWindow/VisualStudio/Guids.cs @@ -4,7 +4,7 @@ namespace Roslyn.VisualStudio.InteractiveWindow { - public static class Guids + internal static class Guids { // vsct guids: // This GUID identifies the VsInteractiveWindow type. We need to pass it to VS in a string form. diff --git a/src/InteractiveWindow/VisualStudio/VisualStudioInteractiveWindow.csproj b/src/InteractiveWindow/VisualStudio/VisualStudioInteractiveWindow.csproj index acf9c7e12ce..e57f5bb11d5 100644 --- a/src/InteractiveWindow/VisualStudio/VisualStudioInteractiveWindow.csproj +++ b/src/InteractiveWindow/VisualStudio/VisualStudioInteractiveWindow.csproj @@ -14,11 +14,8 @@ {20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F} Library true - - false - false Microsoft.VisualStudio - Roslyn.VisualStudio.InteractiveWindow + Microsoft.VisualStudio.VsInteractiveWindow Program $(DevEnvDir)devenv.exe /rootsuffix RoslynDev /log @@ -76,6 +73,7 @@ + @@ -94,6 +92,9 @@ True VSInteractiveWindowResources.resx + + Designer + @@ -122,4 +123,4 @@ - + \ No newline at end of file diff --git a/src/InteractiveWindow/VisualStudio/VsInteractiveWindowCommandFilter.cs b/src/InteractiveWindow/VisualStudio/VsInteractiveWindowCommandFilter.cs index 26c008eb0f5..177fb249bb0 100644 --- a/src/InteractiveWindow/VisualStudio/VsInteractiveWindowCommandFilter.cs +++ b/src/InteractiveWindow/VisualStudio/VsInteractiveWindowCommandFilter.cs @@ -158,7 +158,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint switch ((CommandIds)nCmdID) { case CommandIds.BreakLine: - if (_window.BreakLine()) + if (_window.Operations.BreakLine()) { return VSConstants.S_OK; } @@ -170,7 +170,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint switch ((VSConstants.VSStd2KCmdID)nCmdID) { case VSConstants.VSStd2KCmdID.RETURN: - if (_window.Return()) + if (_window.Operations.Return()) { return VSConstants.S_OK; } @@ -182,7 +182,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint // break; case VSConstants.VSStd2KCmdID.BACKSPACE: - if (_window.Backspace()) + if (_window.Operations.Backspace()) { return VSConstants.S_OK; } @@ -193,7 +193,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown) { - _window.HistoryPrevious(); + _window.Operations.HistoryPrevious(); return VSConstants.S_OK; } break; @@ -201,7 +201,7 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint case VSConstants.VSStd2KCmdID.DOWN: if (_window.CurrentLanguageBuffer != null && !_window.IsRunning && CaretAtEnd && UseSmartUpDown) { - _window.HistoryNext(); + _window.Operations.HistoryNext(); return VSConstants.S_OK; } break; @@ -209,24 +209,24 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint case VSConstants.VSStd2KCmdID.CANCEL: if (_window.TextView.Selection.IsEmpty) { - _window.Cancel(); + _window.Operations.Cancel(); } break; case VSConstants.VSStd2KCmdID.BOL: - _window.Home(false); + _window.Operations.Home(false); return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.BOL_EXT: - _window.Home(true); + _window.Operations.Home(true); return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.EOL: - _window.End(false); + _window.Operations.End(false); return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.EOL_EXT: - _window.End(true); + _window.Operations.End(true); return VSConstants.S_OK; } } @@ -236,22 +236,22 @@ private int PreEditorCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint switch ((VSConstants.VSStd97CmdID)nCmdID) { case VSConstants.VSStd97CmdID.Paste: - _window.Paste(); + _window.Operations.Paste(); return VSConstants.S_OK; case VSConstants.VSStd97CmdID.Cut: - _window.Cut(); + _window.Operations.Cut(); return VSConstants.S_OK; case VSConstants.VSStd97CmdID.Delete: - if (_window.Delete()) + if (_window.Operations.Delete()) { return VSConstants.S_OK; } break; case VSConstants.VSStd97CmdID.SelectAll: - _window.SelectAll(); + _window.Operations.SelectAll(); return VSConstants.S_OK; } } @@ -301,11 +301,15 @@ private int PreLanguageCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCm } } - var result = nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); + if (nextTarget != null) + { + var result = nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); #if DUMP_COMMANDS //DumpCmd("QS", result, ref pguidCmdGroup, prgCmds[0].cmdID, prgCmds[0].cmdf); #endif - return result; + return result; + } + return VSConstants.E_FAIL; } private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) @@ -317,16 +321,16 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui switch ((CommandIds)nCmdID) { case CommandIds.AbortExecution: _window.AbortCommand(); return VSConstants.S_OK; - case CommandIds.Reset: _window.ResetAsync(); return VSConstants.S_OK; - case CommandIds.SmartExecute: _window.ExecuteInput(); return VSConstants.S_OK; - case CommandIds.HistoryNext: _window.HistoryNext(); return VSConstants.S_OK; - case CommandIds.HistoryPrevious: _window.HistoryPrevious(); return VSConstants.S_OK; - case CommandIds.ClearScreen: _window.ClearView(); return VSConstants.S_OK; + case CommandIds.Reset: _window.Operations.ResetAsync(); return VSConstants.S_OK; + case CommandIds.SmartExecute: _window.Operations.ExecuteInput(); return VSConstants.S_OK; + case CommandIds.HistoryNext: _window.Operations.HistoryNext(); return VSConstants.S_OK; + case CommandIds.HistoryPrevious: _window.Operations.HistoryPrevious(); return VSConstants.S_OK; + case CommandIds.ClearScreen: _window.Operations.ClearView(); return VSConstants.S_OK; case CommandIds.SearchHistoryNext: - _window.HistorySearchNext(); + _window.Operations.HistorySearchNext(); return VSConstants.S_OK; case CommandIds.SearchHistoryPrevious: - _window.HistorySearchPrevious(); + _window.Operations.HistorySearchPrevious(); return VSConstants.S_OK; } } @@ -335,11 +339,11 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui switch ((VSConstants.VSStd2KCmdID)nCmdID) { case VSConstants.VSStd2KCmdID.TYPECHAR: - _window.Delete(); + _window.Operations.Delete(); break; case VSConstants.VSStd2KCmdID.RETURN: - if (_window.TrySubmitStandardInput()) + if (_window.Operations.TrySubmitStandardInput()) { return VSConstants.S_OK; } diff --git a/src/InteractiveWindow/VisualStudio/VsInteractiveWindowEditorFactoryService.cs b/src/InteractiveWindow/VisualStudio/VsInteractiveWindowEditorFactoryService.cs index d4b28002b95..2c7effc9482 100644 --- a/src/InteractiveWindow/VisualStudio/VsInteractiveWindowEditorFactoryService.cs +++ b/src/InteractiveWindow/VisualStudio/VsInteractiveWindowEditorFactoryService.cs @@ -26,10 +26,10 @@ internal sealed class VsInteractiveWindowEditorFactoryService : IInteractiveWind private readonly IOleServiceProvider _provider; private readonly IVsEditorAdaptersFactoryService _adapterFactory; private readonly IContentTypeRegistryService _contentTypeRegistry; - private readonly IEnumerable> _oleCommandTargetProviders; + private readonly IEnumerable> _oleCommandTargetProviders; [ImportingConstructor] - public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable> oleCommandTargetProviders) + public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable> oleCommandTargetProviders) { _adapterFactory = adaptersFactory; _provider = (IOleServiceProvider)InteractiveWindowPackage.GetGlobalService(typeof(IOleServiceProvider)); diff --git a/src/InteractiveWindow/VisualStudio/source.extension.vsixmanifest b/src/InteractiveWindow/VisualStudio/source.extension.vsixmanifest new file mode 100644 index 00000000000..481442f72a5 --- /dev/null +++ b/src/InteractiveWindow/VisualStudio/source.extension.vsixmanifest @@ -0,0 +1,23 @@ + + + + + VisualStudio Interactive Components + Interactive components for Visual Studio. + + + + + + + + + + + + + + + + + \ No newline at end of file -- GitLab