void ResolvePropertyExpression(string expression)
		{
			PythonResolverContext context = new PythonResolverContext(parseInfo);
			ExpressionResult expressionResult = new ExpressionResult(expression);
			
			PythonResolver resolver = new PythonResolver();
			result = resolver.Resolve(context, expressionResult);
		}
		public PythonResolverTestsHelper(string code)
		{
			ProjectContent = new ScriptingUtils.MockProjectContent();
			PythonParser parser = new PythonParser();
			string fileName = @"test.py";
			CompilationUnit = parser.Parse(ProjectContent, fileName, code) as DefaultCompilationUnit;
			
			ParseInfo = new ParseInformation(CompilationUnit);			
			Resolver = new PythonResolver();
		}
		public void SetUpFixture()
		{
			resolver = new PythonResolver();
			mockProjectContent = new MockProjectContent();
			List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
			namespaceItems.Add(new NamespaceEntry("Test"));
			mockProjectContent.AddExistingNamespaceContents(String.Empty, namespaceItems);

			ParseInformation parseInfo = new ParseInformation(new DefaultCompilationUnit(mockProjectContent));
			
			results = resolver.CtrlSpace(0, "import".Length, parseInfo, "import", ExpressionContext.Namespace);
		}
Пример #4
0
		public void InitBase()
		{
			projectContent = new MockProjectContent();
			PythonParser parser = new PythonParser();
			string fileName = @"C:\projects\test\test.py";
			compilationUnit = parser.Parse(projectContent, fileName, GetPythonScript());
			parseInfo = new ParseInformation(compilationUnit);
			
			resolver = new PythonResolver();
			
			expressionResult = GetExpressionResult();
			resolveResult = resolver.Resolve(expressionResult, parseInfo, GetPythonScript());
		}
		public void SetUpFixture()
		{
			resolver = new PythonResolver();
			
			mockProjectContent = new MockProjectContent();
			DefaultCompilationUnit cu = new DefaultCompilationUnit(mockProjectContent);
			cu.FileName = @"C:\Projects\Test\test.py";
			ParseInformation parseInfo = new ParseInformation(cu);
					
			string python = "from System";
			PythonExpressionFinder finder = new PythonExpressionFinder();
			ExpressionResult expressionResult = finder.FindExpression(python, python.Length);
			resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as PythonImportModuleResolveResult;
		}
		public void SetUpFixture()
		{
			resolver = new PythonResolver();
			mockProjectContent = new ICSharpCode.Scripting.Tests.Utils.MockProjectContent();
			
			systemConsoleClass = new MockClass(mockProjectContent, "System.Console");
			mockProjectContent.ClassToReturnFromGetClass = systemConsoleClass;
			
			compilationUnit = CreateCompilationUnit(mockProjectContent);
			ParseInformation parseInfo = new ParseInformation(compilationUnit);
			
			string python = GetPythonScript();
			ExpressionResult expressionResult = new ExpressionResult("System.Console", new DomRegion(3, 2), null, null);
			resolveResult = resolver.Resolve(expressionResult, parseInfo, python);
			
			// Check that the best compilation unit is used and the resolve
			// still works.
			invalidMostRecentCompilationUnitResolveResult = resolver.Resolve(expressionResult, parseInfo, python);
		}
		public void SetUpFixture()
		{
			resolver = new PythonResolver();
			mockProjectContent = new MockProjectContent();
			mockProjectContent.AddExistingNamespaceContents("System", new List<ICompletionEntry>());
			
			string python =
				"import System\r\n" +
				"class Test:\r\n" +
				"    def __init__(self):\r\n" +
				"        System.\r\n";
			
			PythonParser parser = new PythonParser();
			string fileName = @"C:\Projects\Test\test.py";
			DefaultCompilationUnit cu = parser.Parse(mockProjectContent, fileName, python) as DefaultCompilationUnit;
			ParseInformation parseInfo = new ParseInformation(cu);
			
			ExpressionResult expressionResult = new ExpressionResult("System", new DomRegion(4, 2), null, null);
			resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as NamespaceResolveResult;
		}
		public void SetUpFixture()
		{
			resolver = new PythonResolver();
			mockProjectContent = new ICSharpCode.Scripting.Tests.Utils.MockProjectContent();
			mockProjectContent.NamespacesToAdd.Add("Test");
			myTestClass = new MockClass(mockProjectContent, "MyTestClass");
			List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
			namespaceItems.Add(myTestClass);
			mockProjectContent.AddExistingNamespaceContents("MyNamespace", namespaceItems);
			
			DefaultCompilationUnit cu = new DefaultCompilationUnit(mockProjectContent);
			
			// Add usings.
			DefaultUsing newUsing = new DefaultUsing(cu.ProjectContent);
			newUsing.Usings.Add("MyNamespace");
			DefaultUsingScope usingScope = new DefaultUsingScope();
			usingScope.Usings.Add(newUsing);
			cu.UsingScope = usingScope;
			ParseInformation parseInfo = new ParseInformation(cu);
			
			results = resolver.CtrlSpace(0, "".Length, parseInfo, "", ExpressionContext.Default);
		}
		public void SetUpFixture()
		{
			resolver = new PythonResolver();
		}
		public void ResolveCtrlSpaceDoesNotThrowExceptionWhenNullParseInfoIsNull()
		{
			PythonResolver resolver = new PythonResolver();
			List<ICompletionEntry> results = resolver.CtrlSpace(0, 0, null, "abc", ExpressionContext.Namespace);
			Assert.AreEqual(0, results.Count);
		}