public static ITreeNode GetTreeNodeForStep(ICSharpFile file, string typeName, string methodName, int methodOccurrence, string text, int textOccurrence) { IEnumerable <ITreeNode> treeNodeList; string navText; var tOccIndex = 0; var mOccIndex = 0; if (text != null) { navText = text; if (textOccurrence > 0) { tOccIndex = textOccurrence - 1; } } else if (methodName != null) { navText = methodName; } else { navText = GetShortNameFromFqn(typeName); } if (typeName == null && methodName == null) { treeNodeList = file.EnumerateTo(file.LastChild); } else if (typeName != null && methodName != null) { //if (methodOccurrence > 0) mOccIndex = methodOccurrence - 1; var node = GetMethodNodeByFullClrName(file, typeName, methodName, methodOccurrence); if (node == null) { return(null); } treeNodeList = node.EnumerateTo(node.NextSibling); } else if (typeName != null) { var node = GetTypeNodeByFullClrName(file, typeName); if (node == null) { return(null); } treeNodeList = node.EnumerateTo(node.NextSibling); } else { return(null); } var result = (from treeNode in treeNodeList where treeNode.GetText() == navText select treeNode).AsArray(); return((result.Length > 0) && (tOccIndex <= result.Length - 1) ? result[tOccIndex] : null); }
public static ITreeNode GetTreeNodeForStep(ICSharpFile file, string typeName, string methodName, string text, int textOccurrence) { IEnumerable <ITreeNode> treeNodeList; string navText; var occIndex = 0; // TODO: provide occurence # for methods as well (for overloads) if (text != null) { navText = text; if (textOccurrence > 0) { occIndex = textOccurrence - 1; } } else if (methodName != null) { navText = methodName; occIndex = 0; } else { navText = GetShortNameFromFqn(typeName); } if (typeName == null && methodName == null) { treeNodeList = file.EnumerateTo(file.LastChild); } else if (typeName != null && methodName != null) { var node = GetMethodNodeByFullClrName(file, typeName, methodName); if (node == null) { return(null); } treeNodeList = node.EnumerateTo(node.NextSibling); } else if (typeName != null) { var node = GetTypeNodeByFullClrName(file, typeName); if (node == null) { return(null); } treeNodeList = node.EnumerateTo(node.NextSibling); } else { return(null); } var result = from treeNode in treeNodeList where treeNode.GetText() == navText select treeNode; return(result.AsArray().Length > 0 ? result.AsArray()[occIndex] : null); }
public static ITreeNode GetTypeNodeByFullClrName(ICSharpFile file, string name) { var treeNodeList = file.EnumerateTo(file.LastChild); var resultList = (from node in treeNodeList let element = GetDeclaredElement(node) let typeElement = element as ITypeElement where typeElement != null && typeElement.GetFullClrName() == name select node).ToList(); return(resultList.FirstOrDefault()); }
public static void NavigateToType(ICSharpFile file, string typeName, IShellLocks shellLocks, Lifetime lifetime) { var treeNodeList = file.EnumerateTo(file.LastChild); var targetType = (from treeNode in treeNodeList let element = GetDeclaredElement(treeNode) let typeElement = element as ITypeElement where typeElement != null where typeElement.GetFullClrName() == typeName select typeElement).FirstOrDefault(); shellLocks.ReentrancyGuard.ExecuteOrQueue("Navigate", () => { targetType.Navigate(true); }); }
public static void NavigateToMethod(ICSharpFile file, string typeName, string methodName, IShellLocks shellLocks, Lifetime lifetime) { var treeNodeList = file.EnumerateTo(file.LastChild); var methods = (from treeNode in treeNodeList let element = GetDeclaredElement(treeNode) let typeElement = element as ITypeElement where typeElement != null where typeElement.GetFullClrName() == typeName select typeElement.GetAllMethods()).FirstOrDefault(); if (methods == null) { return; } var targetMethod = methods.FirstOrDefault(method => method.ShortName == methodName); shellLocks.ReentrancyGuard.ExecuteOrQueue("Navigate", () => { targetMethod.Navigate(true); }); }