Nemerle.VisualStudio.Project.NemerleProjectNode.AddNewFileNodeToHierarchy C# (CSharp) Method

AddNewFileNodeToHierarchy() protected method

protected AddNewFileNodeToHierarchy ( HierarchyNode parentNode, string fileName ) : void
parentNode HierarchyNode
fileName string
return void
        protected override void AddNewFileNodeToHierarchy(HierarchyNode parentNode, string fileName)
        {
            HierarchyNode child;
            HierarchyNode newParent;

            // KLiss: try to find possible parent file (ie, Form3.n would be parent for Form3.designer.n
            bool parentFound = TryFindParentFileNode(parentNode, fileName, out newParent);
            if (parentFound)
            {
                parentNode = newParent;

                // KLiss: when file is added to project, it is treated as code file,
                // regardless of SubType value, specified in the template.
                // SubType is assigned correct value later, and now we will make another
                // attempt to find out, whether it is OK for an item to have designer, or not.
                var nemerleParent = parentNode as NemerleFileNode;
                if (nemerleParent != null)
                {
                    nemerleParent.InferHasDesignerFromSubType();
                }
            }

            // In the case of subitem, we want to create dependent file node
            // and set the DependentUpon property
            if (parentFound || parentNode is FileNode || parentNode is DependentFileNode)
            {
                child = this.CreateDependentFileNode(fileName);

                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (!child.HasParentNodeNameRelation && string.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(fileName);
            }

            parentNode.AddChild(child);

            var projectInfo = ProjectInfo;

            if (projectInfo != null)
                projectInfo.Engine.RequestOnBuildTypesTree();

            //// TODO : Revisit the VSADDFILEFLAGS here. Can it be a nested project?
            this.Tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }