本文整理汇总了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);
}
示例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;
}