• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IVsExpansionSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IVsExpansionSession的典型用法代码示例。如果您正苦于以下问题:C# IVsExpansionSession类的具体用法?C# IVsExpansionSession怎么用?C# IVsExpansionSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IVsExpansionSession类属于命名空间,在下文中一共展示了IVsExpansionSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnBeforeInsertion

 public int OnBeforeInsertion(IVsExpansionSession pSession)
 {
     return VSConstants.S_OK;
 }
开发者ID:gusgorman,项目名称:spring-net-vsnet,代码行数:4,代码来源:SpringCompletionController.cs


示例2: OnAfterInsertion

        public int OnAfterInsertion(IVsExpansionSession pSession)
        {
            Logger.Log(FunctionId.Snippet_OnAfterInsertion);

            return VSConstants.S_OK;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:6,代码来源:AbstractSnippetExpansionClient.cs


示例3: InsertNamedExpansion

 public int InsertNamedExpansion(string bstrTitle, string bstrPath, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, int fShowDisambiguationUI, out IVsExpansionSession pSession) {
     throw new NotImplementedException();
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:3,代码来源:MockVsTextLines.cs


示例4: InsertSpecificExpansion

 public int InsertSpecificExpansion(MSXML.IXMLDOMNode pSnippet, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, string pszRelativePath, out IVsExpansionSession pSession) {
     throw new NotImplementedException();
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:3,代码来源:MockVsTextLines.cs


示例5: InsertExpansion

 public int InsertExpansion(TextSpan tsContext, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, out IVsExpansionSession pSession) {
     throw new NotImplementedException();
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:3,代码来源:MockVsTextLines.cs


示例6: AddReferencesAndImports

        private void AddReferencesAndImports(
            IVsExpansionSession pSession,
            int position,
            CancellationToken cancellationToken)
        {
            if (!TryGetSnippetNode(pSession, out var snippetNode))
            {
                return;
            }

            var documentWithImports = this.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
            if (documentWithImports == null)
            {
                return;
            }

            var documentOptions = documentWithImports.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken);
            var placeSystemNamespaceFirst = documentOptions.GetOption(GenerationOptions.PlaceSystemNamespaceFirst);

            documentWithImports = AddImports(documentWithImports, position, snippetNode, placeSystemNamespaceFirst, cancellationToken);
            AddReferences(documentWithImports.Project, snippetNode);
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:22,代码来源:AbstractSnippetExpansionClient.cs


示例7: SetEndPositionIfNoneSpecified

        /// <summary>
        /// If there was no $end$ token, place it at the end of the snippet code. Otherwise, it
        /// defaults to the beginning of the snippet code.
        /// </summary>
        private static bool SetEndPositionIfNoneSpecified(IVsExpansionSession pSession)
        {
            XElement snippetNode;
            if (!TryGetSnippetNode(pSession, out snippetNode))
            {
                return false;
            }

            var ns = snippetNode.Name.NamespaceName;
            var codeNode = snippetNode.Element(XName.Get("Code", ns));
            if (codeNode == null)
            {
                return false;
            }

            var delimiterAttribute = codeNode.Attribute("Delimiter");
            var delimiter = delimiterAttribute != null ? delimiterAttribute.Value : "$";
            if (codeNode.Value.IndexOf(string.Format("{0}end{0}", delimiter), StringComparison.OrdinalIgnoreCase) != -1)
            {
                return false;
            }

            var snippetSpan = new VsTextSpan[1];
            if (pSession.GetSnippetSpan(snippetSpan) != VSConstants.S_OK)
            {
                return false;
            }

            var newEndSpan = new VsTextSpan
            {
                iStartLine = snippetSpan[0].iEndLine,
                iStartIndex = snippetSpan[0].iEndIndex,
                iEndLine = snippetSpan[0].iEndLine,
                iEndIndex = snippetSpan[0].iEndIndex
            };

            pSession.SetEndSpan(newEndSpan);
            return true;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:43,代码来源:AbstractSnippetExpansionClient.cs


示例8: TryGetSnippetNode

        protected static bool TryGetSnippetNode(IVsExpansionSession pSession, out XElement snippetNode)
        {
            IXMLDOMNode xmlNode = null;
            snippetNode = null;

            try
            {
                // Cast to our own version of IVsExpansionSession so that we can get pNode as an
                // IntPtr instead of a via a RCW. This allows us to guarantee that it pNode is
                // released before leaving this method. Otherwise, a second invocation of the same
                // snippet may cause an AccessViolationException.
                var session = (IVsExpansionSessionInternal)pSession;

                IntPtr pNode;
                if (session.GetSnippetNode(null, out pNode) != VSConstants.S_OK)
                {
                    return false;
                }

                xmlNode = (IXMLDOMNode)Marshal.GetUniqueObjectForIUnknown(pNode);
                snippetNode = XElement.Parse(xmlNode.xml);
                return true;
            }
            finally
            {
                if (xmlNode != null && Marshal.IsComObject(xmlNode))
                {
                    Marshal.ReleaseComObject(xmlNode);
                }
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:31,代码来源:AbstractSnippetExpansionClient.cs


示例9: OnAfterInsertion

 public virtual int OnAfterInsertion(IVsExpansionSession session) {
     return NativeMethods.S_OK;
 }
开发者ID:CaptainHayashi,项目名称:visualfsharp,代码行数:3,代码来源:ExpansionProvider.cs


示例10: OnBeforeInsertion

        public virtual int OnBeforeInsertion(IVsExpansionSession session) {
            if (session == null)
                return NativeMethods.E_UNEXPECTED;

            this.expansionPrepared = false;
            this.expansionActive = true;

            // stash the expansion session pointer while the expansion is active
            if (this.expansionSession == null) {
                this.expansionSession = session;
            } else {
                // these better be the same!
                Debug.Assert(this.expansionSession == session);
            }

            // now set any field defaults that we have.
            foreach (DefaultFieldValue dv in this.fieldDefaults) {
                this.expansionSession.SetFieldDefault(dv.Field, dv.Value);
            }
            this.fieldDefaults.Clear();
            return NativeMethods.S_OK;
        }
开发者ID:CaptainHayashi,项目名称:visualfsharp,代码行数:22,代码来源:ExpansionProvider.cs


示例11: OnBeforeInsertion

        public int OnBeforeInsertion(IVsExpansionSession pSession)
        {
            Logger.Log(FunctionId.Snippet_OnBeforeInsertion);

            this.ExpansionSession = pSession;
            return VSConstants.S_OK;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:7,代码来源:AbstractSnippetExpansionClient.cs


示例12: InsertExpansion

 public int InsertExpansion(TextSpan tsContext, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, out IVsExpansionSession pSession) {
     TextBuffer.Insert(0, "expansion");
     pSession = new VsExpansionSessionMock();
     return VSConstants.S_OK;
 }
开发者ID:int19h,项目名称:RTVS-OLD,代码行数:5,代码来源:VsTextBufferMock.cs


示例13: AddReferencesAndImports

        private void AddReferencesAndImports(IVsExpansionSession pSession, CancellationToken cancellationToken)
        {
            XElement snippetNode;
            if (!TryGetSnippetNode(pSession, out snippetNode))
            {
                return;
            }

            var documentWithImports = this.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
            if (documentWithImports == null)
            {
                return;
            }

            var optionService = documentWithImports.Project.Solution.Workspace.Services.GetService<IOptionService>();
            var placeSystemNamespaceFirst = optionService.GetOption(OrganizerOptions.PlaceSystemNamespaceFirst, documentWithImports.Project.Language);
            documentWithImports = AddImports(documentWithImports, snippetNode, placeSystemNamespaceFirst, cancellationToken);
            AddReferences(documentWithImports.Project, snippetNode);
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:19,代码来源:AbstractSnippetExpansionClient.cs


示例14: InsertNamedExpansion

 public int InsertNamedExpansion(string bstrTitle, string bstrPath, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, int fShowDisambiguationUI, out IVsExpansionSession pSession) {
     TextBuffer.Insert(0, bstrTitle);
     pSession = new VsExpansionSessionMock();
     return VSConstants.S_OK;
 }
开发者ID:int19h,项目名称:RTVS-OLD,代码行数:5,代码来源:VsTextBufferMock.cs


示例15: InsertSpecificExpansion

 public int InsertSpecificExpansion(IXMLDOMNode pSnippet, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, string pszRelativePath, out IVsExpansionSession pSession) {
     TextBuffer.Insert(0, "specific-expansion");
     pSession = new VsExpansionSessionMock();
     return VSConstants.S_OK;
 }
开发者ID:int19h,项目名称:RTVS-OLD,代码行数:5,代码来源:VsTextBufferMock.cs


示例16: OnItemChosen

        public int OnItemChosen(string pszTitle, string pszPath) {
            int hr = VSConstants.E_FAIL;
            if (!TextView.Caret.InVirtualSpace) {
                SnapshotPoint caretPoint = TextView.Caret.Position.BufferPosition;

                IVsExpansion expansion = TextBuffer.GetBufferAdapter<IVsExpansion>();
                _earlyEndExpansionHappened = false;
                _title = pszTitle;
                var ts = TextSpanFromPoint(caretPoint);

                hr = expansion.InsertNamedExpansion(pszTitle, pszPath, ts, this, RGuidList.RLanguageServiceGuid, 0, out _expansionSession);
                if (_earlyEndExpansionHappened) {
                    // EndExpansion was called before InsertNamedExpansion returned, so set _expansionSession
                    // to null to indicate that there is no active expansion session. This can occur when 
                    // the snippet inserted doesn't have any expansion fields.
                    _expansionSession = null;
                    _earlyEndExpansionHappened = false;
                    _title = null;
                    _shortcut = null;
                }
            }
            return hr;
        }
开发者ID:int19h,项目名称:RTVS-OLD,代码行数:23,代码来源:ExpansionClient.cs


示例17: InsertNamedExpansion

        public int InsertNamedExpansion(string pszTitle, string pszPath, TextSpan textSpan) {
            if (_session != null) {
                // if the user starts an expansion session while one is in progress
                // then abort the current expansion session
                _session.EndCurrentExpansion(1);
                _session = null;
            }

            var selection = _textView.Selection;
            var snapshot = selection.Start.Position.Snapshot;

            _selectionStart = snapshot.CreateTrackingPoint(selection.Start.Position, VisualStudio.Text.PointTrackingMode.Positive);
            _selectionEnd = snapshot.CreateTrackingPoint(selection.End.Position, VisualStudio.Text.PointTrackingMode.Negative);
            _selectEndSpan = _sessionEnded = false;

            int hr = _expansion.InsertNamedExpansion(
                pszTitle,
                pszPath,
                textSpan,
                this,
                GuidList.guidPythonLanguageServiceGuid,
                0,
                out _session
            );

            if (ErrorHandler.Succeeded(hr)) {
                if (_sessionEnded) {
                    _session = null;
                }
            }
            return hr;
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:32,代码来源:ExpansionClient.cs


示例18: OnItemChosen

        public int OnItemChosen(string pszTitle, string pszPath)
        {
            var hr = VSConstants.S_OK;

            try
            {
                VsTextSpan textSpan;
                GetCaretPositionInSurfaceBuffer(out textSpan.iStartLine, out textSpan.iStartIndex);

                textSpan.iEndLine = textSpan.iStartLine;
                textSpan.iEndIndex = textSpan.iStartIndex;

                IVsExpansion expansion = EditorAdaptersFactoryService.GetBufferAdapter(TextView.TextBuffer) as IVsExpansion;
                earlyEndExpansionHappened = false;
                hr = expansion.InsertNamedExpansion(pszTitle, pszPath, textSpan, this, LanguageServiceGuid, fShowDisambiguationUI: 0, pSession: out ExpansionSession);

                if (earlyEndExpansionHappened)
                {
                    // EndExpansion was called before InsertNamedExpansion returned, so set
                    // expansionSession to null to indicate that there is no active expansion
                    // session. This can occur when the snippet inserted doesn't have any expansion
                    // fields.
                    ExpansionSession = null;
                    earlyEndExpansionHappened = false;
                }
            }
            catch (COMException ex)
            {
                hr = ex.ErrorCode;
            }

            return hr;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:33,代码来源:AbstractSnippetExpansionClient.cs


示例19: TryHandleBackTab

        public virtual bool TryHandleBackTab()
        {
            if (ExpansionSession != null)
            {
                var tabbedInsideSnippetField = VSConstants.S_OK == ExpansionSession.GoToPreviousExpansionField();

                if (!tabbedInsideSnippetField)
                {
                    ExpansionSession.EndCurrentExpansion(fLeaveCaret: 1);
                    ExpansionSession = null;
                }

                return tabbedInsideSnippetField;
            }

            return false;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:17,代码来源:AbstractSnippetExpansionClient.cs


示例20: TryHandleReturn

        public virtual bool TryHandleReturn()
        {
            // TODO(davip): Only move the caret if the enter was hit within the editable spans

            if (ExpansionSession != null)
            {
                ExpansionSession.EndCurrentExpansion(fLeaveCaret: 0);
                ExpansionSession = null;
                return true;
            }

            return false;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:13,代码来源:AbstractSnippetExpansionClient.cs



注:本文中的IVsExpansionSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IVsHierarchy类代码示例发布时间:2022-05-24
下一篇:
C# IVsEditorAdaptersFactoryService类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap