Пример #1
0
		void CreateUsingScopeForCompilationUnit(string fileName)
		{
			DefaultUsingScope usingScope = new DefaultUsingScope();
			usingScope.NamespaceName = Path.GetFileNameWithoutExtension(fileName);
			usingScope.Parent = new DefaultUsingScope();
			compilationUnit.UsingScope = usingScope;
		}
		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);
		}
Пример #3
0
		public override object VisitNamespaceDeclaration(NRefactoryAST.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;
		}
Пример #4
0
		public override object VisitCompilationUnit(NRefactoryAST.CompilationUnit compilationUnit, object data)
		{
			if (compilationUnit == null) {
				return null;
			}
            mapCompilationUnit(compilationUnit, cu);
			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;
		}
Пример #5
0
		public PythonUsingScope(string fileName)
		{
			NamespaceName = Path.GetFileNameWithoutExtension(fileName);
			Parent = new DefaultUsingScope();
		}