/// <summary> /// Gets called when an item is added. /// </summary> internal void OnItemAdded(string file, VSADDFILEFLAGS flag) { if ((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0) { ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterAddFilesEx(this.projectMgr, 1, new string[1] { file }, new VSADDFILEFLAGS[1] { flag })); } }
public override int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] projects, int[] firstIndices, string[] newFileNames, VSADDFILEFLAGS[] flags) { //Get the current value of the MainFile Property string currentMainFile = this.project.GetProjectProperty(PythonProjectFileConstants.MainFile, true); if(!string.IsNullOrEmpty(currentMainFile)) //No need for further operation since MainFile is already set return VSConstants.S_OK; string fullPathToMainFile = Path.Combine(Path.GetDirectoryName(this.project.BaseURI.Uri.LocalPath), currentMainFile); //Investigate all of the newFileNames if they belong to the current project and set the first pythonFileNode found equal to MainFile int index = 0; foreach(string newfile in newFileNames) { //Compare this project with the project that the new file belongs to IVsProject belongsToProject = projects[firstIndices[index]]; if(Utilities.IsSameComObject(belongsToProject, this.project)) { //If the newfile is a python filenode we willl map this file to the MainFile property PythonFileNode filenode = project.FindChild(newfile) as PythonFileNode; if(filenode != null) { this.project.SetProjectProperty(PythonProjectFileConstants.MainFile, filenode.GetRelativePath()); break; } } index++; } return VSConstants.S_OK; }
// ------------------------------------------------------ public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { CxxTestPackage.Instance.TryToRefreshTestSuitesWindow(); return VSConstants.S_OK; }
int IVsTrackProjectDocumentsEvents2.OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { return OnNotifyTestFileAddRemove(cProjects, rgpProjects, rgpszMkDocuments, rgFirstIndices, TestFileChangedReason.Added); }
/// <summary> /// Notify the environment about a file just added /// </summary> public virtual void OnItemAdded(string file, VSADDFILEFLAGS flag) { if ((this.projectMgr.EventTriggeringFlag & SuppressEvents.Tracker) == 0) { ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterAddFilesEx(this.projectMgr.InteropSafeIVsProject3, 1, new string[1] { file }, new VSADDFILEFLAGS[1] { flag })); } }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { if (FileAdded != null) { var paths = ExtractPath(cProjects, cFiles, rgpProjects, rgFirstIndices, rgpszMkDocuments); foreach (var path in paths) { FileAdded(this, new FileAddedEventArgs(path)); } } return VSConstants.S_OK; }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { var args = new PostProjectAddFilesEventArgs(this.events) { Files = rgpszMkDocuments }; //VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddOK; //VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddNotOK; this.events.TriggerPostProjectAddFiles(args); return VSConstants.S_OK; }
public virtual void NotifyAddFiles(IVsProject project, string[] files) { VSADDFILEFLAGS[] addFlags = new VSADDFILEFLAGS[files.Length]; for (int i = 0; i < files.Length; i++) { addFlags[i] = VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags; } _eventSink.OnAfterAddFilesEx( 1, files.Length, new[] { project }, new[] { 0 }, files, addFlags); }
/// <summary> /// Sets the VSADDFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnAddFiles /// </summary> /// <param name="files">The files to which an array of VSADDFILEFLAGS has to be specified.</param> /// <returns></returns> protected internal override VSADDFILEFLAGS[] GetAddFileFlags(string[] files) { if (files == null || files.Length == 0) { return(new VSADDFILEFLAGS[1] { VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags }); } VSADDFILEFLAGS[] addFileFlags = new VSADDFILEFLAGS[files.Length]; for (int i = 0; i < files.Length; i++) { addFileFlags[i] = VSADDFILEFLAGS.VSADDFILEFLAGS_IsNestedProjectFile; } return(addFileFlags); }
/// <summary> /// Called when a file is added to a project /// </summary> /// <param name="project">The project.</param> /// <param name="filename">The filename.</param> /// <param name="fileOrigin">The file origin.</param> /// <param name="flags">The flags.</param> internal void OnProjectFileAdded(IVsSccProject2 project, string filename, string fileOrigin, VSADDFILEFLAGS flags) { // First update the filemap SccProjectData data; if (!_projectMap.TryGetValue(project, out data)) return; // Not managed by us data.AddPath(filename); if (!IsActive) return; // Let the other SCC package manage it }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { InvalidateParentItems(new string[rgpszMkDocuments.Length], rgpszMkDocuments); return VSConstants.S_OK; }
public int OnAfterAddFilesEx(IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { throw new NotImplementedException(); }
/// <summary> /// Sets the VSADDFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnAddFiles /// </summary> /// <param name="files">The files to which an array of VSADDFILEFLAGS has to be specified.</param> /// <returns></returns> protected internal override VSADDFILEFLAGS[] GetAddFileFlags(string[] files) { if (files == null || files.Length == 0) { return new VSADDFILEFLAGS[1] { VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags }; } VSADDFILEFLAGS[] addFileFlags = new VSADDFILEFLAGS[files.Length]; for (int i = 0; i < files.Length; i++) { addFileFlags[i] = VSADDFILEFLAGS.VSADDFILEFLAGS_IsNestedProjectFile; } return addFileFlags; }
public int OnAfterAddFilesEx(IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { return VSConstants.S_OK; }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { foreach (var evt in GetEvents(cProjects, rgpProjects, rgFirstIndices, rgpszMkDocuments.Length)) { OnFileAdded(this, new ProjectFileAddedEventArgs(evt.Project, rgpszMkDocuments[evt.ItemIndex])); } return VSConstants.S_OK; }
/// <summary> /// This method notifies the client after a project has added files. /// </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.OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { //////SrcMLFileLogger.DefaultLogger.Info("==> Triggered IVsTrackProjectDocumentsEvents2.OnAfterAddFilesEx()"); return OnNotifyFileAddRemove(cProjects, cFiles, rgpProjects, rgFirstIndices, rgpszMkDocuments, FileEventType.FileAdded); }
/// <summary> /// This method notifies the client after a project has added files. /// </summary> /// <param name="cProjects">[in] Number of projects to which files were added.</param> /// <param name="cFiles">[in] Number of files that were added.</param> /// <param name="rgpProjects">[in] Array of projects to which files were added.</param> /// <param name="rgFirstIndices">[in] Array of first indices identifying which project each file belongs to. For more information, see IVsTrackProjectDocumentsEvents2.</param> /// <param name="rgpszMkDocuments">[in] Array of paths for the files that were processed. This is the same size as cFiles.</param> /// <param name="rgFlags">[in] Array of flags. For a list of rgFlags values, see <see cref="VSADDFILEFLAGS" />.</param> /// <returns></returns> public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { int iFile = 0; RegisterForSccCleanup(); // Clear the origins table after adding List<string> selectedFiles = null; bool sccActive = SccProvider.IsActive; 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 (!track) continue; // Not handled by our provider string origin = null; string newName = rgpszMkDocuments[iFile]; if (string.IsNullOrEmpty(newName) || !GitItem.IsValidPath(newName)) continue; newName = GitTools.GetNormalizedFullPath(rgpszMkDocuments[iFile]); if (sccActive && _solutionLoaded) { StatusCache.MarkDirty(newName); TryFindOrigin(newName, ref selectedFiles, out origin); } // We do this before the copies to make sure a failed copy doesn't break the project SccProvider.OnProjectFileAdded(sccProject, newName, origin, rgFlags[iFile]); } } return VSConstants.S_OK; }
/// <summary> /// Notify the environment about a file just added /// </summary> /*internal, but public for FSharp.Project.dll*/ public void OnItemAdded(string file, VSADDFILEFLAGS flag) { if ((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0) { ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterAddFilesEx(projectMgr.InteropSafeIVsProject, 1, new string[1] { file }, new VSADDFILEFLAGS[1] { flag })); } }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { foreach (var file in rgpszMkDocuments) { DocumentEvents.Add("OnAfterAddFilesEx " + file); CodeDocumentEvents.Add("OnAfterAddFilesEx(" + GetRelativePath(rgpProjects[0], file) + ")"); } return VSConstants.S_OK; }
int IVsTrackProjectDocumentsEvents2.OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { _flavoredProjectBase.GenerateEvents(rgpProjects, rgFirstIndices, rgpszMkDocuments, _flavoredProjectBase.FileAdded, new ProjectDocumentsChangeEventArgs()); return VSConstants.S_OK; }
/// <summary> /// Notify the environment about a file just added /// </summary> public virtual void OnItemAdded(string file, VSADDFILEFLAGS flag) { if((this.projectMgr.EventTriggeringFlag & SuppressEvents.Tracker) == 0) { ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterAddFilesEx(this.projectMgr.InteropSafeIVsProject3, 1, new string[1] { file }, new VSADDFILEFLAGS[1] { flag })); } }
public virtual void NotifyAddFiles(IVsProject project, string[] files) { var addFlags = new VSADDFILEFLAGS[files.Length]; for (int i = 0; i < files.Length; i++) { addFlags[i] = VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags; } _eventSink.OnAfterAddFilesEx( 1, files.Length, new[] { project }, new[] { 0 }, files, addFlags); }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { if (Active) { // Start by iterating through all projects calling this function for (int iProject = 0; iProject < cProjects; iProject++) { IVsSccProject2 sccProject = rgpProjects[iProject] as IVsSccProject2; IVsHierarchy pHier = rgpProjects[iProject] as IVsHierarchy; // If the project is not controllable, or is not controlled, skip it if (sccProject == null) { continue; } // Files in this project are in rgszMkOldNames, rgszMkNewNames arrays starting with iProjectFilesStart index and ending at iNextProjecFilesStart-1 int iProjectFilesStart = rgFirstIndices[iProject]; int iNextProjecFilesStart = cFiles; if (iProject < cProjects - 1) { iNextProjecFilesStart = rgFirstIndices[iProject + 1]; } // Now that we know which files belong to this project, iterate the project files for (int iFile = iProjectFilesStart; iFile < iNextProjecFilesStart; iFile++) { var fileName = rgpszMkDocuments[iFile]; _fileCache.AddFile(fileName,sccProject); if (GitSccOptions.Current.AutoAddFiles) { var repo = RepositoryManager.Instance.GetTrackerForPath(fileName); repo.AddFile(fileName); } // Refresh the solution explorer glyphs for all projects containing this file //IList<VSITEMSELECTION> nodes = GetControlledProjectsContainingFile(rgpszMkDocuments[iFile]); //_sccProvider.RefreshNodesGlyphs(nodes); } } } return VSConstants.E_NOTIMPL; ; }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] 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++) FileAdded(rgpszMkDocuments[j]); } return VSConstants.S_OK; }
int IVsTrackProjectDocumentsEvents2.OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { GenerateEvents(rgpProjects, rgFirstIndices, rgpszMkDocuments, FileAdded, new ProjectDocumentsChangeEventArgs()); return NativeMethods.S_OK; }
/// <summary> /// This method notifies the client after a project has added files. /// </summary> /// <param name="cProjects">[in] Number of projects to which files were added.</param> /// <param name="cFiles">[in] Number of files that were added.</param> /// <param name="rgpProjects">[in] Array of projects to which files were added.</param> /// <param name="rgFirstIndices">[in] Array of first indices identifying which project each file belongs to. For more information, see IVsTrackProjectDocumentsEvents2.</param> /// <param name="rgpszMkDocuments">[in] Array of paths for the files that were processed. This is the same size as cFiles.</param> /// <param name="rgFlags">[in] Array of flags. For a list of rgFlags values, see <see cref="VSADDFILEFLAGS" />.</param> /// <returns></returns> public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { int iFile = 0; RegisterForSccCleanup(); // Clear the origins table after adding List<string> selectedFiles = null; SortedList<string, string> copies = null; bool sccActive = SccProvider.IsActive; 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 trackCopies; bool track = SccProvider.TrackProjectChanges(sccProject, out trackCopies); for (; iFile < iLastFileThisProject; iFile++) { if (!track) continue; // Not handled by our provider string origin = null; string newName = rgpszMkDocuments[iFile]; if (string.IsNullOrEmpty(newName) || !SvnItem.IsValidPath(newName)) continue; newName = SvnTools.GetNormalizedFullPath(rgpszMkDocuments[iFile]); if (sccActive && _solutionLoaded) { StatusCache.MarkDirty(newName); TryFindOrigin(newName, ref selectedFiles, out origin); } // We do this before the copies to make sure a failed copy doesn't break the project SccProvider.OnProjectFileAdded(sccProject, newName, origin, rgFlags[iFile]); if (sccActive && trackCopies && !string.IsNullOrEmpty(origin) && StatusCache[origin].HasCopyableHistory) { if (copies == null) copies = new SortedList<string, string>(StringComparer.OrdinalIgnoreCase); copies[newName] = origin; } } } if (copies != null) using (SvnSccContext svn = new SvnSccContext(Context)) { while (copies.Count > 0) { string toFile = copies.Keys[0]; string fromFile = copies.Values[0]; string dir = SvnTools.GetNormalizedDirectoryName(toFile); copies.RemoveAt(0); Guid addGuid; if (!svn.TryGetRepositoryId(dir, out addGuid)) { continue; // No repository to fix up } Guid fileGuid; if (!svn.TryGetRepositoryId(fromFile, out fileGuid) || fileGuid != addGuid) continue; // Can't fix history for this file if (string.Equals(Path.GetFileName(fromFile), Path.GetFileName(toFile), StringComparison.OrdinalIgnoreCase)) { // If the names are the same we can handle all files to the same directory // without a sleep penalty SortedList<string, string> now = new SortedList<string, string>(StringComparer.OrdinalIgnoreCase); now.Add(toFile, fromFile); for (int i = 0; i < copies.Count; i++) { string fl = copies.Keys[i]; string tl = copies.Values[i]; if (string.Equals(SvnTools.GetNormalizedDirectoryName(fl), dir, StringComparison.OrdinalIgnoreCase) && string.Equals(Path.GetFileName(fl), Path.GetFileName(tl), StringComparison.OrdinalIgnoreCase)) { Guid fromGuid; if (svn.TryGetRepositoryId(tl, out fromGuid) && (fromGuid == addGuid)) now.Add(fl, tl); // We can copy this item at the same time // else // This copy comes from another repository, no history to save copies.RemoveAt(i--); } } // Now contains all the files we are receiving in a single directory if (now.Count > 0) svn.SafeWcCopyToDirFixup(now, dir); else svn.SafeWcCopyFixup(fromFile, toFile); } else svn.SafeWcCopyFixup(fromFile, toFile); } } return VSConstants.S_OK; }
/// <summary> /// Notify the environment about a file just added /// </summary> internal void OnItemAdded(string file, VSADDFILEFLAGS flag) { if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0) { ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterAddFilesEx(this.projectMgr, 1, new string[1] { file }, new VSADDFILEFLAGS[1] { flag })); } }
public int OnAfterAddFilesEx( int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { var hr = VSConstants.S_OK; var handler = AfterAddFile; if (handler != null) { for (var fileCount = 0; fileCount < cFiles; fileCount++) { var args = new ModelChangeEventArgs(); args.NewFileName = rgpszMkDocuments[fileCount]; args.ProjectObj = GetProjectFromArray(cProjects, fileCount, rgpProjects, rgFirstIndices); if (args.ProjectObj == null) { continue; } hr = handler(this, args); } } return hr; }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { return VSConstants.S_OK; }
int IVsTrackProjectDocumentsEvents2.OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { OnAfterAddFiles(rgpszMkDocuments); return VSConstants.S_OK; }
public int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) { HandleAddRemoveFiles(FileChangeType.Added, cProjects, cFiles, rgpProjects, rgFirstIndices, rgpszMkDocuments, CsFileAdded, TemplateAdded); return VSConstants.S_OK; }
public int OnAfterAddFilesEx(int projectsLength, int filesLength, IVsProject[] projects, int[] indices, string[] paths, VSADDFILEFLAGS[] 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(paths[j])) { ProjectUtil.SetupGenerated(project, paths[j]); } } } } } catch (Exception ex) { Package.UnexpectedExceptionWarning(ex); throw; } return 0; }