Holds the text for namespace, child element or attribute autocomplete (intellisense).
Inheritance: MonoDevelop.Ide.CodeCompletion.CompletionData
Exemple #1
0
        public XmlCompletionData[] GetNamespaceCompletionData()
        {
            Dictionary <string, XmlCompletionData> items = new Dictionary <string, XmlCompletionData> ();

            foreach (XmlSchemaCompletionData schema in builtin)
            {
                items[schema.NamespaceUri] = new XmlCompletionData(schema.NamespaceUri, XmlCompletionData.DataType.NamespaceUri);
            }
            foreach (XmlSchemaCompletionData schema in user)
            {
                items[schema.NamespaceUri] = new XmlCompletionData(schema.NamespaceUri, XmlCompletionData.DataType.NamespaceUri);
            }
            XmlCompletionData[] result = new XmlCompletionData [items.Count];
            items.Values.CopyTo(result, 0);
            return(result);
        }
Exemple #2
0
		protected override async Task<CompletionDataList> GetElementCompletions (System.Threading.CancellationToken token)
		{
			var list = await base.GetElementCompletions (token);
			var currentPath = GetCurrentPath ();
			var path = GetPath (currentPath);
			var namespaces = GetNamespaces (currentPath);
			var completions = Completion.GetCompletions (namespaces).ToList ();
			var filter = completions.Select (r => r.GetFilter (path)).FirstOrDefault (r => r != null);
			foreach (var completion in completions) {
				foreach (var item in completion.GetClasses (path, filter)) {
					var xmlCompletion = new XmlCompletionData (item.Name, item.Description, XmlCompletionData.DataType.XmlElement);
					xmlCompletion.Icon = Stock.Class;
					list.Add (xmlCompletion);
				}
			}
			AddMiscBeginTags (list);
			return list;
		}
		protected override void GetElementCompletions(CompletionDataList list)
		{
			var currentPath = GetCurrentPath();
			var path = GetPath(currentPath);
			var namespaces = GetNamespaces(currentPath);
			var completions = Completion.GetCompletions(namespaces).ToList();
			var filter = completions.Select(r => r.GetFilter(path)).FirstOrDefault(r => r != null);
			foreach (var completion in completions)
			{
				foreach (var item in completion.GetClasses(path, filter))
				{
					var xmlCompletion = new XmlCompletionData(item.Name, item.Description, XmlCompletionData.DataType.XmlElement);
					xmlCompletion.Icon = Stock.Class;
					list.Add(xmlCompletion);
				}
			}
			BaseXmlEditorExtension.AddMiscBeginTags(list);
			base.GetElementCompletions(list);
		}
		public void XmlElementCompletionString()
		{
			XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.XmlElement);
			Assert.AreEqual("foo", data.CompletionText);
		}
		public void AttributeValueCompletionString()
		{
			XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.XmlAttributeValue);
			Assert.AreEqual("foo", data.CompletionText);
		}
		public void NamespaceUriCompletionString()
		{
			XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.NamespaceUri);
			Assert.AreEqual("foo", data.CompletionText);
		}
		static CompletionDataList GetCompletions (Dictionary<string,HashSet<string>> map, XmlElementPath path, XmlCompletionData.DataType type)
		{
			if (path == null || path.Elements.Count == 0)
				return new CompletionDataList ();
			return GetCompletions (map, path.Elements[path.Elements.Count - 1].Name, type);
		}
		static CompletionDataList GetCompletions (Dictionary<string,HashSet<string>> map, string tagName, XmlCompletionData.DataType type)
		{
			var data = new CompletionDataList ();
			HashSet<string> values;
			if (map.TryGetValue (tagName, out values))
				foreach (string s in values)
					data.Add (new XmlCompletionData (s, type));
			return data;
		}
		protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
		{
			isParameterValueCompletion = true;
			var list = base.GetAttributeValueCompletions(attributedOb, att) ?? new CompletionDataList();

			var currentPath = GetCurrentPath();
			var path = GetPath(currentPath);
			var namespaces = GetNamespaces(currentPath);
			var objectName = attributedOb.Name.FullName;
			foreach (var completion in Completion.GetCompletions(namespaces))
			{
				foreach (var item in completion.GetPropertyValues(objectName, att.Name.FullName, path))
				{
					var xmlCompletion = new XmlCompletionData(item.Name, item.Description, XmlCompletionData.DataType.XmlAttributeValue);
					xmlCompletion.Icon = GetIcon(item.Type);
					list.Add(xmlCompletion);
				}
			}
			return list;
		}
Exemple #10
0
		CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb, Dictionary<string, string> existingAtts, XmlCompletionData.DataType type, bool elementNamespacesOnly)
		{
			var list = base.GetAttributeCompletions(attributedOb, existingAtts) ?? new CompletionDataList();
			var currentPath = GetCurrentPath();
			var path = GetPath(currentPath);
			var namespaces = GetNamespaces(currentPath);
			var objectName = attributedOb.Name.FullName;
			if (elementNamespacesOnly)
				namespaces = namespaces.Where(r => (r.Prefix ?? string.Empty) == (attributedOb.Name.Prefix ?? string.Empty)).ToList();
			foreach (var completion in Completion.GetCompletions(namespaces))
			{
				foreach (var item in completion.GetProperties(objectName, path).Where(r => !existingAtts.ContainsKey(r.Name)))
				{
					var xmlCompletion = new XmlCompletionData(item.Name, item.Description, type);
					xmlCompletion.Icon = GetIcon(item.Type);
					list.Add(xmlCompletion);
				}
			}
			return list;
		}
		public void IconNotNull ()
		{
			XmlCompletionData data = new XmlCompletionData ("foo");
			Assert.IsFalse (data.Icon.IsNull);
		}
		public void IconNotEmptyString ()
		{
			XmlCompletionData data = new XmlCompletionData ("foo");
			Assert.IsTrue (data.Icon.Name.Length > 0);
		}