本文整理汇总了C#中TextPoint.get_CodeElement方法的典型用法代码示例。如果您正苦于以下问题:C# TextPoint.get_CodeElement方法的具体用法?C# TextPoint.get_CodeElement怎么用?C# TextPoint.get_CodeElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextPoint
的用法示例。
在下文中一共展示了TextPoint.get_CodeElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetClosestCodeElementInFlatView
/// <summary>
/// Finds the code element in the flat view TreeView
/// that is closest to the parameter TextPoint.
/// </summary>
/// <param name="tp">The TextPoint cursor position in the source file.</param>
/// <returns>A CodeElementWrapper object.</returns>
private CodeElementWrapper GetClosestCodeElementInFlatView(TextPoint tp)
{
Debug.Assert(_viewType == ViewType.FlatView);
Debug.Assert(FilterView == CurrentTreeView);
CodeElement ce = null;
switch (_searchCriteria.ElementFilter)
{
case CodeElementType.Class:
ce = tp.get_CodeElement(vsCMElement.vsCMElementClass);
break;
case CodeElementType.Union:
ce = tp.get_CodeElement(vsCMElement.vsCMElementUnion);
break;
case CodeElementType.Delegate:
ce = tp.get_CodeElement(vsCMElement.vsCMElementDelegate);
break;
case CodeElementType.Method:
ce = tp.get_CodeElement(vsCMElement.vsCMElementFunction);
break;
case CodeElementType.Property:
ce = tp.get_CodeElement(vsCMElement.vsCMElementProperty);
break;
case CodeElementType.Variable:
ce = tp.get_CodeElement(vsCMElement.vsCMElementVariable);
break;
case CodeElementType.Enumeration:
ce = tp.get_CodeElement(vsCMElement.vsCMElementEnum);
break;
case CodeElementType.All:
return GetClosestCodeElementInTreeView(FilterView, tp);
}
// Find which nodes in the flat view have this code element.
if (ce != null)
{
for (int i = 0; i <= FilterView.Nodes.Count - 1; i++)
{
if (FilterView.Nodes[i].Text == CodeModelHelpers.GetDisplayNameFromCMElement(ce))
{
return (CodeElementWrapper)FilterView.Nodes[i];
}
}
}
return null;
}
示例2: CreateNodeFactoryFromTextPoint
internal static CodeElementNodeFactory CreateNodeFactoryFromTextPoint(TextPoint textPoint,
vsCMElement codeElementType)
{
var codeElement = textPoint.get_CodeElement(codeElementType);
if (null == codeElement)
{
return null;
}
var factory = CreateNodeFactoryFromCodeElement(codeElement);
return factory;
}