private void EnableMenuCommandsOnNewClojureBuffers() { var componentModel = (IComponentModel)GetService(typeof(SComponentModel)); ITextEditorFactoryService editorFactoryService = componentModel.GetService <ITextEditorFactoryService>(); editorFactoryService.TextViewCreated += (o, e) => { e.TextView.GotAggregateFocus += (sender, args) => { _thirdPartyEditorCommands.Clear(); if (e.TextView.TextSnapshot.ContentType.TypeName.ToLower() != "clojure") { return; } var editorOptionsBuilder = new EditorOptionsBuilder(componentModel.GetService <IEditorOptionsFactoryService>().GetOptions(e.TextView)); var tokenizedBuffer = TokenizedBufferBuilder.TokenizedBuffers[e.TextView.TextBuffer]; var formatter = new AutoFormatter(new TextBufferAdapter(e.TextView), tokenizedBuffer); var blockComment = new BlockComment(new TextBufferAdapter(e.TextView)); var blockUncomment = new BlockUncomment(new TextBufferAdapter(e.TextView)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => formatter.Format(editorOptionsBuilder.Get()), CommandIDs.FormatDocument)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => blockComment.Execute(), CommandIDs.BlockComment)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => blockUncomment.Execute(), CommandIDs.BlockUncomment)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => { }, CommandIDs.GotoDefinition)); }; }; }
private void EnableMenuCommandsOnNewClojureBuffers() { var componentModel = (IComponentModel) GetService(typeof (SComponentModel)); ITextEditorFactoryService editorFactoryService = componentModel.GetService<ITextEditorFactoryService>(); editorFactoryService.TextViewCreated += (o, e) => e.TextView.GotAggregateFocus += (sender, args) => { _thirdPartyEditorCommands.Clear(); if (e.TextView.TextSnapshot.ContentType.TypeName.ToLower() != "clojure") return; var editorOptionsBuilder = new EditorOptionsBuilder(componentModel.GetService<IEditorOptionsFactoryService>().GetOptions(e.TextView)); var tokenizedBuffer = TokenizedBufferBuilder.TokenizedBuffers[e.TextView.TextBuffer]; var formatter = new AutoFormatter(new TextBufferAdapter(e.TextView), tokenizedBuffer); var blockComment = new BlockComment(new TextBufferAdapter(e.TextView)); var blockUncomment = new BlockUncomment(new TextBufferAdapter(e.TextView)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => formatter.Format(editorOptionsBuilder.Get()), CommandIDs.FormatDocument)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => blockComment.Execute(), CommandIDs.BlockComment)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => blockUncomment.Execute(), CommandIDs.BlockUncomment)); _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => { }, CommandIDs.GotoDefinition)); }; }