Exemplo n.º 1
0
        public void SharedCoreCanReturnCLRCompletionData()
        {
            var provider = new SharedCompletionProvider(PythonNodeModels.PythonEngineVersion.IronPython2, "");

            Assert.IsNotNull(provider);
            var str = "\nimport System.Collections\nSystem.Collections.";

            var completionData = provider.GetCompletionData(str);
            var completionList = completionData.Select(d => d.Text);

            Assert.IsTrue(completionList.Any());
            Assert.IsTrue(completionList.Intersect(new[] { "Hashtable", "Queue", "Stack" }).Count() == 3);
            Assert.AreEqual(29, completionData.Length);
        }
Exemplo n.º 2
0
        public void SharedCoreCanReturnPythonCompletionData()
        {
            var dynCorePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var provider    = new SharedCompletionProvider(PythonNodeModels.PythonEngineVersion.IronPython2, dynCorePath);

            Assert.IsNotNull(provider);
            var str = "import math\n math.";

            var completionData = provider.GetCompletionData(str);
            var completionList = completionData.Select(d => d.Text);

            Assert.IsTrue(completionList.Any());
            Assert.IsTrue(completionList.Intersect(new[] { "degrees", "radians", "fmod" }).Count() == 3);
            Assert.AreEqual(45, completionData.Length);
        }
Exemplo n.º 3
0
        public void SharedCoreCanReturnCLRCompletionData()
        {
            var provider = new SharedCompletionProvider(PythonEngineManager.CPython3EngineName, "");

            Assert.IsNotNull(provider);
            var str = "\nimport System.Collections\nSystem.Collections.";

            var completionData = provider.GetCompletionData(str);
            var completionList = completionData.Select(d => d.Text);

            Assert.IsTrue(completionList.Any());
            Assert.IsTrue(completionList.Intersect(new[] { "Hashtable", "Queue", "Stack" }).Count() == 3);
            // Serial tests load an extra type (System.Collections.Immutable) in the Python engine
            Assert.IsTrue(completionData.Length >= 29 && completionData.Length <= 30);
        }
Exemplo n.º 4
0
        private void OnTextAreaTextEntered(object sender, TextCompositionEventArgs e)
        {
            try
            {
                if (e.Text == ".")
                {
                    var subString   = editText.Text.Substring(0, editText.CaretOffset);
                    var completions = completionProvider.GetCompletionData(subString, false);

                    if (completions.Length == 0)
                    {
                        return;
                    }

                    completionWindow = new CompletionWindow(editText.TextArea);
                    var data = completionWindow.CompletionList.CompletionData;

                    foreach (var completion in completions)
                    {
                        data.Add(completion);
                    }

                    completionWindow.Show();
                    completionWindow.Closed += delegate
                    {
                        completionWindow = null;
                    };
                }
            }
            catch (Exception ex)
            {
                dynamoViewModel.Model.Logger.Log("Failed to perform python autocomplete with exception:");
                dynamoViewModel.Model.Logger.Log(ex.Message);
                dynamoViewModel.Model.Logger.Log(ex.StackTrace);
            }
        }