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(); ParseInformation parseInfo = new ParseInformation(); mockProjectContent = new MockProjectContent(); systemConsoleClass = new MockClass(mockProjectContent, "System.Console"); mockProjectContent.ClassToReturnFromGetClass = systemConsoleClass; compilationUnit = CreateCompilationUnit(mockProjectContent); parseInfo.SetCompilationUnit(compilationUnit); string python = GetPythonScript(); ExpressionResult expressionResult = new ExpressionResult("System.Console", new DomRegion(3, 2), null, null); resolveResult = resolver.Resolve(expressionResult, parseInfo, python); // Here the most recent compilation unit is modified so it has no // class information. The best compilation unit (i.e. the valid one) // should be used instead by the python resolver. parseInfo.SetCompilationUnit(compilationUnit); parseInfo.SetCompilationUnit(new DefaultCompilationUnit(mockProjectContent) { ErrorsDuringCompile = true }); // Check that the best compilation unit is used and the resolve // still works. invalidMostRecentCompilationUnitResolveResult = resolver.Resolve(expressionResult, parseInfo, python); }
public void ResolveCtrlSpaceDoesNotThrowExceptionWhenNullParseInfoIsNull() { PythonResolver resolver = new PythonResolver(); List <ICompletionEntry> results = resolver.CtrlSpace(0, 0, null, "abc", ExpressionContext.Namespace); Assert.AreEqual(0, results.Count); }
public void SetUpFixture() { resolver = new PythonResolver(); ParseInformation parseInfo = new ParseInformation(); mockProjectContent = new MockProjectContent(); mockProjectContent.NamespacesToAdd.Add("Test"); myTestClass = new MockClass(mockProjectContent, "MyTestClass"); ArrayList namespaceItems = new ArrayList(); namespaceItems.Add(myTestClass); mockProjectContent.AddExistingNamespaceContents("MyNamespace", namespaceItems); DefaultCompilationUnit cu = new DefaultCompilationUnit(mockProjectContent) { ErrorsDuringCompile = true }; parseInfo.SetCompilationUnit(cu); // Add usings. DefaultUsing newUsing = new DefaultUsing(cu.ProjectContent); newUsing.Usings.Add("MyNamespace"); cu.UsingScope.Usings.Add(newUsing); results = resolver.CtrlSpace(0, "".Length, parseInfo, "", ExpressionContext.Default); }
public void NullCompilationUnit() { PythonResolver resolver = new PythonResolver(); ParseInformation parseInfo = new ParseInformation(); MockProjectContent mockProjectContent = new MockProjectContent(); ArrayList results = resolver.CtrlSpace(0, 0, parseInfo, String.Empty, ExpressionContext.Namespace); Assert.AreEqual(0, results.Count); }
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); }
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(); ParseInformation parseInfo = new ParseInformation(); mockProjectContent = new MockProjectContent(); ArrayList namespaceItems = new ArrayList(); namespaceItems.Add("Test"); mockProjectContent.AddExistingNamespaceContents(String.Empty, namespaceItems); // Set the dirty compilation unit and the valid compilation unit // so we make sure that the most recent compilation unit // (i.e the dirty compilation unit) is being taken. parseInfo.SetCompilationUnit(new DefaultCompilationUnit(new MockProjectContent())); parseInfo.SetCompilationUnit(new DefaultCompilationUnit(mockProjectContent)); results = resolver.CtrlSpace(0, "import".Length, parseInfo, "import", ExpressionContext.Namespace); }
public void SetUpFixture() { resolver = new PythonResolver(); mockProjectContent = new ICSharpCode.Scripting.Tests.Utils.MockProjectContent(); systemConsoleClass = new MockClass(mockProjectContent, "System.Console"); mockProjectContent.SetClassToReturnFromGetClass("System.Console", 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(); ParseInformation parseInfo = new ParseInformation(); mockProjectContent = new MockProjectContent(); testClass = new MockClass(mockProjectContent, "Test.Test1"); mockProjectContent.ClassesInProjectContent.Add(testClass); mockProjectContent.ClassToReturnFromGetClass = testClass; mockProjectContent.ClassNameForGetClass = "Test.Test1"; compilationUnit = new DefaultCompilationUnit(mockProjectContent); compilationUnit.FileName = @"C:\Projects\Test\test.py"; parseInfo.SetCompilationUnit(compilationUnit); string python = "a = Test1()\r\n" + "a"; ExpressionResult expressionResult = new ExpressionResult("a", new DomRegion(2, 1), null, null); resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as LocalResolveResult; }
public void SetUpFixture() { resolver = new PythonResolver(); }