Exemplo n.º 1
0
        void GetListItemInfo(IVsObjectList2 subList, uint j, out string text, out ushort image, out bool isProcessing)
        {
            // Get Text
            IVsNavInfoNode navInfoNode;

            subList.GetNavInfoNode(j, out navInfoNode);
            navInfoNode.get_Name(out text);
            if (text == null)
            {
                text = "";
            }

            // Get icon, indicating reference type
            VSTREEDISPLAYDATA[] displayData = new VSTREEDISPLAYDATA[1];
            subList.GetDisplayData(j, displayData);

            isProcessing  = false;
            isProcessing |= text.Contains("Please Wait...");
            isProcessing |= text.Contains("% of items left to process");

            image = displayData[0].Image;
            if (image == 8 || image == 7)
            {
                isProcessing = true;
            }
        }
Exemplo n.º 2
0
        public LibraryNode(LibraryNode node)
        {
            _capabilities  = node._capabilities;
            _contextMenuID = node._contextMenuID;
            _displayData   = node._displayData;
            _name          = node._name;
            _tooltip       = node._tooltip;
            _type          = node._type;
            _children      = new List <LibraryNode>();

            foreach (LibraryNode child in node._children)
            {
                _children.Add(child);
            }

            _clipboardFormats = new List <VSOBJCLIPFORMAT>();

            foreach (VSOBJCLIPFORMAT format in node._clipboardFormats)
            {
                _clipboardFormats.Add(format);
            }

            _filteredView = new Dictionary <LibraryNodeType, LibraryNode>();
            _updateCount  = node._updateCount;
        }
Exemplo n.º 3
0
 public LibraryNode(LibraryNode node)
 {
     this.capabilities  = node.capabilities;
     this.contextMenuID = node.contextMenuID;
     this.displayData   = node.displayData;
     this.name          = node.name;
     this.uniquename    = node.uniquename;
     this.tooltip       = node.tooltip;
     this.type          = node.type;
     this.children      = new List <LibraryNode>();
     foreach (LibraryNode child in node.children)
     {
         children.Add(child);
     }
     this.clipboardFormats = new List <VSOBJCLIPFORMAT>();
     foreach (VSOBJCLIPFORMAT format in node.clipboardFormats)
     {
         clipboardFormats.Add(format);
     }
     this.filteredView   = new Dictionary <LibraryNodeType, LibraryNode>();
     this.ownerHierarchy = node.ownerHierarchy;
     this.fileId         = node.fileId;
     this.sourceSpan     = node.sourceSpan;
     this.CanGoToSource  = node.CanGoToSource;
     this.updateCount    = node.updateCount;
 }
 public SQObjectLibraryNode(LibraryNodeType type, string name)
 {
     _altName                   = name;
     _capabilities              = LibraryNodeCapabilities.None;
     _displayData               = new VSTREEDISPLAYDATA();
     _type                      = LibraryNodeType.Namespaces;
     _displayData.Image         = (ushort)StandardGlyphGroup.GlyphGroupEnum;
     _displayData.SelectedImage = _displayData.Image;
 }
Exemplo n.º 5
0
        protected override void GetDisplayData(uint index, ref VSTREEDISPLAYDATA data)
        {
            var item = _items[(int)index];

            data.Image             = item.GlyphIndex;
            data.SelectedImage     = item.GlyphIndex;
            data.State            |= (uint)_VSTREEDISPLAYSTATE.TDS_FORCESELECT;
            data.ForceSelectStart  = item.DisplaySelectionStart;
            data.ForceSelectLength = item.DisplaySelectionLength;
        }
Exemplo n.º 6
0
        public int GetDisplayData(uint index, VSTREEDISPLAYDATA[] pData)
        {
            pData[0].Mask = (uint)_VSTREEDISPLAYMASK.TDM_STATE | (uint)_VSTREEDISPLAYMASK.TDM_IMAGE | (uint)_VSTREEDISPLAYMASK.TDM_SELECTEDIMAGE;

            // Set TDS_SELECTED and TDS_GRAYTEXT
            pData[0].State = Changes[index].GetDisplayState();

            Changes[index].GetDisplayData(pData);
            return VSConstants.S_OK;
        }
        public SQObjectLibraryNode(SQProjectFileNode filenode, SQDeclaration declaration, LibraryNodeCapabilities capabilities)
        {
            _filenode     = filenode;
            _filePath     = filenode.Url;
            _declaration  = declaration;
            _capabilities = capabilities;
            _displayData  = new VSTREEDISPLAYDATA();
            //if (((VisualStudioWorkspaceImpl)workspace).TryGetImageListAndIndex(_imageService, document.Id, out pData[0].hImageList, out pData[0].Image))
            //bool global = _declaration.Parent.Type == SQDeclarationType.File;
            bool local = _declaration.Parent.Type == SQDeclarationType.Function || _declaration.Parent.Type == SQDeclarationType.Constructor;

            switch (_declaration.Type)
            {
            case SQDeclarationType.Class:
                _type = LibraryNodeType.Classes; break;

            case SQDeclarationType.Constructor:
            case SQDeclarationType.Function:
                _type = LibraryNodeType.Members;
                _displayData.Image = (ushort)StandardGlyphGroup.GlyphGroupMethod;
                break;

            case SQDeclarationType.Variable:
                _type = LibraryNodeType.Members;
                _displayData.Image = (ushort)StandardGlyphGroup.GlyphGroupVariable;
                break;

            case SQDeclarationType.Enum:
                _type = LibraryNodeType.Namespaces;
                _displayData.Image = (ushort)StandardGlyphGroup.GlyphGroupEnum;
                break;

            case SQDeclarationType.EnumData:
                _type = LibraryNodeType.Members;
                _displayData.Image = (ushort)StandardGlyphGroup.GlyphGroupEnumMember;
                break;
            }

            // if (local)
            //   _displayData.Image |= (ushort)StandardGlyphItem.GlyphItemPrivate;

            if (_type == LibraryNodeType.Package)
            {
                this.CanGoToSource = false;
            }
            else
            {
                this.CanGoToSource = true;
            }

            //if (_type == LibraryNodeType.Members)
            {
                _displayData.SelectedImage = _displayData.Image;
            }
        }
Exemplo n.º 8
0
        protected override void GetDisplayData(uint index, ref VSTREEDISPLAYDATA data)
        {
            var item = GetListItem(index);

            data.Image         = item.GlyphIndex;
            data.SelectedImage = item.GlyphIndex;

            if (item.IsHidden)
            {
                data.State |= (uint)_VSTREEDISPLAYSTATE.TDS_GRAYTEXT;
            }
        }
 /// <summary>
 ///     Retrieve information to draw the item.
 /// </summary>
 /// <param name="index">The index of the item.</param>
 /// <param name="pData">The display data to set.  Note: the array size is always 1</param>
 public int GetDisplayData(uint index, VSTREEDISPLAYDATA[] pData)
 {
     ArgumentValidation.CheckForOutOfRangeException(index, 0, _changeList.Count - 1);
     var previewNode = _changeList[(int)index];
     var displayData = previewNode.DisplayData;
     if (previewNode.ShowCheckBox)
     {
         displayData.State = displayData.State | ((uint)previewNode.CheckState) << 12;
     }
     pData[0] = displayData;
     return VSConstants.S_OK;
 }
Exemplo n.º 10
0
            }             // func GetDescription

            private int GetGlyph()
            {
                if (dwIndex == NamespaceIndex)
                {
                    return(90);
                }
                else
                {
                    VSTREEDISPLAYDATA[] data = new VSTREEDISPLAYDATA[1];
                    ErrorHandler.ThrowOnFailure(list.GetDisplayData(dwIndex, data));
                    return(data[0].Image);
                }
            }             // func GetGlyph
Exemplo n.º 11
0
 public int GetDisplayData(uint index, VSTREEDISPLAYDATA[] pData) {
     var item = _items[index];
     pData[0].SelectedImage = pData[0].Image = item.Glyph;
     pData[0].hImageList = item.ImageList;
     pData[0].State = (uint)item.CheckState << 12;
     var selectedSpan = item.Selection;
     if (selectedSpan != null) {
         pData[0].State |= (uint)_VSTREEDISPLAYSTATE.TDS_FORCESELECT;
         pData[0].ForceSelectStart = (ushort)selectedSpan.Value.Start;
         pData[0].ForceSelectLength = (ushort)selectedSpan.Value.Length;
     }
     return VSConstants.S_OK;
 }
Exemplo n.º 12
0
 public LibraryNode(LibraryNode node)
 {
     this.capabilities = node.capabilities;
     this.contextMenuID = node.contextMenuID;
     this.displayData = node.displayData;
     this.name = node.name;
     this.tooltip = node.tooltip;
     this.type = node.type;
     this.children = new List<LibraryNode>();
     foreach (LibraryNode child in node.children) {
         children.Add(child);
     }
     this.clipboardFormats = new List<VSOBJCLIPFORMAT>();
     foreach (VSOBJCLIPFORMAT format in node.clipboardFormats) {
         clipboardFormats.Add(format);
     }
     this.filteredView = new Dictionary<LibraryNodeType, LibraryNode>();
     this.updateCount = node.updateCount;
 }
        protected static PreviewChangesNode CreatePreviewNode(
            string displayText,
            ushort icon,
            IntPtr imageList,
            TextChangeProposal proposal,
            bool forceSelection,
            bool enableChangeUncheck,
            bool isChecked)
        {
            var displayData = new VSTREEDISPLAYDATA();

            if (forceSelection)
            {
                Debug.Assert(!string.IsNullOrEmpty(displayText), "display text is null or empty");
                Debug.Assert(proposal != null, "proposal is null");

                var length = displayText.Length;
                displayText = displayText.TrimStart();
                var spaceLength = length - displayText.Length;

                displayData.State             = (uint)_VSTREEDISPLAYSTATE.TDS_FORCESELECT;
                displayData.ForceSelectStart  = (ushort)(proposal.StartColumn - spaceLength);
                displayData.ForceSelectLength = (ushort)(proposal.EndColumn - proposal.StartColumn);
            }

            if (imageList != IntPtr.Zero)
            {
                displayData.hImageList = imageList;
            }

            displayData.Image = displayData.SelectedImage = icon;

            var node = new PreviewChangesNode(displayText, displayData, displayText, null, proposal);

            if (enableChangeUncheck)
            {
                AddCheckBoxToPreviewNode(node, true, isChecked);
            }

            return(node);
        }
Exemplo n.º 14
0
        public LibraryNode(LibraryNode node)
        {
            _capabilities  = node._capabilities;
            _contextMenuID = node._contextMenuID;
            _displayData   = node._displayData;
            _name		  = node._name;
            _tooltip	   = node._tooltip;
            _type		  = node._type;
            _children	  = new List<LibraryNode>();

            foreach (LibraryNode child in node._children)
                _children.Add(child);

            _clipboardFormats = new List<VSOBJCLIPFORMAT>();

            foreach (VSOBJCLIPFORMAT format in node._clipboardFormats)
                _clipboardFormats.Add(format);

            _filteredView = new Dictionary<LibraryNodeType, LibraryNode>();
            _updateCount  = node._updateCount;
        }
Exemplo n.º 15
0
 public PreviewChangesNode(
     string displayText,
     VSTREEDISPLAYDATA displayData,
     string tooltipText,
     List<PreviewChangesNode> childList,
     ChangeProposal changeProposal)
 {
     _displayText = displayText;
     _displayData = displayData;
     _tooltipText = tooltipText;
     _childList = childList;
     ChangeProposal = changeProposal;
     if (changeProposal != null
         && changeProposal.Included)
     {
         _checkState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked;
     }
     else
     {
         _checkState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked;
     }
 }
Exemplo n.º 16
0
 public LibraryNode(LibraryNode node)
 {
     this.capabilities  = node.capabilities;
     this.contextMenuID = node.contextMenuID;
     this.displayData   = node.displayData;
     this.name          = node.name;
     this.tooltip       = node.tooltip;
     this.type          = node.type;
     this.visible       = node.visible;
     this.children      = new List <LibraryNode>();
     foreach (LibraryNode child in node.children)
     {
         children.Add(child);
     }
     this.clipboardFormats = new List <VSOBJCLIPFORMAT>();
     foreach (VSOBJCLIPFORMAT format in node.clipboardFormats)
     {
         clipboardFormats.Add(format);
     }
     this.filteredView = new Dictionary <LibraryNodeType, LibraryNode>();
     this.updateCount  = node.updateCount;
 }
Exemplo n.º 17
0
 public PreviewChangesNode(
     string displayText,
     VSTREEDISPLAYDATA displayData,
     string tooltipText,
     List <PreviewChangesNode> childList,
     ChangeProposal changeProposal)
 {
     _displayText   = displayText;
     _displayData   = displayData;
     _tooltipText   = tooltipText;
     _childList     = childList;
     ChangeProposal = changeProposal;
     if (changeProposal != null &&
         changeProposal.Included)
     {
         _checkState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked;
     }
     else
     {
         _checkState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked;
     }
 }
Exemplo n.º 18
0
        protected override void SetDisplayData()
        {
            displayData = new VSTREEDISPLAYDATA();
            ushort imageIndex = 0;

            switch (NodeType)
            {
            case LibraryNodeType.Members:
                imageIndex = at.jku.ssw.Coco.VSPlugin.Language.CocoDeclarations.GLYPH_VAR;
                break;

            case LibraryNodeType.References:
                imageIndex = at.jku.ssw.Coco.VSPlugin.Language.CocoDeclarations.GLYPH_USAGE;
                break;

            //add further image indizes here
            default:
                //leave 0 as index
                break;
            }
            displayData.Image = displayData.SelectedImage = imageIndex;
        }
Exemplo n.º 19
0
 internal sealed override void GetDisplayData(VSTREEDISPLAYDATA[] pData)
 {
     pData[0].Image = pData[0].SelectedImage = (ushort)StandardGlyphGroup.GlyphReference;
 }
        protected static List <PreviewChangesNode> CreatePreviewNodesForVsLang(
            IList <FileChange> fileChanges, bool placeNodesUnderSingleRoot = false)
        {
            var vsLangObjectNodes      = new List <PreviewChangesNode>();
            var rootToFileToChangesMap = new Dictionary <string, Dictionary <string, List <PreviewChangesNode> > >();
            var isCSharpChange         = true;

            foreach (var fileChange in fileChanges)
            {
                if (fileChange.ChangeList != null)
                {
                    if (fileChange.ChangeList.Count > 0)
                    {
                        using (var textBuffer = VsTextLinesFromFile.Load(fileChange.FileName))
                        {
                            if (textBuffer != null)
                            {
                                foreach (
                                    var vsLangTextChange in
                                    fileChange.ChangeList.SelectMany(cl => cl.Value).OfType <VsLangTextChangeProposal>())
                                {
                                    if (vsLangTextChange.IsRootChange)
                                    {
                                        // Create object definition node
                                        var rootNode = new PreviewChangesNode(
                                            vsLangTextChange.ObjectDefinitionFullName
                                            , new VSTREEDISPLAYDATA()
                                            , vsLangTextChange.ObjectDefinitionFullName
                                            , new List <PreviewChangesNode>()
                                            , vsLangTextChange);

                                        rootNode.CheckState = vsLangTextChange.Included
                                                                  ? __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked
                                                                  : __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked;
                                        vsLangObjectNodes.Add(rootNode);

                                        // It's possible that a non-root change was processed first, in which case the dictionary will already be updated
                                        // with the root node name. This means we need to check the dictionary before adding to it.
                                        if (!rootToFileToChangesMap.ContainsKey(vsLangTextChange.ObjectDefinitionFullName))
                                        {
                                            rootToFileToChangesMap.Add(
                                                vsLangTextChange.ObjectDefinitionFullName,
                                                new Dictionary <string, List <PreviewChangesNode> >());
                                        }
                                    }
                                    else
                                    {
                                        // Get display text, trim the leading space of the text for display purpose.
                                        var displayText = string.Empty;
                                        int lineLength;

                                        if (ErrorHandler.Succeeded(textBuffer.GetLengthOfLine(vsLangTextChange.StartLine, out lineLength)))
                                        {
                                            if (
                                                ErrorHandler.Succeeded(
                                                    textBuffer.GetLineText(
                                                        vsLangTextChange.StartLine, 0, vsLangTextChange.StartLine, lineLength,
                                                        out displayText)))
                                            {
                                                var length = displayText.Length;
                                                displayText = displayText.TrimStart();
                                                var spaceLength = length - displayText.Length;

                                                Debug.Assert(
                                                    spaceLength <= vsLangTextChange.StartColumn,
                                                    "Start column of selection is negative, HydratedVsLangRefactor.CreatePreviewNodeForChanges()");

                                                if (spaceLength <= vsLangTextChange.StartColumn)
                                                {
                                                    var changeNodeDisplayData = new VSTREEDISPLAYDATA();
                                                    changeNodeDisplayData.State            = (uint)_VSTREEDISPLAYSTATE.TDS_FORCESELECT;
                                                    changeNodeDisplayData.ForceSelectStart =
                                                        (ushort)(vsLangTextChange.StartColumn - spaceLength);
                                                    changeNodeDisplayData.ForceSelectLength = (ushort)(vsLangTextChange.Length);

                                                    var changeNode = new PreviewChangesNode(
                                                        displayText, changeNodeDisplayData, displayText, null, vsLangTextChange);

                                                    // Add checked checkbox
                                                    changeNode.ShowCheckBox = true;
                                                    changeNode.CheckState   = vsLangTextChange.Included
                                                                                ? __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked
                                                                                : __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked;

                                                    // Apply the language service to this change.
                                                    Guid languageServiceId;
                                                    textBuffer.GetLanguageServiceID(out languageServiceId);
                                                    changeNode.LanguageServiceID = languageServiceId;

                                                    Dictionary <string, List <PreviewChangesNode> > fileToChangesMap;
                                                    if (rootToFileToChangesMap.TryGetValue(
                                                            vsLangTextChange.ObjectDefinitionFullName, out fileToChangesMap))
                                                    {
                                                        List <PreviewChangesNode> changeNodes;
                                                        if (fileToChangesMap.TryGetValue(fileChange.FileName, out changeNodes))
                                                        {
                                                            changeNodes.Add(changeNode);
                                                        }
                                                        else
                                                        {
                                                            // There are no changes for the file listed under this root node, so we need to create it
                                                            changeNodes = new List <PreviewChangesNode> {
                                                                changeNode
                                                            };
                                                            fileToChangesMap.Add(fileChange.FileName, changeNodes);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        // There are no changes processed yet for this object name, so we need to update our dictionary with
                                                        // markers for creating a new root node, a new file node, and a new change node.
                                                        fileToChangesMap = new Dictionary <string, List <PreviewChangesNode> >();
                                                        fileToChangesMap.Add(
                                                            fileChange.FileName, new List <PreviewChangesNode> {
                                                            changeNode
                                                        });
                                                        rootToFileToChangesMap.Add(
                                                            vsLangTextChange.ObjectDefinitionFullName, fileToChangesMap);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Now that all the changes have been sorted under the correct root nodes in our dictionary, create the File nodes that connect
            // the root nodes to the change nodes.
            foreach (var rootNode in vsLangObjectNodes)
            {
                Dictionary <string, List <PreviewChangesNode> > fileToChangesMap;
                if (rootToFileToChangesMap.TryGetValue(rootNode.DisplayText, out fileToChangesMap))
                {
                    if (fileToChangesMap != null)
                    {
                        foreach (var fileName in fileToChangesMap.Keys)
                        {
                            var fileNodeDisplayData = new VSTREEDISPLAYDATA();

                            if (FileExtensions.VbExt.Equals(Path.GetExtension(fileName), StringComparison.OrdinalIgnoreCase))
                            {
                                fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_VBPROJECT;
                                isCSharpChange            = false;
                            }
                            else
                            {
                                fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_CSHARPFILE;
                            }

                            var shortFileName = Path.GetFileName(fileName);
                            var checkState    = DetermineCheckState(fileToChangesMap[fileName]);
                            var fileNode      = new PreviewChangesNode(shortFileName, fileNodeDisplayData, shortFileName, null, null);
                            fileNode.AddChildNodes(fileToChangesMap[fileName]);

                            // Add checked checkbox
                            fileNode.ShowCheckBox = true;
                            fileNode.CheckState   = checkState;
                            rootNode.AddChildNode(fileNode);

                            // Update root check state
                            if (rootNode.ChildList.Count == 1)
                            {
                                // This is the first child, so the root should match the child check state
                                rootNode.CheckState = checkState;
                            }
                            else
                            {
                                switch (rootNode.CheckState)
                                {
                                case __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked:
                                {
                                    if (checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked ||
                                        checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked)
                                    {
                                        rootNode.CheckState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked;
                                    }
                                    break;
                                }

                                case __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked:
                                {
                                    if (checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked ||
                                        checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked)
                                    {
                                        rootNode.CheckState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked;
                                    }
                                    break;
                                }
                                }
                            }
                        }
                    }
                }
            }

            if (placeNodesUnderSingleRoot)
            {
                PreviewChangesNode rootNode;
                var fileNodeDisplayData = new VSTREEDISPLAYDATA();

                if (isCSharpChange)
                {
                    fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_CSHARPFILE;
                    rootNode = new PreviewChangesNode(CSharpRootNodeText, fileNodeDisplayData, null, null, null);
                }
                else
                {
                    fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_VBPROJECT;
                    rootNode = new PreviewChangesNode(VBRootNodeText, fileNodeDisplayData, null, null, null);
                }

                rootNode.ShowCheckBox = true;
                rootNode.CheckState   = DetermineCheckState(vsLangObjectNodes);
                rootNode.AddChildNodes(vsLangObjectNodes);
                return(new List <PreviewChangesNode> {
                    rootNode
                });
            }
            else
            {
                return(vsLangObjectNodes);
            }
        }
        protected static List<PreviewChangesNode> CreatePreviewNodesForVsLang(
            IList<FileChange> fileChanges, bool placeNodesUnderSingleRoot = false)
        {
            var vsLangObjectNodes = new List<PreviewChangesNode>();
            var rootToFileToChangesMap = new Dictionary<string, Dictionary<string, List<PreviewChangesNode>>>();
            var isCSharpChange = true;

            foreach (var fileChange in fileChanges)
            {
                if (fileChange.ChangeList != null)
                {
                    if (fileChange.ChangeList.Count > 0)
                    {
                        using (var textBuffer = VsTextLinesFromFile.Load(fileChange.FileName))
                        {
                            if (textBuffer != null)
                            {
                                foreach (
                                    var vsLangTextChange in
                                        fileChange.ChangeList.SelectMany(cl => cl.Value).OfType<VsLangTextChangeProposal>())
                                {
                                    if (vsLangTextChange.IsRootChange)
                                    {
                                        // Create object definition node                                        
                                        var rootNode = new PreviewChangesNode(
                                            vsLangTextChange.ObjectDefinitionFullName
                                            , new VSTREEDISPLAYDATA()
                                            , vsLangTextChange.ObjectDefinitionFullName
                                            , new List<PreviewChangesNode>()
                                            , vsLangTextChange);

                                        rootNode.CheckState = vsLangTextChange.Included
                                                                  ? __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked
                                                                  : __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked;
                                        vsLangObjectNodes.Add(rootNode);

                                        // It's possible that a non-root change was processed first, in which case the dictionary will already be updated
                                        // with the root node name. This means we need to check the dictionary before adding to it.
                                        if (!rootToFileToChangesMap.ContainsKey(vsLangTextChange.ObjectDefinitionFullName))
                                        {
                                            rootToFileToChangesMap.Add(
                                                vsLangTextChange.ObjectDefinitionFullName,
                                                new Dictionary<string, List<PreviewChangesNode>>());
                                        }
                                    }
                                    else
                                    {
                                        // Get display text, trim the leading space of the text for display purpose.
                                        var displayText = string.Empty;
                                        int lineLength;

                                        if (ErrorHandler.Succeeded(textBuffer.GetLengthOfLine(vsLangTextChange.StartLine, out lineLength)))
                                        {
                                            if (
                                                ErrorHandler.Succeeded(
                                                    textBuffer.GetLineText(
                                                        vsLangTextChange.StartLine, 0, vsLangTextChange.StartLine, lineLength,
                                                        out displayText)))
                                            {
                                                var length = displayText.Length;
                                                displayText = displayText.TrimStart();
                                                var spaceLength = length - displayText.Length;

                                                Debug.Assert(
                                                    spaceLength <= vsLangTextChange.StartColumn,
                                                    "Start column of selection is negative, HydratedVsLangRefactor.CreatePreviewNodeForChanges()");

                                                if (spaceLength <= vsLangTextChange.StartColumn)
                                                {
                                                    var changeNodeDisplayData = new VSTREEDISPLAYDATA();
                                                    changeNodeDisplayData.State = (uint)_VSTREEDISPLAYSTATE.TDS_FORCESELECT;
                                                    changeNodeDisplayData.ForceSelectStart =
                                                        (ushort)(vsLangTextChange.StartColumn - spaceLength);
                                                    changeNodeDisplayData.ForceSelectLength = (ushort)(vsLangTextChange.Length);

                                                    var changeNode = new PreviewChangesNode(
                                                        displayText, changeNodeDisplayData, displayText, null, vsLangTextChange);

                                                    // Add checked checkbox
                                                    changeNode.ShowCheckBox = true;
                                                    changeNode.CheckState = vsLangTextChange.Included
                                                                                ? __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked
                                                                                : __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked;

                                                    // Apply the language service to this change.
                                                    Guid languageServiceId;
                                                    textBuffer.GetLanguageServiceID(out languageServiceId);
                                                    changeNode.LanguageServiceID = languageServiceId;

                                                    Dictionary<string, List<PreviewChangesNode>> fileToChangesMap;
                                                    if (rootToFileToChangesMap.TryGetValue(
                                                        vsLangTextChange.ObjectDefinitionFullName, out fileToChangesMap))
                                                    {
                                                        List<PreviewChangesNode> changeNodes;
                                                        if (fileToChangesMap.TryGetValue(fileChange.FileName, out changeNodes))
                                                        {
                                                            changeNodes.Add(changeNode);
                                                        }
                                                        else
                                                        {
                                                            // There are no changes for the file listed under this root node, so we need to create it
                                                            changeNodes = new List<PreviewChangesNode> { changeNode };
                                                            fileToChangesMap.Add(fileChange.FileName, changeNodes);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        // There are no changes processed yet for this object name, so we need to update our dictionary with
                                                        // markers for creating a new root node, a new file node, and a new change node.
                                                        fileToChangesMap = new Dictionary<string, List<PreviewChangesNode>>();
                                                        fileToChangesMap.Add(
                                                            fileChange.FileName, new List<PreviewChangesNode> { changeNode });
                                                        rootToFileToChangesMap.Add(
                                                            vsLangTextChange.ObjectDefinitionFullName, fileToChangesMap);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Now that all the changes have been sorted under the correct root nodes in our dictionary, create the File nodes that connect
            // the root nodes to the change nodes.
            foreach (var rootNode in vsLangObjectNodes)
            {
                Dictionary<string, List<PreviewChangesNode>> fileToChangesMap;
                if (rootToFileToChangesMap.TryGetValue(rootNode.DisplayText, out fileToChangesMap))
                {
                    if (fileToChangesMap != null)
                    {
                        foreach (var fileName in fileToChangesMap.Keys)
                        {
                            var fileNodeDisplayData = new VSTREEDISPLAYDATA();

                            if (FileExtensions.VbExt.Equals(Path.GetExtension(fileName), StringComparison.OrdinalIgnoreCase))
                            {
                                fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_VBPROJECT;
                                isCSharpChange = false;
                            }
                            else
                            {
                                fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_CSHARPFILE;
                            }

                            var shortFileName = Path.GetFileName(fileName);
                            var checkState = DetermineCheckState(fileToChangesMap[fileName]);
                            var fileNode = new PreviewChangesNode(shortFileName, fileNodeDisplayData, shortFileName, null, null);
                            fileNode.AddChildNodes(fileToChangesMap[fileName]);

                            // Add checked checkbox
                            fileNode.ShowCheckBox = true;
                            fileNode.CheckState = checkState;
                            rootNode.AddChildNode(fileNode);

                            // Update root check state
                            if (rootNode.ChildList.Count == 1)
                            {
                                // This is the first child, so the root should match the child check state
                                rootNode.CheckState = checkState;
                            }
                            else
                            {
                                switch (rootNode.CheckState)
                                {
                                    case __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked:
                                        {
                                            if (checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked
                                                || checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked)
                                            {
                                                rootNode.CheckState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked;
                                            }
                                            break;
                                        }
                                    case __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Unchecked:
                                        {
                                            if (checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked
                                                || checkState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked)
                                            {
                                                rootNode.CheckState = __PREVIEWCHANGESITEMCHECKSTATE.PCCS_PartiallyChecked;
                                            }
                                            break;
                                        }
                                }
                            }
                        }
                    }
                }
            }

            if (placeNodesUnderSingleRoot)
            {
                PreviewChangesNode rootNode;
                var fileNodeDisplayData = new VSTREEDISPLAYDATA();

                if (isCSharpChange)
                {
                    fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_CSHARPFILE;
                    rootNode = new PreviewChangesNode(CSharpRootNodeText, fileNodeDisplayData, null, null, null);
                }
                else
                {
                    fileNodeDisplayData.Image = fileNodeDisplayData.SelectedImage = CommonConstants.OM_GLYPH_VBPROJECT;
                    rootNode = new PreviewChangesNode(VBRootNodeText, fileNodeDisplayData, null, null, null);
                }

                rootNode.ShowCheckBox = true;
                rootNode.CheckState = DetermineCheckState(vsLangObjectNodes);
                rootNode.AddChildNodes(vsLangObjectNodes);
                return new List<PreviewChangesNode> { rootNode };
            }
            else
            {
                return vsLangObjectNodes;
            }
        }
Exemplo n.º 22
0
        internal override void GetDisplayData(VSTREEDISPLAYDATA[] pData)
        {
            var document = _right ?? _left;

            // If these are documents from a VS workspace, then attempt to get the right display
            // data from the underlying VSHierarchy and itemids for the document.
            var workspace = document.Project.Solution.Workspace;
            if (workspace is VisualStudioWorkspaceImpl)
            {
                if (((VisualStudioWorkspaceImpl)workspace).TryGetImageListAndIndex(_imageService, document.Id, out pData[0].hImageList, out pData[0].Image))
                {
                    pData[0].SelectedImage = pData[0].Image;
                    return;
                }
            }

            pData[0].Image = pData[0].SelectedImage = (ushort)StandardGlyphGroup.GlyphLibrary;
        }
Exemplo n.º 23
0
 protected abstract void GetDisplayData(uint index, ref VSTREEDISPLAYDATA data);
Exemplo n.º 24
0
            private static void PrintList(IVsLiteTreeList list, int indent = 0) {
                uint count;
                list.GetItemCount(out count);

                
                for (int i = 0; i < count; i++) {
                    string text;
                    list.GetText((uint)i, VSTREETEXTOPTIONS.TTO_DEFAULT, out text);
                    Console.Write("{1}new ExpectedPreviewItem(\"{0}\"", text, new string(' ', indent * 4));

                    int expandable;
                    list.GetExpandable((uint)i, out expandable);
                    if (expandable != 0) {
                        Console.WriteLine(", ");
                        int canRecurse;
                        IVsLiteTreeList subList;
                        list.GetExpandedList((uint)i, out canRecurse, out subList);

                        PrintList(subList, indent + 1);
                    }

                    VSTREEDISPLAYDATA[] data = new VSTREEDISPLAYDATA[1];
                    list.GetDisplayData((uint)i, data);

                    // TODO: Validate display data

                    uint changeCnt = 0;
                    list.GetListChanges(ref changeCnt, null);

                    VSTREELISTITEMCHANGE[] changes = new VSTREELISTITEMCHANGE[changeCnt];
                    list.GetListChanges(ref changeCnt, changes);

                    // TODO: Valiate changes

                    if (i != count - 1) {
                        Console.WriteLine("),");
                    } else {
                        Console.WriteLine(")");
                    }
                }
            }
Exemplo n.º 25
0
 int IVsSimpleObjectList2.GetDisplayData(uint index, VSTREEDISPLAYDATA[] pData)
 {
     if (index >= (uint)children.Count) {
         throw new ArgumentOutOfRangeException("index");
     }
     pData[0] = children[(int)index].displayData;
     return VSConstants.S_OK;
 }
        protected static PreviewChangesNode CreatePreviewNode(
            string displayText,
            ushort icon,
            IntPtr imageList,
            TextChangeProposal proposal,
            bool forceSelection,
            bool enableChangeUncheck,
            bool isChecked)
        {
            var displayData = new VSTREEDISPLAYDATA();

            if (forceSelection)
            {
                Debug.Assert(!string.IsNullOrEmpty(displayText), "display text is null or empty");
                Debug.Assert(proposal != null, "proposal is null");

                var length = displayText.Length;
                displayText = displayText.TrimStart();
                var spaceLength = length - displayText.Length;

                displayData.State = (uint)_VSTREEDISPLAYSTATE.TDS_FORCESELECT;
                displayData.ForceSelectStart = (ushort)(proposal.StartColumn - spaceLength);
                displayData.ForceSelectLength = (ushort)(proposal.EndColumn - proposal.StartColumn);
            }

            if (imageList != IntPtr.Zero)
            {
                displayData.hImageList = imageList;
            }

            displayData.Image = displayData.SelectedImage = icon;

            var node = new PreviewChangesNode(displayText, displayData, displayText, null, proposal);

            if (enableChangeUncheck)
            {
                AddCheckBoxToPreviewNode(node, true, isChecked);
            }

            return node;
        }
Exemplo n.º 27
0
 internal override void GetDisplayData(VSTREEDISPLAYDATA[] pData)
 {
     pData[0].Image = pData[0].SelectedImage = (ushort)_glyph.GetStandardGlyphGroup();
 }
Exemplo n.º 28
0
 internal abstract void GetDisplayData(VSTREEDISPLAYDATA[] pData);
Exemplo n.º 29
0
 /// <summary>
 /// Retrieves data to draw the requested tree list item.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="pData"></param>
 /// <returns></returns>
 public int GetDisplayData(uint index, VSTREEDISPLAYDATA[] pData)
 {
     //ToDo: Find out where the displayData takes from in IronPython and supply it here
     //Logger.Log("ResultList.GetDisplayData index:" + index);
     if (index >= (uint)children.Count)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     pData[0] = children[(int)index].DisplayData;
     return VSConstants.S_OK;
 }
Exemplo n.º 30
0
 internal override void GetDisplayData(VSTREEDISPLAYDATA[] pData)
 {
     pData[0].Image = pData[0].SelectedImage = (ushort)StandardGlyphGroup.GlyphInformation;
 }
Exemplo n.º 31
0
 int IVsLiteTreeList.GetDisplayData(uint index, VSTREEDISPLAYDATA[] pData)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 32
0
 protected virtual void SetDisplayData()
 {
     displayData = new VSTREEDISPLAYDATA();
 }