public void Execute(string[] arguments)
 {
     var scripts = new ReactiveScriptReader(
         Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
         () => { return _pluginLocator; })
         .Read(Environment.CurrentDirectory);
     var script = scripts.FirstOrDefault(x => x.Name.Equals(arguments[0]));
     if (script == null || arguments.Length < 1)
         return;
     _dispatch(string.Format("editor goto \"{0}|0|0\"", script.File));
 }
예제 #2
0
 public void Execute(string[] arguments)
 {
     var scripts = new ReactiveScriptReader(
         _keyPath,
         _pluginLocator,
         (m) => {})
         .Read();
     var script = scripts.FirstOrDefault(x => x.Name.Equals(arguments[0]));
     if (script == null || arguments.Length < 1)
         return;
     File.Delete(script.File);
 }
예제 #3
0
 public void Execute(string[] arguments)
 {
     var scripts = new ReactiveScriptReader(
         _keyPath,
         _pluginLocator,
         (m) => {})
         .Read();
     var script = scripts.FirstOrDefault(x => x.Name.Equals(arguments[0]));
     if (script == null || arguments.Length < 1)
         return;
     _dispatch(string.Format("command|editor goto \"{0}|0|0\"", script.File));
 }
예제 #4
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 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);
            }
        }
 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-restart' '{0}'", script.File));
 }
예제 #7
0
 public void Execute(string[] arguments)
 {
     var scripts =
         new ReactiveScriptReader(
             _token,
             _pluginLocator,
             (m) => {})
             .Read();
     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 + ")");
     }
 }
 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();
     }
 }
 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 + ")");
         }
     }
 }
예제 #10
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\"");
 }
        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);
        }