Example #1
0
        public void Start(
			string path,
			ICacheBuilder cache,
			ICrawlResult crawlReader,
			PluginLocator pluginLocator,
			EventEndpoint eventDispatcher)
        {
            _cache = cache;
            _crawlReader = crawlReader;
            _eventDispatcher = eventDispatcher;
            _tracker = new FileChangeTracker((x) => {
                    _eventDispatcher.Send(
                        "codemodel raw-filesystem-change-" +
                        x.Type.ToString().ToLower() +
                        " \"" + x.Path + "\"");
                });
            pluginLocator.Locate().ToList()
                .ForEach(x =>
                    {
                        var plugin = new PluginPattern(x);
                        _plugins.Add(plugin);
                        _cache.Plugins.Add(
                            new CachedPlugin(x.GetLanguage(), plugin.Patterns));
                    });
            _tracker.Start(path, getFilter(), handleChanges);
        }
Example #2
0
 public Installer(string token, string[] sourcePrioritization, Action<string> dispatch, PluginLocator locator)
 {
     _token = token;
     _dispatch = dispatch;
     _locator = locator;
     _packageFetcher = new PackageFetcher(_token, sourcePrioritization, _dispatch);
 }
Example #3
0
 public EventEndpoint(string keyPath, PluginLocator locator)
 {
     _keyPath = keyPath;
     _server = new TcpServer();
     _server.IncomingMessage += Handle_serverIncomingMessage;
     _server.Start();
     _reactiveEngine = new ReactiveScriptEngine(_keyPath, locator);
 }
Example #4
0
 public EventEndpoint(string keyPath, PluginLocator locator, OpenIDE.CodeEngine.Core.Endpoints.OutputEndpoint outputEndpoint)
 {
     _keyPath = keyPath;
     _outputEndpoint = outputEndpoint;
     _server = new TcpServer();
     _server.IncomingMessage += Handle_serverIncomingMessage;
     _server.Start();
     _reactiveEngine = new ReactiveScriptEngine(_keyPath, locator, (publisher, msg) => _outputEndpoint.Send(publisher, msg), dispatch);
 }
Example #5
0
        public void Start(
			string path,
			ICacheBuilder cache,
			ICrawlResult crawlReader,
			PluginLocator pluginLocator,
			EventEndpoint eventDispatcher)
        {
            _cache = cache;
            _crawlReader = crawlReader;
            _eventDispatcher = eventDispatcher;
            Logger.Write("Setting up file trackers");
            Logger.Write("Setting up token file trackers");
            _tracker = new FileChangeTracker((x) => {
                    _eventDispatcher.Send(
                        "codemodel raw-filesystem-change-" +
                        x.Type.ToString().ToLower() +
                        " \"" + x.Path + "\"");
                });
            Logger.Write("Setting up local file trackers");
            _localTracker = new FileChangeTracker((x) => {
                    _eventDispatcher.Send(
                        "codemodel raw-filesystem-change-" +
                        x.Type.ToString().ToLower() +
                        " \"" + x.Path + "\"");
                });
            Logger.Write("Setting up global file trackers");
            _globalTracker = new FileChangeTracker((x) => {
                    _eventDispatcher.Send(
                        "codemodel raw-filesystem-change-" +
                        x.Type.ToString().ToLower() +
                        " \"" + x.Path + "\"");
                });
            Logger.Write("Adding plugins to cache");
            var plugins = pluginLocator.Locate().ToList();
            foreach (var x in plugins) {
                var plugin = new PluginPattern(x);
                _plugins.Add(plugin);
                _cache.Plugins.Add(
                    new CachedPlugin(x.GetLanguage(), plugin.Patterns));
                Logger.Write("Added plugin " + x.GetLanguage());
            }
            Logger.Write("Starting tracker for {0}", path);
            _tracker.Start(path, getFilter(), handleChanges);
            var locator = new ProfileLocator(path);
            if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) {
                var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile());
                if (Directory.Exists(profilePath)) {
                    Logger.Write("Starting tracker for {0}", profilePath);
                    _localTracker.Start(profilePath, getFilter(), handleChanges);
                }
            }
            var globalPath = locator.GetGlobalProfilePath(locator.GetActiveGlobalProfile());
            if (Directory.Exists(globalPath)) {
                Logger.Write("Starting tracker for {0}", globalPath);
                _globalTracker.Start(globalPath, getFilter(), handleChanges);
            }
        }
 public ReactiveScriptEngine(string path, PluginLocator locator)
 {
     _keyPath = path;
     _scripts = new ReactiveScriptReader(
         Path.GetDirectoryName(
             Path.GetDirectoryName(
                 Assembly.GetExecutingAssembly().Location)),
         () => { return locator; })
         .Read(_keyPath);
 }
Example #7
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;
        }
Example #8
0
 public ReactiveScriptEngine(string path, PluginLocator locator, Action<string> dispatch)
 {
     _keyPath = path;
     _dispatch = dispatch;
     _pausedScripts = new List<string>();
     _reader =
         new ReactiveScriptReader(
             _keyPath,
             () => { return locator; },
             (m) => _dispatch(m));
     _touchHandler = new ScriptTouchHandler(_reader.GetPaths());
     _scripts = _reader.Read();
 }
 public ReactiveScriptEngine(string path, PluginLocator locator, Action<string,string> outputDispatcher, Action<string> dispatch)
 {
     _keyPath = path;
     _outputDispatcher = outputDispatcher;
     _dispatch = dispatch;
     _pausedScripts = new List<string>();
     _reader =
         new ReactiveScriptReader(
             _keyPath,
             () => { return locator; },
             _outputDispatcher,
             (m) => _dispatch(m));
     _touchHandler = new ScriptTouchHandler(_reader.GetPaths());
     _scripts = _reader.Read();
     foreach (var script in _scripts) {
         if (script.IsService)
             script.StartService();
     }
 }
Example #10
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;
        }
Example #11
0
 public GoToDefinitionHandler(CommandEndpoint endpoint, TypeCache cache, PluginLocator locator)
 {
     _endpoint = endpoint;
     _cache = cache;
     _pluginLocator = locator;
 }
 public EditReactiveScriptHandler(Action<string> dispatch, PluginLocator locator)
 {
     _dispatch = dispatch;
     _pluginLocator = locator;
 }
Example #13
0
 private static void shutdownPlugins(PluginLocator locator)
 {
     try {
         var plugins = locator.Locate();
         foreach (var plugin in plugins) {
             try {
                 Logger.Write("Shutting down plugin " + plugin.GetLanguage());
                 plugin.Shutdown();
             } catch (Exception ex) {
                 Logger.Write(ex.ToString());
             }
         }
     } catch {
     }
 }
Example #14
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;
        }
Example #15
0
 private static void initPlugins(PluginLocator locator)
 {
     var plugins = locator.Locate();
     foreach (var plugin in plugins) {
         try {
             plugin.Initialize(_path);
             plugin.GetCrawlFileTypes();
             ThreadPool.QueueUserWorkItem(
                 (o) => {
                     try {
                         var currentPlugin = (LanguagePlugin)o;
                         var handler = new CrawlHandler(_cache, (s) => Logger.Write(s));
                         handler.SetLanguage(currentPlugin.GetLanguage());
                         currentPlugin.Crawl(new string[] { _path }, (line) => handler.Handle(line));
                     } catch (Exception ex) {
                         Logger.Write(ex.ToString());
                     }
                 },
                 plugin);
         } catch (Exception ex) {
             Logger.Write(ex.ToString());
         }
     }
     Logger.Write("Plugins initialized");
 }
 public DeleteReactiveScriptHandler(PluginLocator locator)
 {
     _pluginLocator = locator;
 }
Example #17
0
 public PluginLocator PluginLocator()
 {
     if (_pluginLocator == null) {
         _pluginLocator =
             new PluginLocator(
                 _settings.EnabledLanguages,
                 new ProfileLocator(_settings.Path),
                 (command) => dispatchMessage(command));
     }
     return _pluginLocator;
 }
 public ConfigurationHandler(string token, PluginLocator locator, Action<string> eventDispatcher)
 {
     _token = token;
     _pluginLocator = locator;
     _eventDispatcher = eventDispatcher;
 }
Example #19
0
 private static void initPlugins(PluginLocator locator, CrawlHandler handler)
 {
     new Thread(() =>
         {
             locator.Locate().ToList()
                 .ForEach(x =>
                     {
                         try {
                             handler.SetLanguage(x.GetLanguage());
                             foreach (var line in x.Crawl(new string[] { _path }))
                                 handler.Handle(line);
                         } catch (Exception ex) {
                             Logger.Write(ex.ToString());
                         }
                     });
         }).Start();
 }