Ejemplo n.º 1
0
		/// <summary>
		/// Gets called when an item is removed.
		/// </summary>
		internal void OnItemRemoved(string file, VSREMOVEFILEFLAGS flag)
		{
			if ((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0)
			{
				ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterRemoveFiles(this.projectMgr, 1, new string[1] { file }, new VSREMOVEFILEFLAGS[1] { flag }));
			}
		}
        public override int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] projects, int[] firstIndices, string[] oldFileNames, VSREMOVEFILEFLAGS[] flags)
        {
            //Get the current value of the MainFile Property
            string currentMainFile = this.project.GetProjectProperty(PythonProjectFileConstants.MainFile, true);
            string fullPathToMainFile = Path.Combine(Path.GetDirectoryName(this.project.BaseURI.Uri.LocalPath), currentMainFile);

            //Investigate all of the oldFileNames if they belong to the current project and if they are equal to the current MainFile
            int index = 0;
            foreach(string oldfile in oldFileNames)
            {
                //Compare this project with the project that the old file belongs to
                IVsProject belongsToProject = projects[firstIndices[index]];
                if(Utilities.IsSameComObject(belongsToProject, this.project))
                {
                    //Compare the files and update the MainFile Property if the currentMainFile is an old file
                    if(NativeMethods.IsSamePath(oldfile, fullPathToMainFile))
                    {
                        //Get the first available py file in the project and update the MainFile property
                        List<PythonFileNode> pythonFileNodes = new List<PythonFileNode>();
                        this.project.FindNodesOfType<PythonFileNode>(pythonFileNodes);
                        string newMainFile = string.Empty;
                        if(pythonFileNodes.Count > 0)
                        {
                            newMainFile = pythonFileNodes[0].GetRelativePath();
                        }
                        this.project.SetProjectProperty(PythonProjectFileConstants.MainFile, newMainFile);
                        break;
                    }
                }

                index++;
            }

            return VSConstants.S_OK;
        }
        // ------------------------------------------------------
        public int OnAfterRemoveFiles(int cProjects, int cFiles,
			IVsProject[] rgpProjects, int[] rgFirstIndices,
			string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            CxxTestPackage.Instance.TryToRefreshTestSuitesWindow();

            return VSConstants.S_OK;
        }
 int IVsTrackProjectDocumentsEvents2.OnAfterRemoveFiles(
     int cProjects,
     int cFiles,
     IVsProject[] rgpProjects,
     int[] rgFirstIndices,
     string[] rgpszMkDocuments,
     VSREMOVEFILEFLAGS[] rgFlags)
 {
     return this.OnNotifyTestFileAddRemove(cProjects, rgpProjects, rgpszMkDocuments, rgFirstIndices, TestFileChangedReason.Removed);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Notify the environment about a file just removed
 /// </summary>
 public virtual void OnItemRemoved(string file, VSREMOVEFILEFLAGS flag)
 {
     if ((this.projectMgr.EventTriggeringFlag & SuppressEvents.Tracker) == 0)
     {
         ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterRemoveFiles(this.projectMgr.InteropSafeIVsProject3, 1, new string[1] {
             file
         }, new VSREMOVEFILEFLAGS[1] {
             flag
         }));
     }
 }
        public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices,
            string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            var args = new PostProjectRemoveFilesEventArgs(this.events)
            {
                Files = rgpszMkDocuments
            };

            //VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddOK;
            //VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddNotOK;

            this.events.TriggerPostProjectRemoveFiles(args);

            return VSConstants.S_OK;
        }
        public void NotifyRemoveFiles(IVsProject project, string[] files)
        {
            VSREMOVEFILEFLAGS[] addFlags = new VSREMOVEFILEFLAGS[files.Length];

            for (int i = 0; i < files.Length; i++)
            {
                addFlags[i] = VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags;
            }

            _eventSink.OnAfterRemoveFiles(
                1,
                files.Length,
                new[] { project },
                new[] { 0 },
                files,
                addFlags);
        }
        /// <summary>
        /// Sets the VSREMOVEFILEFLAGS that will be used to call the  IVsTrackProjectDocumentsEvents2 OnRemoveFiles
        /// </summary>
        /// <param name="files">The files to which an array of VSREMOVEFILEFLAGS has to be specified.</param>
        /// <returns></returns>
        protected internal override VSREMOVEFILEFLAGS[] GetRemoveFileFlags(string[] files)
        {
            if (files == null || files.Length == 0)
            {
                return(new VSREMOVEFILEFLAGS[1] {
                    VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags
                });
            }

            VSREMOVEFILEFLAGS[] removeFileFlags = new VSREMOVEFILEFLAGS[files.Length];

            for (int i = 0; i < files.Length; i++)
            {
                removeFileFlags[i] = VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_IsNestedProjectFile;
            }

            return(removeFileFlags);
        }
        public override int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] projects, int[] firstIndices, string[] oldFileNames, VSREMOVEFILEFLAGS[] flags) {
            if (!_project.IsRefreshing) {
                //Get the current value of the StartupFile Property
                string currentStartupFile = _project.GetProjectProperty(CommonConstants.StartupFile, true);
                string fullPathToStartupFile = CommonUtils.GetAbsoluteFilePath(_project.ProjectHome, currentStartupFile);

                //Investigate all of the oldFileNames if they are equal to the current StartupFile
                int index = 0;
                foreach (string oldfile in oldFileNames) {
                    //Compare the files and update the StartupFile Property if the currentStartupFile is an old file
                    if (CommonUtils.IsSamePath(oldfile, fullPathToStartupFile)) {
                        //Startup file has been removed
                        _project.SetProjectProperty(CommonConstants.StartupFile, null);
                        break;
                    }
                    index++;
                }
            }
            return VSConstants.S_OK;
        }
Ejemplo n.º 10
0
        public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            if (rgpProjects == null || rgpszMkDocuments == null)
                return VSConstants.E_POINTER;

            for (int i = 0; i < cFiles; i++)
            {
                string s = rgpszMkDocuments[i];

                if (!string.IsNullOrEmpty(s) && GitItem.IsValidPath(s))
                    StatusCache.MarkDirty(GitTools.GetNormalizedFullPath(s));
            }

            int iFile = 0;

            for (int iProject = 0; (iProject < cProjects) && (iFile < cFiles); iProject++)
            {
                int iLastFileThisProject = (iProject < cProjects - 1) ? rgFirstIndices[iProject + 1] : cFiles;

                IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2;
                bool track = SccProvider.TrackProjectChanges(sccProject);

                for (; iFile < iLastFileThisProject; iFile++)
                {
                    if (sccProject == null || !track)
                        continue; // Not handled by our provider

                    string file = rgpszMkDocuments[iFile];

                    if (string.IsNullOrEmpty(file) || !GitItem.IsValidPath(file))
                        continue;

                    file = GitTools.GetNormalizedFullPath(file);

                    SccProvider.OnProjectFileRemoved(sccProject, file, rgFlags[iFile]);
                }
            }
            return VSConstants.S_OK;
        }
Ejemplo n.º 11
0
        int IVsTrackProjectDocumentsEvents2.OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            for (int i = 0; i < rgpProjects.Length; i++)
            {
                int indexOfFirstDocumentInProject = IndexOfFirstDocumentInProject(i, rgFirstIndices);
                int indexOfFirstDocumentInNextProject = IndexOfFirstDocumentInProject(i + 1, rgFirstIndices);
                for (int j = indexOfFirstDocumentInProject; j < indexOfFirstDocumentInNextProject; j++)
                {
                    string fileFullPath = rgpszMkDocuments[j];
                    if (Path.GetExtension(fileFullPath).Equals(".ruleset", StringComparison.OrdinalIgnoreCase))
                    {
                        EnvDTE.Project project;
                        IVsHierarchy hierarchy = rgpProjects[i] as IVsHierarchy;
                        if (hierarchy != null &&
                            hierarchy.TryGetProject(out project))
                        {
                            UpdateCodeAnalysisRuleSetPropertiesInProject(project, fileFullPath, string.Empty);
                        }
                    }
                }
            }

            return VSConstants.S_OK;
        }
Ejemplo n.º 12
0
 public int OnAfterRemoveFiles(IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags) {
     return VSConstants.S_OK;
 }
Ejemplo n.º 13
0
 int IVsTrackProjectDocumentsEvents2.OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
 {
     GenerateEvents(rgpProjects, rgFirstIndices, rgpszMkDocuments, FileRemoved, new ProjectDocumentsChangeEventArgs());
     return NativeMethods.S_OK;
 }
Ejemplo n.º 14
0
 public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
 {
     foreach (var evt in GetEvents(cProjects, rgpProjects, rgFirstIndices, rgpszMkDocuments.Length))
     {
         OnFileRemoved(this, new ProjectFileRemovedEventArgs(evt.Project, rgpszMkDocuments[evt.ItemIndex]));
     }
     return VSConstants.S_OK;
 }
        /// <summary>
        /// Called when a file is removed from a project
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="flags">The flags.</param>
        internal void OnProjectFileRemoved(IVsSccProject2 project, string filename, VSREMOVEFILEFLAGS flags)
        {
            SccProjectData data;
            if (!_projectMap.TryGetValue(project, out data))
                return; // Not managed by us

            data.RemovePath(filename);

            if (!IsActive)
                return; // Let the other SCC package manage it

            MarkDirty(filename);

            if (GitUpdatesDisabled || !StatusCache[filename].IsVersioned)
                return; // Don't bother

            using (GitSccContext git = new GitSccContext(Context))
            {
                if (File.Exists(filename))
                {
                    // The file was only removed from the project. We should not touch it

                    // Some projects delete the file before (C#) and some after (C++) calling OnProjectFileRemoved
                    if (_delayedDelete == null)
                        _delayedDelete = new List<string>();

                    if (!_delayedDelete.Contains(filename))
                        _delayedDelete.Add(filename);

                    RegisterForSccCleanup();
                    return;
                }

                if (git.IsUnversioned(filename))
                    return;

                git.SafeDeleteFile(filename);
            }
        }
 public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags) {
     foreach (var file in rgpszMkDocuments) {
         DocumentEvents.Add("OnAfterRemoveFiles " + file);
         CodeDocumentEvents.Add("OnAfterRemoveFiles(" + GetRelativePath(rgpProjects[0], file) + ")");
     }
     return VSConstants.S_OK;
 }
Ejemplo n.º 17
0
        public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            HandleAddRemoveFiles(FileChangeType.Deleted, cProjects, cFiles, rgpProjects, rgFirstIndices, rgpszMkDocuments, CsFileDeleted, TemplateDeleted);

            return VSConstants.S_OK;
        }
Ejemplo n.º 18
0
 public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
 {
     return VSConstants.S_OK;
 }
Ejemplo n.º 19
0
        public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            for (int i = 0; i < rgpProjects.Length; i++)
                if (rgpProjects[i] == Project)
                {
                    int upBound = (rgFirstIndices.Length > i + 1) ? rgFirstIndices[i + 1] : rgpszMkDocuments.Length;
                    for (int j = rgFirstIndices[i]; j < upBound; j++)
                        FileRemoved(rgpszMkDocuments[j]);
                }

            return VSConstants.S_OK;
        }
 public int OnAfterRemoveFiles(int projectsLength, int filesLength, IVsProject[] projects, int[] indices,
                               string[] names, VSREMOVEFILEFLAGS[] rgFlags)
 {
     try
     {
         for(int i = 0; i < projectsLength; ++i)
         {
             EnvDTE.Project project = DTEUtil.GetProject(projects[i] as IVsHierarchy);
             if (DTEUtil.IsIceBuilderEnabled(project))
             {
                 int j = indices[i];
                 int k = i < (projectsLength - 1) ? indices[i + 1] : filesLength;
                 for (; j < k; ++j)
                 {
                     if(ProjectUtil.IsSliceFileName(names[j]))
                     {
                         ProjectUtil.DeleteItems(project, ProjectUtil.GetGeneratedFiles(project, names[i]));
                     }
                 }
                 Package.Instance.FileTracker.Reap(project);
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
         throw;
     }
     return 0;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// This method notifies the client after files are removed from the project.
 /// </summary>
 /// <param name="cProjects"></param>
 /// <param name="cFiles"></param>
 /// <param name="rgpProjects"></param>
 /// <param name="rgFirstIndices"></param>
 /// <param name="rgpszMkDocuments"></param>
 /// <param name="rgFlags"></param>
 /// <returns></returns>
 int IVsTrackProjectDocumentsEvents2.OnAfterRemoveFiles(int cProjects,
                                                        int cFiles,
                                                        IVsProject[] rgpProjects,
                                                        int[] rgFirstIndices,
                                                        string[] rgpszMkDocuments,
                                                        VSREMOVEFILEFLAGS[] rgFlags) {
     //////SrcMLFileLogger.DefaultLogger.Info("==> Triggered IVsTrackProjectDocumentsEvents2.OnAfterRemoveFiles()");
     return OnNotifyFileAddRemove(cProjects, cFiles, rgpProjects, rgFirstIndices, rgpszMkDocuments, FileEventType.FileDeleted);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Notify the environment about a file just removed
 /// </summary>
 /*internal, but public for FSharp.Project.dll*/ public void OnItemRemoved(string file, VSREMOVEFILEFLAGS flag)
 {
     if ((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0)
     {
         ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterRemoveFiles(projectMgr.InteropSafeIVsProject, 1, new string[1] {
             file
         }, new VSREMOVEFILEFLAGS[1] {
             flag
         }));
     }
 }
 /// <summary>
 /// Notify the environment about a file just removed
 /// </summary>
 public virtual void OnItemRemoved(string file, VSREMOVEFILEFLAGS flag)
 {
     if((this.projectMgr.EventTriggeringFlag & SuppressEvents.Tracker) == 0)
     {
         ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterRemoveFiles(this.projectMgr.InteropSafeIVsProject3, 1, new string[1] { file }, new VSREMOVEFILEFLAGS[1] { flag }));
     }
 }
		/// <summary>
		/// Notify the environment about a file just removed
		/// </summary>
		internal void OnItemRemoved(string file, VSREMOVEFILEFLAGS flag)
		{
			if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0)
			{
				ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterRemoveFiles(this.projectMgr, 1, new string[1] { file }, new VSREMOVEFILEFLAGS[1] { flag }));
			}
		}
Ejemplo n.º 25
0
        int IVsTrackProjectDocumentsEvents2.OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            if (rgpProjects == null || rgpszMkDocuments == null)
            {
                return VSConstants.E_POINTER;
            }

            OnAfterRemoveFiles(rgpszMkDocuments);
            return VSConstants.S_OK;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Sets the VSREMOVEFILEFLAGS that will be used to call the  IVsTrackProjectDocumentsEvents2 OnRemoveFiles
        /// </summary>
        /// <param name="files">The files to which an array of VSREMOVEFILEFLAGS has to be specified.</param>
        /// <returns></returns>
        protected internal override VSREMOVEFILEFLAGS[] GetRemoveFileFlags(string[] files)
        {
            if (files == null || files.Length == 0)
            {
                return new VSREMOVEFILEFLAGS[1] { VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags };
            }

            VSREMOVEFILEFLAGS[] removeFileFlags = new VSREMOVEFILEFLAGS[files.Length];

            for (int i = 0; i < files.Length; i++)
            {
                removeFileFlags[i] = VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_IsNestedProjectFile;
            }

            return removeFileFlags;
        }
Ejemplo n.º 27
0
        public void NotifyRemoveFiles(IVsProject project, string[] files)
        {
            var addFlags = new VSREMOVEFILEFLAGS[files.Length];

            for (int i = 0; i < files.Length; i++)
            {
                addFlags[i] = VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags;
            }

            _eventSink.OnAfterRemoveFiles(
                1,
                files.Length,
                new[] { project },
                new[] { 0 },
                files,
                addFlags);
        }
        public int OnAfterRemoveFiles(
            int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments,
            VSREMOVEFILEFLAGS[] rgFlags)
        {
            var hr = VSConstants.S_OK;
            var handler = AfterRemoveFile;
            if (handler != null)
            {
                if (cFiles <= rgpszMkDocuments.Length)
                {
                    for (var fileCount = 0; fileCount < cFiles; fileCount++)
                    {
                        var args = new ModelChangeEventArgs();
                        args.OldFileName = rgpszMkDocuments[fileCount];
                        args.ProjectObj = GetProjectFromArray(cProjects, fileCount, rgpProjects, rgFirstIndices);
                        if (args.ProjectObj == null)
                        {
                            continue;
                        }

                        hr = handler(this, args);
                    }
                }
            }
            return hr;
        }
Ejemplo n.º 29
0
 int IVsTrackProjectDocumentsEvents2.OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
 {
     _flavoredProjectBase.GenerateEvents(rgpProjects, rgFirstIndices, rgpszMkDocuments, _flavoredProjectBase.FileRemoved, new ProjectDocumentsChangeEventArgs());
     return VSConstants.S_OK;
 }
Ejemplo n.º 30
0
        public int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
        {
            var paths = ExtractPath(cProjects, cFiles, rgpProjects, rgFirstIndices, rgpszMkDocuments);
            if (FileDeleted != null)
            {
                foreach (var path in paths)
                {
                    FileDeleted(this, new FileDeletedEventArgs(path));
                }
            }

            return VSConstants.S_OK;
        }
 public int OnAfterRemoveFiles(IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags)
 {
     throw new NotImplementedException();
 }