Пример #1
0
 private bool isEnabledPlugin(LanguagePlugin plugin)
 {
     if (_enabledLanguages == null)
     {
         return(false);
     }
     return(_enabledLanguages.Contains(plugin.GetLanguage()));
 }
Пример #2
0
 public LanguageHandler(LanguagePlugin plugin)
 {
     _plugin = plugin;
     Command = _plugin.GetLanguage();
     Usage = new CommandHandlerParameter(
         Command,
         CommandType.LanguageCommand,
         Command,
         "Commands for the " + Command + " plugin");
     _plugin.GetUsages().ToList()
         .ForEach(x => Usage.Add(x));
 }
Пример #3
0
 public LanguagePlugin[] LocateAll()
 {
     if (_pluginsAll == null) {
         lock (_padlock) {
             _pluginsAll = new List<LanguagePlugin>();
             foreach (var file in getPlugins()) {
                 var plugin = new LanguagePlugin(file, _dispatchMessage);
                 _pluginsAll.Add(plugin);
             }
         }
     }
     return _pluginsAll.ToArray();
 }
Пример #4
0
 public bool Run(DefinitionCacheItem cmd, IEnumerable<string> args)
 {
     var arguments = args.ToList();
     Logger.Write("Removing the command name from parameters: " + arguments[0]);
     arguments.RemoveAt(0);
     if (cmd.Type == DefinitionCacheItemType.Script || cmd.Type == DefinitionCacheItemType.LanguageScript) {
         Logger.Write("Running command as script");
         var script = new Script(Bootstrapper.Settings.RootPath, Environment.CurrentDirectory, cmd.Location);
         var sb = new StringBuilder();
         // On language commands remove the second argument too if
         // it matches the command name (oi langcommand vs oi C# langcommand)
         if (cmd.Type == DefinitionCacheItemType.LanguageScript &&
             arguments.Count > 0 &&
             Bootstrapper.Settings.EnabledLanguages.Contains(args.ElementAt(0)))
         {
             Logger.Write("Removing second parameter from language command as it's a language script prefixed by language: " + arguments[0]);
             arguments.RemoveAt(0);
         }
         for (int i = 0; i < arguments.Count; i++) {
             sb.Append(" \"" + arguments[i] + "\"");
         }
         script.Run(
             sb.ToString(),
             (command) => {
                 Bootstrapper.DispatchAndCompleteMessage(
                     command,
                     () => {
                         Logger.Write("Writing end of command");
                         script.Write("end-of-command");
                     });
             });
     } else if (cmd.Type == DefinitionCacheItemType.Language) {
         Logger.Write("Running command as language command");
         var language = new LanguagePlugin(cmd.Location, Bootstrapper.DispatchMessage);
         // If default language command add original parameter
         if (args.ElementAt(0) != language.GetLanguage())
             arguments.Insert(0, args.ElementAt(0));
         language.Run(arguments.ToArray());
     } else {
         Logger.Write("Running command as built in command");
         var command = Bootstrapper.GetDefaultHandlers()
             .FirstOrDefault(x => x.Command == args.ElementAt(0));
         if (command == null)
             return false;
         command.Execute(arguments.ToArray());
         _eventDispatcher(string.Format("builtin command ran \"{0}\" {1}", command.Command, new CommandStringParser().GetArgumentString(arguments)));
     }
     return true;
 }
Пример #5
0
 public LanguagePlugin[] LocateAll()
 {
     if (_pluginsAll == null)
     {
         lock (_padlock) {
             _pluginsAll = new List <LanguagePlugin>();
             foreach (var file in getPlugins())
             {
                 var plugin = new LanguagePlugin(file, _dispatchMessage);
                 _pluginsAll.Add(plugin);
             }
         }
     }
     return(_pluginsAll.ToArray());
 }
Пример #6
0
 public PluginPattern(LanguagePlugin plugin)
 {
     Plugin = plugin;
     Patterns = new List<string>();
     Logger.Write("Getting file types for " + plugin.FullPath);
     Patterns.AddRange(
         Plugin
             .GetCrawlFileTypes()
                 .Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
     FilesToHandle = new List<string>();
 }
 private void addLanguagePath(LanguagePlugin plugin, List<string> rootPaths, ref List<string> paths)
 {
     var pluginRoot = Path.GetDirectoryName(plugin.FullPath);
     var index = rootPaths.IndexOf(pluginRoot);
     foreach (var root in rootPaths.Skip(index)) {
         var path =
                 Path.Combine(
                     root,
                     Path.Combine(
                         plugin.GetLanguage() + "-files",
                         "rscripts"));
         if (!Directory.Exists(path))
             continue;
         paths.Add(path);
     }
 }
Пример #8
0
 public LanguageHandler(LanguagePlugin plugin)
 {
     _plugin = plugin;
     Command = _plugin.GetLanguage();
 }
Пример #9
0
 public PluginPattern(LanguagePlugin plugin)
 {
     Plugin = plugin;
     Patterns = new List<string>();
     Patterns.AddRange(
         Plugin
             .GetCrawlFileTypes()
                 .Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
     FilesToHandle = new List<string>();
 }
Пример #10
0
 private bool isEnabledPlugin(LanguagePlugin plugin)
 {
     if (_enabledLanguages == null)
         return false;
     return _enabledLanguages.Contains(plugin.GetLanguage());
 }