Esempio n. 1
0
        private List<MenuCommand> CreateMenuCommands(Repl repl)
        {
            var dte = (DTE2) _serviceProvider.GetService(typeof (DTE));
            repl.OnInvisibleWrite += () => _replToolWindow.ShowNoActivate();

            Action loadSelectedFilesIntoRepl =
                () => dte.ToolWindows.SolutionExplorer.GetSelectedFiles().LoadFilesInto(repl);

            Action loadSelectedProjectIntoRepl =
                () => dte.ToolWindows.SolutionExplorer.GetSelectedProject().GetAllFiles().LoadFilesInto(repl);

            Action loadActiveFileIntoRepl =
                () => dte.ActiveDocument.FullName.SingletonAsList().LoadFilesInto(repl);

            var componentModel = (IComponentModel) _serviceProvider.GetService(typeof (SComponentModel));
            var namespaceParser = new NamespaceParser(NamespaceParser.NamespaceSymbols);

            var activeTextBufferStateProvider =
                new ActiveTextBufferStateProvider(
                    componentModel.GetService<IVsEditorAdaptersFactoryService>(),
                    (IVsTextManager) _serviceProvider.GetService(typeof (SVsTextManager)));

            var menuCommands = new List<MenuCommand>();
            menuCommands.Add(new MenuCommand((sender, args) => loadSelectedProjectIntoRepl(), new CommandID(Guids.GuidClojureExtensionCmdSet, 11)));
            menuCommands.Add(new MenuCommand((sender, args) => loadSelectedFilesIntoRepl(), new CommandID(Guids.GuidClojureExtensionCmdSet, 12)));
            menuCommands.Add(new MenuCommand((sender, args) => loadActiveFileIntoRepl(), new CommandID(Guids.GuidClojureExtensionCmdSet, 13)));
            menuCommands.Add(new MenuCommand((sender, args) => repl.ChangeNamespace(namespaceParser.Execute(activeTextBufferStateProvider.Get())), new CommandID(Guids.GuidClojureExtensionCmdSet, 14)));
            menuCommands.Add(new MenuCommand((sender, args) => repl.WriteInvisibly((string)dte.ActiveDocument.Selection), new CommandID(Guids.GuidClojureExtensionCmdSet, 15)));
            return menuCommands;
        }
 public void Initialize()
 {
     _tokenizer = new Tokenizer();
     _parser = new NamespaceParser(new List<string>() {"ns"});
 }