Exemplo n.º 1
0
        private void OnTextViewMouseHover(object sender, MouseHoverEventArgs ee)
        {
            ITextBuffer buff = null;
            //find the mouse position by mapping down to the subject buffer
            SnapshotPoint?point = m_textView.BufferGraph.MapDownToFirstMatch
                                      (new SnapshotPoint(m_textView.TextSnapshot, ee.Position),
                                      PointTrackingMode.Positive,
                                      snapshot => m_subjectBuffers.Contains(buff = snapshot.TextBuffer),
                                      PositionAffinity.Predecessor);

            if (point != null)
            {
                ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position,
                                                                                       PointTrackingMode.Positive);

                EnvDTE.DTE      dte = SQVSUtils.GetService <EnvDTE.DTE>();
                EnvDTE.Debugger dbg = dte.Debugger as EnvDTE.Debugger;

                if (dbg != null && dte.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode)
                {
                    string filename = SQLanguageServiceEX.GetFileName(buff);

                    SQProjectFileNode node = _languageService.GetNode(filename);
                    SQVSUtils.CreateDataTipViewFilter(_serviceProvider, node);
                }
                else if (!m_provider.QuickInfoBroker.IsQuickInfoActive(m_textView))
                {
                    //m_session = m_provider.QuickInfoBroker.TriggerQuickInfo(m_textView, triggerPoint, true);
                    /*Setting DEBUG_PROPERTY_INFO.bstrFullName enables the button. I think it uses that name to persist the data tip to a file. It sure would be nice if the documentation gets enhanced one of these days!*/
                }
            }
        }
        void MapObjects(SQProjectFileNode node, SQDeclaration declaration)
        {
            if (!_classviewenabled)
            {
                return;
            }

            SQObjectLibraryNode objectnode = _library._root;

            /*SQObjectLibraryNode globals = _library._global;
             * foreach (SQDeclare d in declaration.Children)
             * {
             *  SQObjectLibraryNode onode = objectnode;
             *  SQDeclaration cd = d.Value;
             *  if (cd.Type == SQDeclarationType.Function
             || cd.Type == SQDeclarationType.Variable)
             || {
             ||     onode = new SQObjectLibraryNode(node, cd, LibraryNodeCapabilities.None);
             ||     globals.Children.Add(onode);
             || }
             || else if (cd.Type == SQDeclarationType.Class
             || cd.Type == SQDeclarationType.Function
             || cd.Type == SQDeclarationType.Constructor
             || cd.Type == SQDeclarationType.Variable
             || cd.Type == SQDeclarationType.Enum
             || cd.Type == SQDeclarationType.EnumData)
             || {
             ||     onode = new SQObjectLibraryNode(node, cd, LibraryNodeCapabilities.None);
             ||     objectnode.Children.Add(onode);
             || }
             || _MapObjects(node, cd, onode);
             ||}*/
            _MapObjects(node, declaration, objectnode);
        }
        public void RegisterFileNode(SQProjectFileNode node)
        {
            if (_library == null)
            {
                IVsObjectManager2 objManager = node.ProjectMgr.Site.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;
                _library = new SQObjectLibrary(new SQObjectLibraryNode(LibraryNodeType.Package, "Project"), objManager);
                if (null == objManager)
                {
                    return;
                }
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    objManager.RegisterSimpleLibrary(_library, out _library.Cookie));
            }
            string ext = Path.GetExtension(node.Url);

            if (ext == ".nut")
            {
                //SQLanguangeService service = (SQLanguangeService)SQVSUtils.GetService<ISQLanguageService>();
                SQDeclaration declaration = Parse(node.Url);
                if (declaration != null)
                {
                    node.OnNodeRemoved += Node_OnFileRemoved;
                    _nodes.Add(node);
                    if (IntellisenseEnabled)
                    {
                        MapObjects(node, declaration);
                    }
                }
            }
        }
        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;
            }
        }
        /// <summary>
        /// Creates the file node.
        /// </summary>
        /// <param name="item">The project element item.</param>
        /// <returns></returns>
        public override FileNode CreateFileNode(ProjectElement item)
        {
            SQProjectFileNode node = new SQProjectFileNode(this, item);

            node.OleServiceProvider.AddService(typeof(EnvDTE.Project), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);
            node.OleServiceProvider.AddService(typeof(ProjectItem), node.ServiceCreator, false);
            node.OleServiceProvider.AddService(typeof(VSProject), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);

            string ext = Path.GetExtension(node.Url);

            if (ext == ".nut")
            {
                SQLanguageServiceEX objectLibrary = (SQLanguageServiceEX)ProjectPackage.GetGlobalService(typeof(ISQLanguageService));
                objectLibrary.RegisterFileNode(node);
            }
            return(node);
        }
        private void Node_OnFileRemoved(ISQNode node)
        {
            SQProjectFileNode fnode = node as SQProjectFileNode;

            node.OnNodeRemoved -= Node_OnFileRemoved;
            RemoveNodesWithFilepath(fnode.Url);
            int d;

            while ((d = _instance.IndexOf(fnode.Url)) != -1)
            {
                if (d != -1)
                {
                    _instance.Children.RemoveAt(d);
                }
            }
            _nodes.Remove(fnode);
        }
 void _MapObjects(SQProjectFileNode node, SQDeclaration declaration, SQObjectLibraryNode objectnode)
 {
     foreach (SQDeclare d in declaration.Children)
     {
         SQObjectLibraryNode onode = objectnode;
         SQDeclaration       cd    = d.Value;
         if (cd.Type == SQDeclarationType.Class ||
             cd.Type == SQDeclarationType.Function ||
             cd.Type == SQDeclarationType.Constructor ||
             cd.Type == SQDeclarationType.Variable ||
             cd.Type == SQDeclarationType.Enum ||
             cd.Type == SQDeclarationType.EnumData)
         {
             onode = new SQObjectLibraryNode(node, cd, LibraryNodeCapabilities.None);
             objectnode.Children.Add(onode);
         }
         _MapObjects(node, cd, onode);
     }
 }
        void CleanHierarchyNode(HierarchyNode hnode)
        {
            HierarchyNode last  = hnode.LastChild;
            HierarchyNode child = hnode.FirstChild;

            if (child == null)
            {
                return;
            }
            do
            {
                if (child is SQProjectFileNode)
                {
                    SQProjectFileNode fnode = child as SQProjectFileNode;
                    Node_OnFileRemoved(fnode);
                }
                CleanHierarchyNode(child);
            } while ((child = child.NextSibling) != null);
        }