/// <summary>
        /// Links a reference node to the project and hierarchy.
        /// </summary>
        protected override void BindReferenceData()
        {
            Debug.Assert(AssemblyName != null, "The AssemblyName field has not been initialized");

            // If the item has not been set correctly like in case of a new reference added it now.
            // The constructor for the AssemblyReference node will create a default project item. In that case the Item is null.
            // We need to specify here the correct project element.
            if (ItemNode == null || ItemNode.Item == null)
            {
                ItemNode = new ProjectElement(ProjectMgr, AssemblyName.FullName, NemerleConstants.MacroReference);
            }

            // Set the basic information we know about
            ItemNode.SetMetadata(ProjectFileConstants.Name, AssemblyName.Name);
            ItemNode.SetMetadata(ProjectFileConstants.AssemblyName, Path.GetFileName(Url));

            var fullFilePath    = Path.GetFullPath(Url);
            var fullProjectPath = Path.GetFullPath(ProjectMgr.ProjectFolder);
            var relativePath    = Utils.GetRelativePath(fullProjectPath, fullFilePath);

            // Set a default HintPath for msbuild to be able to resolve the reference.
            ItemNode.SetMetadata(ProjectFileConstants.HintPath, relativePath);

            // Предотвращаем копирование макро-сборки в каталог собираемого проекта
            ItemNode.SetMetadata(ProjectFileConstants.Private, "False");
        }
示例#2
0
        protected override void BindReferenceData()
        {
            base.BindReferenceData();

            string path         = null;
            var    fullFilePath = Path.GetFullPath(Url);
            // Пробуем определить не является ли путь путем указанным в переменной среды окружения Nemerle...
            var dir    = Path.GetFullPath(Path.GetDirectoryName(fullFilePath));
            var envVar = Environment.GetEnvironmentVariable("Nemerle");

            if (!string.IsNullOrEmpty(envVar))
            {
                envVar = Path.GetFullPath(envVar);
                if (string.Equals(dir, envVar, StringComparison.InvariantCultureIgnoreCase))
                {
                    path = Path.Combine("$(Nemerle)\\", Path.GetFileName(fullFilePath));
                }
            }

            if (path == null)
            {
                // Делаем HintPath относительным путем...
                // Это позволит переносить проекты с машины на машину без изменений.

                var fullProjectPath = Path.GetFullPath(ProjectMgr.ProjectFolder);
                path = Utils.GetRelativePath(fullProjectPath, fullFilePath);
            }

            // Set a default HintPath for msbuild to be able to resolve the reference.
            ItemNode.SetMetadata(ProjectFileConstants.HintPath, path);
        }
 /// <summary>
 /// Links a reference node to the project file.
 /// </summary>
 protected override void BindReferenceData()
 {
     base.BindReferenceData();
     this.ItemNode.ItemName = NemerleConstants.MacroProjectReference;
     // Предотвращаем копирование макро-сборки в каталог собираемого проекта
     ItemNode.SetMetadata(ProjectFileConstants.Private, "False");
 }
示例#4
0
        public AssembleFileNode(ProjectNode root, ProjectElement e)
            :       base(root, e)
        {
            ExcludeNodeFromScc = true;

            // Give it a guid if it does not already have one.

            if (string.IsNullOrEmpty(ItemNode.GetMetadata(Constants.Project.Item.Assemble.Guid.Name)))
            {
                ItemNode.SetMetadata(Constants.Project.Item.Assemble.Guid.Name, System.Guid.NewGuid().ToString("B"));
            }
        }
        protected override void BindReferenceData()
        {
            if (ItemNode == null || ItemNode.Item == null)
            {
                ItemNode = new ProjectElement(ProjectMgr, AssemblyName.Name, ProjectFileConstants.Reference);
            }

            // Set the basic information we know about.

            ItemNode.SetMetadata(ProjectFileConstants.Name, AssemblyName.Name);
            ItemNode.SetMetadata(ProjectFileConstants.AssemblyName, Path.GetFileName(Url));
            ItemNode.SetMetadata(ProjectFileConstants.HintPath, FileSystem.GetRelativePath(Url, Path.GetDirectoryName(ProjectMgr.Url)));
        }
示例#6
0
        /// <summary>
        /// Links a reference node to the project and hierarchy.
        /// </summary>
        protected override void BindReferenceData()
        {
            string relativePath = CommonUtils.GetRelativeFilePath(ProjectMgr.ProjectFolder, _filename);

            // If the item has not been set correctly like in case of a new reference added it now.
            // The constructor for the AssemblyReference node will create a default project item. In that case the Item is null.
            // We need to specify here the correct project element.
            if (ItemNode == null || ItemNode is VirtualProjectElement)
            {
                ItemNode = new MsBuildProjectElement(ProjectMgr, relativePath, ProjectFileConstants.Reference);
            }

            // Set the basic information we know about
            ItemNode.SetMetadata(ProjectFileConstants.Name, Path.GetFileName(_filename));
            ItemNode.SetMetadata(PythonConstants.PythonExtension, relativePath);
        }
示例#7
0
        /// <summary>
        /// Links a reference node to the project and hierarchy.
        /// </summary>
        protected override void BindReferenceData()
        {
            Debug.Assert(_feed != null, "The _feed field has not been initialized");

            // If the item has not been set correctly like in case of a new reference added it now.
            // The constructor for the AssemblyReference node will create a default project item. In that case the Item is null.
            // We need to specify here the correct project element.
            if (ItemNode == null || ItemNode is VirtualProjectElement)
            {
                ItemNode = new MsBuildProjectElement(
                    ProjectMgr,
                    _feed + "?" + _productId,
                    ProjectFileConstants.WebPiReference
                    );
            }

            // Set the basic information we know about
            ItemNode.SetMetadata("Feed", _feed);
            ItemNode.SetMetadata("ProductId", _productId);
            ItemNode.SetMetadata("FriendlyName", _friendlyName);
        }
示例#8
0
        /// <summary>
        /// Performs a SaveAs operation of an open document. Called from SaveItem after the running document table has been updated with the new doc data.
        /// </summary>
        /// <param name="docData">A pointer to the document in the rdt</param>
        /// <param name="newFilePath">The new file path to the document</param>
        /// <returns></returns>
        internal override int AfterSaveItemAs(IntPtr docData, string newFilePath)
        {
            Utilities.ArgumentNotNullOrEmpty("newFilePath", newFilePath);

            int returnCode = VSConstants.S_OK;

            newFilePath = newFilePath.Trim();

            //Identify if Path or FileName are the same for old and new file
            string newDirectoryName = CommonUtils.NormalizeDirectoryPath(Path.GetDirectoryName(newFilePath));
            string oldDirectoryName = CommonUtils.NormalizeDirectoryPath(Path.GetDirectoryName(this.GetMkDocument()));
            bool   isSamePath       = CommonUtils.IsSameDirectory(newDirectoryName, oldDirectoryName);
            bool   isSameFile       = CommonUtils.IsSamePath(newFilePath, this.Url);

            //Get target container
            HierarchyNode targetContainer = null;
            bool          isLink          = false;

            if (isSamePath)
            {
                targetContainer = this.Parent;
            }
            else if (!CommonUtils.IsSubpathOf(this.ProjectMgr.ProjectHome, newDirectoryName))
            {
                targetContainer = this.Parent;
                isLink          = true;
            }
            else if (CommonUtils.IsSameDirectory(this.ProjectMgr.ProjectHome, newDirectoryName))
            {
                //the projectnode is the target container
                targetContainer = this.ProjectMgr;
            }
            else
            {
                //search for the target container among existing child nodes
                targetContainer = this.ProjectMgr.FindNodeByFullPath(newDirectoryName);
                if (targetContainer != null && (targetContainer is FileNode))
                {
                    // We already have a file node with this name in the hierarchy.
                    throw new InvalidOperationException(SR.GetString(SR.FileAlreadyExistsAndCannotBeRenamed, Path.GetFileName(newFilePath)));
                }
            }

            if (targetContainer == null)
            {
                // Add a chain of subdirectories to the project.
                string relativeUri = CommonUtils.GetRelativeDirectoryPath(this.ProjectMgr.ProjectHome, newDirectoryName);
                targetContainer = this.ProjectMgr.CreateFolderNodes(relativeUri);
            }
            Utilities.CheckNotNull(targetContainer, "Could not find a target container");

            //Suspend file changes while we rename the document
            string             oldrelPath = this.ItemNode.GetMetadata(ProjectFileConstants.Include);
            string             oldName    = CommonUtils.GetAbsoluteFilePath(this.ProjectMgr.ProjectHome, oldrelPath);
            SuspendFileChanges sfc        = new SuspendFileChanges(this.ProjectMgr.Site, oldName);

            sfc.Suspend();

            try
            {
                // Rename the node.
                DocumentManager.UpdateCaption(this.ProjectMgr.Site, Path.GetFileName(newFilePath), docData);
                // Check if the file name was actually changed.
                // In same cases (e.g. if the item is a file and the user has changed its encoding) this function
                // is called even if there is no real rename.
                if (!isSameFile || (this.Parent.ID != targetContainer.ID))
                {
                    // The path of the file is changed or its parent is changed; in both cases we have
                    // to rename the item.
                    if (isLink != IsLinkFile)
                    {
                        if (isLink)
                        {
                            var newPath = CommonUtils.GetRelativeFilePath(
                                this.ProjectMgr.ProjectHome,
                                Path.Combine(Path.GetDirectoryName(Url), Path.GetFileName(newFilePath))
                                );

                            ItemNode.SetMetadata(ProjectFileConstants.Link, newPath);
                        }
                        else
                        {
                            ItemNode.SetMetadata(ProjectFileConstants.Link, null);
                        }
                        SetIsLinkFile(isLink);
                    }

                    RenameFileNode(oldName, newFilePath, targetContainer);
                    ProjectMgr.OnInvalidateItems(this.Parent);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Exception : " + e.Message);
                this.RecoverFromRenameFailure(newFilePath, oldrelPath);
                throw;
            }
            finally
            {
                sfc.Resume();
            }

            return(returnCode);
        }