Ejemplo n.º 1
0
            public int GetSccFiles(uint itemid, Microsoft.VisualStudio.OLE.Interop.CALPOLESTR[] pCaStringsOut, Microsoft.VisualStudio.OLE.Interop.CADWORD[] pCaFlagsOut)
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                if (itemid == VSItemId.Root)
                {
                    string solutionFilename = SelectionUtils.GetSolutionFileName(_context);

                    if (!string.IsNullOrEmpty(solutionFilename))
                    {
                        pCaStringsOut[0] = CreateCALPOLESTR(new string[] { solutionFilename });
                    }
                    else
                    {
                        pCaStringsOut[0] = new CALPOLESTR();
                    }

                    pCaFlagsOut[0].cElems = 0;
                    pCaFlagsOut[0].pElems = IntPtr.Zero;

                    return(VSErr.S_OK);
                }

                return(VSErr.E_NOTIMPL);
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the list of files specified by the hierarchy (IVsSccProject2 or IVsHierarchy)
        /// </summary>
        /// <param name="hierarchy"></param>
        /// <param name="id"></param>
        /// <param name="depth"></param>
        /// <returns></returns>
        /// <remarks>The list might contain duplicates if files are included more than once</remarks>
        public IEnumerable <string> GetSccFiles(IVsHierarchy hierarchy, uint id, ProjectWalkDepth depth, IDictionary <string, uint> map)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // Note: This command is not cached like the other commands on this object!
            if (hierarchy == null)
            {
                throw new ArgumentNullException("hierarchy");
            }

            SelectionItem si = new SelectionItem(hierarchy, id);

            string[] files;
            if (!SelectionUtils.GetSccFiles(si, out files, depth >= ProjectWalkDepth.SpecialFiles, IncludeNoScc(depth), map))
            {
                yield break;
            }

            foreach (string file in files)
            {
                yield return(SvnTools.GetNormalizedFullPath(file));
            }

            if (depth > ProjectWalkDepth.SpecialFiles)
            {
                Dictionary <SelectionItem, SelectionItem> previous = new Dictionary <SelectionItem, SelectionItem>();
                previous.Add(si, si);

                foreach (SelectionItem item in GetDescendants(si, previous, depth))
                {
                    if (!SelectionUtils.GetSccFiles(item, out files, depth >= ProjectWalkDepth.SpecialFiles, depth != ProjectWalkDepth.AllDescendantsInHierarchy, map))
                    {
                        continue;
                    }

                    foreach (string file in files)
                    {
                        yield return(SvnTools.GetNormalizedFullPath(file));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the selected files; yielding for each result to allow delay loading
        /// </summary>
        /// <param name="recursive"></param>
        /// <returns></returns>
        IEnumerable <string> InternalGetSelectedFiles(bool recursive)
        {
            HybridCollection <string> foundFiles = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);

            foreach (SelectionItem i in GetSelectedItems(recursive))
            {
                string[] files;

                if (SelectionUtils.GetSccFiles(i, out files, true, true, null))
                {
                    foreach (string file in files)
                    {
                        if (!foundFiles.Contains(file))
                        {
                            foundFiles.Add(file);

                            yield return(file);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected IEnumerable <SccProject> InternalGetOwnerProjects()
        {
            Hashtable          ht = new Hashtable();
            bool               searchedProjectMapper = false;
            IProjectFileMapper projectMapper         = null;

            foreach (SelectionItem si in GetSelectedItems(false))
            {
                if (ht.Contains(si.Hierarchy))
                {
                    continue;
                }

                ht.Add(si.Hierarchy, si);

                if (si.SccProject != null)
                {
                    yield return(new SccProject(null, si.SccProject));

                    continue;
                }
                else if (si.Hierarchy is IVsSccVirtualFolders)
                {
                    continue; // Skip URL WebApplications fast
                }
                string[] files;

                // No need to fetch special files as we only want projects!
                if (!SelectionUtils.GetSccFiles(si, out files, false, false, null) || files.Length == 0)
                {
                    continue; // No files selected
                }
                if (projectMapper == null && !searchedProjectMapper)
                {
                    searchedProjectMapper = true;
                    projectMapper         = GetService <IProjectFileMapper>();
                }

                if (projectMapper != null)
                {
                    foreach (string file in files)
                    {
                        foreach (SccProject project in projectMapper.GetAllProjectsContaining(file))
                        {
                            if (project.RawHandle != null)
                            {
                                if (ht.Contains(project.RawHandle))
                                {
                                    continue;
                                }

                                ht.Add(project.RawHandle, si);
                                yield return(project);
                            }
                            else if (!ht.Contains(project))
                            {
                                ht.Add(project, si);
                                yield return(project);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the selected items; yielding for each result to allow delay loading
        /// </summary>
        /// <returns></returns>
        IEnumerable <SelectionItem> InternalGetSelectedItems()
        {
            HierarchySelection sel = current; // Cache the selection to make sure we don't use an id for another hierarchy

            if (sel.id == VSItemId.Selection)
            {
                uint nItems;
                int  withinSingleHierarchy;

                if (sel.selection == null || !VSErr.Succeeded(sel.selection.GetSelectionInfo(out nItems, out withinSingleHierarchy)))
                {
                    yield break;
                }

                uint flags = 0;

                if ((withinSingleHierarchy != 0) && sel.hierarchy != null)
                {
                    flags = (uint)__VSGSIFLAGS.GSI_fOmitHierPtrs; // Don't marshal the hierarchy for every item
                }
                VSITEMSELECTION[] items = new VSITEMSELECTION[nItems];

                if (!VSErr.Succeeded(sel.selection.GetSelectedItems(flags, nItems, items)))
                {
                    yield break;
                }

                for (int i = 0; i < nItems; i++)
                {
                    IVsHierarchy hier = items[i].pHier ?? sel.hierarchy;

                    if (hier != null)
                    {
                        yield return(new SelectionItem(hier, items[i].itemid));
                    }
                    else
                    {
                        if (items[i].itemid == VSItemId.Root && MightBeSolutionExplorerSelection)
                        {
                            yield return(new SelectionItem((IVsHierarchy)Solution, VSItemId.Root,
                                                           SelectionUtils.GetSolutionAsSccProject(Context)));
                        }
                        // else skip
                    }
                }
            }
            else if (sel.id != VSItemId.Nil && (sel.hierarchy != null))
            {
                if (sel.id == _filterItem && sel.hierarchy == _filterHierarchy)
                {
                    yield break;
                }

                yield return(new SelectionItem(sel.hierarchy, sel.id));
            }
            else if (_currentContainer == null)
            {
                // No selection, no hierarchy.... -> no selection!
            }
            else if (sel.id == VSItemId.Root)
            {
                // This is the case in the solution explorer when only the solution is selected

                // We must validate whether the window is really the solution explorer

                if (MightBeSolutionExplorerSelection)
                {
                    IVsHierarchy hier = (IVsHierarchy)Solution;

                    if (hier != null)
                    {
                        yield return(new SelectionItem(hier, VSItemId.Root,
                                                       SelectionUtils.GetSolutionAsSccProject(Context)));
                    }
                }
            }
        }