From 3988815f83e111e9cf9917506c4c25aa4ce7a781 Mon Sep 17 00:00:00 2001 From: manishv Date: Fri, 30 Jan 2015 14:14:10 -0800 Subject: [PATCH] Rollback changeset 1407857 to fix the build break. (changeset 1407952) --- .../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 +- ...edefinedInteractiveCommandsContentTypes.cs | 19 --- .../Editor/ContentTypeMetadata.cs | 17 --- .../IContentTypeMetadata.cs} | 20 +-- .../Editor/IInteractiveWindow.cs | 125 +++++++++++++++- .../Editor/IInteractiveWindowOperations.cs | 135 ------------------ ...xtViewRoles.cs => InteractiveConstants.cs} | 11 +- .../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 --- 29 files changed, 226 insertions(+), 437 deletions(-) delete mode 100644 src/InteractiveWindow/Editor/Commands/PredefinedInteractiveCommandsContentTypes.cs delete mode 100644 src/InteractiveWindow/Editor/ContentTypeMetadata.cs rename src/InteractiveWindow/{VisualStudio/ContentTypeMetadata.cs => Editor/IContentTypeMetadata.cs} (54%) delete mode 100644 src/InteractiveWindow/Editor/IInteractiveWindowOperations.cs rename src/InteractiveWindow/Editor/{PredefinedInteractiveTextViewRoles.cs => InteractiveConstants.cs} (55%) delete mode 100644 src/InteractiveWindow/Editor/InteractiveContentTypeDefinitions.cs create mode 100644 src/InteractiveWindow/Editor/InteractiveContentTypeNames.cs delete mode 100644 src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs delete 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 722d2ea246f..8f9a8fa57be 100644 --- a/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs +++ b/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveCompletionCommandHandler.cs @@ -3,12 +3,11 @@ 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, PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] + [ExportCommandHandler(PredefinedCommandHandlerNames.Completion, InteractiveContentTypeNames.InteractiveCommandContentType)] [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 6cbfa7ce91d..f2c329006b8 100644 --- a/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveIntelliSenseCommandHandler.cs +++ b/src/Interactive/EditorFeatures/Core/CommandHandlers/InteractiveIntelliSenseCommandHandler.cs @@ -2,11 +2,10 @@ using System.ComponentModel.Composition; using Roslyn.Editor.InteractiveWindow; -using Roslyn.Editor.InteractiveWindow.Commands; namespace Microsoft.CodeAnalysis.Editor.CommandHandlers { - [ExportCommandHandler(PredefinedCommandHandlerNames.IntelliSense, PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] + [ExportCommandHandler(PredefinedCommandHandlerNames.IntelliSense, InteractiveContentTypeNames.InteractiveCommandContentType)] 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 ef918b0df88..22d986546cf 100644 --- a/src/Interactive/EditorFeatures/Core/Implementation/Completion/Presentation/CompletionPresenter.cs +++ b/src/Interactive/EditorFeatures/Core/Implementation/Completion/Presentation/CompletionPresenter.cs @@ -8,13 +8,12 @@ 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(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] + [ContentType(InteractiveContentTypeNames.InteractiveCommandContentType)] 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 e8632854637..8fedbb69d7a 100644 --- a/src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveCommandContentTypeLanguageService.cs +++ b/src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveCommandContentTypeLanguageService.cs @@ -6,7 +6,6 @@ using Microsoft.CodeAnalysis.Interactive; using Microsoft.VisualStudio.Utilities; using Roslyn.Editor.InteractiveWindow; -using Roslyn.Editor.InteractiveWindow.Commands; namespace Microsoft.CodeAnalysis.Editor.Implementation.Interactive { @@ -23,7 +22,7 @@ public InteractiveCommandContentTypeLanguageService(IContentTypeRegistryService public IContentType GetDefaultContentType() { - return _contentTypeRegistry.GetContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName); + return _contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveCommandContentType); } } } diff --git a/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj b/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj index 2654595dd43..9b8f17ed907 100644 --- a/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj +++ b/src/Interactive/EditorFeatures/VisualBasic/BasicInteractiveEditorFeatures.vbproj @@ -30,10 +30,6 @@ {2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6} BasicCodeAnalysis - - {01e9bd68-0339-4a13-b42f-a3ca84d164f3} - InteractiveWindow - {3E7DEA65-317B-4F43-A25D-62F18D96CFD7} BasicScripting @@ -66,6 +62,10 @@ {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 2ec72e5a2ee..5f233ade83e 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.Operations.ClearView(); + window.ClearView(); return ExecutionResult.Succeeded; } diff --git a/src/InteractiveWindow/Editor/Commands/CommandClassifierProvider.cs b/src/InteractiveWindow/Editor/Commands/CommandClassifierProvider.cs index e902baafbea..f0354e33bdd 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(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] + [ContentType(InteractiveContentTypeNames.InteractiveCommandContentType)] [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 1a7e7a053c8..32fdad42d8a 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/VisualStudio/ContentTypeMetadata.cs b/src/InteractiveWindow/Editor/IContentTypeMetadata.cs similarity index 54% rename from src/InteractiveWindow/VisualStudio/ContentTypeMetadata.cs rename to src/InteractiveWindow/Editor/IContentTypeMetadata.cs index 8d8aabf8abb..e6af65fc457 100644 --- a/src/InteractiveWindow/VisualStudio/ContentTypeMetadata.cs +++ b/src/InteractiveWindow/Editor/IContentTypeMetadata.cs @@ -1,27 +1,19 @@ -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 Microsoft.VisualStudio +namespace Roslyn.Editor.InteractiveWindow { - internal class ContentTypeMetadata + public interface IContentTypeMetadata { - public IEnumerable ContentTypes { get; private set; } - - public ContentTypeMetadata(IDictionary data) - { - this.ContentTypes = (IEnumerable)data["ContentTypes"]; - } + IEnumerable ContentTypes { get; } } - internal static class ContentTypeMetadataHelpers + public static class ContentTypeMetadataHelpers { public static T OfContentType( - this IEnumerable> exports, + this IEnumerable> exports, IContentType contentType, IContentTypeRegistryService contentTypeRegistry) { diff --git a/src/InteractiveWindow/Editor/IInteractiveWindow.cs b/src/InteractiveWindow/Editor/IInteractiveWindow.cs index b02b27bfc53..937e06e89fa 100644 --- a/src/InteractiveWindow/Editor/IInteractiveWindow.cs +++ b/src/InteractiveWindow/Editor/IInteractiveWindow.cs @@ -55,6 +55,21 @@ 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. /// @@ -88,6 +103,11 @@ 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. /// @@ -185,6 +205,40 @@ 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. /// @@ -192,11 +246,74 @@ bool IsResetting /// void AddLogicalInput(string input); - IInteractiveWindowOperations Operations - { - get; - } + /// + /// 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); + + /// + /// 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 deleted file mode 100644 index 6b002582b89..00000000000 --- a/src/InteractiveWindow/Editor/IInteractiveWindowOperations.cs +++ /dev/null @@ -1,135 +0,0 @@ -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/PredefinedInteractiveTextViewRoles.cs b/src/InteractiveWindow/Editor/InteractiveConstants.cs similarity index 55% rename from src/InteractiveWindow/Editor/PredefinedInteractiveTextViewRoles.cs rename to src/InteractiveWindow/Editor/InteractiveConstants.cs index 3fd30baa359..d54368687cc 100644 --- a/src/InteractiveWindow/Editor/PredefinedInteractiveTextViewRoles.cs +++ b/src/InteractiveWindow/Editor/InteractiveConstants.cs @@ -1,16 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel.Composition; +using Microsoft.VisualStudio.Utilities; namespace Roslyn.Editor.InteractiveWindow { - public static class PredefinedInteractiveTextViewRoles + 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 deleted file mode 100644 index f596da1569f..00000000000 --- a/src/InteractiveWindow/Editor/InteractiveContentTypeDefinitions.cs +++ /dev/null @@ -1,14 +0,0 @@ -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 new file mode 100644 index 00000000000..504a98c293a --- /dev/null +++ b/src/InteractiveWindow/Editor/InteractiveContentTypeNames.cs @@ -0,0 +1,21 @@ +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 5f09d457511..4eb114d0f00 100644 --- a/src/InteractiveWindow/Editor/InteractiveWindow.cs +++ b/src/InteractiveWindow/Editor/InteractiveWindow.cs @@ -48,7 +48,6 @@ internal class InteractiveWindow : IInteractiveWindow private readonly IWpfTextView textView; private readonly IEditorOperations editorOperations; - private readonly InteractiveOperations interactiveOperations; private readonly History history; private readonly TaskScheduler uiScheduler; @@ -143,7 +142,6 @@ 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; @@ -154,8 +152,8 @@ internal class InteractiveWindow : IInteractiveWindow this.smartIndenterService = smartIndenterService; var textContentType = contentTypeRegistry.GetContentType("text"); - var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); - var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); + var replContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveContentType); + var replOutputContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveOutputContentType); this.outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); this.stdInputBuffer = bufferFactory.CreateTextBuffer(); @@ -240,7 +238,7 @@ private ITextViewRoleSet CreateRoleSet() PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, - PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); + InteractiveConstants.InteractiveTextViewRole); } public void Close() @@ -1190,14 +1188,6 @@ public bool IsResetting } } - public IInteractiveWindowOperations Operations - { - get - { - return interactiveOperations; - } - } - public bool Delete() { historySearch = null; @@ -1644,7 +1634,7 @@ private string GetActiveCode() /// /// Sets the active code to the specified text w/o executing it. /// - private void SetActiveCode(string text) + private void SetActiveCode(string text, object editTag = null) { // TODO (tomat): this should be handled by the language intellisense provider, not here: var completionSession = this.SessionStack.TopSession; @@ -1653,7 +1643,7 @@ private void SetActiveCode(string text) completionSession.Dismiss(); } - using (var edit = currentLanguageBuffer.CreateEdit(EditOptions.None, reiteratedVersionNumber: null, editTag: null)) + using (var edit = currentLanguageBuffer.CreateEdit(EditOptions.None, reiteratedVersionNumber: null, editTag: editTag)) { edit.Replace(new Span(0, currentLanguageBuffer.CurrentSnapshot.Length), text); edit.Apply(); @@ -1666,7 +1656,14 @@ private void SetActiveCode(string text) /// private void SetActiveCodeToHistory(History.Entry entry) { - SetActiveCode(entry.Text); + object editTag = null; + + if (entry.OriginalSpan.HasValue) + { + editTag = new RestoreHistoryEditTag(entry.OriginalSpan.Value); + } + + SetActiveCode(entry.Text, editTag); } /// @@ -3019,110 +3016,5 @@ 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 22a521adfce..31d14c3c1a9 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 - Microsoft.VisualStudio.InteractiveWindow + Roslyn.InteractiveWindow ..\..\..\ true @@ -97,7 +97,6 @@ - @@ -107,7 +106,7 @@ - + @@ -115,9 +114,8 @@ - - - + + @@ -134,10 +132,10 @@ - + @@ -159,4 +157,4 @@ - \ No newline at end of file + diff --git a/src/InteractiveWindow/Editor/Output/InlineAdornmentProvider.cs b/src/InteractiveWindow/Editor/Output/InlineAdornmentProvider.cs index 154fd99f827..bd06ae8caf3 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(PredefinedInteractiveContentTypes.InteractiveContentTypeName)] + [ContentType(InteractiveContentTypeNames.InteractiveContentType)] 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 bc0f1ea1b59..ac7adbc2997 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(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName)] + [ContentType(InteractiveContentTypeNames.InteractiveOutputContentType)] [TextViewRole(PredefinedTextViewRoles.Document)] internal sealed class OutputClassifierProvider : IClassifierProvider { diff --git a/src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs b/src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs deleted file mode 100644 index 96b9aef3910..00000000000 --- a/src/InteractiveWindow/Editor/PredefinedInteractiveContentTypes.cs +++ /dev/null @@ -1,11 +0,0 @@ -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 5db0579b699..5a98f273f79 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 8318d432e36..d382e4fdf06 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(PredefinedInteractiveContentTypes.InteractiveContentTypeName)] + [ContentType(InteractiveContentTypeNames.InteractiveContentType)] 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 d55f6063ef3..8f11e35a740 100644 --- a/src/InteractiveWindow/VisualStudio/CommandIds.cs +++ b/src/InteractiveWindow/VisualStudio/CommandIds.cs @@ -2,7 +2,7 @@ namespace Roslyn.VisualStudio.InteractiveWindow { - internal enum CommandIds : uint + public 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 47503961f32..eb581071f34 100644 --- a/src/InteractiveWindow/VisualStudio/Guids.cs +++ b/src/InteractiveWindow/VisualStudio/Guids.cs @@ -4,7 +4,7 @@ namespace Roslyn.VisualStudio.InteractiveWindow { - internal static class Guids + public 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 e57f5bb11d5..acf9c7e12ce 100644 --- a/src/InteractiveWindow/VisualStudio/VisualStudioInteractiveWindow.csproj +++ b/src/InteractiveWindow/VisualStudio/VisualStudioInteractiveWindow.csproj @@ -14,8 +14,11 @@ {20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F} Library true + + false + false Microsoft.VisualStudio - Microsoft.VisualStudio.VsInteractiveWindow + Roslyn.VisualStudio.InteractiveWindow Program $(DevEnvDir)devenv.exe /rootsuffix RoslynDev /log @@ -73,7 +76,6 @@ - @@ -92,9 +94,6 @@ True VSInteractiveWindowResources.resx - - Designer - @@ -123,4 +122,4 @@ - \ No newline at end of file + diff --git a/src/InteractiveWindow/VisualStudio/VsInteractiveWindowCommandFilter.cs b/src/InteractiveWindow/VisualStudio/VsInteractiveWindowCommandFilter.cs index 177fb249bb0..26c008eb0f5 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.Operations.BreakLine()) + if (_window.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.Operations.Return()) + if (_window.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.Operations.Backspace()) + if (_window.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.Operations.HistoryPrevious(); + _window.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.Operations.HistoryNext(); + _window.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.Operations.Cancel(); + _window.Cancel(); } break; case VSConstants.VSStd2KCmdID.BOL: - _window.Operations.Home(false); + _window.Home(false); return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.BOL_EXT: - _window.Operations.Home(true); + _window.Home(true); return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.EOL: - _window.Operations.End(false); + _window.End(false); return VSConstants.S_OK; case VSConstants.VSStd2KCmdID.EOL_EXT: - _window.Operations.End(true); + _window.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.Operations.Paste(); + _window.Paste(); return VSConstants.S_OK; case VSConstants.VSStd97CmdID.Cut: - _window.Operations.Cut(); + _window.Cut(); return VSConstants.S_OK; case VSConstants.VSStd97CmdID.Delete: - if (_window.Operations.Delete()) + if (_window.Delete()) { return VSConstants.S_OK; } break; case VSConstants.VSStd97CmdID.SelectAll: - _window.Operations.SelectAll(); + _window.SelectAll(); return VSConstants.S_OK; } } @@ -301,15 +301,11 @@ private int PreLanguageCommandFilterQueryStatus(ref Guid pguidCmdGroup, uint cCm } } - if (nextTarget != null) - { - var result = nextTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); + 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 VSConstants.E_FAIL; + return result; } private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) @@ -321,16 +317,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.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.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.SearchHistoryNext: - _window.Operations.HistorySearchNext(); + _window.HistorySearchNext(); return VSConstants.S_OK; case CommandIds.SearchHistoryPrevious: - _window.Operations.HistorySearchPrevious(); + _window.HistorySearchPrevious(); return VSConstants.S_OK; } } @@ -339,11 +335,11 @@ private int PreLanguageCommandFilterExec(ref Guid pguidCmdGroup, uint nCmdID, ui switch ((VSConstants.VSStd2KCmdID)nCmdID) { case VSConstants.VSStd2KCmdID.TYPECHAR: - _window.Operations.Delete(); + _window.Delete(); break; case VSConstants.VSStd2KCmdID.RETURN: - if (_window.Operations.TrySubmitStandardInput()) + if (_window.TrySubmitStandardInput()) { return VSConstants.S_OK; } diff --git a/src/InteractiveWindow/VisualStudio/VsInteractiveWindowEditorFactoryService.cs b/src/InteractiveWindow/VisualStudio/VsInteractiveWindowEditorFactoryService.cs index 2c7effc9482..d4b28002b95 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 deleted file mode 100644 index 481442f72a5..00000000000 --- a/src/InteractiveWindow/VisualStudio/source.extension.vsixmanifest +++ /dev/null @@ -1,23 +0,0 @@ - - - - - VisualStudio Interactive Components - Interactive components for Visual Studio. - - - - - - - - - - - - - - - - - \ No newline at end of file -- GitLab