diff --git a/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs b/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs index 8f9a8fa57be5aedfc63958e2addac48aeedefb56..722d2ea246f5e8afb75026cc3b551bb87f01de11 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 f2c329006b822a386689d9334eda5e8f810cc3a0..6cbfa7ce91d9b83d10bc72f74a8716ad00118081 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 22d986546cf056e43fc233f5aeadb2db42af1ddc..ef918b0df88be92ebdc30aaf2bdaccf0a233cab1 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 8fedbb69d7a34b22a2b4999379cc22b56c39d8e1..e8632854637a5b9d4d17cbf4da7b26f7997267e8 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 9b8f17ed90757ee9312271b592ef0372ca59e956..2654595dd430c45a6026c15340951872ca808627 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 5f233ade83e1095e7c476289ea17c42406bb9d25..2ec72e5a2eefc8e25a8b69c996a7904c69844443 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 f0354e33bdd3b556b3bef2d4da3311743095e522..e902baafbeaa16246813ed9994b073cb8d8b234b 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 32fdad42d8a7b4f9808bff5a74807d5e952a221c..1a7e7a053c83d4c5e2e84ab04933ee9cf26768ac 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/IInteractiveWindow.cs b/src/InteractiveWindow/Editor/IInteractiveWindow.cs index 937e06e89fa625d617b5a5eacb2fb4c043036c11..b02b27bfc5313937b021ae16fb9eb8213d941aab 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/IInteractiveWindowOperations.cs b/src/InteractiveWindow/Editor/IInteractiveWindowOperations.cs new file mode 100644 index 0000000000000000000000000000000000000000..6b002582b8993b0be008af9213ababb24c852ea1 --- /dev/null +++ b/src/InteractiveWindow/Editor/IInteractiveWindowOperations.cs @@ -0,0 +1,135 @@ +using System.Threading.Tasks; + +namespace Roslyn.Editor.InteractiveWindow +{ + /// + /// Provides access to low level editor operations on the REPL window. + /// + public interface IInteractiveWindowOperations + { + /// + /// Deletes the current selection or the character before the caret. + /// + /// + bool Backspace(); + + /// + /// Attempts to insert a line break. Returns true if a line break is inserted, false if not. + /// + /// Will not submit the input. + /// + bool BreakLine(); + + /// + /// Clears the input history. + /// + void ClearHistory(); + + /// + /// Clears the REPL window screen. + /// + void ClearView(); + + /// + /// 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(); + + /// + /// 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); + + /// + /// 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(); + + /// + /// 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(); + + /// + /// If the current input is a standard input this will submit the input. + /// + /// Returns true if the input was submitted, false otherwise. + /// + bool TrySubmitStandardInput(); + + /// + /// Resets the execution context clearing all variables. + /// + Task ResetAsync(bool initialize = true); + + + /// + /// 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(); + + /// + /// Clears the current input. + /// + void Cancel(); + } +} \ 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 0000000000000000000000000000000000000000..f596da1569f99831fc05545bdd823e192c029b42 --- /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 504a98c293a98522cfd9dd4fb11c840e4dea57d0..0000000000000000000000000000000000000000 --- 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 4eb114d0f007a61e6a391c4b23b8e09c0df61a3a..5f09d457511444e14b891aafda728460c597c317 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 31d14c3c1a9c14a57ff2e68b56cac9a571fc4b26..22a521adfce165b670f5eabf980dcd3255082e53 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 bd06ae8caf3e7cb19ac04ee0b1bb61c055904fbe..154fd99f827b0b82f6e93c22e84ff5f76b25af6a 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 ac7adbc2997f89b29464335acaa4c668b7a30646..bc0f1ea1b59f1cb71112263eed310eb0f5a95c3e 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 0000000000000000000000000000000000000000..96b9aef3910fae951f92582e789be6c69aac2cf3 --- /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/InteractiveConstants.cs b/src/InteractiveWindow/Editor/PredefinedInteractiveTextViewRoles.cs similarity index 55% rename from src/InteractiveWindow/Editor/InteractiveConstants.cs rename to src/InteractiveWindow/Editor/PredefinedInteractiveTextViewRoles.cs index d54368687cc514d621bde8e35c409374860ed91c..3fd30baa359b31ab3c6ed090c62c737f4e6e3c71 100644 --- a/src/InteractiveWindow/Editor/InteractiveConstants.cs +++ b/src/InteractiveWindow/Editor/PredefinedInteractiveTextViewRoles.cs @@ -1,13 +1,16 @@ -using System.ComponentModel.Composition; -using Microsoft.VisualStudio.Utilities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace Roslyn.Editor.InteractiveWindow { - public static class InteractiveConstants + public static class PredefinedInteractiveTextViewRoles { /// /// 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/RestoreHistoryEditTag.cs b/src/InteractiveWindow/Editor/RestoreHistoryEditTag.cs deleted file mode 100644 index 972c908772a822b1a578354073b33320465e2203..0000000000000000000000000000000000000000 --- a/src/InteractiveWindow/Editor/RestoreHistoryEditTag.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.VisualStudio.Text; - -namespace Roslyn.Editor.InteractiveWindow -{ - public sealed class RestoreHistoryEditTag - { - /// - /// The original submission where this history item is from. - /// - public SnapshotSpan OriginalSpan { get; private set; } - - internal RestoreHistoryEditTag(SnapshotSpan originalSpan) - { - OriginalSpan = originalSpan; - } - } -} diff --git a/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenter.cs b/src/InteractiveWindow/Editor/SmartIndent/InteractiveSmartIndenter.cs index 5a98f273f79523cd082cbf2915aadc0eda748f15..5db0579b69976ca974582ec8a38abd323b0f20ed 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 d382e4fdf06f35fdee2b2826f09c2b96f1ebd866..8318d432e368d1655800e41066beac08e96cbdbf 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 8f11e35a740c90dd8d21b3e0803988ebeb32d548..d55f6063ef3d72fbafc329925db8551e30b22c4d 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/Editor/IContentTypeMetadata.cs b/src/InteractiveWindow/VisualStudio/ContentTypeMetadata.cs similarity index 54% rename from src/InteractiveWindow/Editor/IContentTypeMetadata.cs rename to src/InteractiveWindow/VisualStudio/ContentTypeMetadata.cs index e6af65fc4579edeaaa46615af22180c323fe9567..8d8aabf8abbdc111e8e05c55790cb1220b6e7dfb 100644 --- a/src/InteractiveWindow/Editor/IContentTypeMetadata.cs +++ b/src/InteractiveWindow/VisualStudio/ContentTypeMetadata.cs @@ -1,19 +1,27 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; +using System.Text; +using System.Threading.Tasks; using Microsoft.VisualStudio.Utilities; +using Roslyn.Editor.InteractiveWindow; -namespace Roslyn.Editor.InteractiveWindow +namespace Microsoft.VisualStudio { - public interface IContentTypeMetadata + internal class ContentTypeMetadata { - IEnumerable ContentTypes { get; } + public IEnumerable ContentTypes { get; private set; } + + public ContentTypeMetadata(IDictionary data) + { + this.ContentTypes = (IEnumerable)data["ContentTypes"]; + } } - public static class ContentTypeMetadataHelpers + internal static class ContentTypeMetadataHelpers { public static T OfContentType( - this IEnumerable> exports, + this IEnumerable> exports, IContentType contentType, IContentTypeRegistryService contentTypeRegistry) { diff --git a/src/InteractiveWindow/VisualStudio/Guids.cs b/src/InteractiveWindow/VisualStudio/Guids.cs index eb581071f34e1042503b5bd55774b39d32980a4f..47503961f32317f84367ce8ab59ae3a8b2987a73 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 acf9c7e12ce00238ebe7ccbfb7348a6ccf231c27..e57f5bb11d5748efa094a3d2dc90e979d2f400a8 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 26c008eb0f5f8f712c79bdc2ad951674ee13015c..177fb249bb0a20976f643b178a1154729a1374ea 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 d4b28002b9501d6d91df54e63bf78db8afd99e5c..2c7effc9482f03f01b695a39fbcf5a50c107808b 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 0000000000000000000000000000000000000000..481442f72a5d3c7113a4ea148e18253d7c718249 --- /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