void AddCodeNamespace(NamespaceEntry namespaceEntry)
		{
			if (!String.IsNullOrEmpty(namespaceEntry.Name)) {
				NamespaceName childNamespaceName = namespaceName.CreateChildNamespaceName(namespaceEntry.Name);
				AddCodeElement(new CodeNamespace(projectContent, childNamespaceName));
			}
		}
		public void GetCompletionItemsFromModule_MathModule_LastCompletionItemIsAsterisk()
		{
			List<ICompletionEntry> items = completion.GetCompletionItemsFromModule("math");
			int lastItem = items.Count - 1;			
			ICompletionEntry lastCompletionItem = items[lastItem];
			NamespaceEntry expectedCompletionItem = new NamespaceEntry("*");
			Assert.AreEqual(expectedCompletionItem, lastCompletionItem);
		}
		public void GetCompletionData_WhenImportNameIsEmptyString_ReturnsStandardMathPythonModule()
		{
			PythonImportExpression expression = new PythonImportExpression(String.Empty);
			PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression);
			MockProjectContent projectContent = new MockProjectContent();
			
			List<ICompletionEntry> completionItems = result.GetCompletionData(projectContent);
			NamespaceEntry mathNamespaceCompletionItem = new NamespaceEntry("math");
			Assert.Contains(mathNamespaceCompletionItem, completionItems);
		}
		public void GetCompletionData_ClonedPythonModuleResult_ReturnsSameCompletionItems()
		{
			PythonImportExpression expression = new PythonImportExpression(String.Empty);
			PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression);
			ResolveResult clonedResult = result.Clone();
			MockProjectContent projectContent = new MockProjectContent();
			
			List<ICompletionEntry> completionItems = clonedResult.GetCompletionData(projectContent);
			NamespaceEntry mathNamespaceCompletionItem = new NamespaceEntry("math");
			Assert.Contains(mathNamespaceCompletionItem, completionItems);
		}
예제 #5
0
		void AddNamespaceStructContents(List<ICompletionEntry> list, NamespaceStruct ns, LanguageProperties language, bool lookInReferences)
		{
			int newCapacity = list.Count + ns.Classes.Count + ns.SubNamespaces.Count;
			if (list.Capacity < newCapacity)
				list.Capacity = Math.Max(list.Count * 2, newCapacity);
			foreach (IClass c in ns.Classes) {
				if (c is GenericClassContainer) {
					foreach (IClass realClass in ((GenericClassContainer)c).RealClasses) {
						AddNamespaceContentsClass(list, realClass, language, lookInReferences);
					}
				} else {
					AddNamespaceContentsClass(list, c, language, lookInReferences);
				}
			}
			foreach (string subns in ns.SubNamespaces) {
				NamespaceEntry subnsEntry = new NamespaceEntry(subns);
				if (!list.Contains(subnsEntry))	// PERF
					list.Add(subnsEntry);
			}
		}
		public void ShowEntry_PassedImportAllNamespaceEntryWhenHasFromAndImportIsTrue_ReturnsTrue()
		{
			PythonImportExpressionContext context = new PythonImportExpressionContext();
			context.HasFromAndImport = true;
			NamespaceEntry entry = new NamespaceEntry("*");
			bool result = context.ShowEntry(entry);
			
			Assert.IsTrue(result);
		}
예제 #7
0
        public override bool Equals(object obj)
        {
            NamespaceEntry e = obj as NamespaceEntry;

            return(e != null && e.Name == this.Name);
        }
		public void ExpressionResultContextShowItemReturnsTrueForNamespaceEntry()
		{
			NamespaceEntry entry = new NamespaceEntry("abc");
			Assert.IsTrue(expressionResult.Context.ShowEntry(entry));
		}