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 override object VisitNamespaceDeclaration(AST.NamespaceDeclaration namespaceDeclaration, object data) { DefaultUsingScope oldNamespace = currentNamespace; foreach (string name in namespaceDeclaration.Name.Split('.')) { currentNamespace = new DefaultUsingScope(); currentNamespace.Parent = currentNamespace; currentNamespace.NamespaceName = PrependCurrentNamespace(name); currentNamespace.Parent.ChildScopes.Add(currentNamespace); } object ret = namespaceDeclaration.AcceptChildren(this, data); currentNamespace = oldNamespace; return(ret); }
public override object VisitCompilationUnit(AST.CompilationUnit compilationUnit, object data) { if (compilationUnit == null) { return(null); } currentNamespace = new DefaultUsingScope(); if (!string.IsNullOrEmpty(VBRootNamespace)) { foreach (string name in VBRootNamespace.Split('.')) { currentNamespace = new DefaultUsingScope(); currentNamespace.NamespaceName = PrependCurrentNamespace(name); currentNamespace.Parent = currentNamespace; currentNamespace.Parent.ChildScopes.Add(currentNamespace); } } cu.UsingScope = currentNamespace; compilationUnit.AcceptChildren(this, data); return(cu); }
public override object VisitNamespaceDeclaration(AST.NamespaceDeclaration namespaceDeclaration, object data) { DefaultUsingScope oldNamespace = currentNamespace; foreach (string name in namespaceDeclaration.Name.Split('.')) { currentNamespace = new DefaultUsingScope { Parent = currentNamespace, NamespaceName = PrependCurrentNamespace(name), }; currentNamespace.Parent.ChildScopes.Add(currentNamespace); } object ret = namespaceDeclaration.AcceptChildren(this, data); currentNamespace = oldNamespace; return ret; }
public override object VisitCompilationUnit(AST.CompilationUnit compilationUnit, object data) { if (compilationUnit == null) { return null; } currentNamespace = new DefaultUsingScope(); if (!string.IsNullOrEmpty(VBRootNamespace)) { foreach (string name in VBRootNamespace.Split('.')) { currentNamespace = new DefaultUsingScope { Parent = currentNamespace, NamespaceName = PrependCurrentNamespace(name), }; currentNamespace.Parent.ChildScopes.Add(currentNamespace); } } cu.UsingScope = currentNamespace; compilationUnit.AcceptChildren(this, data); return cu; }
public PythonUsingScope(string fileName) { NamespaceName = Path.GetFileNameWithoutExtension(fileName); Parent = new DefaultUsingScope(); }