public void Execute(string[] arguments)
        {
            var showState = arguments.Any(x => x == "-s");
            var scripts   =
                new ReactiveScriptReader(
                    _token,
                    _pluginLocator,
                    (p, m) => {},
                    (m) => {})
                .Read();

            if (!showState)
            {
                foreach (var script in scripts)
                {
                    Console.WriteLine(script.Name);
                }
                return;
            }
            using (var instance = _codeEngineLocator.GetInstance(_token)) {
                foreach (var script in scripts)
                {
                    var status = "unavailable";
                    if (instance != null)
                    {
                        status = instance.GetRScriptState(script.Name);
                    }
                    Console.WriteLine(script.Name + " (" + status + ")");
                }
            }
        }
Exemplo n.º 2
0
        private void init(string source)
        {
            var dir        = "";
            var name       = "";
            var definition =
                Bootstrapper.GetDefinitionBuilder()
                .Definitions
                .FirstOrDefault(x =>
                                x.Name == source &&
                                (x.Type == DefinitionCacheItemType.Script || x.Type == DefinitionCacheItemType.LanguageScript));

            if (definition != null)
            {
                dir  = Path.GetDirectoryName(definition.Location);
                name = source;
            }
            else
            {
                var rscript =
                    new ReactiveScriptReader(
                        _token,
                        _locator,
                        (p, m) => {},
                        (m) => {}
                        ).Read()
                    .FirstOrDefault(x => x.Name == source);
                if (rscript != null)
                {
                    dir  = Path.GetDirectoryName(rscript.File);
                    name = source;
                }
                else
                {
                    _dispatch("error|Cannot find command to create package for");
                    return;
                }
            }
            //}
            var files = Path.Combine(dir, name + "-files");

            if (!Directory.Exists(files))
            {
                Directory.CreateDirectory(files);
            }
            var packageFile = Path.Combine(files, "package.json");

            if (!File.Exists(packageFile))
            {
                File.WriteAllText(packageFile, getPackageDescription(dir, name));
            }
            _dispatch("event|builtin package initialized \"" + packageFile + "\"");
            _dispatch("command|editor goto \"" + packageFile + "|0|0\"");
        }
Exemplo n.º 3
0
        private void printConfigurationOptions(string path)
        {
            var paths = new List <string>();

            // Editor engine
            paths.Add(
                Path.Combine(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                    "EditorEngine"));
            // Languages
            foreach (var plugin in _pluginLocator.Locate())
            {
                paths.Add(plugin.GetPluginDir());
            }
            // Scripts
            var definitions =
                Bootstrapper.GetDefinitionBuilder()
                .Definitions
                .Where(x =>
                       x.Type == DefinitionCacheItemType.Script ||
                       x.Type == DefinitionCacheItemType.LanguageScript);

            foreach (var script in definitions)
            {
                var dir  = Path.GetDirectoryName(script.Location);
                var name = Path.GetFileNameWithoutExtension(script.Location);
                paths.Add(Path.Combine(dir, name + "-files"));
            }
            // Reactive scripts
            var rscripts =
                new ReactiveScriptReader(
                    _token,
                    () => _pluginLocator,
                    (p, m) => {},
                    (m) => {})
                .Read();

            foreach (var rscript in rscripts)
            {
                var dir  = Path.GetDirectoryName(rscript.File);
                var name = Path.GetFileNameWithoutExtension(rscript.File);
                paths.Add(Path.Combine(dir, name + "-files"));
            }

            var reader = new ConfigOptionsReader(paths.ToArray());

            reader.Parse();
            foreach (var line in reader.Options.OrderBy(x => x))
            {
                Console.WriteLine(line);
            }
        }
Exemplo n.º 4
0
        public void Execute(string[] arguments)
        {
            var scripts = new ReactiveScriptReader(
                _keyPath,
                _pluginLocator,
                (p, m) => {},
                (m) => {})
                          .Read();
            var script = scripts.FirstOrDefault(x => x.Name.Equals(arguments[0]));

            if (script == null || arguments.Length < 1)
            {
                return;
            }
            File.Delete(script.File);
        }
Exemplo n.º 5
0
        private void listRScript(string languageName, Action <LanguagePlugin> onLanguage, Action <ReactiveScript> onItem)
        {
            var scripts =
                new ReactiveScriptReader(
                    _token,
                    _locator,
                    (p, m) => {},
                    (m) => {})
                .ReadLanguageScripts();

            itemsPrLanguage(
                onLanguage,
                onItem,
                (d) => d.File,
                scripts,
                languageName,
                "rscripts");
        }
        public void Execute(string[] arguments)
        {
            if (arguments.Length < 1)
            {
                return;
            }
            var scripts = new ReactiveScriptReader(
                _keyPath,
                _pluginLocator,
                (p, m) => {},
                (m) => {})
                          .Read();
            var script = scripts.FirstOrDefault(x => x.Name.Equals(arguments[0]));

            if (script == null)
            {
                return;
            }
            _dispatch(string.Format("event|'reactive-script-resume' '{0}'", script.File));
        }
Exemplo n.º 7
0
 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();
         }
     }
 }
Exemplo n.º 8
0
        public void Execute(string[] arguments)
        {
            if (arguments.Length < 2)
            {
                return;
            }
            var scripts = new ReactiveScriptReader(
                _token,
                _pluginLocator,
                (p, m) => {},
                (m) => {})
                          .Read();
            var script = scripts.FirstOrDefault(x => x.Name.Equals(arguments[0]));

            if (script == null)
            {
                return;
            }

            var root   = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var match1 = "'codemodel' 'raw-filesystem-change-filecreated' '" + script.File + "'";
            var match2 = "'codemodel' 'raw-filesystem-change-filechanged' '" + script.File + "'";

            Logger.Write("Looking for: " + match1);
            Logger.Write("Looking for: " + match2);
            var name = "rscript-" + Path.GetFileNameWithoutExtension(script.File);
            var hash = 0;

            try {
                using (var output = new OutputClient(_token, (publisher, msg) => { if (name == publisher)
                                                                                   {
                                                                                       _dispatch(msg);
                                                                                   }
                                                     }))
                {
                    output.Connect();
                    var proc = new Process();
                    proc.Query(
                        Path.Combine(root, Path.Combine("EventListener", "OpenIDE.EventListener.exe")),
                        "",
                        false,
                        _token,
                        (error, s) => {
                        if (s == match1 || s == match2)
                        {
                            var newHas = File.ReadAllText(script.File).GetHashCode();
                            if (newHas != hash)
                            {
                                hash = newHas;
                                Thread.Sleep(200);
                                _dispatch("");
                                _dispatch("Triggering reactive script:");
                                _dispatch("event|" + arguments[1]);
                            }
                        }
                    }
                        );
                }
            } catch (Exception ex) {
                Logger.Write(ex);
            }
        }