private static AssignmentExpression GetAssignmentExpression(LanguageElement element) { // Rory is right. ea.Element will not always be equal to CodeRush.Source.Active. // Also, CodeProviders can be called programmatically, targeting other places. // Rory recommends always exhausting the ea.Xxxxxxx methods and properties, before looking elsewhere. AssignmentExpression assignmentExpression = element as AssignmentExpression; if (assignmentExpression == null) assignmentExpression = element.GetParent(LanguageElementType.AssignmentExpression) as AssignmentExpression; return assignmentExpression; }
// Private implementation private Property GetActiveProperty(LanguageElement element) { if (element == null) return null; Property property = element as Property; if (property == null) property = element.GetParent(LanguageElementType.Property) as Property; return property; }
private static AssignmentExpression GetAssignmentExpression(LanguageElement element) { // Rory is right. ea.Element will not always be equal to CodeRush.Source.Active. // Also, CodeProviders can be called programmatically, targeting other places. // Rory recommends always exhausting the ea.Xxxxxxx methods and properties, before looking elsewhere. AssignmentExpression assignmentExpression = element as AssignmentExpression; if (assignmentExpression == null) { assignmentExpression = element.GetParent(LanguageElementType.AssignmentExpression) as AssignmentExpression; } return(assignmentExpression); }
private Property GetActiveProperty(LanguageElement element) { if (element == null) { return(null); } Property property = element as Property; if (property == null) { property = element.GetParent(LanguageElementType.Property) as Property; } return(property); }
private Member GetActiveMember(LanguageElement element) { if (element == null) { return null; } Member member = element as Member; if (member != null) { LanguageElementType type = member.ElementType; if (((type == LanguageElementType.Method) || (type == LanguageElementType.Property)) || (type == LanguageElementType.Event)) { return member; } } return (element.GetParent(LanguageElementType.Method, new LanguageElementType[] { LanguageElementType.Property, LanguageElementType.Event }) as Member); }
private Member GetActiveMember(LanguageElement element) { if (element == null) { return(null); } Member member = element as Member; if (member != null) { LanguageElementType type = member.ElementType; if (((type == LanguageElementType.Method) || (type == LanguageElementType.Property)) || (type == LanguageElementType.Event)) { return(member); } } return(element.GetParent(LanguageElementType.Method, new LanguageElementType[] { LanguageElementType.Property, LanguageElementType.Event }) as Member); }