Exemplo n.º 1
0
        private IGenerator CreateGenerator(IContext context)
        {
            PluginLocator pluginLocator    = context.Kernel.Get <PluginLocator>();
            Type          roslynPluginType = pluginLocator.Locate <IGenerator>();

            return((IGenerator)context.Kernel.Get(roslynPluginType ?? typeof(HelloWorldGenerator)));
        }
Exemplo n.º 2
0
        private string  getLanguageInstallPath(Package package, bool forcelocal)
        {
            var language = _locator
                           .Locate()
                           .FirstOrDefault(x => x.GetLanguage() == package.Language);

            if (language == null)
            {
                Logger.Write("Failed to locate language " + package.Language);
                return(null);
            }
            var basepath = Path.GetDirectoryName(language.FullPath);

            if (forcelocal)
            {
                var profiles = new ProfileLocator(_token);
                basepath = Path.Combine(profiles.GetLocalProfilePath(profiles.GetActiveLocalProfile()), "languages");
            }
            return
                (Path.Combine(
                     Path.Combine(
                         basepath,
                         language.GetLanguage() + "-files"),
                     package.Target.Replace("language-", "") + "s"));
        }
Exemplo n.º 3
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 void Should_create_instance()
        {
            var path    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var locator = new PluginLocator(path);
            var plugins = locator.Locate();
            var plugin  = plugins.Where(x => x.Assembly.Equals(Path.Combine(path, "AutoTest.TestRunners.Tests.dll")) && x.Type.Equals("AutoTest.TestRunners.Tests.Plugins.Plugin1")).First();

            Assert.That(plugin.New(), Is.InstanceOf <IAutoTestNetTestRunner>());
        }
        public void Should_locate_plugins()
        {
            var path    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var locator = new PluginLocator(path);
            var plugins = locator.Locate();

            Assert.IsTrue(plugins.Count() > 0);
            Assert.That(plugins.Where(x => x.Assembly.Equals(Path.Combine(path, "AutoTest.TestRunners.Tests.dll")) && x.Type.Equals("AutoTest.TestRunners.Tests.Plugins.Plugin1")).Count(), Is.EqualTo(1));
            Assert.That(plugins.Where(x => x.Assembly.Equals(Path.Combine(path, "AutoTest.TestRunners.Tests.dll")) && x.Type.Equals("AutoTest.TestRunners.Tests.Plugins.Plugin2")).Count(), Is.EqualTo(1));
        }
Exemplo n.º 6
0
        private static IEnumerable <Plugin> allPlugins()
        {
            var currentDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
            var dir        = Path.Combine(currentDir, "TestRunners");

            if (!Directory.Exists(dir))
            {
                return new Plugin[] { }
            }
            ;
            var locator = new PluginLocator(dir);

            return(locator.Locate());
        }
Exemplo n.º 7
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 {
     }
 }
Exemplo n.º 8
0
        public void Handle(Guid clientID, Commands.CommandMessage message)
        {
            var response = new StringBuilder();

            if (message.CorrelationID != null)
            {
                response.Append(message.CorrelationID);
            }

            if (message.Arguments.Count < 2)
            {
                return;
            }

            var language = new PluginFinder(_cache).FindLanguage(message.Command);

            if (language == null)
            {
                return;
            }

            var plugin = _pluginLocator.Locate().FirstOrDefault(x => x.GetLanguage() == language);

            if (plugin == null)
            {
                return;
            }


            if (message.Arguments[0] == "command")
            {
                plugin.Run(message.Arguments.Skip(1).ToArray());
                return;
            }
            if (message.Arguments[0] == "query")
            {
                foreach (var line in plugin.Query(message.Arguments.Skip(1).ToArray()))
                {
                    response.AppendLine(line);
                }
                _endpoint.Send(response.ToString(), clientID);
            }
        }
Exemplo n.º 9
0
        public void Handle(Guid clientID, CommandMessage message)
        {
            Logger.Write("Handling go to definition");
            if (message.Arguments.Count != 1)
            {
                return;
            }
            var position  = new OpenIDE.Core.CommandBuilding.FilePosition(message.Arguments[0]);
            var extension = Path.GetExtension(position.Fullpath);
            var language  = new PluginFinder(_cache).FindLanguage(extension);

            if (language == null)
            {
                return;
            }
            var plugin = _pluginLocator.Locate()
                         .FirstOrDefault(x => x.GetLanguage() == language);

            if (plugin == null)
            {
                return;
            }
            var signature = plugin.SignatureFromPosition(position);

            if (signature == null)
            {
                return;
            }
            var codeRef = _cache.AllSignatures()
                          .FirstOrDefault(x => x.Signature == signature.Signature &&
                                          x.File == signature.File);

            if (codeRef == null)
            {
                return;
            }
            _endpoint.Editor.Send(
                string.Format("goto \"{0}|{1}|{2}\"",
                              codeRef.File,
                              codeRef.Line,
                              codeRef.Column));
        }
 private IEnumerable <IAutoTestNetTestRunner> getIdentifiers()
 {
     if (_identifiers == null)
     {
         var locator = new PluginLocator(Path.GetFullPath("TestRunners"));
         var plugins = locator.Locate();
         _identifiers = plugins
                        .Select(x =>
         {
             var instance = x.New();
             if (instance == null)
             {
                 Logger.WriteDebug(string.Format("Could not create plugin for {0} using {1}", x.Type, x.Assembly));
             }
             return(instance);
         })
                        .Where(x => x != null);
     }
     return(_identifiers);
 }
Exemplo n.º 11
0
        public void Start(
            string path,
            ICacheBuilder cache,
            ICrawlResult crawlReader,
            PluginLocator pluginLocator,
            EventEndpoint eventDispatcher,
            string[] ignoreDirectories)
        {
            _cache           = cache;
            _crawlReader     = crawlReader;
            _eventDispatcher = eventDispatcher;
            Logger.Write("Setting up file trackers");
            Logger.Write("Setting up token file trackers");
            _tracker = new FileChangeTracker((x) => {
                if (x.Path.StartsWith(Path.Combine(path, ".OpenIDE")))
                {
                    return;
                }
                _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());
            }
            var locator     = new ProfileLocator(path);
            var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile());

            if (Directory.Exists(profilePath))
            {
                Logger.Write("Starting tracker for {0}", path);
                _tracker.Start(path, getFilter(), handleChanges, ignoreDirectories);
            }
            else
            {
                Logger.Write("No local configuration point so not starting file tracker");
            }
            if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                if (Directory.Exists(profilePath))
                {
                    Logger.Write("Starting tracker for {0}", profilePath);
                    _localTracker.Start(profilePath, getFilter(), handleChanges, ignoreDirectories);
                }
            }
            var globalPath = locator.GetGlobalProfilePath(locator.GetActiveGlobalProfile());

            if (Directory.Exists(globalPath))
            {
                Logger.Write("Starting tracker for {0}", globalPath);
                _globalTracker.Start(globalPath, getFilter(), handleChanges, ignoreDirectories);
            }
        }