Пример #1
0
 private static void startEngine(CommandEndpoint endpoint)
 {
     Logger.Write("Application initialized");
     endpoint.Start();
     while (endpoint.IsAlive)
         Thread.Sleep(100);
     Logger.Write("Shutting down");
 }
Пример #2
0
 public TrayForm(CommandEndpoint endpoint, string defaultLanguage, ICacheBuilder builder)
 {
     _endpoint = endpoint;
     _cacheBuilder = builder;
     _ctx = SynchronizationContext.Current;
     _defaultLanguage = defaultLanguage;
     new Thread(startEngine).Start();
     setupTray();
     setupForm();
 }
 public CompleteSnippetHandler(ICacheBuilder cache, string keyPath, CommandEndpoint endpoint)
 {
     _cache = cache;
     _keyPath = keyPath;
     _endpoint = endpoint;
     _dispatch = (msg) => {
         Logger.Write("dispatching " + msg);
         _endpoint.Handle(msg);
     };
     _editor = new EngineLocator(new FS()).GetInstance(_keyPath);
 }
Пример #4
0
        public static CommandEndpoint GetEndpoint(string path, string[] enabledLanguages)
        {
            _path = path;
            _interpreters = new Interpreters(_path);
            ProcessExtensions.GetInterpreter =
                (file) => {
                        var interpreters = _interpreters
                            .GetInterpreterFor(Path.GetExtension(file));
                        return interpreters;
                    };
            _cache = new TypeCache();
            _crawlHandler = new CrawlHandler(_cache, (s) => Logger.Write(s));
            _pluginLocator = new PluginLocator(
                enabledLanguages,
                new ProfileLocator(_path),
                (msg) => {});
            initPlugins(_pluginLocator, _crawlHandler);

            _eventEndpoint = new EventEndpoint(_path, _pluginLocator);
            _eventEndpoint.Start();
            Logger.Write("Event endpoint listening on port: {0}", _eventEndpoint.Port);

            Logger.Write("Creating plugin file tracker");
            _tracker = new PluginFileTracker();
            Logger.Write("Starting plugin file tracker");
            _tracker.Start(
                _path,
                _cache,
                _cache,
                _pluginLocator,
                _eventEndpoint);
            Logger.Write("Plugin file tracker started");

            _endpoint = new CommandEndpoint(_path, _cache, _eventEndpoint);
            _endpoint.AddHandler(messageHandler);

            _handlers.AddRange(new IHandler[] {
                    new GetProjectsHandler(_endpoint, _cache),
                    new GetFilesHandler(_endpoint, _cache),
                    new GetCodeRefsHandler(_endpoint, _cache),
                    new GetSignatureRefsHandler(_endpoint, _cache),
                    new GoToDefinitionHandler(_endpoint, _cache, _pluginLocator),
                    new FindTypeHandler(_endpoint, _cache),
                    new SnippetEditHandler(_endpoint, _cache, _path),
                    new SnippetDeleteHandler(_cache, _path),
                    new GetRScriptStateHandler(_endpoint, _eventEndpoint),

                    // Make sure this handler is the last one since the command can be file extension or language name
                    new LanguageCommandHandler(_endpoint, _cache, _pluginLocator)
                });
            Logger.Write("Command endpoint started");
            return _endpoint;
        }
Пример #5
0
 private static bool runForm(CommandEndpoint endpoint, string defaultLanguage)
 {
     try {
         var form = new TrayForm(
             endpoint,
             defaultLanguage,
             Bootstrapper.GetCacheBuilder());
         Application.Run(form);
         return true;
     } catch {
         return false;
     }
 }
Пример #6
0
 private static void startEngineNoX(CommandEndpoint endpoint)
 {
     Logger.Write("Application initialized");
     var shutdown = false;
     var editorHasExisted = false;
     endpoint.AddHandler((message, cache, editor) => {
         if (message.Message == "shutdown")
             shutdown = true;
     });
     endpoint.Start();
     while (!shutdown) {
         var isAlive = endpoint.IsAlive;
         if (isAlive)
             editorHasExisted = true;
         if (editorHasExisted && !isAlive)
             break;
         Thread.Sleep(100);
     }
     Logger.Write("Shutting down");
 }
Пример #7
0
        public static CommandEndpoint GetEndpoint(string path, string[] enabledLanguages)
        {
            _path = path;
            Logger.Assign(new FileLogger());
            _cache = new TypeCache();
            var crawlHandler = new CrawlHandler(_cache, (s) => Logger.Write(s));
            var pluginLocator = new PluginLocator(
                enabledLanguages,
                Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)),
                (msg) => {});
            initPlugins(pluginLocator, crawlHandler);

            _eventEndpoint = new EventEndpoint(_path, pluginLocator);
            _eventEndpoint.Start();

            _tracker = new PluginFileTracker();
            _tracker.Start(
                _path,
                _cache,
                _cache,
                pluginLocator,
                _eventEndpoint);

            _endpoint = new CommandEndpoint(_path, _cache, _eventEndpoint);
            _endpoint.AddHandler(messageHandler);

            _handlers.AddRange(new IHandler[] {
                    new GetProjectsHandler(_endpoint, _cache),
                    new GetFilesHandler(_endpoint, _cache),
                    new GetCodeRefsHandler(_endpoint, _cache),
                    new GetSignatureRefsHandler(_endpoint, _cache),
                    new GoToDefinitionHandler(_endpoint, _cache, pluginLocator),
                    new FindTypeHandler(_endpoint, _cache),
                    new SnippetEditHandler(_endpoint, _cache, _path),
                    new SnippetDeleteHandler(_cache, _path)
                });
            return _endpoint;
        }
Пример #8
0
 public GetCodeRefsHandler(CommandEndpoint endpoint, ITypeCache cache)
 {
     _endpoint = endpoint;
     _cache = cache;
 }
Пример #9
0
 public FindTypeHandler(CommandEndpoint endpoint, ITypeCache cache)
 {
     _endpoint = endpoint;
     _cache = cache;
 }
Пример #10
0
 public GoToDefinitionHandler(CommandEndpoint endpoint, TypeCache cache, PluginLocator locator)
 {
     _endpoint = endpoint;
     _cache = cache;
     _pluginLocator = locator;
 }
Пример #11
0
        public static CommandEndpoint GetEndpoint(string path, string[] enabledLanguages)
        {
            _path = path;
            var reader = new ConfigReader(_path);
            _interpreters = new Interpreters(_path);
            ProcessExtensions.GetInterpreter =
                (file) => {
                        var interpreters = _interpreters
                            .GetInterpreterFor(Path.GetExtension(file));
                        return interpreters;
                    };
            _cache = new TypeCache();
            _outputEndpoint = new OutputEndpoint(_path);
            Logger.Write("Event endpoint serving on port: {0}", _outputEndpoint.Port);
            var responseDispatcher = new ResponseDispatcher(
                _path,
                false,
                "language-output ",
                (p, m) => _outputEndpoint.Send(p, m),
                (m) => _endpoint.Handle(m),
                (m) => {}
            );
            responseDispatcher.OnlyCommands();
            _pluginLocator = new PluginLocator(
                enabledLanguages,
                new ProfileLocator(_path),
                (msg) => {
                    responseDispatcher.Handle(false, msg);
                }
            );
            initPlugins(_pluginLocator);

            _eventEndpoint = new EventEndpoint(_path, _pluginLocator, _outputEndpoint);
            _eventEndpoint.Start();
            Logger.Write("Event endpoint listening on port: {0}", _eventEndpoint.Port);

            Logger.Write("Creating plugin file tracker");
            _tracker = new PluginFileTracker();
            Logger.Write("Starting plugin file tracker");
            var ignoreDirSetting = reader.Get("oi.ignore.directories");
            var ignoreDirectories = new string[] {};
            if (ignoreDirSetting != null) {
                ignoreDirectories = ignoreDirSetting
                    .Split(new[] {','})
                    .Select(x => {
                        if (Path.IsPathRooted(x)) {
                            return x;
                        }
                        return Path.Combine(_path, x);
                    })
                    .ToArray();
            }
            _tracker.Start(
                _path,
                _cache,
                _cache,
                _pluginLocator,
                _eventEndpoint,
                ignoreDirectories);
            Logger.Write("Plugin file tracker started");

            _endpoint = new CommandEndpoint(_path, _cache, _eventEndpoint);
            _endpoint.AddHandler(messageHandler);

            _handlers.AddRange(new IHandler[] {
                    new GetProjectsHandler(_endpoint, _cache),
                    new GetFilesHandler(_endpoint, _cache),
                    new GetCodeRefsHandler(_endpoint, _cache),
                    new GetSignatureRefsHandler(_endpoint, _cache),
                    new GoToDefinitionHandler(_endpoint, _cache, _pluginLocator),
                    new FindTypeHandler(_endpoint, _cache),
                    new SnippetEditHandler(_endpoint, _cache, _path),
                    new SnippetDeleteHandler(_cache, _path),
                    new GetRScriptStateHandler(_endpoint, _eventEndpoint),
                    new CompleteSnippetHandler(_cache, _path, _endpoint),
                    new WriteOutputHandler(_eventEndpoint),
                    new GetTokenPathHandler(_endpoint),

                    // Make sure this handler is the last one since the command can be file extension or language name
                    new LanguageCommandHandler(_endpoint, _cache, _pluginLocator)
                });
            Logger.Write("Command endpoint started");
            return _endpoint;
        }
Пример #12
0
 public SnippetEditHandler(CommandEndpoint endpoint, ICacheBuilder cache, string keyPath)
 {
     _endpoint = endpoint;
     _cache = cache;
     _keyPath = keyPath;
 }
 public GetRScriptStateHandler(CommandEndpoint endpoint, EventEndpoint eventEndpoint)
 {
     _endpoint = endpoint;
     _eventEndpoint = eventEndpoint;
 }
Пример #14
0
 public GetProjectsHandler(CommandEndpoint endpoint, ITypeCache cache)
 {
     _endpoint = endpoint;
     _cache = cache;
 }
Пример #15
0
 public GetTokenPathHandler(CommandEndpoint endpoint)
 {
     _endpoint = endpoint;
 }
Пример #16
0
 private static void startEngine(CommandEndpoint endpoint)
 {
     endpoint.Start();
     while (endpoint.IsAlive)
         Thread.Sleep(100);
 }