コード例 #1
0
        private static void MemberCompletionTest(int location, string sourceCode, string expectedExpression)
        {
            if (location < 0)
            {
                location = sourceCode.Length + location + 1;
            }

            var analyzer = new ProjectAnalyzer(new IronPythonInterpreterFactory(), new MockErrorProviderFactory());
            var buffer   = new MockTextBuffer(sourceCode);

            buffer.AddProperty(typeof(ProjectAnalyzer), analyzer);
            var snapshot = (MockTextSnapshot)buffer.CurrentSnapshot;
            var context  = snapshot.GetCompletions(new MockTrackingSpan(snapshot, location, 0));

            Assert.AreEqual(context.Text, expectedExpression);
        }
コード例 #2
0
        private static ExpressionAnalysis AnalyzeExpression(int location, string sourceCode)
        {
            if (location < 0)
            {
                location = sourceCode.Length + location + 1;
            }

            var analyzer = new ProjectAnalyzer(new IronPythonInterpreterFactory(), new MockErrorProviderFactory());
            var buffer   = new MockTextBuffer(sourceCode);

            buffer.AddProperty(typeof(ProjectAnalyzer), analyzer);
            var textView = new MockTextView(buffer);
            var item     = analyzer.MonitorTextBuffer(textView.TextBuffer); // We leak here because we never un-monitor, but it's a test.

            while (!item.ProjectEntry.IsAnalyzed)
            {
                Thread.Sleep(100);
            }

            var snapshot = (MockTextSnapshot)buffer.CurrentSnapshot;

            return(snapshot.AnalyzeExpression(new MockTrackingSpan(snapshot, location, location == snapshot.Length ? 0 : 1)));
        }