本文整理汇总了C#中IElement.GetDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.GetDeclaration方法的具体用法?C# IElement.GetDeclaration怎么用?C# IElement.GetDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.GetDeclaration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckIssuesForReferencedLocalOrField
private void CheckIssuesForReferencedLocalOrField(CheckCodeIssuesEventArgs ea, IForStatement loop, IElement lambda, IElement element)
{
if (element.ElementType == LanguageElementType.ElementReferenceExpression)
{
IElement declaration = element.GetDeclaration();
if (declaration.ElementType == LanguageElementType.Variable || declaration.ElementType == LanguageElementType.InitializedVariable)
{
if (loop.Initializers.Contains(declaration) || !declaration.IsParentedBy(loop))
{
ea.AddWarning(element.ToLanguageElement().Range, "Possible unintended closure scope misuse");
}
}
return;
}
foreach (IElement child in element.Children)
{
CheckIssuesForReferencedLocalOrField(ea, loop, lambda, child);
}
}
示例2: GetDeclaration
private static IWithParameters GetDeclaration(ScopeResolveResult resolveResult, IElement parent)
{
IWithParameters declaration = null;
if (resolveResult != null)
{
ReferenceDeclarationMapping mapping = resolveResult.GetReferenceDeclarationMapping();
if (mapping != null)
{
declaration = mapping[parent] as IWithParameters;
if (declaration == null)
declaration = parent.GetDeclaration(false) as IWithParameters;
}
}
else
declaration = parent.GetDeclaration(false) as IWithParameters;
return declaration;
}