本文整理汇总了C#中IStatement.GetContainingTypeMemberDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C# IStatement.GetContainingTypeMemberDeclaration方法的具体用法?C# IStatement.GetContainingTypeMemberDeclaration怎么用?C# IStatement.GetContainingTypeMemberDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStatement
的用法示例。
在下文中一共展示了IStatement.GetContainingTypeMemberDeclaration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckAssignment
/// <summary>
/// Inserts the assert.
/// </summary>
/// <param name="element">
/// The element.
/// </param>
/// <param name="anchor">
/// The anchor.
/// </param>
/// <param name="name">
/// The name.
/// </param>
private void CheckAssignment(IElement element, IStatement anchor, string name)
{
var functionDeclaration = anchor.GetContainingTypeMemberDeclaration() as IMethodDeclaration;
if (functionDeclaration == null)
{
return;
}
var body = functionDeclaration.Body;
if (body == null)
{
return;
}
var factory = CSharpElementFactory.GetInstance(element.GetPsiModule());
var csharpElement = element as ICSharpElement;
if (csharpElement == null)
{
return;
}
var code = string.Format("if({0} == null) {{ }}", name);
var statement = factory.CreateStatement(code);
var result = body.AddStatementAfter(statement, anchor);
var range = result.GetDocumentRange();
var codeFormatter = new CodeFormatter();
codeFormatter.Format(this.Solution, range);
}