提交 8e667daf 编写于 作者: R RoslynTeam

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 1408072)
上级 c3beadd7
......@@ -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
{
......
......@@ -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]
......
......@@ -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<ICompletionPresenterSession, ICompletionSession>))]
[Export(typeof(ICompletionSourceProvider))]
[ContentType(InteractiveContentTypeNames.InteractiveCommandContentType)]
[ContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)]
internal partial class CompletionPresenter : ForegroundThreadAffinitizedObject, IIntelliSensePresenter<ICompletionPresenterSession, ICompletionSession>, ICompletionSourceProvider
{
private readonly ICompletionBroker _completionBroker;
......
......@@ -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);
}
}
}
......@@ -30,6 +30,10 @@
<Project>{2523D0E6-DF32-4A3E-8AE0-A19BFFAE2EF6}</Project>
<Name>BasicCodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\InteractiveWindow\Editor\InteractiveWindow.csproj">
<Project>{01e9bd68-0339-4a13-b42f-a3ca84d164f3}</Project>
<Name>InteractiveWindow</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Scripting\VisualBasic\BasicScripting.vbproj">
<Project>{3E7DEA65-317B-4F43-A25D-62F18D96CFD7}</Project>
<Name>BasicScripting</Name>
......@@ -62,10 +66,6 @@
<Project>{8E2A252E-A140-45A6-A81A-2652996EA589}</Project>
<Name>InteractiveFeatures</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\InteractiveWindow\Editor\InteractiveWindow.csproj">
<Project>{01E9BD68-0339-4A13-B42F-A3CA84D164F3}</Project>
<Name>InteractiveWindow</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\EditorFeatures\Text\TextEditorFeatures.csproj">
<Project>{18F5FBB8-7570-4412-8CC7-0A86FF13B7BA}</Project>
<Name>TextEditorFeatures</Name>
......@@ -156,4 +156,4 @@
<Import Project="..\..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -11,7 +11,7 @@ internal sealed class ClearScreenCommand : InteractiveWindowCommand
{
public override Task<ExecutionResult> Execute(IInteractiveWindow window, string arguments)
{
window.ClearView();
window.Operations.ClearView();
return ExecutionResult.Succeeded;
}
......
......@@ -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
{
......
......@@ -60,7 +60,7 @@ internal Commands(IInteractiveWindow window, string prefix, IEnumerable<IInterac
this.classificationRegistry = classificationRegistry;
if (contentTypeRegistry != null)
{
this.commandContentType = contentTypeRegistry.GetContentType(InteractiveContentTypeNames.InteractiveCommandContentType);
this.commandContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName);
}
if (window != null)
......
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Utilities;
namespace Roslyn.Editor.InteractiveWindow
{
internal class ContentTypeMetadata
{
public IEnumerable<string> ContentTypes { get; private set; }
public ContentTypeMetadata(IDictionary<string, object> data)
{
this.ContentTypes = (IEnumerable<string>)data["ContentTypes"];
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Utilities;
namespace Roslyn.Editor.InteractiveWindow
{
public interface IContentTypeMetadata
{
IEnumerable<string> ContentTypes { get; }
}
public static class ContentTypeMetadataHelpers
{
public static T OfContentType<T>(
this IEnumerable<Lazy<T, IContentTypeMetadata>> 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();
}
}
}
......@@ -55,21 +55,6 @@ IInteractiveEvaluator Evaluator
/// <returns>Returns a started task that finishes as soon as the initialization completes.</returns>
Task<ExecutionResult> InitializeAsync();
/// <summary>
/// Clears the REPL window screen.
/// </summary>
void ClearView();
/// <summary>
/// Clears the input history.
/// </summary>
void ClearHistory();
/// <summary>
/// Clears the current input.
/// </summary>
void Cancel();
/// <summary>
/// Closes the underlying text view.
/// </summary>
......@@ -103,11 +88,6 @@ IInteractiveEvaluator Evaluator
/// </remarks>
void Submit(IEnumerable<string> inputs);
/// <summary>
/// Resets the execution context clearing all variables.
/// </summary>
Task<ExecutionResult> ResetAsync(bool initialize = true);
/// <summary>
/// Aborts the current command which is executing.
///
......@@ -205,40 +185,6 @@ bool IsResetting
get;
}
/// <summary>
/// Attempts to insert a line break. Returns true if a line break is inserted, false if not.
///
/// Will not submit the input.
/// </summary>
bool BreakLine();
/// <summary>
/// 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.
/// </summary>
bool Return();
/// <summary>
/// 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.
/// </summary>
void ExecuteInput();
/// <summary>
/// If the current input is a standard input this will submit the input.
///
/// Returns true if the input was submitted, false otherwise.
/// </summary>
bool TrySubmitStandardInput();
/// <summary>
/// Appends a input into the editor buffer and history as if it has been executed.
///
......@@ -246,74 +192,11 @@ bool IsResetting
/// </summary>
void AddLogicalInput(string input);
/// <summary>
/// Advances to the next item in history.
/// </summary>
void HistoryNext(string search = null);
/// <summary>
/// Advanced to the previous item in history.
/// </summary>
void HistoryPrevious(string search = null);
/// <summary>
/// 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.
/// </summary>
void HistorySearchNext();
/// <summary>
/// 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.
/// </summary>
void HistorySearchPrevious();
/// <summary>
/// Deletes the current selection or the character before the caret.
/// </summary>
/// <returns></returns>
bool Backspace();
/// <summary>
/// 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.
/// </summary>
/// <param name="extendSelection">True to extend the selection from the current caret position.</param>
void Home(bool extendSelection);
/// <summary>
/// Moves to the end of the line.
/// </summary>
/// <param name="extendSelection">True to extend the selection from the current caret position.</param>
void End(bool extendSelection);
IInteractiveWindowOperations Operations
{
get;
}
/// <summary>
/// Selects all of the text in the buffer
/// </summary>
void SelectAll();
/// <summary>
/// Pastes the current clipboard contents into the interactive window.
/// </summary>
/// <returns></returns>
bool Paste();
/// <summary>
/// Cuts the current selection to the clipboard.
/// </summary>
void Cut();
/// <summary>
/// Deletes the current selection.
///
/// Returns true if the selection was deleted
/// </summary>
bool Delete();
}
}
......@@ -3,19 +3,12 @@
namespace Roslyn.Editor.InteractiveWindow
{
public static class InteractiveContentTypeNames
internal static class InteractiveContentTypeDefinitions
{
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")]
[Export, Name(PredefinedInteractiveContentTypes.InteractiveContentTypeName), BaseDefinition("text"), BaseDefinition("projection")]
internal static readonly ContentTypeDefinition InteractiveContentTypeDefinition;
[Export, Name(InteractiveOutputContentType), BaseDefinition("text")]
[Export, Name(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName), BaseDefinition("text")]
internal static readonly ContentTypeDefinition InteractiveOutputContentTypeDefinition;
[Export, Name(InteractiveCommandContentType), BaseDefinition("code")]
internal static readonly ContentTypeDefinition InteractiveCommandContentTypeDefinition;
}
}
\ No newline at end of file
......@@ -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()
/// <summary>
/// Sets the active code to the specified text w/o executing it.
/// </summary>
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)
/// <param name="entry"></param>
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);
}
/// <summary>
......@@ -3016,5 +3019,110 @@ internal List<ReplSpan> 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<ExecutionResult> 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();
}
}
}
}
......@@ -10,7 +10,7 @@
<ProjectGuid>{01E9BD68-0339-4A13-B42F-A3CA84D164F3}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Roslyn.Editor.InteractiveWindow</RootNamespace>
<AssemblyName>Roslyn.InteractiveWindow</AssemblyName>
<AssemblyName>Microsoft.VisualStudio.InteractiveWindow</AssemblyName>
<!-- TODO -->
<SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
......@@ -97,6 +97,7 @@
<Compile Include="Commands\ClearScreenCommand.cs" />
<Compile Include="Commands\CommandClassifier.cs" />
<Compile Include="Commands\CommandClassifierProvider.cs" />
<Compile Include="Commands\PredefinedInteractiveCommandsContentTypes.cs" />
<Compile Include="Commands\InteractiveWindowCommandExtensions.cs" />
<Compile Include="Commands\InteractiveWindowCommands.cs" />
<Compile Include="Commands\HelpCommand.cs" />
......@@ -106,7 +107,7 @@
<Compile Include="CustomTrackingSpan.cs" />
<Compile Include="ExecutionResult.cs" />
<Compile Include="History.cs" />
<Compile Include="IContentTypeMetadata.cs" />
<Compile Include="ContentTypeMetadata.cs" />
<Compile Include="Commands\IInteractiveWindowCommands.cs" />
<Compile Include="Commands\IInteractiveWindowCommandsFactory.cs" />
<Compile Include="IInteractiveEvaluator.cs" />
......@@ -114,8 +115,9 @@
<Compile Include="IInteractiveWindowEditorFactoryService.cs" />
<Compile Include="IInteractiveWindowFactoryService.cs" />
<Compile Include="Commands\InteractiveCommandsFactory.cs" />
<Compile Include="InteractiveConstants.cs" />
<Compile Include="InteractiveContentTypeNames.cs" />
<Compile Include="IInteractiveWindowOperations.cs" />
<Compile Include="PredefinedInteractiveContentTypes.cs" />
<Compile Include="InteractiveContentTypeDefinitions.cs" />
<Compile Include="InteractiveWindow.cs" />
<Compile Include="InteractiveWindowExtensions.cs" />
<Compile Include="InteractiveWindowOptions.cs" />
......@@ -132,10 +134,10 @@
<Compile Include="Output\ResizingAdorner.cs" />
<Compile Include="Output\SortedSpans.cs" />
<Compile Include="Output\ZoomableInlineAdornment.cs" />
<Compile Include="PredefinedInteractiveTextViewRoles.cs" />
<Compile Include="PromptLineMapping.cs" />
<Compile Include="ReplInput.cs" />
<Compile Include="ReplSpanKind.cs" />
<Compile Include="RestoreHistoryEditTag.cs" />
<Compile Include="SmartIndent\InteractiveSmartIndenter.cs" />
<Compile Include="SmartIndent\InteractiveSmartIndenterProvider.cs" />
<Compile Include="SmartUpDownOption.cs" />
......@@ -157,4 +159,4 @@
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -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<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag
......
......@@ -15,7 +15,7 @@ namespace Roslyn.Editor.InteractiveWindow
/// Classifies error text in interactive window output.
/// </summary>
[Export(typeof(IClassifierProvider))]
[ContentType(InteractiveContentTypeNames.InteractiveOutputContentType)]
[ContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName)]
[TextViewRole(PredefinedTextViewRoles.Document)]
internal sealed class OutputClassifierProvider : IClassifierProvider
{
......
......@@ -3,11 +3,9 @@
namespace Roslyn.Editor.InteractiveWindow
{
public static class InteractiveConstants
public static class PredefinedInteractiveContentTypes
{
/// <summary>
/// The additional role found in any REPL editor window.
/// </summary>
public const string InteractiveTextViewRole = "REPL";
public const string InteractiveContentTypeName = "Interactive Content";
public const string InteractiveOutputContentTypeName = "Interactive Output";
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ internal sealed class InteractiveSmartIndenter : ISmartIndent
private readonly ISmartIndent indenter;
internal static InteractiveSmartIndenter Create(
IEnumerable<Lazy<ISmartIndentProvider, IContentTypeMetadata>> smartIndenterProviders,
IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> 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<IContentType, Lazy<ISmartIndentProvider, IContentTypeMetadata>> GetProvider(
IEnumerable<Lazy<ISmartIndentProvider, IContentTypeMetadata>> smartIndenterProviders,
private static Tuple<IContentType, Lazy<ISmartIndentProvider, ContentTypeMetadata>> GetProvider(
IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> 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<IContentType, Lazy<ISmartIndentProvider, IContentTypeMetadata>> bestPair = null;
Tuple<IContentType, Lazy<ISmartIndentProvider, ContentTypeMetadata>> bestPair = null;
foreach (var baseType in contentType.BaseTypes)
{
var pair = GetProvider(smartIndenterProviders, baseType);
......
......@@ -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<Lazy<ISmartIndentProvider, IContentTypeMetadata>> indentProviders;
private readonly IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> indentProviders;
[ImportingConstructor]
public InteractiveSmartIndenterProvider(
ITextEditorFactoryService editorFactory,
[ImportMany] IEnumerable<Lazy<ISmartIndentProvider, IContentTypeMetadata>> indentProviders)
[ImportMany] IEnumerable<Lazy<ISmartIndentProvider, ContentTypeMetadata>> indentProviders)
{
if (editorFactory == null)
{
......
......@@ -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,
......
......@@ -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.
......
......@@ -14,11 +14,8 @@
<ProjectGuid>{20BB6FAC-44D2-4D76-ABFE-0C1E163A1A4F}</ProjectGuid>
<OutputType>Library</OutputType>
<UseCodebase>true</UseCodebase>
<!-- This project includes the VS SDK targets so we can produce a .pkgdef, but should not produce a .vsix or anything related to it -->
<CreateVsixContainer>false</CreateVsixContainer>
<DeployExtension>false</DeployExtension>
<RootNamespace>Microsoft.VisualStudio</RootNamespace>
<AssemblyName>Roslyn.VisualStudio.InteractiveWindow</AssemblyName>
<AssemblyName>Microsoft.VisualStudio.VsInteractiveWindow</AssemblyName>
<StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/rootsuffix RoslynDev /log</StartArguments>
......@@ -76,6 +73,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CommandIds.cs" />
<Compile Include="ContentTypeMetadata.cs" />
<Compile Include="Guids.cs" />
<Compile Include="IVsInteractiveWindowEditorsFactoryService.cs" />
<Compile Include="VsInteractiveWindowEditorFactoryService.cs" />
......@@ -94,6 +92,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>VSInteractiveWindowResources.resx</DependentUpon>
</Compile>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="VSInteractiveWindowResources.resx">
......@@ -122,4 +123,4 @@
<Import Project="..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -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;
}
......
......@@ -26,10 +26,10 @@ internal sealed class VsInteractiveWindowEditorFactoryService : IInteractiveWind
private readonly IOleServiceProvider _provider;
private readonly IVsEditorAdaptersFactoryService _adapterFactory;
private readonly IContentTypeRegistryService _contentTypeRegistry;
private readonly IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, IContentTypeMetadata>> _oleCommandTargetProviders;
private readonly IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> _oleCommandTargetProviders;
[ImportingConstructor]
public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, IContentTypeMetadata>> oleCommandTargetProviders)
public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> oleCommandTargetProviders)
{
_adapterFactory = adaptersFactory;
_provider = (IOleServiceProvider)InteractiveWindowPackage.GetGlobalService(typeof(IOleServiceProvider));
......
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="1F42C6D0-F876-4AF0-8185-1BEB0A325BB2" Version="|%CurrentProject%;GetBuildVersion|" Language="en-US" Publisher="Microsoft" />
<DisplayName>VisualStudio Interactive Components</DisplayName>
<Description>Interactive components for Visual Studio.</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[14.0,]" />
<InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinDesktopExpress" />
<InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VWDExpress" />
<InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinExpress" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.VisualStudio.InteractiveWindow.dll" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.VisualStudio.VsInteractiveWindow.dll" />
<Asset Type="Microsoft.VisualStudio.VsPackage" Path="Microsoft.VisualStudio.VsInteractiveWindow.pkgdef" />
<Asset Type="Microsoft.VisualStudio.VsPackage" Path="BindingPath.pkgdef" />
</Assets>
</PackageManifest>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册