本文整理汇总了C#中LanguageElement.GetDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C# LanguageElement.GetDeclaration方法的具体用法?C# LanguageElement.GetDeclaration怎么用?C# LanguageElement.GetDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LanguageElement
的用法示例。
在下文中一共展示了LanguageElement.GetDeclaration方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMethodCall
private bool IsMethodCall(LanguageElement Item)
{
if (Item is MethodCall)
{
// Calls which discard any returned value.
return true;
}
if (Item is MethodCallExpression)
{
// Method calls which are themselves passed to other methods.
return true;
}
// C# requires parenthesis for it's method calls. This makes identifying method calls very easy.
// Other languages (VB.Net for example) do not share this requirement.
// References to Methods and Variables end up looking exactly the same to the parser.
// ElementReferenceExpressions may potentially refer to Methods.
if (!(Item is ElementReferenceExpression))
return false;
// This forces us to locate the declaration of the item the reference points at.
// Once there we can confirm if the Item in question is a Method.
if (!(Item.GetDeclaration() is IMethodElement))
return false;
// Finally we need to confirm that the method reference is in fact a call.
// We do this by eliminating the other purpose of a method reference: That of a Method pointer.
// No parent AddressOf operator. Therefore not a method pointer.
if (!(Item.Parent is AddressOfExpression))
return true;
return false;
}
示例2: IsValidSelection
protected override bool IsValidSelection(LanguageElement element, TextViewSelection selection)
{
if ((element == null) || (selection == null))
return false;
if (selection.Exists)
return false;
var creationExpression = element.Parent as ObjectCreationExpression;
return creationExpression != null && element.GetDeclaration() == null;
}
示例3: GetElementDeclaration
private static IElement GetElementDeclaration(LanguageElement element)
{
IElement declaration;
if (elementIsReference(element.ElementType))
declaration = element.GetDeclaration();
else
declaration = element;
if (declaration != null && elementTypeIsSupported(declaration.ElementType))
return declaration;
return null;
}
示例4: IsValidReferenceAndQualifier
private bool IsValidReferenceAndQualifier(LanguageElement activeRerence, out ITypeElement callerType, out Expression qualifier)
{
qualifier = null;
callerType = null;
if (!(activeRerence is IHasQualifier))
return false;
// should be undeclared....
IElement declaration = activeRerence.GetDeclaration(false);
if (declaration != null)
return false;
qualifier = (activeRerence as IHasQualifier).Qualifier;
if (qualifier is MethodReferenceExpression)
qualifier = (qualifier as MethodReferenceExpression).Qualifier;
if (qualifier == null)
return false;
callerType = qualifier.Resolve(ParserServices.SourceTreeResolver) as ITypeElement;
if (callerType == null)
return false;
return true;
}
示例5: IsClass
/// <summary>
/// Is class
/// </summary>
private static bool IsClass(LanguageElement element)
{
IElement declaration = element.GetDeclaration();
return (declaration as IClassElement) != null;
} // IsClass
示例6: GetValidDeclaration
private static IWithParameters GetValidDeclaration(LanguageElement originalCall)
{
if (originalCall == null)
return null;
IElement declaration = originalCall.GetDeclaration(false);
if (declaration is IMethodElement)
return declaration as IWithParameters;
IEventElement eventElement = declaration as IEventElement;
if (eventElement != null && eventElement.Type != null)
{
return eventElement.Type.Resolve(ParserServices.SourceTreeResolver) as IWithParameters;
}
return null;
}
示例7: GetTypeDeclarationForElement
private TypeDeclaration GetTypeDeclarationForElement(LanguageElement element)
{
return element.GetDeclaration() as TypeDeclaration;
}