private void OnInterpretersChanged(object sender, EventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => OnInterpretersChanged(sender, e))); return; } var existing = Interpreters.Where(iv => iv.Interpreter != null).ToDictionary(iv => iv.Interpreter); var def = _interpreterService.DefaultInterpreter; int i = 0; foreach (var interp in _interpreterService.Interpreters) { if (!existing.Remove(interp)) { Interpreters.Insert(i, new InterpreterView(interp, interp.Description, interp == def)); } i += 1; } foreach (var kv in existing) { Interpreters.Remove(kv.Value); } }
public override IOutputProcessorResult GenerateOutput() { // this processor outputs a single file of all classes and other info var fileStream = new FileStream(_outputPath, FileMode.Create); var tw = new StreamWriter(fileStream); Interpreters.ForEach(interpreter => { var processResult = interpreter.Process(); //processResult. processResult.Bundles.ForEach(bundle => { tw.WriteLine(bundle.Name); tw.WriteLine("Methods: " + string.Join(";", bundle.Methods)); }); }); tw.Flush(); tw.Close(); fileStream.Close(); // what do we need to return from here??? return new OutputProcessorResult() { Status = "ok", } }
public string Eval(Scope previous_scope, ContextOptions options, List <string> diagnostics = null) { Expression tree = _parse_result.RootExpression; tree.Print(); ScriptScope script_scope = new ScriptScope(previous_scope, _script); if (_parse_result.Diagnostics.Length != 0) { if (diagnostics != null) { foreach (var diag in _parse_result.Diagnostics) { diagnostics.Add(diag.ToString()); } } else { throw new Exception(_parse_result.Diagnostics.Join("\n")); } } string res = Interpreters.Execute(tree, script_scope).ResultValue.GetStringValue(); if (options.DEBUG_EXECUTION) { Console.ReadLine(); } return(res); }
private void OnInterpretersChanged(object sender, EventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => OnInterpretersChanged(sender, e))); return; } var existing = Interpreters.Where(iv => iv.Interpreter != null).ToDictionary(iv => iv.Interpreter); var def = _project.GetInterpreterFactory(); int i = 0; foreach (var interp in InterpreterView.GetInterpreters(_project.Site, _project).Select(x => x.Interpreter)) { if (!existing.Remove(interp)) { Interpreters.Insert(i, new InterpreterView(interp, interp.Configuration.FullDescription, interp == def)); } i += 1; } foreach (var kv in existing) { Interpreters.Remove(kv.Value); } }
private async void OnInterpretersChanged(object sender, EventArgs e) { await Dispatcher.InvokeAsync(() => { Interpreters.Merge( InterpreterView.GetInterpreters(_project.Site, _project), InterpreterView.EqualityComparer, InterpreterView.Comparer ); }); }
private T GetId <T>(int id) where T : AttributeInterpreterBase { AttributeInterpreterBase interpreter; if (Interpreters.TryGetValue(id, out interpreter)) { return((T)interpreter); } return(null); }
public void RemoveInterpreter(int nameId) { AttributeInterpreterBase removedInterpreter; if (!Interpreters.TryGetValue(nameId, out removedInterpreter)) { return; } Interpreters.Remove(nameId); removedInterpreter.OnRemove(); OnModified(this, removedInterpreter); return; }
//---------------------------------------------------------------------------------------------------- static void SetupGQL() { // node interpreters for types Interpreters.Add(typeof(GameObject), new InterpreterGameObject()); Interpreters.Add(typeof(GameObject[]), new InterpreterGameObjectArray()); Interpreters.Add(typeof(Root), new InterpreterSearchRoot()); Func <object> scene = () => UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); Root.Add("scene", scene); Root.Add("stats", Stats.Singleton); Root.Add("events", Events.Singleton); }
public static void Initialize() { Settings = new AppSettings( Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location), getDefaultHandlers, getLanguageHandlers); _interpreters = new Interpreters(Settings.RootPath); ProcessExtensions.GetInterpreter = (file) => { return(_interpreters .GetInterpreterFor(Path.GetExtension(file))); }; _container = new DIContainer(Settings); }
private void OnInterpretersChanged(object sender, EventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => OnInterpretersChanged(sender, e))); return; } var def = _interpreterService.DefaultInterpreter; Interpreters.Merge( _interpreterService.Interpreters.Select(i => new InterpreterView(i, i.Description, i == def)), InterpreterView.EqualityComparer, InterpreterView.Comparer ); }
private void OnInterpretersChanged(object sender, EventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => OnInterpretersChanged(sender, e))); return; } var def = _project.ActiveInterpreter; Interpreters.Merge( InterpreterView.GetInterpreters(_project.Site, _project), InterpreterView.EqualityComparer, InterpreterView.Comparer ); }
private void OnInterpretersChanged(object sender, EventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => OnInterpretersChanged(sender, e))); return; } var def = _project.ActiveInterpreter; Interpreters.Merge( _project.InterpreterFactories.Select(i => new InterpreterView(i, i.Configuration.Description, i == def)), InterpreterView.EqualityComparer, InterpreterView.Comparer ); }
//---------------------------------------------------------------------------------------------------- static void SetupGQL() { // node interpreters for types Interpreters.Add(typeof(GameObject), new InterpreterGameObject()); Interpreters.Add(typeof(GameObject[]), new InterpreterGameObjectArray()); Interpreters.Add(typeof(Root), new InterpreterSearchRoot()); // /q/scene queries all root-level game objects across scenes Func <object> scene = () => Enumerable.Range(0, SceneManager.sceneCount).SelectMany(i => SceneManager.GetSceneAt(i).GetRootGameObjects()).ToArray(); Root.Add("scene", scene); Root.Add("stats", Stats.Singleton); Root.Add("events", Events.Singleton); }
private void Provider_InterpreterFactoriesChanged(object sender, EventArgs e) { lock (_suppressInterpretersChangedLock) { if (_suppressInterpretersChanged > 0) { _raiseInterpretersChanged = true; return; } } // May have removed the default interpreter, so select a new default if (FindInterpreter(DefaultInterpreter.Id, DefaultInterpreter.Configuration.Version) == null) { DefaultInterpreter = Interpreters.LastOrDefault(fact => fact.CanBeAutoDefault()); } OnInterpretersChanged(); }
public void RemoveAllInterpreters() { if (Interpreters.Count == 0) { return; } var attrNames = new List <int>(); foreach (var attr in Interpreters.Keys) { attrNames.Add(attr); } foreach (var attr in attrNames) { Interpreters[attr].OnRemove(); } Interpreters.Clear(); Mark(); }
public void SelectInterpreter(IPythonInterpreterFactory selection) { if (selection == null) { return; } if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => SelectInterpreter(selection))); return; } var sel = Interpreters.FirstOrDefault(iv => iv.Interpreter == selection); if (sel != null) { BaseInterpreter = sel; } }
//---------------------------------------------------------------------------------------------------- static void SetupGQL() { // node interpreters for types Interpreters.Add(typeof(GameObject), new InterpreterGameObject()); Interpreters.Add(typeof(GameObject[]), new InterpreterGameObjectArray()); Interpreters.Add(typeof(Root), new InterpreterSearchRoot()); // /q/scene queries all root-level game objects Func <object> scene = () => Enumerable .Range(0, SceneManager.sceneCount) .SelectMany(i => SceneManager.GetSceneAt(i).GetRootGameObjects()) // all loaded scenes .Concat(UniumComponent.Singleton.gameObject.scene.GetRootGameObjects()) // don't destroy on load 'scene' .ToArray(); Root.Add("scene", scene); Root.Add("stats", Stats.Singleton); Root.Add("events", Events.Singleton); }
//---------------------------------------------------------------------------------------------------- static void SetupGQL() { // node interpreters for types Interpreters.Add(typeof(GameObject), new InterpreterGameObject()); Interpreters.Add(typeof(GameObject[]), new InterpreterGameObjectArray()); Interpreters.Add(typeof(Root), new InterpreterSearchRoot()); // /q/scene queries root-level game objects from all loaded scenes, and the "DontDestroyOnScene" pseudo-scene if running Func <object> scene = () => Enumerable .Range(0, SceneManager.sceneCount) .SelectMany(i => SceneManager.GetSceneAt(i).GetRootGameObjects()) .Concat(UniumComponent.Singleton ? UniumComponent.Singleton.gameObject.scene.GetRootGameObjects() : Enumerable.Empty <GameObject>()) .ToArray(); Root.Add("scene", scene); Root.Add("stats", Stats.Singleton); Root.Add("events", Events.Singleton); }
private void Provider_InterpreterFactoriesChanged(object sender, EventArgs e) { lock (_suppressInterpretersChangedLock) { if (_suppressInterpretersChanged > 0) { _raiseInterpretersChanged = true; return; } } // May have removed the default interpreter, so select a new default if (FindInterpreter(DefaultInterpreter.Id, DefaultInterpreter.Configuration.Version) == null) { DefaultInterpreter = Interpreters.LastOrDefault(); } var evt = InterpretersChanged; if (evt != null) { evt(this, EventArgs.Empty); } }
protected override Result _execute(ImmutableArray <EvaluatedParameter> parameters, FunctionScope function_scope) { if (parameters.Length != 2) { throw new WrongParameterCountException(this, expected: 2, actual: parameters.Length); } FinalExpression param_needle = parameters [0].EvaluatedValue; FinalExpression param_haystack = parameters [0].EvaluatedValue; if (param_haystack is ArrayPointerExpression array_pointer) { ArrayKey needle = param_needle.GetStringValue(); Log.Debug($"check if element is in array: {needle}"); return(new Result(new BoolExpression(array_pointer.Array.GetAll().Any(item => { return Interpreters.Execute(new BinaryExpression(param_needle, item.Value, BinaryOp.EQUAL), function_scope).ResultValue.GetBoolValue(); })))); } else { return(new Result(new BoolExpression(false))); } }
public void Setup() { Interpreters.Add(typeof(TestObject), new InterpreterTestObject()); }
public void TearDown() { Interpreters.Remove(typeof(TestObject)); }
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), // 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); }
private void RefreshCanCreateVirtualEnv(string path) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => RefreshCanCreateVirtualEnv(path))); return; } if (Interpreters.Count == 0) { WillCreateVirtualEnv = false; WillAddVirtualEnv = false; CannotCreateVirtualEnv = false; NoInterpretersInstalled = true; return; } if (!IsValidVirtualEnvPath(path) || BaseInterpreter == null) { WillCreateVirtualEnv = false; WillAddVirtualEnv = false; CannotCreateVirtualEnv = true; NoInterpretersInstalled = false; return; } if (Directory.Exists(path) && Directory.EnumerateFileSystemEntries(path).Any()) { WillCreateVirtualEnv = false; var options = VirtualEnv.FindInterpreterOptions(path, _interpreterService); if (options != null && File.Exists(options.InterpreterPath)) { var baseInterp = _interpreterService.FindInterpreter(options.Id, options.LanguageVersion); InterpreterView baseInterpView; if (baseInterp != null && (baseInterpView = Interpreters.FirstOrDefault(iv => iv.Interpreter == baseInterp)) != null) { if (_lastUserSelectedBaseInterpreter == null) { _lastUserSelectedBaseInterpreter = BaseInterpreter; } BaseInterpreter = baseInterpView; WillAddVirtualEnv = true; } else { WillAddVirtualEnv = false; } } else { WillAddVirtualEnv = false; } CannotCreateVirtualEnv = !WillAddVirtualEnv; NoInterpretersInstalled = false; } else { WillCreateVirtualEnv = true; WillAddVirtualEnv = false; CannotCreateVirtualEnv = false; NoInterpretersInstalled = false; if (_lastUserSelectedBaseInterpreter != null) { BaseInterpreter = _lastUserSelectedBaseInterpreter; _lastUserSelectedBaseInterpreter = null; } } }
public IPythonInterpreterFactory FindInterpreter(string id) { return(Interpreters.SingleOrDefault(f => f.Configuration.Id == id)); }
private void RefreshCanCreateVirtualEnv(string path) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((Action)(() => RefreshCanCreateVirtualEnv(path))); return; } if (Interpreters.Count == 0) { WillCreateVirtualEnv = false; WillAddVirtualEnv = false; CannotCreateVirtualEnv = false; NoInterpretersInstalled = true; return; } if (!IsValidVirtualEnvPath(path) || BaseInterpreter == null) { WillCreateVirtualEnv = false; WillAddVirtualEnv = false; CannotCreateVirtualEnv = true; NoInterpretersInstalled = false; return; } if (Directory.Exists(path) && Directory.EnumerateFileSystemEntries(path).Any()) { WillCreateVirtualEnv = false; var config = VirtualEnv.FindInterpreterConfiguration(null, path, _interpreterService); if (config != null && File.Exists(config.InterpreterPath)) { var baseInterpView = Interpreters.FirstOrDefault(v => v.Id == config.Id); if (baseInterpView != null) { if (_lastUserSelectedBaseInterpreter == null) { _lastUserSelectedBaseInterpreter = BaseInterpreter; } BaseInterpreter = baseInterpView; WillAddVirtualEnv = true; } else { WillAddVirtualEnv = false; } } else { WillAddVirtualEnv = false; } CannotCreateVirtualEnv = !WillAddVirtualEnv; NoInterpretersInstalled = false; } else { WillCreateVirtualEnv = true; WillAddVirtualEnv = false; CannotCreateVirtualEnv = false; NoInterpretersInstalled = false; if (_lastUserSelectedBaseInterpreter != null) { BaseInterpreter = _lastUserSelectedBaseInterpreter; _lastUserSelectedBaseInterpreter = null; } } }