示例#1
0
		public static MSBuildElement Get (string name, MSBuildElement parent = null)
		{
			//if not in parent's known children, and parent has special children, then it's a special child
			if (parent != null && parent.ChildType != null && !parent.HasChild (name))
				name = parent.ChildType;
			MSBuildElement result;
			builtin.TryGetValue (name, out result);
			return result;
		}
示例#2
0
        public static MSBuildElement Get(string name, MSBuildElement parent = null)
        {
            //if not in parent's known children, and parent has special children, then it's a special child
            if (parent != null && parent.ChildType != null && !parent.HasChild(name))
            {
                name = parent.ChildType;
            }
            MSBuildElement result;

            builtin.TryGetValue(name, out result);
            return(result);
        }
示例#3
0
        void Populate(XDocument doc)
        {
            var project = doc.Nodes.OfType <XElement> ().FirstOrDefault(x => x.Name == xnProject);

            if (project == null)
            {
                return;
            }
            var pel = MSBuildElement.Get("Project");

            foreach (var el in project.Nodes.OfType <XElement> ())
            {
                Populate(el, pel);
            }
        }
        static ResolveResult ResolveElement(IList <XObject> path)
        {
            //need to look up element by walking how the path, since at each level, if the parent has special children,
            //then that gives us information to identify the type of its children
            MSBuildElement el = null;
            string         elName = null, elType = null;

            for (int i = 0; i < path.Count; i++)
            {
                //if children of parent is known to be arbitrary data, give up on completion
                if (el != null && el.ChildType == "Data")
                {
                    return(null);
                }
                //code completion is forgiving, all we care about best guess resolve for deepest child
                var xel = path [i] as XElement;
                if (xel != null && xel.Name.Prefix == null)
                {
                    if (el != null)
                    {
                        elType = el.ChildType;
                    }
                    elName = xel.Name.Name;
                    el     = MSBuildElement.Get(elName, el);
                    if (el != null)
                    {
                        continue;
                    }
                }
                el     = null;
                elName = elType = null;
            }
            if (el == null)
            {
                return(null);
            }

            return(new ResolveResult {
                ElementName = elName,
                ElementType = elType,
                ChildType = el.ChildType,
                BuiltinAttributes = el.Attributes,
                BuiltinChildren = el.Children,
            });
        }
		void Populate (XElement el, MSBuildElement parent)
		{
			if (el.Name.Prefix != null)
				return;

			var name = el.Name.Name;
			var msel = MSBuildElement.Get (name, parent);
			if (msel == null || !msel.IsSpecial) {
				foreach (var child in el.Nodes.OfType<XElement> ())
					Populate (child, msel);
				return;
			}

			switch (parent.ChildType) {
			case "Item":
				HashSet<string> item;
				if (!items.TryGetValue (name, out item))
					items [name] = item = new HashSet<string> ();
				foreach (var metadata in el.Nodes.OfType<XElement> ())
					if (!metadata.Name.HasPrefix)
						item.Add (metadata.Name.Name);
				break;
			case "Property":
				properties.Add (name);
				break;
			case "Import":
				var import = el.Attributes [xnProject];
				if (import != null && string.IsNullOrEmpty (import.Value))
					imports.Add (import.Value);
				break;
			case "Task":
				HashSet<string> task;
				if (!tasks.TryGetValue (name, out task))
					tasks [name] = task = new HashSet<string> ();
				foreach (var att in el.Attributes)
					if (!att.Name.HasPrefix)
						task.Add (att.Name.Name);
				break;
			case "Parameter":
				//TODO: Parameters
				break;
			}
		}
示例#6
0
        void Populate(XElement el, MSBuildElement parent)
        {
            if (el.Name.Prefix != null)
            {
                return;
            }

            var name = el.Name.Name;
            var msel = MSBuildElement.Get(name, parent);

            if (msel == null || !msel.IsSpecial)
            {
                foreach (var child in el.Nodes.OfType <XElement> ())
                {
                    Populate(child, msel);
                }
                return;
            }

            switch (parent.ChildType)
            {
            case "Item":
                HashSet <string> item;
                if (!items.TryGetValue(name, out item))
                {
                    items [name] = item = new HashSet <string> ();
                }
                foreach (var metadata in el.Nodes.OfType <XElement> ())
                {
                    if (!metadata.Name.HasPrefix)
                    {
                        item.Add(metadata.Name.Name);
                    }
                }
                break;

            case "Property":
                properties.Add(name);
                break;

            case "Import":
                var import = el.Attributes [xnProject];
                if (import != null && string.IsNullOrEmpty(import.Value))
                {
                    imports.Add(import.Value);
                }
                break;

            case "Task":
                HashSet <string> task;
                if (!tasks.TryGetValue(name, out task))
                {
                    tasks [name] = task = new HashSet <string> ();
                }
                foreach (var att in el.Attributes)
                {
                    if (!att.Name.HasPrefix)
                    {
                        task.Add(att.Name.Name);
                    }
                }
                break;

            case "Parameter":
                //TODO: Parameters
                break;
            }
        }