当前位置: 首页>>代码示例>>C#>>正文


C# IVsTextView.GetWordExtent方法代码示例

本文整理汇总了C#中IVsTextView.GetWordExtent方法的典型用法代码示例。如果您正苦于以下问题:C# IVsTextView.GetWordExtent方法的具体用法?C# IVsTextView.GetWordExtent怎么用?C# IVsTextView.GetWordExtent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVsTextView的用法示例。


在下文中一共展示了IVsTextView.GetWordExtent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDeclarations

        // ParseReason.CompleteWord
        // ParseReason.DisplayMemberList
        // ParseReason.MemberSelect
        // ParseReason.MemberSelectAndHilightBraces
        /*
         * Visual Studio calls this function to get possible declarations and completions
         */
        public override Microsoft.VisualStudio.Package.Declarations GetDeclarations(IVsTextView view, int line, int col, TokenInfo info, ParseReason reason)
        {
            string currentCommand;
            string startChar;
            //int hResult = view.GetTextStream(line, info.StartIndex, line, info.EndIndex, out currentCommand);
            //int hResult = view.GetTextStream(line, info.StartIndex, line, col, out currentCommand);
            TextSpan[] ts = new TextSpan[1];
            ts[0] = new TextSpan();
            view.GetWordExtent(line, info.StartIndex, (uint)(WORDEXTFLAGS.WORDEXT_FINDTOKEN), ts);
            int hResult = view.GetTextStream(line, ts[0].iStartIndex, line, ts[0].iEndIndex, out currentCommand);
            if (ts[0].iStartIndex > 0)
            {
                view.GetTextStream(line, ts[0].iStartIndex - 1, line, ts[0].iStartIndex, out startChar);
                if (startChar.Equals("#"))
                    currentCommand = startChar;
            }

            ((HLSLResolver)resolver)._source = (HLSLSource)_source;
            if (_source.IsCompletorActive)
                return _source.CompletionSet.Declarations;

            IList<HLSLDeclaration> declarations;
            switch (reason)
            {
                case ParseReason.CompleteWord:
                    declarations = resolver.FindCompletions(currentCommand, line, col);
                    break;
                case ParseReason.DisplayMemberList:
                case ParseReason.MemberSelect:
                case ParseReason.MemberSelectAndHighlightBraces:
                    if(currentCommand.Equals("."))
                        declarations = resolver.FindMembers(parseResult, line, col);
                    else
                        declarations = resolver.FindCompletions(currentCommand, line, col);
                    break;
                default:
                    throw new ArgumentException("reason");
            }

            return new HLSLDeclarations(declarations);
        }
开发者ID:JohnLouderback,项目名称:shadersense,代码行数:48,代码来源:HLSLAuthoringScope.cs

示例2: GetWordExtent

 private String GetWordExtent(IVsTextView pView, int iLine, int iCol)
 {
     TextSpan[] span = new TextSpan[1];
     // get highlighted word
     string word = "";
     var currentLine = _fileContentCache[pView][iLine];
     if (!string.IsNullOrWhiteSpace(currentLine))
     {
         try
         {
             pView.GetWordExtent(iLine, iCol, (uint)(WORDEXTFLAGS.WORDEXT_CURRENT | WORDEXTFLAGS.WORDEXT_FINDWORD), span);
             pView.GetTextStream(iLine, span[0].iStartIndex, iLine, span[0].iEndIndex, out word);
         }
         catch (Exception ex)
         {
             // Can happen during copy+paste events of large text...
         }
     }
     return word;
 }
开发者ID:chrisparnin,项目名称:ganji,代码行数:20,代码来源:NavigateListener.cs


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