Esempio n. 1
0
        public void AssertAttributes(params string[] nameValuePairs)
        {
            AssertNodeIs <IAttributedXObject> ();
            IAttributedXObject obj = (IAttributedXObject)Nodes.Peek();

            AssertAttributes(obj, nameValuePairs);
        }
Esempio n. 2
0
        protected override async Task <CompletionContext> GetAttributeCompletionsAsync(
            IAsyncCompletionSession session,
            SnapshotPoint triggerLocation,
            List <XObject> nodePath,
            IAttributedXObject attributedObject,
            Dictionary <string, string> existingAtts,
            CancellationToken token)
        {
            var context = await GetSessionContext(session, triggerLocation, token);

            var rr  = context.rr;
            var doc = context.doc;

            if (rr?.ElementSyntax == null)
            {
                return(CompletionContext.Empty);
            }

            var items = new List <CompletionItem> ();

            foreach (var att in rr.GetAttributeCompletions(doc, doc.ToolsVersion))
            {
                if (!existingAtts.ContainsKey(att.Name))
                {
                    items.Add(CreateCompletionItem(att, XmlCompletionItemKind.Attribute));
                }
            }

            return(CreateCompletionContext(items));
        }
 public override void GetAttributeCompletions(CompletionDataList list, IAttributedXObject attributedOb, Dictionary <string, string> existingAtts)
 {
     if (!existingAtts.ContainsKey("path"))
     {
         list.Add("path", null, "The path of the extension");
     }
 }
        public override void GetAttributeCompletions(CompletionDataList list, IAttributedXObject attributedOb, Dictionary <string, string> existingAtts)
        {
            if (!existingAtts.ContainsKey("type"))
            {
                list.Add("Gettext", null, "Localizes the add-in with a Gettext catalog.");
                list.Add("StringResource", null, "Localizes the add-in with .NET string resources.");
                list.Add("StringTable", null, "Localizes the add-in with string table defined in the manifest.");
                return;
            }

            string type;

            if (!existingAtts.TryGetValue("type", out type))
            {
                return;
            }

            if (type == "Gettext")
            {
                if (!existingAtts.ContainsKey("catalog"))
                {
                    list.Add("catalog", null, "Name of the catalog which contains the strings.");
                }
                if (!existingAtts.ContainsKey("location"))
                {
                    list.Add("location", null, "Relative path to the location of the catalog. This path must be relative to the add-in location..");
                }
            }
        }
Esempio n. 5
0
        public static void AssertAttributes(this XmlParser parser, params string[] nameValuePairs)
        {
            parser.AssertNodeIs <IAttributedXObject> ();
            IAttributedXObject obj = (IAttributedXObject)parser.GetContext().Nodes.Peek();

            parser.AssertAttributes(obj, nameValuePairs);
        }
		public override void GetAttributeCompletions (CompletionDataList list, IAttributedXObject attributedOb, Dictionary<string, string> existingAtts)
		{
			var required = new NodeCompletionCategory ("Required", 0);
			var optional = new NodeCompletionCategory ("Optional", 1);

			foreach (NodeTypeAttribute att in info.Attributes) {
				if (!existingAtts.ContainsKey (att.Name)) {
					var data = new NodeTypeAttributeCompletionData (att) {
						CompletionCategory = att.Required ? required : optional
					};
					list.Add (data);
				}
			}

			var ordering = new NodeCompletionCategory ("Ordering", 2);
			if (!existingAtts.ContainsKey ("id")) {
				list.Add (new CompletionData ("id", null, "ID for the extension, unique in this extension point.") { CompletionCategory = ordering });
			}
			if (!existingAtts.ContainsKey ("insertbefore")) {
				list.Add (new CompletionData ("insertbefore", null, "ID of an existing extension before which to insert this.") { CompletionCategory = ordering });
			}
			if (!existingAtts.ContainsKey ("insertafter")) {
				list.Add (new CompletionData ("insertafter", null, "ID of an existing extension after which to insert this.") { CompletionCategory = ordering });
			}
		}
        public virtual void GetAttributeValueCompletions(CompletionDataList list, IAttributedXObject attributedOb, XAttribute att)
        {
            SchemaAttribute sca;

            if (attributes != null && attributes.TryGetValue(att.Name.FullName, out sca))
            {
                sca.GetAttributeValueCompletions(list, attributedOb);
            }
        }
Esempio n. 8
0
 protected virtual Task <CompletionContext> GetAttributeCompletionsAsync(
     IAsyncCompletionSession session,
     SnapshotPoint triggerLocation,
     List <XObject> nodePath,
     IAttributedXObject attributedObject,
     Dictionary <string, string> existingAtts,
     CancellationToken token
     )
 => Task.FromResult(CompletionContext.Empty);
Esempio n. 9
0
 protected virtual Task <CompletionContext> GetAttributeValueCompletionsAsync(
     IAsyncCompletionSession session,
     SnapshotPoint triggerLocation,
     List <XObject> nodePath,
     IAttributedXObject attributedObject,
     XAttribute attribute,
     CancellationToken token
     )
 => Task.FromResult(CompletionContext.Empty);
Esempio n. 10
0
        public async virtual Task <CompletionContext> GetCompletionContextAsync(
            IAsyncCompletionSession session,
            CompletionTrigger trigger,
            SnapshotPoint triggerLocation,
            SnapshotSpan applicableToSpan,
            CancellationToken token)
        {
            var reason = ConvertReason(trigger.Reason, trigger.Character);

            if (reason == null)
            {
                return(CompletionContext.Empty);
            }

            var parser = BackgroundParser <TResult> .GetParser <TParser> ((ITextBuffer2)triggerLocation.Snapshot.TextBuffer);

            var spine = parser.GetSpineParser(triggerLocation);

            var(kind, _) = await Task.Run(() => XmlCompletionTriggering.GetTrigger(spine, reason.Value, trigger.Character), token).ConfigureAwait(false);

            if (kind != XmlCompletionTrigger.None)
            {
                List <XObject> nodePath = GetNodePath(spine, triggerLocation.Snapshot);

                switch (kind)
                {
                case XmlCompletionTrigger.Element:
                case XmlCompletionTrigger.ElementWithBracket:
                    //TODO: if it's on the first line and there's no XML declaration, add <"?xml version=\"1.0\" encoding=\"{encoding}\" ?>";
                    //TODO: if it's on the first or second line and there's no DTD declaration, add the DTDs, or at least <!DOCTYPE
                    //TODO: add closing tags // AddCloseTag (list, spine.Nodes);
                    //TODO: add snippets // MonoDevelop.Ide.CodeTemplates.CodeTemplateService.AddCompletionDataForFileName (DocumentContext.Name, list);
                    return(await GetElementCompletionsAsync(session, triggerLocation, nodePath, kind == XmlCompletionTrigger.ElementWithBracket, token));

                case XmlCompletionTrigger.Attribute:
                    IAttributedXObject attributedOb = (spine.Nodes.Peek() as IAttributedXObject) ?? spine.Nodes.Peek(1) as IAttributedXObject;
                    return(await GetAttributeCompletionsAsync(session, triggerLocation, nodePath, attributedOb, GetExistingAttributes (spine, triggerLocation.Snapshot, attributedOb), token));

                case XmlCompletionTrigger.AttributeValue:
                    if (spine.Nodes.Peek() is XAttribute att && spine.Nodes.Peek(1) is IAttributedXObject attributedObject)
                    {
                        return(await GetAttributeValueCompletionsAsync(session, triggerLocation, nodePath, attributedObject, att, token));
                    }
                    break;

                case XmlCompletionTrigger.Entity:
                    return(await GetEntityCompletionsAsync(session, triggerLocation, nodePath, token));

                case XmlCompletionTrigger.DocType:
                case XmlCompletionTrigger.DeclarationOrCDataOrComment:
                    return(await GetDeclarationCompletionsAsync(session, triggerLocation, nodePath, token));
                }
            }

            return(CompletionContext.Empty);
        }
 protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject ob, XAttribute att)
 {
     if (ob is XElement && !ob.Name.HasPrefix)
     {
         var list = new CompletionDataList();
         AddHtmlAttributeValueCompletionData(list, Schema, ob.Name, att.Name);
         return(list);
     }
     return(null);
 }
        protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
        {
            var list = base.GetAttributeValueCompletions(attributedOb, att) ?? new CompletionDataList();
            var ctx  = document.Compilation;

            GetType(attributedOb, delegate(IType type, ICompilation dom) {
                foreach (IProperty prop in type.GetProperties())
                {
                    if (prop.Name != att.Name.FullName)
                    {
                        continue;
                    }

                    //boolean completion
                    if (prop.ReturnType.Equals(ctx.FindType(typeof(bool))))
                    {
                        list.Add("true", "md-literal");
                        list.Add("false", "md-literal");
                        return;
                    }

                    //color completion
                    if (prop.ReturnType.ReflectionName == "System.Windows.Media.Color")
                    {
                        System.Drawing.ColorConverter conv = new System.Drawing.ColorConverter();
                        foreach (System.Drawing.Color c in conv.GetStandardValues(null))
                        {
                            if (c.IsSystemColor)
                            {
                                continue;
                            }
                            string hexcol = string.Format("#{0:x2}{1:x2}{2:x2}", c.R, c.G, c.B);
                            list.Add(c.Name, hexcol);
                        }
                        return;
                    }

                    //enum completion
                    var retCls = prop.ReturnType;
                    if (retCls != null && retCls.Kind == TypeKind.Enum)
                    {
                        foreach (var enumVal in retCls.GetFields())
                        {
                            if (enumVal.IsPublic && enumVal.IsStatic)
                            {
                                list.Add(enumVal.Name, "md-literal", enumVal.Documentation);
                            }
                        }
                        return;
                    }
                }
            });
            return(list.Count > 0? list : null);
        }
        protected override async Task <CompletionDataList> GetAttributeCompletions(IAttributedXObject attributedOb,
                                                                                   Dictionary <string, string> existingAtts, CancellationToken token)
        {
            var list = new CompletionDataList();

            if (attributedOb is XElement && !attributedOb.Name.HasPrefix)
            {
                await AddHtmlAttributeCompletionData(list, Schema, attributedOb.Name, existingAtts, token);
            }
            return(list);
        }
 protected override CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb,
                                                               Dictionary <string, string> existingAtts)
 {
     if (attributedOb is XElement && !attributedOb.Name.HasPrefix)
     {
         var list = new CompletionDataList();
         AddHtmlAttributeCompletionData(list, Schema, attributedOb.Name, existingAtts);
         return(list);
     }
     return(null);
 }
Esempio n. 15
0
        protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
        {
            CompletionDataList list = new CompletionDataList();
            CompletionContext  ctx  = GetCompletionContext(1);

            if (ctx != null)
            {
                ctx.SetCompletionAction(CompletionAction.AttributeValue, att.Name.Name);
                ctx.AddCompletionData(list);
            }
            return(list);
        }
Esempio n. 16
0
        protected override CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb, Dictionary <string, string> existingAtts)
        {
            CompletionDataList list = new CompletionDataList();
            CompletionContext  ctx  = GetCompletionContext(1);

            if (ctx != null)
            {
                ctx.SetCompletionAction(CompletionAction.AttributeStart, null);
                ctx.AddCompletionData(list);
            }
            return(list);
        }
		public override void GetAttributeValueCompletions (CompletionDataList list, IAttributedXObject attributedOb, XAttribute att)
		{
			if (att.Name.FullName != "path") {
				return;
			}

			foreach (var addin in GetReferencedAddins ()) {
				foreach (ExtensionPoint ep in addin.Description.ExtensionPoints) {
					list.Add (ep.Path, null, ep.Name + "\n" + ep.Description);
				}
			}
		}
Esempio n. 18
0
        protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
        {
            var list = base.GetAttributeValueCompletions(attributedOb, att) ?? new CompletionDataList();

            GetType(attributedOb, delegate(IType type, ProjectDom dom) {
                foreach (IProperty prop in GetAllProperties(dom, type))
                {
                    if (prop.Name != att.Name.FullName)
                    {
                        continue;
                    }

                    //boolean completion
                    if (prop.ReturnType.FullName == "System.Boolean")
                    {
                        list.Add("true", "md-literal");
                        list.Add("false", "md-literal");
                        return;
                    }

                    //color completion
                    if (prop.ReturnType.FullName == "System.Windows.Media.Color")
                    {
                        System.Drawing.ColorConverter conv = new System.Drawing.ColorConverter();
                        foreach (System.Drawing.Color c in conv.GetStandardValues(null))
                        {
                            if (c.IsSystemColor)
                            {
                                continue;
                            }
                            string hexcol = string.Format("#{0:x2}{1:x2}{2:x2}", c.R, c.G, c.B);
                            list.Add(c.Name, hexcol);
                        }
                        return;
                    }

                    //enum completion
                    MonoDevelop.Projects.Dom.IType retCls = dom.GetType(prop.ReturnType);
                    if (retCls != null && retCls.ClassType == MonoDevelop.Projects.Dom.ClassType.Enum)
                    {
                        foreach (MonoDevelop.Projects.Dom.IField enumVal in retCls.Fields)
                        {
                            if (enumVal.IsPublic && enumVal.IsStatic)
                            {
                                list.Add(enumVal.Name, "md-literal", enumVal.Documentation);
                            }
                        }
                        return;
                    }
                }
            });
            return(list.Count > 0? list : null);
        }
        protected override Task <CompletionDataList> GetAttributeCompletions(IAttributedXObject attributedOb, Dictionary <string, string> existingAtts, CancellationToken token)
        {
            XElement el;
            var      item = GetSchemaItem(GetCurrentPath(), out el);
            var      list = new CompletionDataList();

            if (item != null)
            {
                item.GetAttributeCompletions(list, attributedOb, existingAtts);
            }
            return(Task.FromResult(list));
        }
        protected override CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb, Dictionary <string, string> existingAtts)
        {
            XElement el;
            var      item = GetSchemaItem(GetCurrentPath(), out el);

            if (item != null)
            {
                var list = new CompletionDataList();
                item.GetAttributeCompletions(list, attributedOb, existingAtts);
                return(list);
            }
            return(null);
        }
        protected override Task <CompletionDataList> GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att, CancellationToken token)
        {
            XElement el;
            var      path = GetCurrentPath();
            var      item = GetSchemaItem(path.Take(path.Count - 1), out el);
            var      list = new CompletionDataList();

            if (item != null)
            {
                item.GetAttributeValueCompletions(list, attributedOb, att);
            }
            return(Task.FromResult(list));
        }
        protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
        {
            XElement el;
            var      path = GetCurrentPath();
            var      item = GetSchemaItem(path.Take(path.Count - 1), out el);

            if (item != null)
            {
                var list = new CompletionDataList();
                item.GetAttributeValueCompletions(list, attributedOb, att);
                return(list);
            }
            return(null);
        }
        protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
        {
            var path = GetElementPath();

            if (path.Elements.Count > 0)
            {
                var schema = FindSchema(path);
                if (schema != null)
                {
                    return(schema.GetAttributeValueCompletionData(path, att.Name.FullName));
                }
            }
            return(null);
        }
Esempio n. 24
0
 static XAttribute FindAttribute(this IAttributedXObject attContainer, int offset)
 {
     foreach (var att in attContainer.Attributes)
     {
         if (att.Span.Start > offset)
         {
             break;
         }
         if (att.Span.Contains(offset))
         {
             return(att);
         }
     }
     return(null);
 }
Esempio n. 25
0
//		static MonoDevelop.Core.TargetFramework GetProjectTargetFramework (MoonlightProject project)
//		{
//			return project == null? MonoDevelop.Core.TargetFramework.Default : project.TargetFramework;
//		}

        protected override CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb,
                                                                      Dictionary <string, string> existingAtts)
        {
            var list = base.GetAttributeCompletions(attributedOb, existingAtts) ?? new CompletionDataList();

            if (!existingAtts.ContainsKey("x:Name"))
            {
                list.Add("x:Name");
            }

            GetType(attributedOb, delegate(IType type, ProjectDom dom) {
                AddControlMembers(list, dom, type, existingAtts);
            });
            return(list.Count > 0? list : null);
        }
        protected override Task <CompletionDataList> GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att, CancellationToken token)
        {
            var path = GetElementPath();

            if (path.Elements.Count > 0)
            {
                var schema = FindSchema(path);

                if (schema != null)
                {
                    return(schema.GetAttributeValueCompletionData(path, att.Name.FullName, token));
                }
            }
            return(Task.FromResult(new CompletionDataList()));
        }
        public override void GetAttributeValueCompletions(CompletionDataList list, IAttributedXObject attributedOb, XAttribute att)
        {
            if (att.Name.FullName != "path")
            {
                return;
            }

            foreach (var addin in GetReferencedAddins())
            {
                foreach (ExtensionPoint ep in addin.Description.ExtensionPoints)
                {
                    list.Add(ep.Path, null, ep.Name + "\n" + ep.Description);
                }
            }
        }
		protected override CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb,
			Dictionary<string, string> existingAtts)
		{
			var el = GetMSBuildElement (GetCurrentPath ());

			if (el != null && el.Attributes != null) {
				var list = new CompletionDataList ();
				foreach (var a in el.Attributes)
					if (!existingAtts.ContainsKey (a))
						list.Add (new XmlCompletionData (a, XmlCompletionData.DataType.XmlElement));
				return list;
			}

			return null;
		}
        void GetType(IAttributedXObject attributedOb, Action <IType, ICompilation> action)
        {
            var database = GetDb();

            if (database == null)
            {
                return;
            }
            foreach (string namespc in namespaces)
            {
                var controlType = database.MainAssembly.GetTypeDefinition(namespc, attributedOb.Name.Name, 0);
                if (controlType != null)
                {
                    action(controlType, database);
                    break;
                }
            }
        }
        protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
        {
            XmlElementPath path = GetCurrentPath();

            if (path.Elements.Count > 0)
            {
                XmlSchemaCompletionData schema = FindSchema(path);
                if (schema != null)
                {
                    CompletionData[] completionData = schema.GetAttributeValueCompletionData(path, att.Name.FullName);
                    if (completionData != null)
                    {
                        return(new CompletionDataList(completionData));
                    }
                }
            }
            return(null);
        }
		public virtual void GetAttributeCompletions (CompletionDataList list, IAttributedXObject attributedOb, Dictionary<string, string> existingAtts)
		{
			if (attributes == null) {
				return;
			}

			foreach (var a in attributes) {
				if (existingAtts.ContainsKey (a.Key)) {
					continue;
				}

				if (a.Value.Exclude != null && a.Value.Exclude.Any (existingAtts.ContainsKey)) {
					continue;
				}

				list.Add (a.Value.Name, null, a.Value.Description);
			}
		}
Esempio n. 32
0
        void GetType(IAttributedXObject attributedOb, Action <IType, ProjectDom> action)
        {
            ProjectDom database = GetDb();

            if (database == null)
            {
                return;
            }
            foreach (string namespc in namespaces)
            {
                IType controlType = database.GetType(namespc + "." + attributedOb.Name.Name);
                if (controlType != null)
                {
                    action(controlType, database);
                    break;
                }
            }
        }
Esempio n. 33
0
        public static void AssertAttributes(this XmlParser parser, IAttributedXObject obj, params string[] nameValuePairs)
        {
            if ((nameValuePairs.Length % 2) != 0)
            {
                throw new ArgumentException("nameValuePairs");
            }

            int i = 0;

            foreach (XAttribute att in obj.Attributes)
            {
                Assert.IsTrue(i < nameValuePairs.Length);
                Assert.AreEqual(nameValuePairs[i], att.Name.FullName);
                Assert.AreEqual(nameValuePairs[i + 1], att.Value);
                i += 2;
            }
            Assert.AreEqual(nameValuePairs.Length, i);
        }
        protected override CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb,
                                                                      Dictionary <string, string> existingAtts)
        {
            var path = GetElementPath();

            if (path.Elements.Count > 0)
            {
                IXmlCompletionProvider schema = FindSchema(path);
                if (schema == null)
                {
                    schema = inferredCompletionData;
                }
                if (schema != null)
                {
                    return(schema.GetAttributeCompletionData(path));
                }
            }
            return(null);
        }
		public override void GetAttributeCompletions (CompletionDataList list, IAttributedXObject attributedOb, Dictionary<string, string> existingAtts)
		{
			if (!existingAtts.ContainsKey ("type")) {
				list.Add ("Gettext", null, "Localizes the add-in with a Gettext catalog.");
				list.Add ("StringResource", null, "Localizes the add-in with .NET string resources.");
				list.Add ("StringTable", null, "Localizes the add-in with string table defined in the manifest.");
				return;
			}

			string type;
			if (!existingAtts.TryGetValue ("type", out type)) {
				return;
			}

			if (type == "Gettext") {
				if (!existingAtts.ContainsKey ("catalog")) {
					list.Add ("catalog", null, "Name of the catalog which contains the strings.");
				}
				if (!existingAtts.ContainsKey ("location")) {
					list.Add ("location", null, "Relative path to the location of the catalog. This path must be relative to the add-in location..");
				}
			}
		}
		protected override CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb, Dictionary<string, string> existingAtts)
		{
			CompletionDataList list = new CompletionDataList ();
			CompletionContext ctx = GetCompletionContext (1);
			if (ctx != null) {
				ctx.SetCompletionAction (CompletionAction.AttributeStart, null);
				ctx.AddCompletionData (list);
			}
			return list;
		}
		protected override CompletionDataList GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att)
		{
			CompletionDataList list = new CompletionDataList ();
			CompletionContext ctx = GetCompletionContext (1);
			if (ctx != null) {
				ctx.SetCompletionAction (CompletionAction.AttributeValue, att.Name.Name);
				ctx.AddCompletionData (list);
			}
			return list;
		}
		protected override async Task<CompletionDataList> GetAttributeCompletions (IAttributedXObject attributedOb,
		                                                                     Dictionary<string, string> existingAtts, CancellationToken token)
		{
			var list = new CompletionDataList ();
			if (attributedOb is XElement && !attributedOb.Name.HasPrefix)
				await AddHtmlAttributeCompletionData (list, Schema, attributedOb.Name, existingAtts, token);
			return list;
		}
Esempio n. 39
0
		protected virtual CompletionDataList GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att)
		{
			return null;
		}
		public virtual void GetAttributeValueCompletions (CompletionDataList list, IAttributedXObject attributedOb, XAttribute att)
		{
			SchemaAttribute sca;
			if (attributes != null && attributes.TryGetValue (att.Name.FullName, out sca)) {
				sca.GetAttributeValueCompletions (list, attributedOb);
			}
		}
Esempio n. 41
0
		protected virtual Task<CompletionDataList> GetAttributeCompletions (IAttributedXObject attributedOb,
		                                                                    Dictionary<string, string> existingAtts, CancellationToken token)
		{
			return Task.FromResult (new CompletionDataList ());
		}
		protected override CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb,
			Dictionary<string, string> existingAtts)
		{
			var path = GetElementPath ();
			if (path.Elements.Count > 0) {
				IXmlCompletionProvider schema = FindSchema (path);
				if (schema == null)
					schema = inferredCompletionData;
				if (schema != null)
					return schema.GetAttributeCompletionData (path);
			}
			return null;
		}
		protected override Task<CompletionDataList> GetAttributeCompletions (IAttributedXObject attributedOb,
		                                                               Dictionary<string, string> existingAtts, CancellationToken token)
		{
			var path = GetElementPath ();

			if (path.Elements.Count > 0) {
				IXmlCompletionProvider schema = FindSchema (path);
				if (schema == null)
					schema = inferredCompletionData;

				if (schema != null)
					return schema.GetAttributeCompletionData (path, token);
			}
			return Task.FromResult (new CompletionDataList ());
		}
		protected override CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb,
			Dictionary<string, string> existingAtts)
		{
			var path = GetCurrentPath ();

			var rr = ResolveElement (path);
			if (rr == null)
				return null;

			var list = new CompletionDataList ();
			foreach (var a in rr.BuiltinAttributes)
				if (!existingAtts.ContainsKey (a))
					list.Add (new XmlCompletionData (a, XmlCompletionData.DataType.XmlAttribute));

			var inferredAttributes = GetInferredAttributes (rr);
			if (inferredAttributes != null)
				foreach (var a in inferredAttributes)
					if (!existingAtts.ContainsKey (a))
						list.Add (new XmlCompletionData (a, XmlCompletionData.DataType.XmlAttribute));

			return list;
		}
		protected override async Task<CompletionDataList> GetAttributeValueCompletions (IAttributedXObject ob, XAttribute att, CancellationToken token)
		{
			var list = new CompletionDataList ();
			if (ob is XElement && !ob.Name.HasPrefix)
				await AddHtmlAttributeValueCompletionData (list, Schema, ob.Name, att.Name, token);
			return list;
		}
Esempio n. 46
0
		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;
		}
Esempio n. 47
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;
		}
		protected override CompletionDataList GetAttributeValueCompletions (IAttributedXObject ob, XAttribute att)
		{
			if (ob is XElement && !ob.Name.HasPrefix) {
				var list = new CompletionDataList ();
				AddHtmlAttributeValueCompletionData (list, Schema, ob.Name, att.Name);
				return list;
			}
			return null;
		}
Esempio n. 49
0
		protected virtual CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb,
			Dictionary<string, string> existingAtts)
		{
			return null;
		}
		protected override CompletionDataList GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att)
		{
			XElement el;
			var path = GetCurrentPath ();
			var item = GetSchemaItem (path.Take (path.Count - 1), out el);
			if (item != null) {
				var list = new CompletionDataList ();
				item.GetAttributeValueCompletions (list, attributedOb, att);
				return list;
			}
			return null;
		}
Esempio n. 51
0
		protected override CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb, Dictionary<string, string> existingAtts)
		{
			return GetAttributeCompletions(attributedOb, existingAtts, XmlCompletionData.DataType.XmlAttribute, false);
		}
		protected override CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb, Dictionary<string, string> existingAtts)
		{
			XElement el;
			var item = GetSchemaItem (GetCurrentPath (), out el);
			if (item != null) {
				var list = new CompletionDataList ();
				item.GetAttributeCompletions (list, attributedOb, existingAtts);
				return list;
			}
			return null;
		}
		protected override CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb,
			Dictionary<string, string> existingAtts)
		{
			if (attributedOb is XElement && !attributedOb.Name.HasPrefix) {
				var list = new CompletionDataList ();
				AddHtmlAttributeCompletionData (list, Schema, attributedOb.Name, existingAtts);
				return list;
			}
			return null;
		}
		public override void GetAttributeValueCompletions (CompletionDataList list, IAttributedXObject attributedOb)
		{
			list.Add ("true");
			list.Add ("false");
		}
Esempio n. 55
0
		protected virtual Task<CompletionDataList> GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att, CancellationToken token)
		{
			return Task.FromResult (new CompletionDataList ());
		}
		protected override Task<CompletionDataList> GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att, CancellationToken token)
		{
			var path = GetElementPath ();

			if (path.Elements.Count > 0) {
				var schema = FindSchema (path);

				if (schema != null)
					return schema.GetAttributeValueCompletionData (path, att.Name.FullName, token);
			}
			return Task.FromResult (new CompletionDataList ());
		}
		public virtual void GetAttributeValueCompletions (CompletionDataList list, IAttributedXObject attributedOb)
		{
		}
		protected override CompletionDataList GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att)
		{
			XmlElementPath path = GetCurrentPath ();
			if (path.Elements.Count > 0) {
				XmlSchemaCompletionData schema = FindSchema (path);
				if (schema != null) {
					CompletionData[] completionData = schema.GetAttributeValueCompletionData (path, att.Name.FullName);
					if (completionData != null)
						return new CompletionDataList (completionData);
				}
			}
			return null;
		}
		protected override CompletionDataList GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att)
		{
			var path = GetElementPath ();
			if (path.Elements.Count > 0) {
				var schema = FindSchema (path);
				if (schema != null)
					return schema.GetAttributeValueCompletionData (path, att.Name.FullName);
			}
			return null;
		}
		public override void GetAttributeValueCompletions (CompletionDataList list, IAttributedXObject attributedOb, XAttribute att)
		{
			var name = att.Name.FullName;

			if (name == "insertbefore" || name == "insertafter") {
				//TODO: conditions, children
				foreach (var ext in GetExtensions (proj, extensionPoint)) {
					foreach (ExtensionNodeDescription node in ext.ExtensionNodes) {
						if (!string.IsNullOrEmpty (node.Id)) {
							list.Add (node.Id, null, "From " + node.ParentAddinDescription.AddinId);
						}
					}
				}
			}
		}